cellular/telephonysettings/xqbindings/psetwrapper/tsrc/ut_psetcallbarringwrapper/ut_psetcallbarringwrapper.cpp
changeset 15 d7fc66ccd6fb
parent 13 e32024264ebb
child 42 35488577e233
equal deleted inserted replaced
13:e32024264ebb 15:d7fc66ccd6fb
    72     {
    72     {
    73         Q_UNUSED(aSuccess);
    73         Q_UNUSED(aSuccess);
    74     }
    74     }
    75 };
    75 };
    76 
    76 
       
    77 void simulateLeaveL()
       
    78 {
       
    79     User::Leave(KErrGeneral);
       
    80 }
    77 
    81 
    78 /*!
    82 /*!
    79   UT_PSetCallBarringWrapper::UT_PSetCallBarringWrapper
    83   UT_PSetCallBarringWrapper::UT_PSetCallBarringWrapper
    80  */
    84  */
    81 UT_PSetCallBarringWrapper::UT_PSetCallBarringWrapper()
    85 UT_PSetCallBarringWrapper::UT_PSetCallBarringWrapper()
   323         .with(setting, EAllTeleAndBearer);
   327         .with(setting, EAllTeleAndBearer);
   324     m_wrapper->enableBarring(
   328     m_wrapper->enableBarring(
   325         ServiceGroupVoice, 
   329         ServiceGroupVoice, 
   326         PSetCallBarringWrapper::BarringTypeAllIncomingServices,
   330         PSetCallBarringWrapper::BarringTypeAllIncomingServices,
   327         QString("1234"));
   331         QString("1234"));
       
   332 
       
   333 // error handling    
       
   334     EXPECT(CPsetCallBarring::SetBarringL)
       
   335         .willOnce(invokeWithoutArguments(simulateLeaveL));
       
   336     EXPECT_EXCEPTION(
       
   337         m_wrapper->enableBarring(
       
   338             ServiceGroupVoice, 
       
   339             PSetCallBarringWrapper::BarringTypeAllIncomingServices,
       
   340             QString("1234"));
       
   341     )
   328     
   342     
   329     QVERIFY(verify());
   343     QVERIFY(verify());
   330 }
   344 }
   331 
   345 
   332 
   346 
   410     m_wrapper->disableBarring(
   424     m_wrapper->disableBarring(
   411         ServiceGroupVoice, 
   425         ServiceGroupVoice, 
   412         PSetCallBarringWrapper::BarringTypeAllIncomingServices,
   426         PSetCallBarringWrapper::BarringTypeAllIncomingServices,
   413         QString("1234"));
   427         QString("1234"));
   414     
   428     
       
   429 // error handling    
       
   430     EXPECT(CPsetCallBarring::SetBarringL)
       
   431         .willOnce(invokeWithoutArguments(simulateLeaveL));
       
   432     EXPECT_EXCEPTION(
       
   433         m_wrapper->disableBarring(
       
   434             ServiceGroupVoice, 
       
   435             PSetCallBarringWrapper::BarringTypeAllIncomingServices,
       
   436             QString("1234"));
       
   437     )
       
   438     
       
   439     QVERIFY(verify());
       
   440 }
       
   441 
       
   442 
       
   443 /*!
       
   444   UT_PSetCallBarringWrapper::t_changeBarringPassword
       
   445  */
       
   446 void UT_PSetCallBarringWrapper::t_changeBarringPassword()
       
   447 {
       
   448     QString oldPassword = "1234";
       
   449     QString newPassword = "4321";
       
   450     QString verifiedPassword = "4321";
       
   451     RMobilePhone::TMobilePhonePasswordChangeV2 passwordChange;
       
   452     passwordChange.iOldPassword.Copy(oldPassword.utf16());
       
   453     passwordChange.iNewPassword.Copy(newPassword.utf16());
       
   454     passwordChange.iVerifiedPassword.Copy(verifiedPassword.utf16());
       
   455     EXPECT(CPsetCallBarring::ChangePasswordL)
       
   456         .with(passwordChange);
       
   457     
       
   458     m_wrapper->changeBarringPassword(
       
   459         oldPassword, newPassword, verifiedPassword);
       
   460     
       
   461 // error handling    
       
   462     EXPECT(CPsetCallBarring::ChangePasswordL)
       
   463         .willOnce(invokeWithoutArguments(simulateLeaveL));
       
   464     EXPECT_EXCEPTION(
       
   465         m_wrapper->changeBarringPassword(
       
   466             oldPassword, newPassword, verifiedPassword);
       
   467     )
       
   468     
   415     QVERIFY(verify());
   469     QVERIFY(verify());
   416 }
   470 }
   417 
   471 
   418 
   472 
   419 /*!
   473 /*!
   482 /*!
   536 /*!
   483   UT_PSetCallBarringWrapper::t_CbPasswordChangedL
   537   UT_PSetCallBarringWrapper::t_CbPasswordChangedL
   484  */
   538  */
   485 void UT_PSetCallBarringWrapper::t_CbPasswordChangedL()
   539 void UT_PSetCallBarringWrapper::t_CbPasswordChangedL()
   486 {
   540 {
   487     // TODO: dummy test as functionality not yet implemented
       
   488     TBool success = EFalse;
   541     TBool success = EFalse;
   489     QT_TRAP_THROWING(
   542     QT_TRAP_THROWING(
   490         m_wrapper->m_privateImpl->CbPasswordChangedL(success);
   543         m_wrapper->m_privateImpl->CbPasswordChangedL(ETrue);
       
   544         m_wrapper->m_privateImpl->CbPasswordChangedL(EFalse);
   491     )
   545     )
   492 }
   546 }
   493 
   547 
   494 
   548 
   495 /*!
   549 /*!
   711     QCOMPARE(spy.at(0).at(3).toBool(), false);
   765     QCOMPARE(spy.at(0).at(3).toBool(), false);
   712 }
   766 }
   713 
   767 
   714 
   768 
   715 /*!
   769 /*!
       
   770   UT_PSetCallBarringWrapper::t_changeBarringPasswordRequestComplete
       
   771  */
       
   772 void UT_PSetCallBarringWrapper::t_changeBarringPasswordRequestComplete()
       
   773 {
       
   774     QSignalSpy spy(
       
   775         m_wrapper, 
       
   776         SIGNAL(barringPasswordChangeRequestCompleted(int)));
       
   777     
       
   778     QString oldPassword = "1234";
       
   779     QString newPassword = "4321";
       
   780     QString verifiedPassword = "4321";
       
   781     m_wrapper->changeBarringPassword(
       
   782         oldPassword, newPassword, verifiedPassword);
       
   783     
       
   784     m_wrapper->m_privateImpl->RequestComplete();
       
   785     
       
   786     if (qstrcmp(QTest::currentTestFunction(), "t_exceptionSafety") == 0) {
       
   787         // Signal emissions from RequestComplete will fail with exception safety 
       
   788         // tests so it's not possible to verify signal data.
       
   789         return;
       
   790     }
       
   791     
       
   792     QCOMPARE(spy.count(), 1);
       
   793     QCOMPARE(spy.at(0).at(0).toInt(), 0);
       
   794 }
       
   795 
       
   796 
       
   797 /*!
   716   UT_PSetCallBarringWrapper::t_RequestStatusChanged
   798   UT_PSetCallBarringWrapper::t_RequestStatusChanged
   717  */
   799  */
   718 void UT_PSetCallBarringWrapper::t_RequestStatusChanged()
   800 void UT_PSetCallBarringWrapper::t_RequestStatusChanged()
   719 {
   801 {
   720     m_wrapper->m_privateImpl->RequestStatusChanged(0);
   802     m_wrapper->m_privateImpl->RequestStatusChanged(0);