75 |
75 |
76 void UT_LogsMatchesView::testActivated() |
76 void UT_LogsMatchesView::testActivated() |
77 { |
77 { |
78 //activate for the first time |
78 //activate for the first time |
79 mMatchesView->mViewManager.mainWindow().setOrientation( Qt::Vertical ); |
79 mMatchesView->mViewManager.mainWindow().setOrientation( Qt::Vertical ); |
80 mRepository->matchesView(); |
80 LogsMatchesView* view = mRepository->matchesView(); |
81 QVERIFY( !mMatchesView->mInitialized ); |
81 QVERIFY( !mMatchesView->mInitialized ); |
82 QVERIFY( !mMatchesView->mListView ); |
82 QVERIFY( !mMatchesView->mListView ); |
83 QVERIFY( !mMatchesView->mModel ); |
83 QVERIFY( !mMatchesView->mModel ); |
84 QVERIFY( mMatchesView->mActionMap.count() == 0 ); |
84 QVERIFY( mMatchesView->mActionMap.count() == 0 ); |
85 mMatchesView->activated( false,QVariant() ); |
85 mMatchesView->activated( false,QVariant() ); |
88 QVERIFY( mMatchesView->mModel ); |
88 QVERIFY( mMatchesView->mModel ); |
89 QVERIFY( mMatchesView->mActionMap.count() == 4 ); |
89 QVERIFY( mMatchesView->mActionMap.count() == 4 ); |
90 QVERIFY( mMatchesView->mListView->layoutName() == logsListDefaultLayout ); |
90 QVERIFY( mMatchesView->mListView->layoutName() == logsListDefaultLayout ); |
91 QVERIFY( mMatchesView->mLayoutSectionName == logsViewDefaultSection ); |
91 QVERIFY( mMatchesView->mLayoutSectionName == logsViewDefaultSection ); |
92 QVERIFY( mMatchesView->mAddToContactsButton ); |
92 QVERIFY( mMatchesView->mAddToContactsButton ); |
|
93 QVERIFY( !mMatchesView->mAddToContactsButton->isVisible() ); |
93 |
94 |
94 //activate once again, model recreated |
95 //activate once again, model recreated |
95 mMatchesView->mViewManager.mainWindow().setOrientation( Qt::Horizontal ); |
96 mMatchesView->mViewManager.mainWindow().setOrientation( Qt::Horizontal ); |
96 LogsModel::setMatchesModelCreated(false); |
97 LogsModel::setMatchesModelCreated(false); |
97 mMatchesView->activated( true,QVariant() ); |
98 mMatchesView->activated( true,QVariant() ); |
99 QVERIFY( mMatchesView->mModel ); |
100 QVERIFY( mMatchesView->mModel ); |
100 QVERIFY( LogsModel::isMatchesModelCreated() ); //model recreated |
101 QVERIFY( LogsModel::isMatchesModelCreated() ); //model recreated |
101 QVERIFY( mMatchesView->mActionMap.count() == 4 ); |
102 QVERIFY( mMatchesView->mActionMap.count() == 4 ); |
102 QVERIFY( mMatchesView->mListView->layoutName() == logsListLandscapeDialpadLayout ); |
103 QVERIFY( mMatchesView->mListView->layoutName() == logsListLandscapeDialpadLayout ); |
103 QVERIFY( mMatchesView->mLayoutSectionName == logsViewLandscapeDialpadSection ); |
104 QVERIFY( mMatchesView->mLayoutSectionName == logsViewLandscapeDialpadSection ); |
|
105 QVERIFY( !mMatchesView->mAddToContactsButton->isVisible() ); |
104 |
106 |
105 //Pass model as input arg |
107 //Pass model as input arg |
106 LogsDbConnector* dbConnector = 0; |
108 LogsDbConnector* dbConnector = 0; |
107 LogsMatchesModel* model1 = new LogsMatchesModel(*dbConnector); |
109 LogsMatchesModel* model1 = new LogsMatchesModel(*dbConnector); |
108 model1->resetLastCall(); |
110 model1->resetLastCall(); |
117 QVariant arg2 = qVariantFromValue( model2 ); |
119 QVariant arg2 = qVariantFromValue( model2 ); |
118 mMatchesView->activated( true, arg2 ); |
120 mMatchesView->activated( true, arg2 ); |
119 QVERIFY( mMatchesView->mListView ); |
121 QVERIFY( mMatchesView->mListView ); |
120 QVERIFY( mMatchesView->mModel == model2 ); |
122 QVERIFY( mMatchesView->mModel == model2 ); |
121 QVERIFY( mMatchesView->mModel->mLastCall.isEmpty() ); |
123 QVERIFY( mMatchesView->mModel->mLastCall.isEmpty() ); |
|
124 QVERIFY( !mMatchesView->mAddToContactsButton->isVisible() ); |
122 |
125 |
123 // After passing model as input arg, do not pass model |
126 // After passing model as input arg, do not pass model |
124 mMatchesView->activated( true,QVariant() ); |
127 mMatchesView->activated( true,QVariant() ); |
125 QVERIFY( mMatchesView->mListView ); |
128 QVERIFY( mMatchesView->mListView ); |
126 QVERIFY( mMatchesView->mModel ); |
129 QVERIFY( mMatchesView->mModel ); |
127 QVERIFY( mMatchesView->mModel->mLastCall == QLatin1String("constructor") ); |
130 QVERIFY( mMatchesView->mModel->mLastCall == QLatin1String("constructor") ); |
|
131 delete view; |
128 } |
132 } |
129 |
133 |
130 |
134 |
131 void UT_LogsMatchesView::testDeactivated() |
135 void UT_LogsMatchesView::testDeactivated() |
132 { |
136 { |
238 QVERIFY( mMatchesView->mModel->lastCall() == QString("logsMatches") ); |
242 QVERIFY( mMatchesView->mModel->lastCall() == QString("logsMatches") ); |
239 QVERIFY( mMatchesView->mDialpad->mIsCallButtonEnabled ); |
243 QVERIFY( mMatchesView->mDialpad->mIsCallButtonEnabled ); |
240 |
244 |
241 //text erased from input, view changed to recent calls |
245 //text erased from input, view changed to recent calls |
242 mMatchesView->mDialpad->editor().setText( QString("") ); |
246 mMatchesView->mDialpad->editor().setText( QString("") ); |
|
247 mMatchesView->dialpadEditorTextChanged(); |
243 QVERIFY( mViewManager->mViewId == LogsRecentViewId ); |
248 QVERIFY( mViewManager->mViewId == LogsRecentViewId ); |
244 } |
249 } |
245 |
250 |
246 void UT_LogsMatchesView::testDialpadClosed() |
251 void UT_LogsMatchesView::testDialpadClosed() |
247 { |
252 { |
|
253 LogsMatchesView* view = mRepository->matchesView(); |
248 mMatchesView->mViewManager.mainWindow().setOrientation( Qt::Horizontal ); |
254 mMatchesView->mViewManager.mainWindow().setOrientation( Qt::Horizontal ); |
249 mMatchesView->mListView = new HbListView(); |
255 mMatchesView->initView(); |
250 mMatchesView->mLayoutSectionName = QString("landscape_dialpad"); |
256 mMatchesView->mLayoutSectionName = QString("landscape_dialpad"); |
251 QString hello("hello"); |
257 QString hello("hello"); |
252 mMatchesView->mDialpad->editor().setText( hello ); |
258 mMatchesView->mDialpad->editor().setText( hello ); |
253 mMatchesView->mAddToContactsButton = new HbPushButton(); |
|
254 mMatchesView->mAddToContactsButton->setVisible(true); |
259 mMatchesView->mAddToContactsButton->setVisible(true); |
255 |
260 |
256 mMatchesView->dialpadClosed(); |
261 mMatchesView->dialpadClosed(); |
257 |
262 |
258 QVERIFY( mMatchesView->mDialpad->editor().text() == hello ); |
263 QVERIFY( mMatchesView->mDialpad->editor().text() == hello ); |
259 QVERIFY( mMatchesView->mLayoutSectionName == logsViewDefaultSection ); |
264 QVERIFY( mMatchesView->mLayoutSectionName == logsViewDefaultSection ); |
260 QVERIFY( !mMatchesView->mAddToContactsButton->isVisible() ); |
265 QVERIFY( !mMatchesView->mAddToContactsButton->isVisible() ); |
261 delete mMatchesView->mListView; |
266 delete view; |
262 mMatchesView->mListView = 0; |
|
263 delete mMatchesView->mAddToContactsButton; |
|
264 mMatchesView->mAddToContactsButton = 0; |
|
265 } |
267 } |
266 |
268 |
267 void UT_LogsMatchesView::testDialpadOpened() |
269 void UT_LogsMatchesView::testDialpadOpened() |
268 { |
270 { |
269 //widgets size and layout updated |
271 //widgets size and layout updated |
|
272 LogsMatchesView* view = mRepository->matchesView(); |
270 mMatchesView->mViewManager.mainWindow().setOrientation( Qt::Vertical ); |
273 mMatchesView->mViewManager.mainWindow().setOrientation( Qt::Vertical ); |
271 mMatchesView->mListView = new HbListView(); |
274 mMatchesView->initView(); |
272 mMatchesView->mLayoutSectionName = QString("dummy"); |
275 mMatchesView->mLayoutSectionName = QString("dummy"); |
273 mMatchesView->mListView->setLayoutName("dummy"); |
276 mMatchesView->mListView->setLayoutName("dummy"); |
274 mMatchesView->mDialpad->mIsOpen = true; |
277 mMatchesView->mDialpad->mIsOpen = true; |
275 mMatchesView->mAddToContactsButton = new HbPushButton(); |
|
276 mMatchesView->mAddToContactsButton->setVisible(false); |
278 mMatchesView->mAddToContactsButton->setVisible(false); |
277 mMatchesView->mDialpad->editor().setText( "hello" ); |
279 mMatchesView->mDialpad->editor().setText( "hello" ); |
278 mMatchesView->mDialpad->mIsOpen = true; |
280 mMatchesView->mDialpad->mIsOpen = true; |
279 |
281 |
280 mMatchesView->dialpadOpened(); |
282 mMatchesView->dialpadOpened(); |
281 |
283 |
282 QVERIFY( mMatchesView->mListView->layoutName() == logsListDefaultLayout ); |
284 QVERIFY( mMatchesView->mListView->layoutName() == logsListDefaultLayout ); |
283 QVERIFY( mMatchesView->mLayoutSectionName == logsViewPortraitDialpadSection ); |
285 QVERIFY( mMatchesView->mLayoutSectionName == logsViewPortraitDialpadSection ); |
284 QVERIFY( mMatchesView->mAddToContactsButton->isVisible() ); |
286 QVERIFY( mMatchesView->mAddToContactsButton->isVisible() ); |
285 delete mMatchesView->mListView; |
287 delete view; |
286 mMatchesView->mListView = 0; |
|
287 delete mMatchesView->mAddToContactsButton; |
|
288 mMatchesView->mAddToContactsButton = 0; |
|
289 } |
288 } |
290 |
289 |
291 void UT_LogsMatchesView::testModel() |
290 void UT_LogsMatchesView::testModel() |
292 { |
291 { |
293 QVERIFY( !mMatchesView->model() ); |
292 QVERIFY( !mMatchesView->model() ); |
302 //no listView, nothing happens |
301 //no listView, nothing happens |
303 QVERIFY( !mMatchesView->mListView ); |
302 QVERIFY( !mMatchesView->mListView ); |
304 mMatchesView->updateWidgetsSizeAndLayout(); |
303 mMatchesView->updateWidgetsSizeAndLayout(); |
305 |
304 |
306 //listView exists, layout and size updated, dialpad not visible |
305 //listView exists, layout and size updated, dialpad not visible |
307 mRepository->matchesView(); |
306 LogsMatchesView* view = mRepository->matchesView(); |
308 mMatchesView->mViewManager.mainWindow().setOrientation( Qt::Vertical ); |
307 mMatchesView->mViewManager.mainWindow().setOrientation( Qt::Vertical ); |
309 mMatchesView->mDialpad->closeDialpad(); |
308 mMatchesView->mDialpad->closeDialpad(); |
310 mMatchesView->mListView = new HbListView(); |
309 mMatchesView->mListView = new HbListView(); |
311 mMatchesView->mListView->setLayoutName("dummy"); |
310 mMatchesView->mListView->setLayoutName("dummy"); |
312 mMatchesView->updateWidgetsSizeAndLayout(); |
311 mMatchesView->updateWidgetsSizeAndLayout(); |
329 QVERIFY( mMatchesView->mLayoutSectionName == logsViewPortraitDialpadSection ); |
328 QVERIFY( mMatchesView->mLayoutSectionName == logsViewPortraitDialpadSection ); |
330 QVERIFY( videoCallAction->isVisible() ); |
329 QVERIFY( videoCallAction->isVisible() ); |
331 QVERIFY( messageAction->isVisible() ); |
330 QVERIFY( messageAction->isVisible() ); |
332 |
331 |
333 delete mMatchesView->mListView; |
332 delete mMatchesView->mListView; |
334 mMatchesView->mListView = 0; |
333 mMatchesView->mListView = 0; |
335 } |
334 delete view; |
|
335 } |
336 |
336 |
337 void UT_LogsMatchesView::testHandleOrientationChanged() |
337 void UT_LogsMatchesView::testHandleOrientationChanged() |
338 { |
338 { |
339 //dialpad position recalculated and layout/size updated |
339 //dialpad position recalculated and layout/size updated |
340 QPointF pos; |
340 QPointF pos; |
341 mMatchesView->mListView = new HbListView(); |
341 LogsMatchesView* view = mRepository->matchesView(); |
|
342 mMatchesView->initView(); |
342 mMatchesView->mListView->setLayoutName("dummy"); |
343 mMatchesView->mListView->setLayoutName("dummy"); |
343 mMatchesView->mLayoutSectionName = "dummy"; |
344 mMatchesView->mLayoutSectionName = "dummy"; |
344 mMatchesView->mDialpad->setPos(pos); |
345 mMatchesView->mDialpad->setPos(pos); |
345 mMatchesView->mViewManager.mainWindow().setOrientation( Qt::Horizontal ); |
346 mMatchesView->mViewManager.mainWindow().setOrientation( Qt::Horizontal ); |
346 |
347 |
347 mMatchesView->handleOrientationChanged(); |
348 mMatchesView->handleOrientationChanged(); |
348 |
349 |
349 QVERIFY( pos != mMatchesView->mDialpad->pos() ); |
350 QVERIFY( pos != mMatchesView->mDialpad->pos() ); |
350 QVERIFY( mMatchesView->mListView->layoutName() == logsListLandscapeLayout ); |
351 QVERIFY( mMatchesView->mListView->layoutName() == logsListLandscapeLayout ); |
351 QVERIFY( mMatchesView->mLayoutSectionName == logsViewDefaultSection ); |
352 QVERIFY( mMatchesView->mLayoutSectionName == logsViewDefaultSection ); |
352 delete mMatchesView->mListView; |
353 delete view; |
353 mMatchesView->mListView = 0; |
|
354 } |
354 } |
355 |
355 |
356 void UT_LogsMatchesView::testUpdateEmptyListWidgetsVisibility() |
356 void UT_LogsMatchesView::testUpdateEmptyListWidgetsVisibility() |
357 { |
357 { |
358 LogsDbConnector* dbConnector = 0; |
358 LogsDbConnector* dbConnector = 0; |
367 |
367 |
368 mMatchesView->updateEmptyListWidgetsVisibility(); |
368 mMatchesView->updateEmptyListWidgetsVisibility(); |
369 |
369 |
370 QVERIFY( mMatchesView->mEmptyListLabel->isVisible() ); |
370 QVERIFY( mMatchesView->mEmptyListLabel->isVisible() ); |
371 QVERIFY( mMatchesView->mAddToContactsButton->isVisible() ); |
371 QVERIFY( mMatchesView->mAddToContactsButton->isVisible() ); |
|
372 |
|
373 mMatchesView->mAddToContactsButtonDisabled = true; |
|
374 mMatchesView->updateEmptyListWidgetsVisibility(); |
|
375 QVERIFY( mMatchesView->mEmptyListLabel->isVisible() ); |
|
376 QVERIFY( !mMatchesView->mAddToContactsButton->isVisible() ); |
|
377 |
372 delete mMatchesView->mEmptyListLabel; |
378 delete mMatchesView->mEmptyListLabel; |
373 mMatchesView->mEmptyListLabel = 0; |
379 mMatchesView->mEmptyListLabel = 0; |
374 delete mMatchesView->mAddToContactsButton; |
380 delete mMatchesView->mAddToContactsButton; |
375 mMatchesView->mAddToContactsButton = 0; |
381 mMatchesView->mAddToContactsButton = 0; |
376 } |
382 } |