//
// Run the tests
//
TVerdict CCmdTestMultipleWait::doTestStepL()
	{
	CreateDummyDeferredListL();
	SsmCommandFactory::DelegateTo(this);
	// common BIC tests
	__UHEAP_MARK;
	TRAPD(err, doTestNewLWithGoodDataL());
	TEST(err == KErrNone);
	__UHEAP_MARKEND;

	__UHEAP_MARK;
	TRAP(err, doTestNewLWithBadDataL());
	TEST(err == KErrNone);
	__UHEAP_MARKEND;

	__UHEAP_MARK;
	TRAP(err, doTestInternalizeLWithGoodDataL());
	TEST(err == KErrNone);
	__UHEAP_MARKEND;

	__UHEAP_MARK;
	TRAP(err, doTestInternalizeLWithBadDataL());
	TEST(err == KErrNone);
	__UHEAP_MARKEND;

	__UHEAP_MARK;
	TRAP(err, doTestResourceReaderWithGoodDataL());
	TEST(err == KErrNone);
	__UHEAP_MARKEND;

	__UHEAP_MARK;
	TRAP(err, doTestResourceReaderWithMissingDataL());
	TEST(err == KErrNone);
	__UHEAP_MARKEND;

	__UHEAP_MARK;
	TRAP(err, doTestResourceReaderWithBadDataL());
	TEST(err == KErrNone);
	__UHEAP_MARKEND;

	__UHEAP_MARK;
	TRAP(err, doTestCommandTypeL());
	TEST(err == KErrNone);
	__UHEAP_MARKEND;
	
	__UHEAP_MARK;
	TRAP(err, doTestCmdFailureIgnoreSeverityL());
	TEST(err == KErrNone);
	__UHEAP_MARKEND;

	__UHEAP_MARK;
	TRAP(err, doTestCmdFailureHighSeverityL());
	TEST(err == KErrNone);
	__UHEAP_MARKEND;

	__UHEAP_MARK;
	TRAP(err, doTestCancelCmdIgnoreSeverityL());
	TEST(err == KErrNone);
	__UHEAP_MARKEND;

	__UHEAP_MARK;
	TRAP(err, doTestCancelCmdHighSeverityL());
	TEST(err == KErrNone);
	__UHEAP_MARKEND;

	return TestStepResult();
	}
Exemplo n.º 2
0
/** Creates a new setting with a floating-point value.
@param aKey New setting key.
@param aValue Setting value.
@return
	KErrNone if successful,
	KErrAlreadyExists if a setting with that key already exists
	plus other system-wide error codes.
@post
	Transactions fail on all error conditions.
	Outside transactions: on success the new setting is persistent,
	on failure the repository is unmodified.
@capability Dependent Caller must satisfy the write access policy of that key in the repository.
*/
EXPORT_C TInt CRepository::Create(TUint32 aKey, const TReal& aValue)
	{
	TRAPD(err,iImpl->CreateSettingL(aKey,aValue,NULL));
	return err;
	}
Exemplo n.º 3
0
/** Deletes all the settings that exist and match the specification:
	(key & mask) == (partialKey & mask)
Partial key is guaranteed to be masked before use.
Examples of use:
- To delete a single key.
	Delete(key, 0xFFFFFFFF, errorKey);
- To delete all keys from 0 to 0xFF:
	Delete(0, 0xFFFFFF00, errorKey);
	(digits from 0 to 0xFF would be ignored if given in the partial key)
- To delete all keys matching 0x5B??3A?6:
	Delete(0x5B003A06, 0xFF00FF0F, errorKey);

@param aPartialKey
	Contains a bit pattern that all the keys must at least partially
	match.
@param aMask
	Has bits set for all the bits in aPartialKey that must match the keys being deleted.
@param aErrorKey If the delete operation fails this contains the key involved in the
	failure, or aPartialKey or KUnspecifiedKey if it could not be attributed to any key
@return
	KErrNone if successful,
	KErrNotFound if no items were found in the partial key range.
	plus other system-wide error codes.
@post
	Transactions fail on all error conditions except KErrNotFound
	Outside transactions: on success the changes are persistent, on failure the
	repository is unmodified.
@capability Dependent Caller must satisfy the write policies of all settings found in the
					  partial key range.
*/	
EXPORT_C TInt CRepository::Delete(TUint32 aPartialKey, TUint32 aMask, TUint32& aErrorKey)
	{
	TRAPD(ret,iImpl->DeleteRangeL(aPartialKey,aMask,aErrorKey));
	return ret;
	}
Exemplo n.º 4
0
// -----------------------------------------------------------------------------
// CDRMHelperServer::CheckPermission().
// This function check timebased contraints for a permission
// -----------------------------------------------------------------------------
//
void CDRMHelperServer::CheckPermission(
                CDRMPermission* aPermission ,
                const TUint8& aPermType ,
                TTimeBased& aTime ,
                TTimeIntervalSeconds& aInterval,
                const RPointerArray<HBufC8>& aIndividual )
    {
#ifdef _DRM_TESTING
    TRAPD(err,WriteL(_L8("CheckPermission")));
#endif

    CDRMConstraint* c = NULL;
    ContentAccess::TIntent type = MapPermissionType(aPermType);
    TTime temp;
    temp.HomeTime();
    TUint32 reason( 0 );
    TBool validity = EFalse;

    aTime.SetStart(Time::MinTTime());
    aTime.SetEnd(Time::MinTTime());
    if (aPermission->iAvailableRights & type)
        {
        c = aPermission->ConstraintForIntent(type);
        if (!c)
            {
            return;
            }
        if (aPermission->iAvailableRights & ERightsTopLevel)
            {
            CDRMConstraint* temp = aPermission->TopLevelConstraint();
            c->Merge(*temp);
            }

        validity = c->Valid( temp, aIndividual, reason );
        if ( !validity && reason & EConstraintIndividual )
            {
            return;
            }
        if (c->iActiveConstraints==EConstraintNone ||
            c->iActiveConstraints == EConstraintIndividual )
            {
            aTime.SetStart(Time::MinTTime());
            aTime.SetEnd(Time::MaxTTime());
            return;
            }
        if (c->iActiveConstraints & EConstraintInterval)
            {
            if (c->iIntervalStart == Time::NullTTime())
                {
                aInterval = c->iInterval;
                }
            else
                {
                aTime.SetStart(c->iIntervalStart);
                aTime.SetEnd(c->iIntervalStart + c->iInterval);
                }
            }
        if (c->iActiveConstraints & EConstraintStartTime)
            {
            if ( !(c->iActiveConstraints & EConstraintInterval ) )
                {
                aTime.SetStart( c->iStartTime );
                if (c->iActiveConstraints&EConstraintEndTime)
                    {
                    aTime.SetEnd( c->iEndTime );
                    }
                else
                    {
                    aTime.SetEnd( Time::MaxTTime() );
                    }
                }
            else
                {
                aTime.SetStart( aTime.StartTime() > c->iStartTime ? aTime.StartTime() : c->iStartTime );
                if (c->iActiveConstraints&EConstraintEndTime)
                    {
                    aTime.SetEnd( aTime.EndTime() < c->iEndTime ? aTime.EndTime() : c->iEndTime );
                    }
                }
            }
        else
            {
            if (c->iActiveConstraints==EConstraintEndTime)
                {
                if ( !(c->iActiveConstraints & EConstraintInterval ) )
                    {
                    aTime.SetStart(Time::MinTTime());
                    aTime.SetEnd( c->iEndTime );
                    }
                else
                    {
                    aTime.SetEnd( aTime.EndTime() < c->iEndTime ? aTime.EndTime() : c->iEndTime );
                    }
                }
            }
        }
#ifdef _DRM_TESTING
    TRAP(err,WriteL(_L8("Start Time:")));
    TRAP(err,WriteTimeL(aTime.StartTime()));
    TRAP(err,WriteL(_L8("End Time:")));
    TRAP(err,WriteTimeL(aTime.EndTime()));
#endif
    }
Exemplo n.º 5
0
void CGroupViewTester::HandleContactViewEvent(const CContactViewBase& aView,const TContactViewEvent& aEvent)
	{
	//LOGGING///////////////////////////////////////////////////////////////////////////////////
				if(&aView == iLocalView)
					test.Printf(_L("LocalView "));
				else if(&aView == iGroupViewOne)
					test.Printf(_L("GroupViewOne "));
				else if(&aView == iGroupViewOneByName)
					test.Printf(_L("GroupViewOneByName "));
				else if(&aView == iGroupViewOneNotInGroup)
					test.Printf(_L("GroupViewOneNotInGroup "));
				else if(&aView == iGroupViewUnfiled)
					test.Printf(_L("GroupViewUnfiled "));
				else
					test.Printf(_L("Er, none of the known views... "));

				switch (aEvent.iEventType)
					{
					case TContactViewEvent::EUnavailable:
						test.Printf(_L("EUnavailable\n"));
						break;
					case TContactViewEvent::EReady:
						test.Printf(_L("EReady\n"));
						break;
					case TContactViewEvent::ESortOrderChanged:
						test.Printf(_L("ESortOrderChanged\n"));
						break;
					case TContactViewEvent::ESortError:
						test.Printf(_L("ESortError\n"));
						break;
					case TContactViewEvent::EServerError:
						test.Printf(_L("EServerError\n"));
						break;
					case TContactViewEvent::EIndexingError:
						test.Printf(_L("EIndexingError\n"));
						break;
					case TContactViewEvent::EItemAdded:
						test.Printf(_L("EItemAdded\n"));
						break;
					case TContactViewEvent::EItemRemoved:
						test.Printf(_L("EItemRemoved\n"));
						break;
					case TContactViewEvent::EGroupChanged:
						test.Printf(_L("EGroupChanged\n"));
						break;
					default:
						test.Printf(_L("Er, none of the known event types... "));
						break;
					}
	////////////////////////////////////////////////////////////////////////////////////////////
	
	switch (iCurrentTest)
		{
		case ECreateLocalView:
			test(iLocalView==&aView);
			test(aEvent.iEventType==TContactViewEvent::EReady);
			break;
		case EExerciseLocalView:
			test(ETrue);
			break;
		case ECreateGroupOneView:
			test(iGroupViewOne==&aView);
			test(aEvent.iEventType==TContactViewEvent::EReady);
			break;
		case ETestGroupOneView:
			test(EFalse);
			break;
		case ECreateGroupOneViewByName:
			test(iGroupViewOneByName==&aView);
			test(aEvent.iEventType==TContactViewEvent::EReady);
			break;
		case ETestGroupOneViewByName:
			test(EFalse);
			break;
		case ECreateGroupOneViewNotInGroup:
			test(iGroupViewOneNotInGroup==&aView);
			test(aEvent.iEventType==TContactViewEvent::EReady);
			break;
		case ETestGroupOneViewNotInGroup:
			test(EFalse);
			break;
		case EAllViewsOutOfBoundsAccess:
			test(EFalse);
			break;
		case ECreateUnfiledGroupView:
			test(iGroupViewUnfiled==&aView);
			test(aEvent.iEventType==TContactViewEvent::EReady);
			break;
		case ETestUnfiledGroupView:
			break;
		case ETestUnfiledGroupAddition:
			{
			// No point testing for each and every notification: the test will
			// pass for all notifications.
			if (iNumNotificationExpected > 1)
				{
				break;
				}
			// Test that adding contact which formed part of iGroupViewUnfiled
			// to iGroupOne caused update of iGroupViewUnfiled such that the
			// contact no longer forms part of iGroupViewUnfiled (i.e. by adding
			// the contact to the group it is no longer unfiled is not a member
			// of the unfiled view).
			TInt ret(KErrNone);
			TRAPD(err1, ret = iGroupViewUnfiled->FindL(KNumContacts) );
			test(err1 == KErrNone && ret == KErrNotFound);
			// Double check - make sure the number of items in the unfiled
			// group view agrees with the number of unfiled items reported by
			// the database.
			TInt groupViewUnfiledCount(0);
			TRAPD(err2, groupViewUnfiledCount = iGroupViewUnfiled->CountL() );
			CContactIdArray* dbUnfiled = NULL;
			TRAPD(err3, dbUnfiled = iDb.UnfiledContactsL() );
			test(err2 == KErrNone && err3 == KErrNone && groupViewUnfiledCount==dbUnfiled->Count() );
			delete dbUnfiled;
			}
			break;
		case ENumTests:
		default:
			test(EFalse);
			break;
		}
	if (--iNumNotificationExpected <= 0)
		{
		iNumNotificationExpected=0;
		NextTest();
		}
	}
