TInt RMmCustomAPI::GetParameterValue(TInt aLineNumber,TInt aIndex ) 
{
		
		if ( KErrNone != iFileError)
		 	return -1;
		
		RFile fread;	
		TInt lError = fread.Open(iFs,KMyFile,EFileRead); 	
		RFileReadStream rfs(fread);
		
		TChar delmeter(10); 
		TInt ret = -9999;
		TInt err;
		if ( KErrNone == lError )
		    {
		    for(TInt i = 0; i < aLineNumber; i++ )
		    	{
					TRAP(err,rfs.ReadL(iLineBuffer,delmeter));
					if(err != KErrNone)
						{
							rfs.Close();	
							fread.Close();	    
							return -1;
						}
					iLineBuffer.Copy(iLineBuffer.Left(iLineBuffer.Length() - 2 ));
		    	}
		    }
		    
	TBuf8<64> restBuffer;  
	TInt pos = KErrNotFound;
	TChar c(44); // 44 means ',' 
	
	if(aIndex != -1 )
		{
			for(TInt i = 0; i < aIndex; i++ )
				{
					pos = iLineBuffer.Locate(c);    
					if(pos == KErrNotFound)
						break;
					restBuffer.Copy(iLineBuffer.Left(pos ));
					iLineBuffer.Copy(iLineBuffer.Mid( pos + 1));
				}
			if(pos != KErrNotFound)	
				iLineBuffer.Copy(restBuffer);
		}
		
	if(ret == -9999)	    
		{
			pos = iLineBuffer.Locate(c);    
			if(pos != KErrNotFound)
				{
					restBuffer.Copy(iLineBuffer.Left(pos ));
					iLineBuffer.Copy(restBuffer);
				}
			TLex8 input(iLineBuffer);		    
			input.Val(ret);
		}
	
	rfs.Close();	
	fread.Close();	    

	return ret;
	
#if 0
		RFs fs;
		RFile fread;
		TInt lError = fs.Connect();
		if ( KErrNone != lError )
		 	return -1;
		 	
		 lError = fread.Open(fs,KMyFile,EFileRead);
		RFileReadStream rfs(fread);
		TBuf8<8> buf;
		TChar delmeter(10); 
		TInt ret = -999;
		TInt err;
		if ( KErrNone == lError )
		    {
		    for(TInt i = 0; i < aIndex; i++ )
		    	{
					TRAP(err,rfs.ReadL(buf,delmeter));
					if(err != KErrNone)
						{
							rfs.Close();	
							fread.Close();	    
							fs.Close();
							return -1;
						}
					buf.Copy(buf.Left(buf.Length() - 2 ));
		    	}
		    }
		    
	if(ret == -999)	    
		{
			TLex8 input(buf);		    
			input.Val(ret);
		}
	
	rfs.Close();	
	fread.Close();	    
	fs.Close();
	return ret;
#endif	

}	
TVerdict CTestDevVideoPlayGetSupportedSnapshotFormats::DoTestL(CMMFDevVideoPlay& aDevVideoPlay)
	{
	TVerdict ret = EFail;
	TInt expErr = KErrNone;
	
	INFO_PRINTF1(_L("CMMFDevVideoPlay:  GetSupportedSnapshotFormats"));
	
	// expected results
	if (iTestType != ETestValid)
		{
		ERR_PRINTF1(_L("Error - invalid test step type"));
		return EInconclusive;
		}

	TInt err = KErrNone;

//	THwDeviceId hwDecoder = 0;
//	THwDeviceId hwPostProc = 0;

	// select decoder
//	TRAP(err, hwDecoder = aDevVideoPlay.SelectDecoderL(KUidDevVideoTestDecodeHwDevice));
	TRAP(err, aDevVideoPlay.SelectDecoderL(KUidDevVideoTestDecodeHwDevice));	// EABI warning removal
	if (err != KErrNone)
		{
		ERR_PRINTF1(_L("Error - couldn't initialize decoder"));
			return EInconclusive;
		}

	// select post-processor
//	TRAP(err, hwPostProc = aDevVideoPlay.SelectPostProcessorL(KUidDevVideoTestPostProcHwDevice));
	TRAP(err, aDevVideoPlay.SelectPostProcessorL(KUidDevVideoTestPostProcHwDevice));	// EABI warning removal
	if (err != KErrNone)
		{
		ERR_PRINTF1(_L("Error - couldn't initialize post processor"));
			return EInconclusive;
		}

	// initialize CDevVideoPlay and wait for response
	// iError is set by the MdvpoInitComplete callback
	aDevVideoPlay.Initialize();
	
	if (iError != KErrNone)
		{
		ERR_PRINTF1(_L("Error - couldn't initialize DevVideoPlay"));
			return EInconclusive;
		}

	RArray<TUncompressedVideoFormat> vidFormats;

	// get a list of supported formats from the plugin
	TRAP(err, aDevVideoPlay.GetSupportedSnapshotFormatsL(vidFormats) )

	// check picture and timestamp from callback
	if (err == KErrNone)
		{
		if ( vidFormats.Count() == 3)
			{
			if ((vidFormats[0] == KTestVidFormat1) &&
				(vidFormats[1] == KTestVidFormat2) &&
				(vidFormats[2] == KTestVidFormat3) )
				{
				INFO_PRINTF1(_L("Snapshot format list checks ok"));
				ret = EPass;
				}
			else
				{
				ERR_PRINTF1(_L("Error - Snapshot format list is corrupt!"));
				}
			}
		}
	else
		{
		ERR_PRINTF3(_L("GetSupportedSnapshotFormatsL() gave error %d (expected %d)"),err, expErr);
		}

	vidFormats.Reset();
	vidFormats.Close();

	return ret;
	}
void CCustomCommand::MoscoStateChangeEvent(CBase* /*aObject*/, TInt aPreviousState, TInt aCurrentState, TInt aErrorCode)
{
#ifdef _DEBUG
    RDebug::Print (_L ("CCustomCommand::MoscoStateChangeEvent"));
#endif
	

	logger->Log(_L("MoscoStateChangeEvent called, error: %d	prev: %d curr : %d"),aErrorCode,aPreviousState,aCurrentState);
	
	iCallBackErr = aErrorCode;
	
	TUint bitRate = recorder->SourceBitRateL();
	logger->Log(_L("SourceBitRateL %d "),bitRate);
	
	

	if (recorder && aErrorCode == KErrNone && aCurrentState == CMdaAudioClipUtility::EOpen && aPreviousState == 0)
	{
		TBuf8<25> dataFrom;

 	   	TRequestStatus status;
		TMMFMessageDestinationPckg dummyPckg;
		TInt dummyFunc = 100;
		TBuf8<8> dummyBuff;

	    // Initialize
		recorder->SetAudioDeviceMode(CMdaAudioRecorderUtility::ELocal);
		logger->Log(_L("Mode set"));
		recorder->SetGain(recorder->MaxGain());
		logger->Log(_L("Gain set"));
		recorder->SetVolume(recorder->MaxVolume());
		logger->Log(_L("Volume set"));
		recorder->SetPosition(TTimeIntervalMicroSeconds(TInt64(0)));
		logger->Log(_L("Position set"));


		TRAPD(err, recorder->PlayControllerCustomCommandSync(dummyPckg, dummyFunc,
  								    	dummyBuff, dummyBuff, dataFrom));
	    if (err != KErrNone)
        {
            logger->Log(_L("PlayControllerCustomCommandSync with dataFrom - err=%d"), err);

        }
    	logger->Log(_L("PlayControllerCustomCommandSync with dataFrom successful"));

    	TRAP(err, recorder->PlayControllerCustomCommandSync(dummyPckg, dummyFunc,
        								dummyBuff, dummyBuff));
    	if (err != KErrNone)
        {
            logger->Log(_L("PlayControllerCustomCommandSync - err=%d"), err);

        }
    	logger->Log(_L("PlayControllerCustomCommandSync successful"));


    	recorder->RegisterForAudioLoadingNotification(*this);
		logger->Log(_L("RegisterForAudioLoadingNotification set"));
		recorder->RegisterAudioResourceNotification(*this,KUidInterfaceMMFController);
		logger->Log(_L("RegisterAudioResourceNotification set"));
        recorder->CancelRegisterAudioResourceNotification(KUidInterfaceMMFController);
		logger->Log(_L("CancelRegisterAudioResourceNotification set"));



		//PlayController
 	   	TRAPD(err1, recorder->RecordControllerCustomCommandSync(dummyPckg, dummyFunc,
  								    	dummyBuff, dummyBuff, dataFrom));
	    if (err1 != KErrNone)
        {
            logger->Log(_L("RecordControllerCustomCommandSync with dataFrom - err=%d"), err1);

        }
    	logger->Log(_L("RecordControllerCustomCommandSync with dataFrom successful"));

    	TRAP(err, recorder->RecordControllerCustomCommandSync(dummyPckg, dummyFunc,
        								dummyBuff, dummyBuff));
    	if (err != KErrNone)
        {
            logger->Log(_L("RecordControllerCustomCommandSync - err=%d"), err);

        }
    	logger->Log(_L("RecordControllerCustomCommandSync successful"));

    	logger->Log(_L("Using UseSharedHeap"));
    	recorder->UseSharedHeap();

		recorder->PlayL();


		return;

	}

	if (recorder && aErrorCode == KErrNone && aCurrentState == CMdaAudioClipUtility::EOpen && aPreviousState == CMdaAudioClipUtility::EPlaying)
	{
		// Create DRM custom command
    	MMMFDRMCustomCommand* drmCustomCommand;
    	drmCustomCommand = recorder->GetDRMCustomCommand();
    	if (drmCustomCommand == NULL)
        {
        	logger->Log(_L("MMMFDRMCustomCommand is NULL."));

        }
        logger->Log(_L("MMMFDRMCustomCommand is successful."));

		recorder->WillResumePlay();
		CActiveScheduler::Stop();
	}
	if(aErrorCode != KErrNone)
	        {
	            
	            CActiveScheduler::Stop();
	            
	        }

	return;

}
TVerdict CTestDevVideoPlayGetSnapshot::DoTestL(CMMFDevVideoPlay& aDevVideoPlay)
	{
	TVerdict ret = EFail;
	
	INFO_PRINTF1(_L("CMMFDevVideoPlay:  GetSnapshot"));
	
	// expected results
	if (iTestType != ETestValid)
		{
		ERR_PRINTF1(_L("Error - invalid test step type"));
		return EInconclusive;
		}

	TInt err = KErrNone;

//	THwDeviceId hwDecoder = 0;
//	THwDeviceId hwPostProc = 0;

	// select decoder
//	TRAP(err, hwDecoder = aDevVideoPlay.SelectDecoderL(KUidDevVideoTestDecodeHwDevice));
	TRAP(err, aDevVideoPlay.SelectDecoderL(KUidDevVideoTestDecodeHwDevice));	// EABI warning removal
	if (err != KErrNone)
		{
		ERR_PRINTF1(_L("Error - couldn't initialize decoder"));
			return EInconclusive;
		}

	// select post-processor
//	TRAP(err, hwPostProc = aDevVideoPlay.SelectPostProcessorL(KUidDevVideoTestPostProcHwDevice));
	TRAP(err, aDevVideoPlay.SelectPostProcessorL(KUidDevVideoTestPostProcHwDevice));	// EABI warning removal
	if (err != KErrNone)
		{
		ERR_PRINTF1(_L("Error - couldn't initialize post processor"));
			return EInconclusive;
		}

	// initialize CDevVideoPlay and wait for response
	// iError is set by the MdvpoInitComplete callback
	aDevVideoPlay.Initialize();
	
	if (iError != KErrNone)
		{
		ERR_PRINTF1(_L("Error - couldn't initialize DevVideoPlay"));
			return EInconclusive;
		}

	TBool result = EFalse;
	TPictureData pictureData;

	TUncompressedVideoFormat format;
	format.iDataFormat = EYuvRawData;
	format.iYuvFormat = KTestYuvFormat1;

	TRAP(err, result = aDevVideoPlay.GetSnapshotL(pictureData, format));

	if (err == KErrNone)
		{
		if (result)
			{
			if ((pictureData.iDataFormat == EYuvRawData) &&
				(pictureData.iDataSize == TSize(KTestPictureDataSizeX, KTestPictureDataSizeY)) && 
				(pictureData.iRawData == NULL))
				{
				ret = EPass;
				}
			}
		}
	
	return ret;
	}
