logsui/logsapp/tsrc/ut_logsapp/src/ut_logsmatchesview.cpp
changeset 10 b04270301d3b
parent 6 41c0a814d878
child 11 64a47b97e1e1
--- a/logsui/logsapp/tsrc/ut_logsapp/src/ut_logsmatchesview.cpp	Fri Jun 11 13:38:41 2010 +0300
+++ b/logsui/logsapp/tsrc/ut_logsapp/src/ut_logsmatchesview.cpp	Wed Jun 23 18:13:05 2010 +0300
@@ -77,7 +77,7 @@
 {
     //activate for the first time
     mMatchesView->mViewManager.mainWindow().setOrientation( Qt::Vertical );
-    mRepository->matchesView();
+    LogsMatchesView* view = mRepository->matchesView();
     QVERIFY( !mMatchesView->mInitialized );
     QVERIFY( !mMatchesView->mListView );
     QVERIFY( !mMatchesView->mModel );
@@ -125,6 +125,7 @@
     QVERIFY( mMatchesView->mListView );
     QVERIFY( mMatchesView->mModel );
     QVERIFY( mMatchesView->mModel->mLastCall == QLatin1String("constructor") );
+    delete view;
 }
 
 
@@ -240,17 +241,18 @@
     
     //text erased from input, view changed to recent calls
     mMatchesView->mDialpad->editor().setText( QString("") );
+    mMatchesView->dialpadEditorTextChanged();
     QVERIFY( mViewManager->mViewId == LogsRecentViewId );   
 }
 
 void UT_LogsMatchesView::testDialpadClosed()
 {
+    LogsMatchesView* view = mRepository->matchesView();
     mMatchesView->mViewManager.mainWindow().setOrientation( Qt::Horizontal );
-    mMatchesView->mListView = new HbListView();
+    mMatchesView->initView();
     mMatchesView->mLayoutSectionName = QString("landscape_dialpad");
     QString hello("hello");
     mMatchesView->mDialpad->editor().setText( hello );
-    mMatchesView->mAddToContactsButton = new HbPushButton();
     mMatchesView->mAddToContactsButton->setVisible(true);
     
     mMatchesView->dialpadClosed();
@@ -258,21 +260,18 @@
     QVERIFY( mMatchesView->mDialpad->editor().text() == hello );
     QVERIFY( mMatchesView->mLayoutSectionName == logsViewDefaultSection );
     QVERIFY( !mMatchesView->mAddToContactsButton->isVisible() );
-    delete mMatchesView->mListView;
-    mMatchesView->mListView = 0;
-    delete mMatchesView->mAddToContactsButton;
-    mMatchesView->mAddToContactsButton = 0;
+    delete view;
 }
 
 void UT_LogsMatchesView::testDialpadOpened()
 {
     //widgets size and layout updated
+    LogsMatchesView* view = mRepository->matchesView();
     mMatchesView->mViewManager.mainWindow().setOrientation( Qt::Vertical );
-    mMatchesView->mListView = new HbListView();
+    mMatchesView->initView();
     mMatchesView->mLayoutSectionName = QString("dummy");
     mMatchesView->mListView->setLayoutName("dummy");
     mMatchesView->mDialpad->mIsOpen = true;
-    mMatchesView->mAddToContactsButton = new HbPushButton();
     mMatchesView->mAddToContactsButton->setVisible(false);
     mMatchesView->mDialpad->editor().setText( "hello" );
     mMatchesView->mDialpad->mIsOpen = true;
@@ -282,10 +281,7 @@
     QVERIFY( mMatchesView->mListView->layoutName() == logsListDefaultLayout );
     QVERIFY( mMatchesView->mLayoutSectionName == logsViewPortraitDialpadSection );
     QVERIFY( mMatchesView->mAddToContactsButton->isVisible() );
-    delete mMatchesView->mListView;
-    mMatchesView->mListView = 0;
-    delete mMatchesView->mAddToContactsButton;
-    mMatchesView->mAddToContactsButton = 0;
+    delete view;
 }
 
 void UT_LogsMatchesView::testModel()
@@ -304,7 +300,7 @@
     mMatchesView->updateWidgetsSizeAndLayout();
     
     //listView exists, layout and size updated, dialpad not visible
-    mRepository->matchesView();
+    LogsMatchesView* view = mRepository->matchesView();
     mMatchesView->mViewManager.mainWindow().setOrientation( Qt::Vertical );
     mMatchesView->mDialpad->closeDialpad();
     mMatchesView->mListView = new HbListView();
@@ -331,14 +327,16 @@
     QVERIFY( messageAction->isVisible() );
     
     delete mMatchesView->mListView;
-    mMatchesView->mListView = 0; 
-}
+    mMatchesView->mListView = 0;
+    delete view;
+ }
 
 void UT_LogsMatchesView::testHandleOrientationChanged()
 {
     //dialpad position recalculated and layout/size updated
     QPointF pos;
-    mMatchesView->mListView = new HbListView();
+    LogsMatchesView* view = mRepository->matchesView();
+    mMatchesView->initView();
     mMatchesView->mListView->setLayoutName("dummy");
     mMatchesView->mLayoutSectionName = "dummy";
     mMatchesView->mDialpad->setPos(pos);    
@@ -349,8 +347,7 @@
     QVERIFY( pos != mMatchesView->mDialpad->pos() );
     QVERIFY( mMatchesView->mListView->layoutName() == logsListLandscapeLayout );
     QVERIFY( mMatchesView->mLayoutSectionName == logsViewDefaultSection );
-    delete mMatchesView->mListView;
-    mMatchesView->mListView = 0; 
+    delete view;
 }
 
 void UT_LogsMatchesView::testUpdateEmptyListWidgetsVisibility()
@@ -433,7 +430,8 @@
     status = view->mModel->predictiveSearchStatus();
     QVERIFY( status == 2 );
     QVERIFY( mViewManager->mViewId == LogsRecentViewId );
-    QVERIFY( mMatchesView->mDialpad->editor().text() == "1234" );    
+    QVERIFY( mMatchesView->mDialpad->editor().text() == "1234" );
+    delete view;
     
 }