1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <e32svr.h> |
|
22 #include <stifparser.h> |
|
23 #include <stiftestinterface.h> |
|
24 #include <stiftesteventinterface.h> |
|
25 |
|
26 #include <utf.h> |
|
27 |
|
28 #include "ttscontrollerplugintest.h" |
|
29 |
|
30 _LIT( Kttscontrollerplugintest, "ttscontrollerplugintest" ); |
|
31 |
|
32 // ============================ MEMBER FUNCTIONS =============================== |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // Cttscontrollerplugintest::Delete |
|
36 // Delete here all resources allocated and opened from test methods. |
|
37 // Called from destructor. |
|
38 // ----------------------------------------------------------------------------- |
|
39 // |
|
40 void Cttscontrollerplugintest::Delete() |
|
41 { |
|
42 } |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // Cttscontrollerplugintest::RunMethodL |
|
46 // Run specified method. Contains also table of test mothods and their names. |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 TInt Cttscontrollerplugintest::RunMethodL( |
|
50 CStifItemParser& aItem ) |
|
51 { |
|
52 TStifFunctionInfo const KFunctions[] = |
|
53 { |
|
54 // Copy this line for every implemented function. |
|
55 // First string is the function name used in TestScripter script file. |
|
56 // Second is the actual implementation member function. |
|
57 ENTRY( "Create", Cttscontrollerplugintest::CreateL ), |
|
58 ENTRY( "CreateFilePlayer", Cttscontrollerplugintest::CreateFilePlayerL ), |
|
59 ENTRY( "CreateDesPlayer", Cttscontrollerplugintest::CreateDesPlayerL ), |
|
60 ENTRY( "OpenFile", Cttscontrollerplugintest::OpenFileL ), |
|
61 ENTRY( "OpenFileHandle", Cttscontrollerplugintest::OpenFileHandleL ), |
|
62 ENTRY( "OpenDes", Cttscontrollerplugintest::OpenDesL ), |
|
63 ENTRY( "Play", Cttscontrollerplugintest::Play ), |
|
64 ENTRY( "SetVolumeAndRamp", Cttscontrollerplugintest::SetVolumeAndRampL ), |
|
65 ENTRY( "Destroy", Cttscontrollerplugintest::Destroy ), |
|
66 }; |
|
67 |
|
68 const TInt count = sizeof( KFunctions ) / |
|
69 sizeof( TStifFunctionInfo ); |
|
70 |
|
71 return RunInternalL( KFunctions, count, aItem ); |
|
72 } |
|
73 |
|
74 // ----------------------------------------------------------------------------- |
|
75 // Cttscontrollerplugintest::CreateL |
|
76 // |
|
77 // ----------------------------------------------------------------------------- |
|
78 // |
|
79 TInt Cttscontrollerplugintest::CreateL() |
|
80 { |
|
81 // Print to UI |
|
82 _LIT( KFunction, "In CreateL" ); |
|
83 TestModuleIf().Printf( 0, Kttscontrollerplugintest, KFunction ); |
|
84 |
|
85 iAudioPlayer = CMdaAudioPlayerUtility::NewL( *this ); |
|
86 |
|
87 return KErrNone; |
|
88 } |
|
89 |
|
90 // ----------------------------------------------------------------------------- |
|
91 // Cttscontrollerplugintest::CreateFilePlayerL |
|
92 // |
|
93 // ----------------------------------------------------------------------------- |
|
94 // |
|
95 TInt Cttscontrollerplugintest::CreateFilePlayerL( CStifItemParser& aItem ) |
|
96 { |
|
97 // Print to UI |
|
98 _LIT( KFunction, "In CreateFilePlayerL" ); |
|
99 TestModuleIf().Printf( 0, Kttscontrollerplugintest, KFunction ); |
|
100 |
|
101 TPtrC file; |
|
102 User::LeaveIfError( aItem.GetNextString ( file ) ); |
|
103 TFileName fileName( file ); |
|
104 |
|
105 iAudioPlayer = CMdaAudioPlayerUtility::NewFilePlayerL( fileName, *this ); |
|
106 |
|
107 return KErrNone; |
|
108 } |
|
109 |
|
110 // ----------------------------------------------------------------------------- |
|
111 // Cttscontrollerplugintest::CreateDesPlayerL |
|
112 // |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 TInt Cttscontrollerplugintest::CreateDesPlayerL( CStifItemParser& aItem ) |
|
116 { |
|
117 // Print to UI |
|
118 _LIT( KFunction, "In CreateDesPlayerL" ); |
|
119 |
|
120 TestModuleIf().Printf( 0, Kttscontrollerplugintest, KFunction ); |
|
121 |
|
122 // Allow asynchronous request to leak handle |
|
123 TestModuleIf().SetBehavior( CTestModuleIf::ETestLeaksHandles ); |
|
124 |
|
125 TPtrC input; |
|
126 User::LeaveIfError( aItem.GetNextString ( input ) ); |
|
127 |
|
128 iInputText = HBufC8::NewL( 4 * input.Length() ); |
|
129 TPtr8 refText = iInputText->Des(); |
|
130 |
|
131 User::LeaveIfError( CnvUtfConverter::ConvertFromUnicodeToUtf8( refText, input ) ); |
|
132 |
|
133 iAudioPlayer = CMdaAudioPlayerUtility::NewDesPlayerL( *iInputText, *this ); |
|
134 |
|
135 return KErrNone; |
|
136 } |
|
137 |
|
138 // ----------------------------------------------------------------------------- |
|
139 // Cttscontrollerplugintest::OpenFileL |
|
140 // |
|
141 // ----------------------------------------------------------------------------- |
|
142 // |
|
143 TInt Cttscontrollerplugintest::OpenFileL( CStifItemParser& aItem ) |
|
144 { |
|
145 // Print to UI |
|
146 _LIT( KFunction, "In OpenFileL" ); |
|
147 TestModuleIf().Printf( 0, Kttscontrollerplugintest, KFunction ); |
|
148 |
|
149 iAudioPlayer->Close(); |
|
150 |
|
151 TPtrC file; |
|
152 User::LeaveIfError( aItem.GetNextString ( file ) ); |
|
153 TFileName fileName( file ); |
|
154 |
|
155 iAudioPlayer->OpenFileL( fileName ); |
|
156 |
|
157 return KErrNone; |
|
158 } |
|
159 |
|
160 // ----------------------------------------------------------------------------- |
|
161 // Cttscontrollerplugintest::OpenFileHandleL |
|
162 // |
|
163 // ----------------------------------------------------------------------------- |
|
164 // |
|
165 TInt Cttscontrollerplugintest::OpenFileHandleL( CStifItemParser& aItem ) |
|
166 { |
|
167 // Print to UI |
|
168 _LIT( KFunction, "In OpenFileHandleL" ); |
|
169 TestModuleIf().Printf( 0, Kttscontrollerplugintest, KFunction ); |
|
170 |
|
171 iFile.Close(); |
|
172 iFs.Close(); |
|
173 iAudioPlayer->Close(); |
|
174 |
|
175 TPtrC file; |
|
176 User::LeaveIfError( aItem.GetNextString ( file ) ); |
|
177 TFileName fileName( file ); |
|
178 |
|
179 User::LeaveIfError( iFs.Connect() ); |
|
180 User::LeaveIfError( iFile.Open( iFs, fileName, EFileRead|EFileStreamText ) ); |
|
181 |
|
182 iAudioPlayer->OpenFileL( iFile ); |
|
183 |
|
184 return KErrNone; |
|
185 } |
|
186 |
|
187 // ----------------------------------------------------------------------------- |
|
188 // Cttscontrollerplugintest::OpenDesL |
|
189 // |
|
190 // ----------------------------------------------------------------------------- |
|
191 // |
|
192 TInt Cttscontrollerplugintest::OpenDesL( CStifItemParser& aItem ) |
|
193 { |
|
194 // Print to UI |
|
195 _LIT( KFunction, "In OpenFileL" ); |
|
196 |
|
197 TestModuleIf().Printf( 0, Kttscontrollerplugintest, KFunction ); |
|
198 |
|
199 iAudioPlayer->Close(); |
|
200 |
|
201 TPtrC input; |
|
202 User::LeaveIfError( aItem.GetNextString ( input ) ); |
|
203 |
|
204 iInputText = HBufC8::NewL( 4 * input.Length() ); |
|
205 TPtr8 refText = iInputText->Des(); |
|
206 |
|
207 User::LeaveIfError( CnvUtfConverter::ConvertFromUnicodeToUtf8( refText, input ) ); |
|
208 |
|
209 iAudioPlayer->OpenDesL( *iInputText ); |
|
210 |
|
211 return KErrNone; |
|
212 } |
|
213 |
|
214 // ----------------------------------------------------------------------------- |
|
215 // Cttscontrollerplugintest::Play |
|
216 // |
|
217 // ----------------------------------------------------------------------------- |
|
218 // |
|
219 TInt Cttscontrollerplugintest::Play() |
|
220 { |
|
221 // Print to UI |
|
222 _LIT( KFunction, "In Play" ); |
|
223 TestModuleIf().Printf( 0, Kttscontrollerplugintest, KFunction ); |
|
224 |
|
225 iAudioPlayer->Play(); |
|
226 |
|
227 return KErrNone; |
|
228 } |
|
229 |
|
230 // ----------------------------------------------------------------------------- |
|
231 // Cttscontrollerplugintest::SetVolumeAndRampL |
|
232 // |
|
233 // ----------------------------------------------------------------------------- |
|
234 // |
|
235 TInt Cttscontrollerplugintest::SetVolumeAndRampL() |
|
236 { |
|
237 // Print to UI |
|
238 _LIT( KFunction, "In SetVolumeAndRampL" ); |
|
239 TestModuleIf().Printf( 0, Kttscontrollerplugintest, KFunction ); |
|
240 |
|
241 iAudioPlayer->SetVolume( iAudioPlayer->MaxVolume() ); |
|
242 iAudioPlayer->SetVolumeRamp( 100000 ); |
|
243 |
|
244 return KErrNone; |
|
245 } |
|
246 |
|
247 // ----------------------------------------------------------------------------- |
|
248 // Cttscontrollerplugintest::Destroy |
|
249 // |
|
250 // ----------------------------------------------------------------------------- |
|
251 // |
|
252 TInt Cttscontrollerplugintest::Destroy() |
|
253 { |
|
254 // Print to UI |
|
255 _LIT( KFunction, "In Destroy" ); |
|
256 TestModuleIf().Printf( 0, Kttscontrollerplugintest, KFunction ); |
|
257 |
|
258 iFile.Close(); |
|
259 iFs.Close(); |
|
260 |
|
261 delete iAudioPlayer; |
|
262 iAudioPlayer = NULL; |
|
263 |
|
264 delete iInputText; |
|
265 iInputText = NULL; |
|
266 |
|
267 return KErrNone; |
|
268 } |
|
269 |
|
270 // ----------------------------------------------------------------------------- |
|
271 // Cttscontrollerplugintest::MapcInitComplete |
|
272 // |
|
273 // ----------------------------------------------------------------------------- |
|
274 // |
|
275 void Cttscontrollerplugintest::MapcInitComplete( TInt aError, |
|
276 const TTimeIntervalMicroSeconds& /*aDuration*/ ) |
|
277 { |
|
278 if ( aError ) |
|
279 { |
|
280 User::Panic( Kttscontrollerplugintest, aError ); |
|
281 } |
|
282 |
|
283 TEventIf stifEvent( TEventIf::ESetEvent, _L( "MapcInitComplete" ) ); |
|
284 TestModuleIf().Event( stifEvent ); |
|
285 } |
|
286 |
|
287 // ----------------------------------------------------------------------------- |
|
288 // Cttscontrollerplugintest::MapcPlayComplete |
|
289 // |
|
290 // ----------------------------------------------------------------------------- |
|
291 // |
|
292 void Cttscontrollerplugintest::MapcPlayComplete( TInt aError ) |
|
293 { |
|
294 if ( aError ) |
|
295 { |
|
296 User::Panic( Kttscontrollerplugintest, aError ); |
|
297 } |
|
298 |
|
299 TEventIf stifEvent( TEventIf::ESetEvent, _L( "MapcPlayComplete" ) ); |
|
300 TestModuleIf().Event( stifEvent ); |
|
301 } |
|
302 |
|
303 // End of File |
|