TVerdict CTestDevVideoPlayGetTimedSnapshotID::DoTestL(CMMFDevVideoPlay& aDevVideoPlay)
	{
	TVerdict ret = EPass;
	TInt expErr = KErrNone;
	
	INFO_PRINTF1(_L("CMMFDevVideoPlay:  GetTimedSnapshotID"));
	
	// expected results
	if (iTestType != ETestValid)
		{
		ERR_PRINTF1(_L("Error - invalid test step type"));
		return EInconclusive;
		}

	TInt err = KErrNone;

//	THwDeviceId hwDecoder = 0;
//	THwDeviceId hwPostProc = 0;

	// select decoder
//	TRAP(err, hwDecoder = aDevVideoPlay.SelectDecoderL(KUidDevVideoTestDecodeHwDevice));
	TRAP(err, aDevVideoPlay.SelectDecoderL(KUidDevVideoTestDecodeHwDevice));	// EABI warning removal
	if (err != KErrNone)
		{
		ERR_PRINTF1(_L("Error - couldn't initialize decoder"));
			return EInconclusive;
		}

	// select post-processor
//	TRAP(err, hwPostProc = aDevVideoPlay.SelectPostProcessorL(KUidDevVideoTestPostProcHwDevice));
	TRAP(err, aDevVideoPlay.SelectPostProcessorL(KUidDevVideoTestPostProcHwDevice));	// EABI warning removal
	if (err != KErrNone)
		{
		ERR_PRINTF1(_L("Error - couldn't initialize post processor"));
			return EInconclusive;
		}

	// initialize CDevVideoPlay and wait for response
	// iError is set by the MdvpoInitComplete callback
	aDevVideoPlay.Initialize();
	
	if (iError != KErrNone)
		{
		ERR_PRINTF1(_L("Error - couldn't initialize DevVideoPlay"));
			return EInconclusive;
		}

	TPictureData pictureData;

	TUncompressedVideoFormat format;
	format.iDataFormat = EYuvRawData;
	format.iYuvFormat = KTestYuvFormat1;
	TPictureId snapId = KTestSnapshotId;

	// get a timed snapshot from the post processor
	TRAP(err, aDevVideoPlay.GetTimedSnapshotL(&pictureData, format, snapId));

	// check picture and timestamp from callback
	if ((err == KErrNone) && (iError == KErrNone))
		{
		if ( (iPictureData) && (iPictureId.iIdType == KTestSnapshotId.iIdType) && 
			 (iPictureId.iId == KTestSnapshotId.iId) )
			{
			if ((iPictureData->iDataFormat == EYuvRawData) &&
				(iPictureData->iDataSize == TSize(KTestPictureDataSizeX, KTestPictureDataSizeY)) && 
				(iPictureData->iRawData == NULL))
				{
				ret = EPass;
				}
			else
				{
				ERR_PRINTF1(_L("Error - PictureData is corrupt!"));
				}
			}
		}
	else
		{
		ERR_PRINTF3(_L("GetTimedSnapshotL() gave error %d (expected %d)"),err, expErr);
		}
	
	return ret;
	}
TVerdict CTestDevVideoPlayRevert::DoTestL(CMMFDevVideoPlay& aDevVideoPlay)
	{
	TVerdict ret = EPass;
//	TInt expErr = KErrNone;
	TBool selDec = ETrue;
	TBool selPost = ETrue;

	INFO_PRINTF1(_L("CMMFDevVideoPlay:  Revert"));
	
	// expected results
	switch(iTestType)
		{
		case ETestValid:
//			expErr = KErrNone;
			break;
		case ETestDecoderOnly:
			selPost = EFalse;
			break;
		case ETestPostProcOnly:
			selDec = EFalse;
			break;
		default:
			ERR_PRINTF1(_L("Error - invalid test step type"));
			return EInconclusive;
		}

	TInt err = KErrNone;

//	THwDeviceId hwDecoder = 0;
//	THwDeviceId hwPostProc = 0;

	// select decoder
	if (selDec)
		{
//		TRAP(err, hwDecoder = aDevVideoPlay.SelectDecoderL(KUidDevVideoTestDecodeHwDevice));
		TRAP(err, aDevVideoPlay.SelectDecoderL(KUidDevVideoTestDecodeHwDevice));	// EABI warning removal
		if (err != KErrNone)
			{
			ERR_PRINTF1(_L("Error - couldn't initialize decoder"));
				return EInconclusive;
			}
		}

	// select post-processor
	if (selPost)
		{
//		TRAP(err, hwPostProc = aDevVideoPlay.SelectPostProcessorL(KUidDevVideoTestPostProcHwDevice));
		TRAP(err, aDevVideoPlay.SelectPostProcessorL(KUidDevVideoTestPostProcHwDevice));	// EABI warning removal
		if (err != KErrNone)
			{
			ERR_PRINTF1(_L("Error - couldn't initialize post processor"));
				return EInconclusive;
			}
		}

	// initialize CDevVideoPlay and wait for response
	// iError is set by the MdvpoInitComplete callback
	aDevVideoPlay.Initialize();
	
	if (iError != KErrNone)
		{
		ERR_PRINTF1(_L("Error - couldn't initialize DevVideoPlay"));
			return EInconclusive;
		}

	// call Revert on DevVideoPlay
	aDevVideoPlay.Revert();

	// if no PANIC then test has passed...

	INFO_PRINTF1(_L("Revert() called successfully"));
	
	return ret;
	}
TVerdict CTestDevVideoPlayNextPicture::DoTestL(CMMFDevVideoPlay& aDevVideoPlay)
	{
	TVerdict ret = EPass;
	
	INFO_PRINTF1(_L("CMMFDevVideoPlay:  NextPicture"));
	
	// expected results
	if (iTestType != ETestValid)
		{
		ERR_PRINTF1(_L("Error - invalid test step type"));
		return EInconclusive;
		}

	TInt err = KErrNone;

//	THwDeviceId hwDecoder = 0;
//	THwDeviceId hwPostProc = 0;

	// select decoder
//	TRAP(err, hwDecoder = aDevVideoPlay.SelectDecoderL(KUidDevVideoTestDecodeHwDevice));
	TRAP(err, aDevVideoPlay.SelectDecoderL(KUidDevVideoTestDecodeHwDevice));// EABI warning removal
	if (err != KErrNone)
		{
		ERR_PRINTF1(_L("Error - couldn't initialize decoder"));
			return EInconclusive;
		}

	// select post-processor
//	TRAP(err, hwPostProc = aDevVideoPlay.SelectPostProcessorL(KUidDevVideoTestPostProcHwDevice));
	TRAP(err, aDevVideoPlay.SelectPostProcessorL(KUidDevVideoTestPostProcHwDevice));	// EABI warning removal
	if (err != KErrNone)
		{
		ERR_PRINTF1(_L("Error - couldn't initialize post processor"));
			return EInconclusive;
		}

	//Tell plugin to start creating pictures.
	TRAP(iError, aDevVideoPlay.SetVideoDestScreenL(EFalse));
	if (iError != KErrNone)
		{
		ERR_PRINTF1(_L("Error - couldn't SetVideoDestScreen"));
			return EInconclusive;
		}

	// initialize CDevVideoPlay and wait for response
	// iError is set by the MdvpoInitComplete callback
	aDevVideoPlay.Initialize();

	if (iError != KErrNone)
		{
		ERR_PRINTF1(_L("Error - couldn't initialize DevVideoPlay"));
			return EInconclusive;
		}

	iDevVideoPlay = &aDevVideoPlay;
	aDevVideoPlay.Start();//Tell plugin to start creating pictures.
	// We should now get a series of NewPicture() callbacks.

	if (iError == KErrNone)
		{
		ret = EPass;
		}
	else
		{
		ERR_PRINTF2(_L("Error - picture processing failed with error %d"), iError);
		}
	
	return ret;
	}
Beispiel #8
0
Datei: kgdb.c Projekt: 7L/pi_plus
/* KGDB functions to use existing PowerPC64 hooks. */
static int kgdb_debugger(struct pt_regs *regs)
{
	return !kgdb_handle_exception(1, computeSignal(TRAP(regs)),
				      DIE_OOPS, regs);
}
// -----------------------------------------------------------------------------
// CSendObject::ReserveObjectL
// -----------------------------------------------------------------------------
//
TInt CSendObject::ReserveObjectL()
    {
    PRINT( _L( "MM MTP => CSendObject::ReserveObjectL" ) );
    TInt err = KErrNone;

    iReceivedObjectInfo->SetUint( CMTPObjectMetaData::EStorageId, iStorageId );
    iReceivedObjectInfo->SetUint( CMTPObjectMetaData::EParentHandle,
        iParentHandle );
    iReceivedObjectInfo->SetDesCL( CMTPObjectMetaData::ESuid, iFullPath );
    iReceivedObjectInfo->SetUint( CMTPObjectMetaData::EFormatCode,
        iObjectFormat );

    // Reserves space for and assigns an object handle to the object described
    // by the specified object information record.
    TRAP( err, iObjectMgr.ReserveObjectHandleL( *iReceivedObjectInfo,
        iObjectSize ) );
    iRollbackList.Append( &CSendObject::UnreserveObjectL );

    PRINT2( _L( "MM MTP => CSendObject::ReserveObjectL iObjectsize = %Lu, Operation: 0x%x" ), iObjectSize, iOperationCode );
    if ( err != KErrNone )
        {
        PRINT1( _L( "MM MTP <> ReserveObjectHandleL err = %d" ), err );
        }

    if ( err == KErrNone )
        {
        delete iFileReceived;
        iFileReceived = NULL;
        PRINT2( _L( "MM MTP <> CSendObject::ServiceObjectL, iFullPath is %S, iObjectSize: %Lu" ), &iFullPath, iObjectSize );
        iRollbackList.Append( &CSendObject::RemoveObjectFromFs );
        TRAP( err, iFileReceived = CMTPTypeFile::NewL( iFs, iFullPath, EFileWrite ) );

        PRINT1( _L("MM MTP <> CMTPTypeFile::NewL Leave Code is: %d"), err );
        }

    if ( err == KErrNone )
        {
        TRAP( err, iFileReceived->SetSizeL( iObjectSize ) );
        PRINT1( _L( "MM MTP <> SetSizeL leave code:%d" ), err );
        if ( err == KErrDiskFull )
            {
            SendResponseL( EMTPRespCodeStoreFull );
            Rollback();
            return err;
            }
        }

    if ( err == KErrNone && iObjectSize == 0 )
        {
        // Already trapped inside SaveEmptyFileL.
        SaveEmptyFileL();
        if ( iOperationCode == EMTPOpCodeSendObjectPropList )
            {
            // Only leave when getting proplist element from data received by fw.
            // It should not happen after ReceiveDataL in which construction of proplist already succeed.
            SetObjectPropListL();
            }

        iObjectMgr.CommitReservedObjectHandleL( *iReceivedObjectInfo );
        iRollbackList.Reset();
        }

    if ( err == KErrNone )
        {
        iExpectedSendObjectRequest.SetUint32( TMTPTypeRequest::ERequestSessionID, iSessionId );
        iFramework.RouteRequestRegisterL( iExpectedSendObjectRequest, iConnection );

        TUint32 parameters[3];
        parameters[0] = iStorageId;
        parameters[1] = iParentHandle;
        parameters[2] = iReceivedObjectInfo->Uint( CMTPObjectMetaData::EHandle );
        SendResponseL( EMTPRespCodeOK, 3, parameters );
        }
    else
        {
        SendResponseL( EMTPRespCodeGeneralError );
        Rollback();
        }

    PRINT( _L( "MM MTP <= CSendObject::ReserveObjectL" ) );
    return err;
    }
