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: |
|
15 * |
|
16 */ |
|
17 #include "ut_lcuiengine.h" |
|
18 #include "lcuiengine.h" |
|
19 #include "lcuiengine_p.h" |
|
20 #include "lcactivitymanager.h" |
|
21 |
|
22 #include "lcenginestub.h" |
|
23 #include "lcsessionstub.h" |
|
24 #include "lcvideoplayerstub.h" |
|
25 #include "lcuidefs.h" |
|
26 #include "qthighway_stub_helper.h" |
|
27 |
|
28 #include <QtTest/QtTest> |
|
29 #include <QMap> |
|
30 |
|
31 #include <hbmainwindow.h> |
|
32 #include <hbdialog.h> |
|
33 #include <hbprogressdialog.h> |
|
34 #include <hbmessagebox.h> |
|
35 #include <hbaction.h> |
|
36 #include <hblabel.h> |
|
37 #include <QSignalSpy> |
|
38 #include <hbview.h> |
|
39 |
|
40 #include <xqsettingsmanager.h> |
|
41 #include <xqsettingskey.h> |
|
42 #include <settingsinternalcrkeys.h> |
|
43 #include <telincallvolcntrlcrkeys.h> |
|
44 |
|
45 const char lcutMultimediaSharingEng[] = "MultimediaSharing"; |
|
46 const char lcutVideotelephonyEng[] = "Videotelephony"; |
|
47 |
|
48 const char lcutMultimediaSharingApp[] = "Multimedia Sharing"; |
|
49 const char lcutVideotelephonyApp[] = "Videotelephony"; |
|
50 |
|
51 #define LC_ENGINE( uiengine )\ |
|
52 (static_cast<CLcEngineStub*>( uiengine->d->mLiveCommsEngine ) ) |
|
53 |
|
54 #define LC_SESSION( uiengine )\ |
|
55 (LC_ENGINE(uiengine)->iSession) |
|
56 |
|
57 void UT_LcUiEngine::initTestCase() |
|
58 { |
|
59 lcutStub_LcEngine_reset(); |
|
60 lcutStub_LcSession_reset(); |
|
61 lcutStub_LcPlayer_reset(); |
|
62 |
|
63 } |
|
64 |
|
65 void UT_LcUiEngine::cleanupTestCase() |
|
66 { |
|
67 lcutStub_LcEngine_reset(); |
|
68 lcutStub_LcSession_reset(); |
|
69 lcutStub_LcPlayer_reset(); |
|
70 } |
|
71 |
|
72 |
|
73 void UT_LcUiEngine::init() |
|
74 { |
|
75 lcutStub_LcEngine_reset(); |
|
76 lcutStub_LcSession_reset(); |
|
77 lcutStub_LcPlayer_reset(); |
|
78 mEngine = new LcUiEngine( lcutMultimediaSharingEng, |
|
79 lcutMultimediaSharingApp ); |
|
80 mInvitingNote = new HbProgressDialog(); |
|
81 mWaitingNote = new HbProgressDialog(); |
|
82 mAcceptQuery = new HbDialog(); |
|
83 mRecipientQuery = new HbDialog(); |
|
84 mShareOwnVideoQuery = new HbDialog(); |
|
85 |
|
86 } |
|
87 |
|
88 void UT_LcUiEngine::cleanup() |
|
89 { |
|
90 lcutStub_LcEngine_reset(); |
|
91 lcutStub_LcSession_reset(); |
|
92 lcutStub_LcPlayer_reset(); |
|
93 delete mEngine; |
|
94 delete mInvitingNote; |
|
95 delete mWaitingNote; |
|
96 delete mAcceptQuery; |
|
97 delete mRecipientQuery; |
|
98 delete mShareOwnVideoQuery; |
|
99 } |
|
100 |
|
101 void UT_LcUiEngine::testConstructor() |
|
102 { |
|
103 // "MuS plug-in" loaded |
|
104 QVERIFY( mEngine ); |
|
105 QCOMPARE( mEngine->d->mViewLayout, Lc_IdleViewLayout ); |
|
106 QVERIFY( !mEngine->d->mInvitingNote ); |
|
107 QVERIFY( !mEngine->d->mWaitingNote ); |
|
108 QVERIFY( !mEngine->d->mAcceptQuery ); |
|
109 QVERIFY( !mEngine->d->mRecipientQuery ); |
|
110 QVERIFY( !mEngine->d->mCloseTimer ); |
|
111 QVERIFY( mEngine->d->mLiveCommsEngine ); |
|
112 QCOMPARE( mEngine->d->mEngineName, QByteArray( lcutMultimediaSharingEng ) ); |
|
113 QVERIFY( mEngine->d->recipient() != hbTrId("txt_vt_custom_unknown_number") ); |
|
114 QCOMPARE( mEngine->d->sessionTitle(), QString( lcutMultimediaSharingApp ) ); |
|
115 int engineWindowParam = 0; |
|
116 QVERIFY( LC_SESSION( mEngine )->mParams.contains( engineWindowParam ) ); |
|
117 QVERIFY( mEngine->d->mActivityManager ); |
|
118 QVERIFY( !mEngine->d->mActivityManager->isActivitySimulationEnabled() ); |
|
119 QVERIFY( !mEngine->d->mShareOwnVideoQuery ); |
|
120 |
|
121 // "VT plug-in" loaded |
|
122 lcutStub_LcEngine_reset(); |
|
123 lcutStub_LcSession_reset(); |
|
124 delete mEngine; |
|
125 mEngine = 0; |
|
126 mEngine = new LcUiEngine( lcutVideotelephonyEng, |
|
127 lcutVideotelephonyApp ); |
|
128 QVERIFY( mEngine ); |
|
129 QCOMPARE( mEngine->d->mViewLayout, Lc_AllInOneViewLayout ); |
|
130 QVERIFY( !mEngine->d->mInvitingNote ); |
|
131 QVERIFY( !mEngine->d->mWaitingNote ); |
|
132 QVERIFY( !mEngine->d->mAcceptQuery ); |
|
133 QVERIFY( !mEngine->d->mRecipientQuery ); |
|
134 QVERIFY( !mEngine->d->mCloseTimer ); |
|
135 QVERIFY( mEngine->d->mLiveCommsEngine ); |
|
136 QCOMPARE( mEngine->d->mEngineName, QByteArray( lcutVideotelephonyEng ) ); |
|
137 QVERIFY( mEngine->d->recipient() != hbTrId("txt_vt_custom_unknown_number") ); |
|
138 QCOMPARE( mEngine->d->sessionTitle(), QString( lcutVideotelephonyApp ) ); |
|
139 QVERIFY( LC_SESSION( mEngine )->mParams.contains( engineWindowParam ) ); |
|
140 QVERIFY( !mEngine->d->mFullScreen ); |
|
141 QVERIFY( mEngine->d->mActivityManager ); |
|
142 QVERIFY( !mEngine->d->mActivityManager->isActivitySimulationEnabled() ); |
|
143 QVERIFY( !mEngine->d->mShareOwnVideoQuery ); |
|
144 } |
|
145 |
|
146 void UT_LcUiEngine::testFeatureSupported() |
|
147 { |
|
148 // Engine not loaded |
|
149 CLcEngine* enginePtr = mEngine->d->mLiveCommsEngine; |
|
150 mEngine->d->mLiveCommsEngine = 0; |
|
151 QVERIFY( !mEngine->d->featureSupported( CLcEngine::ELcShowAcceptQuery ) ); |
|
152 |
|
153 // Engine loaded, feature not supported |
|
154 mEngine->d->mLiveCommsEngine = enginePtr; |
|
155 QVERIFY( !mEngine->d->featureSupported( CLcEngine::ELcShowAcceptQuery ) ); |
|
156 |
|
157 // Feature supported |
|
158 lcutStub_LcEngine_setLcFeatureSupported( true ); |
|
159 QVERIFY( mEngine->d->featureSupported( CLcEngine::ELcShowAcceptQuery ) ); |
|
160 } |
|
161 |
|
162 void UT_LcUiEngine::testEstablishSession() |
|
163 { |
|
164 // Leave |
|
165 lcutStub_LcEngine_setFailure( -1 ); |
|
166 QCOMPARE( mEngine->d->establishSession(), -1 ); |
|
167 QVERIFY( !mEngine->d->mCloseTimer ); |
|
168 |
|
169 // No leave |
|
170 lcutStub_LcEngine_reset(); |
|
171 QCOMPARE( mEngine->d->establishSession(), 0 ); |
|
172 QVERIFY( mEngine->d->mCloseTimer ); |
|
173 } |
|
174 |
|
175 void UT_LcUiEngine::testTerminateSession() |
|
176 { |
|
177 // Leave |
|
178 lcutStub_LcEngine_setFailure( -1 ); |
|
179 QCOMPARE( mEngine->d->terminateSession(), -1 ); |
|
180 |
|
181 // No leave |
|
182 lcutStub_LcEngine_reset(); |
|
183 QCOMPARE( mEngine->d->establishSession(), 0 ); |
|
184 } |
|
185 |
|
186 void UT_LcUiEngine::testSetWindowRect() |
|
187 { |
|
188 TRect rect; |
|
189 MLcVideoPlayer* player = |
|
190 mEngine->d->mLiveCommsEngine->Session().LocalVideoPlayer(); |
|
191 |
|
192 // No player |
|
193 QCOMPARE( mEngine->d->setWindowRect( 0, rect ), -1 ); |
|
194 |
|
195 // Leave |
|
196 lcutStub_LcEngine_setFailure( -2 ); |
|
197 QCOMPARE( mEngine->d->setWindowRect( player, rect ), -2 ); |
|
198 |
|
199 // No leave |
|
200 lcutStub_LcEngine_reset(); |
|
201 QCOMPARE( mEngine->d->setWindowRect( player, rect ), 0 ); |
|
202 } |
|
203 |
|
204 void UT_LcUiEngine::testEnableWindow() |
|
205 { |
|
206 MLcVideoPlayer* player = |
|
207 mEngine->d->mLiveCommsEngine->Session().LocalVideoPlayer(); |
|
208 |
|
209 // No player |
|
210 QCOMPARE( mEngine->d->enableWindow( 0, true ), -1 ); |
|
211 |
|
212 // Leave |
|
213 lcutStub_LcEngine_setFailure( -2 ); |
|
214 QCOMPARE( mEngine->d->enableWindow( player, true ), -2 ); |
|
215 |
|
216 // No leave |
|
217 lcutStub_LcEngine_reset(); |
|
218 QCOMPARE( mEngine->d->enableWindow( player, true ), 0 ); |
|
219 } |
|
220 |
|
221 void UT_LcUiEngine::testPlay() |
|
222 { |
|
223 MLcVideoPlayer* player = |
|
224 mEngine->d->mLiveCommsEngine->Session().LocalVideoPlayer(); |
|
225 |
|
226 // No player |
|
227 QCOMPARE( mEngine->d->play( 0 ), -1 ); |
|
228 |
|
229 // Leave |
|
230 lcutStub_LcEngine_setFailure( -2 ); |
|
231 QCOMPARE( mEngine->d->play( player ), -2 ); |
|
232 |
|
233 // No leave |
|
234 lcutStub_LcEngine_reset(); |
|
235 QVERIFY( !player->LcIsPlayingL() ); |
|
236 QCOMPARE( mEngine->d->play( player ), 0 ); |
|
237 QVERIFY( player->LcIsPlayingL() ); |
|
238 } |
|
239 |
|
240 void UT_LcUiEngine::testPause() |
|
241 { |
|
242 MLcVideoPlayer* player = |
|
243 mEngine->d->mLiveCommsEngine->Session().LocalVideoPlayer(); |
|
244 |
|
245 // No player |
|
246 QCOMPARE( mEngine->d->pause( 0 ), -1 ); |
|
247 |
|
248 // Leave |
|
249 lcutStub_LcEngine_setFailure( -2 ); |
|
250 QCOMPARE( mEngine->d->pause( player ), -2 ); |
|
251 |
|
252 // No leave |
|
253 lcutStub_LcEngine_reset(); |
|
254 QCOMPARE( mEngine->d->play( player ), 0 ); |
|
255 QVERIFY( player->LcIsPlayingL() ); |
|
256 QCOMPARE( mEngine->d->pause( player ), 0 ); |
|
257 QVERIFY( !player->LcIsPlayingL() ); |
|
258 } |
|
259 |
|
260 void UT_LcUiEngine::testEnableSpeaker() |
|
261 { |
|
262 // Leave |
|
263 lcutStub_LcEngine_setFailure( -1 ); |
|
264 QCOMPARE( mEngine->d->enableSpeaker( true ), -1 ); |
|
265 QVERIFY( !mEngine->d->isSpeakerOn() ); |
|
266 |
|
267 // No leave |
|
268 lcutStub_LcEngine_reset(); |
|
269 QCOMPARE( mEngine->d->enableSpeaker( true ), 0 ); |
|
270 QVERIFY( mEngine->d->isSpeakerOn() ); |
|
271 } |
|
272 |
|
273 void UT_LcUiEngine::testMuteMic() |
|
274 { |
|
275 // Leave |
|
276 lcutStub_LcEngine_setFailure( -1 ); |
|
277 QCOMPARE( mEngine->d->muteMic( true ), -1 ); |
|
278 lcutStub_LcEngine_reset(); |
|
279 QVERIFY( !mEngine->d->isMuted() ); |
|
280 |
|
281 // No leave |
|
282 QCOMPARE( mEngine->d->muteMic( true ), 0 ); |
|
283 QVERIFY( mEngine->d->isMuted() ); |
|
284 } |
|
285 |
|
286 void UT_LcUiEngine::testStartLiveContent() |
|
287 { |
|
288 // mInvitingNote not set |
|
289 mInvitingNote->hide(); |
|
290 mEngine->d->startLiveContent(); |
|
291 QVERIFY( !mInvitingNote->isVisible() ); |
|
292 QVERIFY( lcutStub_LcSession_expectCall( lcutStub_LcSession_establishSession ) ); |
|
293 |
|
294 // mInvitingNote set, but the engine does not support the feature |
|
295 lcutStub_LcSession_reset(); |
|
296 mEngine->d->mInvitingNote = mInvitingNote; |
|
297 mEngine->d->startLiveContent(); |
|
298 QVERIFY( !mInvitingNote->isVisible() ); |
|
299 QVERIFY( lcutStub_LcSession_expectCall( lcutStub_LcSession_establishSession ) ); |
|
300 |
|
301 // mInvitingNote set and the engine supports the feature |
|
302 lcutStub_LcSession_reset(); |
|
303 lcutStub_LcEngine_setLcFeatureSupported( true ); |
|
304 mEngine->d->startLiveContent(); |
|
305 QVERIFY( mInvitingNote->isVisible() ); |
|
306 QVERIFY( lcutStub_LcSession_expectCall( lcutStub_LcSession_establishSession ) ); |
|
307 } |
|
308 |
|
309 void UT_LcUiEngine::testStart() |
|
310 { |
|
311 LC_SESSION( mEngine )->iState = MLcSession::EReceived; |
|
312 mEngine->d->start(); |
|
313 QVERIFY( mEngine->d->mActivityManager->isActivitySimulationEnabled() ); |
|
314 QVERIFY( lcutStub_LcSession_expectCall( lcutStub_LcSession_NoCall ) ); |
|
315 |
|
316 lcutStub_LcSession_reset(); |
|
317 lcutStub_LcPlayer_reset(); |
|
318 |
|
319 LC_SESSION( mEngine )->iState = MLcSession::EInitialized; |
|
320 mEngine->d->start(); |
|
321 QVERIFY( lcutStub_LcSession_expectCall( lcutStub_LcSession_establishSession ) ); |
|
322 |
|
323 lcutStub_LcSession_reset(); |
|
324 lcutStub_LcPlayer_reset(); |
|
325 |
|
326 mEngine->d->setUiComponents( mInvitingNote, mWaitingNote, |
|
327 mAcceptQuery, mRecipientQuery,mShareOwnVideoQuery ); |
|
328 LC_SESSION( mEngine )->iState = MLcSession::EInitialized; |
|
329 mEngine->d->start(); |
|
330 QVERIFY( lcutStub_LcSession_expectCall( lcutStub_LcSession_establishSession ) ); |
|
331 } |
|
332 |
|
333 void UT_LcUiEngine::testSetUiComponents() |
|
334 { |
|
335 QVERIFY( !mEngine->d->mInvitingNote ); |
|
336 QVERIFY( !mEngine->d->mWaitingNote ); |
|
337 QVERIFY( !mEngine->d->mAcceptQuery ); |
|
338 QVERIFY( !mEngine->d->mRecipientQuery ); |
|
339 |
|
340 mEngine->d->setUiComponents(0,0,0,0,0); |
|
341 |
|
342 QVERIFY( !mEngine->d->mInvitingNote ); |
|
343 QVERIFY( !mEngine->d->mWaitingNote ); |
|
344 QVERIFY( !mEngine->d->mAcceptQuery ); |
|
345 QVERIFY( !mEngine->d->mRecipientQuery ); |
|
346 |
|
347 mEngine->d->setUiComponents(mInvitingNote,mWaitingNote,mAcceptQuery,mRecipientQuery,mShareOwnVideoQuery); |
|
348 QVERIFY( mEngine->d->mInvitingNote ); |
|
349 QVERIFY( mEngine->d->mWaitingNote ); |
|
350 QVERIFY( mEngine->d->mAcceptQuery ); |
|
351 QVERIFY( mEngine->d->mRecipientQuery ); |
|
352 } |
|
353 |
|
354 void UT_LcUiEngine::testSessionStateChanged() |
|
355 { |
|
356 LC_SESSION( mEngine )->iState = MLcSession::EUninitialized; |
|
357 mEngine->d->StateChanged( *LC_SESSION( mEngine ) ); |
|
358 QVERIFY( lcutStub_LcSession_expectCall( lcutStub_LcSession_NoCall ) ); |
|
359 |
|
360 lcutStub_LcSession_reset(); |
|
361 lcutStub_LcPlayer_reset(); |
|
362 |
|
363 QVERIFY( mEngine->d->mSessionDurationTimerId == 0 ); |
|
364 LC_SESSION( mEngine )->iState = MLcSession::EOpen; |
|
365 mEngine->d->StateChanged( *LC_SESSION( mEngine ) ); |
|
366 QVERIFY( lcutStub_LcSession_expectCall( lcutStub_LcSession_NoCall ) ); |
|
367 QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcPlayer_EnableLcWindowL ) ); |
|
368 // Session duration is started when session opened |
|
369 QVERIFY( mEngine->d->mSessionDurationTimerId != 0 ); |
|
370 |
|
371 lcutStub_LcSession_reset(); |
|
372 lcutStub_LcPlayer_reset(); |
|
373 |
|
374 LC_SESSION( mEngine )->iState = MLcSession::EClosed; |
|
375 QSignalSpy spy(mEngine, SIGNAL(stopped())); |
|
376 mEngine->d->StateChanged( *LC_SESSION( mEngine ) ); |
|
377 QVERIFY( lcutStub_LcSession_expectCall( lcutStub_LcSession_NoCall ) ); |
|
378 QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcPlayer_NoCall ) ); |
|
379 QCOMPARE( spy.count(), 1 ); |
|
380 |
|
381 // mAcceptQuery not set |
|
382 lcutStub_LcSession_reset(); |
|
383 lcutStub_LcPlayer_reset(); |
|
384 mAcceptQuery->hide(); |
|
385 LC_SESSION( mEngine )->iState = MLcSession::EReceived; |
|
386 mEngine->d->StateChanged( *LC_SESSION( mEngine ) ); |
|
387 QVERIFY( !mAcceptQuery->isVisible() ); |
|
388 QVERIFY( lcutStub_LcSession_expectCall( lcutStub_LcSession_establishSession ) ); |
|
389 QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcPlayer_NoCall ) ); |
|
390 |
|
391 // mAcceptQuery set, but the engine does not support the feature |
|
392 lcutStub_LcSession_reset(); |
|
393 lcutStub_LcPlayer_reset(); |
|
394 LC_SESSION( mEngine )->iState = MLcSession::EReceived; |
|
395 mEngine->d->mAcceptQuery = mAcceptQuery; |
|
396 mEngine->d->StateChanged( *LC_SESSION( mEngine ) ); |
|
397 QVERIFY( !mAcceptQuery->isVisible() ); |
|
398 QVERIFY( lcutStub_LcSession_expectCall( lcutStub_LcSession_establishSession ) ); |
|
399 QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcPlayer_NoCall ) ); |
|
400 |
|
401 // mAcceptQuery set and the engine supports the feature |
|
402 lcutStub_LcSession_reset(); |
|
403 lcutStub_LcPlayer_reset(); |
|
404 LC_SESSION( mEngine )->iState = MLcSession::EReceived; |
|
405 lcutStub_LcEngine_setLcFeatureSupported( true ); |
|
406 mEngine->d->StateChanged( *LC_SESSION( mEngine ) ); |
|
407 QVERIFY( mAcceptQuery->isVisible() ); |
|
408 QVERIFY( lcutStub_LcSession_expectCall( lcutStub_LcSession_NoCall ) ); |
|
409 QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcPlayer_NoCall ) ); |
|
410 |
|
411 // MT call and sharing own video not allowed by default , popup query shown |
|
412 lcutStub_LcSession_reset(); |
|
413 lcutStub_LcPlayer_reset(); |
|
414 mShareOwnVideoQuery->hide(); |
|
415 mEngine->d->setUiComponents(mInvitingNote,mWaitingNote,mAcceptQuery,mRecipientQuery,mShareOwnVideoQuery); |
|
416 LC_SESSION( mEngine )->iState = MLcSession::EOpen; |
|
417 lcutStub_LcEngine_setLcFeatureSupported( true ); |
|
418 mEngine->d->StateChanged( *LC_SESSION( mEngine ) ); |
|
419 QVERIFY( mEngine->d->mShareOwnVideoQuery ); |
|
420 QVERIFY( mEngine->d->mShareOwnVideoQuery->isVisible() ); |
|
421 CLcVideoPlayer* localPlayer = LC_SESSION( mEngine )->iLocalPlayer; |
|
422 localPlayer = 0; |
|
423 |
|
424 // MO call and sharing own video allowed by default , popup query not shown |
|
425 lcutStub_LcSession_reset(); |
|
426 lcutStub_LcPlayer_reset(); |
|
427 mShareOwnVideoQuery->hide(); |
|
428 mEngine->d->setUiComponents(mInvitingNote,mWaitingNote,mAcceptQuery,mRecipientQuery,mShareOwnVideoQuery); |
|
429 LC_SESSION( mEngine )->iState = MLcSession::EOpen; |
|
430 lcutStub_LcEngine_setLcFeatureSupported( false ); |
|
431 mEngine->d->StateChanged( *LC_SESSION( mEngine ) ); |
|
432 QVERIFY( mEngine->d->mShareOwnVideoQuery ); |
|
433 QVERIFY( !mEngine->d->mShareOwnVideoQuery->isVisible() ); |
|
434 |
|
435 } |
|
436 |
|
437 void UT_LcUiEngine::testPlayerStateChanged() |
|
438 { |
|
439 CLcVideoPlayer* localPlayer = LC_SESSION( mEngine )->iLocalPlayer; |
|
440 QVERIFY( localPlayer != NULL ); |
|
441 QSignalSpy localPlayerSignalSpy( mEngine, SIGNAL( localPlayerPlaying() ) ); |
|
442 QSignalSpy localPlayerSignalSpy2( mEngine, SIGNAL( localPlayerPreparing() ) ); |
|
443 QSignalSpy localPlayerSignalSpy3( mEngine, SIGNAL( localPlayerBuffering() ) ); |
|
444 QSignalSpy localPlayerSignalSpy4( mEngine, SIGNAL( localPlayerPaused() ) ); |
|
445 QSignalSpy localPlayerSignalSpy5( mEngine, SIGNAL( localPlayerUnavailable() ) ); |
|
446 |
|
447 CLcVideoPlayer* remotePlayer = LC_SESSION( mEngine )->iRemotePlayer; |
|
448 QVERIFY( remotePlayer != NULL ); |
|
449 QSignalSpy remotePlayerSignalSpy( mEngine, SIGNAL( remotePlayerPlaying() ) ); |
|
450 QSignalSpy remotePlayerSignalSpy2( mEngine, SIGNAL( remotePlayerPreparing() ) ); |
|
451 QSignalSpy remotePlayerSignalSpy3( mEngine, SIGNAL( remotePlayerBuffering() ) ); |
|
452 QSignalSpy remotePlayerSignalSpy4( mEngine, SIGNAL( remotePlayerPaused() ) ); |
|
453 QSignalSpy remotePlayerSignalSpy5( mEngine, SIGNAL( remotePlayerUnavailable() ) ); |
|
454 |
|
455 // Use local player, player not playing |
|
456 mEngine->d->StateChanged( *localPlayer ); |
|
457 QCOMPARE( localPlayerSignalSpy.count(), 0 ); |
|
458 QCOMPARE( localPlayerSignalSpy2.count(), 0 ); |
|
459 QCOMPARE( localPlayerSignalSpy3.count(), 0 ); |
|
460 QCOMPARE( localPlayerSignalSpy4.count(), 0 ); |
|
461 QCOMPARE( localPlayerSignalSpy5.count(), 0 ); |
|
462 |
|
463 // Use local player, player preparing |
|
464 localPlayer->iState = MLcVideoPlayer::EPreparing; |
|
465 mEngine->d->StateChanged( *localPlayer ); |
|
466 QCOMPARE( localPlayerSignalSpy2.count(), 1 ); |
|
467 |
|
468 // Use local player, player buffering |
|
469 localPlayer->iState = MLcVideoPlayer::EBuffering; |
|
470 mEngine->d->StateChanged( *localPlayer ); |
|
471 QCOMPARE( localPlayerSignalSpy3.count(), 1 ); |
|
472 |
|
473 // Use local player, player playing |
|
474 localPlayer->iState = MLcVideoPlayer::EPlaying; |
|
475 mEngine->d->StateChanged( *localPlayer ); |
|
476 QCOMPARE( localPlayerSignalSpy.count(), 1 ); |
|
477 |
|
478 // Use local player, player paused |
|
479 localPlayer->iState = MLcVideoPlayer::EPaused; |
|
480 mEngine->d->StateChanged( *localPlayer ); |
|
481 QCOMPARE( localPlayerSignalSpy4.count(), 1 ); |
|
482 |
|
483 // Use local player, player unavailable |
|
484 localPlayer->iState = MLcVideoPlayer::EUnavailable; |
|
485 mEngine->d->StateChanged( *localPlayer ); |
|
486 QCOMPARE( localPlayerSignalSpy5.count(), 1 ); |
|
487 |
|
488 // Use remote player, no waiting note |
|
489 mEngine->d->StateChanged( *remotePlayer ); |
|
490 QVERIFY( mWaitingNote->isVisible() ); |
|
491 QCOMPARE( remotePlayerSignalSpy.count(), 0 ); |
|
492 QCOMPARE( remotePlayerSignalSpy2.count(), 0 ); |
|
493 QCOMPARE( remotePlayerSignalSpy3.count(), 0 ); |
|
494 QCOMPARE( remotePlayerSignalSpy4.count(), 0 ); |
|
495 QCOMPARE( remotePlayerSignalSpy5.count(), 0 ); |
|
496 |
|
497 // Use remote player, waiting note present, player not playing |
|
498 mEngine->d->mWaitingNote = mWaitingNote; |
|
499 mEngine->d->StateChanged( *remotePlayer ); |
|
500 QVERIFY( mWaitingNote->isVisible() ); |
|
501 QCOMPARE( remotePlayerSignalSpy.count(), 0 ); |
|
502 QCOMPARE( remotePlayerSignalSpy2.count(), 0 ); |
|
503 QCOMPARE( remotePlayerSignalSpy3.count(), 0 ); |
|
504 QCOMPARE( remotePlayerSignalSpy4.count(), 0 ); |
|
505 QCOMPARE( remotePlayerSignalSpy5.count(), 0 ); |
|
506 |
|
507 // Use remote player, player preparing |
|
508 remotePlayer->iState = MLcVideoPlayer::EPreparing; |
|
509 mEngine->d->StateChanged( *remotePlayer ); |
|
510 QVERIFY( mWaitingNote->isVisible() ); |
|
511 QCOMPARE( remotePlayerSignalSpy2.count(), 1 ); |
|
512 |
|
513 // Use remote player, player buffering |
|
514 remotePlayer->iState = MLcVideoPlayer::EBuffering; |
|
515 mEngine->d->StateChanged( *remotePlayer ); |
|
516 QVERIFY( mWaitingNote->isVisible() ); |
|
517 QCOMPARE( remotePlayerSignalSpy3.count(), 1 ); |
|
518 |
|
519 // Use remote player, waiting note present, player playing |
|
520 remotePlayer->iState = MLcVideoPlayer::EPlaying; |
|
521 mEngine->d->StateChanged( *remotePlayer ); |
|
522 QVERIFY( !mWaitingNote->isVisible() ); |
|
523 QCOMPARE( remotePlayerSignalSpy.count(), 1 ); |
|
524 |
|
525 // Use remote player, waiting note present, player playing |
|
526 remotePlayer->iState = MLcVideoPlayer::EUnavailable; |
|
527 mEngine->d->StateChanged( *remotePlayer ); |
|
528 QVERIFY( !mWaitingNote->isVisible() ); |
|
529 QCOMPARE( remotePlayerSignalSpy5.count(), 1 ); |
|
530 |
|
531 // Use remote player, player paused |
|
532 remotePlayer->iState = MLcVideoPlayer::EPaused; |
|
533 mEngine->d->StateChanged( *remotePlayer ); |
|
534 QVERIFY( !mWaitingNote->isVisible() ); |
|
535 QCOMPARE( remotePlayerSignalSpy4.count(), 1 ); |
|
536 |
|
537 QCOMPARE( localPlayerSignalSpy.count(), 1 ); |
|
538 QCOMPARE( localPlayerSignalSpy2.count(), 1 ); |
|
539 QCOMPARE( localPlayerSignalSpy3.count(), 1 ); |
|
540 QCOMPARE( localPlayerSignalSpy4.count(), 1 ); |
|
541 QCOMPARE( localPlayerSignalSpy5.count(), 1 ); |
|
542 |
|
543 QCOMPARE( remotePlayerSignalSpy.count(), 1 ); |
|
544 QCOMPARE( remotePlayerSignalSpy2.count(), 1 ); |
|
545 QCOMPARE( remotePlayerSignalSpy3.count(), 1 ); |
|
546 QCOMPARE( remotePlayerSignalSpy4.count(), 1 ); |
|
547 QCOMPARE( remotePlayerSignalSpy5.count(), 1 ); |
|
548 |
|
549 } |
|
550 |
|
551 void UT_LcUiEngine::testSetContentAreas() |
|
552 { |
|
553 QRectF shared; |
|
554 QRectF received; |
|
555 |
|
556 QVERIFY( LC_SESSION( mEngine )->iLocalPlayer ); |
|
557 QVERIFY( LC_SESSION( mEngine )->iRemotePlayer ); |
|
558 QVERIFY( LC_SESSION( mEngine )->iLocalPlayer->iRect.iTl.iX != 0); |
|
559 QVERIFY( LC_SESSION( mEngine )->iRemotePlayer->iRect.iTl.iX != 0); |
|
560 |
|
561 mEngine->d->setContentAreas( shared, received ); |
|
562 QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcPlayer_SetLcWindowRectL ) ); |
|
563 QVERIFY( LC_SESSION( mEngine )->iLocalPlayer->iRect.iTl.iX == 0); |
|
564 QVERIFY( LC_SESSION( mEngine )->iRemotePlayer->iRect.iTl.iX == 0); |
|
565 |
|
566 lcutStub_LcSession_reset(); |
|
567 lcutStub_LcPlayer_reset(); |
|
568 |
|
569 mEngine->d->setContentAreas( shared, received ); |
|
570 QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcPlayer_NoCall ) ); |
|
571 |
|
572 lcutStub_LcSession_reset(); |
|
573 lcutStub_LcPlayer_reset(); |
|
574 |
|
575 shared.setHeight(100); |
|
576 received.setHeight(100); |
|
577 |
|
578 mEngine->d->setContentAreas( shared, received ); |
|
579 QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcPlayer_SetLcWindowRectL ) ); |
|
580 |
|
581 lcutStub_LcSession_reset(); |
|
582 lcutStub_LcPlayer_reset(); |
|
583 |
|
584 delete LC_SESSION( mEngine )->iLocalPlayer; |
|
585 LC_SESSION( mEngine )->iLocalPlayer = 0; |
|
586 delete LC_SESSION( mEngine )->iRemotePlayer; |
|
587 LC_SESSION( mEngine )->iRemotePlayer = 0; |
|
588 |
|
589 mEngine->d->setContentAreas( shared, received ); |
|
590 QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcPlayer_NoCall ) ); |
|
591 } |
|
592 |
|
593 void UT_LcUiEngine::testSetOrientation() |
|
594 { |
|
595 bool ok( false ); |
|
596 |
|
597 //1. setting landscape |
|
598 QVERIFY( LC_SESSION( mEngine )->iLocalPlayer ); |
|
599 QVERIFY( LC_SESSION( mEngine )->iRemotePlayer ); |
|
600 |
|
601 ok = mEngine->d->setOrientation( Qt::Horizontal ); |
|
602 QVERIFY( ok ); |
|
603 QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcPlayer_SetLcWindowOrientationL ) ); |
|
604 QVERIFY( LC_SESSION( mEngine )->iLocalPlayer->iOrientation == MLcWindow::ELandscape ); |
|
605 QVERIFY( LC_SESSION( mEngine )->iRemotePlayer->iOrientation == MLcWindow::ELandscape ); |
|
606 |
|
607 //2. setting layout failed |
|
608 // Leave |
|
609 lcutStub_LcEngine_setFailure( -1 ); |
|
610 lcutStub_LcPlayer_reset(); |
|
611 ok = mEngine->d->setOrientation( Qt::Horizontal ); |
|
612 QVERIFY( !ok ); |
|
613 QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcPlayer_NoCall ) ); |
|
614 |
|
615 //3. setting layout with no players |
|
616 lcutStub_LcEngine_reset(); |
|
617 lcutStub_LcPlayer_reset(); |
|
618 delete LC_SESSION( mEngine )->iLocalPlayer; |
|
619 LC_SESSION( mEngine )->iLocalPlayer = 0; |
|
620 delete LC_SESSION( mEngine )->iRemotePlayer; |
|
621 LC_SESSION( mEngine )->iRemotePlayer = 0; |
|
622 |
|
623 ok = mEngine->d->setOrientation( Qt::Horizontal ); |
|
624 QVERIFY( ok ); |
|
625 QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcPlayer_NoCall ) ); |
|
626 } |
|
627 |
|
628 |
|
629 void UT_LcUiEngine::testToggleMute() |
|
630 { |
|
631 QSignalSpy mutedSpy(mEngine, SIGNAL(muted())); |
|
632 QSignalSpy unmutedSpy(mEngine, SIGNAL(unmuted())); |
|
633 |
|
634 |
|
635 // Leave from isMuted |
|
636 mEngine->d->toggleMute(); |
|
637 QVERIFY( mEngine->d->isMuted() ); |
|
638 lcutStub_LcEngine_setFailure( -2 ); |
|
639 QVERIFY( !mEngine->d->isMuted() ); |
|
640 |
|
641 // No leave |
|
642 lcutStub_LcEngine_reset(); |
|
643 lcutStub_LcSession_reset(); |
|
644 lcutStub_LcPlayer_reset(); |
|
645 mutedSpy.clear(); |
|
646 unmutedSpy.clear(); |
|
647 |
|
648 mEngine->d->toggleMute(); |
|
649 QVERIFY( !mEngine->d->isMuted() ); |
|
650 mutedSpy.clear(); |
|
651 unmutedSpy.clear(); |
|
652 |
|
653 mEngine->d->toggleMute(); |
|
654 QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcPlayer_MuteLcMicL ) ); |
|
655 QVERIFY( mEngine->d->isMuted() ); |
|
656 QCOMPARE(mutedSpy.count(), 1); // make sure the signal was emitted exactly one time |
|
657 lcutStub_LcSession_reset(); |
|
658 lcutStub_LcPlayer_reset(); |
|
659 mutedSpy.clear(); |
|
660 unmutedSpy.clear(); |
|
661 |
|
662 mEngine->d->toggleMute(); |
|
663 QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcPlayer_MuteLcMicL ) ); |
|
664 QVERIFY( !mEngine->d->isMuted() ); |
|
665 QCOMPARE(unmutedSpy.count(), 1); // make sure the signal was emitted exactly one time |
|
666 |
|
667 lcutStub_LcSession_reset(); |
|
668 lcutStub_LcPlayer_reset(); |
|
669 mutedSpy.clear(); |
|
670 unmutedSpy.clear(); |
|
671 |
|
672 // test async mute |
|
673 lcutStub_LcPlayer_asyncCompletion( true ); |
|
674 mEngine->d->toggleMute(); |
|
675 QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcPlayer_MuteLcMicL ) ); |
|
676 QVERIFY( mEngine->d->isMuted() ); |
|
677 QVERIFY( mEngine->d->mBlocked ); |
|
678 QVERIFY( mEngine->d->mPendingAction == "muted" ); |
|
679 |
|
680 // nothing yet signaled as completion is pending |
|
681 QCOMPARE(mutedSpy.count(), 0); |
|
682 QCOMPARE(unmutedSpy.count(), 0); |
|
683 |
|
684 |
|
685 lcutStub_LcPlayer_asyncCompletion( false ); |
|
686 } |
|
687 |
|
688 void UT_LcUiEngine::testToggleSpeaker() |
|
689 { |
|
690 QSignalSpy speakerEnabledSpy(mEngine, SIGNAL(speakerEnabled())); |
|
691 QSignalSpy speakerDisabledSpy(mEngine, SIGNAL(speakerDisabled())); |
|
692 |
|
693 QVERIFY( !mEngine->d->isSpeakerOn() ); |
|
694 |
|
695 mEngine->d->toggleSpeaker(); |
|
696 QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcPlayer_EnableLcLoudspeakerL ) ); |
|
697 QVERIFY( mEngine->d->isSpeakerOn() ); |
|
698 QCOMPARE(speakerEnabledSpy.count(), 1); |
|
699 |
|
700 |
|
701 lcutStub_LcSession_reset(); |
|
702 lcutStub_LcPlayer_reset(); |
|
703 speakerEnabledSpy.clear(); |
|
704 speakerDisabledSpy.clear(); |
|
705 |
|
706 mEngine->d->toggleSpeaker(); |
|
707 QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcPlayer_EnableLcLoudspeakerL ) ); |
|
708 QVERIFY( !mEngine->d->isSpeakerOn() ); |
|
709 QCOMPARE(speakerDisabledSpy.count(), 1); |
|
710 |
|
711 lcutStub_LcSession_reset(); |
|
712 lcutStub_LcPlayer_reset(); |
|
713 speakerEnabledSpy.clear(); |
|
714 speakerDisabledSpy.clear(); |
|
715 |
|
716 // test asynch speaker functionality. |
|
717 |
|
718 lcutStub_LcPlayer_asyncCompletion( true ); |
|
719 mEngine->d->toggleSpeaker(); |
|
720 QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcPlayer_EnableLcLoudspeakerL ) ); |
|
721 QVERIFY( mEngine->d->isSpeakerOn() ); |
|
722 QVERIFY( mEngine->d->mBlocked ); |
|
723 QVERIFY( mEngine->d->mPendingAction == "speakerEnabled" ); |
|
724 |
|
725 // nothing yet signaled as completion is pending |
|
726 QCOMPARE(speakerEnabledSpy.count(), 0); |
|
727 QCOMPARE(speakerDisabledSpy.count(), 0); |
|
728 |
|
729 lcutStub_LcPlayer_asyncCompletion( false ); |
|
730 } |
|
731 |
|
732 void UT_LcUiEngine::testToggleDisableCamera() |
|
733 { |
|
734 QSignalSpy enabledSpy(mEngine, SIGNAL(cameraEnabled())); |
|
735 QSignalSpy disabledSpy(mEngine, SIGNAL(cameraDisabled())); |
|
736 |
|
737 QVERIFY( LC_SESSION( mEngine )->iLocalPlayer ); |
|
738 LC_SESSION( mEngine )->iLocalPlayer->iPlaying = ETrue; |
|
739 LC_SESSION( mEngine )->iRemotePlayer->iState = MLcVideoPlayer::EPlaying; |
|
740 QVERIFY( LC_SESSION( mEngine )->iLocalPlayer->iPlaying ); |
|
741 |
|
742 mEngine->d->toggleDisableCamera(); |
|
743 QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcPlayer_LcPauseL ) ); |
|
744 QVERIFY( !LC_SESSION( mEngine )->iLocalPlayer->iPlaying ); |
|
745 QVERIFY( LC_SESSION( mEngine )->iLocalPlayer->iState == MLcVideoPlayer::EPaused ); |
|
746 QCOMPARE(enabledSpy.count(), 0); |
|
747 QCOMPARE(disabledSpy.count(), 1); |
|
748 |
|
749 mEngine->d->toggleDisableCamera(); |
|
750 QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcPlayer_LcPlayL ) ); |
|
751 QVERIFY( LC_SESSION( mEngine )->iLocalPlayer->iPlaying ); |
|
752 QVERIFY( LC_SESSION( mEngine )->iLocalPlayer->iState == MLcVideoPlayer::EPlaying ); |
|
753 QCOMPARE(enabledSpy.count(), 1); |
|
754 QCOMPARE(disabledSpy.count(), 1); |
|
755 } |
|
756 |
|
757 void UT_LcUiEngine::testToggleCamera() |
|
758 { |
|
759 // Leave |
|
760 lcutStub_LcEngine_setFailure( -1 ); |
|
761 mEngine->d->toggleCamera(); |
|
762 QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcPlayer_NoCall ) ); |
|
763 |
|
764 // No leave |
|
765 lcutStub_LcEngine_reset(); |
|
766 mEngine->d->toggleCamera(); |
|
767 QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcPlayer_ToggleLcCameraL ) ); |
|
768 } |
|
769 |
|
770 void UT_LcUiEngine::testStartReceiving() |
|
771 { |
|
772 // mAcceptQuery not set, mWaitingNote not set |
|
773 mAcceptQuery->show(); |
|
774 mWaitingNote->hide(); |
|
775 mEngine->d->startReceiving(); |
|
776 QVERIFY( mAcceptQuery->isVisible() ); |
|
777 QVERIFY( !mWaitingNote->isVisible() ); |
|
778 QVERIFY( lcutStub_LcSession_expectCall( lcutStub_LcSession_establishSession ) ); |
|
779 |
|
780 // mAcceptQuery set, mWaitingNote not set |
|
781 lcutStub_LcSession_reset(); |
|
782 mEngine->d->mAcceptQuery = mAcceptQuery; |
|
783 mEngine->d->startReceiving(); |
|
784 QVERIFY( !mAcceptQuery->isVisible() ); |
|
785 QVERIFY( !mWaitingNote->isVisible() ); |
|
786 QVERIFY( lcutStub_LcSession_expectCall( lcutStub_LcSession_establishSession ) ); |
|
787 |
|
788 // mWaitingNote set, but the engine does not support the feature |
|
789 lcutStub_LcSession_reset(); |
|
790 mEngine->d->mWaitingNote = mWaitingNote; |
|
791 mEngine->d->startReceiving(); |
|
792 QVERIFY( !mAcceptQuery->isVisible() ); |
|
793 QVERIFY( !mWaitingNote->isVisible() ); |
|
794 QVERIFY( lcutStub_LcSession_expectCall( lcutStub_LcSession_establishSession ) ); |
|
795 |
|
796 // mWaitingNote set and the engine supports the feature |
|
797 lcutStub_LcSession_reset(); |
|
798 lcutStub_LcEngine_setLcFeatureSupported( true ); |
|
799 mEngine->d->startReceiving(); |
|
800 QVERIFY( !mAcceptQuery->isVisible() ); |
|
801 QVERIFY( mWaitingNote->isVisible() ); |
|
802 QVERIFY( lcutStub_LcSession_expectCall( lcutStub_LcSession_establishSession ) ); |
|
803 } |
|
804 |
|
805 void UT_LcUiEngine::testStartPlayback() |
|
806 { |
|
807 mEngine->d->startPlayback(); |
|
808 QVERIFY( lcutStub_LcSession_expectCall( lcutStub_LcSession_NoCall ) ); |
|
809 QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcPlayer_EnableLcWindowL,0 ) ); |
|
810 QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcPlayer_EnableLcWindowL,1 ) ); |
|
811 |
|
812 lcutStub_LcSession_reset(); |
|
813 lcutStub_LcPlayer_reset(); |
|
814 |
|
815 delete LC_SESSION( mEngine )->iLocalPlayer; |
|
816 LC_SESSION( mEngine )->iLocalPlayer = 0; |
|
817 mEngine->d->startPlayback(); |
|
818 QVERIFY( lcutStub_LcSession_expectCall( lcutStub_LcSession_NoCall ) ); |
|
819 QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcPlayer_EnableLcWindowL,0 ) ); |
|
820 QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcPlayer_NoCall,1 ) ); |
|
821 |
|
822 lcutStub_LcSession_reset(); |
|
823 lcutStub_LcPlayer_reset(); |
|
824 |
|
825 delete LC_SESSION( mEngine )->iRemotePlayer; |
|
826 LC_SESSION( mEngine )->iRemotePlayer = 0; |
|
827 |
|
828 mEngine->d->startPlayback(); |
|
829 QVERIFY( lcutStub_LcSession_expectCall( lcutStub_LcSession_NoCall ) ); |
|
830 QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcPlayer_NoCall,0 ) ); |
|
831 QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcPlayer_NoCall,1 ) ); |
|
832 } |
|
833 |
|
834 void UT_LcUiEngine::testStop() |
|
835 { |
|
836 // Ensure that in MLcSession::EOpen state, "stopped" signal won't be emited |
|
837 // Check also that session duration timer is stopped |
|
838 LC_SESSION( mEngine )->iState = MLcSession::EOpen; |
|
839 mEngine->d->startSessionDurationTimer(); |
|
840 QVERIFY( mEngine->d->mSessionDurationTimerId != 0 ); |
|
841 QSignalSpy spy(mEngine, SIGNAL(stopped())); |
|
842 mEngine->d->mActivityManager->enableActivitySimulation(true); |
|
843 mEngine->d->stop(); |
|
844 QVERIFY( !mEngine->d->mActivityManager->isActivitySimulationEnabled() ); |
|
845 QVERIFY( lcutStub_LcSession_expectCall( lcutStub_LcSession_terminateSession ) ); |
|
846 QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcPlayer_NoCall ) ); |
|
847 QCOMPARE( spy.count(), 0 ); |
|
848 QVERIFY( mEngine->d->mSessionDurationTimerId == 0 ); |
|
849 |
|
850 // Ensure that MLcSession::EClosed, will cause emition of "stopped" signal |
|
851 lcutStub_LcSession_reset(); |
|
852 lcutStub_LcPlayer_reset(); |
|
853 LC_SESSION( mEngine )->iState = MLcSession::EClosed; |
|
854 mEngine->d->stop(); |
|
855 QVERIFY( lcutStub_LcSession_expectCall( lcutStub_LcSession_terminateSession ) ); |
|
856 QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcPlayer_NoCall ) ); |
|
857 QCOMPARE( spy.count(), 1 ); |
|
858 } |
|
859 |
|
860 void UT_LcUiEngine::testSetViewLayout() |
|
861 { |
|
862 QVERIFY( LC_SESSION( mEngine )->iLocalPlayer ); |
|
863 QVERIFY( LC_SESSION( mEngine )->iRemotePlayer ); |
|
864 QVERIFY( !LC_SESSION( mEngine )->iLocalPlayer->iPlaying ); |
|
865 QVERIFY( !LC_SESSION( mEngine )->iRemotePlayer->iPlaying ); |
|
866 LC_SESSION( mEngine )->iRemotePlayer->iState = MLcVideoPlayer::EPaused; |
|
867 QVERIFY( !mEngine->d->usingVideoTelephoneEngine() ); |
|
868 |
|
869 mEngine->d->setViewLayout(); |
|
870 QVERIFY( mEngine->d->viewLayout() == Lc_IdleViewLayout ); |
|
871 |
|
872 LC_SESSION( mEngine )->iLocalPlayer->iPlaying = ETrue; |
|
873 |
|
874 mEngine->d->setViewLayout(); |
|
875 QVERIFY( mEngine->d->viewLayout() == Lc_SharedViewLayout ); |
|
876 |
|
877 LC_SESSION( mEngine )->iLocalPlayer->iPlaying = EFalse; |
|
878 LC_SESSION( mEngine )->iRemotePlayer->iState = MLcVideoPlayer::EPlaying; |
|
879 |
|
880 mEngine->d->setViewLayout(); |
|
881 QVERIFY( mEngine->d->viewLayout() == Lc_ReceivedViewLayout ); |
|
882 |
|
883 LC_SESSION( mEngine )->iLocalPlayer->iPlaying = ETrue; |
|
884 LC_SESSION( mEngine )->iRemotePlayer->iState = MLcVideoPlayer::EPlaying; |
|
885 |
|
886 mEngine->d->setViewLayout(); |
|
887 QVERIFY( mEngine->d->viewLayout() == Lc_TwowayViewLayout ); |
|
888 |
|
889 delete LC_SESSION( mEngine )->iLocalPlayer; |
|
890 LC_SESSION( mEngine )->iLocalPlayer = 0; |
|
891 |
|
892 mEngine->d->setViewLayout(); |
|
893 QVERIFY( mEngine->d->viewLayout() == Lc_ReceivedOnlyViewLayout ); |
|
894 |
|
895 delete LC_SESSION( mEngine )->iRemotePlayer; |
|
896 LC_SESSION( mEngine )->iRemotePlayer = 0; |
|
897 |
|
898 mEngine->d->setViewLayout(); |
|
899 QVERIFY( mEngine->d->viewLayout() == Lc_IdleViewLayout ); |
|
900 |
|
901 mEngine->d->mEngineName = lcutVideotelephonyApp; |
|
902 QVERIFY( mEngine->d->usingVideoTelephoneEngine() ); |
|
903 |
|
904 mEngine->d->setViewLayout(); |
|
905 QVERIFY( mEngine->d->viewLayout() == Lc_AllInOneViewLayout ); |
|
906 } |
|
907 |
|
908 void UT_LcUiEngine::testHideNotes() |
|
909 { |
|
910 // Notes not set |
|
911 mEngine->d->hideNotes( true ); |
|
912 QVERIFY( lcutStub_LcSession_expectCall( lcutStub_LcSession_NoCall ) ); |
|
913 QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcPlayer_NoCall ) ); |
|
914 QVERIFY( mInvitingNote->isVisible() ); |
|
915 QVERIFY( mWaitingNote->isVisible() ); |
|
916 QVERIFY( mAcceptQuery->isVisible() ); |
|
917 QVERIFY( mRecipientQuery->isVisible() ); |
|
918 |
|
919 // Notes set, hide all |
|
920 mEngine->d->setUiComponents( mInvitingNote, mWaitingNote, |
|
921 mAcceptQuery, mRecipientQuery,mShareOwnVideoQuery ); |
|
922 mEngine->d->hideNotes( true ); |
|
923 QVERIFY( lcutStub_LcSession_expectCall( lcutStub_LcSession_NoCall ) ); |
|
924 QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcPlayer_NoCall ) ); |
|
925 QVERIFY( !mInvitingNote->isVisible() ); |
|
926 QVERIFY( !mWaitingNote->isVisible() ); |
|
927 QVERIFY( !mAcceptQuery->isVisible() ); |
|
928 QVERIFY( !mRecipientQuery->isVisible() ); |
|
929 |
|
930 // Notes not set, do not hide waiting note |
|
931 mInvitingNote->show(); |
|
932 mWaitingNote->show(); |
|
933 mAcceptQuery->show(); |
|
934 mRecipientQuery->show(); |
|
935 mEngine->d->hideNotes( false ); |
|
936 QVERIFY( lcutStub_LcSession_expectCall( lcutStub_LcSession_NoCall ) ); |
|
937 QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcPlayer_NoCall ) ); |
|
938 QVERIFY( !mInvitingNote->isVisible() ); |
|
939 QVERIFY( mWaitingNote->isVisible() ); |
|
940 QVERIFY( !mAcceptQuery->isVisible() ); |
|
941 QVERIFY( !mRecipientQuery->isVisible() ); |
|
942 } |
|
943 |
|
944 void UT_LcUiEngine::testZoom() |
|
945 { |
|
946 LcControlValues zoomData; |
|
947 |
|
948 // Leave |
|
949 lcutStub_LcEngine_setFailure( -1 ); |
|
950 mEngine->d->zoom( 1 ); |
|
951 QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcPlayer_NoCall ) ); |
|
952 QCOMPARE( mEngine->d->zoomValues( zoomData ), -1 ); |
|
953 QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcPlayer_NoCall ) ); |
|
954 |
|
955 // No leave |
|
956 lcutStub_LcEngine_reset(); |
|
957 lcutStub_LcPlayer_reset(); |
|
958 QCOMPARE( mEngine->d->zoomValues( zoomData ), 0 ); |
|
959 mEngine->d->zoom( 2 ); |
|
960 mEngine->d->zoom( 1 ); |
|
961 mEngine->d->zoom( 3 ); |
|
962 |
|
963 QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcPlayer_SetLcZoomValueL, 0 ) ); |
|
964 QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcPlayer_SetLcZoomValueL, 1 ) ); |
|
965 QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcPlayer_SetLcZoomValueL, 2 ) ); |
|
966 QVERIFY( lcutStub_LcPlayer_expectCall( lcutStub_LcSession_NoCall, 3 ) ); |
|
967 } |
|
968 |
|
969 void UT_LcUiEngine::testBlockUi() |
|
970 { |
|
971 QSignalSpy blockedSpy(mEngine, SIGNAL(blocked())); |
|
972 QSignalSpy unblockedSpy(mEngine, SIGNAL(unblocked())); |
|
973 QSignalSpy mutedSpy(mEngine, SIGNAL(muted())); |
|
974 |
|
975 mEngine->d->BlockUi( ETrue ); |
|
976 |
|
977 QCOMPARE(blockedSpy.count(), 1); |
|
978 QCOMPARE(unblockedSpy.count(), 0); |
|
979 QCOMPARE(mutedSpy.count(), 0); |
|
980 |
|
981 // no pending action once unblocked |
|
982 blockedSpy.clear(); |
|
983 |
|
984 mEngine->d->BlockUi( EFalse ); |
|
985 QCOMPARE(blockedSpy.count(), 0); |
|
986 QCOMPARE(unblockedSpy.count(), 1); |
|
987 QCOMPARE(mutedSpy.count(), 0); |
|
988 |
|
989 |
|
990 // pending action once unblocked |
|
991 unblockedSpy.clear(); |
|
992 mEngine->d->setPendingAction( "muted" ); |
|
993 mEngine->d->BlockUi( EFalse ); |
|
994 QCOMPARE(blockedSpy.count(), 0); |
|
995 QCOMPARE(unblockedSpy.count(), 1); |
|
996 QCOMPARE(mutedSpy.count(), 1); |
|
997 QVERIFY( mEngine->d->mPendingAction.isEmpty() ); |
|
998 } |
|
999 |
|
1000 void UT_LcUiEngine::testCloseTimer() |
|
1001 { |
|
1002 // Try to cancel without timer |
|
1003 mEngine->d->cancelCloseTimer(); |
|
1004 QVERIFY( !mEngine->d->mCloseTimer ); |
|
1005 |
|
1006 // Try to cancel without timer being active |
|
1007 mEngine->d->startCloseTimer(); |
|
1008 QVERIFY( mEngine->d->mCloseTimer ); |
|
1009 QVERIFY( mEngine->d->mCloseTimer->isActive() ); |
|
1010 mEngine->d->mCloseTimer->stop(); |
|
1011 QVERIFY( !mEngine->d->mCloseTimer->isActive() ); |
|
1012 mEngine->d->cancelCloseTimer(); |
|
1013 QVERIFY( mEngine->d->mCloseTimer ); |
|
1014 QVERIFY( !mEngine->d->mCloseTimer->isActive() ); |
|
1015 |
|
1016 // Cancel an active timer |
|
1017 mEngine->d->startCloseTimer(); |
|
1018 QVERIFY( mEngine->d->mCloseTimer ); |
|
1019 QVERIFY( mEngine->d->mCloseTimer->isActive() ); |
|
1020 mEngine->d->cancelCloseTimer(); |
|
1021 QVERIFY( mEngine->d->mCloseTimer ); |
|
1022 QVERIFY( !mEngine->d->mCloseTimer->isActive() ); |
|
1023 } |
|
1024 |
|
1025 |
|
1026 void UT_LcUiEngine::testfullScreenMode() |
|
1027 { |
|
1028 QVERIFY( !mEngine->d->fullScreenMode() ); |
|
1029 } |
|
1030 |
|
1031 |
|
1032 void UT_LcUiEngine::testsetFullScreenMode() |
|
1033 { |
|
1034 mEngine->d->setFullScreenMode(true); |
|
1035 QVERIFY( mEngine->d->fullScreenMode() ); |
|
1036 } |
|
1037 |
|
1038 void UT_LcUiEngine::testTimerEvent() |
|
1039 { |
|
1040 mEngine->d->startSessionDurationTimer(); |
|
1041 QSignalSpy spy(mEngine, SIGNAL(sessionDurationChanged(const QString &))); |
|
1042 |
|
1043 QTimerEvent wrongTimerEvent(9999); |
|
1044 mEngine->d->timerEvent(&wrongTimerEvent); |
|
1045 QVERIFY( spy.count() == 0 ); |
|
1046 |
|
1047 QTimerEvent correctTimerEvent(mEngine->d->mSessionDurationTimerId); |
|
1048 mEngine->d->timerEvent(&correctTimerEvent); |
|
1049 QVERIFY( spy.count() == 1 ); |
|
1050 QVERIFY( spy.at(0).count() == 1 ); // one arg which is duration as string |
|
1051 QTime currDuration = QTime::fromString(spy.at(0).at(0).toString()); |
|
1052 QVERIFY( currDuration.isValid() ); |
|
1053 } |
|
1054 |
|
1055 void UT_LcUiEngine::testFillRemoteInfo() |
|
1056 { |
|
1057 QSignalSpy recipientSpy(mEngine, SIGNAL(recipientChanged(const QString &))); |
|
1058 QSignalSpy numberSpy(mEngine, SIGNAL(phoneNumberChanged(const QString &))); |
|
1059 |
|
1060 // test filling without signal emitting |
|
1061 |
|
1062 // number and name changed |
|
1063 mEngine->d->mRecipient = ""; |
|
1064 mEngine->d->mPhoneNumber = ""; |
|
1065 mEngine->d->fillRemoteInfo( false ); |
|
1066 QVERIFY( mEngine->d->mRecipient.length() > 0 ); |
|
1067 QVERIFY( mEngine->d->mPhoneNumber.length() > 0 ); |
|
1068 QVERIFY( recipientSpy.count() == 0 ); |
|
1069 QVERIFY( numberSpy.count() == 0 ); |
|
1070 |
|
1071 // nothing changed |
|
1072 QString prevRecipient = mEngine->d->mRecipient; |
|
1073 QString prevNumber = mEngine->d->mPhoneNumber; |
|
1074 mEngine->d->fillRemoteInfo( false ); |
|
1075 QVERIFY( mEngine->d->mRecipient == prevRecipient ); |
|
1076 QVERIFY( mEngine->d->mPhoneNumber == prevNumber ); |
|
1077 QVERIFY( recipientSpy.count() == 0 ); |
|
1078 QVERIFY( numberSpy.count() == 0 ); |
|
1079 |
|
1080 // test filling with signal emitting |
|
1081 |
|
1082 // number and name changed |
|
1083 mEngine->d->mRecipient = ""; |
|
1084 mEngine->d->mPhoneNumber = ""; |
|
1085 mEngine->d->fillRemoteInfo( true ); |
|
1086 QVERIFY( mEngine->d->mRecipient == prevRecipient ); |
|
1087 QVERIFY( mEngine->d->mPhoneNumber == prevNumber ); |
|
1088 QVERIFY( recipientSpy.count() == 1 ); |
|
1089 QVERIFY( numberSpy.count() == 1 ); |
|
1090 |
|
1091 // state is opened and name not found and no number, unknown name is used |
|
1092 LC_SESSION( mEngine )->iState = MLcSession::EOpen; |
|
1093 delete LC_SESSION( mEngine )->iRemoteDisplayName; |
|
1094 LC_SESSION( mEngine )->iRemoteDisplayName = NULL; |
|
1095 LC_SESSION( mEngine )->iRemoteDisplayName = KNullDesC().AllocL(); |
|
1096 delete LC_SESSION( mEngine )->iRemoteDetails; |
|
1097 LC_SESSION( mEngine )->iRemoteDetails = NULL; |
|
1098 LC_SESSION( mEngine )->iRemoteDetails = KNullDesC().AllocL(); |
|
1099 mEngine->d->mPhoneNumber = ""; |
|
1100 mEngine->d->fillRemoteInfo( true ); |
|
1101 QVERIFY( mEngine->d->mRecipient == hbTrId("txt_vt_custom_unknown_number") ); |
|
1102 QVERIFY( mEngine->d->mPhoneNumber.isEmpty() ); |
|
1103 QVERIFY( recipientSpy.count() == 2 ); |
|
1104 QVERIFY( numberSpy.count() == 1 ); |
|
1105 |
|
1106 // name not found but number exists, number is used at opened state as recipient |
|
1107 mEngine->d->mRecipient = ""; |
|
1108 mEngine->d->mPhoneNumber = ""; |
|
1109 delete LC_SESSION( mEngine )->iRemoteDetails; |
|
1110 LC_SESSION( mEngine )->iRemoteDetails = NULL; |
|
1111 LC_SESSION( mEngine )->iRemoteDetails = _L("123445").AllocL(); |
|
1112 mEngine->d->fillRemoteInfo( true ); |
|
1113 QVERIFY( mEngine->d->mRecipient == "123445" ); |
|
1114 QVERIFY( mEngine->d->mPhoneNumber == "123445" ); |
|
1115 QVERIFY( recipientSpy.count() == 3 ); |
|
1116 QVERIFY( numberSpy.count() == 2 ); |
|
1117 |
|
1118 } |
|
1119 |
|
1120 void UT_LcUiEngine::testUpdateSession() |
|
1121 { |
|
1122 mEngine->d->updateSession(); |
|
1123 QVERIFY( lcutStub_LcSession_expectCall( lcutStub_LcSession_updateSession ) ); |
|
1124 } |
|
1125 |
|
1126 void UT_LcUiEngine::testIsLocalPlayerPlaying() |
|
1127 { |
|
1128 // Not playing |
|
1129 QVERIFY( !mEngine->d->isLocalPlayerPlaying() ); |
|
1130 |
|
1131 // Playing |
|
1132 LC_SESSION( mEngine )->iLocalPlayer->LcPlayL(); |
|
1133 QVERIFY( mEngine->d->isLocalPlayerPlaying() ); |
|
1134 } |
|
1135 |
|
1136 void UT_LcUiEngine::testIsRemotePlayerPlaying() |
|
1137 { |
|
1138 // Not playing |
|
1139 QVERIFY( !mEngine->d->isRemotePlayerPlaying() ); |
|
1140 |
|
1141 // Playing |
|
1142 LC_SESSION( mEngine )->iRemotePlayer->LcPlayL(); |
|
1143 QVERIFY( mEngine->d->isRemotePlayerPlaying() ); |
|
1144 } |
|
1145 |
|
1146 void UT_LcUiEngine::testMinimized() |
|
1147 { |
|
1148 mEngine->minimize(); |
|
1149 QVERIFY( mEngine->isMinimized() ); |
|
1150 mEngine->minimize(); // Doing nothing |
|
1151 QVERIFY( mEngine->isMinimized() ); |
|
1152 } |
|
1153 |
|
1154 void UT_LcUiEngine::testMaximized() |
|
1155 { |
|
1156 mEngine->maximize(); |
|
1157 QVERIFY(mEngine->isMaximized() ); |
|
1158 mEngine->maximize(); // Doing nothing |
|
1159 QVERIFY(mEngine->isMaximized() ); |
|
1160 } |
|
1161 |
|
1162 void UT_LcUiEngine::testIsMinimized() |
|
1163 { |
|
1164 mEngine->minimize(); |
|
1165 QVERIFY( mEngine->isMinimized() ); |
|
1166 } |
|
1167 |
|
1168 void UT_LcUiEngine::testHandleForegroundStatus() |
|
1169 { |
|
1170 QtHighwayStubHelper::reset(); |
|
1171 |
|
1172 // First time to foreground, engine is not set to foreground until viewReady signal |
|
1173 HbView currView; |
|
1174 mEngine->d->setCurrentView(&currView); |
|
1175 QVERIFY( mEngine->d->mFirstForegroundSwitch ); |
|
1176 QVERIFY( !mEngine->d->mActivityManager->isActivitySimulationEnabled() ); |
|
1177 |
|
1178 mEngine->d->HandleForegroundStatus(ETrue); |
|
1179 QVERIFY( mEngine->d->mActivityManager->isActivitySimulationEnabled() ); |
|
1180 QVERIFY( !mEngine->d->session().IsBackgroundStartup() ); // Stub returns fg status in this |
|
1181 QVERIFY( !QtHighwayStubHelper::isAtBg() ); |
|
1182 QVERIFY( !mEngine->d->mFirstForegroundSwitch ); |
|
1183 |
|
1184 //Simulate viewReady signal happens, funciton will be called again. |
|
1185 mEngine->d->HandleForegroundStatus(ETrue); |
|
1186 QVERIFY( mEngine->d->session().IsBackgroundStartup() ); // Stub returns fg status in this |
|
1187 QVERIFY( !mEngine->d->mFirstForegroundSwitch ); |
|
1188 |
|
1189 // Bg switch |
|
1190 QtHighwayStubHelper::reset(); |
|
1191 QVERIFY( mEngine->d->mActivityManager->isActivitySimulationEnabled() ); |
|
1192 mEngine->d->HandleForegroundStatus(EFalse); |
|
1193 QVERIFY( !mEngine->d->mActivityManager->isActivitySimulationEnabled() ); |
|
1194 QVERIFY( QtHighwayStubHelper::isAtBg() ); |
|
1195 QVERIFY( !mEngine->d->session().IsBackgroundStartup() ); // Stub returns fg status in this |
|
1196 |
|
1197 } |
|
1198 |
|
1199 |
|
1200 void UT_LcUiEngine::testSendDialTone() |
|
1201 { |
|
1202 //Dumy test: Ensure Conversion does not cause any problem. |
|
1203 QVERIFY( mEngine->d->SendDialTone('3') ); |
|
1204 } |
|
1205 |
|
1206 |
|
1207 void UT_LcUiEngine::testShareVideoIsAllowedShownAutomatically() |
|
1208 { |
|
1209 lcutStub_LcEngine_setLcFeatureSupported( false ); |
|
1210 mShareOwnVideoQuery->hide(); |
|
1211 mEngine->d->setUiComponents(mInvitingNote,mWaitingNote,mAcceptQuery,mRecipientQuery,mShareOwnVideoQuery); |
|
1212 mEngine->d->showSendVideoQueryWhenNecessary(); |
|
1213 QVERIFY(mEngine->d->mShareOwnVideoQuery && !mEngine->d->mShareOwnVideoQuery->isVisible()); |
|
1214 } |
|
1215 |
|
1216 |
|
1217 void UT_LcUiEngine::testShareVideoIsNotAllowedShown() |
|
1218 { |
|
1219 lcutStub_LcEngine_setLcFeatureSupported( false ); |
|
1220 mShareOwnVideoQuery->hide(); |
|
1221 mEngine->d->setUiComponents(mInvitingNote,mWaitingNote,mAcceptQuery,mRecipientQuery,mShareOwnVideoQuery); |
|
1222 mEngine->d->showSendVideoQueryWhenNecessary(); |
|
1223 QVERIFY(mEngine->d->mShareOwnVideoQuery && !mEngine->d->mShareOwnVideoQuery->isVisible()); |
|
1224 } |
|
1225 |
|
1226 |
|
1227 void UT_LcUiEngine::testShareVideoPermissionAskedAlways() |
|
1228 { |
|
1229 lcutStub_LcEngine_setLcFeatureSupported( true ); |
|
1230 mShareOwnVideoQuery->hide(); |
|
1231 mEngine->d->setUiComponents(mInvitingNote,mWaitingNote,mAcceptQuery,mRecipientQuery,mShareOwnVideoQuery); |
|
1232 mEngine->d->showSendVideoQueryWhenNecessary(); |
|
1233 QVERIFY(mEngine->d->mShareOwnVideoQuery && mEngine->d->mShareOwnVideoQuery->isVisible()); |
|
1234 } |
|
1235 |
|
1236 |
|
1237 void UT_LcUiEngine::testVolumeLevelChanged() |
|
1238 { |
|
1239 // Subscribe to the events. |
|
1240 mEngine->d->subscribeVolumeEvents(); |
|
1241 |
|
1242 QSignalSpy spy(mEngine, SIGNAL(volumeChanged(int))); |
|
1243 QCOMPARE( spy.count(), 0 ); |
|
1244 |
|
1245 |
|
1246 //Test1: Known Key Event handled |
|
1247 QVariant value; |
|
1248 value.setValue(5); |
|
1249 |
|
1250 XQSettingsKey validKey1(XQSettingsKey::TargetCentralRepository, |
|
1251 KCRUidInCallVolume.iUid, KTelIncallEarVolume); |
|
1252 mEngine->d->volumeLevelChanged(validKey1, value); |
|
1253 QCOMPARE( spy.count(), 1 ); |
|
1254 spy.clear(); |
|
1255 |
|
1256 |
|
1257 //Test2: Known Key Event-2 handled |
|
1258 XQSettingsKey validKey2(XQSettingsKey::TargetCentralRepository, |
|
1259 KCRUidInCallVolume.iUid,KTelIncallLoudspeakerVolume); |
|
1260 mEngine->d->volumeLevelChanged(validKey2, value); |
|
1261 QCOMPARE( spy.count(), 1 ); |
|
1262 spy.clear(); |
|
1263 |
|
1264 //Test3: Unknow Key Event Ignored. |
|
1265 XQSettingsKey unKnownKey(XQSettingsKey::TargetCentralRepository, |
|
1266 787,899); |
|
1267 mEngine->d->volumeLevelChanged(unKnownKey, value); |
|
1268 QCOMPARE( spy.count(), 0 ); |
|
1269 |
|
1270 // Un-Subscribe Events. |
|
1271 mEngine->d->unSubscribeVolumeEvents(); |
|
1272 } |
|
1273 |
|
1274 |
|
1275 |
|
1276 // End of file |
|