os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/vclnt/OpenFileByHandle1513.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #include "TestRecord.h"
    17 #include "OpenFileByHandle1513.h"
    18 
    19 #include <caf/caf.h>
    20 
    21 /**
    22  * Constructor
    23  */
    24 CTestMmfVclntOpenFile1513::CTestMmfVclntOpenFile1513(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName,const TBool aRec)
    25 	:iRec (aRec)
    26 	{
    27 	// store the name of this test case
    28 	// this is the name that is used by the script file
    29 	// Each test step initialises it's own name
    30 	iTestStepName = aTestName;
    31 	iSectName = aSectName;
    32 	iKeyName = aKeyName;
    33 	}
    34 
    35 CTestMmfVclntOpenFile1513* CTestMmfVclntOpenFile1513::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aRec)
    36 	{
    37 	CTestMmfVclntOpenFile1513* self = new (ELeave) CTestMmfVclntOpenFile1513(aTestName,aSectName,aKeyName,aRec);
    38 	return self;
    39 	}
    40 
    41 CTestMmfVclntOpenFile1513* CTestMmfVclntOpenFile1513::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aRec)
    42 	{
    43 	CTestMmfVclntOpenFile1513* self = CTestMmfVclntOpenFile1513::NewL(aTestName,aSectName,aKeyName,aRec);
    44 	CleanupStack::PushL(self);
    45 	return self;
    46 	}
    47 
    48 void CTestMmfVclntOpenFile1513::MvruoOpenComplete(TInt aError)
    49 	{
    50 	iError = aError;
    51 	INFO_PRINTF1(_L("Open complete callback"));
    52 	CActiveScheduler::Stop();
    53 	}
    54 
    55 void CTestMmfVclntOpenFile1513::MvruoRecordComplete(TInt aError)
    56 	{
    57 	iError = aError;
    58 	INFO_PRINTF1(_L("Record complete callback"));
    59 	CActiveScheduler::Stop();
    60 	}
    61 
    62 void CTestMmfVclntOpenFile1513::MvruoPrepareComplete(TInt aError)
    63 	{
    64 	iError = aError;
    65 	INFO_PRINTF1(_L("Prepare complete callback"));
    66 	CActiveScheduler::Stop();
    67 	}
    68 	
    69 void CTestMmfVclntOpenFile1513::MvruoEvent(const TMMFEvent& /*aEvent*/)
    70 	{
    71 	}
    72 
    73 /**
    74  * Load and initialise an audio file.
    75  */
    76 TVerdict CTestMmfVclntOpenFile1513::DoTestStepL()
    77 	{
    78 	return( PerformTestStepL() );
    79 	}
    80 
    81 TVerdict CTestMmfVclntOpenFile1513::PerformTestStepL()
    82 	{
    83 	TVerdict ret = EFail;
    84 
    85 	INFO_PRINTF1(_L("Test : Video Recorder - OpenFileL(RFile&)"));
    86 
    87 	RFs		fs;
    88 	RFile	file;
    89 
    90 	User::LeaveIfError(fs.Connect());
    91 	CleanupClosePushL(fs);
    92 	User::LeaveIfError(fs.ShareProtected());
    93 
    94 	iError = KErrTimedOut;
    95 
    96 	TPtrC filename;
    97 	if(!GetStringFromConfig(iSectName,iKeyName,filename))
    98 		{
    99 		return EInconclusive;
   100 		}
   101 
   102 	User::LeaveIfError(file.Replace(fs,filename,EFileWrite));
   103 	CleanupClosePushL(file);
   104 
   105 	CVideoRecorderUtility* rec = CVideoRecorderUtility::NewL(*this);
   106 	CleanupStack::PushL(rec);
   107 
   108 	const TUid KVidTstControllerUid = {KMmfVideoTestControllerUid};
   109 
   110 	TRAP(iError,rec->OpenFileL(file,
   111 							   NULL,
   112 							   KVidTstControllerUid,
   113 							   KUidMdaBmpClipFormat,
   114 							   KNullDesC8,
   115 							   KMMFFourCCCodeNULL));
   116 
   117 	if(iError == KErrNone)
   118 		{
   119 		INFO_PRINTF1(_L("CVideoRecorderUtility: Open file"));
   120 		// Wait for initialisation callback
   121 		CActiveScheduler::Start();
   122 		}
   123 
   124 	// Check for errors.
   125 	if ((iError == KErrNone) && (rec != NULL))
   126 		{
   127 		rec->Prepare();
   128 		CActiveScheduler::Start();
   129 		if(iError != KErrNone)
   130 			{
   131 			INFO_PRINTF2(_L("Prepare callback : error %d"), iError);
   132 			ret = EInconclusive;
   133 			}
   134 
   135 		if(iRec)
   136 			{
   137 			iError = KErrTimedOut;
   138 			rec->Record();
   139 			INFO_PRINTF1(_L("CVideoRecorderUtility: Record"));
   140 			// Wait for init callback
   141 			CActiveScheduler::Start();
   142 			if(iError == KErrNone)
   143 				{
   144 				ret = EPass;
   145 				}
   146 			}
   147 		else
   148 			{
   149 			ret = EPass;			
   150 			}
   151 		}
   152 	
   153 	INFO_PRINTF1(_L("CVideoRecorderUtility: Destroy"));
   154 	User::After(KOneSecond); // wait for deletion to shut down devsound
   155 	if(iError != KErrNone)
   156 		{
   157 		ERR_PRINTF2( _L("CVideoRecorderUtility failed with error %d"),iError );
   158 		}
   159 
   160 	CleanupStack::PopAndDestroy(3, &fs);
   161 
   162 	return	ret;
   163 	}