TInt CConvertTime::CreateAndRunTestUnitL()
{
    TTime t;
    TInt converterErrUTC = KErrNone;
    TInt rulesErrUTC = KErrNone;
    TInt converterErrLocal = KErrNone;
    TInt rulesErrLocal = KErrNone;

    User::LeaveIfError(iTimeZoneServer.Connect());

    // Set home location
    TInt err = CDstIntUtils::SetHomeTimeZoneL(iCityName, iTimeZoneServer);

    if (iSystemLocalTime != Time::NullTTime())
    {
        iTimeZoneServer.SetHomeTime(iSystemLocalTime);
    }

    // Instantiate Converter
    CTzConverter *converter = CTzConverter::NewL(iTimeZoneServer);
    CleanupStack::PushL(converter);

    CTzId* tzId = CTzId::NewL(iCityName);
    CleanupStack::PushL(tzId);
    CTzRules* rules = iTimeZoneServer.GetTimeZoneRulesL(*tzId, TDateTime(0, EJanuary, 0, 0, 0, 0, 0), TDateTime(9999, EJanuary, 0, 0, 0, 0, 0), ETzWallTimeReference);
    CleanupStack::PopAndDestroy(tzId);
    CleanupStack::PushL(rules);

    if(err != KErrNone)
    {
        TBuf8<64> txt;
        txt.Append(_L8("Zone not set: "));
        txt.Append(iCityName);
        TBuf<64> txtmsg;
        txtmsg.Copy(txt);
        LogCheck(txtmsg, err);
    }
    else
    {
        // Handle UTC to local conversion
        if((iConversion == EConvertUTC) || (iConversion == EConvertBoth))
        {
            t = iUTCTime;
            converterErrUTC = converter->ConvertToLocalTime(t);
            if(converterErrUTC == KErrNone)
            {
                converterErrUTC = CompareTimesL(t, EConvertUTC);
            }

            t = iUTCTime;
            TRAP(rulesErrUTC, rules->ConvertToLocalL(t));
            if(rulesErrUTC == KErrNone)
            {
                rulesErrUTC = CompareTimesL(t, EConvertUTC);
            }
        }

        // Handle local to UTC conversion
        if((iConversion == EConvertLocal) || (iConversion == EConvertBoth))
        {
            t = iLocalTime;
            converterErrLocal = converter->ConvertToUniversalTime(t);
            if(converterErrLocal == KErrNone)
            {
                converterErrLocal = CompareTimesL(t, EConvertLocal);
            }

            t = iLocalTime;
            TRAP(rulesErrLocal, rules->ConvertToUtcL(t));
            if(rulesErrLocal == KErrNone)
            {
                rulesErrLocal = CompareTimesL(t, EConvertLocal);
            }
        }

        if(converterErrUTC != KErrNone)
            err = converterErrUTC;
        if(converterErrLocal != KErrNone)
            err = converterErrLocal;
        if(rulesErrUTC != KErrNone)
            err = rulesErrUTC;
        if(rulesErrLocal != KErrNone)
            err = rulesErrLocal;
    }

    CleanupStack::PopAndDestroy(rules);
    CleanupStack::PopAndDestroy(converter);

    return err;
}
// ---------------------------------------------------------
// CPosTp154::DoCancelTestL
//
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CPosTp154::DoCancelTestL()
    {
    iLog->Log(_L("DoCancelTestL"));
    iLandmarkParser = CPosLandmarkParser::NewL(KKmzMimeType);
    iLandmarkParser->SetInputFileL(KKMZFile);

    iOperation = iLandmarkParser->ParseContentL();

    TRequestStatus status = KPosLmOperationNotComplete;
    TReal32 progress;

    // 1 ) Cancel parse function by deleting iOperation
    delete iOperation;
    iOperation = NULL;

    TUint32 nr = iLandmarkParser->NumOfParsedLandmarks();
    if ((TInt)nr != 0)
    {
    	iLog->Log(_L("No landmarks should be found"));
    	User::Leave(KErrNone);
    }

    // No landmark should be found
    TRAPD(err, iLandmarkParser->LandmarkLC());
    if (err != KErrNotFound)
        {
        iLog->Log(_L("ERROR: No Landmark should be found"));
        iErrorsFound++;
        }

    // 1 ) Cancel parse function by changing input
    iOperation = iLandmarkParser->ParseContentL();

    // Get the first landmark
    iOperation->NextStep(status, progress);
    // Wait for NextStep to complete
    User::WaitForRequest(status);
    nr = iLandmarkParser->NumOfParsedLandmarks();
    if ((TInt)nr != 1)
    {
    	iLog->Log(_L("One landmark should be found"));
    	User::Leave(KErrNone);
    }

    // Change input
    iLandmarkParser->SetInputFileL(KKMZFile);

    nr = iLandmarkParser->NumOfParsedLandmarks();
    if ((TInt)nr != 0)
    {
    	iLog->Log(_L("No landmarks should be found"));
    	User::Leave(KErrNone);
    }

    // No landmark should be found
    TRAP(err, iLandmarkParser->LandmarkLC());
    if (err != KErrNotFound)
        {
        iLog->Log(_L("ERROR: No Landmark should be found"));
        iErrorsFound++;
        }

    delete iOperation;
    iOperation = NULL;
    delete iLandmarkParser;
    iLandmarkParser = NULL;
    iLog->Log(_L("DoCancelTestL Done"));
    }
void CPlayAudioFile::RunL()
	{
	THwDeviceInitParams initParams;
	TInt err = KErrNone;	
	switch (iState)
		{
		case EHwDeviceCreateAndInit:
			{
			err = OMX_Init();
			if (err != KErrNone)
				{
				iParent->SetVerdict(_L("The OMX Core cannot be initialised"), EFail);
				SetState(EHwDeviceError);
				}	
			initParams.iHwDeviceObserver = this;
			TRAP(err, iHwDevice = CMMFHwDevice::NewL(TUid::Uid(KUidHwDeviceAudioAdapter)));
			if (err != KErrNone)
				{
				iParent->SetVerdict(_L("The Hw Device Adapter cannot be created"), EFail);
				OMX_Deinit();
				SetState(EHwDeviceError);
				}
			MMdfHwDeviceSetup* setup = (MMdfHwDeviceSetup*)iHwDevice->CustomInterface(KUidHwDeviceSetupInterface);
			if (setup != NULL)
				{
				//Play is pcmU8 -> pcm16
				
				TRAPD(err, setup->SetDataTypesL(KMMFFourCCCodeTestPCMU8, KMMFFourCCCodePCM16));
				if (err == KErrNotFound)
					{
					iParent->SetVerdict(_L("Cannot load the PU"), EFail);
					delete iHwDevice;
					OMX_Deinit();
					SetState(EHwDeviceError);
					break;
					}
				}				
			err = iHwDevice->Init(initParams);
			if (err != KErrNone)
				{
				CleanupAndSetDeviceError(_L("The Hw Device Adapter cannot be initialised"));
				break;
				}	
			iParent->SetVerdict(_L("The Hw Device Adapter created & initialised"));	
			SetState(EHwDeviceStartDecode);
			break;
			}
		case EHwDeviceStartDecode:
			{
			// if we are playing a file, first we have to open the file
			err = ReadTestFileInBuffer();
			if (err != KErrNone)
				{
				CleanupAndSetDeviceError(_L("Cannot open the file to be played"));
				break;
				}
			iParent->SetVerdict(_L("The files to be played has opened successfully"));
			
			// tell the HwDeviceAdapter to play the file
			err = iHwDevice->Start(EDevDecode, EDevInFlow);
			if (err != KErrNone)
				{
				CleanupAndSetDeviceError(_L("The Hw Device Adapter cannot start"));
				break;
				}
			iParent->SetVerdict(_L("The Hw Device Adapter has started successfully"));
			break;
			}
		case EHwDeviceAllowToComplete:
			break;
		case EHwDeviceDone:
			{
			delete iHwDevice;
			OMX_Deinit();	
			Cancel();
			CActiveScheduler::Stop();
			break;
			}				
		case EHwDeviceError:
			{
			CActiveScheduler::Stop();
			break;
			}
		default:
			{
			CleanupAndSetDeviceError(_L("Unknown CPlayAudioFile iState"));
			break;
			}
		}
	}
void CT_AddressStringTokenizerStep::RunTestCases()
	{
	TInt err;
	SetTestStepID(_L("UIF-ETUL-0001"));
	INFO_PRINTF1(_L("Test to search URLs"));
	TRAP(err, SearchURLsL());
	TEST(err == KErrNone);
	RecordTestResultL();

	SetTestStepID(_L("UIF-ETUL-0002"));
	INFO_PRINTF1(_L("Test to search EMailAddresses"));
	TRAP(err, SearchEMailAddressesL());
	TEST(err == KErrNone);
	RecordTestResultL();
	
	SetTestStepID(_L("UIF-ETUL-0003"));
	INFO_PRINTF1(_L("Test to search PhoneNumbers"));
	TRAP(err, SearchPhoneNumbersL());
	TEST(err == KErrNone);
	RecordTestResultL();

	SetTestStepID(_L("UIF-ETUL-0004"));
	INFO_PRINTF1(_L("Tests for PhoneNos with Min. 3 nos. in a string \n\t\t\t\t\t\t\t when the string is considered as a phone no.\n"));
	TRAP(err, SearchPhoneNumbersWithMin3NosL());
	TEST(err == KErrNone);
	RecordTestResultL();
	
	SetTestStepID(_L("UIF-ETUL-0005"));
	INFO_PRINTF1(_L("Tests for PhoneNos with Min. 8 nos. in a string \n\t\t\t\t\t\t\t when the string is considered as a phone no.\n"));
	TRAP(err, SearchPhoneNumbersWithMin8NosL());
	TEST(err == KErrNone);
	RecordTestResultL();
	
	SetTestStepID(_L("UIF-ETUL-0006"));
	INFO_PRINTF1(_L("Tests for PhoneNos with Min. 15 nos. in a string \n\t\t\t\t\t\t\t when the string is considered as a phone no.\n"));
	TRAP(err, SearchPhoneNumbersWithMin15NosL());
	TEST(err == KErrNone);
	RecordTestResultL();
	
	SetTestStepID(_L("UIF-ETUL-0007"));
	INFO_PRINTF1(_L("Test to search URL's, EMailAddresses, PhoneNumbers"));
	TRAP(err, SearchAllL());
	TEST(err == KErrNone);
	RecordTestResultL();
	
	SetTestStepID(_L("UIF-ETUL-0008"));
	INFO_PRINTF1(_L("Test to check the positions"));
	TRAP(err, CheckPositionsL());
	TEST(err == KErrNone);
	RecordTestResultL();
	
	SetTestStepID(_L("UIF-ETUL-0009"));
 	INFO_PRINTF1(_L("Test to Parse URI file"));
	TRAP(err, ParseURIFileL());
	TEST(err == KErrNone);
	RecordTestResultL();
		
	TestOOMForAddressStringTokenizer();
	
	SetTestStepID(_L("UIF-ETUL-0024"));
	INFO_PRINTF1(_L("Test Phone Search Separators"));
	TRAP(err, TestPhoneSearchSeparatorsL());
	TEST(err == KErrNone);
	RecordTestResultL();
	CloseTMSGraphicsStep();
	}
// -----------------------------------------------------------------------------
// RMmCustomAPI::Open
// This method opens a RMmCustomAPI subsession from RMobilePhone.
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
 TInt RMmCustomAPI::Open( RMobilePhone& /*aPhone*/ )
    {
    	TInt error = KErrNone;
    	TRAP(error,ConstructL());
    	return error;   
    }
