os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/vclnt/OpenFileByHandle1511.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     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 "OpenFileByHandle1511.h"
    18 
    19 #include <caf/caf.h>
    20 
    21 /**
    22  * Constructor
    23  */
    24 CTestMmfVclntOpenFile1511::CTestMmfVclntOpenFile1511(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 CTestMmfVclntOpenFile1511* CTestMmfVclntOpenFile1511::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aRec)
    36 	{
    37 	CTestMmfVclntOpenFile1511* self = new (ELeave) CTestMmfVclntOpenFile1511(aTestName,aSectName,aKeyName,aRec);
    38 	return self;
    39 	}
    40 
    41 CTestMmfVclntOpenFile1511* CTestMmfVclntOpenFile1511::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aRec)
    42 	{
    43 	CTestMmfVclntOpenFile1511* self = CTestMmfVclntOpenFile1511::NewL(aTestName,aSectName,aKeyName,aRec);
    44 	CleanupStack::PushL(self);
    45 	return self;
    46 	}
    47 
    48 void CTestMmfVclntOpenFile1511::MvruoOpenComplete(TInt aError)
    49 	{
    50 	iError = aError;
    51 	INFO_PRINTF1(_L("Open complete callback"));
    52 	CActiveScheduler::Stop();
    53 	}
    54 
    55 void CTestMmfVclntOpenFile1511::MvruoRecordComplete(TInt aError)
    56 	{
    57 	iError = aError;
    58 	INFO_PRINTF1(_L("Record complete callback"));
    59 	CActiveScheduler::Stop();
    60 	}
    61 
    62 void CTestMmfVclntOpenFile1511::MvruoPrepareComplete(TInt aError)
    63 	{
    64 	iError = aError;
    65 	INFO_PRINTF1(_L("Prepare complete callback"));
    66 	CActiveScheduler::Stop();
    67 	}
    68 	
    69 void CTestMmfVclntOpenFile1511::MvruoEvent(const TMMFEvent& /*aEvent*/)
    70 	{
    71 	}
    72 
    73 /**
    74  * Load and initialise an audio file.
    75  */
    76 TVerdict CTestMmfVclntOpenFile1511::DoTestStepL()
    77 	{
    78 	return( PerformTestStepL() );
    79 	}
    80 
    81 #define KMmfInvalidVideoTestControllerUid	0xA0A0A0A0
    82 
    83 TVerdict CTestMmfVclntOpenFile1511::PerformTestStepL()
    84 	{
    85 	TVerdict ret = EFail;
    86 
    87 	INFO_PRINTF1(_L("Test : Video Recorder - OpenFileL(RFile&)"));
    88 
    89 	RFs		fs;
    90 	RFile	file;
    91 
    92 	User::LeaveIfError(fs.Connect());
    93 	CleanupClosePushL(fs);
    94 	User::LeaveIfError(fs.ShareProtected());
    95 
    96 	iError = KErrTimedOut;
    97 
    98 	TPtrC filename;
    99 	if(!GetStringFromConfig(iSectName,iKeyName,filename))
   100 		{
   101 		return EInconclusive;
   102 		}
   103 
   104 	User::LeaveIfError(file.Replace(fs,filename,EFileWrite));
   105 	CleanupClosePushL(file);
   106 
   107 	CVideoRecorderUtility* rec = CVideoRecorderUtility::NewL(*this);
   108 	CleanupStack::PushL(rec);
   109 
   110 	const TUid KVidTstControllerUid = {KMmfInvalidVideoTestControllerUid};
   111 	TRAP(iError,rec->OpenFileL(file,
   112 							   NULL,
   113 							   KVidTstControllerUid,
   114 							   KUidMdaBmpClipFormat,
   115 							   KNullDesC8,
   116 							   KMMFFourCCCodeNULL));
   117 
   118 	if(iError == KErrNone)
   119 		{
   120 		INFO_PRINTF1(_L("CVideoRecorderUtility: Open file"));
   121 		// Wait for initialisation callback
   122 		CActiveScheduler::Start();
   123 		}
   124 
   125 	// controller with supplied UID should not be found
   126 	if(iError == KErrNotFound)
   127 		{
   128 		ret = EPass;
   129 		}
   130 
   131 	// Check for errors.
   132 	if ((iError == KErrNone) && (rec != NULL))
   133 		{
   134 		rec->Prepare();
   135 		CActiveScheduler::Start();
   136 		if(iError != KErrNone)
   137 			{
   138 			INFO_PRINTF2(_L("Prepare callback : error %d"), iError);
   139 			ret = EInconclusive;
   140 			}
   141 
   142 		if(iRec)
   143 			{
   144 			iError = KErrTimedOut;
   145 			rec->Record();
   146 			INFO_PRINTF1(_L("CVideoRecorderUtility: Record"));
   147 			// Wait for init callback
   148 			CActiveScheduler::Start();
   149 			if(iError == KErrNone)
   150 				{
   151 				ret = EPass;
   152 				}
   153 			}
   154 		else
   155 			{
   156 			ret = EPass;
   157 			}
   158 		}
   159 	
   160 	INFO_PRINTF1(_L("CVideoRecorderUtility: Destroy"));
   161 	User::After(KOneSecond); // wait for deletion to shut down devsound
   162 	if(iError != KErrNone)
   163 		{
   164 		ERR_PRINTF2( _L("CVideoRecorderUtility reported error %d"),iError );
   165 		}
   166 
   167 	CleanupStack::PopAndDestroy(3, &fs);
   168 
   169 	return	ret;
   170 	}