Exemplo n.º 6
0
//Encrypted Data
TVerdict CTPKCS7EncryptedDataTest::doTestStepL()
	{

	if (TestStepResult() != EPass)
		{
		return TestStepResult();
		}
		
	TInt reason;
	// Read from INI file.
	GetIntFromConfig(ConfigSection(),_L("Reason"),reason);

	//Is Valid	
  	TBool expectedValid;
  	TBool checkValid;
      
  	checkValid = GetBoolFromConfig(ConfigSection(),_L("IsValid"), expectedValid);
 	
	 __UHEAP_MARK;
    CPKCS7ContentInfo *contentInfo = NULL;
	TRAPD (err, contentInfo = CPKCS7ContentInfo::NewL(iRawData->Des()));
	CleanupStack::PushL(contentInfo);
    if(err == KErrNone)
		{
	     
		CPKCS7EncryptedDataObject* p7 = NULL;
		TInt type = contentInfo->ContentType();
		if( contentInfo->ContentType() == CPKCS7ContentInfo::EContentTypeEncryptedData)
			{
			TRAPD (err, p7 = CPKCS7EncryptedDataObject::NewL(*contentInfo));
		    CleanupStack::PushL(p7);
		    __UHEAP_MARK;

			if (checkValid)
  				{
  				if(!expectedValid && err == reason)
  		 			{ 
					CleanupStack::PopAndDestroy(2,contentInfo);//p7, contentInfo
  		 			return TestStepResult();
  		 			}
  				if(!expectedValid && contentInfo->ContentType() == 1)	
           			{
           			CleanupStack::PopAndDestroy(2,contentInfo);//p7, contentInfo
           		 	return TestStepResult();
           			}
  				}

			if (err != KErrNone)
				{
				SetTestStepResult(EFail);
				ERR_PRINTF2(_L("Got %d building PKCS7 object"), err);
				}
    	
			//CONTENT TYPE
			CPKCS7EncryptedDataObject::TContentType contentType = p7->ContentType();
			if(contentType != CPKCS7EncryptedDataObject::EPkcs7Data)
    			{
     			SetTestStepResult(EFail);
     			ERR_PRINTF1(_L("ContentType does not match"));
     			CleanupStack::PopAndDestroy(3,contentInfo);//expectedContentType, p7, contentInfo
     			return TestStepResult();	
     			}
			 else
     			{
     			INFO_PRINTF1(_L("ContentType matches"));	
     			}
	  
			//ENCRYPTEDCONTENT DATA
			const TDesC8& contentData = p7->EncryptedContentInfoData();
			if(contentData.Compare(*iContentData) != 0)
				{
	   			SetTestStepResult(EFail);
	   			ERR_PRINTF1(_L("EncryptedContentData does not match"));
	   			CleanupStack::PopAndDestroy(2,contentInfo);	//p7, contentInfo
	   			return TestStepResult();
	  			}
			else
	  			{
	  			INFO_PRINTF1(_L("EncryptedContentData matches")); 	
	  			}
		    
	  
			//SALT
			const CPBEncryptParms& encryptParams = p7->EncryptParams();
			if((encryptParams.Salt()).Compare(*iSaltValue) != 0)
				{
	   			SetTestStepResult(EFail);
	   			ERR_PRINTF1(_L("Salt Value does not match"));	
	   			CleanupStack::PopAndDestroy(2, contentInfo);//p7,contentInfo
	   			return TestStepResult();
	  			}
			else
				{
				INFO_PRINTF1(_L("Salt Value matches"));	
				}  	
	        
	
			//ITERATION COUNT
			TBool checkIteration;
			TInt expectedIterationCount;
	
			checkIteration = GetIntFromConfig(ConfigSection(),_L("Iteration"), expectedIterationCount);
			if(checkIteration)
				{
	   			if(encryptParams.Iterations() != expectedIterationCount)
	   				{
	   				SetTestStepResult(EFail);
	   				ERR_PRINTF1(_L("Iterations does not match"));
	   				CleanupStack::PopAndDestroy(2, contentInfo);//p7, contentInfo
	   				return TestStepResult();	
	   				}
	   			else
	   				{
	   				INFO_PRINTF1(_L("Iteration matches")); 
	   				}
	  			}		
	
			//CIPHER
			TBool checkCipher;
			TPtrC expectedCipher;
			TPBECipher cipherValue = (TPBECipher) -1;//assign to impossible value
	
			checkCipher = GetStringFromConfig(ConfigSection(),_L("Algorithm"),  expectedCipher);
		
			if(checkCipher)
				{
				if(expectedCipher.Compare(_L("pbeWithSHA1And40BitRC2_CBC")) == 0)
	   	 			{
	   	  			cipherValue = ECipherRC2_CBC_40_5;
	     			}
				else if(expectedCipher.Compare(_L("pbeWithSHA1And128BitRC4")) == 0)
	   	 			{
	   	  			cipherValue = ECipherARC4_128;
	     			}
	            else if(expectedCipher.Compare(_L("pbeWithSHA1AndDES-CBC")) == 0)
	   	 			{
	   	  			cipherValue = ECipherDES_CBC;
	     			}
	     		else if(expectedCipher.Compare(_L("pbeWithSHAAnd3_KeyTripleDES_CBC")) == 0)
	   	 			{
	   	  			cipherValue = ECipher3DES_CBC;
	     			}
	     		else if(expectedCipher.Compare(_L("pbeWithSHAAnd2-KeyTripleDES-CBC"))==0)
	     			{
	     			cipherValue = ECipher2Key3DES_CBC;	
	     			}
	     		else if(expectedCipher.Compare(_L("pbeWithSHA1And40BitRC4")) == 0)
	   	 			{
	   	  			cipherValue = ECipherARC4_40;
	     			}
	     		else if(expectedCipher.Compare(_L("pbewithSHAAnd128BitRC2CBC")) == 0)
	   	 			{
	   	  			cipherValue = ECipherRC2_CBC_128_16;
	     			}
	     		else if(expectedCipher.Compare(_L("pbeWithSHA1AndRC2_CBC")) == 0)
	     			{
	     			cipherValue = ECipherRC2_CBC_40;
	     			}
	     					
	   			if(encryptParams.Cipher() != cipherValue)
	     			{
	     			SetTestStepResult(EFail);
	     			ERR_PRINTF1(_L("Cipher does not match"));
	     			CleanupStack::PopAndDestroy(3, contentInfo);//expectedCipher,p7,contentInfo
	     			return TestStepResult();	
	     			} 
				else 
	    			{
	   				INFO_PRINTF1(_L("Cipher matches")); 
	    			}
				}
					
			if(contentData.Length() != 0)
				{
				//Decryption
				TBool checkPassword;
				TPtrC password;
				
				checkPassword = GetStringFromConfig(ConfigSection(),_L("Password"), password);
					
				if(checkPassword)
					{
			    	HBufC8* plainText = p7->DecryptDataL(password);
			    	delete plainText;
			    	SetTestStepResult(EPass);
	  				} 
				}
	  		CleanupStack::PopAndDestroy(p7);
            }
        //If ContentType is not Encrypted Data
        else
        	{
        		
        	if(checkValid)
          		{
          		if(!expectedValid && err == reason)
 		 			{
  		 			CleanupStack::PopAndDestroy(contentInfo);
  		 			return TestStepResult();
  		 			}
          		else
          			{
          			SetTestStepResult(EFail);	
          			}
          		}

       		}
		}
	else if(err != reason)
		{
		SetTestStepResult(EFail);
		}
	CleanupStack::PopAndDestroy(contentInfo);
	__UHEAP_MARKEND;
	
	return TestStepResult();
	}
Exemplo n.º 7
0
// -----------------------------------------------------------------------------
// CSIPProfile::GetParameter
// -----------------------------------------------------------------------------
//	
EXPORT_C TInt CSIPProfile::GetParameter(TUint32 aParam, TDesC8 const *& aVal) const
	{
	switch (aParam)
		{
		case KSIPProviderName:
			{
			const TDesC8& val= iSIPProfile->ProviderName();
			aVal = &val;
			break;
			}
		case KSIPUserAor:
			{
			const TDesC8& val = iSIPProfile->AOR();
			aVal = &val;
			break;
			}
		case KSIPPrivateIdentity:
			{
			const TDesC8& val = iSIPProfile->PrivateIdentity();
			aVal = &val;
			break;
			}
		case KSIPNegotiatedSecurityMechanism:
			{
			if(iSIPProfileRegistry)
				{
				TRAPD(err,iSIPProfileRegistry->NegotiatedSecurityMechanismL(*iSIPProfile));
				if (err != KErrNone)
					{
					return err;
					}
				}
			const TDesC8& val = iSIPProfile->NegotiatedSecurityMechanism();
			aVal = &val;
			break;
			}
		case KSIPProfileId:
		case KSIPAccessPointId:
		case KSIPSigComp:
		case KSIPSecurityNegotiation:
		case KSIPAutoRegistration:
		case KSIPProfileRegistered:
		case KSIPRegisteredAors:
		case KSIPDefaultProfile:
		case KSIPContactHeaderParams:
		case KSIPRegistrar:
		case KSIPOutboundProxy:
		case KSIPDigestUserName:
		case KSIPDigestRealm:
		case KSIPServerAddress:
		case KSIPDigestPassword:
			{
			return KErrNotFound;
			}
		default:
			{
			return iSIPProfile->ExtensionParameter(aParam, aVal);
			}
		}
	return KErrNone;
	}	
// ----------------------------------------------------------------------------
// CSysApFeatureManager::ConstructL() 
// ----------------------------------------------------------------------------
void CSysApFeatureManager::ConstructL()
    {
    TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL()") ) );
    FeatureManager::InitializeLibL();
    iFeatMgrActive = ETrue;
    
    iSimSupported = FeatureManager::FeatureSupported( KFeatureIdSimCard );
    TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: SIM card supported=%d"), iSimSupported ) );

    iOfflineModeSupported = FeatureManager::FeatureSupported( KFeatureIdOfflineMode );
    TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: Offline mode supported=%d"), iOfflineModeSupported ) );
    
    iCoverDisplaySupported = FeatureManager::FeatureSupported( KFeatureIdCoverDisplay );
    TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: Cover display supported=%d"), iCoverDisplaySupported ) );
    
    iGripNotSupported = FeatureManager::FeatureSupported( KFeatureIdKeypadNoSlider );
    TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: iGripNotSupported=%d"), iGripNotSupported ) );
    
    iLocationPrivacySupported = FeatureManager::FeatureSupported( KFeatureIdPrivacyFramework );
    TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: Location Privacy supported=%d"), iLocationPrivacySupported ) );

    iMMCSupported = FeatureManager::FeatureSupported( KFeatureIdMmc );
    TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: MMC supported=%d"), iMMCSupported ) );
        
    iMMCHotSwapSupported = FeatureManager::FeatureSupported( KFeatureIdMmcHotswap );
    TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: MMC HotSwap supported=%d"), iMMCHotSwapSupported ) );
    
    iStarterExtensionsSupported = FeatureManager::FeatureSupported( KFeatureIdExtendedStartup );
    TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: Starter Extensions supported=%d"), iStarterExtensionsSupported ) );

    iCameraSupported = FeatureManager::FeatureSupported( KFeatureIdCamera );
    TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: Camera supported=%d"), iCameraSupported ) );

    iBtSupported = FeatureManager::FeatureSupported( KFeatureIdBt );
    TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: Bluetooth supported=%d"), iBtSupported ) );

    iLockSupported = FeatureManager::FeatureSupported( KFeatureIdMmcLock );
    TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: Memory card lock supported=%d"), iLockSupported ) );
    
    iEject = FeatureManager::FeatureSupported( KFeatureIdMmcEject );
    TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: Memory card sw eject supported=%d"), iEject ) );
    
    iPowerSaveSupported = FeatureManager::FeatureSupported( KFeatureIdPowerSave );
    TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: Power save supported=%d"), iPowerSaveSupported ) );

    iNoPowerKeySupported = FeatureManager::FeatureSupported( KFeatureIdNoPowerkey );
    TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: No power key supported=%d"), iNoPowerKeySupported ) );
    
//    iFmTxSupported = FeatureManager::FeatureSupported( KFeatureIdFmtx );
//    TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: FM TX supported=%d"), iFmTxSupported ) );

//    iPenEnabled = AknLayoutUtils::PenEnabled();
    TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: Pen enabled=%d"), iPenEnabled ) );
    
    iVmbxCallDivertIconSupported = FeatureManager::FeatureSupported( KFeatureIdVmbxCallDivertIcon );
    TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: VMBX call divert icon supported=%d"), iVmbxCallDivertIconSupported ) );
    
    iTouchUnlockStrokeSupported = FeatureManager::FeatureSupported( KFeatureIdFfTouchUnlockStroke );
    TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: Touch unlock stroke supported=%d"), iTouchUnlockStrokeSupported ) );
    
//    iFmTxRdsTextSupported = FeatureManager::FeatureSupported( KFeatureIdFfFmtxRdsText );
//    TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: FM TX RDS-TEXT supported=%d"), iFmTxRdsTextSupported ) );
    
    CRepository* repository = NULL;
    
    TRAPD( err, repository = CRepository::NewL( KCRUidCoreApplicationUIsConf ) );
    
    if ( err == KErrNone )
        {
        err = repository->Get( KCoreAppUIsSysAp, iSysApFeatures );
        if ( err != KErrNone || iSysApFeatures < 0 ) // ERROR
            {
            TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: ERROR: %d, KCoreAppUIsSysAp=%d"), err, iSysApFeatures ) );
            iSysApFeatures = 0;
            }

        TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: KCoreAppUIsSysAp=%d"), iSysApFeatures ) );

        err = repository->Get( KCoreAppUIsHotSwapMemoryCardHatch, iHatchSupported );
        if ( err != KErrNone || iHatchSupported < 0 ) // ERROR
            {
            TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: ERROR: %d, KCoreAppUIsHotSwapMemoryCardHatch=%d"), err, iHatchSupported ) );
            iHatchSupported = EFalse;
            }
            
        err = repository->Get( KCoreAppUIsLockedStateLights, iLockedStateLightsSupported );
        
        if ( err != KErrNone || iLockedStateLightsSupported < 0 ) // ERROR
            {
            TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: ERROR: %d, KCoreAppUIsLightsLocked=%d"), err, iLockedStateLightsSupported ) );
            iLockedStateLightsSupported = EFalse;
            iLockedStateLightsIntensity = KHWRMDefaultIntensity;
            }
        
        if ( iLockedStateLightsSupported ) // get intensity only if configuration is supported
            {
            err = repository->Get( KCoreAppUIsLockedStateLightsIntensity, iLockedStateLightsIntensity );
            
            if ( err != KErrNone || iLockedStateLightsIntensity < KHWRMLightMinIntensity || iLockedStateLightsIntensity > KHWRMLightMaxIntensity )
                {
                TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: ERROR: %d, KCoreAppUIsLightsLockedIntensity=%d"), err, iLockedStateLightsIntensity ) );
                iLockedStateLightsIntensity = KHWRMDefaultIntensity;
                }
            }        
        }
    else
        {
        TRACES( RDebug::Print( _L("CSysApFeatureManager::ConstructL: open KCRUidCoreApplicatinUIsConf failed, err=%d"), err ) );
        }        
    
    delete repository;
    }
