|
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 // OpenFileByHandlePlayTextFile.CPP |
|
15 // |
|
16 // |
|
17 |
|
18 #include "TestPlayer.h" |
|
19 #include "OpenFileByHandle_PlayText.h" |
|
20 |
|
21 #include <caf/caf.h> |
|
22 |
|
23 /** |
|
24 * Constructor |
|
25 */ |
|
26 CTestMmfVclntOpenFilePlayTextFile::CTestMmfVclntOpenFilePlayTextFile(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay) |
|
27 :iPlay (aPlay) |
|
28 { |
|
29 // store the name of this test case |
|
30 // this is the name that is used by the script file |
|
31 // Each test step initialises it's own name |
|
32 iTestStepName = aTestName; |
|
33 iSectName = aSectName; |
|
34 iKeyName = aKeyName; |
|
35 |
|
36 // expand heap, so we can load 80k video |
|
37 iHeapSize = 150000; |
|
38 } |
|
39 |
|
40 CTestMmfVclntOpenFilePlayTextFile* CTestMmfVclntOpenFilePlayTextFile::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay) |
|
41 { |
|
42 CTestMmfVclntOpenFilePlayTextFile* self = new (ELeave) CTestMmfVclntOpenFilePlayTextFile(aTestName,aSectName,aKeyName,aPlay); |
|
43 return self; |
|
44 } |
|
45 |
|
46 CTestMmfVclntOpenFilePlayTextFile* CTestMmfVclntOpenFilePlayTextFile::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay) |
|
47 { |
|
48 CTestMmfVclntOpenFilePlayTextFile* self = CTestMmfVclntOpenFilePlayTextFile::NewLC(aTestName,aSectName,aKeyName,aPlay); |
|
49 CleanupStack::PushL(self); |
|
50 return self; |
|
51 } |
|
52 |
|
53 void CTestMmfVclntOpenFilePlayTextFile::MvpuoOpenComplete(TInt aError) |
|
54 { |
|
55 iError = aError; |
|
56 INFO_PRINTF1(_L("Open Complete callback")); |
|
57 CActiveScheduler::Stop(); |
|
58 } |
|
59 |
|
60 void CTestMmfVclntOpenFilePlayTextFile::MvpuoPrepareComplete(TInt aError) |
|
61 { |
|
62 iError = aError; |
|
63 INFO_PRINTF1(_L("Open Complete callback")); |
|
64 CActiveScheduler::Stop(); |
|
65 } |
|
66 |
|
67 void CTestMmfVclntOpenFilePlayTextFile::MvpuoFrameReady(CFbsBitmap& /*aFrame*/, TInt aError) |
|
68 { |
|
69 iError = aError; |
|
70 INFO_PRINTF1(_L("Frame Ready callback")); |
|
71 } |
|
72 |
|
73 void CTestMmfVclntOpenFilePlayTextFile::MvpuoPlayComplete(TInt aError) |
|
74 { |
|
75 iError = aError; |
|
76 INFO_PRINTF1(_L("Play Complete callback")); |
|
77 CActiveScheduler::Stop(); |
|
78 } |
|
79 |
|
80 void CTestMmfVclntOpenFilePlayTextFile::MvpuoEvent(const TMMFEvent& /*aEvent*/) |
|
81 { |
|
82 } |
|
83 |
|
84 |
|
85 /** |
|
86 * Load and initialise an audio file. |
|
87 */ |
|
88 TVerdict CTestMmfVclntOpenFilePlayTextFile::DoTestStepL() |
|
89 { |
|
90 return( PerformTestStepL() ); |
|
91 } |
|
92 |
|
93 TVerdict CTestMmfVclntOpenFilePlayTextFile::PerformTestStepL() |
|
94 { |
|
95 TVerdict ret = EFail; |
|
96 iError = KErrTimedOut; |
|
97 |
|
98 INFO_PRINTF1(_L("Test : Video Player - OpenFileL(RFile&)")); |
|
99 |
|
100 RFs fs; |
|
101 RFile file; |
|
102 |
|
103 User::LeaveIfError(fs.Connect()); |
|
104 CleanupClosePushL(fs); |
|
105 User::LeaveIfError(fs.ShareProtected()); |
|
106 |
|
107 TPtrC filename; |
|
108 if(!GetStringFromConfig(iSectName,iKeyName,filename)) |
|
109 { |
|
110 return EInconclusive; |
|
111 } |
|
112 |
|
113 User::LeaveIfError(file.Open(fs,filename,EFileRead)); |
|
114 CleanupClosePushL(file); |
|
115 |
|
116 InitWservL(); |
|
117 |
|
118 TRect rect, clipRect; |
|
119 CVideoPlayerUtility* player = CVideoPlayerUtility::NewL(*this, EMdaPriorityNormal, |
|
120 EMdaPriorityPreferenceTimeAndQuality, |
|
121 iWs, *iScreen, *iWindow, rect, clipRect); |
|
122 CleanupStack::PushL(player); |
|
123 TRAP(iError,player->OpenFileL(file)); |
|
124 |
|
125 if(iError == KErrNone) |
|
126 { |
|
127 // Wait for initialisation callback |
|
128 INFO_PRINTF1(_L("CVideoPlayerUtility: Opening file")); |
|
129 CActiveScheduler::Start(); |
|
130 } |
|
131 |
|
132 // text file is not supported |
|
133 if(iError == KErrNotSupported) |
|
134 { |
|
135 ret = EPass; |
|
136 } |
|
137 |
|
138 // Check for errors. |
|
139 if (iError == KErrNone && player != NULL) |
|
140 { |
|
141 player->Prepare(); |
|
142 CActiveScheduler::Start(); |
|
143 } |
|
144 |
|
145 // Check for errors. |
|
146 if (iError == KErrNone && player != NULL) |
|
147 { |
|
148 if(iPlay) |
|
149 { |
|
150 iError = KErrTimedOut; |
|
151 player->Play(); |
|
152 INFO_PRINTF1(_L("CVideoPlayerUtility: Playing file")); |
|
153 // Wait for init callback |
|
154 CActiveScheduler::Start(); |
|
155 if(iError == KErrNone) |
|
156 { |
|
157 ret = EPass; |
|
158 } |
|
159 } |
|
160 else |
|
161 { |
|
162 ret = EPass; |
|
163 } |
|
164 } |
|
165 |
|
166 User::After(500000); |
|
167 player->Stop(); |
|
168 player->Close(); |
|
169 |
|
170 INFO_PRINTF1(_L("CVideoPlayerUtility: Destroying")); |
|
171 if(iError != KErrNone) |
|
172 { |
|
173 ERR_PRINTF2( _L("CVideoPlayerUtility failed with error %d"),iError ); |
|
174 } |
|
175 |
|
176 CleanupStack::PopAndDestroy(3, &fs); |
|
177 |
|
178 return ret; |
|
179 } |
|
180 |