cellular/telephonysettings/xqbindings/psetwrapper/tsrc/ut_psetcallbarringwrapper/ut_psetcallbarringwrapper.cpp
changeset 15 d7fc66ccd6fb
parent 13 e32024264ebb
child 42 35488577e233
--- a/cellular/telephonysettings/xqbindings/psetwrapper/tsrc/ut_psetcallbarringwrapper/ut_psetcallbarringwrapper.cpp	Fri Apr 16 15:31:58 2010 +0300
+++ b/cellular/telephonysettings/xqbindings/psetwrapper/tsrc/ut_psetcallbarringwrapper/ut_psetcallbarringwrapper.cpp	Mon May 03 13:01:45 2010 +0300
@@ -74,6 +74,10 @@
     }
 };
 
+void simulateLeaveL()
+{
+    User::Leave(KErrGeneral);
+}
 
 /*!
   UT_PSetCallBarringWrapper::UT_PSetCallBarringWrapper
@@ -325,6 +329,16 @@
         ServiceGroupVoice, 
         PSetCallBarringWrapper::BarringTypeAllIncomingServices,
         QString("1234"));
+
+// error handling    
+    EXPECT(CPsetCallBarring::SetBarringL)
+        .willOnce(invokeWithoutArguments(simulateLeaveL));
+    EXPECT_EXCEPTION(
+        m_wrapper->enableBarring(
+            ServiceGroupVoice, 
+            PSetCallBarringWrapper::BarringTypeAllIncomingServices,
+            QString("1234"));
+    )
     
     QVERIFY(verify());
 }
@@ -412,6 +426,46 @@
         PSetCallBarringWrapper::BarringTypeAllIncomingServices,
         QString("1234"));
     
+// error handling    
+    EXPECT(CPsetCallBarring::SetBarringL)
+        .willOnce(invokeWithoutArguments(simulateLeaveL));
+    EXPECT_EXCEPTION(
+        m_wrapper->disableBarring(
+            ServiceGroupVoice, 
+            PSetCallBarringWrapper::BarringTypeAllIncomingServices,
+            QString("1234"));
+    )
+    
+    QVERIFY(verify());
+}
+
+
+/*!
+  UT_PSetCallBarringWrapper::t_changeBarringPassword
+ */
+void UT_PSetCallBarringWrapper::t_changeBarringPassword()
+{
+    QString oldPassword = "1234";
+    QString newPassword = "4321";
+    QString verifiedPassword = "4321";
+    RMobilePhone::TMobilePhonePasswordChangeV2 passwordChange;
+    passwordChange.iOldPassword.Copy(oldPassword.utf16());
+    passwordChange.iNewPassword.Copy(newPassword.utf16());
+    passwordChange.iVerifiedPassword.Copy(verifiedPassword.utf16());
+    EXPECT(CPsetCallBarring::ChangePasswordL)
+        .with(passwordChange);
+    
+    m_wrapper->changeBarringPassword(
+        oldPassword, newPassword, verifiedPassword);
+    
+// error handling    
+    EXPECT(CPsetCallBarring::ChangePasswordL)
+        .willOnce(invokeWithoutArguments(simulateLeaveL));
+    EXPECT_EXCEPTION(
+        m_wrapper->changeBarringPassword(
+            oldPassword, newPassword, verifiedPassword);
+    )
+    
     QVERIFY(verify());
 }
 
@@ -484,10 +538,10 @@
  */
 void UT_PSetCallBarringWrapper::t_CbPasswordChangedL()
 {
-    // TODO: dummy test as functionality not yet implemented
     TBool success = EFalse;
     QT_TRAP_THROWING(
-        m_wrapper->m_privateImpl->CbPasswordChangedL(success);
+        m_wrapper->m_privateImpl->CbPasswordChangedL(ETrue);
+        m_wrapper->m_privateImpl->CbPasswordChangedL(EFalse);
     )
 }
 
@@ -713,6 +767,34 @@
 
 
 /*!
+  UT_PSetCallBarringWrapper::t_changeBarringPasswordRequestComplete
+ */
+void UT_PSetCallBarringWrapper::t_changeBarringPasswordRequestComplete()
+{
+    QSignalSpy spy(
+        m_wrapper, 
+        SIGNAL(barringPasswordChangeRequestCompleted(int)));
+    
+    QString oldPassword = "1234";
+    QString newPassword = "4321";
+    QString verifiedPassword = "4321";
+    m_wrapper->changeBarringPassword(
+        oldPassword, newPassword, verifiedPassword);
+    
+    m_wrapper->m_privateImpl->RequestComplete();
+    
+    if (qstrcmp(QTest::currentTestFunction(), "t_exceptionSafety") == 0) {
+        // Signal emissions from RequestComplete will fail with exception safety 
+        // tests so it's not possible to verify signal data.
+        return;
+    }
+    
+    QCOMPARE(spy.count(), 1);
+    QCOMPARE(spy.at(0).at(0).toInt(), 0);
+}
+
+
+/*!
   UT_PSetCallBarringWrapper::t_RequestStatusChanged
  */
 void UT_PSetCallBarringWrapper::t_RequestStatusChanged()