Exemplo n.º 9
0
/**
    Open a drive for formatting.
*/
TInt FsFormatOpen(CFsRequest* aRequest)
	{
    TDrive& drive = *aRequest->Drive();

	__PRINT1(_L("FsFormatOpen() drv:%d"), drive.DriveNumber());
    
    TInt nMountRes = drive.CheckMount();
    //-- KErrNotReady means that there is no file system mounted on this drive
    //-- KErrInUse means that there are some "disk access" objects, like RFormat or RRawDisk opened on the mount.
    if(nMountRes == KErrNotReady || nMountRes == KErrInUse) 
        {
        __PRINT1(_L("FsFormatOpen() ChkMount:%d"), nMountRes);
        return nMountRes;
        }
    
    const TFormatMode fmtMode = (TFormatMode)aRequest->Message().Int1();
    TName buf;
    TUint32 currFsNameHash = 0; //-- current file system name hash, 0 means "not set"; used during forced FS dismounting

    if((nMountRes == KErrNone) && drive.CurrentMount().LockStatus() < 0)
        {//-- the mount is locked, it has normal objects (files, directories) opened on it. 
        
        //-- if someone is interested in the list of opened files and number of opened directories, compile this code in.
        #ifdef DUMP_OPENED_OBJECTS
            DumpOpenedObjects(drive);
        #endif //DUMP_OPENED_OBJECTS


        if(!(fmtMode & EForceFormat))
            {
            __PRINT(_L("FsFormatOpen() The mount is in use"));
            return KErrInUse;
            }    

        //-- there is a special flag that tells to force media dismounting even if it has files or dirs opened.
        __PRINT(_L("FsFormatOpen() The mount is in use, forcing dismounting!"));

        //-- record currently mounted FS name hash, it may be used after forced dismounting
        drive.CurrentMount().FileSystemName(buf); //-- the iCurrentMount is alive
        currFsNameHash = TVolFormatParam::CalcFSNameHash(buf);

        //-- kill the current mount
        FsThreadManager::LockDrive(drive.DriveNumber());
        TInt nRes = drive.ForceUnmountFileSystemForFormatting();
        FsThreadManager::UnlockDrive(drive.DriveNumber());

        
        switch(nRes)
            {
            case KErrInUse: 
            __PRINT(_L("FsFormatOpen() The mount has clamps! Can't force dismount"));    
            return KErrInUse; //-- there are clamps on this drive - can't dismount

            case KErrNone:
            break;

            default:
            ASSERT(0); //-- unexpected error code
            return nRes;

            };

        if(fmtMode & EQuickFormat)
            {//-- quick format may require the normally mounted FS, make the best effrot to mount it
            nMountRes = drive.CheckMount();
            }
        else
            {//-- this will make the FS mounted by force; for full format it will be quicker
            nMountRes = KErrCorrupt;
            }

        }

	//-- if True, we will need mount (probably specific) file system by force because normal mounting has failed
    TBool bNeedForceMount = (nMountRes != KErrNone); 

    //-- find out if we have optional data structure that describes format parameter
    TUint32 newFsNameHash = 0; //-- file system name hash, may be used for selecting which file system to put onto the volume. 0 means "not specified"

    const TLDFormatInfo*    pLDFormatInfo   = NULL;
    const TVolFormatParam*  pVolFormatParam = NULL;

    __ASSERT_COMPILE(sizeof(TVolFormatParam) >= sizeof(TLDFormatInfo));
    TBuf8<sizeof(TVolFormatParam)> paramBuf;
   
    
    if(fmtMode & ESpecialFormat)  
        {   
        //-- the user has provided format parameters structure.
        //-- IPC argument #2 contains a structure: <TUint32>[optional package descriptor]
        //-- where 1st mandatory TUint32 is a pointer to format counter and the optional additional package is a data structure passed to the filesystem by the client of RFormat
        const TInt desLen = aRequest->GetDesLength(KMsgPtr2);
        ASSERT((TUint32)desLen >= sizeof(TUint32));
    
        const TInt dataPckgLen = desLen - sizeof(TUint32);

        if((TUint32)dataPckgLen > sizeof(TUint32))
            {
            aRequest->ReadL(KMsgPtr2, paramBuf); 
            }
        
        if(dataPckgLen == sizeof(TLDFormatInfo))
            {//-- the user has provided formatting parameters via TLDFormatInfo structure.
            pLDFormatInfo = (const TLDFormatInfo*)(paramBuf.Ptr() + sizeof(TUint32));
            }
        else if(dataPckgLen == sizeof(TVolFormatParam))
            {//-- it's likely to be TVolFormatParam, need to check UId to be sure.
            pVolFormatParam = (const TVolFormatParam*)(const TVolFormatParam*)(paramBuf.Ptr() + sizeof(TUint32));

            if(pVolFormatParam->iUId == TVolFormatParam::KUId)  //-- check the class UID
                {//-- this is the real TVolFormatParam object passed
                newFsNameHash = pVolFormatParam->FSNameHash();
                }
            }
        else if(dataPckgLen >0)
            {//-- parameters data structure has strange length
            return KErrArgument;
            }
    
        }

    //-------------------
    if(!newFsNameHash && currFsNameHash)
        {//-- new file system name isn't specified (default formatting), but the volume had been forcedly dismounted.
         //-- restore the original file system   
        newFsNameHash = currFsNameHash;
        }
    
    if(newFsNameHash)
        {//-- check if the specified FS is already mounted on the volume
        if(!bNeedForceMount)
            {
            drive.CurrentMount().FileSystemName(buf); //-- the iCurrentMount is alive
            }
        else
            { //-- the iCurrentMount can be NULL, use the iFsys - the real file system associated with this drive
            buf = drive.GetFSys()->Name();
            }

        const TUint32 currFSNameHash = TVolFormatParam::CalcFSNameHash(buf);
        if(currFSNameHash == newFsNameHash)
            {//-- no need to do anything, the required FS is already mounted
            newFsNameHash = 0; 
            } 
        }

    if(newFsNameHash) 
        {
        //-- the user has specified some filesystem to be mounted on the volume. Check if this FS is supported at all.
        //-- if it is supported, but some other FS is currently mounted, it will be dismounted and the new one will be forced.
        TInt nRes;
            
        for(TInt cntFS=0; ;++cntFS)
            {
            nRes = drive.FSys().GetSupportedFileSystemName(cntFS, buf); //-- enumerate possible child file systems
            
            if(nRes != KErrNone)
                return KErrNotSupported; //-- the filesystem with the given name (fsNameHash) is not supported.

            if(newFsNameHash == TVolFormatParam::CalcFSNameHash(buf))
                {//-- the filesystem with the given name (fsNameHash) is supported, but some other filesystem can be already mounted
                drive.Dismount();
                bNeedForceMount = ETrue; //-- this will force the desired FS to be mounted
                break;
                }
            }
    
        }//if(fsNameHash) 


    //-- try force mounting the desired file system if it is required
    if(bNeedForceMount)
        {
        const TInt KMaxRetries = 3;
        for(TInt cnt=0; ; ++cnt)
            {
            drive.MountFileSystem(ETrue, newFsNameHash);

            nMountRes = drive.GetReason();
            if(nMountRes == KErrNone || nMountRes == KErrLocked)
                break;
            
            drive.Dismount(); //-- will reset mount retries counter
            
            if(cnt >= KMaxRetries)
                {
                __PRINT1(_L("FsFormatOpen() can't mount FS! res:%d"), nMountRes);    
                return nMountRes;
                }
            }
        }

    ASSERT(nMountRes == KErrNone || nMountRes == KErrLocked);
    
    __ASSERT_DEBUG(drive.CurrentMount().LockStatus()==0, Fault(ESvrFormatOpenFailed));


	TDriveInfo dInfo;
	drive.DriveInfo(dInfo);
	const TInt mediaAtt = dInfo.iMediaAtt;

#if defined(_LOCKABLE_MEDIA)
	if (!(fmtMode & EForceErase) && (mediaAtt & KMediaAttLocked))
		{
		// if attempting to format a locked drive, dismount otherwise subsequent 
		// requests will operate on a mount that has been forcibly mounted (a few lines above)
		CMountCB* pM = &drive.CurrentMount();
		
        if(pM)
			pM->Close();

		drive.MountFileSystem(EFalse);	// clear iCurrentMount
		return KErrLocked;
		}
#endif

	if (!(mediaAtt & KMediaAttFormattable) || (mediaAtt & KMediaAttWriteProtected))
		{
		CMountCB* pM = &drive.CurrentMount();
		
        if(pM)
			pM->Close();

		drive.MountFileSystem(EFalse);
        return KErrAccessDenied;
		}

	//-- instantinate and open CFormatCB object for this drive
    CFormatCB* formatCB=NULL;
	TInt fmtHandle;
    
    TRAPD(ret, formatCB = drive.FormatOpenL(aRequest, fmtHandle, fmtMode, pLDFormatInfo, pVolFormatParam ));

	if (ret!=KErrNone)
		{
		if(formatCB)
			formatCB->Close();

		return ret;
		}

	TPtrC8 pH((TUint8*)&fmtHandle,sizeof(TInt));
	aRequest->WriteL(KMsgPtr3,pH);
	TInt count=100;

	TPtrC8 pCount((TUint8*)&count,sizeof(TInt));
	aRequest->WriteL(KMsgPtr2,pCount);
	aRequest->Session()->IncResourceCount();
	
    return KErrNone;
	}
Exemplo n.º 10
0
/** Play and record an audio file using the UseOldCodecAudioController
 *  which uses CMMFCodecs and the 'null' pcm16->pcm16 hw device plugin
 *  This is for DEF039267
 */
TVerdict CTestMmfAclntOldCodecFile::DoTestStepL( void )
	{
	INFO_PRINTF1( _L("TestPlayerUtils : File"));
	TVerdict ret = EFail;

	iError = KErrTimedOut;

	TBuf<KSizeBuf>	filename;
	TPtrC			filename1; 
	if(!GetStringFromConfig(iSectName,iKeyName,filename1))
		return EInconclusive;
	GetDriveName(filename);
	filename.Append(filename1);
	TUid useCMMFCodecAudioController;

	useCMMFCodecAudioController.iUid = KMmfUidUseOldCodecAudioController;

	CMdaAudioRecorderUtility* recUtil = CMdaAudioRecorderUtility::NewL(*this);

	TRAPD(err, recUtil->OpenFileL(filename,useCMMFCodecAudioController));

	if (err)
		{
		INFO_PRINTF2( _L("error opening record to file %d "), err);
		}
	else
		{
		CActiveScheduler::Start();
		TTimeIntervalMicroSeconds duration = recUtil->Duration();
		// Wait for initialisation callback
		INFO_PRINTF1( _L("Initialise CMdaAudioPlayerUtility"));

		// Check for errors.
		if (iError == KErrNone && recUtil != NULL)
			{
			if(iPlay)
				{
				iError = KErrTimedOut;
				TRAPD(err, recUtil->PlayL());
				if (err)
					{
					INFO_PRINTF2( _L("error opening record to file %d "), err);
					}
				else
					{
					//lets time how long the file plays for and check 
					//it has played for the full time
					TTime startTime(0);
					TTime endTime(0);
					startTime.HomeTime();
					// Wait for init callback
					CActiveScheduler::Start();
					endTime.HomeTime();
					//check file played for the expected time - allow margin of error + 1S -0.5S
					TTimeIntervalMicroSeconds playduration = endTime.MicroSecondsFrom(startTime);
					if ( (playduration.Int64() < (duration.Int64()-KOneSecond/2)) ||
						(playduration.Int64() > (duration.Int64()+KOneSecond)) )
						{
						INFO_PRINTF2(_L("file didn't play for the expected duration expected %ld"), duration.Int64());
						INFO_PRINTF2(_L("but actual duration was %ld"), playduration.Int64());
						}
					else if(iError == KErrNone)
						ret = EPass;
					}
				}		
			}

		recUtil->Close();
		}

	//now try recording file

	TFourCC recordedDataType;
	TUid format;
	format.iUid = KMmfUidFormatWAVWrite;

	//check that the datatype is a valid datatype to record
	if (!iKeyName.Compare(_L("ALAW ")))
		recordedDataType.Set(KMMFFourCCCodeALAW);
	else if (!iKeyName.Compare(_L("PCMU8")))
		recordedDataType.Set(KMMFFourCCCodePCMU8);
	else if (!iKeyName.Compare(_L("MULAW")))
		recordedDataType.Set(KMMFFourCCCodeMuLAW);
	else if (!iKeyName.Compare(_L("IMAD")))
		recordedDataType.Set(KMMFFourCCCodeIMAD);
	else if (!iKeyName.Compare(_L("GSM610")))
		recordedDataType.Set(KMMFFourCCCodeGSM610);

	//rename file to indicate it is recorded
	if (recordedDataType != KMMFFourCCCodeNULL)
		{
		TInt matchpos = filename.Find(_L(".wav"));//get position of extension
		filename.Insert(matchpos,_L("recorded"));//change filename to indicate it is recorded

		//delete file prior to recording
		RFs fs;
		fs.Connect();
		fs.Delete(filename);
		fs.Close();
	
		TRAPD(err,recUtil->OpenFileL(filename,useCMMFCodecAudioController,useCMMFCodecAudioController,format,recordedDataType));

		if (err)
			{
			ret = EFail;
			INFO_PRINTF2( _L("error opening record to file %d "), err);
			}
		else
			{
			INFO_PRINTF1( _L("Initialise CMdaAudioRecorderUtility"));
			CActiveScheduler::Start();	// idle -> open

			recUtil->RecordL();

			// Commented this line of code as a fix for DEF 40709 as it looks like sending a trace message
			// to the TestFramework server(for some reason)and taking a very long time on beech/lubbock 

			//INFO_PRINTF1( _L("Record CMdaAudioRecorderUtility"));
			CActiveScheduler::Start(); // open -> record
			User::After(KTwoSeconds);
			
			recUtil->Stop();
	
			TTimeIntervalMicroSeconds expectedDuration(KTwoSeconds);
			TTimeIntervalMicroSeconds duration = recUtil->Duration();
			//we'll alow +/- 0.5 variance 
			if (duration > TTimeIntervalMicroSeconds(expectedDuration.Int64() + KDeviation/2))
				{
				INFO_PRINTF3( _L("Duration too long expected %ld actual %ld "), expectedDuration.Int64(), duration.Int64());
				ret = EFail;
				}
			else if (duration < TTimeIntervalMicroSeconds(expectedDuration.Int64() - KDeviation/2))
				{
				INFO_PRINTF3( _L("Duration too short expected %ld actual %ld "), expectedDuration.Int64(), duration.Int64());
				ret = EFail;
				}

			recUtil->Close();
			}
		}

	delete recUtil;
	User::After(KOneSecond); // wait for deletion to shut down devsound
	if(iError != KErrNone)
		ERR_PRINTF2( _L("CMdaAudioPlayerUtility failed with error %d"),iError );
	return	ret;
	}
