logsui/logsapp/tsrc/ut_logsapp/src/ut_logsmatchesview.cpp
changeset 21 2f0af9ba7665
parent 17 90fe74753f71
equal deleted inserted replaced
18:acd4e87b24b4 21:2f0af9ba7665
    66 {
    66 {
    67     QVERIFY( mMatchesView );
    67     QVERIFY( mMatchesView );
    68     QVERIFY( mMatchesView->viewId() == LogsMatchesViewId );
    68     QVERIFY( mMatchesView->viewId() == LogsMatchesViewId );
    69     QVERIFY( !mMatchesView->mListView );
    69     QVERIFY( !mMatchesView->mListView );
    70     QVERIFY( !mMatchesView->mModel );
    70     QVERIFY( !mMatchesView->mModel );
    71     QVERIFY( mMatchesView->mActionMap.count() == 0 );
       
    72     QVERIFY( mMatchesView->mLayoutSectionName == "" );
    71     QVERIFY( mMatchesView->mLayoutSectionName == "" );
    73     QVERIFY( !mMatchesView->mAddToContactsButton );
    72     QVERIFY( !mMatchesView->mAddToContactsButton );
    74     QCOMPARE( mMatchesView->mActivities.at(0), QString(logsActivityIdViewMatches) );
    73     QCOMPARE( mMatchesView->mActivities.at(0), QString(logsActivityIdViewMatches) );
    75 }
    74 }
    76 
    75 
    80     mMatchesView->mViewManager.mainWindow().setOrientation( Qt::Vertical );
    79     mMatchesView->mViewManager.mainWindow().setOrientation( Qt::Vertical );
    81     LogsMatchesView* view = mRepository->matchesView();
    80     LogsMatchesView* view = mRepository->matchesView();
    82     QVERIFY( !mMatchesView->mInitialized );
    81     QVERIFY( !mMatchesView->mInitialized );
    83     QVERIFY( !mMatchesView->mListView );
    82     QVERIFY( !mMatchesView->mListView );
    84     QVERIFY( !mMatchesView->mModel );
    83     QVERIFY( !mMatchesView->mModel );
    85     QVERIFY( mMatchesView->mActionMap.count() == 0 );
    84     mMatchesView->activated( false,QVariant(), mMatchesView->mDialpad->editor().text() );
    86     mMatchesView->activated( false,QVariant() );
       
    87     QVERIFY( mMatchesView->mInitialized );
    85     QVERIFY( mMatchesView->mInitialized );
    88     QVERIFY( mMatchesView->mListView );
    86     QVERIFY( mMatchesView->mListView );
    89     QVERIFY( mMatchesView->mModel );
    87     QVERIFY( mMatchesView->mModel );
    90     QVERIFY( mMatchesView->mActionMap.count() == 4 );
       
    91     QVERIFY( mMatchesView->mListView->layoutName() == logsListDefaultLayout );
    88     QVERIFY( mMatchesView->mListView->layoutName() == logsListDefaultLayout );
    92     QVERIFY( mMatchesView->mLayoutSectionName == logsViewDefaultSection );
    89     QVERIFY( mMatchesView->mLayoutSectionName == logsViewDefaultSection );
    93     QVERIFY( mMatchesView->mAddToContactsButton );
    90     QVERIFY( mMatchesView->mAddToContactsButton );
    94     QVERIFY( !mMatchesView->mAddToContactsButton->isVisible() );
    91     QVERIFY( !mMatchesView->mAddToContactsButton->isVisible() );
    95     
    92     
    96     //activate once again, model recreated
    93     //activate once again, model recreated
    97     mMatchesView->mViewManager.mainWindow().setOrientation( Qt::Horizontal );
    94     mMatchesView->mViewManager.mainWindow().setOrientation( Qt::Horizontal );
    98     LogsModel::setMatchesModelCreated(false);
    95     LogsModel::setMatchesModelCreated(false);
    99     mMatchesView->activated( true,QVariant() );
    96     mMatchesView->activated( true,QVariant(), mMatchesView->mDialpad->editor().text() );
   100     QVERIFY( mMatchesView->mListView );
    97     QVERIFY( mMatchesView->mListView );
   101     QVERIFY( mMatchesView->mModel );    
    98     QVERIFY( mMatchesView->mModel );    
   102     QVERIFY( LogsModel::isMatchesModelCreated() ); //model recreated
    99     QVERIFY( LogsModel::isMatchesModelCreated() ); //model recreated
   103     QVERIFY( mMatchesView->mActionMap.count() == 4 );
       
   104     QVERIFY( mMatchesView->mListView->layoutName() == logsListLandscapeDialpadLayout );
   100     QVERIFY( mMatchesView->mListView->layoutName() == logsListLandscapeDialpadLayout );
   105     QVERIFY( mMatchesView->mLayoutSectionName == logsViewLandscapeDialpadSection );
   101     QVERIFY( mMatchesView->mLayoutSectionName == logsViewLandscapeDialpadSection );
   106     QVERIFY( !mMatchesView->mAddToContactsButton->isVisible() );
   102     QVERIFY( !mMatchesView->mAddToContactsButton->isVisible() );
   107     
   103     
   108     //Pass model as input arg
   104     //Pass model as input arg
   109     LogsDbConnector* dbConnector = 0;
   105     LogsDbConnector* dbConnector = 0;
   110     LogsMatchesModel* model1 = new LogsMatchesModel(*dbConnector);
   106     LogsMatchesModel* model1 = new LogsMatchesModel(*dbConnector);
   111     model1->resetLastCall();
   107     model1->resetLastCall();
   112     QVariant arg = qVariantFromValue( model1 );
   108     QVariant arg = qVariantFromValue( model1 );
   113     mMatchesView->activated( true, arg );
   109     mMatchesView->activated( true, arg , mMatchesView->mDialpad->editor().text());
   114     QVERIFY( mMatchesView->mListView );
   110     QVERIFY( mMatchesView->mListView );
   115     QVERIFY( mMatchesView->mModel == model1 );
   111     QVERIFY( mMatchesView->mModel == model1 );
   116     QVERIFY( mMatchesView->mModel->mLastCall.isEmpty() );
   112     QVERIFY( mMatchesView->mModel->mLastCall.isEmpty() );
   117     
   113     
   118     LogsMatchesModel* model2 = new LogsMatchesModel(*dbConnector);
   114     LogsMatchesModel* model2 = new LogsMatchesModel(*dbConnector);
   119     model2->resetLastCall();
   115     model2->resetLastCall();
   120     QVariant arg2 = qVariantFromValue( model2 );
   116     QVariant arg2 = qVariantFromValue( model2 );
   121     mMatchesView->activated( true, arg2 );
   117     mMatchesView->activated( true, arg2, mMatchesView->mDialpad->editor().text() );
   122     QVERIFY( mMatchesView->mListView );
   118     QVERIFY( mMatchesView->mListView );
   123     QVERIFY( mMatchesView->mModel == model2 );
   119     QVERIFY( mMatchesView->mModel == model2 );
   124     QVERIFY( mMatchesView->mModel->mLastCall.isEmpty() );
   120     QVERIFY( mMatchesView->mModel->mLastCall.isEmpty() );
   125     QVERIFY( !mMatchesView->mAddToContactsButton->isVisible() );
   121     QVERIFY( !mMatchesView->mAddToContactsButton->isVisible() );
   126     
   122     
   127     // After passing model as input arg, do not pass model
   123     // After passing model as input arg, do not pass model
   128     mMatchesView->mActivating = true;
   124     mMatchesView->mActivating = true;
   129     mMatchesView->activated( true,QVariant() );
   125     mMatchesView->activated( true,QVariant(), mMatchesView->mDialpad->editor().text() );
   130     QVERIFY( mMatchesView->mListView );
   126     QVERIFY( mMatchesView->mListView );
   131     QVERIFY( mMatchesView->mModel );
   127     QVERIFY( mMatchesView->mModel );
   132     QVERIFY( mMatchesView->mModel->mLastCall == QLatin1String("constructor") );
   128     QVERIFY( mMatchesView->mModel->mLastCall == QLatin1String("constructor") );
   133     QVERIFY( !mMatchesView->mActivating );
   129     QVERIFY( !mMatchesView->mActivating );
   134     delete view;   
   130     delete view;   
   216 
   212 
   217 void UT_LogsMatchesView::testSaveNumberInDialpadToContacts()
   213 void UT_LogsMatchesView::testSaveNumberInDialpadToContacts()
   218 {
   214 {
   219     // Nothing happens if there is no text in dialpad
   215     // Nothing happens if there is no text in dialpad
   220     QVERIFY(!mMatchesView->mContact);
   216     QVERIFY(!mMatchesView->mContact);
   221     QCOMPARE(mMatchesView->mDialpad->editor().text().length(), 0);
   217     QCOMPARE(mMatchesView->currDialpadText().length(), 0);
   222     mMatchesView->saveNumberInDialpadToContacts();
   218     mMatchesView->saveNumberInDialpadToContacts();
   223     QVERIFY(!mMatchesView->mContact);
   219     QVERIFY(!mMatchesView->mContact);
   224     
   220     
   225     // If there is a number, new contact will be created
   221     // If there is a number, new contact will be created
   226     mMatchesView->mDialpad->editor().setText("123");
   222     mMatchesView->mDialpad->editor().setText("123");
   261     mMatchesView->mDialpad->editor().setText( hello );
   257     mMatchesView->mDialpad->editor().setText( hello );
   262     mMatchesView->mAddToContactsButton->setVisible(true);
   258     mMatchesView->mAddToContactsButton->setVisible(true);
   263     
   259     
   264     mMatchesView->dialpadClosed();
   260     mMatchesView->dialpadClosed();
   265     
   261     
   266     QVERIFY( mMatchesView->mDialpad->editor().text() == hello );
   262     QVERIFY( mMatchesView->currDialpadText() == hello );
   267     QVERIFY( mMatchesView->mLayoutSectionName == logsViewDefaultSection );
   263     QVERIFY( mMatchesView->mLayoutSectionName == logsViewDefaultSection );
   268     QVERIFY( !mMatchesView->mAddToContactsButton->isVisible() );
   264     QVERIFY( !mMatchesView->mAddToContactsButton->isVisible() );
   269     delete view;
   265     delete view;
   270 }
   266 }
   271 
   267 
   429 {	
   425 {	
   430     LogsMatchesView* view = mRepository->matchesView();
   426     LogsMatchesView* view = mRepository->matchesView();
   431 	LogsDbConnector* dbConnector = 0;
   427 	LogsDbConnector* dbConnector = 0;
   432     LogsMatchesModel* model1 = new LogsMatchesModel(*dbConnector);
   428     LogsMatchesModel* model1 = new LogsMatchesModel(*dbConnector);
   433     QVariant arg = qVariantFromValue( model1 );
   429     QVariant arg = qVariantFromValue( model1 );
   434     view->activated( true, arg );
   430     view->activated( true, arg , view->mDialpad->editor().text());
   435     int status = view->mModel->predictiveSearchStatus();
   431     int status = view->mModel->predictiveSearchStatus();
   436     QVERIFY( status == 1 );   
   432     QVERIFY( status == 1 );   
   437     
   433     
   438     //set contact search off, view changes and dialpad content is not cleared  
   434     //set contact search off, view changes and dialpad content is not cleared  
   439     mMatchesView->mDialpad->editor().setText( "1234" );
   435     mMatchesView->mDialpad->editor().setText( "1234" );
   440     mViewManager->reset();
   436     mViewManager->reset();
   441     view->toggleContactSearch();
   437     view->toggleContactSearch();
   442     status = view->mModel->predictiveSearchStatus();
   438     status = view->mModel->predictiveSearchStatus();
   443     QVERIFY( status == 2 );
   439     QVERIFY( status == 2 );
   444     QVERIFY( mViewManager->mViewId == LogsRecentViewId );
   440     QVERIFY( mViewManager->mViewId == LogsRecentViewId );
   445     QVERIFY( mMatchesView->mDialpad->editor().text() == "1234" );
   441     QVERIFY( mMatchesView->currDialpadText() == "1234" );
   446     delete view;    
   442     delete view;    
   447 }
   443 }
   448 
   444 
   449 void UT_LogsMatchesView::testLocaleChanged()
   445 void UT_LogsMatchesView::testLocaleChanged()
   450 {
   446 {