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