Exemplo n.º 11
0
// ---------------------------------------------------------
// TInt RSCPClient::Connect()
// Creates a new session, and starts the server, if required.
// 
// Status : Approved
// ---------------------------------------------------------
//
EXPORT_C TInt RSCPClient::Connect()
    {
    Dprint( (_L("--> RSCPClient::Connect()") ));
    
    // Use a mutex-object so that two processes cannot start the server at the same time
    RMutex startMutex;
    
    TRAPD( errf, FeatureManager::InitializeLibL() );
	if( errf != KErrNone )
		{
		return errf;
		}
		if(FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements))
		{
			isFlagEnabled = ETrue;
		}
		else
		{
			isFlagEnabled = EFalse;
		}
		FeatureManager::UnInitializeLib();
    TInt mRet = startMutex.OpenGlobal( KSCPServerName );
    if ( mRet == KErrNotFound )
        {
        mRet = startMutex.CreateGlobal( KSCPServerName );
        }
        
    if ( mRet != KErrNone )
        {        
        return mRet;
        }
    
    // Acquire the mutex
    startMutex.Wait();
    
    TInt retry = KSCPConnectRetries;
    TInt r;
    for (;;)
        {        
        r = CreateSession( KSCPServerName, Version(), KDefaultMessageSlots );
        
        if ( ( r != KErrNotFound ) && ( r != KErrServerTerminated  ) )
            {
            break;
            }
        
        if ( --retry == 0 )
            {
            break;
            }
      
        r = StartServer();
        
        if ( ( r != KErrNone ) && ( r != KErrAlreadyExists ) )
            {
            break;   
            }
        }
    
    Dprint( (_L("<-- RSCPClient::Connect(), exiting: %d"), r ));
    
    // Release the mutex
    startMutex.Signal();
    startMutex.Close();

    return r;
    }
TVerdict CAppFwkStartSafeTestStepProcMonSysRestart::doTestStepL()
	{
	
#ifdef __WINSCW__
	ASSERT(0);
#endif	

	CActiveScheduler* sched = new(ELeave) CActiveScheduler; //lint !e527 Unreachable
	CleanupStack::PushL(sched); //lint !e527 Unreachable
	CActiveScheduler::Install(sched);	
	
	iNotifier = CSaveNotifier::NewL(*this);

	CStartSafe* startSafe = CStartSafe::NewL();	
	CleanupStack::PushL( startSafe );

	CStartupProperties* prop = CStartupProperties::NewLC();
	prop->SetFileParamsL(KTestProcGood, KNullDesC);	
	prop->SetStartMethod(EWaitForStart);
	prop->SetMonitored(ETrue);
	prop->SetRecoveryParams(ERestartOS, 0);
	
	TInt tried;
	RProcess proc;
	CleanupClosePushL(proc);
	TRAPD(err, startSafe->StartAndMonitorL(*prop, proc, tried));
	TEST(KErrNone == err);
	CleanupStack::Pop(&proc);
	CleanupStack::PopAndDestroy(prop);
	CleanupStack::PopAndDestroy(startSafe);
	INFO_PRINTF1(_L("Process monitoring setup with TRecoveryMethod=ERestartOS"));

	proc.Kill(KErrNone);
	proc.Close();
	
	TTime init;
	init.UniversalTime();
	INFO_PRINTF4( _L("Process killed at time %d:%d.%d"), init.DateTime().Minute(), init.DateTime().Second(), init.DateTime().MicroSecond());
	INFO_PRINTF1(_L("Starting scheduler (expecting an OS restart)"));
	CActiveScheduler::Start(); //Wait for MSaveObserver callback
	
	//resume here after callback has stopped the scheduler
	TESTE(iCallbackReceived, iCallbackReceived);
	if(iCallbackReceived)
		{
		const TTimeIntervalMicroSeconds elapsedTime = iShutdownPerformed.MicroSecondsFrom(init);
		const TDateTime dt = iShutdownPerformed.DateTime();
		const TInt64 value = elapsedTime.Int64();
		INFO_PRINTF5(_L("Shutdown callback received at time %d:%d.%d (after %d microseconds)"), dt.Minute(), dt.Second(), dt.MicroSecond(), value);
		TESTE((value >= 0) && (value < 1000000), value); // within 1 second	
		}
	else
		{
		INFO_PRINTF1( _L("Restart didn't take place :-("));
		TEST(EFalse);	
		}
	
	//abort restart
	iNotifier->HandleError(KErrNone); 	
	
	CleanupStack::PopAndDestroy(sched);
	return TestStepResult();	
	}
Exemplo n.º 13
0
/**
 *  CMMFDevSound::CBody::CustomInterface
 *
 *  Returns custom interface proxy object created by Proxy Custom Interface
 *  Utility.
 *
 *  @param  TUid
 *          UID of the custom interface object to be started.
 *
 *  @return TAny*
 *          Pointer to the Interface Returned by the DevSoundProxy member.
 */
TAny* CMMFDevSound::CBody::CustomInterface(TUid aInterfaceId)
	{
	// check if this UID refers to CancelInitialize()
	if (aInterfaceId == KMmfUidDevSoundCancelInitializeCustomInterface)
		{
		MMMFDevSoundCancelInitialize* result = this; 
		return result;
		}
	
	// check if this UID refers to EmptyBuffers()
	if (aInterfaceId == KMmfUidDevSoundEmptyBuffersCustomInterface)
		{
		MMMFDevSoundEmptyBuffers* result = this; 
		return result;
		}
		
	if (aInterfaceId == KMmfUidDevSoundAudioResourceCustomInterface)
		{
		MAutoPauseResumeSupport* result = this; 
		return result;
		}		

	if (aInterfaceId == KMmfUidDevSoundTimePlayedCustomInterface)
		{
		MMMFDevSoundTimePlayed* result = this; 
		return result;
		}
	
	if (aInterfaceId == KMmfUidDevSoundQueryIgnoresUnderflowCustomInterface)
		{
		MMMFDevSoundQueryIgnoresUnderflow* result = this;
		return result;
		}
		
	if (aInterfaceId == KMmfUidDevSoundAudioClientThreadInfoCustomInterface)
		{
		MAudioClientThreadInfo* result = this; 
		return result;
		}

	if (aInterfaceId == KMmfUidDevSoundTruePauseCustomInterface)
		{
		MMMFDevSoundTruePause* result = this;
		return result;
		}

	// first check if we already have resolved a custom interface of this type
	TInt index = FindCustomInterface(aInterfaceId);
	
	MMMFDevSoundCustomInterfaceMuxPlugin* ptr = NULL;
		
	// if we found the interface, take a copy of this instead
	if (index != KNullHandle)
		{
		// check our index is valid
		ptr = iCustomInterfaceArray[index-1].iInterface;
		if (ptr)		
			{
			return ptr->CustomInterface(aInterfaceId);
			}
		}
	else
		{
		// else try and instantiate a plugin tunnelling
		// pair to support this Custom Interface
		TRAPD(err, ptr = iMuxUtility->CreateCustomInterfaceMuxL(aInterfaceId));
	
		if (ptr && (err == KErrNone))
			{
			TMMFDevSoundCustomInterfaceData data;
			data.iInterface = ptr;
			data.iId = aInterfaceId;
			
			// attempt to open remote demux
			// this will store a handle in the mux plugin if successful
			// and also return it here - invalid handle = -1
			data.iHandle = ptr->OpenInterface(aInterfaceId);
			
			// if the handle is greater than zero then we know we have
			// successfully opened the interface
			if (data.iHandle > KNullHandle)
				{	
				// append this to the current interface list
				TInt err = KErrNone;
				err = iCustomInterfaceArray.Append(data);
				if (err == KErrNone)
					{
					// return the custom interface on the ptr
					return ptr->CustomInterface(aInterfaceId);
					}
				}
					
				// no memory or other problem so shut down interface
				ptr->Release();
				ptr = NULL;
			}
		}
		
	if (iCIExtension)
		{
		// CI Extension exists, see if it supports the interface
		TAny* interface;
		TInt err = iCIExtension->CustomInterfaceExtension(aInterfaceId, interface);
		if (err == KErrNone)
			{
			return interface;
			}
		}
	// No Mux/DeMux support & no support from CI Extension, if here
	// So, its not supported	
	return NULL;
	}
Exemplo n.º 14
0
/**
 * Subroutine performing pre-processing tasks for testexecute execution
 * Also, responsible for triggering the state machine through instance of ScriptMaster
 * @param aScheduler - Instance of ActiveScheduler created through MainL()
 * @param aSysDrive - Default system drive letter to be used for all script parsing
 */
