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