1 /* |
|
2 * Copyright (c) 2009 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: radiostation test implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <e32base.h> |
|
19 #include <eikenv.h> |
|
20 #include <e32property.h> |
|
21 #include <radiomonitor.h> |
|
22 |
|
23 #include "t_radioenginewrapper.h" |
|
24 //#include "radiopresetstorage.h" |
|
25 //#include "radiostation.h" |
|
26 //#include "radiostationmodel.h" |
|
27 //#include "radioplaylogmodel.h" |
|
28 #include "radioenginewrapper.h" |
|
29 #include "radiologger.h" //Radio::connect |
|
30 #include <cradiosettings.h> |
|
31 #include "mradioenginesettings.h" |
|
32 #include "trace.h" |
|
33 #include "RadioClientServer.h" |
|
34 #include "radiointernalcrkeys.h" |
|
35 #include "radioengineutils.h" |
|
36 |
|
37 #define STUB mRadioStubManager |
|
38 #define TUNER mRadioStubManager->iTuner |
|
39 #define PLAYER mRadioStubManager->iPlayer |
|
40 #define RDS mRadioStubManager->iRds |
|
41 #define ACCESSORYOBSERVER mRadioStubManager->iAccessoryObserver |
|
42 #define REMCONTARGET mRadioStubManager->iRemConTarget |
|
43 |
|
44 // Constants |
|
45 |
|
46 // CONSTANTS |
|
47 _LIT_SECURITY_POLICY_PASS(KRadioServerReadPolicy); |
|
48 _LIT_SECURITY_POLICY_C1(KRadioServerWritePolicy, ECapabilityWriteUserData); |
|
49 |
|
50 /*! |
|
51 * |
|
52 */ |
|
53 int main(int /* argc*/, char *argv[]) |
|
54 { |
|
55 FUNC_LOG; |
|
56 TestRadioEngineWrapper tv; |
|
57 |
|
58 char *pass[3]; |
|
59 pass[0] = argv[0]; |
|
60 pass[1] = "-o"; |
|
61 pass[2] = "c:\\data\\testradiouiengine.txt"; |
|
62 |
|
63 int res = QTest::qExec(&tv, 3, pass); |
|
64 |
|
65 INFO_1( "Main, result value %i", res ); |
|
66 return res; |
|
67 } |
|
68 |
|
69 TestRadioEngineWrapper::TestRadioEngineWrapper() |
|
70 { |
|
71 FUNC_LOG; |
|
72 } |
|
73 |
|
74 // from base class RadioStationHandlerIf |
|
75 |
|
76 uint TestRadioEngineWrapper::currentFrequency() const |
|
77 { |
|
78 FUNC_LOG; |
|
79 return 0; |
|
80 } |
|
81 |
|
82 int TestRadioEngineWrapper::currentPresetIndex() const |
|
83 { |
|
84 FUNC_LOG; |
|
85 return 0; |
|
86 } |
|
87 |
|
88 void TestRadioEngineWrapper::setCurrentStation( uint /*frequency*/ ) |
|
89 { |
|
90 FUNC_LOG; |
|
91 } |
|
92 |
|
93 bool TestRadioEngineWrapper::containsFrequency( uint /*frequency*/ ) |
|
94 { |
|
95 FUNC_LOG; |
|
96 return 1; |
|
97 } |
|
98 |
|
99 bool TestRadioEngineWrapper::containsPresetIndex( int /*presetIndex*/ ) |
|
100 { |
|
101 FUNC_LOG; |
|
102 return 1; |
|
103 } |
|
104 |
|
105 void TestRadioEngineWrapper::startDynamicPsCheck() |
|
106 { |
|
107 FUNC_LOG; |
|
108 } |
|
109 |
|
110 void TestRadioEngineWrapper::addScannedFrequency( uint /*frequency*/ ) |
|
111 { |
|
112 FUNC_LOG; |
|
113 } |
|
114 |
|
115 void TestRadioEngineWrapper::removeLocalStations() |
|
116 { |
|
117 FUNC_LOG; |
|
118 } |
|
119 |
|
120 void TestRadioEngineWrapper::setCurrentPsName( uint /*frequency*/, const QString& /*name*/ ) |
|
121 { |
|
122 FUNC_LOG; |
|
123 } |
|
124 |
|
125 void TestRadioEngineWrapper::setCurrentRadioText( uint /*frequency*/, const QString& /*radioText*/ ) |
|
126 { |
|
127 FUNC_LOG; |
|
128 } |
|
129 |
|
130 void TestRadioEngineWrapper::setCurrentRadioTextPlus( uint /*frequency*/, int /*rtClass*/, const QString& /*rtItem*/ ) |
|
131 { |
|
132 FUNC_LOG; |
|
133 } |
|
134 |
|
135 void TestRadioEngineWrapper::setCurrentPiCode( uint /*frequency*/, int /*piCode*/ ) |
|
136 { |
|
137 FUNC_LOG; |
|
138 } |
|
139 |
|
140 void TestRadioEngineWrapper::setCurrentGenre( uint /*frequency*/, int /*genre*/ ) |
|
141 { |
|
142 FUNC_LOG; |
|
143 } |
|
144 |
|
145 // from base class RadioEngineWrapperObserver |
|
146 |
|
147 void TestRadioEngineWrapper::tunedToFrequency( uint frequency, int /* commandSender */) |
|
148 { |
|
149 FUNC_LOG; |
|
150 mEnteredSlots |= TunedToFrequency; |
|
151 TInt err = mRadioCR->Set( KRadioCRTunedFrequency , (TInt)frequency ); |
|
152 QVERIFY2( KErrNone == err, "Setting key KRadioCRTunedFrequency failed!" ); |
|
153 } |
|
154 |
|
155 |
|
156 void TestRadioEngineWrapper::rdsAvailabilityChanged( bool /* available */) |
|
157 { |
|
158 FUNC_LOG; |
|
159 } |
|
160 |
|
161 void TestRadioEngineWrapper::increaseVolume() |
|
162 { |
|
163 FUNC_LOG; |
|
164 } |
|
165 |
|
166 void TestRadioEngineWrapper::decreaseVolume() |
|
167 { |
|
168 FUNC_LOG; |
|
169 } |
|
170 |
|
171 void TestRadioEngineWrapper::volumeChanged( int volume ) |
|
172 { |
|
173 FUNC_LOG; |
|
174 mEnteredSlots |= VolumeChanged; |
|
175 mLastRecordedVolume = volume; |
|
176 } |
|
177 |
|
178 void TestRadioEngineWrapper::muteChanged( bool /* muted */) |
|
179 { |
|
180 FUNC_LOG; |
|
181 mEnteredSlots |= MuteChanged; |
|
182 } |
|
183 |
|
184 void TestRadioEngineWrapper::antennaStatusChanged( bool /* muted */) |
|
185 { |
|
186 FUNC_LOG; |
|
187 mEnteredSlots |= AntennaChanged; |
|
188 } |
|
189 |
|
190 void TestRadioEngineWrapper::audioRouteChanged( bool /* loudspeaker */) |
|
191 { |
|
192 FUNC_LOG; |
|
193 } |
|
194 |
|
195 void TestRadioEngineWrapper::skipPrevious() |
|
196 { |
|
197 FUNC_LOG; |
|
198 } |
|
199 |
|
200 void TestRadioEngineWrapper::skipNext() |
|
201 { |
|
202 FUNC_LOG; |
|
203 } |
|
204 |
|
205 /*! |
|
206 * Destructor |
|
207 */ |
|
208 TestRadioEngineWrapper::~TestRadioEngineWrapper() |
|
209 { |
|
210 FUNC_LOG; |
|
211 mRadioStubManagerChunk.Close(); |
|
212 delete mEngineWrapper; |
|
213 mEngineWrapper = NULL; |
|
214 delete mScheduler; |
|
215 mScheduler = NULL; |
|
216 } |
|
217 |
|
218 /*! |
|
219 * called before each testfunction is executed |
|
220 */ |
|
221 void TestRadioEngineWrapper::init() |
|
222 { |
|
223 FUNC_LOG; |
|
224 } |
|
225 |
|
226 /*! |
|
227 * called after every testfunction |
|
228 */ |
|
229 void TestRadioEngineWrapper::cleanup() |
|
230 { |
|
231 FUNC_LOG; |
|
232 } |
|
233 |
|
234 /*! |
|
235 * called before the first testfunction is executed |
|
236 */ |
|
237 void TestRadioEngineWrapper::initTestCase() |
|
238 { |
|
239 FUNC_LOG; |
|
240 // Workaround for the below panic, occured after porting to 10.1 |
|
241 // Main Panic E32USER-CBase 44 |
|
242 // Create and install the active scheduler |
|
243 mScheduler = new(ELeave) CActiveScheduler; |
|
244 CActiveScheduler::Install(mScheduler); |
|
245 |
|
246 TInt err = mRadioStubManagerChunk.CreateGlobal( |
|
247 KRadioStubManagerLocalChunkName, |
|
248 sizeof(SRadioStubManager), |
|
249 sizeof(SRadioStubManager), |
|
250 EOwnerThread ); |
|
251 QVERIFY2( KErrNone == err, "Creation of memory chunk KRadioStubManagerLocalChunkName failed." ); |
|
252 QVERIFY2( sizeof(SRadioStubManager) <= mRadioStubManagerChunk.MaxSize(), "Improper size for memory chunk KRadioStubManagerLocalChunkName." ); |
|
253 TUint8* basePtr = mRadioStubManagerChunk.Base(); |
|
254 QVERIFY2( 0 != basePtr, "Getting base pointer of memory chunk KRadioStubManagerLocalChunkName failed." ); |
|
255 mRadioStubManager = (SRadioStubManager*)basePtr; |
|
256 // Zero configuration/control data |
|
257 |
|
258 mRadioStubManager->FillZ(); |
|
259 TRAP( err, mSchedulerTimer = CSchedulerStopAndStartTimer::NewL( *this ) ); |
|
260 QVERIFY2( KErrNone == err, "CSchedulerStopAndStartTimer not constructed!" ); |
|
261 mSchedulerTimer->StartTimer( 1000000, CSchedulerStopAndStartTimer::ETimerIdCreateMUT ); |
|
262 } |
|
263 |
|
264 void TestRadioEngineWrapper::testRadioSettingsReference() |
|
265 { |
|
266 FUNC_LOG; |
|
267 QVERIFY2( 0 != &mEngineWrapper->settings(), "Settings reference illegal!" ); |
|
268 } |
|
269 |
|
270 void TestRadioEngineWrapper::testRegion() |
|
271 { |
|
272 FUNC_LOG; |
|
273 QVERIFY2( mEngineWrapper->region() >= RadioRegion::None, "Illegal Region Id!"); |
|
274 QVERIFY2( mEngineWrapper->region() <= RadioRegion::Poland, "Illegal Region Id!"); |
|
275 QVERIFY2( mEngineWrapper->frequencyStepSize() != 0, "Region Step Size illegal!" ); |
|
276 QVERIFY2( mEngineWrapper->minFrequency() < mEngineWrapper->maxFrequency(), "Region Minimum Frequency illegal!" ); |
|
277 QVERIFY2( mEngineWrapper->maxFrequency() > mEngineWrapper->minFrequency(), "Region Maximum Frequency illegal!" ); |
|
278 QVERIFY2( mEngineWrapper->isFrequencyValid( mEngineWrapper->minFrequency() + mEngineWrapper->frequencyStepSize() ), "Legal frequency not accepted!" ); |
|
279 QVERIFY2( mEngineWrapper->isFrequencyValid( mEngineWrapper->maxFrequency() - mEngineWrapper->frequencyStepSize() ), "Legal frequency not accepted!" ); |
|
280 QVERIFY2( mEngineWrapper->isFrequencyValid( mEngineWrapper->minFrequency() ), "Legal minimum frequency not accepted!" ); |
|
281 QVERIFY2( mEngineWrapper->isFrequencyValid( mEngineWrapper->maxFrequency() ), "Legal maximum frequency not accepted!" ); |
|
282 QVERIFY2( !mEngineWrapper->isFrequencyValid( mEngineWrapper->maxFrequency() + mEngineWrapper->frequencyStepSize() ), "Illegal frequency accepted!" ); |
|
283 QVERIFY2( !mEngineWrapper->isFrequencyValid( mEngineWrapper->minFrequency() - mEngineWrapper->frequencyStepSize() ), "Illegal frequency accepted!" ); |
|
284 QVERIFY2( !mEngineWrapper->isFrequencyValid( 0 + mEngineWrapper->frequencyStepSize() ), "Illegal frequency accepted!" ); |
|
285 QVERIFY2( !mEngineWrapper->isFrequencyValid( 0 - mEngineWrapper->frequencyStepSize() ), "Illegal frequency accepted!" ); |
|
286 } |
|
287 |
|
288 void TestRadioEngineWrapper::testRadioOnOff() |
|
289 { |
|
290 FUNC_LOG; |
|
291 QVERIFY2( !mEngineWrapper->isRadioOn(), "Radio is not off!" ); |
|
292 |
|
293 TInt err(KErrNone); |
|
294 TBool antennaAttached = ETrue; |
|
295 err = RProperty::Set( KStub_KRadioServerPropertyCategory, ERadioServPsAntennaStatus, antennaAttached ); |
|
296 INFO_1("RProperty::Set( KStub_KRadioServerPropertyCategory, ERadioServPsAntennaStatus, antennaAttached ) err: %d", err); |
|
297 QVERIFY2( KErrNone == err, "Setting property ERadioServPsAntennaStatus failed!" ); |
|
298 mSchedulerTimer->StartTimer( 1000000 ); |
|
299 QVERIFY2( mEngineWrapper->isAntennaAttached(), "Headset/Antenna not connected!"); |
|
300 ACCESSORYOBSERVER.iObserver->HeadsetConnectedCallbackL(); |
|
301 |
|
302 TPckgBuf<TRsSettingsData> playerState; |
|
303 playerState().iError = KErrNone; |
|
304 playerState().iData1 = ETrue; |
|
305 err = RProperty::Set( KStub_KRadioServerPropertyCategory, ERadioServPsPlayerState, playerState ); |
|
306 QVERIFY2( KErrNone == err, "Setting property ERadioServPsPlayerState failed!" ); |
|
307 |
|
308 mSchedulerTimer->StartTimer( 1000000 ); |
|
309 QVERIFY2( mEngineWrapper->isAntennaAttached(), "Headset/Antenna not connected!"); |
|
310 QVERIFY2( mEngineWrapper->isRadioOn(), "Radio is not on!" ); |
|
311 } |
|
312 |
|
313 void TestRadioEngineWrapper::testTuning() |
|
314 { |
|
315 FUNC_LOG; |
|
316 QVERIFY2( mEngineWrapper->isRadioOn(), "Radio is not on!" ); |
|
317 |
|
318 // Tune to minimum frequency |
|
319 mEngineWrapper->setFrequency( mEngineWrapper->minFrequency() ); |
|
320 TInt err = mPropertyFrequency.Set( KStub_KRadioServerPropertyCategory, ERadioServPsFrequency, tstGetFrequency() ); |
|
321 QVERIFY2( KErrNone == err, "Setting property ERadioServPsFrequency failed!" ); |
|
322 mSchedulerTimer->StartTimer( 1000000 ); |
|
323 INFO_1("mEngineWrapper->minFrequency() = %i", mEngineWrapper->minFrequency() ); |
|
324 INFO_1("mEngineWrapper->currentFrequency() = %i", mEngineWrapper->currentFrequency() ); |
|
325 QVERIFY2( mEngineWrapper->currentFrequency() == mEngineWrapper->minFrequency(), "Tuning to minimum frequency failed!"); |
|
326 |
|
327 // Seek upwards |
|
328 uint freq_A = mEngineWrapper->currentFrequency(); |
|
329 //mSchedulerTimer->StartTimer( 1000 ); |
|
330 tstSetFrequency( freq_A + mEngineWrapper->frequencyStepSize() ); |
|
331 mEngineWrapper->startSeeking( Seek::Up ); |
|
332 err = mPropertyFrequency.Set( KStub_KRadioServerPropertyCategory, ERadioServPsFrequency, tstGetFrequency() ); |
|
333 QVERIFY2( KErrNone == err, "Setting property ERadioServPsFrequency failed!" ); |
|
334 mSchedulerTimer->StartTimer( 1000000 ); |
|
335 QVERIFY2( TunedToFrequency == ( mEnteredSlots & TunedToFrequency ), "Not Tuned to next upward frequency!"); |
|
336 mEnteredSlots &= !TunedToFrequency; |
|
337 uint freq_B = mEngineWrapper->currentFrequency(); |
|
338 QVERIFY2( (freq_B - mEngineWrapper->frequencyStepSize()) == freq_A, "Seeking upwards failed!"); |
|
339 |
|
340 |
|
341 // Tune to maximum frequency |
|
342 tstSetFrequency( mEngineWrapper->maxFrequency() ); |
|
343 mEngineWrapper->setFrequency( mEngineWrapper->maxFrequency() ); |
|
344 err = mPropertyFrequency.Set( KStub_KRadioServerPropertyCategory, ERadioServPsFrequency, tstGetFrequency() ); |
|
345 QVERIFY2( KErrNone == err, "Setting property ERadioServPsFrequency failed!" ); |
|
346 mSchedulerTimer->StartTimer( 1000000 ); |
|
347 QVERIFY2( TunedToFrequency == ( mEnteredSlots & TunedToFrequency ), "Not Tuned to maximum frequency!"); |
|
348 mEnteredSlots &= !TunedToFrequency; |
|
349 QVERIFY2( mEngineWrapper->currentFrequency() == mEngineWrapper->maxFrequency(), "Current frequency not the maximum one!" ); |
|
350 |
|
351 |
|
352 // Seek downwards |
|
353 mEngineWrapper->startSeeking( Seek::Down ); |
|
354 tstSetFrequency( mEngineWrapper->currentFrequency() - (2 * mEngineWrapper->frequencyStepSize()) ); |
|
355 err = mPropertyFrequency.Set( KStub_KRadioServerPropertyCategory, ERadioServPsFrequency, tstGetFrequency() ); |
|
356 QVERIFY2( KErrNone == err, "Setting property ERadioServPsFrequency failed!" ); |
|
357 mSchedulerTimer->StartTimer( 1000000 ); |
|
358 QVERIFY2( TunedToFrequency == ( mEnteredSlots & TunedToFrequency ), "Not Tuned to next downward frequency!"); |
|
359 mEnteredSlots &= !TunedToFrequency; |
|
360 QVERIFY2( mEngineWrapper->currentFrequency() == mEngineWrapper->maxFrequency()- (2 * mEngineWrapper->frequencyStepSize()), "Seeking downwards failed!"); |
|
361 |
|
362 // Tune to avarage frequency |
|
363 uint averageFrequency( mEngineWrapper->maxFrequency() + mEngineWrapper->minFrequency() ); |
|
364 averageFrequency /= 2; |
|
365 averageFrequency -= ( averageFrequency % mEngineWrapper->frequencyStepSize() ); |
|
366 mEngineWrapper->setFrequency( averageFrequency ); |
|
367 err = mPropertyFrequency.Set( KStub_KRadioServerPropertyCategory, ERadioServPsFrequency, tstGetFrequency() ); |
|
368 QVERIFY2( KErrNone == err, "Setting property ERadioServPsFrequency failed!" ); |
|
369 mSchedulerTimer->StartTimer( 1000000 ); |
|
370 QVERIFY2( TunedToFrequency == ( mEnteredSlots & TunedToFrequency ), "Not Tuned to average frequency!"); |
|
371 mEnteredSlots &= !TunedToFrequency; |
|
372 QVERIFY2( mEngineWrapper->currentFrequency() == averageFrequency, "Tuning to average frequency failed!"); |
|
373 |
|
374 // Try to use frequency above maximum |
|
375 uint freq_C = mEngineWrapper->currentFrequency(); |
|
376 TUNER.iSetFrequencyError.SetStubError( KRadioServErrFrequencyOutOfBandRange ); |
|
377 mEngineWrapper->setFrequency( mEngineWrapper->maxFrequency() + mEngineWrapper->frequencyStepSize() ); |
|
378 mSchedulerTimer->StartTimer( 1000000 ); |
|
379 // Should be == not != as now. This is done in order to complete tests. |
|
380 QVERIFY2( mEngineWrapper->currentFrequency() != freq_C, "Tuning over maximum frequency succeeded?"); |
|
381 QVERIFY2( !mEngineWrapper->isFrequencyValid( mEngineWrapper->currentFrequency() ), "A frequency over maximum accepted?"); |
|
382 |
|
383 // Try to use frequency below minimum |
|
384 uint freq_D = mEngineWrapper->currentFrequency(); |
|
385 TUNER.iSetFrequencyError.SetStubError( KRadioServErrFrequencyOutOfBandRange ); |
|
386 mEngineWrapper->setFrequency( mEngineWrapper->minFrequency() - mEngineWrapper->frequencyStepSize() ); |
|
387 mSchedulerTimer->StartTimer( 1000000 ); |
|
388 // Should be == not != as now. This is done in order to complete tests. |
|
389 QVERIFY2( mEngineWrapper->currentFrequency() != freq_D, "Tuning below minimum frequency succeeded?"); |
|
390 QVERIFY2( !mEngineWrapper->isFrequencyValid( mEngineWrapper->currentFrequency() ), "A frequency below minimum accepted?"); |
|
391 } |
|
392 |
|
393 void TestRadioEngineWrapper::testCancelSeeking() |
|
394 { |
|
395 FUNC_LOG; |
|
396 QVERIFY2( mEngineWrapper->isRadioOn(), "Radio is not on!" ); |
|
397 |
|
398 mEngineWrapper->startSeeking( Seek::Up, TuneReason::StationScanInitialization ); |
|
399 mSchedulerTimer->StartTimer( 1000000 ); |
|
400 TInt frequency1( mEngineWrapper->currentFrequency() ); |
|
401 |
|
402 mEngineWrapper->startSeeking( Seek::Up, TuneReason::StationScan ); |
|
403 tstSetFrequency( mEngineWrapper->currentFrequency() + mEngineWrapper->frequencyStepSize() ); |
|
404 TInt err = mPropertyFrequency.Set( KStub_KRadioServerPropertyCategory, ERadioServPsFrequency, tstGetFrequency() ); |
|
405 QVERIFY2( KErrNone == err, "Setting property ERadioServPsFrequency failed!" ); |
|
406 mSchedulerTimer->StartTimer( 1000000 ); |
|
407 QVERIFY2( mEngineWrapper->currentFrequency() > frequency1, "Seeking Upwards failed!" ); |
|
408 frequency1 = mEngineWrapper->currentFrequency(); |
|
409 |
|
410 mEngineWrapper->cancelSeeking(); |
|
411 } |
|
412 |
|
413 /* Mute's callback function CRadioEngine::MrpoMuteChange() is commented in radio engine, so no point to test here. |
|
414 void TestRadioEngineWrapper::testMute() |
|
415 { |
|
416 FUNC_LOG; |
|
417 QVERIFY2( mEngineWrapper->isRadioOn(), "Radio is not on!" ); |
|
418 // Toggle mute. |
|
419 TBool muted_1( mEngineWrapper->isMuted() ); |
|
420 INFO_1( "muted_1", muted_1 ); |
|
421 mEngineWrapper->setMute( !muted_1 ); |
|
422 TInt err = mPropertyFrequency.Set( KStub_KRadioServerPropertyCategory, ERadioServPsMuteStatus, muted_1 ? 0x0 : 0xff ); |
|
423 QVERIFY2( KErrNone == err, "Setting property ERadioServPsMuteStatus failed!" ); |
|
424 mSchedulerTimer->StartTimer( 1000000 ); |
|
425 TBool muted_2( mEngineWrapper->isMuted() ); |
|
426 QVERIFY2( mEnteredSlots &= MuteChanged, "Mute not changed!"); |
|
427 mEnteredSlots &= !MuteChanged; |
|
428 QVERIFY2( muted_1 != muted_2, "Mute() not working!" ); |
|
429 |
|
430 // Toggle back to original value |
|
431 mEngineWrapper->setMute( muted_1 ); |
|
432 err = mPropertyFrequency.Set( KStub_KRadioServerPropertyCategory, ERadioServPsMuteStatus, muted_1 ); |
|
433 QVERIFY2( KErrNone == err, "Setting property ERadioServPsMuteStatus failed!" ); |
|
434 mSchedulerTimer->StartTimer( 1000000 ); |
|
435 TBool muted_3( mEngineWrapper->isMuted() ); |
|
436 QVERIFY2( mEnteredSlots &= MuteChanged, "Mute not changed!"); |
|
437 mEnteredSlots &= !MuteChanged; |
|
438 QVERIFY2( muted_1 == muted_3, "Mute status not changed to original value!") ; |
|
439 } |
|
440 */ |
|
441 |
|
442 |
|
443 void TestRadioEngineWrapper::testVolumeSetting() |
|
444 { |
|
445 FUNC_LOG; |
|
446 // SetVoliúme(() seems to accept any value. Probably because the real check point |
|
447 // is missing from test constellation. |
|
448 QVERIFY2( mEngineWrapper->isRadioOn(), "Radio is not on!" ); |
|
449 INFO_1( "mLastRecordedVolume: %i", mLastRecordedVolume ); |
|
450 TInt volume_1( 10 ); |
|
451 mEngineWrapper->setVolume( volume_1 ); |
|
452 |
|
453 mSchedulerTimer->StartTimer( 1000000 ); |
|
454 |
|
455 INFO_1( "mLastRecordedVolume: %i", mLastRecordedVolume ); |
|
456 QVERIFY2( mEnteredSlots &= VolumeChanged, "Volume not changed!"); |
|
457 mEnteredSlots &= !VolumeChanged; |
|
458 QVERIFY2( volume_1 == mLastRecordedVolume, "Volume has unexpected value!") ; |
|
459 |
|
460 volume_1 = mLastRecordedVolume; |
|
461 TInt volume_2( (mLastRecordedVolume + 5)%20 ); |
|
462 mEngineWrapper->setVolume( volume_2 ); |
|
463 |
|
464 mSchedulerTimer->StartTimer( 1000000 ); |
|
465 |
|
466 INFO_1( "mLastRecordedVolume: %i", mLastRecordedVolume ); |
|
467 QVERIFY2( mEnteredSlots &= VolumeChanged, "Volume not changed!"); |
|
468 mEnteredSlots &= !VolumeChanged; |
|
469 QVERIFY2( volume_2 == mLastRecordedVolume, "Volume has unexpected value!") ; |
|
470 |
|
471 // Increase volume |
|
472 mEngineWrapper->setVolume( volume_1 ); |
|
473 mSchedulerTimer->StartTimer( 1000000 ); |
|
474 mEngineWrapper->increaseVolume(); |
|
475 mSchedulerTimer->StartTimer( 1000000 ); |
|
476 QVERIFY2( mEnteredSlots &= VolumeChanged, "Volume not increased!"); |
|
477 mEnteredSlots &= !VolumeChanged; |
|
478 QVERIFY2( volume_1 != mLastRecordedVolume, "Volume has unexpected value, not increased!") ; |
|
479 INFO_1( "mLastRecordedVolume: %i", mLastRecordedVolume ); |
|
480 |
|
481 // Decrease volume |
|
482 mEngineWrapper->setVolume( volume_1 ); |
|
483 mSchedulerTimer->StartTimer( 1000000 ); |
|
484 mEngineWrapper->decreaseVolume(); |
|
485 mSchedulerTimer->StartTimer( 1000000 ); |
|
486 QVERIFY2( mEnteredSlots &= VolumeChanged, "Volume not decreased!"); |
|
487 mEnteredSlots &= !VolumeChanged; |
|
488 QVERIFY2( volume_1 != mLastRecordedVolume, "Volume has unexpected value, not decreased!") ; |
|
489 INFO_1( "mLastRecordedVolume: %i", mLastRecordedVolume ); |
|
490 |
|
491 mEngineWrapper->toggleAudioRoute(); |
|
492 mEngineWrapper->toggleAudioRoute(); |
|
493 |
|
494 } |
|
495 |
|
496 void TestRadioEngineWrapper::testLoudSpeakerUsage() |
|
497 { |
|
498 FUNC_LOG; |
|
499 QVERIFY2( mEngineWrapper->isRadioOn(), "Radio is not on!" ); |
|
500 TBool isLoudSpeakerUsed( mEngineWrapper->isUsingLoudspeaker() ); |
|
501 INFO_1( "isLoudSpeakerUsed: %i", isLoudSpeakerUsed ); |
|
502 } |
|
503 |
|
504 |
|
505 /*! |
|
506 * called after the last testfunction was executed |
|
507 */ |
|
508 void TestRadioEngineWrapper::cleanupTestCase() |
|
509 { |
|
510 FUNC_LOG; |
|
511 DeleteMUT(); |
|
512 delete mScheduler; |
|
513 mScheduler = NULL; |
|
514 mRadioStubManagerChunk.Close(); |
|
515 mPropertyPlayerState.Close(); |
|
516 mPropertyAntennaStatus.Close(); |
|
517 mPropertyOfflineMode.Close(); |
|
518 mPropertyTransmitterStatus.Close(); |
|
519 mPropertyFrequency.Close(); |
|
520 mPropertyFrequencyRange.Close(); |
|
521 mPropertyForceMonoReception.Close(); |
|
522 mPropertySquelch.Close(); |
|
523 mPropertyVolume.Close(); |
|
524 mPropertyMuteStatus.Close(); |
|
525 mPropertyBalance.Close(); |
|
526 } |
|
527 |
|
528 void TestRadioEngineWrapper::tstSetTunerCababilities(uint /*category*/) |
|
529 { |
|
530 FUNC_LOG; |
|
531 TUNER.iCaps.iFrequencyRange = ERsRangeFmEuroAmerica; |
|
532 TUNER.iCaps.iCapabilities = |
|
533 TRsTunerCapabilities::ETunerFunctionAvailableInOfflineMode | |
|
534 TRsTunerCapabilities::ETunerFunctionRds | |
|
535 TRsTunerCapabilities::ETunerFunctionDualTuner; |
|
536 } |
|
537 |
|
538 void TestRadioEngineWrapper::Timeout( TUint aTimerId ) |
|
539 { |
|
540 FUNC_LOG; |
|
541 if ( CSchedulerStopAndStartTimer::ETimerIdCreateMUT == aTimerId ) |
|
542 { |
|
543 INFO("ETimerIdCreateMUT elapsed"); |
|
544 } |
|
545 else if ( CSchedulerStopAndStartTimer::ETimerIdDeleteMUT == aTimerId ) |
|
546 { |
|
547 INFO("ETimerIdDeleteMUT elapsed"); |
|
548 } |
|
549 else if ( CSchedulerStopAndStartTimer::ETimerIdRunMUT == aTimerId ) |
|
550 { |
|
551 INFO("ETimerIdRunMUT elapsed"); |
|
552 } |
|
553 else |
|
554 { |
|
555 INFO("Unknown timer elapsed"); |
|
556 } |
|
557 } |
|
558 |
|
559 void TestRadioEngineWrapper::CreateMUT() |
|
560 { |
|
561 FUNC_LOG; |
|
562 tstDefineAndAttachRadioServerProperties(); |
|
563 TInt err( KErrNone ); |
|
564 err = tstCreateCRObjects(); |
|
565 QVERIFY2( KErrNone == err, "Radio CR not created!" ); |
|
566 TRAP( err, mEngineWrapper = new (ELeave) RadioEngineWrapper( *this ) ); |
|
567 RadioEngineUtils::InitializeL(); |
|
568 bool retVal( EFalse ); |
|
569 retVal = mEngineWrapper->init(); |
|
570 QVERIFY2( EFalse != retVal, "mEngineWrapper->init() failed!"); |
|
571 mEngineWrapper->addObserver( this ); |
|
572 QVERIFY2( KErrNone == err, "Radio Engine not constructed!" ); |
|
573 tstSetTunerCababilities(); |
|
574 } |
|
575 |
|
576 void TestRadioEngineWrapper::DeleteMUT() |
|
577 { |
|
578 FUNC_LOG; |
|
579 mEngineWrapper->removeObserver( this ); |
|
580 delete mEngineWrapper; |
|
581 mEngineWrapper = NULL; |
|
582 } |
|
583 |
|
584 void TestRadioEngineWrapper::tstSetFrequency( TUint aFrequency ) |
|
585 { |
|
586 FUNC_LOG; |
|
587 TUNER.iFrequency = aFrequency; |
|
588 } |
|
589 |
|
590 TInt TestRadioEngineWrapper::tstGetFrequency() |
|
591 { |
|
592 FUNC_LOG; |
|
593 return TUNER.iFrequency; |
|
594 } |
|
595 |
|
596 void TestRadioEngineWrapper::tstSetScanningData( TUint aCount, TInt aMinFreq, TInt aFrequencyStepSize ) |
|
597 { |
|
598 FUNC_LOG; |
|
599 TUNER.iScanStations.iCount = aCount; |
|
600 TUNER.iScanStations.iMinFreq = aMinFreq; |
|
601 TUNER.iScanStations.iFrequencyStepSize = aFrequencyStepSize; |
|
602 } |
|
603 |
|
604 |
|
605 void TestRadioEngineWrapper::tstDefineAndAttachRadioServerProperties() |
|
606 { |
|
607 FUNC_LOG; |
|
608 QVERIFY2(KErrNone == RProperty::Define(KStub_KRadioServerPropertyCategory, ERadioServPsPlayerState, RProperty::EByteArray, |
|
609 KRadioServerReadPolicy, KRadioServerWritePolicy), "Property Define() failed!"); |
|
610 QVERIFY2(KErrNone == RProperty::Define(KStub_KRadioServerPropertyCategory, ERadioServPsAntennaStatus, RProperty::EInt, |
|
611 KRadioServerReadPolicy, KRadioServerWritePolicy), "Property Define() failed!"); |
|
612 QVERIFY2(KErrNone == RProperty::Define(KStub_KRadioServerPropertyCategory, ERadioServPsOfflineMode, RProperty::EInt, |
|
613 KRadioServerReadPolicy, KRadioServerWritePolicy), "Property Define() failed!"); |
|
614 QVERIFY2(KErrNone == RProperty::Define(KStub_KRadioServerPropertyCategory, ERadioServPsTransmitterStatus, RProperty::EInt, |
|
615 KRadioServerReadPolicy, KRadioServerWritePolicy), "Property Define() failed!"); |
|
616 QVERIFY2(KErrNone == RProperty::Define(KStub_KRadioServerPropertyCategory, ERadioServPsFrequency, RProperty::EInt, |
|
617 KRadioServerReadPolicy, KRadioServerWritePolicy), "Property Define() failed!"); |
|
618 QVERIFY2(KErrNone == RProperty::Define(KStub_KRadioServerPropertyCategory, ERadioServPsFrequencyRange, RProperty::EInt, |
|
619 KRadioServerReadPolicy, KRadioServerWritePolicy), "Property Define() failed!"); |
|
620 QVERIFY2(KErrNone == RProperty::Define(KStub_KRadioServerPropertyCategory, ERadioServPsForceMonoReception, RProperty::EInt, |
|
621 KRadioServerReadPolicy, KRadioServerWritePolicy), "Property Define() failed!"); |
|
622 QVERIFY2(KErrNone == RProperty::Define(KStub_KRadioServerPropertyCategory, ERadioServPsSquelch, RProperty::EInt, |
|
623 KRadioServerReadPolicy, KRadioServerWritePolicy), "Property Define() failed!"); |
|
624 QVERIFY2(KErrNone == RProperty::Define(KStub_KRadioServerPropertyCategory, ERadioServPsVolume, RProperty::EInt, |
|
625 KRadioServerReadPolicy, KRadioServerWritePolicy), "Property Define() failed!"); |
|
626 QVERIFY2(KErrNone == RProperty::Define(KStub_KRadioServerPropertyCategory, ERadioServPsMuteStatus, RProperty::EInt, |
|
627 KRadioServerReadPolicy, KRadioServerWritePolicy), "Property Define() failed!"); |
|
628 QVERIFY2(KErrNone == RProperty::Define(KStub_KRadioServerPropertyCategory, ERadioServPsBalance, RProperty::EByteArray, |
|
629 KRadioServerReadPolicy, KRadioServerWritePolicy), "Property Define() failed!"); |
|
630 |
|
631 |
|
632 QVERIFY2(KErrNone == mPropertyPlayerState.Attach( KStub_KRadioServerPropertyCategory, ERadioServPsPlayerState ), "Property Attach() failed!"); |
|
633 QVERIFY2(KErrNone == mPropertyAntennaStatus.Attach( KStub_KRadioServerPropertyCategory, ERadioServPsAntennaStatus ), "Property Attach() failed!"); |
|
634 QVERIFY2(KErrNone == mPropertyOfflineMode.Attach( KStub_KRadioServerPropertyCategory, ERadioServPsOfflineMode ), "Property Attach() failed!"); |
|
635 QVERIFY2(KErrNone == mPropertyTransmitterStatus.Attach( KStub_KRadioServerPropertyCategory, ERadioServPsTransmitterStatus ), "Property Attach() failed!"); |
|
636 QVERIFY2(KErrNone == mPropertyFrequency.Attach( KStub_KRadioServerPropertyCategory, ERadioServPsFrequency ), "Property Attach() failed!"); |
|
637 QVERIFY2(KErrNone == mPropertyFrequencyRange.Attach( KStub_KRadioServerPropertyCategory, ERadioServPsFrequencyRange ), "Property Attach() failed!"); |
|
638 QVERIFY2(KErrNone == mPropertyForceMonoReception.Attach( KStub_KRadioServerPropertyCategory, ERadioServPsForceMonoReception ), "Property Attach() failed!"); |
|
639 QVERIFY2(KErrNone == mPropertySquelch.Attach( KStub_KRadioServerPropertyCategory, ERadioServPsSquelch ), "Property Attach() failed!"); |
|
640 QVERIFY2(KErrNone == mPropertyVolume.Attach( KStub_KRadioServerPropertyCategory, ERadioServPsVolume ), "Property Attach() failed!"); |
|
641 QVERIFY2(KErrNone == mPropertyMuteStatus.Attach( KStub_KRadioServerPropertyCategory, ERadioServPsMuteStatus ), "Property Attach() failed!"); |
|
642 QVERIFY2(KErrNone == mPropertyBalance.Attach( KStub_KRadioServerPropertyCategory, ERadioServPsBalance ), "Property Attach() failed!"); |
|
643 } |
|
644 |
|
645 TInt TestRadioEngineWrapper::tstCreateCRObjects() |
|
646 { |
|
647 FUNC_LOG; |
|
648 TInt err( KErrNone ); |
|
649 TRAP( err, mRadioCR = CRepository::NewL(KStub_KRadioCRUid) ); |
|
650 INFO_1( "Returning err = %i", err ); |
|
651 return err; |
|
652 } |
|
653 |
|
654 |
|