LOCAL_C void ProcessMainL(CActiveScheduler* aScheduler, const TDriveName aSysDrive)
	{
	TDriveName defaultSysDrive(aSysDrive);
	TDriveName testSysDrive(KTEFLegacySysDrive);
	TInt waitForLoggingTime = 0;
	TBuf<KMaxTestExecuteNameLength> htmlLogPath;
	// Create a object of the Parser for TestExecute.ini
	CTestExecuteIniData* parseTestExecuteIni = NULL;
	TRAPD(err, parseTestExecuteIni = CTestExecuteIniData::NewL(defaultSysDrive));
	if (err == KErrNone)
		{
		CleanupStack::PushL(parseTestExecuteIni);
		// Extract all the key values within the object
		parseTestExecuteIni->ExtractValuesFromIni();
		}

	// Read and parse the command line for the flags
	// -d -slf -help and -v
	TBuf<KMaxTestExecuteCommandLength> commandLine;
	TDesC* selTestCfgFileData = NULL; //the pointer to the data of in the .tcs file
	ReadCommandLineL(commandLine);
	
	// Make lower case because we parse it for flags and search for ".script"
	commandLine.LowerCase();
	TBool separateLogFiles(EFalse); // -slf
	TBool justInTime(EFalse); // -d
	TBool graphicalWindowServer(EFalse); // -gws
	TBool helpRequest(EFalse); // -help
	TBool versionRequest(EFalse); // -v

	TBool includeSelectiveCases(EFalse); // -tci
	TBool excludeSelectiveCases(EFalse); // -tcx
	TBool pipe(EFalse) ; 
	
	// Set up the bools from the command line
	ParseCommandLine(commandLine,separateLogFiles,justInTime,graphicalWindowServer,includeSelectiveCases, excludeSelectiveCases,pipe, helpRequest,versionRequest,*parseTestExecuteIni,err);
	// If -d then set Just In Time debugging. Panicks break into debug on emulator
	(justInTime) ? (User::SetJustInTime(ETrue)) : (User::SetJustInTime(EFalse)); 

	// Hooks for creating the Graphical Window server
	#ifdef GWS
	#endif

	// Create a console
	_LIT(KMessage,"TestExecute Script Engine");
	CConsoleBase* console = Console::NewL(KMessage,TSize(KConsFullScreen,KConsFullScreen));
	CleanupStack::PushL(console);
	console->SetCursorHeight(0);
	RConsoleLogger consoleLogger(*console);
	
	CScriptControl::iRunScriptFailCount=0;
	// A lex for getting the first command line argument, ie the script file path
	TLex lex(commandLine);
	TPtrC scriptFilePath(lex.NextToken());
	TInt ret = KErrNotFound;
	if (scriptFilePath.CompareF(KNull) != 0)
		{
		_LIT(KTEFSwitchPrefix, "-");
		if(scriptFilePath.Mid(0,1).CompareF(KTEFSwitchPrefix) == 0)
			{
			// If the first command line argument is not the script file path but a optional switches
			// Then set the script file path for the execution to be 'blank'
			scriptFilePath.Set(KNull);
			}
		else
			{
			TBuf<KBuffSize> tempScriptPath(scriptFilePath);

			// Check whether script name is provided along with folder path in the command line
			// If not, take the path from testexecute.ini & name from the command line
			ret=scriptFilePath.FindC(KTEFColon);
			if(ret==KErrNotFound)
				{
				if (parseTestExecuteIni != NULL)
					{
					TBuf<KMaxTestExecuteNameLength> tempBuffer;
					parseTestExecuteIni->GetKeyValueFromIni(KTEFDefaultScriptPath, tempBuffer);
 					// If the relative script file path does not refer to the root,
 					// we will look for DefaultScriptDir entry in testexecute.ini
 					// If available prepend it to the relative path
 					// else if the relative path refers to root,
 					// then set the default system drive, i.e. c:
 					// else leaving it as it is (considering invalid path)
 					if (scriptFilePath.Left(1).CompareF(KTEFSlash) != 0 &&
 					 tempBuffer.Length() > 0)
 						scriptFilePath.Set(tempBuffer);
 					else if (scriptFilePath.Left(1).CompareF(KTEFSlash) == 0)
 						scriptFilePath.Set(defaultSysDrive);
 					else
 						scriptFilePath.Set(KNull);
					}
				else
					{
					// If the file path is not provided in command line as well as in testexecute.ini
					// then set the  script file path to be 'blank'
					scriptFilePath.Set(KNull);
					}

				// Construct the full file path from the values extracted from command line and ini file
				TBuf<KBuffSize> storeScriptPathTemp(scriptFilePath);
				storeScriptPathTemp.Append(tempScriptPath);
				scriptFilePath.Set(storeScriptPathTemp);
				tempScriptPath.Copy(scriptFilePath);
				}

			//If scriptFilePath is not appended by .script Append .script 
			if(scriptFilePath.Find(KTEFScriptExtension)==KErrNotFound)
				{
				tempScriptPath.Append(KTEFScriptExtension);
				}
			scriptFilePath.Set(tempScriptPath);
			}
		}

	TPtrC pipeName ; 
	if(pipe)
		{
		TLex flagLex(commandLine);
		//first of all navigate the command line arguments to the selective test cases flag...
		while(!flagLex.Eos())
		{
			TPtrC token(flagLex.NextToken());
			if( (token.CompareF(KTestExecuteCommandLineFlagPipe) == 0) )
				{
				break;
				}
		}
		pipeName.Set(flagLex.NextToken()) ; 	
		}
	
	TSelectiveTestingOptions* selTestingOptions =NULL;
	if (includeSelectiveCases && excludeSelectiveCases)
		{
			//mutually exclusive options have been encountered
			includeSelectiveCases =EFalse;
			excludeSelectiveCases =EFalse;					
			console->Printf(KTEFInvalidCommandSetMessage);
			console->Printf(KTEFEnterKeyMessage);
			console->Getch();
		}
	else
		{
		if(includeSelectiveCases || excludeSelectiveCases)
			{
			RArray<TRange> selectiveCaseRange;
			ParseCommandLineForSelectiveTestingOptions(commandLine,*parseTestExecuteIni,selectiveCaseRange, selTestCfgFileData);
			
			//you need to sort these two arrays first, and also if they are both empty ignore the entire option altogether.
			if(  selectiveCaseRange.Count() > 0 )
				{
				CleanupStack::PushL(selTestCfgFileData);
				TLinearOrder<TRange> orderingrng(TRange::CompareTRangeStartOrder) ; 
				selectiveCaseRange.Sort(orderingrng );
				ESelectiveTesting selectiveTestingType(iExclusive);
				if(includeSelectiveCases)
					{
					selectiveTestingType = iInclusive ; 
					}
				selTestingOptions = new(ELeave) TSelectiveTestingOptions(selectiveCaseRange, selectiveTestingType);
				}
			else
				{
				//if no arguments to this option have been found, ignore it...
				includeSelectiveCases =EFalse;
				excludeSelectiveCases =EFalse;
				delete selTestCfgFileData;
				}
			}
		}

	if (scriptFilePath.CompareF(KNull)==0)
		{
		if (!separateLogFiles && !justInTime)
			{
			// Print the product version details through console window
			console->Printf(KTEFVersionMessage);
			console->Printf(KTEFProductVersion);

			if (!(versionRequest && !helpRequest))
				{
				// Print the help & usage informations through console window along with product version
				console->Printf(KTEFConsoleHelpMessage1);
				console->Printf(KTEFConsoleHelpMessage2);
				console->Printf(KTEFConsoleHelpMessage3);
				console->Printf(KTEFConsoleHelpMessage4);
				console->Printf(KTEFConsoleHelpMessage5);
				}
			}
		else
			{
			// Display a error message on the console window for invalid set of arguments
			console->Printf(KTEFInvalidCommandSetMessage);
			}
		// Exit on a key press from user
		console->Printf(KTEFEnterKeyMessage);
		console->Getch();
		}
	else
		{
		// Create a Interface class object for generating HTML & XML logs
		CTestExecuteLogger *tefLogger = new(ELeave) CTestExecuteLogger();
		CleanupStack::PushL(tefLogger);

		TInt logMode;
		TInt logLevel;
		TInt remotePanicDetection;
		TBuf<KMaxTestExecuteNameLength> iniSysDrive;

		if (parseTestExecuteIni != NULL)
			{
			// Parse ini for retrieving logging options set through ini
			parseTestExecuteIni->GetKeyValueFromIni(KTEFLogMode, logMode);
			parseTestExecuteIni->GetKeyValueFromIni(KTEFLogSeverityKey, logLevel);
			parseTestExecuteIni->GetKeyValueFromIni(KTEFRemotePanicDetection, remotePanicDetection);
			parseTestExecuteIni->GetKeyValueFromIni(KTEFDefaultSysDrive, iniSysDrive);
			parseTestExecuteIni->GetKeyValueFromIni(KTEFWaitForLoggingTime, waitForLoggingTime);
			parseTestExecuteIni->GetKeyValueFromIni(KTEFHtmlKey, htmlLogPath);
			}
		else
			{
			// Set default values for logging options if parser is not functioning
			logMode = TLoggerOptions(ELogHTMLOnly);
			logLevel = RFileFlogger::TLogSeverity(ESevrAll);
			remotePanicDetection = 0;
			iniSysDrive.Copy(KTEFIniSysDrive);
			waitForLoggingTime = 5;
			htmlLogPath.Copy(KTestExecuteLogPath);
			htmlLogPath.Replace(0, 2, defaultSysDrive);
			}
		
		tefLogger->SetLoggerOptions(logMode);
		if(pipe)
			{
			tefLogger->SetPipeName(pipeName) ; 
			}
		
		// Initialise the logging passing in the script file path & log level to the interface
		tefLogger->InitialiseLoggingL(scriptFilePath, separateLogFiles, logLevel);

		// Check to see if defaultsysdrive key is set in testexecute.ini
		// if set to SYSDRIVE, assign the default system drive obtained from the plugin
		// else, if a true value is set in testexecute.ini, use it as system drive for all test artifacts
		if (iniSysDrive.Length() == 2 && iniSysDrive.Right(1).Compare(KTEFColon) == 0)
			testSysDrive.Copy(iniSysDrive);
		else if (iniSysDrive.CompareF(KTEFIniSysDrive) == 0)
			testSysDrive.Copy(defaultSysDrive);


		// Pass the first command line argument to the script master
		// which is always the command script
		CScriptMaster* scriptMaster = new (ELeave) CScriptMaster(scriptFilePath,*tefLogger, consoleLogger, defaultSysDrive, testSysDrive, selTestingOptions);
		// To kick the state machine of the script master off -
		// Call the kick method which jumps us into the RunL() of the CScriptMaster class
		// CScriptMaster is the top AO in the hierarchy.
		scriptMaster->Kick();

		// Construct and Install a test watcher object for capturing remote panics during test execution
		CTestWatcher* testWatcher = NULL;
		if (remotePanicDetection != 0)
			{
			testWatcher = CTestWatcher::NewL();
			testWatcher->StartL();
			}

		// Enter the Active Scheduler
		aScheduler->Start();
		
		// Cleanup
		delete scriptMaster;
		
		TInt commentedCommandsCnt=CScriptControl::commentedCommandsCount;
		if(commentedCommandsCnt==-1)
			{
			CScriptControl::commentedCommandsCount=0;
			//If the path specified fails check out for path from testexecute.ini
			if(ret!=KErrNotFound)
				{
				//To get scriptFile name  i.e get sampleFile.script
				TInt posOfLastSlash=scriptFilePath.LocateReverse('\\') ;
				scriptFilePath.Set(scriptFilePath.Mid(posOfLastSlash+1));
				TBuf<KBuffSize> tempStore(scriptFilePath);
				if (parseTestExecuteIni != NULL)
					{
					TBuf<KMaxTestExecuteNameLength> tempBuffer;
					parseTestExecuteIni->GetKeyValueFromIni(KTEFDefaultScriptPath, tempBuffer);
					if (tempBuffer.CompareF(KNull) != 0)
						{
						scriptFilePath.Set(tempBuffer);
						TBuf<KBuffSize> tempStoreScriptPath(scriptFilePath);
						tempStoreScriptPath.Append(tempStore);
						scriptFilePath.Set(tempStoreScriptPath);
						TBuf<KMaxTestExecuteNameLength> scriptFileLocation(scriptFilePath);
						CScriptMaster* scriptMaster = new (ELeave) CScriptMaster(scriptFilePath,*tefLogger, consoleLogger, defaultSysDrive, testSysDrive, selTestingOptions);
						// To kick the state machine of the script master off -
						// Call the kick method which jumps us into the RunL() of the CScriptMaster class
						// CScriptMaster is the top AO in the hierarchy.
						scriptMaster->Kick();
						// Enter the Active Scheduler
						aScheduler->Start();
						
						commentedCommandsCnt=CScriptControl::commentedCommandsCount;
						if(commentedCommandsCnt==-1)
							{
							CScriptControl::commentedCommandsCount=0;
							}
							
						// Cleanup
						delete scriptMaster;
						}
					}
				}
			}
		delete selTestingOptions;
		
		TInt commandsCount = CScriptControl::commentedCommandsCount;
		TInt countOfRemotePanics = 0;

		// Stop and Process the test watcher object for extracting panic informations and print them to the log files
		if (remotePanicDetection != 0)
			{
			testWatcher->Stop();
			countOfRemotePanics = testWatcher->iSharedData->iPanicDetails.Count();
			if (countOfRemotePanics > 0)
				{
				tefLogger->LogExtra((TText8*)__FILE__,__LINE__,ESevrErr,
					_L("The panic detection thread detected %d panics:"), countOfRemotePanics);
				for (TInt count = 0; count < countOfRemotePanics; count++)
					tefLogger->LogExtra((TText8*)__FILE__,__LINE__,ESevrErr,_L("Remote Panic %d - Name of Panicked Thread: %S, Exit Reason: %d, Exit Category %S"), count+1, &(testWatcher->iSharedData->iPanicDetails)[count]->iThreadName,(testWatcher->iSharedData->iPanicDetails)[count]->iReason,&(testWatcher->iSharedData->iPanicDetails)[count]->iCategory);
				}
			delete testWatcher;
			}

		// Call the Termination routine for logging within the interface
		tefLogger->TerminateLoggingL(commandsCount, countOfRemotePanics, CScriptControl::iRunScriptFailCount);
		CleanupStack::Pop(tefLogger);
		delete tefLogger;
		}
	if(includeSelectiveCases || excludeSelectiveCases)
		{	
		CleanupStack::PopAndDestroy(selTestCfgFileData);
		selTestCfgFileData = NULL;
		}
	// Close the parser instance if it is active
	CleanupStack::PopAndDestroy(console);
	if (parseTestExecuteIni != NULL)
		{
		CleanupStack::PopAndDestroy(parseTestExecuteIni);
		}

	if (scriptFilePath.CompareF(KNull)!=0)
		{
		// Wait for flogger to write to file
		_LIT(KHtmExtension,".htm");
		TParse fileNameParse;
		fileNameParse.Set(scriptFilePath, NULL, NULL);
		
		TPtrC fileName = fileNameParse.Name();
		htmlLogPath.Append(fileName);
		htmlLogPath.Append(KHtmExtension);

	#ifdef _DEBUG
		RDebug::Print(_L("Log file path--> %S"), &htmlLogPath);
	#endif
		RFs fs;
		fs.Connect();
		TBool answer = EFalse;
		while(ETrue)
			{
			TInt err = fs.IsFileOpen(htmlLogPath, answer);
			if ((KErrNone==err&&!answer) || KErrNotFound==err || KErrPathNotFound==err) 
				{
				break;
				}
			User::After(100000);
			}
		
		if (waitForLoggingTime > 0)
			{
			User::After(waitForLoggingTime*1000000);
			}
		}
	}
Exemplo n.º 15
0
void CSwiTask::Log(const TDesC& aLine)
	{
	TRAPD(e,iPassiveLogger->AppendL(aLine));
	}
Exemplo n.º 16
0
// -----------------------------------------------------------------------------
// AknsDrawUtils::DrawBackground()
// (commented in the header).
// -----------------------------------------------------------------------------
EXPORT_C TBool AknsDrawUtils::DrawBackground( MAknsSkinInstance* aInstance,
    MAknsControlContext* aContext, const CCoeControl* aControl,
    CBitmapContext& aGc, const TPoint& aDstPos,
    const TRect& aControlRect, const TInt aDrawParam )
    {
    TInt drawParam = aDrawParam;
    TInt originalParam = aDrawParam;
    TBool retVal = EFalse;
    TBool blitFailed = EFalse;
    TBool blit = EFalse;
    TBool blitAttempted = EFalse;

    if ( !&aGc )
        {
        return retVal;
        }

    MAknsControlContext* parentContext = GetParentContext( aContext );
    if( parentContext )
        {
        retVal = DrawBackground( aInstance, parentContext, aControl, aGc,
            aDstPos, aControlRect, aDrawParam );
        drawParam |= KAknsDrawParamNoClearUnderImage;
        }
    else if( drawParam & KAknsDrawParamBottomLevelRGBOnly )
        {
        drawParam |= KAknsDrawParamRGBOnly;
        }

    originalParam = drawParam;

    if( aContext )
        {
        aContext->UpdateContext();
        }

    TAknsBackground* bgLayout = RetrieveBackgroundLayout( aContext );

    TAknsItemID imgIID( KAknsIIDNone );
    CAknsImageItemData* imgData = RetrieveBackgroundImage(
        aInstance, bgLayout, imgIID );

    // chained background
    if (imgData && imgData->ParentIID() != KAknsIIDNone)
        {
        TAknsItemID parentiid = imgData->ParentIID();
        TRect parentDrawRect = imgData->DrawRect();

        imgData = RetrieveKnownBackgroundImage(
            aInstance, parentiid );
        if (imgData)
            {
            imgData->SetDrawRect(parentDrawRect);
            drawParam |= KAknsDrawParamChained ;
            }
        }

    TPoint paDelta = GetParentAbsoluteDelta( bgLayout, aControl );

    TRect drawRect = aControlRect;
    drawRect.Move( aDstPos-aControlRect.iTl );
    paDelta += aControlRect.iTl-aDstPos;

    if (!(aDrawParam & KAknsDrawParamPrepareOnly))
        {
        aGc.SetPenStyle(CGraphicsContext::ENullPen);
        aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
        }

    if ( !(aDrawParam & KAknsDrawParamIgnoreLayerMask))
        {
        if( imgData )
            {
            blitAttempted = ETrue;
            if( (drawParam&KAknsDrawParamNoClearUnderImage)==0 )
                {
                blit = BlitAndClear( aInstance, aGc, drawRect,
                    imgData, imgIID, bgLayout, paDelta, drawParam );
                }
            else
                {
                blit = Blit( aInstance, aGc, drawRect,
                    imgData, imgIID, bgLayout, paDelta, drawParam );
                }
            if ( !blit )
                {
                blitFailed = ETrue;
                }
            }
        else
            {
            if( !(drawParam&KAknsDrawParamNoClearUnderImage) &&
                !(drawParam&KAknsDrawParamPrepareOnly) )
                {
                // Clear only if permitted
                aGc.DrawRect( drawRect );
                }
            }
        }

    if( bgLayout )
        {
        if (!(aDrawParam & KAknsDrawParamIgnoreLayerMask) && aContext->IsCompatibleWithType(EAknsControlContextTypeMasked))
            {
            CAknsMaskedLayerBackgroundControlContext* layeredCxt = static_cast<CAknsMaskedLayerBackgroundControlContext*>(aContext);
            if (layeredCxt->iOffScreenBmp)
                {
                CAknsMaskedBitmapItemData* maskedImgData = NULL;
                TRAPD( err, maskedImgData = CAknsMaskedBitmapItemData::NewL() );
                if ( err != KErrNone )
                    {
                    return EFalse;
                    }
                maskedImgData->SetBitmap(layeredCxt->iOffScreenBmp);
                maskedImgData->SetMask(layeredCxt->iLayerMask);

                TAknsBackground* childLayout = bgLayout->iNext;

                blitAttempted = ETrue;
                blit = Blit( aInstance, aGc, drawRect, maskedImgData,
                    KAknsIIDNone, childLayout, paDelta, drawParam );
                if ( !blit )
                    {
                    blitFailed = ETrue;
                    }

                maskedImgData->SetBitmap(NULL);
                maskedImgData->SetMask(NULL);
                delete maskedImgData;
                if (!(aDrawParam & KAknsDrawParamPrepareOnly))
                    {
                    aGc.SetPenStyle(CGraphicsContext::ESolidPen);
                    aGc.SetBrushStyle(CGraphicsContext::ENullBrush);
                    }
                retVal = !blitFailed;
                return retVal;
                }
            }

        if (!aContext->IsCompatibleWithType(EAknsControlContextTypeFrame))
            {
            // special handling for frames
            drawParam|=KAknsDrawParamNoClearUnderImage;
            originalParam|=KAknsDrawParamNoClearUnderImage;
            }
        TAknsBackground* nextLayout = bgLayout->iNext;
        while( nextLayout &&
            ((drawParam & KAknsDrawParamLimitToFirstLevel) == 0) )
            {
            imgData = RetrieveKnownBackgroundImage( aInstance,
                nextLayout->iImageID );
            if (imgData && imgData->ParentIID() != KAknsIIDNone)
                {
                TAknsItemID parentiid = imgData->ParentIID();
                TRect parentDrawRect = imgData->DrawRect();

                imgData = RetrieveKnownBackgroundImage(
                    aInstance, parentiid );
                if (imgData)
                    {
                    imgData->SetDrawRect(parentDrawRect);
                    drawParam |= KAknsDrawParamChained ;
                    }
                }
            else
                {
                drawParam=originalParam;
                }
            if( imgData )
                {
                blitAttempted = ETrue;
                blit = BlitAndClear( aInstance, aGc, drawRect, imgData,
                    nextLayout->iImageID, nextLayout, paDelta, drawParam );
                if ( !blit )
                    {
                    blitFailed = ETrue;
                    }
                }
            nextLayout = nextLayout->iNext;
            }
        }

    if (!(aDrawParam & KAknsDrawParamPrepareOnly))
        {
        aGc.SetPenStyle(CGraphicsContext::ESolidPen);
        aGc.SetBrushStyle(CGraphicsContext::ENullBrush);
        }

    // If Blit failed, or was not even attempted => return EFalse
    if ( blitFailed )
        {
        retVal = EFalse;
        }
    else if ( !retVal )
        {
        retVal = blitAttempted;
        }

    return retVal;
    }
