phonesettings/cpphonesettingsplugins/cptelephonyutils/tsrc/ut_cpplugincommon/ut_cpplugincommon.cpp
changeset 27 2f8f8080a020
parent 22 6bb1b21d2484
child 51 f39ed5e045e0
equal deleted inserted replaced
22:6bb1b21d2484 27:2f8f8080a020
   160 }
   160 }
   161 
   161 
   162 /*!
   162 /*!
   163   UT_CpPluginCommon::t_memleak
   163   UT_CpPluginCommon::t_memleak
   164  */
   164  */
   165 void UT_CpPluginCommon::t_convertEtelMobileServiceCode()
       
   166 {
       
   167     //
       
   168     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   169             RMobilePhone::EAllServices), AllTeleAndBearer);
       
   170     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   171             RMobilePhone::EAllTele), AllTele);
       
   172 
       
   173     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   174             RMobilePhone::EVoiceService), Telephony);
       
   175     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   176             RMobilePhone::ETelephony), Telephony);
       
   177     
       
   178     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   179             RMobilePhone::EAllDataTele), AllDataTele);
       
   180     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   181             RMobilePhone::EFaxService), Fax);
       
   182     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   183             RMobilePhone::EShortMessageService), Sms);
       
   184     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   185             RMobilePhone::EAllDataExSms), AllDataExSms);
       
   186     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   187             RMobilePhone::EAllTeleExcSms), AllTeleExcSms);
       
   188     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   189             RMobilePhone::EAllPlmnTele), AllPlmnTele);
       
   190     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   191             RMobilePhone::EPlmnTele1), PlmnTele1);
       
   192     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   193             RMobilePhone::EPlmnTele2), PlmnTele2);
       
   194     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   195             RMobilePhone::EPlmnTele3), PlmnTele3);
       
   196     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   197             RMobilePhone::EPlmnTele4), PlmnTele4);
       
   198     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   199             RMobilePhone::EPlmnTele5), PlmnTele5);
       
   200     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   201             RMobilePhone::EPlmnTele6), PlmnTele6);
       
   202     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   203             RMobilePhone::EPlmnTele7), PlmnTele7);
       
   204     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   205             RMobilePhone::EPlmnTele8), PlmnTele8);
       
   206     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   207             RMobilePhone::EPlmnTele9), PlmnTele9);
       
   208     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   209             RMobilePhone::EPlmnTeleA), PlmnTeleA);
       
   210     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   211             RMobilePhone::EPlmnTeleB), PlmnTeleB);
       
   212     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   213             RMobilePhone::EPlmnTeleC), PlmnTeleC);
       
   214     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   215             RMobilePhone::EPlmnTeleD), PlmnTeleD);
       
   216     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   217             RMobilePhone::EPlmnTeleE), PlmnTeleE);
       
   218     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   219             RMobilePhone::EPlmnTeleF), PlmnTeleF);
       
   220     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   221             RMobilePhone::EAllBearer), AllBearer);
       
   222     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   223             RMobilePhone::EAllAsync), AllAsync);
       
   224     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   225             RMobilePhone::EAllSync), AllSync);
       
   226     
       
   227     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   228             RMobilePhone::ECircuitDataService), SyncData);
       
   229     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   230             RMobilePhone::ESyncData), SyncData);
       
   231     
       
   232     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   233             RMobilePhone::EPacketDataService), AsyncData);
       
   234     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   235             RMobilePhone::EAsyncData), AsyncData);
       
   236     
       
   237     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   238             RMobilePhone::EPacketData), PacketData);
       
   239     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   240             RMobilePhone::EPadAccess), PadAccess);
       
   241     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   242             RMobilePhone::EAllPlmnBearer), AllPlmnBearer);
       
   243     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   244             RMobilePhone::EPlmnBearerServ1), PlmnBearerServ1);
       
   245     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   246             RMobilePhone::EPlmnBearerServ2), PlmnBearerServ2);
       
   247     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   248             RMobilePhone::EPlmnBearerServ3), PlmnBearerServ3);
       
   249     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   250             RMobilePhone::EPlmnBearerServ4), PlmnBearerServ4);
       
   251     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   252             RMobilePhone::EPlmnBearerServ5), PlmnBearerServ5);
       
   253     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   254             RMobilePhone::EPlmnBearerServ6), PlmnBearerServ6);
       
   255     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   256             RMobilePhone::EPlmnBearerServ7), PlmnBearerServ7);
       
   257     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   258             RMobilePhone::EPlmnBearerServ8), PlmnBearerServ8);
       
   259     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   260             RMobilePhone::EPlmnBearerServ9), PlmnBearerServ9);
       
   261     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   262             RMobilePhone::EPlmnBearerServA), PlmnBearerServA);
       
   263     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   264             RMobilePhone::EPlmnBearerServB), PlmnBearerServB);
       
   265     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   266             RMobilePhone::EPlmnBearerServC), PlmnBearerServC);
       
   267     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   268             RMobilePhone::EPlmnBearerServD), PlmnBearerServD);
       
   269     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   270             RMobilePhone::EPlmnBearerServE), PlmnBearerServE);
       
   271     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   272             RMobilePhone::EPlmnBearerServF), PlmnBearerServF);
       
   273     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   274             RMobilePhone::EAuxVoiceService), AltTele);
       
   275     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   276             RMobilePhone::EAltTele), AltTele);
       
   277     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   278             RMobilePhone::EServiceUnspecified), Unknown);
       
   279     // ??
       
   280     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   281             RMobilePhone::EVoiceGroupCall), Unknown);
       
   282     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   283             RMobilePhone::EVoiceBroadcast), Unknown);
       
   284     QCOMPARE(Tools::convertEtelMobileServiceCode(
       
   285             RMobilePhone::EAllGprsBearer), Unknown);
       
   286 
       
   287 }
       
   288 
       
   289 /*!
       
   290   UT_CpPluginCommon::t_memleak
       
   291  */
       
   292 void UT_CpPluginCommon::t_errorCodeTextMapping()
   165 void UT_CpPluginCommon::t_errorCodeTextMapping()
   293 {
   166 {
   294     QString text = "";
   167     QString text = "";
   295     Tools::errorCodeTextMapping(KErrGsmSSSubscriptionViolation, text);
   168     Tools::errorCodeTextMapping(KErrGsmSSSubscriptionViolation, text);
   296     QCOMPARE( text, QString(
   169     QCOMPARE( text, QString(
   297             "Barring operation not successful. Contact your service provider"));
   170             "txt_phone_info_barring_operation_not_successful"));
   298     Tools::errorCodeTextMapping(KErrGsmSSUnknownSubscriber, text);
   171     Tools::errorCodeTextMapping(KErrGsmSSUnknownSubscriber, text);
   299     QCOMPARE( text, QString(
   172     QCOMPARE( text, QString(
   300             "Not allowed"));
   173             "txt_phone_info_not_allowed"));
   301     Tools::errorCodeTextMapping(KErrGsmSSAbsentSubscriber, text);
   174     Tools::errorCodeTextMapping(KErrGsmSSAbsentSubscriber, text);
   302     QCOMPARE( text, QString(
   175     QCOMPARE( text, QString(
   303             "Not allowed"));
   176             "txt_phone_info_not_allowed"));
   304     Tools::errorCodeTextMapping(KErrGsmSSIllegalOperation, text);
   177     Tools::errorCodeTextMapping(KErrGsmSSIllegalOperation, text);
   305     QCOMPARE( text, QString(
   178     QCOMPARE( text, QString(
   306             "Not allowed"));
   179             "txt_phone_info_not_allowed"));
   307     Tools::errorCodeTextMapping(KErrGsmSSIllegalSubscriber, text);
   180     Tools::errorCodeTextMapping(KErrGsmSSIllegalSubscriber, text);
   308     QCOMPARE( text, QString(
   181     QCOMPARE( text, QString(
   309             "Not allowed"));
   182             "txt_phone_info_not_allowed"));
   310     Tools::errorCodeTextMapping(KErrGsmSSIllegalEquipment, text);
   183     Tools::errorCodeTextMapping(KErrGsmSSIllegalEquipment, text);
   311     QCOMPARE( text, QString(
   184     QCOMPARE( text, QString(
   312             "Not allowed"));
   185             "txt_phone_info_not_allowed"));
   313     Tools::errorCodeTextMapping(KErrGsmSSCallBarred, text);
   186     Tools::errorCodeTextMapping(KErrGsmSSCallBarred, text);
   314     QCOMPARE( text, QString(
   187     QCOMPARE( text, QString(
   315             "Not allowed"));
   188             "txt_phone_info_not_allowed"));
   316     Tools::errorCodeTextMapping(KErrGsmSSDataMissing, text);
   189     Tools::errorCodeTextMapping(KErrGsmSSDataMissing, text);
   317     QCOMPARE( text, QString(
   190     QCOMPARE( text, QString(
   318             "Not allowed"));
   191             "txt_phone_info_not_allowed"));
   319     Tools::errorCodeTextMapping(KErrGsmSSIncompatibility, text);
   192     Tools::errorCodeTextMapping(KErrGsmSSIncompatibility, text);
   320     QCOMPARE( text, QString(
   193     QCOMPARE( text, QString(
   321             "Services in conflict"));
   194             "Services in conflict"));
   322     Tools::errorCodeTextMapping(KErrGsmSSSystemFailure, text);
   195     Tools::errorCodeTextMapping(KErrGsmSSSystemFailure, text);
   323     QCOMPARE( text, QString(
   196     QCOMPARE( text, QString(
   324             "Result unknown"));
   197             "txt_phone_info_result_unknown"));
   325     Tools::errorCodeTextMapping(KErrGsmSSUnexpectedDataValue, text);
   198     Tools::errorCodeTextMapping(KErrGsmSSUnexpectedDataValue, text);
   326     QCOMPARE( text, QString(
   199     QCOMPARE( text, QString(
   327             "Request rejected"));
   200             "txt_phone_info_request_rejected"));
   328     Tools::errorCodeTextMapping(KErrGsmSSResourcesUnavailable, text);
   201     Tools::errorCodeTextMapping(KErrGsmSSResourcesUnavailable, text);
   329     QCOMPARE( text, QString(
   202     QCOMPARE( text, QString(
   330             "Request rejected"));
   203             "txt_phone_info_request_rejected"));
   331     Tools::errorCodeTextMapping(KErrGsmSSNegativePasswordCheck, text);
   204     Tools::errorCodeTextMapping(KErrGsmSSNegativePasswordCheck, text);
   332     QCOMPARE( text, QString(
   205     QCOMPARE( text, QString(
   333             "Password error"));
   206             "Password error"));
   334     Tools::errorCodeTextMapping(KErrGsmSSPasswordRegistrationFailure, text);
   207     Tools::errorCodeTextMapping(KErrGsmSSPasswordRegistrationFailure, text);
   335     QCOMPARE( text, QString(
   208     QCOMPARE( text, QString(
   336             "Password error"));
   209             "Password error"));
   337     Tools::errorCodeTextMapping(KErrGsmSSPasswordAttemptsViolation, text);
   210     Tools::errorCodeTextMapping(KErrGsmSSPasswordAttemptsViolation, text);
   338     QCOMPARE( text, QString(
   211     QCOMPARE( text, QString(
   339             "Password blocked"));
   212             "txt_phone_info_barring_password_blocked"));
   340     Tools::errorCodeTextMapping(KErrGsmSMSNoNetworkService, text);
   213     Tools::errorCodeTextMapping(KErrGsmSMSNoNetworkService, text);
   341     QCOMPARE( text, QString(
   214     QCOMPARE( text, QString(
   342             "No network coverage"));
   215             "No network coverage"));
   343     Tools::errorCodeTextMapping(KErrGsmNoService, text);
   216     Tools::errorCodeTextMapping(KErrGsmNoService, text);
   344     QCOMPARE( text, QString(
   217     QCOMPARE( text, QString(
   345             "No network coverage"));
   218             "No network coverage"));
   346     Tools::errorCodeTextMapping(KErrSsActivationDataLost, text);
   219     Tools::errorCodeTextMapping(KErrSsActivationDataLost, text);
   347     QCOMPARE( text, QString(
   220     QCOMPARE( text, QString(
   348             "Check network services"));
   221             "Check network services"));
   349     Tools::errorCodeTextMapping(KErrGsmSSUnknownAlphabet, text);
   222     Tools::errorCodeTextMapping(KErrGsmSSUnknownAlphabet, text);
   350     QCOMPARE( text, QString("Invalid phone number"));
   223     QCOMPARE( text, QString("txt_phone_info_invalid_phone_number"));
   351     
   224     
   352     expect("XQSysInfo::isSupported").returns(false);
   225     expect("XQSysInfo::isSupported").returns(false);
   353     Tools::errorCodeTextMapping(KErrGsmOfflineOpNotAllowed, text);
   226     Tools::errorCodeTextMapping(KErrGsmOfflineOpNotAllowed, text);
   354     QCOMPARE( text, QString(
   227     QCOMPARE( text, QString(
   355             "Not done"));
   228             "txt_phone_info_request_not_completed"));
   356     QVERIFY( verify() );
   229     QVERIFY( verify() );
   357     
   230     
   358     expect("XQSysInfo::isSupported").returns(true);
   231     expect("XQSysInfo::isSupported").returns(true);
   359     expect("XQSettingsManager::readItemValue").returns(QVariant(EBTSapConnected));
   232     expect("XQSettingsManager::readItemValue").returns(QVariant(EBTSapConnected));
   360     Tools::errorCodeTextMapping(KErrGsmOfflineOpNotAllowed, text);
   233     Tools::errorCodeTextMapping(KErrGsmOfflineOpNotAllowed, text);
   368     QCOMPARE( text, QString(
   241     QCOMPARE( text, QString(
   369             "Operation not possible in Off-line mode"));
   242             "Operation not possible in Off-line mode"));
   370     
   243     
   371     Tools::errorCodeTextMapping(-1, text);
   244     Tools::errorCodeTextMapping(-1, text);
   372     QCOMPARE( text, QString(
   245     QCOMPARE( text, QString(
   373             "Not done"));
   246             "txt_phone_info_request_not_completed"));
   374     
   247     
   375     QVERIFY( verify() );
   248     QVERIFY( verify() );
   376         
   249         
   377 }
   250 }
   378 
   251