phonesettings/cpphonesettingsplugins/barringplugin/tsrc/ut_barringplugingroup/ut_barringplugingroup.cpp
branchGCC_SURGE
changeset 51 f39ed5e045e0
parent 30 ebdbd102c78a
parent 45 6b911d05207e
equal deleted inserted replaced
40:bab96b7ed1a4 51:f39ed5e045e0
    33 }
    33 }
    34 
    34 
    35 
    35 
    36 const QString KCurrentPassword = "1234";
    36 const QString KCurrentPassword = "1234";
    37 void setCurrentPasswordParams(
    37 void setCurrentPasswordParams(
    38     const QString &title, 
    38         const QString &title,
    39     const QValidator &validator,
    39         const QValidator &validator,
    40     int maxPasswordLength,
    40         int maxPasswordLength)
    41     QString &password, 
       
    42     bool &ok)
       
    43 {
    41 {
    44     Q_UNUSED(title)
    42     Q_UNUSED(title)
    45     Q_UNUSED(validator)
    43     Q_UNUSED(validator)
    46     Q_UNUSED(maxPasswordLength)
    44     Q_UNUSED(maxPasswordLength)
    47     
       
    48     password = KCurrentPassword;
       
    49     ok = true;
       
    50 }
    45 }
    51 
    46 
    52 
    47 
    53 const QString KNewAndVerifiedPassword = "4321";
    48 const QString KNewAndVerifiedPassword = "4321";
    54 void setNewAndVerifiedPasswordParams(
    49 void setNewAndVerifiedPasswordParams(
    55     const QString &title, 
    50     const QString &title, 
    56     const QValidator &validator,
    51     const QValidator &validator,
    57     int maxPasswordLength,
    52     int maxPasswordLength)
    58     QString &password, 
       
    59     bool &ok)
       
    60 {
    53 {
    61     Q_UNUSED(title)
    54     Q_UNUSED(title)
    62     Q_UNUSED(validator)
    55     Q_UNUSED(validator)
    63     Q_UNUSED(maxPasswordLength)
    56     Q_UNUSED(maxPasswordLength)
    64     
       
    65     password = KNewAndVerifiedPassword;
       
    66     ok = true;
       
    67 }
    57 }
    68 
    58 
    69 
    59 
    70 void setPasswordParamsCancel(
    60 void setPasswordParamsCancel(
    71     const QString &title, 
    61     const QString &title, 
    72     const QValidator &validator,
    62     const QValidator &validator,
    73     int maxPasswordLength,
    63     int maxPasswordLength)
    74     QString &password, 
       
    75     bool &ok)
       
    76 {
    64 {
    77     Q_UNUSED(title)
    65     Q_UNUSED(title)
    78     Q_UNUSED(validator)
    66     Q_UNUSED(validator)
    79     Q_UNUSED(maxPasswordLength)
    67     Q_UNUSED(maxPasswordLength)
    80     Q_UNUSED(password)
       
    81     
       
    82     ok = false;
       
    83 }
    68 }
    84 
    69 
    85 
    70 
    86 /*!
    71 /*!
    87   UT_CpBarringPluginGroup::UT_CpBarringPluginGroup
    72   UT_CpBarringPluginGroup::UT_CpBarringPluginGroup
    99 /*!
    84 /*!
   100   UT_CpBarringPluginGroup::~UT_CpBarringPluginGroup
    85   UT_CpBarringPluginGroup::~UT_CpBarringPluginGroup
   101  */
    86  */
   102 UT_CpBarringPluginGroup::~UT_CpBarringPluginGroup()
    87 UT_CpBarringPluginGroup::~UT_CpBarringPluginGroup()
   103 {
    88 {
   104     delete m_barringpluginGroup;
       
   105     delete m_barringWrapperMock;
    89     delete m_barringWrapperMock;
       
    90     delete m_dataFormModel;
   106 }
    91 }
   107 
    92 
   108 
    93 
   109 /*!
    94 /*!
   110   UT_CpBarringPluginGroup::init
    95   UT_CpBarringPluginGroup::init
   120     
   105     
   121     CpItemDataHelper itemDataHelper;
   106     CpItemDataHelper itemDataHelper;
   122     m_barringpluginGroup = new CpBarringPluginGroup(itemDataHelper);
   107     m_barringpluginGroup = new CpBarringPluginGroup(itemDataHelper);
   123     
   108     
   124     m_dataFormModel = new HbDataFormModel();
   109     m_dataFormModel = new HbDataFormModel();
   125     m_barringpluginGroup->setModel(m_dataFormModel);
   110     m_dataFormModel->appendDataFormItem(m_barringpluginGroup);
       
   111     m_barringpluginGroup->m_model = m_dataFormModel;
   126     
   112     
   127     QVERIFY(verify());
   113     QVERIFY(verify());
   128     
   114     
   129     connect(
   115     connect(
   130         this, SIGNAL(simulateCheckStateChange(int)), 
   116         this, SIGNAL(simulateCheckStateChange(int)), 
   141     
   127     
   142     disconnect(
   128     disconnect(
   143         this, SIGNAL(simulateCheckStateChange(int)), 
   129         this, SIGNAL(simulateCheckStateChange(int)), 
   144         m_barringpluginGroup, SLOT(changeBarringStateRequested(int)));
   130         m_barringpluginGroup, SLOT(changeBarringStateRequested(int)));
   145     
   131     
   146     delete m_barringpluginGroup;
   132     delete m_dataFormModel;
   147     m_barringpluginGroup = NULL;
   133     m_dataFormModel = NULL;
   148     delete m_barringWrapperMock;
   134     delete m_barringWrapperMock;
   149     m_barringWrapperMock = NULL;
   135     m_barringWrapperMock = NULL;
   150     delete m_dataFormModel;
   136 
   151     m_dataFormModel = NULL;
       
   152 }
   137 }
   153 
   138 
   154 
   139 
   155 /*!
   140 /*!
   156   UT_CpBarringPluginGroup::t_memleak
   141   UT_CpBarringPluginGroup::t_memleak
   219     // simulate barring enable request
   204     // simulate barring enable request
   220     EXPECT(CpItemDataHelper::widgetFromModelIndex).returns(this).times(1);
   205     EXPECT(CpItemDataHelper::widgetFromModelIndex).returns(this).times(1);
   221     EXPECT(CpPhoneNotes::showPasswordQueryDialog)
   206     EXPECT(CpPhoneNotes::showPasswordQueryDialog)
   222         .willOnce(invoke(setCurrentPasswordParams));
   207         .willOnce(invoke(setCurrentPasswordParams));
   223     emit simulateCheckStateChange(Qt::Checked);
   208     emit simulateCheckStateChange(Qt::Checked);
       
   209     m_barringpluginGroup->completeBarringStateChangeRequestHandling(
       
   210             KCurrentPassword, true);
   224     
   211     
   225     // verify that already connected items are not enabled/connected again
   212     // verify that already connected items are not enabled/connected again
   226     EXPECT(CpItemDataHelper::removeConnection).times(1);
   213     EXPECT(CpItemDataHelper::removeConnection).times(1);
   227     EXPECT(CpItemDataHelper::addConnection).times(1);
   214     EXPECT(CpItemDataHelper::addConnection).times(1);
   228     m_barringpluginGroup->barringStatusRequestCompleted(
   215     m_barringpluginGroup->barringStatusRequestCompleted(
   229         errorCode,
   216         errorCode,
   230         basicServiceGroupIds, 
   217         basicServiceGroupIds, 
   231         PSetCallBarringWrapper::BarringStatusActive);
   218         PSetCallBarringWrapper::BarringStatusActive);
       
   219     
   232     QVERIFY(verify());
   220     QVERIFY(verify());
   233 }
   221 }
   234 
   222 
   235 
   223 
   236 /*!
   224 /*!
   337 // request completed succesfully -case
   325 // request completed succesfully -case
   338     EXPECT(CpItemDataHelper::widgetFromModelIndex).returns(this).times(1);
   326     EXPECT(CpItemDataHelper::widgetFromModelIndex).returns(this).times(1);
   339     EXPECT(CpPhoneNotes::showPasswordQueryDialog)
   327     EXPECT(CpPhoneNotes::showPasswordQueryDialog)
   340         .willOnce(invoke(setCurrentPasswordParams));
   328         .willOnce(invoke(setCurrentPasswordParams));
   341     EXPECT(CpPhoneNotes::cancelNote);
   329     EXPECT(CpPhoneNotes::cancelNote);
   342     EXPECT(CpPhoneNotes::showGlobalNote);
   330     EXPECT(CpPhoneNotes::showNotificationDialog);
   343     
   331     
   344     emit simulateCheckStateChange(Qt::Checked);
   332     emit simulateCheckStateChange(Qt::Checked);
       
   333     m_barringpluginGroup->completeBarringStateChangeRequestHandling(
       
   334             KCurrentPassword, true);
       
   335 
   345     m_barringpluginGroup->enableBarringRequestCompleted(
   336     m_barringpluginGroup->enableBarringRequestCompleted(
   346         0, 
   337         0, 
   347         PSetCallBarringWrapper::BarringTypeAllBarrings,
   338         PSetCallBarringWrapper::BarringTypeAllBarrings,
   348         PSetCallBarringWrapper::BarringStatusActive,
   339         PSetCallBarringWrapper::BarringStatusActive,
   349         false);
   340         false);
   361     EXPECT(CpItemDataHelper::addConnection);
   352     EXPECT(CpItemDataHelper::addConnection);
   362     EXPECT(CpPhoneNotes::cancelNote);
   353     EXPECT(CpPhoneNotes::cancelNote);
   363     EXPECT(CpPhoneNotes::showGlobalErrorNote);
   354     EXPECT(CpPhoneNotes::showGlobalErrorNote);
   364     
   355     
   365     emit simulateCheckStateChange(Qt::Checked);
   356     emit simulateCheckStateChange(Qt::Checked);
       
   357     m_barringpluginGroup->completeBarringStateChangeRequestHandling(
       
   358             KCurrentPassword, true);
       
   359     
   366     m_barringpluginGroup->enableBarringRequestCompleted(
   360     m_barringpluginGroup->enableBarringRequestCompleted(
   367         -1, 
   361         -1, 
   368         PSetCallBarringWrapper::BarringTypeAllBarrings,
   362         PSetCallBarringWrapper::BarringTypeAllBarrings,
   369         PSetCallBarringWrapper::BarringStatusActive,
   363         PSetCallBarringWrapper::BarringStatusActive,
   370         false);
   364         false);
   383     EXPECT(PSetCallBarringWrapper::barringStatus);
   377     EXPECT(PSetCallBarringWrapper::barringStatus);
   384     EXPECT(CpPhoneNotes::cancelNote).times(0);
   378     EXPECT(CpPhoneNotes::cancelNote).times(0);
   385     EXPECT(CpPhoneNotes::showGlobalNote).times(0);
   379     EXPECT(CpPhoneNotes::showGlobalNote).times(0);
   386     
   380     
   387     emit simulateCheckStateChange(Qt::Checked);
   381     emit simulateCheckStateChange(Qt::Checked);
       
   382     m_barringpluginGroup->completeBarringStateChangeRequestHandling(
       
   383             KCurrentPassword, true);
       
   384     
   388     m_barringpluginGroup->enableBarringRequestCompleted(
   385     m_barringpluginGroup->enableBarringRequestCompleted(
   389         0, 
   386         0, 
   390         PSetCallBarringWrapper::BarringTypeAllBarrings,
   387         PSetCallBarringWrapper::BarringTypeAllBarrings,
   391         PSetCallBarringWrapper::BarringStatusActive,
   388         PSetCallBarringWrapper::BarringStatusActive,
   392         false);
   389         false);
   403  */
   400  */
   404 void UT_CpBarringPluginGroup::t_enableBarringRequestCompletedUnknownBarring()
   401 void UT_CpBarringPluginGroup::t_enableBarringRequestCompletedUnknownBarring()
   405 {
   402 {
   406     // something very weird has happened and enable request completes for unknown
   403     // something very weird has happened and enable request completes for unknown
   407     // barring type.
   404     // barring type.
   408     HbDataFormModel *formModel = qobject_cast<HbDataFormModel*>(
       
   409         m_barringpluginGroup->model());
       
   410     HbDataFormModelItem *item = m_barringpluginGroup->childAt(5);
   405     HbDataFormModelItem *item = m_barringpluginGroup->childAt(5);
   411     QModelIndex modelIndex = formModel->indexFromItem(item);
   406     QModelIndex modelIndex = m_dataFormModel->indexFromItem(item);
   412     
   407     
   413     EXPECT(CpItemDataHelper::widgetFromModelIndex).with(modelIndex).returns(this);
   408     EXPECT(CpItemDataHelper::widgetFromModelIndex)
       
   409         .with<const QModelIndex &>(modelIndex).returns(this);
   414     EXPECT(CpPhoneNotes::showPasswordQueryDialog)
   410     EXPECT(CpPhoneNotes::showPasswordQueryDialog)
   415         .willOnce(invoke(setCurrentPasswordParams));
   411         .willOnce(invoke(setCurrentPasswordParams));
   416     EXPECT(CpPhoneNotes::cancelNote);
   412     EXPECT(CpPhoneNotes::cancelNote);
   417     EXPECT(CpPhoneNotes::showGlobalNote);
   413     EXPECT(CpPhoneNotes::showNotificationDialog);
   418     // completion of unknown barring type should not lead to updating
   414     // completion of unknown barring type should not lead to updating
   419     EXPECT(PSetCallBarringWrapper::barringStatus).times(0);
   415     EXPECT(PSetCallBarringWrapper::barringStatus).times(0);
   420     emit simulateCheckStateChange(Qt::Checked);
   416     emit simulateCheckStateChange(Qt::Checked);
       
   417     m_barringpluginGroup->completeBarringStateChangeRequestHandling(
       
   418             KCurrentPassword, true);
       
   419     
   421     m_barringpluginGroup->enableBarringRequestCompleted(
   420     m_barringpluginGroup->enableBarringRequestCompleted(
   422         0, 
   421         0, 
   423         PSetCallBarringWrapper::BarringTypeAllBarrings,
   422         PSetCallBarringWrapper::BarringTypeAllBarrings,
   424         PSetCallBarringWrapper::BarringStatusActive,
   423         PSetCallBarringWrapper::BarringStatusActive,
   425         false);
   424         false);
   442     QList<unsigned char> basicServiceGroupIds;
   441     QList<unsigned char> basicServiceGroupIds;
   443     EXPECT(CpItemDataHelper::widgetFromModelIndex).returns(this);
   442     EXPECT(CpItemDataHelper::widgetFromModelIndex).returns(this);
   444     EXPECT(CpPhoneNotes::showPasswordQueryDialog)
   443     EXPECT(CpPhoneNotes::showPasswordQueryDialog)
   445         .willOnce(invoke(setCurrentPasswordParams));
   444         .willOnce(invoke(setCurrentPasswordParams));
   446     emit simulateCheckStateChange(Qt::Checked);
   445     emit simulateCheckStateChange(Qt::Checked);
       
   446     m_barringpluginGroup->completeBarringStateChangeRequestHandling(
       
   447             KCurrentPassword, true);
       
   448     
   447     EXPECT(PSetCallBarringWrapper::barringStatus).with(
   449     EXPECT(PSetCallBarringWrapper::barringStatus).with(
   448         ServiceGroupVoice, PSetCallBarringWrapper::BarringTypeOutgoingInternational);
   450         ServiceGroupVoice, PSetCallBarringWrapper::BarringTypeOutgoingInternational);
   449     EXPECT(PSetCallBarringWrapper::barringStatus).with(
   451     EXPECT(PSetCallBarringWrapper::barringStatus).with(
   450         ServiceGroupVoice, 
   452         ServiceGroupVoice, 
   451         PSetCallBarringWrapper::BarringTypeOutgoingInternationalExceptToHomeCountry);
   453         PSetCallBarringWrapper::BarringTypeOutgoingInternationalExceptToHomeCountry);
   468   UT_CpBarringPluginGroup::t_enableBOICRequestCompletedStatusUpdate
   470   UT_CpBarringPluginGroup::t_enableBOICRequestCompletedStatusUpdate
   469  */
   471  */
   470 void UT_CpBarringPluginGroup::t_enableBOICRequestCompletedStatusUpdate()
   472 void UT_CpBarringPluginGroup::t_enableBOICRequestCompletedStatusUpdate()
   471 {
   473 {
   472     QModelIndex modelIndex;
   474     QModelIndex modelIndex;
   473     HbDataFormModel *formModel = qobject_cast<HbDataFormModel*>(
       
   474         m_barringpluginGroup->model());
       
   475     int numOfChilds = m_barringpluginGroup->childCount();
   475     int numOfChilds = m_barringpluginGroup->childCount();
   476     for (int childIndex = 0; childIndex < numOfChilds - 1; childIndex++) {
   476     for (int childIndex = 0; childIndex < numOfChilds - 1; childIndex++) {
   477         HbDataFormModelItem *item = m_barringpluginGroup->childAt(childIndex);
   477         HbDataFormModelItem *item = m_barringpluginGroup->childAt(childIndex);
   478         item->setContentWidgetData("checkState", QVariant(Qt::Checked));
   478         item->setContentWidgetData("checkState", QVariant(Qt::Checked));
   479         if (childIndex == 1) {
   479         if (childIndex == 1) {
   480             modelIndex = formModel->indexFromItem(item);
   480             modelIndex = m_dataFormModel->indexFromItem(item);
   481         }
   481         }
   482     }
   482     }
   483     
   483     
   484     QList<unsigned char> basicServiceGroupIds;
   484     QList<unsigned char> basicServiceGroupIds;
   485     EXPECT(CpItemDataHelper::widgetFromModelIndex).with(modelIndex).returns(this);
   485     EXPECT(CpItemDataHelper::widgetFromModelIndex).with(modelIndex).returns(this);
   486     EXPECT(CpPhoneNotes::showPasswordQueryDialog)
   486     EXPECT(CpPhoneNotes::showPasswordQueryDialog)
   487         .willOnce(invoke(setCurrentPasswordParams));
   487         .willOnce(invoke(setCurrentPasswordParams));
   488     emit simulateCheckStateChange(Qt::Checked);
   488     emit simulateCheckStateChange(Qt::Checked);
       
   489     m_barringpluginGroup->completeBarringStateChangeRequestHandling(
       
   490             KCurrentPassword, true);
       
   491     
   489     EXPECT(PSetCallBarringWrapper::barringStatus).with(
   492     EXPECT(PSetCallBarringWrapper::barringStatus).with(
   490         ServiceGroupVoice, 
   493         ServiceGroupVoice, 
   491         PSetCallBarringWrapper::BarringTypeAllOutgoing);
   494         PSetCallBarringWrapper::BarringTypeAllOutgoing);
   492     EXPECT(PSetCallBarringWrapper::barringStatus).with(
   495     EXPECT(PSetCallBarringWrapper::barringStatus).with(
   493         ServiceGroupVoice, 
   496         ServiceGroupVoice, 
   511   UT_CpBarringPluginGroup::t_enableBOICexHCRequestCompletedStatusUpdate
   514   UT_CpBarringPluginGroup::t_enableBOICexHCRequestCompletedStatusUpdate
   512  */
   515  */
   513 void UT_CpBarringPluginGroup::t_enableBOICexHCRequestCompletedStatusUpdate()
   516 void UT_CpBarringPluginGroup::t_enableBOICexHCRequestCompletedStatusUpdate()
   514 {
   517 {
   515     QModelIndex modelIndex;
   518     QModelIndex modelIndex;
   516     HbDataFormModel *formModel = qobject_cast<HbDataFormModel*>(
       
   517         m_barringpluginGroup->model());
       
   518     int numOfChilds = m_barringpluginGroup->childCount();
   519     int numOfChilds = m_barringpluginGroup->childCount();
   519     for (int childIndex = 0; childIndex < numOfChilds - 1; childIndex++) {
   520     for (int childIndex = 0; childIndex < numOfChilds - 1; childIndex++) {
   520         HbDataFormModelItem *item = m_barringpluginGroup->childAt(childIndex);
   521         HbDataFormModelItem *item = m_barringpluginGroup->childAt(childIndex);
   521         item->setContentWidgetData("checkState", QVariant(Qt::Checked));
   522         item->setContentWidgetData("checkState", QVariant(Qt::Checked));
   522         if (childIndex == 2) {
   523         if (childIndex == 2) {
   523             modelIndex = formModel->indexFromItem(item);
   524             modelIndex = m_dataFormModel->indexFromItem(item);
   524         }
   525         }
   525     }
   526     }
   526     
   527     
   527     QList<unsigned char> basicServiceGroupIds;
   528     QList<unsigned char> basicServiceGroupIds;
   528     EXPECT(CpItemDataHelper::widgetFromModelIndex).with(modelIndex).returns(this);
   529     EXPECT(CpItemDataHelper::widgetFromModelIndex).with(modelIndex).returns(this);
   529     EXPECT(CpPhoneNotes::showPasswordQueryDialog)
   530     EXPECT(CpPhoneNotes::showPasswordQueryDialog)
   530         .willOnce(invoke(setCurrentPasswordParams));
   531         .willOnce(invoke(setCurrentPasswordParams));
   531     emit simulateCheckStateChange(Qt::Checked);
   532     emit simulateCheckStateChange(Qt::Checked);
       
   533     m_barringpluginGroup->completeBarringStateChangeRequestHandling(
       
   534             KCurrentPassword, true);
       
   535     
   532     EXPECT(PSetCallBarringWrapper::barringStatus).with(
   536     EXPECT(PSetCallBarringWrapper::barringStatus).with(
   533         ServiceGroupVoice, 
   537         ServiceGroupVoice, 
   534         PSetCallBarringWrapper::BarringTypeAllOutgoing);
   538         PSetCallBarringWrapper::BarringTypeAllOutgoing);
   535     EXPECT(PSetCallBarringWrapper::barringStatus).with(
   539     EXPECT(PSetCallBarringWrapper::barringStatus).with(
   536         ServiceGroupVoice, 
   540         ServiceGroupVoice, 
   560   UT_CpBarringPluginGroup::t_enableBAICRequestCompletedStatusUpdate
   564   UT_CpBarringPluginGroup::t_enableBAICRequestCompletedStatusUpdate
   561  */
   565  */
   562 void UT_CpBarringPluginGroup::t_enableBAICRequestCompletedStatusUpdate()
   566 void UT_CpBarringPluginGroup::t_enableBAICRequestCompletedStatusUpdate()
   563 {
   567 {
   564     QModelIndex modelIndex;
   568     QModelIndex modelIndex;
   565     HbDataFormModel *formModel = qobject_cast<HbDataFormModel*>(
       
   566         m_barringpluginGroup->model());
       
   567     int numOfChilds = m_barringpluginGroup->childCount();
   569     int numOfChilds = m_barringpluginGroup->childCount();
   568     for (int childIndex = 0; childIndex < numOfChilds - 1; childIndex++) {
   570     for (int childIndex = 0; childIndex < numOfChilds - 1; childIndex++) {
   569         HbDataFormModelItem *item = m_barringpluginGroup->childAt(childIndex);
   571         HbDataFormModelItem *item = m_barringpluginGroup->childAt(childIndex);
   570         item->setContentWidgetData("checkState", QVariant(Qt::Checked));
   572         item->setContentWidgetData("checkState", QVariant(Qt::Checked));
   571         if (childIndex == 3) {
   573         if (childIndex == 3) {
   572             modelIndex = formModel->indexFromItem(item);
   574             modelIndex = m_dataFormModel->indexFromItem(item);
   573         }
   575         }
   574     }
   576     }
   575     
   577     
   576     QList<unsigned char> basicServiceGroupIds;
   578     QList<unsigned char> basicServiceGroupIds;
   577     EXPECT(CpItemDataHelper::widgetFromModelIndex).with(modelIndex).returns(this);
   579     EXPECT(CpItemDataHelper::widgetFromModelIndex).with(modelIndex).returns(this);
   578     EXPECT(CpPhoneNotes::showPasswordQueryDialog)
   580     EXPECT(CpPhoneNotes::showPasswordQueryDialog)
   579         .willOnce(invoke(setCurrentPasswordParams));
   581         .willOnce(invoke(setCurrentPasswordParams));
   580     emit simulateCheckStateChange(Qt::Checked);
   582     emit simulateCheckStateChange(Qt::Checked);
       
   583     m_barringpluginGroup->completeBarringStateChangeRequestHandling(
       
   584             KCurrentPassword, true);
       
   585     
   581     EXPECT(PSetCallBarringWrapper::barringStatus).with(
   586     EXPECT(PSetCallBarringWrapper::barringStatus).with(
   582         ServiceGroupVoice, 
   587         ServiceGroupVoice, 
   583         PSetCallBarringWrapper::BarringTypeIncomingWhenRoaming);
   588         PSetCallBarringWrapper::BarringTypeIncomingWhenRoaming);
   584     m_barringpluginGroup->enableBarringRequestCompleted(
   589     m_barringpluginGroup->enableBarringRequestCompleted(
   585         0, 
   590         0, 
   597   UT_CpBarringPluginGroup::t_enableBICRoamRequestCompletedStatusUpdate
   602   UT_CpBarringPluginGroup::t_enableBICRoamRequestCompletedStatusUpdate
   598  */
   603  */
   599 void UT_CpBarringPluginGroup::t_enableBICRoamRequestCompletedStatusUpdate()
   604 void UT_CpBarringPluginGroup::t_enableBICRoamRequestCompletedStatusUpdate()
   600 {
   605 {
   601     QModelIndex modelIndex;
   606     QModelIndex modelIndex;
   602     HbDataFormModel *formModel = qobject_cast<HbDataFormModel*>(
       
   603         m_barringpluginGroup->model());
       
   604     int numOfChilds = m_barringpluginGroup->childCount();
   607     int numOfChilds = m_barringpluginGroup->childCount();
   605     for (int childIndex = 0; childIndex < numOfChilds - 1; childIndex++) {
   608     for (int childIndex = 0; childIndex < numOfChilds - 1; childIndex++) {
   606         HbDataFormModelItem *item = m_barringpluginGroup->childAt(childIndex);
   609         HbDataFormModelItem *item = m_barringpluginGroup->childAt(childIndex);
   607         item->setContentWidgetData("checkState", QVariant(Qt::Checked));
   610         item->setContentWidgetData("checkState", QVariant(Qt::Checked));
   608         if (childIndex == 4) {
   611         if (childIndex == 4) {
   609             modelIndex = formModel->indexFromItem(item);
   612             modelIndex = m_dataFormModel->indexFromItem(item);
   610         }
   613         }
   611     }
   614     }
   612     
   615     
   613     QList<unsigned char> basicServiceGroupIds;
   616     QList<unsigned char> basicServiceGroupIds;
   614     EXPECT(CpItemDataHelper::widgetFromModelIndex).with(modelIndex).returns(this);
   617     EXPECT(CpItemDataHelper::widgetFromModelIndex).with(modelIndex).returns(this);
   615     EXPECT(CpPhoneNotes::showPasswordQueryDialog)
   618     EXPECT(CpPhoneNotes::showPasswordQueryDialog)
   616         .willOnce(invoke(setCurrentPasswordParams));
   619         .willOnce(invoke(setCurrentPasswordParams));
   617     emit simulateCheckStateChange(Qt::Checked);
   620     emit simulateCheckStateChange(Qt::Checked);
       
   621     m_barringpluginGroup->completeBarringStateChangeRequestHandling(
       
   622             KCurrentPassword, true);
       
   623     
   618     EXPECT(PSetCallBarringWrapper::barringStatus).with(
   624     EXPECT(PSetCallBarringWrapper::barringStatus).with(
   619         ServiceGroupVoice, 
   625         ServiceGroupVoice, 
   620         PSetCallBarringWrapper::BarringTypeAllIncoming);
   626         PSetCallBarringWrapper::BarringTypeAllIncoming);
   621     m_barringpluginGroup->enableBarringRequestCompleted(
   627     m_barringpluginGroup->enableBarringRequestCompleted(
   622         0, 
   628         0, 
   638 // request completed succesfully -case
   644 // request completed succesfully -case
   639     EXPECT(CpItemDataHelper::widgetFromModelIndex).returns(this).times(1);
   645     EXPECT(CpItemDataHelper::widgetFromModelIndex).returns(this).times(1);
   640     EXPECT(CpPhoneNotes::showPasswordQueryDialog)
   646     EXPECT(CpPhoneNotes::showPasswordQueryDialog)
   641         .willOnce(invoke(setCurrentPasswordParams));
   647         .willOnce(invoke(setCurrentPasswordParams));
   642     EXPECT(CpPhoneNotes::cancelNote);
   648     EXPECT(CpPhoneNotes::cancelNote);
   643     EXPECT(CpPhoneNotes::showGlobalNote);
   649     EXPECT(CpPhoneNotes::showNotificationDialog);
   644     emit simulateCheckStateChange(Qt::Unchecked);
   650     emit simulateCheckStateChange(Qt::Unchecked);
       
   651     m_barringpluginGroup->completeBarringStateChangeRequestHandling(
       
   652             KCurrentPassword, true);
   645     
   653     
   646     m_barringpluginGroup->disableBarringRequestCompleted(
   654     m_barringpluginGroup->disableBarringRequestCompleted(
   647         0, 
   655         0, 
   648         PSetCallBarringWrapper::BarringTypeAllBarrings,
   656         PSetCallBarringWrapper::BarringTypeAllBarrings,
   649         PSetCallBarringWrapper::BarringStatusActive,
   657         PSetCallBarringWrapper::BarringStatusActive,
   661     EXPECT(CpItemDataHelper::addConnection);
   669     EXPECT(CpItemDataHelper::addConnection);
   662     EXPECT(CpPhoneNotes::cancelNote);
   670     EXPECT(CpPhoneNotes::cancelNote);
   663     EXPECT(CpPhoneNotes::showGlobalErrorNote);
   671     EXPECT(CpPhoneNotes::showGlobalErrorNote);
   664     
   672     
   665     emit simulateCheckStateChange(Qt::Unchecked);
   673     emit simulateCheckStateChange(Qt::Unchecked);
       
   674     m_barringpluginGroup->completeBarringStateChangeRequestHandling(
       
   675             KCurrentPassword, true);
       
   676     
   666     m_barringpluginGroup->disableBarringRequestCompleted(
   677     m_barringpluginGroup->disableBarringRequestCompleted(
   667         -1, 
   678         -1, 
   668         PSetCallBarringWrapper::BarringTypeAllBarrings,
   679         PSetCallBarringWrapper::BarringTypeAllBarrings,
   669         PSetCallBarringWrapper::BarringStatusActive,
   680         PSetCallBarringWrapper::BarringStatusActive,
   670         false);
   681         false);
   678  */
   689  */
   679 void UT_CpBarringPluginGroup::t_barringPasswordChangeRequestCompleted()
   690 void UT_CpBarringPluginGroup::t_barringPasswordChangeRequestCompleted()
   680 {
   691 {
   681 // request completed with no error
   692 // request completed with no error
   682     EXPECT(CpPhoneNotes::cancelNote);
   693     EXPECT(CpPhoneNotes::cancelNote);
   683     EXPECT(CpPhoneNotes::showGlobalNote);
   694     EXPECT(CpPhoneNotes::showNotificationDialog);
   684     
   695     
   685     m_barringpluginGroup->barringPasswordChangeRequestCompleted(0);
   696     m_barringpluginGroup->barringPasswordChangeRequestCompleted(0);
   686     
   697     
   687     QVERIFY(verify());
   698     QVERIFY(verify());
   688 
   699 
   708     EXPECT(PSetCallBarringWrapper::enableBarring)
   719     EXPECT(PSetCallBarringWrapper::enableBarring)
   709         .with(ServiceGroupVoice, 
   720         .with(ServiceGroupVoice, 
   710             PSetCallBarringWrapper::BarringTypeAllOutgoing, KCurrentPassword);
   721             PSetCallBarringWrapper::BarringTypeAllOutgoing, KCurrentPassword);
   711     EXPECT(CpPhoneNotes::showGlobalProgressNote);
   722     EXPECT(CpPhoneNotes::showGlobalProgressNote);
   712     
   723     
   713     emit simulateCheckStateChange(Qt::Checked);
   724     HbDataFormModelItem *item = m_barringpluginGroup->childAt(0);
       
   725     item->setContentWidgetData("checkState", QVariant(Qt::Checked));
       
   726     emit simulateCheckStateChange(Qt::Checked);
       
   727     m_barringpluginGroup->completeBarringStateChangeRequestHandling(
       
   728             KCurrentPassword, true);
   714     
   729     
   715     QVERIFY(verify());
   730     QVERIFY(verify());
   716     
   731     
   717 // barring disable request case
   732 // barring disable request case
   718     EXPECT(CpItemDataHelper::widgetFromModelIndex).returns(this);
   733     EXPECT(CpItemDataHelper::widgetFromModelIndex).returns(this);
   721     EXPECT(PSetCallBarringWrapper::disableBarring)
   736     EXPECT(PSetCallBarringWrapper::disableBarring)
   722         .with(ServiceGroupVoice, 
   737         .with(ServiceGroupVoice, 
   723             PSetCallBarringWrapper::BarringTypeAllOutgoing, KCurrentPassword);
   738             PSetCallBarringWrapper::BarringTypeAllOutgoing, KCurrentPassword);
   724     EXPECT(CpPhoneNotes::showGlobalProgressNote);
   739     EXPECT(CpPhoneNotes::showGlobalProgressNote);
   725     
   740     
       
   741     item = m_barringpluginGroup->childAt(0);
       
   742     item->setContentWidgetData("checkState", QVariant(Qt::Unchecked));
   726     emit simulateCheckStateChange(Qt::Unchecked);
   743     emit simulateCheckStateChange(Qt::Unchecked);
       
   744     m_barringpluginGroup->completeBarringStateChangeRequestHandling(
       
   745             KCurrentPassword, true);
   727     
   746     
   728     QVERIFY(verify());
   747     QVERIFY(verify());
   729 
   748 
   730 // cancel pressed while querying barring password
   749 // cancel pressed while querying barring password
   731     EXPECT(CpItemDataHelper::widgetFromModelIndex).returns(this);
   750     EXPECT(CpItemDataHelper::widgetFromModelIndex).returns(this);
   734     EXPECT(CpItemDataHelper::removeConnection);
   753     EXPECT(CpItemDataHelper::removeConnection);
   735     EXPECT(CpItemDataHelper::addConnection);
   754     EXPECT(CpItemDataHelper::addConnection);
   736     EXPECT(PSetCallBarringWrapper::disableBarring).times(0);
   755     EXPECT(PSetCallBarringWrapper::disableBarring).times(0);
   737     EXPECT(CpPhoneNotes::showGlobalProgressNote).times(0);
   756     EXPECT(CpPhoneNotes::showGlobalProgressNote).times(0);
   738     
   757     
       
   758     item = m_barringpluginGroup->childAt(0);
       
   759     item->setContentWidgetData("checkState", QVariant(Qt::Unchecked));
   739     emit simulateCheckStateChange(Qt::Unchecked);
   760     emit simulateCheckStateChange(Qt::Unchecked);
       
   761     m_barringpluginGroup->completeBarringStateChangeRequestHandling(
       
   762                 "", false);
   740     
   763     
   741     QVERIFY(verify());
   764     QVERIFY(verify());
   742     
   765     
   743 // barring item not found case
   766 // barring item not found case
   744     EXPECT(PSetCallBarringWrapper::enableBarring).times(0);
   767     EXPECT(PSetCallBarringWrapper::enableBarring).times(0);
   755  */
   778  */
   756 void UT_CpBarringPluginGroup::t_changeBarringPasswordRequested()
   779 void UT_CpBarringPluginGroup::t_changeBarringPasswordRequested()
   757 {
   780 {
   758     connect(
   781     connect(
   759         this, SIGNAL(simulateEditPasswordButtonClicked(bool)), 
   782         this, SIGNAL(simulateEditPasswordButtonClicked(bool)), 
   760         m_barringpluginGroup, SLOT(changeBarringPasswordRequested(bool)));
   783         m_barringpluginGroup, SLOT(changeBarringPasswordRequested()));
   761     
   784     
   762     // cancel from current password query
   785     // cancel from current password query
   763     EXPECT(CpPhoneNotes::showPasswordQueryDialog)
   786     EXPECT(CpPhoneNotes::showPasswordQueryDialog)
   764         .willOnce(invoke(setPasswordParamsCancel));
   787         .willOnce(invoke(setPasswordParamsCancel));
   765     emit simulateEditPasswordButtonClicked(false);
   788     emit simulateEditPasswordButtonClicked(false);
       
   789     m_barringpluginGroup->changeBarringPasswordPhasesHandling("", false);
   766     QVERIFY(verify());
   790     QVERIFY(verify());
   767     
   791     
   768     // cancel from new password query
   792     // cancel from new password query
   769     EXPECT(CpPhoneNotes::showPasswordQueryDialog)
   793     EXPECT(CpPhoneNotes::showPasswordQueryDialog)
   770         .willOnce(invoke(setCurrentPasswordParams));
   794         .willOnce(invoke(setCurrentPasswordParams));
   771     EXPECT(CpPhoneNotes::showPasswordQueryDialog)
   795     EXPECT(CpPhoneNotes::showPasswordQueryDialog)
   772         .willOnce(invoke(setPasswordParamsCancel));
   796         .willOnce(invoke(setPasswordParamsCancel));
   773     emit simulateEditPasswordButtonClicked(false);
   797     emit simulateEditPasswordButtonClicked(false);
       
   798     m_barringpluginGroup->changeBarringPasswordPhasesHandling(
       
   799             KCurrentPassword, true);
       
   800     m_barringpluginGroup->changeBarringPasswordPhasesHandling(
       
   801             "", false);
   774     QVERIFY(verify());
   802     QVERIFY(verify());
   775     
   803     
   776     // cancel from verify new password query
   804     // cancel from verify new password query
   777     EXPECT(CpPhoneNotes::showPasswordQueryDialog)
   805     EXPECT(CpPhoneNotes::showPasswordQueryDialog)
   778         .willOnce(invoke(setCurrentPasswordParams));
   806         .willOnce(invoke(setCurrentPasswordParams));
   779     EXPECT(CpPhoneNotes::showPasswordQueryDialog)
   807     EXPECT(CpPhoneNotes::showPasswordQueryDialog)
   780         .willOnce(invoke(setNewAndVerifiedPasswordParams));
   808         .willOnce(invoke(setNewAndVerifiedPasswordParams));
   781     EXPECT(CpPhoneNotes::showPasswordQueryDialog)
   809     EXPECT(CpPhoneNotes::showPasswordQueryDialog)
   782         .willOnce(invoke(setPasswordParamsCancel));
   810         .willOnce(invoke(setPasswordParamsCancel));
   783     emit simulateEditPasswordButtonClicked(false);
   811     emit simulateEditPasswordButtonClicked(false);
       
   812     m_barringpluginGroup->changeBarringPasswordPhasesHandling(
       
   813             KCurrentPassword, true);
       
   814     m_barringpluginGroup->changeBarringPasswordPhasesHandling(
       
   815             KNewAndVerifiedPassword, true);
       
   816     m_barringpluginGroup->changeBarringPasswordPhasesHandling(
       
   817             "", false);
   784     QVERIFY(verify());
   818     QVERIFY(verify());
   785     
   819     
   786     // all data successfully queried
   820     // all data successfully queried
   787     EXPECT(CpPhoneNotes::showPasswordQueryDialog)
   821     EXPECT(CpPhoneNotes::showPasswordQueryDialog)
   788         .willOnce(invoke(setCurrentPasswordParams));
   822         .willOnce(invoke(setCurrentPasswordParams));
   791     EXPECT(CpPhoneNotes::showPasswordQueryDialog)
   825     EXPECT(CpPhoneNotes::showPasswordQueryDialog)
   792         .willOnce(invoke(setNewAndVerifiedPasswordParams));
   826         .willOnce(invoke(setNewAndVerifiedPasswordParams));
   793     EXPECT(PSetCallBarringWrapper::changeBarringPassword)
   827     EXPECT(PSetCallBarringWrapper::changeBarringPassword)
   794         .with(KCurrentPassword, KNewAndVerifiedPassword, KNewAndVerifiedPassword);
   828         .with(KCurrentPassword, KNewAndVerifiedPassword, KNewAndVerifiedPassword);
   795     emit simulateEditPasswordButtonClicked(false);
   829     emit simulateEditPasswordButtonClicked(false);
       
   830     m_barringpluginGroup->changeBarringPasswordPhasesHandling(
       
   831             KCurrentPassword, true);
       
   832     m_barringpluginGroup->changeBarringPasswordPhasesHandling(
       
   833             KNewAndVerifiedPassword, true);
       
   834     m_barringpluginGroup->changeBarringPasswordPhasesHandling(
       
   835             KNewAndVerifiedPassword, true);
   796     QVERIFY(verify());
   836     QVERIFY(verify());
   797 }
   837 }
   798 
   838 
   799 QTEST_MAIN_S60(UT_CpBarringPluginGroup)
   839 QTEST_MAIN_S60(UT_CpBarringPluginGroup)