Exemplo n.º 17
0
//	Step 3	Content
TVerdict CTPKCS7ContentTest::doTestStepL()
	{
	if (TestStepResult() != EPass)
		{
		return TestStepResult();
		}

	TBool checkType;
	TBool checkLength;
	TBool checkContent;
	TInt expectedType;
	TInt expectedLength;
	TPtrC expectedString;
	HBufC8 * expectedContent = NULL;

	checkType    = GetIntFromConfig   (ConfigSection(),_L("ContentType"),   expectedType);
	checkLength  = GetIntFromConfig   (ConfigSection(),_L("ContentLength"), expectedLength);
	checkContent = GetStringFromConfig(ConfigSection(),_L("ContentString"), expectedString);

	if (checkContent)
		{
		if (expectedString.Length() & 1)
			{
			SetTestStepResult(ETestSuiteError);
			INFO_PRINTF1(_L("ContentString is not a multiple of 2 long"));
			checkContent = EFalse;
			}
		else
			{
			// workaround to parse the expectedstring 
			expectedContent = HBufC8::NewLC (expectedString.Length()/2);
			TPtr8 des = expectedContent->Des ();
			for (TInt i = 0; i < expectedString.Length()/2; i++)
				{
				TInt top = expectedString[2*i];
				TInt low = expectedString[2*i+1];
				if (top >= 0x61) top -= (0x61-10);
				else top -= 0x30;
				if (low >= 0x61) low -= (0x61-10);
				else low -= 0x30;
				des.Append (top*16+low);
				}
			}
		}
	TInt err;

    CPKCS7ContentInfo * contentInfo = NULL;
	TRAP (err, contentInfo = CPKCS7ContentInfo::NewL(iRawData->Des()));
    if(err == KErrNone)
		{
		CPKCS7SignedObject * p7 = NULL;
		if( contentInfo->ContentType() == 2)
			{
			TRAPD (err, p7 = CPKCS7SignedObject::NewL(*contentInfo));

			if (err != KErrNone)
				{
				SetTestStepResult(EFail);
				INFO_PRINTF2(_L("Got %d building PKCS7 object"), err);
				}
			else
				{
				CleanupStack::PushL (p7);
				const CPKCS7ContentInfo& p7info = p7->ContentInfo ();
				if (checkType)
					{
					if (p7info.ContentType() != expectedType)
						{
						SetTestStepResult(EFail);
						INFO_PRINTF3(_L("Expected ContentType %d, got %d"), expectedType, p7info.ContentType());
						}
					}
				const TDesC8& content = p7info.ContentData();
		
				if (checkLength)
					{
					if (content.Length() != expectedLength)
						{
						SetTestStepResult(EFail);
						INFO_PRINTF3(_L("Expected ContentLength %d, got %d"), expectedLength, content.Length());
						}
					}
				if (checkContent)
					{
					if (content.Length() != expectedContent->Length())
						{
						SetTestStepResult(EFail);
						INFO_PRINTF3(_L("Expected ContentString length %d does not correspond to PKCS7 data length %d"),
						expectedContent->Length(), content.Length());
						}
					else
						{
						if (expectedContent->Compare(content) != 0)
							{
							SetTestStepResult(EFail);
							INFO_PRINTF1(_L("Expected ContentString does not match PKCS7 content"));
							}
						}
					}
				CleanupStack::PopAndDestroy (p7);
				}

			}
		}
	else
		{
		SetTestStepResult(EFail);
		}

		if (expectedContent)
			{
			CleanupStack::PopAndDestroy (expectedContent);
			}

		if (!checkType && !checkLength && !checkContent && (TestStepResult()==EPass))
			{
			SetTestStepResult(EInconclusive);
			INFO_PRINTF1(_L("No test performed in this step"));
			}

	return TestStepResult();
	}
Exemplo n.º 18
0
void CSimAdaptationObservers::DoGetLastSimEvent(const RMessage2& aMessage)
	{
	TRAPD(err,aMessage.WriteL(0, iEventPckg));
	aMessage.Complete(err);	
	}
Exemplo n.º 19
0
//Digest Info
TVerdict CTPKCS7DigestInfoTest::doTestStepL()
	{
	if (TestStepResult() != EPass)
		{
		return TestStepResult();
		}
	__UHEAP_MARK;
	
	TInt reason;
	// Read from INI file.
	GetIntFromConfig(ConfigSection(),_L("Reason"),reason);
			
	CPKCS7DigestInfo* p7 = NULL;
	TRAPD (err, p7 = CPKCS7DigestInfo::NewL(iRawData->Des()));
	CleanupStack::PushL(p7);
	
	if (err != KErrNone)
		{
		if(err == reason)
			{
			CleanupStack::PopAndDestroy(p7);
			SetTestStepResult(EPass);
			return TestStepResult();
			}
		else
			{
			SetTestStepResult(EFail);
			ERR_PRINTF2(_L("Got %d building PKCS7 object"), err);
			}
		}
	
	//DIGEST	
    const TDesC8& digest = p7->Digest();
    if(digest.Compare(*iDigest) != 0)		
    	{
       	SetTestStepResult(EFail);
	   	ERR_PRINTF1(_L("Digest does not match"));
      	}
    else
		{
		INFO_PRINTF1(_L("Digest matches"));		
		}
     
    //ALGORITHM ID
    TBool checkAlgorithm;
    TPtrC expectedAlgorithm;
    TAlgorithmId algorithmId = (TAlgorithmId) -1;
   	
	checkAlgorithm = GetStringFromConfig(ConfigSection(),_L("AlgorithmId"), expectedAlgorithm);

	if(checkAlgorithm)
		{
	   	if(expectedAlgorithm.Compare(_L("SHA1")) == 0)
	   	 	{
	   	  	algorithmId = ESHA1;
	     	}
      	else if(expectedAlgorithm.Compare(_L("MD5")) == 0)
	   	 	{
	   	  	algorithmId = EMD5;
	     	}
      
    	if(algorithmId != p7->Algorithm())  
        	{
       		SetTestStepResult(EFail);
	   		ERR_PRINTF1(_L("Algorithm Id does not match"));	
      		}
      	else
      		{
      		INFO_PRINTF1(_L("Algorithm Id matches"));	
      		}	
    	}
    
    //ENCODED PARAMS
    const TDesC8& encodedParams= p7->EncodedParams();
    
    if(encodedParams.Length() != 0)
    	{
    	if(encodedParams.Compare(*iEncodedParams))  
    		{
       		SetTestStepResult(EFail);
	   		ERR_PRINTF1(_L("EncodedParams does not match"));		
      		}
    	else
    		{
    		INFO_PRINTF1(_L("EncodedParams match"));	
    		}  	
    	}
    else if(!iEncodedParams)
        {
        INFO_PRINTF1(_L("EncodedParams not present"));	
        }
    
    
    CleanupStack::PopAndDestroy(p7);
    __UHEAP_MARKEND;	
	return TestStepResult();
	}
Exemplo n.º 20
0
void CTestAppUi::DoNextEnduranceTestActivation()
	{
	if (iAutoTestTimer->IsActive())
		iAutoTestTimer->Cancel();
	
	TInt rand=0;
	if (iDoKills)
		{
		// Occasionally we kill another TVIEW
		TUid killAppUid=KNullUid;
		rand=Math::Rand(iRandSeed);
		if (rand<=KMaxTInt/8)	// 1 in 8 chance
			{
			killAppUid=KUidViewAppTwo;
			}
		else if (rand/2<=KMaxTInt/8)
			{
			killAppUid=KUidViewAppThree;
			}
			
		if (killAppUid!=KNullUid)
			{
			TApaTaskList taskList(CEikonEnv::Static()->WsSession());
			TApaTask task=taskList.FindApp(killAppUid);
			if (task.Exists())
				{
				RDebug::Print(_L("TVIEW1 : ********************* KILLING %x ********************* "),killAppUid.iUid);
				task.KillTask();
				User::After(10000);	// 0.1 sec
				}

			// Start the timer again with a new time delay
			TTimeIntervalMicroSeconds32 delay(KMinimumDelay+KMinimumDelay*Math::Rand(iRandSeed)/KMaxTInt);
			iAutoTestTimer->Start(delay,delay,TCallBack(EnduranceTestCallBack,this));
			
			TRAPD(err,ActivateViewL(TVwsViewId(killAppUid,KUidViewOne),KUidEndurance,KNullDesC16));
			__ASSERT_ALWAYS(!err,User::Panic(_L("ActivateViewL(TVwsViewId(killAppUid,KUidViewOne),KUidEndurance,KNullDesC16)"),err));
			return;
			}
		}	
	// Otherwise we do another random activation

	// Find a new view to activate
	TUid viewUid = (Math::Rand(iRandSeed)>KMaxTInt/2) ? KUidViewOne : KUidViewTwo;
	TUid appUid = KNullUid;
	rand=Math::Rand(iRandSeed);
	if (rand<=KMaxTInt/3)	// 1 in 3 chance
		{
		appUid=KUidViewAppOne;
		}
	else if (rand/2<=KMaxTInt/3)	
		{
		appUid=KUidViewAppTwo;
		}
	else	
		{
		appUid=KUidViewAppThree;
		}

	// Decide whether any special condition should be used with activation.
	// This can mean the activation will be sluggish, a deactivation will be sluggish
	// or the activation will leave or exit
	TUid messageUid=KNullUid;
	rand=Math::Rand(iRandSeed);
	if (rand<KMaxTInt/10)	// 1 in 10 chance
		{
		messageUid=KUidActivationOOM;
		}
	else if (rand/2<KMaxTInt/10)
		{
		messageUid=KUidSluggishActivation;
		}
	else if (rand/3<KMaxTInt/10)
		{
		STATIC_CAST(CTestView*,View(VIEW_ONE))->iSluggishDeactivation=ETrue;
		}
	else if (rand/4<=KMaxTInt/10 && iDoKills)
		{
		STATIC_CAST(CTestView*,View(VIEW_ONE))->iExitDeactivation=ETrue;
		}
	else if (rand<=KMaxTInt && iDoKills && appUid==KUidViewAppTwo)
		{
		messageUid=KUidActivationExit;
		}

	// Start the timer again with a new time delay
	TTimeIntervalMicroSeconds32 delay(KMinimumDelay+KMinimumDelay*Math::Rand(iRandSeed)/KMaxTInt);
	iAutoTestTimer->Start(delay,delay,TCallBack(EnduranceTestCallBack,this));

	TRAPD(err,ActivateViewL(TVwsViewId(appUid,viewUid),messageUid,KNullDesC));
	__ASSERT_ALWAYS(!err,User::Panic(_L("ActivateViewL(TVwsViewId(appUid,viewUid),messageUid,KNullDesC)"),err));
	}
