|
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 "OpenFileByHandle0523.h" |
|
18 |
|
19 #include <caf/caf.h> |
|
20 |
|
21 /** |
|
22 * Constructor |
|
23 */ |
|
24 CTestMmfVclntOpenFile0523::CTestMmfVclntOpenFile0523(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 CTestMmfVclntOpenFile0523* CTestMmfVclntOpenFile0523::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aRec) |
|
36 { |
|
37 CTestMmfVclntOpenFile0523* self = new (ELeave) CTestMmfVclntOpenFile0523(aTestName,aSectName,aKeyName,aRec); |
|
38 return self; |
|
39 } |
|
40 |
|
41 CTestMmfVclntOpenFile0523* CTestMmfVclntOpenFile0523::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aRec) |
|
42 { |
|
43 CTestMmfVclntOpenFile0523* self = CTestMmfVclntOpenFile0523::NewL(aTestName,aSectName,aKeyName,aRec); |
|
44 CleanupStack::PushL(self); |
|
45 return self; |
|
46 } |
|
47 |
|
48 void CTestMmfVclntOpenFile0523::MvruoOpenComplete(TInt aError) |
|
49 { |
|
50 iError = aError; |
|
51 INFO_PRINTF1(_L("Open complete callback")); |
|
52 CActiveScheduler::Stop(); |
|
53 } |
|
54 |
|
55 void CTestMmfVclntOpenFile0523::MvruoRecordComplete(TInt aError) |
|
56 { |
|
57 iError = aError; |
|
58 INFO_PRINTF1(_L("Record complete callback")); |
|
59 CActiveScheduler::Stop(); |
|
60 } |
|
61 |
|
62 void CTestMmfVclntOpenFile0523::MvruoPrepareComplete(TInt aError) |
|
63 { |
|
64 iError = aError; |
|
65 INFO_PRINTF1(_L("Prepare complete callback")); |
|
66 CActiveScheduler::Stop(); |
|
67 } |
|
68 |
|
69 void CTestMmfVclntOpenFile0523::MvruoEvent(const TMMFEvent& /*aEvent*/) |
|
70 { |
|
71 } |
|
72 |
|
73 /** |
|
74 * Load and initialise an audio file. |
|
75 */ |
|
76 TVerdict CTestMmfVclntOpenFile0523::DoTestStepL() |
|
77 { |
|
78 return( PerformTestStepL() ); |
|
79 } |
|
80 |
|
81 TVerdict CTestMmfVclntOpenFile0523::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 TRAP(iError,rec->OpenFileL(file, |
|
110 NULL, |
|
111 KVidTstControllerUid, |
|
112 KUidMdaBmpClipFormat, |
|
113 KNullDesC8, |
|
114 KMMFFourCCCodeNULL)); |
|
115 |
|
116 if(iError == KErrNone) |
|
117 { |
|
118 INFO_PRINTF1(_L("CVideoRecorderUtility: Open file")); |
|
119 // Wait for initialisation callback |
|
120 CActiveScheduler::Start(); |
|
121 } |
|
122 |
|
123 if(iError == KErrNotSupported) |
|
124 { |
|
125 ret = EPass; |
|
126 } |
|
127 |
|
128 // Check for errors. |
|
129 if ((iError == KErrNone) && (rec != NULL)) |
|
130 { |
|
131 rec->Prepare(); |
|
132 CActiveScheduler::Start(); |
|
133 if(iError != KErrNone) |
|
134 { |
|
135 INFO_PRINTF2(_L("Prepare callback : error %d"), iError); |
|
136 return EInconclusive; |
|
137 } |
|
138 |
|
139 if(iRec) |
|
140 { |
|
141 iError = KErrTimedOut; |
|
142 rec->Record(); |
|
143 INFO_PRINTF1(_L("CVideoRecorderUtility: Record")); |
|
144 // Wait for init callback |
|
145 CActiveScheduler::Start(); |
|
146 if(iError == KErrNone) |
|
147 { |
|
148 ret = EPass; |
|
149 } |
|
150 } |
|
151 else |
|
152 { |
|
153 ret = EPass; |
|
154 } |
|
155 } |
|
156 |
|
157 rec->Close(); |
|
158 |
|
159 INFO_PRINTF1(_L("CVideoRecorderUtility: Destroy")); |
|
160 User::After(KOneSecond); // wait for deletion to shut down devsound |
|
161 if(iError != KErrNone) |
|
162 { |
|
163 ERR_PRINTF2( _L("CVideoRecorderUtility failed with error %d"),iError ); |
|
164 } |
|
165 |
|
166 CleanupStack::PopAndDestroy(3,&fs); |
|
167 |
|
168 return ret; |
|
169 } |