|
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 |
|
18 #include "ut_lcuicomponentrepository.h" |
|
19 #include "ut_lcuidefs.h" |
|
20 #include "lcuicomponentrepository.h" |
|
21 #include "lcuidefs.h" |
|
22 #include "lcview.h" |
|
23 #include "lcuiengine.h" |
|
24 #include <QtTest/QtTest> |
|
25 #include <QObjectList> |
|
26 #include <hbmainwindow.h> |
|
27 #include <QAction> |
|
28 #include <QString> |
|
29 #include <hbmenu.h> |
|
30 #include <hbtoolbar.h> |
|
31 #include <hbdialog.h> |
|
32 #include <hbaction.h> |
|
33 #include <hbinstance.h> |
|
34 #include <hbzoomsliderpopup.h> |
|
35 #include <hbprogressdialog.h> |
|
36 |
|
37 #define UT_SET_ORIENTATION(orient) \ |
|
38 HbInstance::instance()->allMainWindows().at(0)->setOrientation(orient); |
|
39 |
|
40 void UT_LcUiComponentRepository::initTestCase() |
|
41 { |
|
42 } |
|
43 |
|
44 void UT_LcUiComponentRepository::cleanupTestCase() |
|
45 { |
|
46 } |
|
47 |
|
48 |
|
49 void UT_LcUiComponentRepository::init() |
|
50 { |
|
51 mEngine = new LcUiEngine( lcEngineName, lcDisplayName ); |
|
52 mRepository = new LcUiComponentRepository( *mEngine ); |
|
53 } |
|
54 |
|
55 void UT_LcUiComponentRepository::cleanup() |
|
56 { |
|
57 delete mRepository; |
|
58 delete mEngine; |
|
59 } |
|
60 |
|
61 void UT_LcUiComponentRepository::testConstructor() |
|
62 { |
|
63 QVERIFY( mRepository ); |
|
64 QVERIFY( !mRepository->mIdleView ); |
|
65 QVERIFY( !mRepository->mReceiveView ); |
|
66 QVERIFY( !mRepository->mReceiveOnlyView ); |
|
67 QVERIFY( !mRepository->mTwowayView ); |
|
68 QVERIFY( !mRepository->mSendView ); |
|
69 QVERIFY( !mRepository->mAllInOneView ); |
|
70 QVERIFY( !mRepository->mAcceptQuery ); |
|
71 QVERIFY( !mRepository->mInvitingNote ); |
|
72 QVERIFY( !mRepository->mWaitingNote ); |
|
73 QVERIFY( !mRepository->mRecipientQuery ); |
|
74 QVERIFY( !mRepository->mZoomSlider ); |
|
75 |
|
76 } |
|
77 |
|
78 void UT_LcUiComponentRepository::testIdleView() |
|
79 { |
|
80 // View not yet loaded |
|
81 // Portrait layout |
|
82 UT_SET_ORIENTATION( Qt::Vertical ); |
|
83 QVERIFY( !mRepository->mIdleView ); |
|
84 LcView* view = mRepository->idleView(); |
|
85 QVERIFY( mRepository->mIdleView ); |
|
86 QCOMPARE( view->objectName(), QString( lcViewIdleId ) ); |
|
87 |
|
88 // View loaded |
|
89 LcView* view2 = mRepository->idleView(); |
|
90 QVERIFY( view == view2 ); |
|
91 } |
|
92 |
|
93 void UT_LcUiComponentRepository::testReceiveView() |
|
94 { |
|
95 // View not yet loaded |
|
96 // Landscape layout |
|
97 UT_SET_ORIENTATION( Qt::Horizontal ); |
|
98 QVERIFY( !mRepository->mReceiveView ); |
|
99 LcView* view = mRepository->receiveView(); |
|
100 QVERIFY( mRepository->mReceiveView ); |
|
101 QCOMPARE( view->objectName(), QString( lcViewReceiveId ) ); |
|
102 |
|
103 // View loaded |
|
104 LcView* view2 = mRepository->receiveView(); |
|
105 QVERIFY( view == view2 ); |
|
106 } |
|
107 |
|
108 |
|
109 void UT_LcUiComponentRepository::testReceiveOnlyView() |
|
110 { |
|
111 // View not yet loaded |
|
112 QVERIFY( !mRepository->mReceiveOnlyView ); |
|
113 LcView* view = mRepository->receiveOnlyView(); |
|
114 QVERIFY( mRepository->mReceiveOnlyView ); |
|
115 QCOMPARE( view->objectName(), QString( lcViewReceiveOnlyId ) ); |
|
116 |
|
117 // View loaded |
|
118 LcView* view2 = mRepository->receiveOnlyView(); |
|
119 QVERIFY( view == view2 ); |
|
120 } |
|
121 |
|
122 |
|
123 void UT_LcUiComponentRepository::testTwowayView() |
|
124 { |
|
125 // View not yet loaded |
|
126 QVERIFY( !mRepository->mTwowayView ); |
|
127 LcView* view = mRepository->twowayView(); |
|
128 QVERIFY( mRepository->mTwowayView ); |
|
129 QCOMPARE( view->objectName(), QString( lcViewTwowayId ) ); |
|
130 |
|
131 // View loaded |
|
132 LcView* view2 = mRepository->twowayView(); |
|
133 QVERIFY( view == view2 ); |
|
134 } |
|
135 |
|
136 void UT_LcUiComponentRepository::testSendView() |
|
137 { |
|
138 // View not yet loaded |
|
139 QVERIFY( !mRepository->mSendView ); |
|
140 LcView* view = mRepository->sendView(); |
|
141 QVERIFY( mRepository->mSendView ); |
|
142 QCOMPARE( view->objectName(), QString( lcViewSendId ) ); |
|
143 |
|
144 // View loaded |
|
145 LcView* view2 = mRepository->sendView(); |
|
146 QVERIFY( view == view2 ); |
|
147 } |
|
148 |
|
149 void UT_LcUiComponentRepository::testAllInOneView() |
|
150 { |
|
151 // View not yet loaded |
|
152 UT_SET_ORIENTATION( Qt::Vertical ); |
|
153 QVERIFY( !mRepository->mAllInOneView ); |
|
154 LcView* view = mRepository->allInOneView(); |
|
155 QVERIFY( mRepository->mAllInOneView ); |
|
156 QCOMPARE( view->objectName(), QString( lcViewAllInOneId ) ); |
|
157 QCOMPARE( mRepository->mLayoutSection, QString( lcLayoutPortraitDefaultId ) ); |
|
158 // View loaded |
|
159 LcView* view2 = mRepository->allInOneView(); |
|
160 QVERIFY( view == view2 ); |
|
161 |
|
162 // Try fresh loading in landscape orientation |
|
163 UT_SET_ORIENTATION( Qt::Horizontal ); |
|
164 mRepository->mAllInOneView = 0; |
|
165 view = mRepository->allInOneView(); |
|
166 QVERIFY( mRepository->mAllInOneView ); |
|
167 QCOMPARE( view->objectName(), QString( lcViewAllInOneId ) ); |
|
168 QCOMPARE( mRepository->mLayoutSection, QString( lcLayoutLandscapeDefaultId ) ); |
|
169 } |
|
170 |
|
171 void UT_LcUiComponentRepository::testAcceptQuery() |
|
172 { |
|
173 // Query created and returned |
|
174 QVERIFY( !mRepository->mAcceptQuery ); |
|
175 HbDialog* query = mRepository->acceptQuery(); |
|
176 QVERIFY( query ); |
|
177 QCOMPARE( query, mRepository->mAcceptQuery ); |
|
178 QVERIFY( !query->isVisible() ); |
|
179 |
|
180 // Existing query returned |
|
181 HbDialog* query2 = mRepository->acceptQuery(); |
|
182 QVERIFY( query2 ); |
|
183 QVERIFY( query2 == query ); |
|
184 } |
|
185 |
|
186 void UT_LcUiComponentRepository::testInvitingNote() |
|
187 { |
|
188 // Note created and returned |
|
189 QVERIFY( !mRepository->mInvitingNote ); |
|
190 HbDialog* note = mRepository->invitingNote(); |
|
191 QVERIFY( note ); |
|
192 QVERIFY( note == mRepository->mInvitingNote ); |
|
193 QVERIFY( !note->isVisible() ); |
|
194 |
|
195 // Existing note returned |
|
196 HbDialog* note2 = mRepository->invitingNote(); |
|
197 QVERIFY( note2 ); |
|
198 QVERIFY( note2 == note ); |
|
199 } |
|
200 |
|
201 void UT_LcUiComponentRepository::testWaitingNote() |
|
202 { |
|
203 // Note created and returned |
|
204 QVERIFY( !mRepository->mWaitingNote ); |
|
205 HbDialog* note = mRepository->waitingNote(); |
|
206 QVERIFY( note ); |
|
207 QVERIFY( note == mRepository->mWaitingNote ); |
|
208 QVERIFY( !note->isVisible() ); |
|
209 |
|
210 // Existing note returned |
|
211 HbDialog* note2 = mRepository->waitingNote(); |
|
212 QVERIFY( note2 ); |
|
213 QVERIFY( note2 == note ); |
|
214 } |
|
215 |
|
216 void UT_LcUiComponentRepository::testRecipientQuery() |
|
217 { |
|
218 // Query created and returned |
|
219 QVERIFY( !mRepository->mRecipientQuery ); |
|
220 HbDialog* query = mRepository->recipientQuery(); |
|
221 QVERIFY( mRepository->mRecipientQuery ); |
|
222 QCOMPARE( query, mRepository->mRecipientQuery ); |
|
223 QVERIFY( !query->isVisible() ); |
|
224 |
|
225 // Existing query returned |
|
226 HbDialog* query2 = mRepository->recipientQuery(); |
|
227 QVERIFY( query2 == query ); |
|
228 } |
|
229 |
|
230 void UT_LcUiComponentRepository::testShareOwnVideoQuery() |
|
231 { |
|
232 // Query created and returned |
|
233 QVERIFY( !mRepository->mShareOwnVideoQuery ); |
|
234 HbDialog* query = mRepository->shareOwnVideoQuery(); |
|
235 QVERIFY( mRepository->mShareOwnVideoQuery ); |
|
236 QCOMPARE( query, (HbDialog*)mRepository->mShareOwnVideoQuery ); |
|
237 QVERIFY( !query->isVisible() ); |
|
238 |
|
239 // Existing query returned |
|
240 HbDialog* query2 = mRepository->shareOwnVideoQuery(); |
|
241 QVERIFY( query2 ); |
|
242 QVERIFY( query2 == query ); |
|
243 } |
|
244 |
|
245 void UT_LcUiComponentRepository::testZoomSlider() |
|
246 { |
|
247 int sliderTimeout = 3000; // 3 Seconds Timeout |
|
248 // slider created and returned |
|
249 QVERIFY( !mRepository->mZoomSlider ); |
|
250 HbDialog* slider = mRepository->zoomSlider(); |
|
251 QVERIFY( mRepository->mZoomSlider ); |
|
252 //QCOMPARE( slider, mRepository->mZoomSlider ); |
|
253 QVERIFY( slider == mRepository->mZoomSlider ); |
|
254 QVERIFY( !slider->isVisible() ); |
|
255 QCOMPARE( sliderTimeout, slider->timeout() ); |
|
256 |
|
257 // Existing slider returned |
|
258 HbDialog* slider2 = mRepository->zoomSlider(); |
|
259 QVERIFY( slider2 == slider ); |
|
260 |
|
261 } |
|
262 |
|
263 void UT_LcUiComponentRepository::testSharedVideoContextMenu() |
|
264 { |
|
265 HbMenu* menu = new HbMenu(); |
|
266 QVERIFY( menu->isEmpty() ); |
|
267 |
|
268 QVERIFY( !mRepository->mAllInOneView ); |
|
269 LcView* view = mRepository->allInOneView(); |
|
270 QVERIFY( mRepository->mAllInOneView ); |
|
271 QCOMPARE( view->objectName(), QString( lcViewAllInOneId ) ); |
|
272 |
|
273 HbAction zoom( lcActZoomId ); |
|
274 HbAction changeCamera( lcActChangeCameraId ); |
|
275 HbAction disableCam( lcActMenuDisableCameraId ); |
|
276 HbAction changeCam( lcActMenuChangeCameraId ); |
|
277 |
|
278 mRepository->mActions.append( &zoom ); |
|
279 mRepository->mActions.append( &changeCamera ); |
|
280 mRepository->mActions.append( &disableCam ); |
|
281 mRepository->mActions.append( &changeCam ); |
|
282 |
|
283 mRepository->sharedVideoContextMenuActions( menu, *view ); |
|
284 //TBD stub implementation of void QGraphicsWidget::addAction(QAction *action); |
|
285 //QVERIFY( !menu->isEmpty() ); |
|
286 } |
|
287 |
|
288 |
|
289 void UT_LcUiComponentRepository::testLoadView_FileNotFound() |
|
290 { |
|
291 QObjectList viewR; |
|
292 const QString vid( "view"); |
|
293 const QString file( "file not found" ); |
|
294 QVERIFY( !mRepository->loadView( viewR, vid, file ) ); |
|
295 } |
|
296 |
|
297 void UT_LcUiComponentRepository::testConnect() |
|
298 { |
|
299 LcView* view = mRepository->idleView(); |
|
300 QVERIFY( view ); |
|
301 HbAction action; |
|
302 |
|
303 // Existing action |
|
304 action.setObjectName( QString( lcActMuteId ) ); |
|
305 QVERIFY( mRepository->connect( action, *view ) ); |
|
306 |
|
307 // Action not found |
|
308 action.setObjectName( QString( "Action not defined" ) ); |
|
309 QVERIFY( !mRepository->connect( action, *view ) ); |
|
310 } |
|
311 |
|
312 |
|
313 void UT_LcUiComponentRepository::testLoadLayout() |
|
314 { |
|
315 bool ok( false ); |
|
316 |
|
317 // View not yet loaded |
|
318 QVERIFY( mRepository->mLastLoadedView.length() == 0 ); |
|
319 ok = mRepository->loadLayout( lcLayoutPortraitDefaultId ); |
|
320 QVERIFY( !ok ); |
|
321 |
|
322 // View is loaded |
|
323 mRepository->mLastLoadedView = lcIdleViewFile; |
|
324 ok = mRepository->loadLayout( lcLayoutPortraitDefaultId ); |
|
325 QVERIFY( ok ); |
|
326 |
|
327 // Changing layout |
|
328 ok = mRepository->loadLayout( lcLayoutLandscapeDefaultId ); |
|
329 QVERIFY( ok ); |
|
330 |
|
331 // Loading non-existing section |
|
332 ok = mRepository->loadLayout( QString("dummy_layout") ); |
|
333 QVERIFY( !ok ); |
|
334 |
|
335 // Check for current and previously loaded layout name |
|
336 mRepository->mLastLoadedView = lcIdleViewFile; |
|
337 ok = mRepository->loadLayout( lcLayoutLandscapeDefaultId ); |
|
338 QVERIFY( ok ); |
|
339 QVERIFY( mRepository->layout() == lcLayoutLandscapeDefaultId ); |
|
340 ok = mRepository->loadLayout( lcLayoutLandscapeDialpadId ); |
|
341 QVERIFY( ok ); |
|
342 QVERIFY( mRepository->layout() == lcLayoutLandscapeDialpadId ); |
|
343 QVERIFY( mRepository->previousLayout() == lcLayoutLandscapeDefaultId ); |
|
344 ok = mRepository->loadLayout( mRepository->previousLayout() ); |
|
345 QVERIFY( ok ); |
|
346 QVERIFY( mRepository->layout() == lcLayoutLandscapeDefaultId ); |
|
347 QVERIFY( mRepository->previousLayout() == lcLayoutLandscapeDialpadId ); |
|
348 |
|
349 } |