Exemplo n.º 21
0
// -----------------------------------------------------------------------------
// CDRMHelperServer::ConstructL
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CDRMHelperServer::ConstructL()
    {
    TInt err = 0;

#ifdef _DRM_TESTING
    TRAPD( r , WriteL(_L8("ConstructL")) );
#endif


    TUint8 waitCount = 0;
    User::LeaveIfError(iFs.Connect());
    User::LeaveIfError(iDrm.StartServer());
    User::LeaveIfError(iDrm.Connect());
    StartL(KDRMHelperServerName);
    //ignore errors
    err = User::RenameProcess( KDRMHSServerFileName );
    err = User::RenameThread(KDRMHSServerFileName);


    CreatePrivatePathL(iFs); // create path for internal data file
    iEndTimeFactory = CEndTimeFactory::NewL( *this );
    err = KErrNotFound;
    while( err!=0 && waitCount < 30 ) // wait maximum of 6s
        {
        TRAP( err , iNotifier = CDRMNotifier::NewL() );
        if ( err ) // wait only if the server isn't running
            {
            User::After(200000); // 0.2s
            waitCount++;
            }
        if (iNotifier)
            {
            iNotifier->RegisterEventObserverL( *this , KEventTimeChange );
            }
        }
#ifdef _DRM_TESTING
    TRAP( r , WriteL(_L8("ConstructL->Notifier")) );
#endif
    User::LeaveIfError( err ); // None can do, throw an exception.

    iUiTimeNotifier = CEnvironmentChangeNotifier::NewL(
        EPriorityHigh,
        TCallBack(UiTimeChanged,this)
        );
    iUiTimeNotifier->Start();

    iIdleObserver = CIdleObserver::NewL( *this );

    iIdleObserver->StartL();
#ifdef _DRM_TESTING
    TRAP( r , WriteL(_L8("ConstructL->IdleObserver")) );
#endif

    CreateCRKeyL();
    RestoreL();

    iEndTimeFactory->HandleExpiredL();

#ifdef _DRM_TESTING
    TRAP( r , WriteL(_L8("ConstructL->End")) );
#endif
    }
/**
  Function : doTestStepL
  Description : Sets the priority of an email message via the IMAP \Flagged flag
  @return : TVerdict - Test step result
*/
TVerdict CT_MsgSetImap4EmailPriority::doTestStepL()
	{
	INFO_PRINTF1( _L("Test Step : SetSmtpEmailPriority") );
	if (ReadIni())
		{
		TMsvId parentFolderId;
		// Local parent folder location...
		if(iLocation.Compare(_L("LOCAL"))==0)
			{
			// Retrieves the folder Id based on the local folder name read from the ini file
			parentFolderId = CT_MsgUtilsEnumConverter::FindFolderIdByName(iParentFolderName);
			if(parentFolderId == KErrNotFound)
				{
				ERR_PRINTF1(_L("Invalid local parent folder name specified"));
				SetTestStepResult(EFail);
				return TestStepResult();
				}
			INFO_PRINTF2(_L("The local parent folder Id is %d"),parentFolderId);
			}
		// Remote parent folder location...
		else if(iLocation.Compare(_L("REMOTE"))==0)
			{
			TRAPD(err,parentFolderId = CT_MsgUtils::GetRemoteFolderIdByNameL(iSharedDataIMAP.iSession, iImapAccountName, iParentFolderName));
			if(err == KErrNotFound)
				{
				ERR_PRINTF1(_L("Invalid remote parent folder name specified"));
				SetTestStepResult(EFail);
				return TestStepResult();
				}	
			INFO_PRINTF2(_L(" The remote parent folder Id is %d"),parentFolderId);
			}
		// Location Local or Remote not specified...
		else
			{
			ERR_PRINTF1(_L("Invalid parent folder location"));
			SetTestStepResult(EFail);
			return TestStepResult();
			}
			
		// Retrieves the message Id based on the message subject of the email under the given parent folder
		TMsvId	messageId;
		TRAPD(err,messageId = CT_MsgUtils::SearchMessageBySubjectL(iSharedDataIMAP.iSession, parentFolderId, iEmailSubject));
		if(err == KErrNotFound)
			{
			ERR_PRINTF1(_L("The given message is not found"));
			SetTestStepResult(EFail);
			}
		// Message found	
		else
			{
			INFO_PRINTF2(_L("The Message Id is %d"),messageId);

			// Retrieve the default Smtp service Id
			TMsvId smtpServiceId(0);
			TRAPD(err, smtpServiceId = CT_MsgUtilsCentralRepository::GetDefaultSmtpServiceIdL());
			if(err != KErrNone)
				{
				ERR_PRINTF2(_L("Failure while getting the default SMTP Service Id. Error = %d"),err);
				SetTestStepResult(EFail);
				}
			else
				{
				INFO_PRINTF2(_L("The Default Smtp Service Id is %d"),smtpServiceId);
				
				CT_MsgActive& active = Active();
				delete iOperation;
				iOperation=NULL;
				
				// Setting the current context to the parent of the mesage
				CMsvEntry*	entry = CMsvEntry::NewL(*iSharedDataIMAP.iSession, messageId, TMsvSelectionOrdering());
				CleanupStack::PushL(entry);
				
				TMsvEmailEntry emailEntry(entry->Entry());
				
				if(iEmailPriority==1)
					{
					emailEntry.SetFlaggedIMAP4Flag(ETrue);
					iOperation = entry->ChangeL(emailEntry,active.iStatus);
					active.Activate();
					CActiveScheduler::Start();
					User::LeaveIfError(active.Result());
					INFO_PRINTF1(_L("The state of the Flagged IMAP4 flag of the email is set for urgent/special attention"));
					}
				else if (iEmailPriority==0)
					{
					emailEntry.SetFlaggedIMAP4Flag(EFalse);
					iOperation = entry->ChangeL(emailEntry,active.iStatus);
					active.Activate();
					CActiveScheduler::Start();
					User::LeaveIfError(active.Result());
					INFO_PRINTF1(_L("The state of the Flagged IMAP4 flag of the email is NOT set for urgent/special attention"));
					}
				else
					{
					ERR_PRINTF1(_L("Error in setting the Flagged IMAP4 flag! Usage: 1=ETrue and 0=EFalse"));
					SetTestStepResult(EFail);
					}
					
				CleanupStack::PopAndDestroy(entry);
				}
			}
		}
	return TestStepResult();
	}
Exemplo n.º 23
0
//Returns TMsvEntry.iDate for aEntryId, and the time it is scheduled for on the task scheduler
EXPORT_C TInt CMsvTestUtils::ScheduleTime(TMsvId aEntryId, TTime& rEntryTime, TTime& rTaskSchedulerTime, TTaskInfo& rTaskInfo)
	{
	TRAPD(err, DoScheduleTimeL(aEntryId, rEntryTime, rTaskSchedulerTime, rTaskInfo));
	return err;
	}
Exemplo n.º 24
0
enum TVerdict CTest07TrimStart::doTestStepL(void)
	{
	__UHEAP_MARK;
	
	//-------------- substep 0 --------------------
	Log(_L("  00 Read parameters from the script:"));
	TInt aOffset;// Will contain the position in chain where split action will be done
	TInt aLength;// Will contain the length of desc & chains in the test
	TInt bRet = GetIntFromConfig(_L("MBufMgrTest07"), _L("Length"), aLength);
	if (!bRet)
		{
		return EFail;
		}
	bRet = GetIntFromConfig(_L("MBufMgrTest07"), _L("Offset"), aOffset);
	if (!bRet)
		{
		return EFail;
		}
   	Log(_L("     ------- Chain LENGTH              = %d --"), aLength);
 	Log(_L("     ------- OFFSET where to TrimStart = %d --"), aOffset);
	if ( (aLength > 1000)    ||(aLength <0) ||
		 (aOffset > aLength) || (aOffset <0)  )
		{
		Log(_L("ERROR: Wrong input parameter(s)"));
		return EFail;
		}

#ifdef __CFLOG_ACTIVE
	__CFLOG_CREATEL;
	__CFLOG_OPEN;
#endif
	
	//-------------- substep 1 --------------------
	Log(_L("  01 Creating CMBufManager and installing active scheduler:"));
    CleanupStack::PushL( iActSch = new(ELeave) CActiveScheduler );
	CActiveScheduler::Install(iActSch);
	CleanupStack::PushL(CreateInstanceMBufMgrL(KMBufDefaultHeapSize));

	//-------------- substep 2 --------------------
	Log(_L("  02 Allocate two desc. of Length:LENGTH(Des1) & (LENGTH-OFFSET)(Des2):"));
	TBuf8<1000> *aDes1, *aDes2;
    CleanupStack::PushL( aDes1 = new(ELeave) TBuf8<1000> );
    CleanupStack::PushL( aDes2 = new(ELeave) TBuf8<1000> );
	aDes1->SetLength(aLength);
	aDes2->SetLength(aLength-aOffset);

	//-------------- substep 3 --------------------
	Log(_L("  03 Fill in Des1 with a pattern:"));
	StripeDes(*aDes1, 0, aLength, '@', 'Z');

	//-------------- substep 4 --------------------
	Log(_L("  04 Fill in Des2 with zeros:"));
	StripeDes(*aDes2, 0, aLength-aOffset, 0, 0);

	//-------------- substep 5 --------------------
	Log(_L("  05 Allocate Chain:"));
	RMBufChain aChain;
	TRAPD(ret,aChain.AllocL(aLength));
	if (ret != KErrNone)
		{
		Log(_L("Error: Couldn't allocate RMBuf:"));
#ifdef __CFLOG_ACTIVE
		__CFLOG_CLOSE;
		__CFLOG_DELETE;
#endif
		User::Leave(EFail);
		}

	//-------------- substep 6 --------------------
	Log(_L("  06 Copy in Des1 into Chain1:"));
	aChain.CopyIn(*aDes1);

	//-------------- substep 7 --------------------
	Log(_L("  07 TrimStart Chain1 at OFFSET position (actually, remove the 1st OFFSET bytes:"));
	aChain.TrimStart(aOffset);

	//-------------- substep 8 --------------------
	Log(_L("  08 Check the length of the chain. It should be (LENGTH - OFFSET):"));
	TInt temp;
	if ( (temp = aChain.Length()) != aLength-aOffset)
		{
		Log(_L("Error: Chain length is %d instead of %d"), temp, aLength-aOffset);
		aChain.Free();
#ifdef __CFLOG_ACTIVE
		__CFLOG_CLOSE;
		__CFLOG_DELETE;
#endif
		User::Leave(EFail);
		}

	//-------------- substep 09 --------------------
	Log(_L("  09 Copy the last (LENGTH-OFFSET) bytes of Des1 into the start of Des1:"));
	(void)Mem::Copy((TUint8 *)aDes1->Ptr(), (TUint8 *)aDes1->Ptr()+aOffset, aLength-aOffset);

	//-------------- substep 10 --------------------
	Log(_L("  10 Set the length of Des1 to value LENGTH-OFFSET"));
	aDes1->SetLength(aLength-aOffset);

	//-------------- substep 11 --------------------
	Log(_L("  11 Copy out Chain into Des2:"));
	aChain.CopyOut(*aDes2);

	//-------------- substep 12 --------------------
	Log(_L("  12 Compare the content of Des1 & Des2:"));
	if(aDes1->Compare(*aDes2))
		{
		aChain.Free();
		Log(_L("Error: The content is not the same"));
#ifdef __CFLOG_ACTIVE
		__CFLOG_CLOSE;
		__CFLOG_DELETE;
#endif
		User::Leave(EFail);
		}

	//-------------- substep 13 --------------------
	Log(_L("  13 Free the chains. Clean up stack:"));
	aChain.Free();
    CleanupStack::PopAndDestroy(aDes2);
    CleanupStack::PopAndDestroy(aDes1);
    CleanupStack::PopAndDestroy(iMBMngr);
	CActiveScheduler::Install(NULL);
	CleanupStack::PopAndDestroy(iActSch);

#ifdef __CFLOG_ACTIVE
	__CFLOG_CLOSE;
	__CFLOG_DELETE;
#endif
 	__UHEAP_MARKEND;
	return EPass;
	}
Exemplo n.º 25
0
/**
@SYMTestCaseID			PDS-SQL-UT-4234
@SYMTestCaseDesc		CSqlBurEventMonitor functional test
						The test sets the backup & restore property status and then checks
						how the backup & restore property monitor (CSqlBurEventMonitor) reacts to the event.
@SYMTestActions			CSqlBurEventMonitor functional test
@SYMTestExpectedResults Test must not fail
@SYMTestPriority		High
*/
void SqlBurEventMonitorFunctionalTest()
	{
	CSqlBurEventMonitor* monitor = NULL;
	TRAPD(err, monitor = CSqlBurEventMonitor::NewL(*TheSqlSrvTestBurInterface));
	TEST2(err, KErrNone);
	TEST(!monitor->ActiveBackupClient());
	TEST(!monitor->SqlBurCallback());
	//Set the property to conn::EBURBackupFull, conn::EBURBackupPartial, conn::EBURRestoreFull, conn::EBURRestorePartial, 
	//then start the scheduler. CSqlBurEventMonitor::RunL() gets called and 
	//CSqlBurCallback and CActiveBackupClient interfaces get created (if the interfaces do exist, they are destroyed first).
	TInt burPropertyStatus[] = {conn::EBURBackupFull, conn::EBURBackupPartial, conn::EBURRestoreFull, conn::EBURRestorePartial};
	for(TInt i=0;i<(sizeof(burPropertyStatus)/sizeof(burPropertyStatus[0]));++i)
		{
		err = RProperty::Set(KSqlBurPropertyCategoryUid, KSqlBurBackupRestoreKey, burPropertyStatus[i]);
		TEST2(err, KErrNone);
		TestModeSqlBurError = KErrNone;
		if(i > 0)
			{
			__UHEAP_MARK;
			}
		CActiveScheduler::Start();
		if(i > 0)
			{
			__UHEAP_MARKEND;
			}
		TEST2(TestModeSqlBurError, KErrNone);
		TEST(monitor->ActiveBackupClient() != NULL);
		TEST(monitor->SqlBurCallback() != NULL);
		}
	//Set the property to conn::EBURUnset, start the scheduler. CSqlBurEventMonitor::RunL() gets called 
	//and CSqlBurCallback interface gets destroyed.
	err = RProperty::Set(KSqlBurPropertyCategoryUid, KSqlBurBackupRestoreKey, conn::EBURUnset);
	TEST2(err, KErrNone);
	TestModeSqlBurError = KErrNone;
	CActiveScheduler::Start();
	TEST2(TestModeSqlBurError, KErrNone);
	TEST(!monitor->ActiveBackupClient());
	TEST(!monitor->SqlBurCallback());
	//Set the property to conn::EBURNormal, start the scheduler. CSqlBurEventMonitor::RunL() gets called. 
	//CSqlBurCallback interface has been destroyed alread. No memory deallocations should be made during this call.
	err = RProperty::Set(KSqlBurPropertyCategoryUid, KSqlBurBackupRestoreKey, conn::EBURNormal);
	TEST2(err, KErrNone);
	__UHEAP_MARK;
	TestModeSqlBurError = KErrNone;
	CActiveScheduler::Start();
	TEST2(TestModeSqlBurError, KErrNone);
	TEST(!monitor->ActiveBackupClient());
	TEST(!monitor->SqlBurCallback());
	__UHEAP_MARKEND;
	//Set the property, then delete it. CSqlBurEventMonitor::RunL() should get called, but the call should
	//fail because the property does not exist.
	err = RProperty::Set(KSqlBurPropertyCategoryUid, KSqlBurBackupRestoreKey, conn::EBURBackupFull);
	TEST2(err, KErrNone);
	err = RProperty::Delete(KSqlBurPropertyCategoryUid, KSqlBurBackupRestoreKey);  
	TEST2(err, KErrNone);
	__UHEAP_MARK;
	TestModeSqlBurError = KErrNone;
	CActiveScheduler::Start();
	TEST2(TestModeSqlBurError, KErrNotFound);
	TEST(!monitor->ActiveBackupClient());
	TEST(!monitor->SqlBurCallback());
	__UHEAP_MARKEND;
	//Restore the property
	err = RProperty::Define(KSqlBurPropertyCategoryUid, KSqlBurBackupRestoreKey, 0);  
	TEST2(err, KErrNone);
	//
	delete monitor;
	}
