phonesettings/cpphonesettingsplugins/divertplugin/tsrc/ut_cpdivertplugin/ut_cpdivertplugin.cpp
changeset 27 2f8f8080a020
parent 22 6bb1b21d2484
child 51 f39ed5e045e0
equal deleted inserted replaced
22:6bb1b21d2484 27:2f8f8080a020
    35 #define private public
    35 #define private public
    36 #include "cpdivertplugin.h"
    36 #include "cpdivertplugin.h"
    37 #include "cpdivertplugingroup.h"
    37 #include "cpdivertplugingroup.h"
    38 
    38 
    39 
    39 
    40 
    40 Q_DECLARE_METATYPE(PsCallDivertingCondition)
    41 Q_EXTERN_C const char * qt_plugin_query_verification_data();
    41 Q_EXTERN_C const char * qt_plugin_query_verification_data();
    42 Q_EXTERN_C ::QObject *  qt_plugin_instance();
    42 Q_EXTERN_C ::QObject *  qt_plugin_instance();
    43 
    43 
    44 class CPsetContainer
    44 class CPsetContainer
    45 {
    45 {
    46 public:
    46 public:
    47     CPsetContainer(){};
    47     CPsetContainer(){};
    48     ~CPsetContainer(){};
    48     ~CPsetContainer(){};
    49 };
    49 };
    50 
    50 
       
    51 void fillNumber(QString& number)
       
    52 {
       
    53     number = "1234567";
       
    54 }
       
    55     
       
    56 
    51 /*!
    57 /*!
    52   UT_CpDivertPlugin::UT_CpDivertPlugin
    58   UT_CpDivertPlugin::UT_CpDivertPlugin
    53  */
    59  */
    54 UT_CpDivertPlugin::UT_CpDivertPlugin() 
    60 UT_CpDivertPlugin::UT_CpDivertPlugin() 
    55     : m_divertplugin(NULL)
    61     : m_divertplugin(NULL)
    56 {
    62 {
    57     const char * verificationData = qt_plugin_query_verification_data();
    63     const char * verificationData = qt_plugin_query_verification_data();
       
    64 	qRegisterMetaType<PsCallDivertingCondition>(
       
    65         "PsCallDivertingCondition");
    58 }
    66 }
    59 
    67 
    60 /*!
    68 /*!
    61   UT_CpDivertPlugin::~UT_CpDivertPlugin
    69   UT_CpDivertPlugin::~UT_CpDivertPlugin
    62  */
    70  */
    63 UT_CpDivertPlugin::~UT_CpDivertPlugin()
    71 UT_CpDivertPlugin::~UT_CpDivertPlugin()
    64 {
    72 {
       
    73     delete m_divertpluginGroup;
       
    74     delete m_helper;
    65     delete m_divertplugin;
    75     delete m_divertplugin;
    66 }
    76 }
    67 
    77 
    68 /*!
    78 /*!
    69   UT_CpDivertPlugin::init
    79   UT_CpDivertPlugin::init
    93   UT_CpDivertPlugin::cleanup
   103   UT_CpDivertPlugin::cleanup
    94  */
   104  */
    95 void UT_CpDivertPlugin::cleanup()
   105 void UT_CpDivertPlugin::cleanup()
    96 {
   106 {
    97     reset();
   107     reset();
       
   108     delete m_divertpluginGroup;
       
   109     m_divertpluginGroup = NULL;
       
   110 
       
   111     delete m_helper;
       
   112     m_helper = NULL;
    98     
   113     
    99     delete m_divertplugin;
   114     delete m_divertplugin;
   100     m_divertplugin = NULL;
   115     m_divertplugin = NULL;
   101     
   116 
   102     delete m_divertpluginGroup;
       
   103     m_divertpluginGroup = NULL;
       
   104     
       
   105     delete m_helper;
       
   106     m_helper = NULL;
       
   107 }
   117 }
   108 
   118 
   109 /*!
   119 /*!
   110   UT_CpDivertPlugin::t_memleak
   120   UT_CpDivertPlugin::t_memleak
   111  */
   121  */
   123     CPsetContainer tmpContainer;
   133     CPsetContainer tmpContainer;
   124     PSetCallDivertingWrapper tmpDivWrapper(tmpContainer); 
   134     PSetCallDivertingWrapper tmpDivWrapper(tmpContainer); 
   125     
   135     
   126     expect("PSetWrapper::callDivertingWrapper").returns(&tmpDivWrapper); 
   136     expect("PSetWrapper::callDivertingWrapper").returns(&tmpDivWrapper); 
   127     
   137     
   128     CpDivertPlugin* p = (CpDivertPlugin*)qt_plugin_instance();
   138     CpDivertPlugin* p = (CpDivertPlugin*)qt_plugin_instance(); // Get static
   129     QList<CpSettingFormItemData*> list;
   139     QList<CpSettingFormItemData*> list;
   130     list.append(p->createSettingFormItemData(itemDataHelper));
   140     list.append(p->createSettingFormItemData(itemDataHelper));
   131     qDeleteAll(list);
   141     qDeleteAll(list);
   132     QVERIFY(verify());
   142     QVERIFY(verify());
   133 }
   143 }
   138 void UT_CpDivertPlugin::t_changeDivertingStateRequested()
   148 void UT_CpDivertPlugin::t_changeDivertingStateRequested()
   139 {
   149 {
   140     //except user cancels
   150     //except user cancels
   141     appendAction("All voice calls:", selectAction, "Cancel");
   151     appendAction("All voice calls:", selectAction, "Cancel");
   142     expect("PSetCallDivertingWrapper::getDefaultNumbers");
   152     expect("PSetCallDivertingWrapper::getDefaultNumbers");
   143     m_divertpluginGroup->m_DataItemAllVoiceCalls->setContentWidgetData("number", "");
   153     m_divertpluginGroup->m_DataItemVoiceAllCalls->setContentWidgetData("number", "");
   144     m_divertpluginGroup->m_DataItemAllVoiceCalls->setContentWidgetData(
   154     m_divertpluginGroup->m_DataItemVoiceAllCalls->setContentWidgetData(
   145             "state", CpDivertSelectionCustomitem::Disabled);
   155             "state", CpDivertSelectionCustomitem::Disabled);
   146     m_divertpluginGroup->m_DataItemAllVoiceCalls->thisItemClicked();
   156     m_divertpluginGroup->m_DataItemVoiceAllCalls->thisItemClicked();
   147     QVERIFY(verify());
   157     QVERIFY(verify());
   148     
   158     
   149     //except user selects vmb and inserts number
   159     //except user selects vmb
   150     appendAction("All voice calls:", selectItem, "txt_phone_setlabel_voice_mbx");
   160     appendAction("All voice calls:", selectItem, "txt_phone_setlabel_voice_mbx");
   151     appendAction("Voice mail box number:", insertText, "12345");
       
   152     appendAction("Voice mail box number:", selectAction, "OK");
       
   153     expect("PSetCallDivertingWrapper::getDefaultNumbers");
   161     expect("PSetCallDivertingWrapper::getDefaultNumbers");
       
   162     expect("PSetCallDivertingWrapper::getVoiceMailBoxNumber").willOnce(invoke(fillNumber));
   154     expect("SsSettingsWrapper::get");
   163     expect("SsSettingsWrapper::get");
   155     expect("PSetCallDivertingWrapper::setCallDiverting");
   164     expect("PSetCallDivertingWrapper::setCallDiverting");
   156     expect("CpPhoneNotes::noteShowing").returns(false);
   165     expect("CpPhoneNotes::noteShowing").returns(false);
   157     expect("CpPhoneNotes::showGlobalProgressNote");
   166     expect("CpPhoneNotes::showGlobalProgressNote");
   158     m_divertpluginGroup->m_DataItemAllVoiceCalls->thisItemClicked();
   167     m_divertpluginGroup->m_DataItemVoiceAllCalls->thisItemClicked();
       
   168     QVERIFY(verify()); // Verify item click
   159     PSCallDivertingCommand command;
   169     PSCallDivertingCommand command;
   160     command.iNumber = "12345";
   170     command.iNumber = "12345";
   161     command.iStatus = DivertingStatusActive;
   171     command.iStatus = DivertingStatusActive;
   162     command.iCondition = m_divertpluginGroup->m_DataItemAllVoiceCalls->condition();
   172     command.iCondition = qvariant_cast<PsCallDivertingCondition>(
       
   173             m_divertpluginGroup->m_DataItemVoiceAllCalls->property("condition"));
       
   174     command.iServiceGroup = ServiceGroupVoice;
   163     expect("CpPhoneNotes::showGlobalNote");
   175     expect("CpPhoneNotes::showGlobalNote");
   164     m_divertpluginGroup->handleDivertingChanged(command, false);
   176     m_divertpluginGroup->handleDivertingChanged(command, false);
   165     expect("CpPhoneNotes::cancelNote");
   177     expect("CpPhoneNotes::cancelNote");
   166     m_divertpluginGroup->divertRequestProcessed();
   178     m_divertpluginGroup->divertRequestProcessed();
   167     QVERIFY(verify());
   179     QVERIFY(verify()); // Verify result processing
   168 
   180 
   169     //except user selects one of the default numbers
   181     //except user selects one of the default numbers
   170     m_divertpluginGroup->m_DataItemAllVoiceCalls->setContentWidgetData("number","");
   182     m_divertpluginGroup->m_DataItemVoiceAllCalls->setContentWidgetData("number","");
   171     m_divertpluginGroup->m_DataItemAllVoiceCalls->setContentWidgetData(
   183     m_divertpluginGroup->m_DataItemVoiceAllCalls->setContentWidgetData(
   172             "state", CpDivertSelectionCustomitem::Disabled);
   184             "state", CpDivertSelectionCustomitem::Disabled);
   173     appendAction("All voice calls:", selectItem, "0401234567");
   185     appendAction("All voice calls:", selectItem, "0401234567");
   174     expect("PSetCallDivertingWrapper::getDefaultNumbers");
   186     expect("PSetCallDivertingWrapper::getDefaultNumbers");
   175     expect("SsSettingsWrapper::get");
   187     expect("SsSettingsWrapper::get");
   176     expect("PSetCallDivertingWrapper::setCallDiverting");
   188     expect("PSetCallDivertingWrapper::setCallDiverting");
   177     expect("CpPhoneNotes::noteShowing").returns(false);
   189     expect("CpPhoneNotes::noteShowing").returns(false);
   178     expect("CpPhoneNotes::showGlobalProgressNote");
   190     expect("CpPhoneNotes::showGlobalProgressNote");
   179     m_divertpluginGroup->m_DataItemAllVoiceCalls->thisItemClicked();
   191     m_divertpluginGroup->m_DataItemVoiceAllCalls->thisItemClicked();
   180     command.iNumber = "0401234567";
   192     command.iNumber = "0401234567";
   181     command.iStatus = DivertingStatusActive;
   193     command.iStatus = DivertingStatusActive;
   182     command.iCondition = m_divertpluginGroup->m_DataItemAllVoiceCalls->condition();
   194     command.iCondition = qvariant_cast<PsCallDivertingCondition>(
       
   195             m_divertpluginGroup->m_DataItemVoiceAllCalls->property("condition"));
       
   196     command.iServiceGroup = ServiceGroupVoice;
   183     expect("CpPhoneNotes::cancelNote");
   197     expect("CpPhoneNotes::cancelNote");
   184     expect("CpPhoneNotes::showGlobalNote");
   198     expect("CpPhoneNotes::showGlobalNote");
   185     expect("PSetCallDivertingWrapper::setNewDefaultNumber").with(QString("0401234567"));
   199     expect("PSetCallDivertingWrapper::setNewDefaultNumber").with(QString("0401234567"));
   186     expect("Tools::voipSupported").returns(false);
   200     expect("Tools::voipSupported").returns(false);
   187     m_divertpluginGroup->handleDivertingChanged(command, true);
   201     m_divertpluginGroup->handleDivertingChanged(command, true);
   192     // Divert is disabled
   206     // Divert is disabled
   193     expect("SsSettingsWrapper::get");
   207     expect("SsSettingsWrapper::get");
   194     expect("PSetCallDivertingWrapper::setCallDiverting"); // Disable divert
   208     expect("PSetCallDivertingWrapper::setCallDiverting"); // Disable divert
   195     expect("CpPhoneNotes::noteShowing").returns(false);
   209     expect("CpPhoneNotes::noteShowing").returns(false);
   196     expect("CpPhoneNotes::showGlobalProgressNote");
   210     expect("CpPhoneNotes::showGlobalProgressNote");
   197     m_divertpluginGroup->m_DataItemAllVoiceCalls->thisItemClicked();
   211     m_divertpluginGroup->m_DataItemVoiceAllCalls->thisItemClicked();
   198     command.iNumber = "";
   212     command.iNumber = "";
   199     command.iStatus = DivertingStatusInactive;
   213     command.iStatus = DivertingStatusInactive;
   200     command.iCondition = m_divertpluginGroup->m_DataItemAllVoiceCalls->condition();
   214     command.iCondition = qvariant_cast<PsCallDivertingCondition>(
       
   215             m_divertpluginGroup->m_DataItemVoiceAllCalls->property("condition"));
       
   216     command.iServiceGroup = ServiceGroupVoice;
   201     expect("CpPhoneNotes::showGlobalNote");
   217     expect("CpPhoneNotes::showGlobalNote");
   202     m_divertpluginGroup->handleDivertingChanged(command, false);
   218     m_divertpluginGroup->handleDivertingChanged(command, false);
   203     expect("CpPhoneNotes::cancelNote");
   219     expect("CpPhoneNotes::cancelNote");
   204     m_divertpluginGroup->divertRequestProcessed();
   220     m_divertpluginGroup->divertRequestProcessed();
   205     QVERIFY(verify());
   221     QVERIFY(verify());
   207     //except user selects other number, inserts number and cancels
   223     //except user selects other number, inserts number and cancels
   208     appendAction("All voice calls:", selectItem, "Other number");
   224     appendAction("All voice calls:", selectItem, "Other number");
   209     appendAction("Number:", insertText, "12345");
   225     appendAction("Number:", insertText, "12345");
   210     appendAction("Number:", selectAction, "Cancel");
   226     appendAction("Number:", selectAction, "Cancel");
   211     expect("PSetCallDivertingWrapper::getDefaultNumbers");
   227     expect("PSetCallDivertingWrapper::getDefaultNumbers");
   212     m_divertpluginGroup->m_DataItemAllVoiceCalls->thisItemClicked();
   228     m_divertpluginGroup->m_DataItemVoiceAllCalls->thisItemClicked();
   213     QVERIFY(verify());
   229     QVERIFY(verify());
   214 }
   230 }
   215 
   231 
   216 /*!
   232 /*!
   217   UT_CpDivertPlugin::t_itemShown
   233   UT_CpDivertPlugin::t_itemShown
   223     
   239     
   224     expect("PSetCallDivertingWrapper::getCallDivertingStatus");
   240     expect("PSetCallDivertingWrapper::getCallDivertingStatus");
   225     expect("CpPhoneNotes::noteShowing").returns(false);
   241     expect("CpPhoneNotes::noteShowing").returns(false);
   226     expect("CpPhoneNotes::showGlobalProgressNote");
   242     expect("CpPhoneNotes::showGlobalProgressNote");
   227     m_divertpluginGroup->itemShown(
   243     m_divertpluginGroup->itemShown(
   228             model->indexFromItem(m_divertpluginGroup->m_DataItemAllVoiceCalls));
   244             model->indexFromItem(m_divertpluginGroup->m_DataItemVoiceAllCalls));
   229     m_divertpluginGroup->itemShown(
   245     m_divertpluginGroup->itemShown(
   230             model->indexFromItem(m_divertpluginGroup->m_DataItemIfBusy));
   246             model->indexFromItem(m_divertpluginGroup->m_DataItemVoiceIfBusy));
   231     m_divertpluginGroup->itemShown(
   247     m_divertpluginGroup->itemShown(
   232             model->indexFromItem(m_divertpluginGroup->m_DataItemIfNotAnswered));
   248             model->indexFromItem(m_divertpluginGroup->m_DataItemVoiceIfNotAnswered));
   233     m_divertpluginGroup->itemShown(
   249     m_divertpluginGroup->itemShown(
   234             model->indexFromItem(m_divertpluginGroup->m_DataItemIfOutOfReach));
   250             model->indexFromItem(m_divertpluginGroup->m_DataItemVoiceIfOutOfReach));
   235     m_divertpluginGroup->itemShown(
   251     m_divertpluginGroup->itemShown(
   236             model->indexFromItem(m_divertpluginGroup->m_DataItemIfNotAvailable));
   252             model->indexFromItem(m_divertpluginGroup->m_DataItemVoiceIfNotAvailable));
   237     
   253     
   238     QList<PSCallDivertingStatus*> list;
   254     QList<PSCallDivertingStatus*> list;
   239     PSCallDivertingStatus divertStatus;
   255     PSCallDivertingStatus divertStatus;
   240     list.append(&divertStatus);
   256     list.append(&divertStatus);
   241     divertStatus.iCondition = m_divertpluginGroup->m_DataItemAllVoiceCalls->condition();
   257     divertStatus.iCondition = qvariant_cast<PsCallDivertingCondition>(
   242     m_divertpluginGroup->handleDivertingStatus(list, true);
   258             m_divertpluginGroup->m_DataItemVoiceAllCalls->property("condition"));
   243     m_divertpluginGroup->divertRequestProcessed();
   259     m_divertpluginGroup->handleDivertingStatus(list, true);
   244     divertStatus.iCondition = m_divertpluginGroup->m_DataItemIfBusy->condition();
   260     m_divertpluginGroup->divertRequestProcessed();
   245     m_divertpluginGroup->handleDivertingStatus(list, true);
   261     divertStatus.iCondition = qvariant_cast<PsCallDivertingCondition>(
   246     m_divertpluginGroup->divertRequestProcessed();
   262             m_divertpluginGroup->m_DataItemVoiceIfBusy->property("condition"));
   247     divertStatus.iCondition = m_divertpluginGroup->m_DataItemIfNotAnswered->condition();
   263     m_divertpluginGroup->handleDivertingStatus(list, true);
   248     m_divertpluginGroup->handleDivertingStatus(list, true);
   264     m_divertpluginGroup->divertRequestProcessed();
   249     m_divertpluginGroup->divertRequestProcessed();
   265     divertStatus.iCondition = qvariant_cast<PsCallDivertingCondition>(
   250     divertStatus.iCondition = m_divertpluginGroup->m_DataItemIfOutOfReach->condition();
   266             m_divertpluginGroup->m_DataItemVoiceIfNotAnswered->property("condition"));
   251     m_divertpluginGroup->handleDivertingStatus(list, true);
   267     m_divertpluginGroup->handleDivertingStatus(list, true);
   252     m_divertpluginGroup->divertRequestProcessed();
   268     m_divertpluginGroup->divertRequestProcessed();
   253     divertStatus.iCondition = m_divertpluginGroup->m_DataItemIfNotAvailable->condition();
   269     divertStatus.iCondition = qvariant_cast<PsCallDivertingCondition>(
       
   270             m_divertpluginGroup->m_DataItemVoiceIfOutOfReach->property("condition"));
       
   271     m_divertpluginGroup->handleDivertingStatus(list, true);
       
   272     m_divertpluginGroup->divertRequestProcessed();
       
   273     divertStatus.iCondition = qvariant_cast<PsCallDivertingCondition>(
       
   274             m_divertpluginGroup->m_DataItemVoiceIfNotAvailable->property("condition"));
   254     m_divertpluginGroup->handleDivertingStatus(list, true);
   275     m_divertpluginGroup->handleDivertingStatus(list, true);
   255     m_divertpluginGroup->divertRequestProcessed();
   276     m_divertpluginGroup->divertRequestProcessed();
   256     
   277     
   257     m_divertpluginGroup->divertRequestProcessed(); // Test overflow
   278     m_divertpluginGroup->divertRequestProcessed(); // Test overflow
   258 
   279 
   259     // Test, Do not check status again
   280     // Test, Do not check status again
   260     m_divertpluginGroup->itemShown(
   281     m_divertpluginGroup->itemShown(
   261             model->indexFromItem(m_divertpluginGroup->m_DataItemAllVoiceCalls));
   282             model->indexFromItem(m_divertpluginGroup->m_DataItemVoiceAllCalls));
   262     m_divertpluginGroup->itemShown(
   283     m_divertpluginGroup->itemShown(
   263             model->indexFromItem(m_divertpluginGroup->m_DataItemIfBusy));
   284             model->indexFromItem(m_divertpluginGroup->m_DataItemVoiceIfBusy));
   264     m_divertpluginGroup->itemShown(
   285     m_divertpluginGroup->itemShown(
   265             model->indexFromItem(m_divertpluginGroup->m_DataItemIfNotAnswered));
   286             model->indexFromItem(m_divertpluginGroup->m_DataItemVoiceIfNotAnswered));
   266     m_divertpluginGroup->itemShown(
   287     m_divertpluginGroup->itemShown(
   267             model->indexFromItem(m_divertpluginGroup->m_DataItemIfOutOfReach));
   288             model->indexFromItem(m_divertpluginGroup->m_DataItemVoiceIfOutOfReach));
   268     m_divertpluginGroup->itemShown(
   289     m_divertpluginGroup->itemShown(
   269             model->indexFromItem(m_divertpluginGroup->m_DataItemIfNotAvailable));
   290             model->indexFromItem(m_divertpluginGroup->m_DataItemVoiceIfNotAvailable));
   270     
   291     
   271 
   292 
   272     QVERIFY(verify());
   293     QVERIFY(verify());
   273 }
   294 }
   274 
   295 
   278 void UT_CpDivertPlugin::t_popUpTimerQuery()
   299 void UT_CpDivertPlugin::t_popUpTimerQuery()
   279 {
   300 {
   280     appendAction("If not answered:", selectItem, "0401234567");
   301     appendAction("If not answered:", selectItem, "0401234567");
   281     appendAction("Time out", selectAction, "Cancel");
   302     appendAction("Time out", selectAction, "Cancel");
   282     expect("PSetCallDivertingWrapper::getDefaultNumbers");
   303     expect("PSetCallDivertingWrapper::getDefaultNumbers");
   283     m_divertpluginGroup->m_DataItemIfNotAnswered->setContentWidgetData("number", "");
   304     m_divertpluginGroup->m_DataItemVoiceIfNotAnswered->setContentWidgetData("number", "");
   284     m_divertpluginGroup->m_DataItemIfNotAnswered->setContentWidgetData(
   305     m_divertpluginGroup->m_DataItemVoiceIfNotAnswered->setContentWidgetData(
   285             "state", CpDivertSelectionCustomitem::Disabled);
   306             "state", CpDivertSelectionCustomitem::Disabled);
   286     m_divertpluginGroup->m_DataItemIfNotAnswered->thisItemClicked();
   307     m_divertpluginGroup->m_DataItemVoiceIfNotAnswered->thisItemClicked();
   287     QVERIFY(verify());
   308     QVERIFY(verify());
   288     
   309     
   289     appendAction("If not answered:", selectItem, "Other number");
   310     appendAction("If not answered:", selectItem, "Other number");
   290     appendAction("Number:", insertText, "12345");
   311     appendAction("Number:", insertText, "12345");
   291     appendAction("Number:", selectAction, "OK");
   312     appendAction("Number:", selectAction, "OK");
   292     appendAction("Time out", selectItem, "15 second");
   313     appendAction("Time out", selectItem, "15 second");
   293     //except user chooses other number and inserts number and timeout
   314     //except user chooses other number and inserts number and timeout
   294     expect("PSetCallDivertingWrapper::getDefaultNumbers");    
   315     expect("PSetCallDivertingWrapper::getDefaultNumbers");    
   295     expect("SsSettingsWrapper::get");
   316     expect("SsSettingsWrapper::get");
   296     expect("PSetCallDivertingWrapper::setCallDiverting");
   317     expect("PSetCallDivertingWrapper::setCallDiverting");
   297     m_divertpluginGroup->m_DataItemIfNotAnswered->thisItemClicked();
   318     m_divertpluginGroup->m_DataItemVoiceIfNotAnswered->thisItemClicked();
   298     PSCallDivertingCommand command;
   319     PSCallDivertingCommand command;
   299     command.iNumber = "12345";
   320     command.iNumber = "12345";
   300     command.iNoReplyTimer = 15;
   321     command.iNoReplyTimer = 15;
   301     command.iStatus = DivertingStatusActive;
   322     command.iStatus = DivertingStatusActive;
   302     command.iCondition = m_divertpluginGroup->m_DataItemIfNotAnswered->condition();
   323     command.iCondition = qvariant_cast<PsCallDivertingCondition>(
       
   324             m_divertpluginGroup->m_DataItemVoiceIfNotAnswered->property("condition"));
       
   325     command.iServiceGroup = ServiceGroupVoice;
   303     expect("CpPhoneNotes::showGlobalNote");
   326     expect("CpPhoneNotes::showGlobalNote");
   304     m_divertpluginGroup->handleDivertingChanged(command, false);
   327     m_divertpluginGroup->handleDivertingChanged(command, false);
   305     expect("CpPhoneNotes::cancelNote");
   328     expect("CpPhoneNotes::cancelNote");
   306     m_divertpluginGroup->divertRequestProcessed();
   329     m_divertpluginGroup->divertRequestProcessed();
   307     QVERIFY(verify());
   330     QVERIFY(verify());
   308     
   331     
   309     expect("SsSettingsWrapper::get");
   332     expect("SsSettingsWrapper::get");
   310     expect("PSetCallDivertingWrapper::setCallDiverting");
   333     expect("PSetCallDivertingWrapper::setCallDiverting");
   311     m_divertpluginGroup->m_DataItemIfNotAnswered->thisItemClicked();
   334     m_divertpluginGroup->m_DataItemVoiceIfNotAnswered->thisItemClicked();
   312     command.iNumber = "";
   335     command.iNumber = "";
   313     command.iNoReplyTimer = 0;
   336     command.iNoReplyTimer = 0;
   314     command.iStatus = DivertingStatusInactive;
   337     command.iStatus = DivertingStatusInactive;
   315     command.iCondition = m_divertpluginGroup->m_DataItemIfNotAnswered->condition();
   338     command.iCondition = qvariant_cast<PsCallDivertingCondition>(
       
   339             m_divertpluginGroup->m_DataItemVoiceIfNotAnswered->property("condition"));
       
   340     command.iServiceGroup = ServiceGroupVoice;
   316     expect("CpPhoneNotes::showGlobalNote");
   341     expect("CpPhoneNotes::showGlobalNote");
   317     m_divertpluginGroup->handleDivertingChanged(command, false);
   342     m_divertpluginGroup->handleDivertingChanged(command, false);
   318     expect("CpPhoneNotes::cancelNote");
   343     expect("CpPhoneNotes::cancelNote");
   319     m_divertpluginGroup->divertRequestProcessed();
   344     m_divertpluginGroup->divertRequestProcessed();
   320     QVERIFY(verify());
   345     QVERIFY(verify());
   327 void UT_CpDivertPlugin::t_handleDivertingChanged()
   352 void UT_CpDivertPlugin::t_handleDivertingChanged()
   328 {
   353 {
   329     PSCallDivertingCommand c;
   354     PSCallDivertingCommand c;
   330     
   355     
   331     c.iStatus = DivertingStatusActive;
   356     c.iStatus = DivertingStatusActive;
       
   357     c.iServiceGroup = ServiceGroupAllTeleservices;
   332     bool bRet = false;
   358     bool bRet = false;
   333     expect("PSetCallDivertingWrapper::setNewDefaultNumber");
   359     expect("PSetCallDivertingWrapper::setNewDefaultNumber");
   334     expect("Tools::voipSupported").returns(bRet);
   360     expect("Tools::voipSupported").returns(bRet);
   335     m_divertpluginGroup->handleDivertingChanged(c, true);
   361     m_divertpluginGroup->handleDivertingChanged(c, true);
   336     
   362     
       
   363     QVERIFY(verify());
       
   364     
       
   365     bRet = true;
       
   366     c.iServiceGroup = ServiceGroupAllTeleservices;
       
   367     c.iCondition = DivertConditionUnconditional;
   337     expect("PSetCallDivertingWrapper::setNewDefaultNumber");
   368     expect("PSetCallDivertingWrapper::setNewDefaultNumber");
   338     bRet = true;
       
   339     c.iServiceGroup = ServiceGroupVoice;
       
   340     expect("Tools::voipSupported").returns(bRet);
   369     expect("Tools::voipSupported").returns(bRet);
   341     m_divertpluginGroup->handleDivertingChanged(c, false);
   370     m_divertpluginGroup->handleDivertingChanged(c, false);
   342     
   371     
       
   372     QVERIFY(verify());
       
   373     
   343     c.iStatus = DivertingStatusInactive;
   374     c.iStatus = DivertingStatusInactive;
       
   375     c.iCondition = DivertConditionBusy;
   344     m_divertpluginGroup->handleDivertingChanged(c, true);
   376     m_divertpluginGroup->handleDivertingChanged(c, true);
   345     m_divertpluginGroup->handleDivertingChanged(c, false);
   377     m_divertpluginGroup->handleDivertingChanged(c, false);
   346     
   378     
   347     c.iStatus = DivertingStatusNotRegistered;
   379     c.iStatus = DivertingStatusNotRegistered;
       
   380     c.iCondition = DivertConditionNoReply;
   348     m_divertpluginGroup->handleDivertingChanged(c, true);
   381     m_divertpluginGroup->handleDivertingChanged(c, true);
   349     
   382     
   350     c.iStatus = DivertingStatusNotProvisioned;
   383     c.iStatus = DivertingStatusNotProvisioned;
       
   384     c.iCondition = DivertConditionNotReachable;
   351     m_divertpluginGroup->handleDivertingChanged(c, true);
   385     m_divertpluginGroup->handleDivertingChanged(c, true);
   352     
   386     
   353     c.iStatus = DivertingStatusUnknown;
   387     c.iStatus = DivertingStatusUnknown;
       
   388     c.iCondition = DivertConditionAllCalls;
   354     m_divertpluginGroup->handleDivertingChanged(c, true);
   389     m_divertpluginGroup->handleDivertingChanged(c, true);
   355     
   390     
   356     c.iStatus = (PsCallDivertingStatus)5;
   391     c.iStatus = (PsCallDivertingStatus)5;
       
   392     c.iCondition = DivertConditionAllConditionalCases;
   357     m_divertpluginGroup->handleDivertingChanged(c, true);
   393     m_divertpluginGroup->handleDivertingChanged(c, true);
   358     
   394     
   359     QVERIFY(verify());
   395     QVERIFY(verify());
   360 }
   396 }
   361 
   397 
   413         const QString& dialog, actionType actionType, const QString& action)
   449         const QString& dialog, actionType actionType, const QString& action)
   414 {
   450 {
   415     if (!actionQueue.count()) {
   451     if (!actionQueue.count()) {
   416         startTimer(2000);
   452         startTimer(2000);
   417     }
   453     }
       
   454     qDebug() << "appendAction(" << dialog << actionType << action <<")";
   418     actionQueue.append(new dialogAction(dialog, actionType, action));
   455     actionQueue.append(new dialogAction(dialog, actionType, action));
   419 }
   456 }
   420 
   457 
   421 /*!
   458 /*!
   422   UT_CpDivertPlugin::executeAction
   459   UT_CpDivertPlugin::executeAction
   423  */
   460  */
   424 void UT_CpDivertPlugin::executeAction( const dialogAction &action )
   461 void UT_CpDivertPlugin::executeAction( const dialogAction &action )
   425 {
   462 {
       
   463     qDebug() << "executeAction(" << action.dialog << action.type << action.item <<")";
   426     switch (action.type) {
   464     switch (action.type) {
   427     case selectAction:
   465     case selectAction:
   428         doAndVerifyAction(action.dialog, action.item);
   466         doAndVerifyAction(action.dialog, action.item);
   429         break;
   467         break;
   430     case selectItem:
   468     case selectItem: