phonesettings/cpphonesettingsplugins/divertplugin/tsrc/ut_cpdivertplugin/ut_cpdivertplugin.cpp
branchGCC_SURGE
changeset 51 f39ed5e045e0
parent 27 2f8f8080a020
parent 46 bc5a64e5bc3c
equal deleted inserted replaced
40:bab96b7ed1a4 51:f39ed5e045e0
    28 #include <HbAbstractViewItem>
    28 #include <HbAbstractViewItem>
    29 #include <HbDataFormModel>
    29 #include <HbDataFormModel>
    30 #include "cpitemdatahelper.h"
    30 #include "cpitemdatahelper.h"
    31 #include "cpdivertitemdata.h"
    31 #include "cpdivertitemdata.h"
    32 #include "psetwrappertypes.h"
    32 #include "psetwrappertypes.h"
    33 #include "cpdivertselectioncustomitem.h"
       
    34 
    33 
    35 #define private public
    34 #define private public
    36 #include "cpdivertplugin.h"
    35 #include "cpdivertplugin.h"
    37 #include "cpdivertplugingroup.h"
    36 #include "cpdivertplugingroup.h"
    38 
    37 
    46 public:
    45 public:
    47     CPsetContainer(){};
    46     CPsetContainer(){};
    48     ~CPsetContainer(){};
    47     ~CPsetContainer(){};
    49 };
    48 };
    50 
    49 
    51 void fillNumber(QString& number)
    50 void fillNumber(QString& number, PsService /*service*/)
    52 {
    51 {
    53     number = "1234567";
    52     number = "1234567";
    54 }
    53 }
    55     
    54     
    56 
    55 
    94     QList<CpSettingFormItemData*> list;
    93     QList<CpSettingFormItemData*> list;
    95     list.append(m_divertplugin->createSettingFormItemData(*m_helper));
    94     list.append(m_divertplugin->createSettingFormItemData(*m_helper));
    96     m_divertpluginGroup = qobject_cast<CpDivertPluginGroup *>(list.takeFirst());
    95     m_divertpluginGroup = qobject_cast<CpDivertPluginGroup *>(list.takeFirst());
    97     QVERIFY(m_divertpluginGroup);
    96     QVERIFY(m_divertpluginGroup);
    98     
    97     
       
    98     m_dataForm = new HbDataFormModel;
       
    99     m_dataForm->appendDataFormItem(m_divertpluginGroup);
       
   100     
    99     QVERIFY(verify());
   101     QVERIFY(verify());
   100 }
   102 }
   101 
   103 
   102 /*!
   104 /*!
   103   UT_CpDivertPlugin::cleanup
   105   UT_CpDivertPlugin::cleanup
   104  */
   106  */
   105 void UT_CpDivertPlugin::cleanup()
   107 void UT_CpDivertPlugin::cleanup()
   106 {
   108 {
   107     reset();
   109     reset();
   108     delete m_divertpluginGroup;
   110     delete m_dataForm;
       
   111     m_dataForm = NULL;
       
   112     
       
   113     //delete m_divertpluginGroup; // dataForm owned
   109     m_divertpluginGroup = NULL;
   114     m_divertpluginGroup = NULL;
   110 
   115 
   111     delete m_helper;
   116     delete m_helper;
   112     m_helper = NULL;
   117     m_helper = NULL;
   113     
   118     
   146   UT_CpDivertPlugin::t_changeDivertingStateRequested
   151   UT_CpDivertPlugin::t_changeDivertingStateRequested
   147  */
   152  */
   148 void UT_CpDivertPlugin::t_changeDivertingStateRequested()
   153 void UT_CpDivertPlugin::t_changeDivertingStateRequested()
   149 {
   154 {
   150     //except user cancels
   155     //except user cancels
   151     appendAction("All voice calls:", selectAction, "Cancel");
   156     /*
       
   157     appendAction("txt_phone_setlabel_all_calls", selectAction, "Cancel");
   152     expect("PSetCallDivertingWrapper::getDefaultNumbers");
   158     expect("PSetCallDivertingWrapper::getDefaultNumbers");
   153     m_divertpluginGroup->m_DataItemVoiceAllCalls->setContentWidgetData("number", "");
   159     m_divertpluginGroup->m_DataItemVoiceAllCalls->setContentWidgetData("text", "");
   154     m_divertpluginGroup->m_DataItemVoiceAllCalls->setContentWidgetData(
   160     m_divertpluginGroup->m_DataItemVoiceAllCalls->setContentWidgetData(
   155             "state", CpDivertSelectionCustomitem::Disabled);
   161         "checkState", Qt::Checked);
   156     m_divertpluginGroup->m_DataItemVoiceAllCalls->thisItemClicked();
   162     m_divertpluginGroup->m_DataItemVoiceAllCalls->thisItemClicked();
       
   163     waitForQueueEmpty();
   157     QVERIFY(verify());
   164     QVERIFY(verify());
   158     
   165     
   159     //except user selects vmb
   166     //except user selects vmb
   160     appendAction("All voice calls:", selectItem, "txt_phone_setlabel_voice_mbx");
   167     appendAction("txt_phone_setlabel_all_calls", selectItem, "txt_phone_setlabel_voice_mbx");
   161     expect("PSetCallDivertingWrapper::getDefaultNumbers");
   168     expect("PSetCallDivertingWrapper::getDefaultNumbers");
   162     expect("PSetCallDivertingWrapper::getVoiceMailBoxNumber").willOnce(invoke(fillNumber));
   169     expect("PSetCallDivertingWrapper::queryVoiceMailBoxNumber").willOnce(invoke(fillNumber)).returns(0);
   163     expect("SsSettingsWrapper::get");
   170     expect("SsSettingsWrapper::get");
   164     expect("PSetCallDivertingWrapper::setCallDiverting");
   171     expect("PSetCallDivertingWrapper::setCallDiverting");
   165     expect("CpPhoneNotes::noteShowing").returns(false);
   172     expect("CpPhoneNotes::noteShowing").returns(false);
   166     expect("CpPhoneNotes::showGlobalProgressNote");
   173     expect("CpPhoneNotes::showGlobalProgressNote");
       
   174     m_divertpluginGroup->m_DataItemVoiceAllCalls->setContentWidgetData(
       
   175         "checkState", Qt::Checked);
   167     m_divertpluginGroup->m_DataItemVoiceAllCalls->thisItemClicked();
   176     m_divertpluginGroup->m_DataItemVoiceAllCalls->thisItemClicked();
       
   177     waitForQueueEmpty();
   168     QVERIFY(verify()); // Verify item click
   178     QVERIFY(verify()); // Verify item click
   169     PSCallDivertingCommand command;
   179     PSCallDivertingCommand command;
   170     command.iNumber = "12345";
   180     command.iNumber = "12345";
   171     command.iStatus = DivertingStatusActive;
   181     command.iStatus = DivertingStatusActive;
   172     command.iCondition = qvariant_cast<PsCallDivertingCondition>(
   182     command.iCondition = qvariant_cast<PsCallDivertingCondition>(
   173             m_divertpluginGroup->m_DataItemVoiceAllCalls->property("condition"));
   183             m_divertpluginGroup->m_DataItemVoiceAllCalls->property("condition"));
   174     command.iServiceGroup = ServiceGroupVoice;
   184     command.iServiceGroup = ServiceGroupVoice;
   175     expect("CpPhoneNotes::showGlobalNote");
   185     expect("CpPhoneNotes::showNotificationDialog");
   176     m_divertpluginGroup->handleDivertingChanged(command, false);
   186     m_divertpluginGroup->handleDivertingChanged(command, false);
   177     expect("CpPhoneNotes::cancelNote");
   187     expect("CpPhoneNotes::cancelNote");
   178     m_divertpluginGroup->divertRequestProcessed();
   188     m_divertpluginGroup->divertRequestProcessed();
   179     QVERIFY(verify()); // Verify result processing
   189     QVERIFY(verify()); // Verify result processing
   180 
   190 
   181     //except user selects one of the default numbers
   191     //except user selects one of the default numbers
   182     m_divertpluginGroup->m_DataItemVoiceAllCalls->setContentWidgetData("number","");
   192     m_divertpluginGroup->m_DataItemVoiceAllCalls->setContentWidgetData("text", "");
   183     m_divertpluginGroup->m_DataItemVoiceAllCalls->setContentWidgetData(
   193     m_divertpluginGroup->m_DataItemVoiceAllCalls->setContentWidgetData(
   184             "state", CpDivertSelectionCustomitem::Disabled);
   194         "checkState", Qt::Checked);
   185     appendAction("All voice calls:", selectItem, "0401234567");
   195     appendAction("txt_phone_setlabel_all_calls", selectItem, "0401234567");
   186     expect("PSetCallDivertingWrapper::getDefaultNumbers");
   196     expect("PSetCallDivertingWrapper::getDefaultNumbers");
   187     expect("SsSettingsWrapper::get");
   197     expect("SsSettingsWrapper::get");
   188     expect("PSetCallDivertingWrapper::setCallDiverting");
   198     expect("PSetCallDivertingWrapper::setCallDiverting");
   189     expect("CpPhoneNotes::noteShowing").returns(false);
   199     expect("CpPhoneNotes::noteShowing").returns(false);
   190     expect("CpPhoneNotes::showGlobalProgressNote");
   200     expect("CpPhoneNotes::showGlobalProgressNote");
   191     m_divertpluginGroup->m_DataItemVoiceAllCalls->thisItemClicked();
   201     m_divertpluginGroup->m_DataItemVoiceAllCalls->thisItemClicked();
       
   202     waitForQueueEmpty();
   192     command.iNumber = "0401234567";
   203     command.iNumber = "0401234567";
   193     command.iStatus = DivertingStatusActive;
   204     command.iStatus = DivertingStatusActive;
   194     command.iCondition = qvariant_cast<PsCallDivertingCondition>(
   205     command.iCondition = qvariant_cast<PsCallDivertingCondition>(
   195             m_divertpluginGroup->m_DataItemVoiceAllCalls->property("condition"));
   206             m_divertpluginGroup->m_DataItemVoiceAllCalls->property("condition"));
   196     command.iServiceGroup = ServiceGroupVoice;
   207     command.iServiceGroup = ServiceGroupVoice;
   197     expect("CpPhoneNotes::cancelNote");
   208     expect("CpPhoneNotes::cancelNote");
   198     expect("CpPhoneNotes::showGlobalNote");
   209     expect("CpPhoneNotes::showNotificationDialog");
   199     expect("PSetCallDivertingWrapper::setNewDefaultNumber").with(QString("0401234567"));
   210     expect("PSetCallDivertingWrapper::setNewDefaultNumber").with(QString("0401234567"));
   200     expect("Tools::voipSupported").returns(false);
       
   201     m_divertpluginGroup->handleDivertingChanged(command, true);
   211     m_divertpluginGroup->handleDivertingChanged(command, true);
   202     expect("CpPhoneNotes::cancelNote");
   212     expect("CpPhoneNotes::cancelNote");
   203     m_divertpluginGroup->divertRequestProcessed();
   213     m_divertpluginGroup->divertRequestProcessed();
   204     QVERIFY(verify());
   214     QVERIFY(verify());
   205     
   215     
   206     // Divert is disabled
   216     // Divert is disabled
   207     expect("SsSettingsWrapper::get");
   217     expect("SsSettingsWrapper::get");
   208     expect("PSetCallDivertingWrapper::setCallDiverting"); // Disable divert
   218     expect("PSetCallDivertingWrapper::setCallDiverting"); // Disable divert
   209     expect("CpPhoneNotes::noteShowing").returns(false);
   219     expect("CpPhoneNotes::noteShowing").returns(false);
   210     expect("CpPhoneNotes::showGlobalProgressNote");
   220     expect("CpPhoneNotes::showGlobalProgressNote");
       
   221     m_divertpluginGroup->m_DataItemVoiceAllCalls->setContentWidgetData(
       
   222         "checkState", Qt::Unchecked);
   211     m_divertpluginGroup->m_DataItemVoiceAllCalls->thisItemClicked();
   223     m_divertpluginGroup->m_DataItemVoiceAllCalls->thisItemClicked();
       
   224     waitForQueueEmpty();
   212     command.iNumber = "";
   225     command.iNumber = "";
   213     command.iStatus = DivertingStatusInactive;
   226     command.iStatus = DivertingStatusInactive;
   214     command.iCondition = qvariant_cast<PsCallDivertingCondition>(
   227     command.iCondition = qvariant_cast<PsCallDivertingCondition>(
   215             m_divertpluginGroup->m_DataItemVoiceAllCalls->property("condition"));
   228             m_divertpluginGroup->m_DataItemVoiceAllCalls->property("condition"));
   216     command.iServiceGroup = ServiceGroupVoice;
   229     command.iServiceGroup = ServiceGroupVoice;
   217     expect("CpPhoneNotes::showGlobalNote");
   230     expect("CpPhoneNotes::showNotificationDialog");
   218     m_divertpluginGroup->handleDivertingChanged(command, false);
   231     m_divertpluginGroup->handleDivertingChanged(command, false);
   219     expect("CpPhoneNotes::cancelNote");
   232     //expect("CpPhoneNotes::cancelNote");
   220     m_divertpluginGroup->divertRequestProcessed();
   233     m_divertpluginGroup->divertRequestProcessed();
   221     QVERIFY(verify());
   234     QVERIFY(verify());
   222     
   235     */
   223     //except user selects other number, inserts number and cancels
   236     //except user selects other number, inserts number and cancels
       
   237     /* BUG in framework (Crash in QGestureManager::getState due to QWeakPointer) */
       
   238     /*
   224     appendAction("All voice calls:", selectItem, "Other number");
   239     appendAction("All voice calls:", selectItem, "Other number");
   225     appendAction("Number:", insertText, "12345");
   240     appendAction("Number:", insertText, "12345");
   226     appendAction("Number:", selectAction, "Cancel");
   241     appendAction("Number:", selectAction, "Cancel");
   227     expect("PSetCallDivertingWrapper::getDefaultNumbers");
   242     expect("PSetCallDivertingWrapper::getDefaultNumbers");
   228     m_divertpluginGroup->m_DataItemVoiceAllCalls->thisItemClicked();
   243     m_divertpluginGroup->m_DataItemVoiceAllCalls->thisItemClicked();
   229     QVERIFY(verify());
   244     waitForQueueEmpty();
       
   245     QVERIFY(verify());
       
   246     */
   230 }
   247 }
   231 
   248 
   232 /*!
   249 /*!
   233   UT_CpDivertPlugin::t_itemShown
   250   UT_CpDivertPlugin::t_itemShown
   234  */
   251  */
   235 void UT_CpDivertPlugin::t_itemShown()
   252 void UT_CpDivertPlugin::t_itemShown()
   236 {
   253 {
   237     HbDataFormModel* model = 
       
   238             qobject_cast<HbDataFormModel*>(m_divertpluginGroup->model());
       
   239     
       
   240     expect("PSetCallDivertingWrapper::getCallDivertingStatus");
   254     expect("PSetCallDivertingWrapper::getCallDivertingStatus");
   241     expect("CpPhoneNotes::noteShowing").returns(false);
   255     expect("CpPhoneNotes::noteShowing").returns(false);
   242     expect("CpPhoneNotes::showGlobalProgressNote");
   256     expect("CpPhoneNotes::showGlobalProgressNote");
   243     m_divertpluginGroup->itemShown(
   257     m_divertpluginGroup->itemShown(
   244             model->indexFromItem(m_divertpluginGroup->m_DataItemVoiceAllCalls));
   258             m_dataForm->indexFromItem(m_divertpluginGroup->m_DataItemVoiceAllCalls));
   245     m_divertpluginGroup->itemShown(
   259     m_divertpluginGroup->itemShown(
   246             model->indexFromItem(m_divertpluginGroup->m_DataItemVoiceIfBusy));
   260             m_dataForm->indexFromItem(m_divertpluginGroup->m_DataItemVoiceIfBusy));
   247     m_divertpluginGroup->itemShown(
   261     m_divertpluginGroup->itemShown(
   248             model->indexFromItem(m_divertpluginGroup->m_DataItemVoiceIfNotAnswered));
   262             m_dataForm->indexFromItem(m_divertpluginGroup->m_DataItemVoiceIfNotAnswered));
   249     m_divertpluginGroup->itemShown(
   263     m_divertpluginGroup->itemShown(
   250             model->indexFromItem(m_divertpluginGroup->m_DataItemVoiceIfOutOfReach));
   264             m_dataForm->indexFromItem(m_divertpluginGroup->m_DataItemVoiceIfOutOfReach));
   251     m_divertpluginGroup->itemShown(
   265     m_divertpluginGroup->itemShown(
   252             model->indexFromItem(m_divertpluginGroup->m_DataItemVoiceIfNotAvailable));
   266             m_dataForm->indexFromItem(m_divertpluginGroup->m_DataItemVoiceIfNotAvailable));
   253     
   267     
   254     QList<PSCallDivertingStatus*> list;
   268     QList<PSCallDivertingStatus*> list;
   255     PSCallDivertingStatus divertStatus;
   269     PSCallDivertingStatus divertStatus;
   256     list.append(&divertStatus);
   270     list.append(&divertStatus);
   257     divertStatus.iCondition = qvariant_cast<PsCallDivertingCondition>(
   271     divertStatus.iCondition = qvariant_cast<PsCallDivertingCondition>(
   277     
   291     
   278     m_divertpluginGroup->divertRequestProcessed(); // Test overflow
   292     m_divertpluginGroup->divertRequestProcessed(); // Test overflow
   279 
   293 
   280     // Test, Do not check status again
   294     // Test, Do not check status again
   281     m_divertpluginGroup->itemShown(
   295     m_divertpluginGroup->itemShown(
   282             model->indexFromItem(m_divertpluginGroup->m_DataItemVoiceAllCalls));
   296             m_dataForm->indexFromItem(m_divertpluginGroup->m_DataItemVoiceAllCalls));
   283     m_divertpluginGroup->itemShown(
   297     m_divertpluginGroup->itemShown(
   284             model->indexFromItem(m_divertpluginGroup->m_DataItemVoiceIfBusy));
   298             m_dataForm->indexFromItem(m_divertpluginGroup->m_DataItemVoiceIfBusy));
   285     m_divertpluginGroup->itemShown(
   299     m_divertpluginGroup->itemShown(
   286             model->indexFromItem(m_divertpluginGroup->m_DataItemVoiceIfNotAnswered));
   300             m_dataForm->indexFromItem(m_divertpluginGroup->m_DataItemVoiceIfNotAnswered));
   287     m_divertpluginGroup->itemShown(
   301     m_divertpluginGroup->itemShown(
   288             model->indexFromItem(m_divertpluginGroup->m_DataItemVoiceIfOutOfReach));
   302             m_dataForm->indexFromItem(m_divertpluginGroup->m_DataItemVoiceIfOutOfReach));
   289     m_divertpluginGroup->itemShown(
   303     m_divertpluginGroup->itemShown(
   290             model->indexFromItem(m_divertpluginGroup->m_DataItemVoiceIfNotAvailable));
   304             m_dataForm->indexFromItem(m_divertpluginGroup->m_DataItemVoiceIfNotAvailable));
   291     
   305     
   292 
   306 
   293     QVERIFY(verify());
   307     QVERIFY(verify());
   294 }
   308 }
   295 
   309 
   296 /*!
   310 /*!
   297   UT_CpDivertPlugin::t_popUpTimerQuery
   311   UT_CpDivertPlugin::t_popUpTimerQuery
   298  */
   312  */
   299 void UT_CpDivertPlugin::t_popUpTimerQuery()
   313 void UT_CpDivertPlugin::t_popUpTimerQuery()
   300 {
   314 {
   301     appendAction("If not answered:", selectItem, "0401234567");
   315     const QString delayLnString("txt_phone_list_ln_seconds");
   302     appendAction("Time out", selectAction, "Cancel");
   316         
   303     expect("PSetCallDivertingWrapper::getDefaultNumbers");
   317     appendAction("txt_phone_setlabel_if_not_answered", selectItem, "txt_phone_list_enter_number_manually");
   304     m_divertpluginGroup->m_DataItemVoiceIfNotAnswered->setContentWidgetData("number", "");
   318     appendAction("txt_phone_info_number", insertText, "12345");
   305     m_divertpluginGroup->m_DataItemVoiceIfNotAnswered->setContentWidgetData(
   319     appendAction("txt_phone_info_number", selectAction, "OK");
   306             "state", CpDivertSelectionCustomitem::Disabled);
   320     appendAction("txt_phone_title_delay", selectItem, delayLnString);
   307     m_divertpluginGroup->m_DataItemVoiceIfNotAnswered->thisItemClicked();
   321     // expect user chooses other number and inserts number and timeout
   308     QVERIFY(verify());
       
   309     
       
   310     appendAction("If not answered:", selectItem, "Other number");
       
   311     appendAction("Number:", insertText, "12345");
       
   312     appendAction("Number:", selectAction, "OK");
       
   313     appendAction("Time out", selectItem, "15 second");
       
   314     //except user chooses other number and inserts number and timeout
       
   315     expect("PSetCallDivertingWrapper::getDefaultNumbers");    
   322     expect("PSetCallDivertingWrapper::getDefaultNumbers");    
   316     expect("SsSettingsWrapper::get");
   323     expect("SsSettingsWrapper::get");
   317     expect("PSetCallDivertingWrapper::setCallDiverting");
   324     expect("PSetCallDivertingWrapper::setCallDiverting");
       
   325     m_divertpluginGroup->m_DataItemVoiceIfNotAnswered->setContentWidgetData(
       
   326         "checkState", Qt::Checked);
   318     m_divertpluginGroup->m_DataItemVoiceIfNotAnswered->thisItemClicked();
   327     m_divertpluginGroup->m_DataItemVoiceIfNotAnswered->thisItemClicked();
       
   328     waitForQueueEmpty();
   319     PSCallDivertingCommand command;
   329     PSCallDivertingCommand command;
   320     command.iNumber = "12345";
   330     command.iNumber = "12345";
   321     command.iNoReplyTimer = 15;
   331     command.iNoReplyTimer = 15;
   322     command.iStatus = DivertingStatusActive;
   332     command.iStatus = DivertingStatusActive;
   323     command.iCondition = qvariant_cast<PsCallDivertingCondition>(
   333     command.iCondition = qvariant_cast<PsCallDivertingCondition>(
   324             m_divertpluginGroup->m_DataItemVoiceIfNotAnswered->property("condition"));
   334             m_divertpluginGroup->m_DataItemVoiceIfNotAnswered->property("condition"));
   325     command.iServiceGroup = ServiceGroupVoice;
   335     command.iServiceGroup = ServiceGroupVoice;
   326     expect("CpPhoneNotes::showGlobalNote");
   336     expect("CpPhoneNotes::showNotificationDialog");
   327     m_divertpluginGroup->handleDivertingChanged(command, false);
   337     m_divertpluginGroup->handleDivertingChanged(command, false);
   328     expect("CpPhoneNotes::cancelNote");
   338     expect("CpPhoneNotes::cancelNote");
   329     m_divertpluginGroup->divertRequestProcessed();
   339     m_divertpluginGroup->divertRequestProcessed();
   330     QVERIFY(verify());
   340     QVERIFY(verify());
   331     
   341     
   332     expect("SsSettingsWrapper::get");
   342     expect("SsSettingsWrapper::get");
   333     expect("PSetCallDivertingWrapper::setCallDiverting");
   343     expect("PSetCallDivertingWrapper::setCallDiverting");
       
   344     m_divertpluginGroup->m_DataItemVoiceIfNotAnswered->setContentWidgetData(
       
   345         "checkState", Qt::Unchecked);
   334     m_divertpluginGroup->m_DataItemVoiceIfNotAnswered->thisItemClicked();
   346     m_divertpluginGroup->m_DataItemVoiceIfNotAnswered->thisItemClicked();
       
   347     waitForQueueEmpty();
   335     command.iNumber = "";
   348     command.iNumber = "";
   336     command.iNoReplyTimer = 0;
   349     command.iNoReplyTimer = 0;
   337     command.iStatus = DivertingStatusInactive;
   350     command.iStatus = DivertingStatusInactive;
   338     command.iCondition = qvariant_cast<PsCallDivertingCondition>(
   351     command.iCondition = qvariant_cast<PsCallDivertingCondition>(
   339             m_divertpluginGroup->m_DataItemVoiceIfNotAnswered->property("condition"));
   352             m_divertpluginGroup->m_DataItemVoiceIfNotAnswered->property("condition"));
   340     command.iServiceGroup = ServiceGroupVoice;
   353     command.iServiceGroup = ServiceGroupVoice;
   341     expect("CpPhoneNotes::showGlobalNote");
   354     expect("CpPhoneNotes::showNotificationDialog");
   342     m_divertpluginGroup->handleDivertingChanged(command, false);
   355     m_divertpluginGroup->handleDivertingChanged(command, false);
   343     expect("CpPhoneNotes::cancelNote");
   356     expect("CpPhoneNotes::cancelNote");
   344     m_divertpluginGroup->divertRequestProcessed();
   357     m_divertpluginGroup->divertRequestProcessed();
   345     QVERIFY(verify());
   358     QVERIFY(verify());
   346 
   359 
   353 {
   366 {
   354     PSCallDivertingCommand c;
   367     PSCallDivertingCommand c;
   355     
   368     
   356     c.iStatus = DivertingStatusActive;
   369     c.iStatus = DivertingStatusActive;
   357     c.iServiceGroup = ServiceGroupAllTeleservices;
   370     c.iServiceGroup = ServiceGroupAllTeleservices;
   358     bool bRet = false;
   371     c.iNumber = QString("0401234567890");
   359     expect("PSetCallDivertingWrapper::setNewDefaultNumber");
   372     expect("PSetCallDivertingWrapper::setNewDefaultNumber");
   360     expect("Tools::voipSupported").returns(bRet);
       
   361     m_divertpluginGroup->handleDivertingChanged(c, true);
   373     m_divertpluginGroup->handleDivertingChanged(c, true);
   362     
   374     
   363     QVERIFY(verify());
   375     QVERIFY(verify());
   364     
   376     
   365     bRet = true;
       
   366     c.iServiceGroup = ServiceGroupAllTeleservices;
   377     c.iServiceGroup = ServiceGroupAllTeleservices;
   367     c.iCondition = DivertConditionUnconditional;
   378     c.iCondition = DivertConditionUnconditional;
       
   379     c.iNumber = QString("0401234567890");
   368     expect("PSetCallDivertingWrapper::setNewDefaultNumber");
   380     expect("PSetCallDivertingWrapper::setNewDefaultNumber");
   369     expect("Tools::voipSupported").returns(bRet);
       
   370     m_divertpluginGroup->handleDivertingChanged(c, false);
   381     m_divertpluginGroup->handleDivertingChanged(c, false);
   371     
   382     
   372     QVERIFY(verify());
   383     QVERIFY(verify());
   373     
   384     
   374     c.iStatus = DivertingStatusInactive;
   385     c.iStatus = DivertingStatusInactive;
   508     HbDialog* d = visibleDialog(dialog);
   519     HbDialog* d = visibleDialog(dialog);
   509     QVERIFY(d);
   520     QVERIFY(d);
   510     HbListWidget *list = qobject_cast<HbListWidget*>(d->contentWidget());
   521     HbListWidget *list = qobject_cast<HbListWidget*>(d->contentWidget());
   511     QVERIFY(list);
   522     QVERIFY(list);
   512     
   523     
   513     bool ok=true;
   524     bool ok=false;
   514     HbListWidgetItem *itemObject = 0;
   525     HbListWidgetItem *itemObject = 0;
   515     for (int i=0; i < list->count();i++) {
   526     for (int i=0; i < list->count();i++) {
   516         itemObject = list->item(i);
   527         itemObject = list->item(i);
   517         if (itemObject->text() == item) {
   528         if (itemObject->text() == item) {
   518             ok=true;
   529             ok=true;
   522             qDebug() << "selectItemFromListWidget: " << itemObject->text();
   533             qDebug() << "selectItemFromListWidget: " << itemObject->text();
   523             while (!spy.count()) {
   534             while (!spy.count()) {
   524                 QTest::qWait(50);
   535                 QTest::qWait(50);
   525             }
   536             }
   526             QTest::qWait(50);
   537             QTest::qWait(50);
       
   538             break;
   527         }
   539         }
   528         
   540         
   529     }
   541     }
   530     
   542     
   531     QVERIFY(ok);
   543     QVERIFY(ok);
   537 void UT_CpDivertPlugin::doAndVerifyAction(
   549 void UT_CpDivertPlugin::doAndVerifyAction(
   538         const QString& dialog, const QString& action )
   550         const QString& dialog, const QString& action )
   539 {
   551 {
   540     HbDialog* d = visibleDialog(dialog);
   552     HbDialog* d = visibleDialog(dialog);
   541     QVERIFY(d);
   553     QVERIFY(d);
   542     
       
   543     QAction* o;
   554     QAction* o;
   544     bool ok=false;
   555     bool ok=false;
   545     foreach (o, d->actions()) {
   556     foreach (o, d->actions()) {
   546         if (o->text() == action) {
   557         if (o->text() == action) {
   547             ok=true;
   558             ok=true;
   550             qDebug() << "doAndVerifyAction: " << o->text();
   561             qDebug() << "doAndVerifyAction: " << o->text();
   551             while (!spy.count()) {
   562             while (!spy.count()) {
   552                 QTest::qWait(50);
   563                 QTest::qWait(50);
   553             }
   564             }
   554             QTest::qWait(50);
   565             QTest::qWait(50);
       
   566             break;
   555         }
   567         }
   556     }
   568     }
   557     QVERIFY(ok);
   569     QVERIFY(ok);
   558 }
   570 }
   559 
   571 
   567     qDebug() << "timerEvent:" << currentTest;
   579     qDebug() << "timerEvent:" << currentTest;
   568     killTimer(event->timerId());
   580     killTimer(event->timerId());
   569     executeAction(*actionQueue.takeFirst());
   581     executeAction(*actionQueue.takeFirst());
   570     if (actionQueue.count()) {
   582     if (actionQueue.count()) {
   571         startTimer(1000);
   583         startTimer(1000);
       
   584     } else {
       
   585         emit queueEmpty();
   572     }
   586     }
   573 
   587 
   574     qDebug() << "timerEvent, OUT";
   588     qDebug() << "timerEvent, OUT";
   575 }
   589 }
   576 
   590 
       
   591 /*!
       
   592   UT_CpDivertPlugin::waitForQueueEmpty
       
   593  */
       
   594 void UT_CpDivertPlugin::waitForQueueEmpty()
       
   595 {
       
   596     if (actionQueue.count()) {
       
   597         QSignalSpy spy(this, SIGNAL(queueEmpty()));
       
   598         while (spy.count() == 0)
       
   599             QTest::qWait(200);
       
   600     }
       
   601 }
       
   602 
   577 QTEST_MAIN_S60UI(UT_CpDivertPlugin)
   603 QTEST_MAIN_S60UI(UT_CpDivertPlugin)