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