void CT_LbsConflictStep_X3PMenuPush::NotifyMeasurementControlLocation(const TPositionInfo& aPosition, 
															  const RLbsAssistanceDataBuilderSet& aData, 
															  const TLbsNetPosRequestQuality& aQuality)
	{
	T_LbsUtils utils;	
	TInt err;
	
	// Determine and record sequence event.
	if (iState == EReqX3PMenu)
		{
		INFO_PRINTF1(_L("Got - X3P(MENU) MOLR - NetSim Notify Measurement Control Location - Event."));
		// cannot record this event since it may/maynot occur depending on timing but ...
		//		SetCurrentSeqEvent(ESelf_MOLR_NetSim_Got_NotifyMeasurementControlLocation);
		// ... if we do get one of these, we must get a failure message so add that to adhoc list
		SetVerifyAdhocEvent(ESelf_MOLR_NetSim_Got_NotifyMeasurementReportControlFailure);
		}
		
	else if(iState == EReqX3PPush)
		{
		INFO_PRINTF1(_L("Got - X3P(PUSH) MOLR - NetSim Notify Measurement Control Location - Event."));
		SetCurrentSeqEvent(EX3P_PUSH_MOLR_NetSim_Got_NotifyMeasurementControlLocation);
		}


	// Verify the reference position.
	TPositionInfo verifyRefPosInfo;
	
	verifyRefPosInfo.SetPosition(iRefPos);
	if (!utils.Compare_PosInfo(verifyRefPosInfo, aPosition))
		{
		INFO_PRINTF1(_L("Failed test, position incorrect."));
		SetTestStepResult(EFail);
		}

   
	// Verify the assistance data.	
	RLbsAssistanceDataBuilderSet& data = const_cast<RLbsAssistanceDataBuilderSet&>(aData);
	RUEPositioningGpsReferenceTimeBuilder* refTimeBuilder = NULL;
	
	data.GetDataBuilder(refTimeBuilder);

	// Create a reader from the builder's data to allow us to verify the actual
	// assistance data.
	RUEPositioningGpsReferenceTimeReader refTimeReader;
		
	TRAP(err, refTimeReader.OpenL());
	if (err == KErrNone)
		{
		refTimeReader.DataBuffer() = refTimeBuilder->DataBuffer();
		
		if (!utils.VerifySimpleAssistanceData(refTimeReader))
			{
			INFO_PRINTF1(_L("Failed test, assistance data incorrect."));
			SetTestStepResult(EFail);
			}
		refTimeReader.Close();
		}
			
	else
		{
		INFO_PRINTF2(_L("Failed test, assistance data reader err %d."), err);
		SetTestStepResult(EFail);
		}


	// TODO: Check if we can verify aQuality in any way.
	(void)aQuality;
	}
/** Convert times using multiple TZ converter objects
*/	
void CTestTZServer::MulitpleTZConverterL()
	{
	CActiveScheduler* scheduler;
	scheduler = new CActiveScheduler();
	CleanupStack::PushL(scheduler);  
	CActiveScheduler::Install(scheduler);
	
	TPtrC	ptrSystemTime;
	TESTL(GetStringFromConfig(ConfigSection(), KTime, ptrSystemTime));
	TTime	time(ptrSystemTime);	
	
	_LIT8(KEuropeLondon, "Europe/London");
	CTzId* zoneId = CTzId::NewL(KEuropeLondon);
	
	CleanupStack::PushL(zoneId);

	RTz tz;
	CTzConverter* timeConverter = NULL;
	CTzConverter* timeConverter1 = NULL;
	CTzConverter* timeConverter2 = NULL;
	CTzConverter* timeConverter3 = NULL;
	CTzConverter* timeConverter4 = NULL;
	CTzConverter* timeConverter5 = NULL;
	CTzConverter* timeConverter6 = NULL;
	CTzConverter* timeConverter7 = NULL;

	CleanupClosePushL(tz);
	User::LeaveIfError(tz.Connect());
	
	TRAPD(err,timeConverter = CTzConverter::NewL(tz));
	TESTL(err == KErrNone);
	CleanupStack::PushL(timeConverter);

	TRAP(err,timeConverter1 = CTzConverter::NewL(tz));
	TESTL(err == KErrNone);
	CleanupStack::PushL(timeConverter1);
	
	TRAP(err,timeConverter2 = CTzConverter::NewL(tz));
	TESTL(err == KErrNone);
	CleanupStack::PushL(timeConverter2);
	
	TRAP(err,timeConverter3 = CTzConverter::NewL(tz));
	TESTL(err == KErrNone);
	CleanupStack::PushL(timeConverter3);
	
	TRAP(err,timeConverter4 = CTzConverter::NewL(tz));
	TESTL(err == KErrNone);
	CleanupStack::PushL(timeConverter4);
	
	TRAP(err,timeConverter5 = CTzConverter::NewL(tz));
	TESTL(err == KErrNone);
	CleanupStack::PushL(timeConverter5);
	
	TRAP(err,timeConverter6 = CTzConverter::NewL(tz));
	TESTL(err == KErrNone);
	CleanupStack::PushL(timeConverter6);
	
	TRAP(err,timeConverter7 = CTzConverter::NewL(tz));
	TESTL(err == KErrNone);
	CleanupStack::PushL(timeConverter7);
	
	TRAP(err, timeConverter->ConvertToLocalTime(time, *zoneId));
	TESTL(err == KErrNone);
	TRAP(err, timeConverter1->ConvertToLocalTime(time, *zoneId));
	TESTL(err == KErrNone);
	TRAP(err, timeConverter2->ConvertToLocalTime(time, *zoneId));
	TESTL(err == KErrNone);
	TRAP(err, timeConverter3->ConvertToLocalTime(time, *zoneId));
	TESTL(err == KErrNone);
	TRAP(err, timeConverter4->ConvertToLocalTime(time, *zoneId));
	TESTL(err == KErrNone);
	TRAP(err, timeConverter5->ConvertToLocalTime(time, *zoneId));
	TESTL(err == KErrNone);
	TRAP(err, timeConverter6->ConvertToLocalTime(time, *zoneId));
	TESTL(err == KErrNone);
	TRAP(err, timeConverter7->ConvertToLocalTime(time, *zoneId));
	TESTL(err == KErrNone);
	
	TRAP(err, timeConverter->ConvertToLocalTime(time));
	TESTL(err == KErrNone);
	TRAP(err, timeConverter1->ConvertToLocalTime(time));
	TESTL(err == KErrNone);
	TRAP(err, timeConverter2->ConvertToLocalTime(time));
	TESTL(err == KErrNone);
	TRAP(err, timeConverter3->ConvertToLocalTime(time));
	TESTL(err == KErrNone);
	TRAP(err, timeConverter4->ConvertToLocalTime(time));
	TESTL(err == KErrNone);
	TRAP(err, timeConverter5->ConvertToLocalTime(time));
	TESTL(err == KErrNone);
	TRAP(err, timeConverter6->ConvertToLocalTime(time));
	TESTL(err == KErrNone);
	TRAP(err, timeConverter7->ConvertToLocalTime(time));
	TESTL(err == KErrNone);
	
	TRAP(err, timeConverter->ConvertToUniversalTime(time));
	TESTL(err == KErrNone);
	TRAP(err, timeConverter1->ConvertToUniversalTime(time));
	TESTL(err == KErrNone);
	TRAP(err, timeConverter2->ConvertToUniversalTime(time));
	TESTL(err == KErrNone);
	TRAP(err, timeConverter3->ConvertToUniversalTime(time));
	TESTL(err == KErrNone);
	TRAP(err, timeConverter4->ConvertToUniversalTime(time));
	TESTL(err == KErrNone);
	TRAP(err, timeConverter5->ConvertToUniversalTime(time));
	TESTL(err == KErrNone);
	TRAP(err, timeConverter6->ConvertToUniversalTime(time));
	TESTL(err == KErrNone);
	TRAP(err, timeConverter7->ConvertToUniversalTime(time));
	TESTL(err == KErrNone);
	
	TRAP(err, timeConverter->ConvertToUniversalTime(time, *zoneId));
	TESTL(err == KErrNone);
	TRAP(err, timeConverter1->ConvertToUniversalTime(time, *zoneId));
	TESTL(err == KErrNone);
	TRAP(err, timeConverter2->ConvertToUniversalTime(time, *zoneId));
	TESTL(err == KErrNone);
	TRAP(err, timeConverter3->ConvertToUniversalTime(time, *zoneId));
	TESTL(err == KErrNone);
	TRAP(err, timeConverter4->ConvertToUniversalTime(time, *zoneId));
	TESTL(err == KErrNone);
	TRAP(err, timeConverter5->ConvertToUniversalTime(time, *zoneId));
	TESTL(err == KErrNone);
	TRAP(err, timeConverter6->ConvertToUniversalTime(time, *zoneId));
	TESTL(err == KErrNone);
	TRAP(err, timeConverter7->ConvertToUniversalTime(time, *zoneId));
	TESTL(err == KErrNone);
	
	CleanupStack::PopAndDestroy(timeConverter7);
	CleanupStack::PopAndDestroy(timeConverter6);
	CleanupStack::PopAndDestroy(timeConverter5);
	CleanupStack::PopAndDestroy(timeConverter4);
	CleanupStack::PopAndDestroy(timeConverter3);
	CleanupStack::PopAndDestroy(timeConverter2);
	CleanupStack::PopAndDestroy(timeConverter1);
	CleanupStack::PopAndDestroy(timeConverter);
	CleanupStack::PopAndDestroy(&tz);
	CleanupStack::PopAndDestroy(zoneId);
	
	CleanupStack::PopAndDestroy(scheduler);
	
	CActiveScheduler::Install(NULL);
	}