Exemplo n.º 26
0
void CCamcTestClient_9::Start_Active_ObjectL ( TestClient9Actions aAction, TInt aCameraHandle )
    {
    
    TFileName file;
    TInt camHandle = aCameraHandle;
    TUid controllerUid = {0x101F8503};	//implementation uid
    TUid formatUid = {0};
    TUid formatUidG2 = {0x101F86D6};
    TUid formatUidMP4 = {0x101F873D};
    
    
    iAction = aAction;                  //iAction might be set to NULL after action has been executed
    iSavedAction = aAction;             //SavedAction will never be changed.
    //	iTimeout = aTimeout;
    iTimeout = 1500000;
    
    if ( iAction == K_TC9_NewFileNameWhenRecordSecondTimeDiffFileFormat )
        {
        AddDriveLetterToPath(_L("recordQCIF.3g2"), file);
        
        TRAPD(err,
            iCamc->OpenFileL( file, camHandle, 
            controllerUid,
            formatUidG2,
            _L8("video/H263-2000"),
            TFourCC(' ', 'A', 'M', 'R') ));
        
        if (err)
            {
            User::Leave(99);
            }
        }
    else if ( iAction == K_TC9_NewFileNameWhenRecordSecondTimeMPEG4FileFormat )
        {
        AddDriveLetterToPath(_L("recordQCIF.mp4"), file);
        
        TRAPD(err,
            iCamc->OpenFileL( file, camHandle, 
            controllerUid,
            formatUidMP4,
            _L8("video/mp4v-es; profile-level-id=3"),
            TFourCC(' ', 'A', 'A', 'C') ));
        
        if (err)
            {
            User::Leave(99);
            }
        }
    else
        {       
        AddDriveLetterToPath(_L("recordQCIF.3gp"), file);
        
        TRAPD(err,
            iCamc->OpenFileL( file, camHandle, 
            controllerUid,
            formatUid,
            _L8("video/H263-2000"),
            TFourCC(' ', 'A', 'M', 'R') ));
        
        if (err)
            {
            User::Leave(99);
            }
        }
    iOpenReady = EFalse;
    
    // Main part of program is a wait loop
    // This function completes when the scheduler stops
    CActiveScheduler::Start();
    
    if ( iError )
        {
        User::Leave( iError );
        }
    }
Exemplo n.º 27
0
/** Deletes a setting.
@param aKey Key of setting to be deleted.
@return
	KErrNone if successful, 
	KErrNotFound if the setting does not exist,
	plus other system-wide error codes.
@post
	Transactions fail on all error conditions except KErrNotFound.
	Outside transactions: on success the deletion of the setting is persistent,
	on failure the repository is unmodified.
@capability Dependent Caller must satisfy the write access policy for that key in the repository
*/
EXPORT_C TInt CRepository::Delete(TUint32 aKey)
	{
	TRAPD(err,iImpl->DeleteSettingL(aKey));
	iImpl->RemoveAnyMarkDeleted();
	return err;
	}
Exemplo n.º 28
0
void CSsTestStepProcStart::DoTestForMonitorAlreadyMonProcL()
	{
	INFO_PRINTF1( _L("\n\nPerforming Process-monitor test for already started and monitored process") );
	
	RProcess process;
	CleanupClosePushL(process);
	
	CSsmStartupProperties* startupProperties = CSsmStartupProperties::NewL();
	CleanupStack::PushL( startupProperties );
	
	// Need to start testprocess as a server so that we can tell it to stop being monitored.
	startupProperties->SetFileParamsL(KTestProcGood, KLaunchServerCommandLineOption);
	startupProperties->SetCommandTypeL(ESsmCmdStartProcess);
	startupProperties->SetExecutionBehaviour(ESsmWaitForSignal);
	
	const TInt KMonitorTimeout = 3000; // milliseconds I presume
	TSsmMonitorInfo monitorInfo;
	monitorInfo.iRestartPolicy = ESsmIgnoreOnFailure;
	monitorInfo.iRestartMode = 0;
	monitorInfo.iTimeout = KMonitorTimeout;
	monitorInfo.iRetries = 1;
	startupProperties->SetMonitorInfoL(monitorInfo);

	CSsmStartSafe* ss  = CSsmStartSafe::NewLC();

	// Try to start and monitor the process
	TRAPD(err, ss->StartAndMonitorL(*startupProperties, process));
	TEST(err == KErrNone);
	INFO_PRINTF3( _L("StartAndMonitorL() completed with %d. anticipated value %d"),err, KErrNone );
	
	RTestProcGoodSession testProcServerSession;
	err = testProcServerSession.Connect();
	TEST(KErrNone == err);
	INFO_PRINTF1( _L("Asserted that server is running"));

	// Try to start and monitor an already started and monitored process
	TRAP(err, ss->StartAndMonitorL(*startupProperties, process));

	// sysmon returns KErrAlreadyExists, if we try to monitor an already monitored process
	TEST(err == KErrAlreadyExists);
	INFO_PRINTF3( _L("StartAndMonitorL() completed with %d. anticipated value %d"),err, KErrAlreadyExists);
	
	process.Kill(KErrNone);
	
	err = testProcServerSession.Connect();
	//Connecting to the test proc server session should fail here with error value as either KErrNotFound(in case session object is cleaned up) or KErrServerTerminated(session object is there but session terminated) 
	TEST(KErrNotFound == err || KErrServerTerminated == err);
	INFO_PRINTF3( _L("Connect to test proc server session failed with %d. anticipated value %d"),err, KErrNotFound);

	RSemaphore sem;
	err = sem.CreateGlobal(KStartProcSignalSemaphore, 0);
	INFO_PRINTF2(_L("Created semaphore with err %d"),err);
	TEST(err == KErrNone);
	CleanupClosePushL(sem);
	
	INFO_PRINTF1(_L("Waiting for Start of the test application"));
	sem.Wait();
	//Waiting for 5 seconds as in the ssmtestprocgood application the active scheduler
	// will be started after signalling the semaphore.  And we can connect to the
	// application only after the active scheduler is started.
	User::After(KWaitForActiveSchedStart);
	
	// Check that the killed process is restarted by SysMon
	err = testProcServerSession.Connect();
	TEST(KErrNone == err);
	INFO_PRINTF3( _L("process re-started by sysmon with %d, anticipate value %d"),err,KErrNone);
	
	// Stop monitoring to stop restarts.
	if(KErrNone == testProcServerSession.Connect())
		{
		testProcServerSession.CancelMonitor();
		testProcServerSession.Close();
		}
	TEST(1 == FindAndKill(KTestProcGood));
	CleanupStack::PopAndDestroy(4, &process);
	}
Exemplo n.º 29
0
/** Sets an existing integer setting to a new value or creates a new setting 
with an integer value if the setting doesn't exist.
@param aKey Key of setting to be written to.
@param aValue Value to be written.
@return
	KErrNone if successful,
	KErrArgument if the setting exists but is not an integer
	plus other system-wide error codes.
@post
	Transactions fail on all error conditions.
	Outside transactions: on success the new value is persistent,
	on failure the repository is unmodified.
@capability Dependent Caller must satisfy the write access policy of that key in the repository.
*/
EXPORT_C TInt CRepository::Set(TUint32 aKey, TInt aValue)
	{
	TRAPD(err,iImpl->SetSettingL(aKey,aValue));
	return err;
	}
Exemplo n.º 30
0
void CGroupViewTester::HandleContactViewEvent( const CContactViewBase& aView,
    const TContactViewEvent& aEvent )
	{
    // Log events from both underlying view and group view.
    LogEvent( const_cast<TContactViewEvent&>( aEvent ) );

	switch (iCurrentTest)
		{
		case ECreateLocalView:
			test(iLocalView==&aView);
			test(aEvent.iEventType==TContactViewEvent::EReady);
			break;

		case ECreateGroupOneView:
			{
			test(iGroupViewOne == &aView);
			test(aEvent.iEventType == TContactViewEvent::EReady);

			//Reserve the IDs of last three contacts in the group
			TInt index = KNumContactsInGroupOne-1;
            TRAPD(err, iLastContactID = iGroupViewOne->ContactAtL(index).Id() );
			if (err)
				{
				_LIT(KErrMsg, "Contact view error in CGroupViewTester::HandleContactViewEvent() assigning iLastContactID\n");
				test.Printf(KErrMsg);
				User::Invariant();
				}

            --index;
            TRAP(err, iSecondLastContactID = iGroupViewOne->ContactAtL(index).Id() );
			if (err)
				{
				_LIT(KErrMsg, "Contact view error in CGroupViewTester::HandleContactViewEvent() assigning iSecondLastContactID\n");
				test.Printf(KErrMsg);
				User::Invariant();
				}

            --index;
            TRAP(err, iThirdLastContactID = iGroupViewOne->ContactAtL(index).Id() );
			if (err)
				{
				_LIT(KErrMsg, "Contact view error in CGroupViewTester::HandleContactViewEvent() assigning iThirdLastContactID\n");
				test.Printf(KErrMsg);
				User::Invariant();
				}

			}
			break;

        case ECreateGroupTwoView:
			test( iGroupViewTwo == &aView );
			test( aEvent.iEventType == TContactViewEvent::EReady );
            break;

        case EDeleteItemsFromView:
            {
            // Bulk delete complete when the last Ready is received from the 
            // base view. This comes after the group view ready event. Break to 
            // run next test.
            TBool lastEvent = (aEvent.iEventType == TContactViewEvent::EReady) &&
                (&aView == iLocalView);
            if (lastEvent) 
                { 
                break; 
                }

            if (aEvent.iEventType == TContactViewEvent::EItemRemoved)
                {
                // Only proces events from group view.
                if (&aView == iGroupViewOne)
                    {
                    // Ensure that only 1 contact is removed per notification.
                     iNumRemovedEvents++;
                    TInt numItemsExpected = KNumContactsInGroupOne - iNumRemovedEvents;
		            
		            TInt numItems(0);
		            TRAPD(err, numItems = iGroupViewOne->CountL() );
					if (err)
						{
						_LIT(KErrMsg, "Contact view error in CGroupViewTester::HandleContactViewEvent() assigning numItems\n");
						test.Printf(KErrMsg);
						User::Invariant();
						}
		            test(numItems == numItemsExpected );

                    // Verify the contacts were deleted as expected.
                    TBool testVal(EFalse);
                    TInt index = numItemsExpected - 1;
					TRAP(err, testVal = (iGroupViewOne->ContactAtL(index).Id() == iLastContactID) );
					if (err)
						{
						_LIT(KErrMsg, "Contact view error in CGroupViewTester::HandleContactViewEvent() assigning testVal for iLastContactID\n");
						test.Printf(KErrMsg);
						User::Invariant();
						}
					test(testVal);

                    --index;
					TRAP(err, testVal = (iGroupViewOne->ContactAtL(index).Id() == iSecondLastContactID) );
					if (err)
						{
						_LIT(KErrMsg, "Contact view error in CGroupViewTester::HandleContactViewEvent() assigning testVal for iSecondLastContactID\n");
						test.Printf(KErrMsg);
						User::Invariant();
						}
					test(testVal);

                    --index;
					TRAP(err, testVal = (iGroupViewOne->ContactAtL(index).Id() == iThirdLastContactID) );
					if (err)
						{
						_LIT(KErrMsg, "Contact view error in CGroupViewTester::HandleContactViewEvent() assigning testVal for iThirdLastContactID\n");
						test.Printf(KErrMsg);
						User::Invariant();
						}
					test(testVal);
                    }

                // More events expected, don't run next test.
                return;
                }
            else
                {
                // Ignore all other events.
                return;
                }
            }

        case EAddItemToGroup:
            {
            // Break to run next test if this is the last expected event. The last
            // event is the group being added from the base view. The local view
            // removes and then adds the group id whenever the group changes. These
            // events are meaningless.
            TBool lastEvent = (&aView == iLocalView) && 
                (aEvent.iEventType == TContactViewEvent::EItemAdded) &&
                (aEvent.iContactId == iGroupOneId);
            if (lastEvent)
                {
                break; // Run next test.
                }

            // Verify contact has been added.
            if (aEvent.iEventType == TContactViewEvent::EItemAdded && 
                &aView == iGroupViewOne)
                {
                // Check if contact was added.
                test( aEvent.iContactId == iIdAdded );

                TInt index = iGroupViewOne->FindL( iIdAdded );
                test (index != KErrNotFound);

                // More events expected, don't run next test.
                return;
                }
            else
                {
                // Ignore all other events.
                return;
                }
            }

		default:
			test( EFalse );
			break;
		}

    // Run the next test.
	if (--iNumNotificationExpected <= 0)
		{
		NextTest();
		iNumNotificationExpected = 0;
		}
	}