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 "OpenFileByHandle0034.h" |
|
18 |
|
19 #include <caf/caf.h> |
|
20 |
|
21 /** |
|
22 * Constructor |
|
23 */ |
|
24 CTestMmfVclntOpenFile0034::CTestMmfVclntOpenFile0034(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay) |
|
25 :iPlay (aPlay) |
|
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 // expand heap, so we can load 80k video |
|
35 iHeapSize = 150000; |
|
36 } |
|
37 |
|
38 CTestMmfVclntOpenFile0034* CTestMmfVclntOpenFile0034::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay) |
|
39 { |
|
40 CTestMmfVclntOpenFile0034* self = new (ELeave) CTestMmfVclntOpenFile0034(aTestName,aSectName,aKeyName,aPlay); |
|
41 return self; |
|
42 } |
|
43 |
|
44 CTestMmfVclntOpenFile0034* CTestMmfVclntOpenFile0034::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay) |
|
45 { |
|
46 CTestMmfVclntOpenFile0034* self = CTestMmfVclntOpenFile0034::NewLC(aTestName,aSectName,aKeyName,aPlay); |
|
47 CleanupStack::PushL(self); |
|
48 return self; |
|
49 } |
|
50 |
|
51 void CTestMmfVclntOpenFile0034::MvpuoOpenComplete(TInt aError) |
|
52 { |
|
53 iError = aError; |
|
54 INFO_PRINTF1(_L("Open Complete callback")); |
|
55 CActiveScheduler::Stop(); |
|
56 } |
|
57 |
|
58 void CTestMmfVclntOpenFile0034::MvpuoPrepareComplete(TInt aError) |
|
59 { |
|
60 iError = aError; |
|
61 INFO_PRINTF1(_L("Prepare Complete callback")); |
|
62 CActiveScheduler::Stop(); |
|
63 } |
|
64 |
|
65 void CTestMmfVclntOpenFile0034::MvpuoFrameReady(CFbsBitmap& /*aFrame*/, TInt aError) |
|
66 { |
|
67 iError = aError; |
|
68 INFO_PRINTF1(_L("Frame Ready callback")); |
|
69 } |
|
70 |
|
71 void CTestMmfVclntOpenFile0034::MvpuoPlayComplete(TInt aError) |
|
72 { |
|
73 iError = aError; |
|
74 INFO_PRINTF1(_L("Play Complete callback")); |
|
75 CActiveScheduler::Stop(); |
|
76 } |
|
77 |
|
78 void CTestMmfVclntOpenFile0034::MvpuoEvent(const TMMFEvent& /*aEvent*/) |
|
79 { |
|
80 } |
|
81 |
|
82 |
|
83 /** |
|
84 * Load and initialise an audio file. |
|
85 */ |
|
86 TVerdict CTestMmfVclntOpenFile0034::DoTestStepL() |
|
87 { |
|
88 InitWservL(); |
|
89 |
|
90 return( PerformTestStepL() ); |
|
91 } |
|
92 |
|
93 TVerdict CTestMmfVclntOpenFile0034::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 TRect rect, clipRect; |
|
117 CVideoPlayerUtility* player = CVideoPlayerUtility::NewL(*this, EMdaPriorityNormal, |
|
118 EMdaPriorityPreferenceTimeAndQuality, |
|
119 iWs, *iScreen, *iWindow, rect, clipRect); |
|
120 CleanupStack::PushL(player); |
|
121 TRAP(iError,player->OpenFileL(file)); |
|
122 |
|
123 if(iError == KErrNone) |
|
124 { |
|
125 // Wait for initialisation callback |
|
126 INFO_PRINTF1(_L("CVideoPlayerUtility: Opening file")); |
|
127 CActiveScheduler::Start(); |
|
128 } |
|
129 |
|
130 if(iError == KErrNotSupported) |
|
131 { |
|
132 ret = EPass; |
|
133 } |
|
134 |
|
135 // Check for errors. |
|
136 if (iError == KErrNone && player != NULL) |
|
137 { |
|
138 player->Prepare(); |
|
139 CActiveScheduler::Start(); |
|
140 } |
|
141 |
|
142 // Check for errors. |
|
143 if (iError == KErrNone && player != NULL) |
|
144 { |
|
145 if(iPlay) |
|
146 { |
|
147 iError = KErrTimedOut; |
|
148 player->Play(); |
|
149 INFO_PRINTF1(_L("CVideoPlayerUtility: Playing file")); |
|
150 // Wait for init callback |
|
151 CActiveScheduler::Start(); |
|
152 if(iError == KErrNone) |
|
153 { |
|
154 ret = EPass; |
|
155 } |
|
156 } |
|
157 else |
|
158 { |
|
159 ret = EPass; |
|
160 } |
|
161 } |
|
162 |
|
163 User::After(1000000); |
|
164 player->Stop(); |
|
165 player->Close(); |
|
166 |
|
167 INFO_PRINTF1(_L("CVideoPlayerUtility: Destroying")); |
|
168 CleanupStack::PopAndDestroy(player); |
|
169 if(iError != KErrNone) |
|
170 { |
|
171 ERR_PRINTF2( _L("CVideoPlayerUtility failed with error %d"),iError ); |
|
172 } |
|
173 |
|
174 CleanupStack::PopAndDestroy(2, &fs); |
|
175 return ret; |
|
176 } |
|