Beispiel #17
0
void game::init_traps()
{
 int id = -1;
#define TRAP(name, sym, color, visibility, avoidance, difficulty, action, ...) \
id++;\
traps.push_back(new trap(id, sym, color, name, visibility, avoidance,\
                    difficulty, action, __VA_ARGS__));
 TRAP("none", '?', c_white, 20, 0, 0, &trapfunc::none, &trapfuncm::none,
      NULL);

//	Name			Symbol	Color		Vis Avd Diff
 TRAP("bubblewrap",		'_',	c_ltcyan,	 0,  8,  0,
	&trapfunc::bubble,	&trapfuncm::bubble,
	itm_bubblewrap, NULL);
//      Name                    Symbol  Colour          Vis Avd Diff
 TRAP("cot",                    '#',    c_green,         0,  0,  0,
        &trapfunc::none,         &trapfuncm::cot,
        itm_cot, NULL);

//      Name                    Symbol  Colour          Vis Avd Diff
 TRAP("brazier",                '#',    c_red,           0,  0,  0,
        &trapfunc::none,         &trapfuncm::none,
        itm_brazier, NULL);

//      Name                    Symbol  Colour          Vis Avd Diff
 TRAP("roll mat",               '#',    c_blue,          0,  0,  0,
        &trapfunc::none,     &trapfuncm::none,
        itm_rollmat, NULL);
//	Name			Symbol	Color		Vis Avd Diff
 TRAP("bear trap",		'^',	c_blue,		 2,  7,  3,
	&trapfunc::beartrap,	&trapfuncm::beartrap,
	itm_beartrap, NULL);

//	Name			Symbol	Color		Vis Avd Diff
 TRAP("buried bear trap",	'^',	c_blue,		 9,  8,  4,
	&trapfunc::beartrap,	&trapfuncm::beartrap,
	itm_beartrap, NULL);

//	Name			Symbol	Color		Vis Avd Diff
 TRAP("rabbit snare",		'\\',	c_brown,	 5, 10,  2,
	&trapfunc::snare,	&trapfuncm::snare,
	itm_stick, itm_string_36, NULL);

 TRAP("spiked board",		'_',	c_ltgray,	 1,  6,  0,
	&trapfunc::board,	&trapfuncm::board,
	itm_board_trap, NULL);

 TRAP("tripwire",		'^',	c_ltred,	 6,  4,  3,
	&trapfunc::tripwire,	&trapfuncm::tripwire,
	itm_string_36, NULL);

 TRAP("crossbow trap",		'^',	c_green,	 5,  4,  5,
	&trapfunc::crossbow,	&trapfuncm::crossbow,
	itm_string_36, itm_crossbow, NULL);

 TRAP("shotgun trap",		'^',	c_red,		 4,  5,  6,// 2 shots
	&trapfunc::shotgun,	&trapfuncm::shotgun,
	itm_string_36, itm_shotgun_sawn, NULL);

 TRAP("shotgun trap",		'^',	c_red,		 4,  5,  6,// 1 shot
	&trapfunc::shotgun,	&trapfuncm::shotgun,
	itm_string_36, itm_shotgun_sawn, NULL);

 TRAP("spinning blade engine",	'_',	c_ltred,	 0,  0,  2,
	&trapfunc::none,	&trapfuncm::none,
	itm_motor, itm_machete, itm_machete, NULL);

 TRAP("spinning blade",		'\\',	c_cyan,		 0,  4, 99,
	&trapfunc::blade,	&trapfuncm::blade,
	NULL);

//	Name			Symbol	Color		Vis Avd Diff
 TRAP("land mine",		'_',	c_red,		10, 14, 10,
	&trapfunc::landmine,	&trapfuncm::landmine,
	itm_landmine, NULL);

//	Name			Symbol	Color		Vis Avd Diff
 TRAP("teleport pad",		'_',	c_magenta,	 0, 15, 20,
	&trapfunc::telepad,	&trapfuncm::telepad,
	itm_null, NULL);

//	Name			Symbol	Color		Vis Avd Diff
 TRAP("goo pit",		'_',	c_dkgray,	 0, 15, 15,
	&trapfunc::goo,		&trapfuncm::goo,
	itm_null, NULL);

//	Name			Symbol	Color		Vis Avd Diff
 TRAP("dissector",		'7',	c_cyan,		 2, 20, 99,
	&trapfunc::dissector,	&trapfuncm::dissector,
	itm_null, NULL);

//	Name			Symbol	Color		Vis Avd Diff
 TRAP("sinkhole",		'_',	c_brown,	10, 14, 99,
	&trapfunc::sinkhole,	&trapfuncm::sinkhole,
	itm_null, NULL);

 TRAP("pit",			'0',	c_brown,	 0,  8, 99,
	&trapfunc::pit,		&trapfuncm::pit,
	itm_null, NULL);

 TRAP("spiked pit",		'0',	c_blue,		 0,  8, 99,
	&trapfunc::pit_spikes,	&trapfuncm::pit_spikes,
	itm_null, NULL);

 TRAP("lava",			'~',	c_red,		 0, 99, 99,
	&trapfunc::lava,	&trapfuncm::lava,
	itm_null, NULL);

// The '%' symbol makes the portal cycle through ~*0&
//	Name			Symbol	Color		Vis Avd Diff
 TRAP("shimmering portal",	'%',	c_magenta,	 0, 30, 99,
	&trapfunc::portal,	&trapfuncm::portal,
	itm_null, NULL);

 TRAP("ledge",			' ',	c_black,	 0, 99, 99,
	&trapfunc::ledge,	&trapfuncm::ledge,
	itm_null, NULL);

 TRAP("boobytrap",		'^',	c_ltcyan,	 5,  4,  7,
 	&trapfunc::boobytrap,	&trapfuncm::boobytrap,
 	itm_null, NULL);

 TRAP("raised tile",		'^',	c_ltgray,	 9, 20, 99,
	&trapfunc::temple_flood,&trapfuncm::none,
	itm_null, NULL);

// Toggles through states of RGB walls
 TRAP("",			'^',	c_white,	99, 99, 99,
	&trapfunc::temple_toggle,	&trapfuncm::none,
	itm_null, NULL);

// Glow attack
 TRAP("",			'^',	c_white,	99, 99, 99,
	&trapfunc::glow,	&trapfuncm::glow,
	itm_null, NULL);

// Hum attack
 TRAP("",			'^',	c_white,	99, 99, 99,
	&trapfunc::hum,		&trapfuncm::hum,
	itm_null, NULL);

// Shadow spawn
 TRAP("",			'^',	c_white,	99, 99, 99,
	&trapfunc::shadow,	&trapfuncm::none,
	itm_null, NULL);

// Drain attack
 TRAP("",			'^',	c_white,	99, 99, 99,
	&trapfunc::drain,	&trapfuncm::drain,
	itm_null, NULL);

// Snake spawn / hisssss
 TRAP("",			'^',	c_white,	99, 99, 99,
	&trapfunc::snake,	&trapfuncm::snake,
	itm_null, NULL);

}
/**
  ExecuteActionL
	Obtain the input parameters
	1.	sendAsMessage
	2.	recipientAddress
	3.	alias  (Default value implies empty string)
	4. recipientAddress1
	5.	recipientType 
	IF alias for recipient address is provided as input 
	Call RSendAsMessage::AddRecipient (const TDesC& aAddress, const TDesC& aAlias, 
	TSendAsRecipientType aRecipientType) passing recipientAddress, alias and
	recipientType as input parameters
    ELSE 
	Call RSendAsMessage::AddRecipient (const TDesC& aAddress, TSendAsRecipientType aRecipientType) passing recipientAddress and recipientType as input parameters

  @internalTechnology 
  @pre    None
  @post   None
  @leave  System wide errors
*/
void CMtfTestActionSendAsAddMultipleRecipient::ExecuteActionL()
	{
	if((TestCase().TestStepResult()) == EPass)
		{
		TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSendAsAddMultipleRecipient);

		// Get test action input parameters
		RSendAsMessage sendAsMessage = ObtainValueParameterL<RSendAsMessage>(TestCase(),
											ActionParameters().Parameter(0));

		HBufC*  recipientAddress	 = ObtainParameterReferenceL<HBufC>(TestCase(),
											ActionParameters().Parameter(1), NULL);


		HBufC* alias				 = ObtainParameterReferenceL<HBufC>(TestCase(),
											ActionParameters().Parameter(2), NULL);

		
		RSendAsMessage::TSendAsRecipientType recipientType	
									 = ObtainValueParameterL<RSendAsMessage::TSendAsRecipientType>(TestCase(),
											ActionParameters().Parameter(3));

		TUid msgTypeId				 =  ObtainValueParameterL<TUid>(TestCase(),
											ActionParameters().Parameter(4));
											
		TInt expectedErr			 =  ObtainValueParameterL<TInt>(TestCase(),
											ActionParameters().Parameter(5));
		//Get the second recipient address
		HBufC*  recipientAddress1	 = ObtainParameterReferenceL<HBufC>(TestCase(),
											ActionParameters().Parameter(6), NULL);
										
		TInt err = KErrNone;
		TBuf16<3> btAddress;
						

		if(recipientAddress == NULL)
			{
			if( msgTypeId.operator == (KUidMsgTypeSMTP))
				{
				TMsvId paramServiceId = ObtainValueParameterL<TMsvId>(TestCase(), ActionParameters().Parameter(7), 0);
				CImSmtpSettings* settings = new(ELeave) CImSmtpSettings();
				CleanupStack::PushL(settings);
		 		
		 		CEmailAccounts* accounts = CEmailAccounts::NewLC();
		 		TSmtpAccount smtpAccount;
		 		accounts->GetSmtpAccountL(paramServiceId, smtpAccount);
				accounts->LoadSmtpSettingsL(smtpAccount, *settings);
				CleanupStack::PopAndDestroy(accounts);
				
				recipientAddress=settings->EmailAddress().AllocL();
				CleanupStack::PopAndDestroy(settings);
				}
			else
				{
				TestCase().ERR_PRINTF1(_L("Recipient address is not provided"));
				TestCase().SetTestStepResult(EFail);
				}
			}
		else
			{
			if( msgTypeId.operator == (KUidMsgTypeBt))
				{
				CMtfTestActionUtilsMessage::FormatBtRecipientAddress(*recipientAddress, btAddress);
				}
			}
		if((TestCase().TestStepResult()) == EPass)
			{
			if(alias == NULL )
				{
				if( msgTypeId.operator == (KUidMsgTypeBt))
					{
					TRAP(err,sendAsMessage.AddRecipientL(btAddress, recipientType));
					}
				else
					{
					TRAP(err,sendAsMessage.AddRecipientL(*recipientAddress, recipientType));
					TRAP(err, sendAsMessage.AddRecipientL(*recipientAddress1,  recipientType));
					}
				if(err == expectedErr)
					{
					TestCase().INFO_PRINTF1(_L("Recipient address added successfully"));	
					}
				else
					{
					TestCase().ERR_PRINTF2(_L("Add Recipient address failed with error %d"), err);
					}
				}
			else
				{
				if( msgTypeId.operator == (KUidMsgTypeBt))
					{
					TRAP(err,sendAsMessage.AddRecipientL(btAddress, alias->Des(), recipientType));
					}
				else
					{
					TRAP(err, sendAsMessage.AddRecipientL(recipientAddress->Des(), alias->Des(), recipientType));
					}

				if (err == expectedErr)
					{
					if(err == KErrNone)
						{
						TestCase().INFO_PRINTF1(_L("Recipient address with alias added successfully"));						
						}
					else
						{
						TestCase().INFO_PRINTF1(_L("Recipient address with alias failed with expected error"));
						}
					}
				else
					{
					TestCase().ERR_PRINTF2(_L("Add Recipient address with alias failed with error %d"), err);
					}
				}
				
			}
									
			TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSendAsAddMultipleRecipient);
		}
	TestCase().ActionCompletedL(*this);
	}
TVerdict CTestDevVideoPlayCustomInterface::DoTestL(CMMFDevVideoPlay& aDevVideoPlay)
	{
	INFO_PRINTF1(_L("CMMFDevVideoPlay:  CustomInterface"));

	THwDeviceId hwDecoder = 0;
	THwDeviceId hwPostProc = 0;
	TInt err = KErrNone;

	TRAP(err, hwDecoder = aDevVideoPlay.SelectDecoderL(KUidDevVideoTestDecodeHwDevice));
	if (err != KErrNone)
		{
		ERR_PRINTF1(_L("Error - couldn't initialize decoder"));
			return EInconclusive;
		}
	
	TRAP(err, hwPostProc = aDevVideoPlay.SelectPostProcessorL(KUidDevVideoTestPostProcHwDevice));
	if (err != KErrNone)
		{
		ERR_PRINTF1(_L("Error - couldn't initialize post processor"));
			return EInconclusive;
		}

	// First try test uninitialized

	TAny* ciOne = NULL;
	TAny* ciTwo = NULL;
	TAny* ciThree = NULL;
	TAny* ciFour = NULL;
	
	ciOne = aDevVideoPlay.CustomInterface(hwDecoder, KUidCustomInterfaceOne);
	ciTwo = aDevVideoPlay.CustomInterface(hwDecoder, KUidCustomInterfaceTwo);
	ciThree = aDevVideoPlay.CustomInterface(hwPostProc, KUidCustomInterfaceTwo);
	ciFour = aDevVideoPlay.CustomInterface(hwPostProc, KUidCustomInterfaceOne);

	if (ciOne==NULL || ciTwo!=NULL || ciThree==NULL || ciFour!=NULL)
		{
		ERR_PRINTF1(_L("Test Failed - wrong interfaces returned"));
		return EFail;
		}

	// Next, re-perform test initialized.

	// initialize CDevVideoPlay and wait for response
	// iError is set by the MdvpoInitComplete callback
	aDevVideoPlay.Initialize();
	
	if (iError != KErrNone)
		{
		ERR_PRINTF1(_L("Error - couldn't initialize DevVideoPlay"));
		return EInconclusive;
		}

	ciOne = NULL;
	ciTwo = NULL;
	ciThree = NULL;
	ciFour = NULL;
	
	ciOne = aDevVideoPlay.CustomInterface(hwDecoder, KUidCustomInterfaceOne);
	ciTwo = aDevVideoPlay.CustomInterface(hwDecoder, KUidCustomInterfaceTwo);
	ciThree = aDevVideoPlay.CustomInterface(hwPostProc, KUidCustomInterfaceTwo);
	ciFour = aDevVideoPlay.CustomInterface(hwPostProc, KUidCustomInterfaceOne);

	if (ciOne==NULL || ciTwo!=NULL || ciThree==NULL || ciFour!=NULL)
		{
		ERR_PRINTF1(_L("Test Failed - wrong interfaces returned"));
		return EFail;
		}


	return EPass;
	}
EXPORT_C void AknsUtils::CreateAppIconLC(
    MAknsSkinInstance* aInstance, TUid aAppUid,
    TAknsAppIconType aType,
    CFbsBitmap*& aBitmap, CFbsBitmap*& aMask )
    {
    aBitmap = NULL;
    aMask = NULL;

    if (!aInstance)
        {
        User::Leave(KErrArgument);
        }

    TSize legacySize( 42, 29 );
    TInt bitmapIndex( 0 );
    TInt maskIndex( 1 );
    if( aType == EAknsAppIconTypeContext )
        {
        legacySize = TSize( 44, 44 );
        bitmapIndex = 2;
        maskIndex = 3;
        }
    else if( aType != EAknsAppIconTypeList )
        {
        User::Leave( KErrArgument );
        }

    // Make the forthcoming pushes safe (up to level 2)
    CleanupStack::PushL( static_cast<TAny*>(NULL) );
    CleanupStack::PushL( static_cast<TAny*>(NULL) );
    CleanupStack::Pop( 2 );

    // 1. Check if the icon has been configured.
    TInt ret = KErrNone;
    TBool configuredIcon = EFalse;
    //
    CAknsAppSkinInstance* apskin = static_cast<CAknsAppSkinInstance*>(aInstance);
    if ( apskin )
        {
        TInt config = apskin->IsIconConfiguredL( aAppUid );
        if ( config > 0 )
        configuredIcon = ETrue;
        }

    if ( !configuredIcon )
        {
        // 2. Skin-originating icon
        ret = GetAppIconFromSkin( aInstance, aAppUid, legacySize, aBitmap, aMask );
        if( ret == KErrNone )
            {
            // These pushes are safe
            CleanupStack::PushL( aBitmap ); // (1)
            CleanupStack::PushL( aMask ); // (2)
            return;
            }
        }
    // Cache connected apparc session for future reuse, if not already cached
    // This is done per appskininstance when necessary...
    if (!apskin->iCachedApaSession)
        {
        apskin->iCachedApaSession = new (ELeave) RApaLsSession;
        User::LeaveIfError(apskin->iCachedApaSession->Connect());
        }

    RApaLsSession* lsSession = apskin->iCachedApaSession;

    TBool forceDefaultIcon = EFalse;

    TApaAppInfo appInfo;
    TFileName filename;
    // 3. New appicon framework
    HBufC* filenameBuf = NULL;
    TBool javaIcon = EFalse;
    ret = lsSession->GetAppIcon( aAppUid, filenameBuf );
    if( filenameBuf )
        {
        filename.Copy( *filenameBuf );
        delete filenameBuf;
        }
    if( ret == KErrNone )
        {
        ret = lsSession->GetAppInfo( appInfo, aAppUid );
        }
    if( (ret==KErrNone) && (filename.Length()>2) &&
        (appInfo.iFullName.Length()>2) )
        {
        // Correct drive letter, if necessary
        if( appInfo.iFullName[1]==':' )
            {
            if( filename[1]==':' )
                {
                filename[0] = appInfo.iFullName[0];
                }
            else if( filename[0]=='\\' )
                {
                filename.Insert( 0, appInfo.iFullName.Left(2) );
                }
            }

        // check if the icon is java icon
        javaIcon = AknsJavaUtils::IsJavaIcon(filename);

        if( AknIconUtils::IsMifFile( filename ) )
            {
            // SVG icon
            // SVG always has only one icon
            bitmapIndex = 0;
            maskIndex = 1;
            AknIconUtils::ValidateLogicalAppIconId( filename,
                bitmapIndex, maskIndex );

            if (javaIcon)
                {
                AknsJavaUtils::CreateIconLC(*lsSession, aAppUid, aBitmap,
                    aMask, bitmapIndex, maskIndex ); // aBitmap, aMask (2)
                }
            else
                {
                AknIconUtils::CreateIconLC( aBitmap, aMask, filename,
                    bitmapIndex, maskIndex ); // aBitmap, aMask (2)
                }
            AknInternalIconUtils::SetAppIcon(aBitmap); //icon case
            return;
            }
        else
            {
            // MBM icon
            AknIconUtils::ValidateLogicalAppIconId( filename,
                bitmapIndex, maskIndex );
            TRAP( ret, AknIconUtils::CreateIconL( aBitmap, aMask, filename,
                bitmapIndex, maskIndex ) );
            if( ret == KErrNone )
                {
                // These pushes are safe
                CleanupStack::PushL( aBitmap ); // (1)
                CleanupStack::PushL( aMask ); // (2)
                }
            else
                {
                bitmapIndex = 0;
                maskIndex = 1;
                AknIconUtils::ValidateLogicalAppIconId( filename,
                    bitmapIndex, maskIndex );
                AknIconUtils::CreateIconLC( aBitmap, aMask, filename,
                    bitmapIndex, maskIndex ); // aBitmap, aMask (2)
                }
            AknInternalIconUtils::SetAppIcon(aBitmap); //icon case
            return;
            }
        }
    else if( ret!=KErrNotSupported )
        {
        // New framework, but no icon defined
        forceDefaultIcon = ETrue;
        }

    CApaMaskedBitmap* apaBmp = CApaMaskedBitmap::NewLC(); // apaBmp (1)
    // 3. Old (AIF-based) framework
    if( !forceDefaultIcon )
        {
        TInt apaErr = lsSession->GetAppIcon( aAppUid, legacySize, *apaBmp );
        // Use default icon if APPARC did not initialize icon bitmaps
        if( apaErr || (!apaBmp) || (!apaBmp->Mask()) ||
            (!apaBmp->Handle()) || (!apaBmp->Mask()->Handle()) )
            {
            forceDefaultIcon = ETrue;
            }
        }

    if( forceDefaultIcon )
        {
        // Default icon
        CleanupStack::PopAndDestroy( 1 ); // apaBmp (0)
        TAknsItemID iid = KAknsIIDQgnMenuUnknownLst;
        bitmapIndex = EMbmAvkonQgn_menu_unknown_lst;
        maskIndex = EMbmAvkonQgn_menu_unknown_lst_mask;
        if( aType == EAknsAppIconTypeContext )
            {
            iid = KAknsIIDQgnMenuUnknownCxt;
            bitmapIndex = EMbmAvkonQgn_menu_unknown_cxt;
            maskIndex = EMbmAvkonQgn_menu_unknown_cxt_mask;
            }
        AknsUtils::CreateIconLC( aInstance, iid, aBitmap, aMask,
            AknIconUtils::AvkonIconFileName(), bitmapIndex, maskIndex ); // aBitmap, aMask (2)
        }
    else
        {
        // AIF-based icon
        CFbsBitmap* iconOwnedBitmap = new (ELeave) CFbsBitmap();
        CleanupStack::PushL( iconOwnedBitmap ); // iob (3)
        CFbsBitmap* iconOwnedMask = new (ELeave) CFbsBitmap();
        CleanupStack::PushL( iconOwnedMask ); // iom (4)
        User::LeaveIfError(
            iconOwnedBitmap->Duplicate( apaBmp->Handle() ) );
        User::LeaveIfError(
            iconOwnedMask->Duplicate( apaBmp->Mask()->Handle() ) );

        CAknIcon* tmpIcon = CAknIcon::NewL();
        CleanupStack::Pop( 2 ); // iom, iob (2)
        CleanupStack::PopAndDestroy( 1 ); // apaBmp (0)

        // Ownership is transferred
        tmpIcon->SetBitmap( iconOwnedBitmap );
        tmpIcon->SetMask( iconOwnedMask );
        // Ownership of tmpIcon is transferred
        CAknIcon* appIcon = AknIconUtils::CreateIconL( tmpIcon );

        aBitmap = appIcon->Bitmap();
        aMask = appIcon->Mask();
        // Detach and delete
        appIcon->SetBitmap( NULL );
        appIcon->SetMask( NULL );
        delete appIcon;

        // These are both safe
        CleanupStack::PushL( aBitmap ); // (1)
        CleanupStack::PushL( aMask ); // (2)
        }
    }
void CTestDevVideoPlayNextPicture::MdvpoNewPictures()
	{
	TRAP(iError, DoNewPicturesL());
	}
/**
 * Calls RSysMonSession::MonitorL twice. the first call is expected to succeed and the second call
 * returns KErrNone in release builds, whereas panics in debug builds
 */	
void CStepProcMonInit::DoTestMonitorL(const RProcess& aProcess, const TDesC& aFilename, const TInt aStartUpPropType)
	{
	RSysMonSession sess;
	sess.OpenL();
	CleanupClosePushL(sess);
	
	if (aStartUpPropType)
		{
		CSsmStartupProperties* prop = CSsmStartupProperties::NewLC(aFilename, KNullDesC);
		// Testing consistency assertion of aStartupProperties in RSysMonSession::MonitorL
		TRAPD(err, sess.MonitorL(*prop, aProcess)); 
		TESTE(err == KErrArgument, err);
		if(err == KErrArgument)
			{
			INFO_PRINTF1(_L("Monitor request with invalid args was refused properly by RSysMonSession::MonitorL using ssmstartupproperties"));
			}
		
		prop->SetExecutionBehaviour(ESsmWaitForSignal);
		TSsmMonitorInfo monitorInfo;
		monitorInfo.iRestartPolicy = ESsmIgnoreOnFailure;
		monitorInfo.iRestartMode = 0;
		monitorInfo.iTimeout = 0;
		monitorInfo.iRetries = 0;
		prop->SetMonitorInfoL(monitorInfo); // SysMon will not do any restart attempts
		
		// monitoring first time should succeed
		TRAP(err, sess.MonitorL(*prop, aProcess)); 
		TESTEL(err == KErrNone, err);
		INFO_PRINTF1(_L("First monitor request succeeded"));
		
		TRAP(err, sess.MonitorL(*prop, aProcess)); 
		TESTE(err == KErrAlreadyExists, err);
		if(err == KErrAlreadyExists)
			{
			INFO_PRINTF1(_L("Second monitor request returned KErrAlreadyExists as expected"));
			}
		
		CleanupStack::PopAndDestroy(prop);
		}
	else
		{
		CStartupProperties* prop = CStartupProperties::NewLC(aFilename, KNullDesC);
		// Testing consistency assertion of aStartupProperties in RSysMonSession::MonitorL
		TRAPD(err, sess.MonitorL(*prop, aProcess)); 
		TESTE(err == KErrArgument, err);
		if(err == KErrArgument)
			{
			INFO_PRINTF1(_L("Monitor request with invalid args was refused properly by RSysMonSession::MonitorL using startupproperties"));
			}
		
		prop->SetMonitored(ETrue);
		prop->SetNoOfRetries(0); // SysMon will not do any restart attempts
		
		// monitoring first time should succeed
		TRAP(err, sess.MonitorL(*prop, aProcess)); 
		TESTEL(err == KErrNone, err);
		INFO_PRINTF1(_L("First monitor request succeeded"));
		
		TRAP(err, sess.MonitorL(*prop, aProcess)); 
		TESTE(err == KErrAlreadyExists, err);
		if(err == KErrAlreadyExists)
			{
			INFO_PRINTF1(_L("Second monitor request returned KErrAlreadyExists as expected"));
			}

		CleanupStack::PopAndDestroy(prop);
		}
	CleanupStack::PopAndDestroy(&sess);
	}
TVerdict CTestDevVideoPlayGetNewPictureInfo::DoTestL(CMMFDevVideoPlay& aDevVideoPlay)
	{
	TVerdict ret = EFail;
	
	INFO_PRINTF1(_L("CMMFDevVideoPlay:  GetNewPictureInfo"));
	
	// expected results
	if (iTestType != ETestValid)
		{
		ERR_PRINTF1(_L("Error - invalid test step type"));
		return EInconclusive;
		}

	TInt err = KErrNone;

//	THwDeviceId hwDecoder = 0;
//	THwDeviceId hwPostProc = 0;

	// select decoder
//	TRAP(err, hwDecoder = aDevVideoPlay.SelectDecoderL(KUidDevVideoTestDecodeHwDevice));
	TRAP(err, aDevVideoPlay.SelectDecoderL(KUidDevVideoTestDecodeHwDevice));	// EABI warning removal
	if (err != KErrNone)
		{
		ERR_PRINTF1(_L("Error - couldn't initialize decoder"));
			return EInconclusive;
		}

	// select post-processor
//	TRAP(err, hwPostProc = aDevVideoPlay.SelectPostProcessorL(KUidDevVideoTestPostProcHwDevice));
	TRAP(err, aDevVideoPlay.SelectPostProcessorL(KUidDevVideoTestPostProcHwDevice));	// EABI warning removal
	if (err != KErrNone)
		{
		ERR_PRINTF1(_L("Error - couldn't initialize post processor"));
			return EInconclusive;
		}

	//Tell plugin to start creating pictures.
	TRAP(iError, aDevVideoPlay.SetVideoDestScreenL(EFalse));
	if (iError != KErrNone)
		{
		ERR_PRINTF1(_L("Error - couldn't SetVideoDestScreen"));
			return EInconclusive;
		}

	// initialize CDevVideoPlay and wait for response
	// iError is set by the MdvpoInitComplete callback
	aDevVideoPlay.Initialize();

	if (iError != KErrNone)
		{
		ERR_PRINTF1(_L("Error - couldn't initialize DevVideoPlay"));
			return EInconclusive;
		}

	aDevVideoPlay.Start();

	TUint numPictures = 0;
	TTimeIntervalMicroSeconds earliestTimeStamp(0);
	TTimeIntervalMicroSeconds latestTimeStamp(0);


	aDevVideoPlay.GetNewPictureInfo(numPictures, earliestTimeStamp, latestTimeStamp);

	if ((numPictures == 1)
		&& (earliestTimeStamp == TTimeIntervalMicroSeconds(0))
		&& (latestTimeStamp == TTimeIntervalMicroSeconds(0)))
		{
		ret = EPass;
		}
	
	return ret;
	}
/*
Bonus-test APPFWK-SYSMON-0001C 
Testing consistency of assertions in RSysMonSession::MonitorL
*/
void CStepProcMonInit::DoTestErrArgumentL()
	{
	INFO_PRINTF1(_L("TEST APPFWK-SYSMON-0001C -  validade that sysmon refuse invalid requests"));

	RProcess process;
	CleanupClosePushL(process);
	User::LeaveIfError(process.Create(KTestProcGood, KNullDesC));
	ResumeL(process);
	
	RSysMonSession sess;
	sess.OpenL();
	CleanupClosePushL(sess);
	CStartupProperties* prop = CStartupProperties::NewLC(KTestProcGood, KNullDesC);
	CSsmStartupProperties* ssmProp = CSsmStartupProperties::NewLC(KTestProcGood, KNullDesC);
	
	INFO_PRINTF1(_L("Going to check if RSysMonSession::MonitorL correctly refuse monitor with CStartupProperties::Monitor()==EFalse using startupproperties"));
	TRAPD(err, sess.MonitorL(*prop, process)); 
	TESTE(err == KErrArgument, err);

	INFO_PRINTF1(_L("Going to check if RSysMonSession::MonitorL correctly refuse monitor with CStartupProperties::Monitor()==EFalse using ssmstartupproperties"));
	TRAP(err, sess.MonitorL(*ssmProp, process)); 
	TESTE(err == KErrArgument, err);
	
	INFO_PRINTF1(_L("Going to check if RSysMonSession::MonitorL correctly refuse monitor with CStartupProperties::StartMethod==EDeferredWaitForStart using startupproperties"));
	prop->SetStartMethod(EDeferredWaitForStart);
	prop->SetNoOfRetries(0);
	TRAP(err, sess.MonitorL(*prop, process)); 
	TESTE(err == KErrArgument, err);

	INFO_PRINTF1(_L("Going to check if RSysMonSession::MonitorL correctly refuse monitor with CStartupProperties::StartMethod==ESsmDeferredWaitForSignal using ssmstartupproperties"));
	ssmProp->SetExecutionBehaviour(ESsmDeferredWaitForSignal);	
	TSsmMonitorInfo monitorInfo;
	monitorInfo.iRestartPolicy = ESsmIgnoreOnFailure;
	monitorInfo.iRestartMode = 0;
	monitorInfo.iTimeout = 0;
	monitorInfo.iRetries = 0;
	ssmProp->SetMonitorInfoL(monitorInfo);
	TRAP(err, sess.MonitorL(*ssmProp, process)); 
	TESTE(err == KErrArgument, err);
	
	INFO_PRINTF1(_L("Going to check if RSysMonSession::MonitorL correctly refuse to restart another exe image than the one it monitors using startupproperties."));
	prop->SetStartMethod(EWaitForStart);
	prop->SetNoOfRetries(1);
	prop->SetFileParamsL(_L("sdkjfhsdk"), KNullDesC);
	TRAP(err, sess.MonitorL(*prop, process)); 
	TESTE(err == KErrArgument, err);

	INFO_PRINTF1(_L("Going to check if RSysMonSession::MonitorL correctly refuse to restart another exe image than the one it monitors using ssmsstartupproperties."));
	ssmProp->SetExecutionBehaviour(ESsmWaitForSignal);	
	monitorInfo.iRestartPolicy = ESsmIgnoreOnFailure;
	monitorInfo.iRestartMode = 0;
	monitorInfo.iTimeout = 0;
	monitorInfo.iRetries = 1;
	ssmProp->SetMonitorInfoL(monitorInfo);
	ssmProp->SetFileParamsL(_L("sdkjfhsdk"), KNullDesC);
	TRAP(err, sess.MonitorL(*ssmProp, process)); 
	TESTE(err == KErrArgument, err);

	INFO_PRINTF1(_L("Going to check if RSysMonSession::MonitorL correctly refuse to monitor a dead process using startupproperties."));
	prop->SetFileParamsL(KTestProcGood, KNullDesC);
	prop->SetStartMethod(EWaitForStart);
	prop->SetMonitored(ETrue);
	prop->SetNoOfRetries(1);
	process.Kill(KErrNone);
	TRAP(err, sess.MonitorL(*prop, process)); 
	TESTE(err == KErrDied, err);

	INFO_PRINTF1(_L("Going to check if RSysMonSession::MonitorL correctly refuse to monitor a dead process using ssmstartupproperties."));
	ssmProp->SetFileParamsL(KTestProcGood, KNullDesC);
	TRAP(err, sess.MonitorL(*ssmProp, process)); 
	TESTE(err == KErrDied, err);

	CleanupStack::PopAndDestroy(ssmProp);
	CleanupStack::PopAndDestroy(prop);
	CleanupStack::PopAndDestroy(&sess);
	CleanupStack::PopAndDestroy(&process);
	}
TVerdict CTestDevVideoPlayCancelTimedSnapshot::DoTestL(CMMFDevVideoPlay& aDevVideoPlay)
	{
	TVerdict ret = EFail;
	TInt expErr = KErrNone;
	
	INFO_PRINTF1(_L("CMMFDevVideoPlay:  CancelTimedSnapshot"));
	
	// expected results
	if (iTestType != ETestValid)
		{
		ERR_PRINTF1(_L("Error - invalid test step type"));
		return EInconclusive;
		}

	TInt err = KErrNone;

//	THwDeviceId hwDecoder = 0;
//	THwDeviceId hwPostProc = 0;

	// select decoder
//	TRAP(err, hwDecoder = aDevVideoPlay.SelectDecoderL(KUidDevVideoTestDecodeHwDevice));
	TRAP(err, aDevVideoPlay.SelectDecoderL(KUidDevVideoTestDecodeHwDevice));
	if (err != KErrNone)
		{
		ERR_PRINTF1(_L("Error - couldn't initialize decoder"));
			return EInconclusive;
		}

	// select post-processor
//	TRAP(err, hwPostProc = aDevVideoPlay.SelectPostProcessorL(KUidDevVideoTestPostProcHwDevice));
	TRAP(err, aDevVideoPlay.SelectPostProcessorL(KUidDevVideoTestPostProcHwDevice));
	if (err != KErrNone)
		{
		ERR_PRINTF1(_L("Error - couldn't initialize post processor"));
			return EInconclusive;
		}

	// initialize CDevVideoPlay and wait for response
	// iError is set by the MdvpoInitComplete callback
	aDevVideoPlay.Initialize();
	
	if (iError != KErrNone)
		{
		ERR_PRINTF1(_L("Error - couldn't initialize DevVideoPlay"));
			return EInconclusive;
		}

	
	TPictureData pictureData;

	TUncompressedVideoFormat format;
	format.iDataFormat = EYuvRawData;
	format.iYuvFormat = KTestYuvFormat1;
	TPictureId snapId = KTestSnapshotId;

	// get a timed snapshot from the post processor
	TRAP(err, aDevVideoPlay.GetTimedSnapshotL(&pictureData, format, snapId));

	// cancel the snapshot
	aDevVideoPlay.CancelTimedSnapshot();

	// check picture has been cancelled
	if (err == KErrNone) 
		{
		if (iError == KErrAbort)
			{
			INFO_PRINTF1(_L("Timed snapshot cancelled successfully"));
			ret = EPass;
			}
		else
			{
			ERR_PRINTF3(_L("MdvpoTimedSnapshotComplete() gave error %d (expected %d)"),iError, KErrAbort);			
			}
		}
	else
		{
		ERR_PRINTF3(_L("CancelTimedSnapshotL() gave error %d (expected %d)"),err, expErr);
		}

	return ret;
	}
//DEF063053  Additional method required on RDbs API for Secure Backup
static void DEF063053L()
	{
	//Invalid SID
	TheTest.Printf(_L("--Invalid backup SID: 0\n"));
	TSecureId backupSID = 0;
	TUid dbUid = {0x1133557A};
	CDbStrings* paths = NULL;
	TRAPD(err, paths = TheDbs.BackupPathsL(backupSID, dbUid));
	TEST2(err, KErrArgument);
	TEST(!paths);

	TheTest.Printf(_L("--Invalid backup SID: ECapability_None\n"));
	backupSID = (TUint32)ECapability_None;
	TRAP(err, paths = TheDbs.BackupPathsL(backupSID, dbUid));
	TEST2(err, KErrArgument);
	TEST(!paths);

	TheTest.Printf(_L("--Invalid backup SID: not matching the SID in security policy\n"));
	backupSID = (TUint32)0x109345FF;
	TRAP(err, paths = TheDbs.BackupPathsL(backupSID, dbUid));
	TEST2(err, KErrPermissionDenied);
	TEST(!paths);

	//Invalid UID
	TheTest.Printf(_L("--Invalid UID: no security policy for it\n"));
	backupSID = 0x30003000;
	dbUid.iUid = 0xFB34010F;
	TRAP(err, paths = TheDbs.BackupPathsL(backupSID, dbUid));
	TEST2(err, KErrArgument);
	TEST(!paths);

	TheTest.Printf(_L("--Invalid UID: 0\n"));
	dbUid.iUid = 0;
	TRAP(err, paths = TheDbs.BackupPathsL(backupSID, dbUid));
	TEST2(err, KErrArgument);
	TEST(!paths);

	//Valid arguments
	TheTest.Printf(_L("--Valid BackupPathL() arguments\n"));
	backupSID = 0x30003000;
	dbUid.iUid = 0x1133557A;
	TRAP(err, paths = TheDbs.BackupPathsL(backupSID, dbUid));
	TEST2(err, KErrNone);
	TEST(paths != NULL);
	for(TInt i=0;i<paths->Count();++i)
		{
		const TDesC& dd = (*paths)[i];
		RDebug::Print(_L("  Database %d: %S\r\n"), i + 1, &dd);
		}
	delete paths;
	paths = NULL;

	//Valid arguments, but no databases having the supplied security policy UID.
	TheTest.Printf(_L("--Valid BackupPathL() arguments, no databases\n"));
	backupSID = 0x30003001;
	dbUid.iUid = 0x11335577;
	TRAP(err, paths = TheDbs.BackupPathsL(backupSID, dbUid));
	TEST2(err, KErrNone);
	TEST(paths != NULL);
	TEST(paths->Count() == 0);
	delete paths;
	}
//-----------------------------------------------------------------------------
// CCFActionPlugInThread::ExecuteActionsInQueue
//-----------------------------------------------------------------------------
//
void CCFActionPlugInThread::ExecuteActionsInQueue()
    {
    FUNC_LOG;

    //__ASSERT_DEBUG( iPlugIn, Panic( EInvalidPluginPointer ) );

    TInt err = KErrNone;

    CCFActionPlugIn::TExecutionTime exec = CCFActionPlugIn::ENone;
    TInt timerValue = 0;

    // abort if we are already executing an action
    if ( iCurrentAction )
    	{
    	return;
    	}

    iCurrentAction = GetNextActionToExecute();

    do
        {
        // abort immediately if exit wanted
        if( iExit )
        	{
        	return;
        	}
        if( iCurrentAction )
            {
            // Prepare
            INFO( "PrepareExecution for action plug-in implementation" );
            TRAP( err, iPlugIn->PrepareExecutionL() );
            ERROR_1( err, "PrepareExecution failed with code: %d", err );

            // Execute if no errors, cannot continue if prepare fails
            if( err == KErrNone )
                {
                INFO( "ExecuteL for action plug-in implementation" );
                TRAP( err, exec = iPlugIn->ExecuteL( iCurrentAction ) );
                ERROR_1( err, "ExecuteL failed with code: %d", err );
                if( err == KErrNone )
                    {
                    // Wait completion. If request has already been completed
                    // this will return right away.
                    // Otherwise we'll wait here untill async ExecuteL is
                    // finished.
                    switch( exec )
                        {
                        case CCFActionPlugIn::ESmall:
                            {
                            timerValue = KSmallTimerValue;
                            break;
                            }
                        case CCFActionPlugIn::EMedium:
                            {
                            timerValue = KMediumTimerValue;
                            break;
                            }
                        case CCFActionPlugIn::ELong:
                            {
                            timerValue = KLongTimerValue;
                            break;
                            }
                        default:
                            {
                            // Nothing to do
                            break;
                            }
                        }
                    // Start active scheduler wait if we have an async operation.
                    // Callback timer will also be started to remove possible
                    // dead lock situations.
                    if( exec != CCFActionPlugIn::ENone )
                        {
                        INFO( "Started waiting for implementation to finnish async operation" );
                        if( !iWait->IsActive() )
                            {
                            iWait->Start( timerValue );
                            }
                        }
                    INFO( "FinishedExecution for action plug-in implementation" );
                    iPlugIn->FinishedExecution();
                    }
                }

            delete iCurrentAction;
            iCurrentAction = NULL;

            iCurrentAction = GetNextActionToExecute();
            }
        }
    while( iCurrentAction );
    }
void CImMobilityLogger::DoCreateStandardLogL(const TDesC& /*aFilePartName*/, TInt& /*aLogId*/)
#endif //__IM_MOBILITY_LOGGING
	{
#ifdef __IM_MOBILITY_LOGGING
	aLogId = KDefaultLog;

	TBool fileOpen(ETrue);
	TFileName filename;
	TInt err;
	TInt fileOffset(0);

	do
		{
		++fileOffset;
		filename.Format(KStandardLogFileFormat, &KLogDir(), &aFilePartName, fileOffset);

		err = iFs.IsFileOpen(filename, fileOpen);
		if (err == KErrNotFound)
			{
			err = KErrNone;
			fileOpen = EFalse;
			}

		User::LeaveIfError(err);
		}
	while (fileOpen);

	// See if we should take a backup of the log file
	if (BaflUtils::FolderExists(iFs, KBackupLogDir))
		{
		TInt backupOffset(KMaxBackupOffset);
		TFileName source;
		TFileName dest;

		dest.Format(KBackupLogFileFormat, &KBackupLogDir(), &aFilePartName, fileOffset, backupOffset);

		while (backupOffset > 1)
			{
			--backupOffset;
			source.Format(KBackupLogFileFormat, &KBackupLogDir(), &aFilePartName, fileOffset, backupOffset);
			BaflUtils::CopyFile(iFs, source, dest);
			dest = source;
			}

		BaflUtils::CopyFile(iFs, filename, dest);
		}

	TLogFileInfo info;
	info.iLoggingOn = ETrue;
	err = info.iFile.Replace(iFs, filename, EFileWrite | EFileShareAny);

	if (err != KErrNone)
		{
		return;
		}

	CleanupClosePushL(info.iFile);
	iFileList.AppendL(info);
	CleanupStack::Pop(&info.iFile);

	HBufC8* buf;
	TRAP(err, buf = CnvUtfConverter::ConvertFromUnicodeToUtf8L(filename));
	if (err == KErrNone)
		{
		const TDesC8& bufRef = *buf;
		LogFormat(KDefaultLog, KTxtFormatStandardLogStarted, &bufRef);
		delete buf;
		}

	aLogId = iFileList.Count() - 1;
#endif //__IM_MOBILITY_LOGGING
	}
Beispiel #29
0
/**
@SYMTestCaseID          SYSLIB-STORE-CT-1149
@SYMTestCaseDesc	    Tests writing using a direct file store
@SYMTestPriority 	    High
@SYMTestActions  	    Tests for memory and end of file error while creating the store.
                        Tests for writing to replaced,temporary,opened,created file.
						Tests for creating an already existing file.
						Tests for panic while deleting a file.
@SYMTestExpectedResults Test must not fail
@SYMREQ                 REQ0000
*/
LOCAL_C void testWriteL()
	{
	test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1149 Creating and failing to open 'ghost' file "));
	
	TDriveUnit drive(static_cast<TUint>(RFs::GetSystemDrive()));	
	TParse parse;
	parse.Set(drive.Name(), &KFileLocationSpec, NULL);
	
	TheFs.Delete(parse.NameAndExt());
	CFileStore* store=CDirectFileStore::CreateLC(TheFs,parse.NameAndExt(),EFileWrite);
	CleanupStack::PopAndDestroy();
	store=NULL;
	TRAPD(r,store=CDirectFileStore::OpenL(TheFs,parse.NameAndExt(),EFileRead|EFileWrite));
	test(store==NULL&&r==KErrEof);
//
	test.Next(_L("Writing to replaced file"));
	store=CDirectFileStore::ReplaceLC(TheFs,parse.NameAndExt(),EFileWrite);
	store->SetTypeL(TUidType(KDirectFileStoreLayoutUid,KDirectFileStoreLayoutUid));
	testWriteL(*store);
	CleanupStack::PopAndDestroy();
//
	test.Next(_L("Writing to replaced file - 2"));
	store=CDirectFileStore::ReplaceL(TheFs,parse.NameAndExt(),EFileWrite);
	CleanupStack::PushL(store);
	store->SetTypeL(TUidType(KDirectFileStoreLayoutUid,KDirectFileStoreLayoutUid));
	testWriteL(*store);
	CleanupStack::PopAndDestroy();
//
	test.Next(_L("Writing to temp file"));
	store=CDirectFileStore::TempLC(TheFs,parse.DriveAndPath(),TheTempFile,EFileWrite);
	store->SetTypeL(TUidType(store->Layout(),KNullUid,KDirectFileStoreLayoutUid));
	testWriteL(*store);
	store->CommitL();
	CleanupStack::PopAndDestroy();
	(void)TheFs.Delete(TheTempFile);
//	
	test.Next(_L("Writing to temp file - 2"));
	store=CDirectFileStore::TempL(TheFs,parse.DriveAndPath(),TheTempFile,EFileWrite);
	CleanupStack::PushL(store);
	store->SetTypeL(TUidType(store->Layout(),KNullUid,KDirectFileStoreLayoutUid));
	testWriteL(*store);
	store->CommitL();
	CleanupStack::PopAndDestroy();
//
	test.Next(_L("Writing to opened file"));
	store=CDirectFileStore::OpenLC(TheFs,parse.NameAndExt(),EFileRead|EFileWrite);
	testWriteL(*store);
	store->CommitL();
	CleanupStack::PopAndDestroy();
//
	test.Next(_L("Failing to create existing file"));
	store=NULL;
	TRAP(r,store=CDirectFileStore::CreateL(TheFs,TheTempFile,EFileWrite));
	test(store==NULL&&r==KErrAlreadyExists);
	if (TheFs.Delete(parse.NameAndExt())!=KErrNone)
		test.Panic(_L("Deleting file"));
//
	test.Next(_L("Writing to created file"));
	RFile file;
	test(file.Create(TheFs,parse.NameAndExt(),EFileWrite)==KErrNone);
	store=CDirectFileStore::NewLC(file);
	CleanupStack::PopAndDestroy();
	test(file.Open(TheFs,parse.NameAndExt(),EFileWrite)==KErrNone);
	store=CDirectFileStore::NewL(file);
	CleanupStack::PushL(store);
	store->SetTypeL(KDirectFileStoreLayoutUid);
	testWriteL(*store);
	store->CommitL();
	CleanupStack::PopAndDestroy();
	}
TVerdict CRepositoryFnStep::doTestStepL()
/**
 * @return - TVerdict code
 * Override of base class pure virtual
 * Our implementation only gets called if the base class doTestStepPreambleL()
 * did not leave. That being the case, the current test result value will be
 * EPass.
 * Perform functions on a repository, this can include creation, deletion and
 * setting of repository settings.
 */
    {
    SetTestStepResult(EPass);    

    // Get the key for the repository we're interested in. Leave if absent.
    TInt reposkey=0;
    TInt bRet = GetHexFromConfig(ConfigSection(), KRepositoryKey, reposkey );
    if(bRet!=1)
        {
        SetTestStepResult(EFail);    
        INFO_PRINTF1(HTML_RED);
        ERR_PRINTF1(_L("Repository key not specified in .ini file."));
        INFO_PRINTF1(HTML_RED_OFF);
        return TestStepResult();
        }
    INFO_PRINTF2(_L("Repository key: 0x%x"), reposkey );

    // Create the repository object...
    CRepository* repository=NULL;
    TInt leavecode;
    TRAP(leavecode, repository = CRepository::NewL(TUid::Uid(reposkey)));
    if( leavecode != KErrNone )
        {
        INFO_PRINTF1(HTML_RED);
        ERR_PRINTF2(_L("Repository 0x%x does not exist."), reposkey );
        INFO_PRINTF1(HTML_RED_OFF);
        SetTestStepResult(EFail);
        return TestStepResult();
        }
    CleanupStack::PushL(repository);

    // Look for integer settings to set...
    TInt nints=0;
    bRet = GetIntFromConfig(ConfigSection(), KRepositoryNumInts, nints );
    INFO_PRINTF2(_L("%d ints to modify"), nints );
    if(bRet == 1)
        {
        ModifyRepositoryIntegerSettings(repository, nints);
        }

    // Look for real settings to set...
    TInt nreals=0;
    bRet = GetIntFromConfig(ConfigSection(), KRepositoryNumReals, nreals );
    INFO_PRINTF2(_L("%d reals to modify"), nreals );
    if(bRet == 1)
        {
        ModifyRepositoryRealSettings(repository, nreals);
        }

    // Look for string settings to set...
    TInt nstrings=0;
    bRet = GetIntFromConfig(ConfigSection(), KRepositoryNumStrings, nstrings );
    INFO_PRINTF2(_L("%d strings to modify"), nstrings );
    if(bRet == 1)
        {
        ModifyRepositoryStringSettings(repository, nstrings );
        }

    CleanupStack::PopAndDestroy(repository);
    
    return TestStepResult();
    }