TVerdict CSysUtilsGetLangSWVersionNoNewLinesStep::doTestStepL() { TInt err = SetTestPath(ETrue); if( err != KErrNone ) { ERR_PRINTF2(_L("Could not turn test path on. Error = %d"), err); SetTestStepResult(EAbort); return TestStepResult(); } INFO_PRINTF1(_L("Test path turned on.")); err = DeletePSProperties(); if( err != KErrNone ) { ERR_PRINTF2(_L("Could not delete P&S properties. Error = %d"), err); SetTestStepResult(EAbort); return TestStepResult(); } INFO_PRINTF1(_L("Deleted P&S properties successfully.")); _LIT16(KDummy,"xxxxx"); TBuf16<KSysUtilVersionTextLength> version; version.Insert(0,KDummy); err = SysUtil::GetLangSWVersion( version ); if ( err == KErrNone) { _LIT(KLangSw, "LangSW"); TPtrC16 line; TESTL( GetStringFromConfig(ConfigSection(), KLangSw, line) ); TBuf16<KSysUtilVersionTextLength> testBuf(line); if (version.Compare(testBuf)==0) { INFO_PRINTF1(_L("Got version ")); INFO_PRINTF1(version); } else { ERR_PRINTF1(_L("Version not correct")); INFO_PRINTF1(version); SetTestStepResult(EFail); } } else { ERR_PRINTF2(_L("Error code = %d"), err); SetTestStepResult(EFail); } return TestStepResult(); }
TVerdict CSysUtilsGetPRInformationStep::doTestStepL() { TInt err=KErrNone; _LIT16(KDummy,"xxxxx"); TBuf16<KSysUtilVersionTextLength> version; version.Insert(0,KDummy); TInt fileErr = CheckIsFileExist( _L("C:\\versions\\purpose.txt")); if(fileErr == KErrNone) { err = DeletePSProperties(); if(err != KErrNone) { ERR_PRINTF2(_L("Could not delete P&S properties. Error = %d"), err); SetTestStepResult(EAbort); return TestStepResult(); } INFO_PRINTF1(_L("Deleted P&S properties successfully.")); err = SetTestPath(ETrue); if( err != KErrNone ) { ERR_PRINTF2(_L("Could not turn test path off. Error = %d"), err); SetTestStepResult(EAbort); return TestStepResult(); } INFO_PRINTF1(_L("Test path turned off.")); err = SysUtil::GetPRInformation( version ); if ( err != KErrNone ) { ERR_PRINTF2(_L("Get PR Information failed. Error = %d"), err); SetTestStepResult(EFail); } else { //Get the information from the ini file _LIT(KPRInfo, "PRInfo"); TPtrC16 line; TESTL( GetStringFromConfig(ConfigSection(), KPRInfo, line) ); TBuf16<KSysUtilVersionTextLength> testBuf(line); //Parse the information from the ini file //Replace new-line patterns with real ones _LIT(KNewLinePattern, "\\n"); _LIT( KNewline, "\n" ); err = testBuf.Find(KNewLinePattern); while (err != KErrNotFound) { // err is a position testBuf.Replace(err, KNewLinePattern().Length(), KNewline ); err = testBuf.Find(KNewLinePattern); } if (version.Compare(testBuf)!=0) { ERR_PRINTF1(_L("PR Information formatted incorrectly")); INFO_PRINTF1(_L("From ini file: ")); INFO_PRINTF1(testBuf); INFO_PRINTF1(_L("From txt file: ")); INFO_PRINTF1(version); INFO_PRINTF2(_L("Comparison returned value %d"), version.Compare(testBuf)); SetTestStepResult(EFail); } else { INFO_PRINTF1(_L("PR Information formatted correctly")); INFO_PRINTF1(_L("from ini file ")); INFO_PRINTF1(testBuf); INFO_PRINTF1(_L("from txt file ")); INFO_PRINTF1(version); } } } else { ERR_PRINTF1(_L("purpose.txt is missing, should be included to base packets")); SetTestStepResult(EFail); } err = SetTestPath(EFalse); return TestStepResult(); }
/** Test Broadcast Messaging Functions This test step tests performs the following tests: Test 1 - RMobileBroadcastMessaging::GetCaps (sync) Test 2 - RMobileBroadcastMessaging::ReceiveMessage (test asynchronous call, then test call and cancel request) Test 3 - RMobileBroadcastMessaging::ReceiveMessage using V2params (test asynchronous call, then test call and cancel request) Test 4 - RMobileBroadcastMessaging::ReceiveMessage incorrect buffer size (buffer too big) (async call). Tests fix for INC072923. Test 5 - RMobileBroadcastMessaging::ReceiveMessage incorrect buffer size (buffer too small) (async call). Tests fix for INC072923. Test 6 - RMobileBroadcastMessaging::GetFilterSetting (sync) Test 7 - RMobileBroadcastMessaging::NotifyFilterSettingChange (test asynchronous call, then test call and cancel request) Test 8 - RMobileBroadcastMessaging::SetFilterSetting (test asynchronous call, then test call and cancel request) Test 9 - RMobileBroadcastMessaging::GetLanguageFilter (test asynchronous call, then test call and cancel request) Test 10 - RMobileBroadcastMessaging::SetLanguageFilter (test asynchronous call, then test call and cancel request) Test 11 - RMobileBroadcastMessaging::NotifyLanguageFilterChange (test asynchronous call, then test call and cancel request) Test 12 - Test CRetrieveMobilePhoneBroadcastIdList (test asynchronous call, then test call and cancel request) Test 13 - Test StoreBroadcastIdListL (test asynchronous call, then test call and cancel request) Test 14 - RMobileBroadcastMessaging::NotifyBroadcastIdListChange (test asynchronous call, then test call and cancel request) @return The verdict of the test step. */ enum TVerdict CTestBroadcastMessaging::doTestStepL() // // Test Broadcast Messaging Functions // { iTestCount=1; INFO_PRINTF1(_L("")); INFO_PRINTF1(_L("Test Mobile Broadcast Messaging Functionality")); // LOGTEXT(_L8("Test Mobile Broadcast Messaging Functionality")); RMobilePhone mmPhone; TInt ret=mmPhone.Open(iTelServer,DMMTSY_PHONE_NAME); TEST(ret==KErrNone); RMobileBroadcastMessaging cbsMessaging; ret=cbsMessaging.Open(mmPhone); TEST(ret==KErrNone); TRequestStatus reqStatus; // Get Broadcast messaging caps RMobileBroadcastMessaging::TMobileBroadcastCapsV1 cbsCaps; RMobileBroadcastMessaging::TMobileBroadcastCapsV1Pckg cbsCapsPckg(cbsCaps); TEST(cbsMessaging.GetCaps(cbsCapsPckg)==KErrNone); TEST(cbsCaps.iModeCaps==DMMTSY_BROADCAST_MESSAGING_MODE_CAPS); TEST(cbsCaps.iFilterCaps==DMMTSY_BROADCAST_MESSAGING_FILTER_CAPS); INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::GetCaps (sync) passed"), iTestCount++); // test.Next(_L("OK: RMobileBroadcastMessaging's Get Broadcast caps")); // Receiving broadcast messages RMobileBroadcastMessaging::TBroadcastPageData msgData; RMobileBroadcastMessaging::TMobileBroadcastAttributesV1 msgAtts; RMobileBroadcastMessaging::TMobileBroadcastAttributesV1Pckg msgAttsPckg(msgAtts); cbsMessaging.ReceiveMessage(reqStatus, msgData, msgAttsPckg); User::WaitForRequest(reqStatus); TEST(reqStatus.Int()==KErrNone); TEST(msgAtts.iFormat==DMMTSY_CBS_MESSAGE_PDU_FORMAT); TEST(msgAtts.iFlags==DMMTSY_BROADCAST_MESSAGING_ATT_FLAGS); TEST(msgData.Compare(DMMTSY_CBS_MESSAGE_PDU) == 0); // Test cancel cbsMessaging.ReceiveMessage(reqStatus, msgData, msgAttsPckg); cbsMessaging.CancelAsyncRequest(EMobileBroadcastMessagingReceiveMessage); User::WaitForRequest(reqStatus); TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel); if (reqStatus.Int()==KErrCancel) INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::ReceiveMessage (async & cancel (Cancelled Request)) passed"), iTestCount++); else { TEST(msgAtts.iFormat==DMMTSY_CBS_MESSAGE_PDU_FORMAT); TEST(msgAtts.iFlags==DMMTSY_BROADCAST_MESSAGING_ATT_FLAGS); TEST(msgData.Compare(DMMTSY_CBS_MESSAGE_PDU) == 0); INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::ReceiveMessage (async & cancel (Request Not Cancelled)) passed"), iTestCount++); } // test.Next(_L("OK: RMobileBroadcastMessaging's Receive Message")); // Receiving broadcast messages V2 RMobileBroadcastMessaging::TBroadcastPageData msgPage; RMobileBroadcastMessaging::TMobileBroadcastAttributesV2 msgAttsV2; RMobileBroadcastMessaging::TMobileBroadcastAttributesV2Pckg msgAttsV2Pckg(msgAttsV2); cbsMessaging.ReceiveMessage(reqStatus, msgPage, msgAttsV2Pckg); User::WaitForRequest(reqStatus); TEST(reqStatus.Int()==KErrNone); TEST(msgAttsV2.iFormat==DMMTSY_CBS_MESSAGE_PDU_FORMAT); TEST(msgAttsV2.iFlags==DMMTSY_BROADCAST_MESSAGING_ATT_FLAGS); TEST(msgPage.Compare(DMMTSY_CBS_MESSAGE_PDU) == 0); // Test cancel cbsMessaging.ReceiveMessage(reqStatus, msgPage, msgAttsV2Pckg); cbsMessaging.CancelAsyncRequest(EMobileBroadcastMessagingReceiveMessage); User::WaitForRequest(reqStatus); TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel); if (reqStatus.Int()==KErrCancel) INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::ReceiveMessage V2params (async & cancel (Cancelled Request)) passed"), iTestCount++); else { TEST(msgAttsV2.iFormat==DMMTSY_CBS_MESSAGE_PDU_FORMAT); TEST(msgAttsV2.iFlags==DMMTSY_BROADCAST_MESSAGING_ATT_FLAGS); TEST(msgPage.Compare(DMMTSY_CBS_MESSAGE_PDU) == 0); INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::ReceiveMessage V2params (async & cancel (Request Not Cancelled)) passed"), iTestCount++); } // Receiving broadcast messages when buffer size incorrect // Test if client uses buffer of size not equal to // RMobileBroadcastMessaging::TBroadcastPageData to hold the // received message const TInt KIncorrectBroadcastPageSizeTooBig = 255; TBuf8<KIncorrectBroadcastPageSizeTooBig> incorrectMsgPageTooBig; RMobileBroadcastMessaging::TMobileBroadcastAttributesV1 msgAttributesV1; RMobileBroadcastMessaging::TMobileBroadcastAttributesV1Pckg msgAttributesV1Pckg(msgAttributesV1); cbsMessaging.ReceiveMessage(reqStatus, incorrectMsgPageTooBig, msgAttributesV1Pckg); User::WaitForRequest(reqStatus); // RMobileBroadcastMessaging::ReceiveMessage should detect // incorrect buffer size and return KErrArgument TEST(reqStatus.Int()==KErrArgument); if (reqStatus.Int()==KErrArgument) INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::ReceiveMessage incorrect buffer size (too big) passed"), iTestCount++); else { INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::ReceiveMessage incorrect buffer size (too big) failed"), iTestCount++); INFO_PRINTF3(_L("reqStatus = %d, expected reqStatus = %d"), reqStatus.Int(), KErrArgument); } const TInt KIncorrectBroadcastPageSizeTooSmall = 35; TBuf8<KIncorrectBroadcastPageSizeTooSmall> incorrectMsgPageTooSmall; cbsMessaging.ReceiveMessage(reqStatus, incorrectMsgPageTooSmall, msgAttributesV1Pckg); User::WaitForRequest(reqStatus); // RMobileBroadcastMessaging::ReceiveMessage should detect // incorrect buffer size and return KErrArgument TEST(reqStatus.Int()==KErrArgument); if (reqStatus.Int()==KErrArgument) INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::ReceiveMessage incorrect buffer size (too small) passed"), iTestCount++); else { INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::ReceiveMessage incorrect buffer size (too small) failed"), iTestCount++); INFO_PRINTF3(_L("reqStatus = %d, expected reqStatus = %d"), reqStatus.Int(), KErrArgument); } // Get/Set/Notify broadcast receive setting RMobileBroadcastMessaging::TMobilePhoneBroadcastFilter setting; TEST(cbsMessaging.GetFilterSetting(setting)==KErrNone); TEST(setting==DMMTSY_BROADCAST_RECEIVE_SETTING1); INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::GetFilterSetting (sync) passed"), iTestCount++); // NotifyFilterSettingChange // Asynchronous cbsMessaging.NotifyFilterSettingChange(reqStatus, setting); User::WaitForRequest(reqStatus); TEST(reqStatus.Int()==KErrNone); TEST(setting==DMMTSY_BROADCAST_RECEIVE_SETTING2); // Asynchronous & cancel cbsMessaging.NotifyFilterSettingChange(reqStatus, setting); cbsMessaging.CancelAsyncRequest(EMobileBroadcastMessagingNotifyFilterSettingChange); User::WaitForRequest(reqStatus); TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel); if (reqStatus.Int()==KErrCancel) { INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::NotifyFilterSettingChange (async & cancel (Cancelled Request)) passed"), iTestCount++); // The cancel function currently alters the value of setting. This occurs because the Tsy // calls completeReq when cancelling requests. This need to verified to determine whether this // behaviour is correct. So the rest of the script can proceed, reset setting. setting=DMMTSY_BROADCAST_RECEIVE_SETTING2; } else { INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::NotifyFilterSettingChange (async & cancel (Request Not Cancelled)) passed"), iTestCount++); TEST(setting==DMMTSY_BROADCAST_RECEIVE_SETTING2); } // set filter setting - async cbsMessaging.SetFilterSetting(reqStatus, setting); User::WaitForRequest(reqStatus); TEST(reqStatus.Int()==KErrNone); // asynchronous & cancel cbsMessaging.SetFilterSetting(reqStatus, setting); cbsMessaging.CancelAsyncRequest(EMobileBroadcastMessagingSetFilterSetting); User::WaitForRequest(reqStatus); TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel); if (reqStatus.Int()==KErrCancel) INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::SetFilterSetting (async & cancel (Cancelled Request)) passed"), iTestCount++); else INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::SetFilterSetting (async & cancel (Request Not Cancelled)) passed"), iTestCount++); // test.Next(_L("OK: RMobileBroadcastMessaging's Broadcast receive setting")); TBuf16<16> setLangFilter(DMMTSY_CBS_MESSAGE_LANGUAGE_FILTER); TBuf16<16> getLangFilter; // Test Get Language Filter // asynchronous cbsMessaging.GetLanguageFilter(reqStatus,getLangFilter); User::WaitForRequest(reqStatus); TEST(reqStatus.Int()==KErrNone); TEST(getLangFilter.Compare(DMMTSY_CBS_MESSAGE_LANGUAGE_FILTER) == 0); // asynchronous & cancel cbsMessaging.GetLanguageFilter(reqStatus,getLangFilter); cbsMessaging.CancelAsyncRequest(EMobileBroadcastMessagingGetLanguageFilter); User::WaitForRequest(reqStatus); TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel); if (reqStatus.Int()==KErrCancel) INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::GetLanguageFilter (async & cancel (Cancelled Request)) passed"), iTestCount++); else { TEST(getLangFilter.Compare(DMMTSY_CBS_MESSAGE_LANGUAGE_FILTER) == 0); INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::GetLanguageFilter (async & cancel (Request Not Cancelled)) passed"), iTestCount++); } // Test Set Language Filter // asynchronous cbsMessaging.SetLanguageFilter(reqStatus,setLangFilter); User::WaitForRequest(reqStatus); TEST(reqStatus.Int()==KErrNone); // asynchronous & cancel cbsMessaging.SetLanguageFilter(reqStatus,setLangFilter); cbsMessaging.CancelAsyncRequest(EMobileBroadcastMessagingSetLanguageFilter); User::WaitForRequest(reqStatus); TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel); if (reqStatus.Int()==KErrCancel) INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::SetLanguageFilter (async & cancel (Cancelled Request)) passed"), iTestCount++); else INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::SetLanguageFilter (async & cancel (Request Not Cancelled)) passed"), iTestCount++); // Test Notify Language Filter Change // asynchronous cbsMessaging.NotifyLanguageFilterChange(reqStatus,getLangFilter); User::WaitForRequest(reqStatus); TEST(reqStatus.Int()==KErrNone); TEST(getLangFilter.Compare(DMMTSY_CBS_MESSAGE_LANGUAGE_FILTER) == 0); // asynchronous & cancel cbsMessaging.NotifyLanguageFilterChange(reqStatus,getLangFilter); cbsMessaging.CancelAsyncRequest(EMobileBroadcastMessagingNotifyLanguageFilterChange); User::WaitForRequest(reqStatus); TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel); if (reqStatus.Int()==KErrCancel) INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::NotifyLanguageFilterChange (async & cancel (Cancelled Request)) passed"), iTestCount++); else { TEST(getLangFilter.Compare(DMMTSY_CBS_MESSAGE_LANGUAGE_FILTER) == 0); INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::NotifyLanguageFilterChange (async & cancel (Request Not Cancelled)) passed"), iTestCount++); } //Test deletion of list object whilst async request in progress CRetrieveMobilePhoneBroadcastIdList* retrieve=CRetrieveMobilePhoneBroadcastIdList::NewL(cbsMessaging); retrieve->Start(reqStatus,DMMTSY_BROADCAST_ID_TYPE); delete retrieve; retrieve = NULL; User::WaitForRequest(reqStatus); TEST(reqStatus == KErrCancel); // Get CBMI list using asynchronous AO version CTestGetCbmiList* getCbmiList=CTestGetCbmiList::NewLC(cbsMessaging, this); getCbmiList->Start(); CActiveScheduler::Start(); // Lets ensure that the same ao can be used to retrieve more than one list. getCbmiList->Start(); CActiveScheduler::Start(); // I only need to delete the retrieval object because the destructor // of this will also delete the list object. CleanupStack::PopAndDestroy(); // getCbmiList // Now test the cancelling getCbmiList=CTestGetCbmiList::NewLC(cbsMessaging, this); getCbmiList->Start(); CTestCanceller* cancelGetCbmiList = getCbmiList->RetrieveCancelPtr(); cancelGetCbmiList->Call(); CActiveScheduler::Start(); TBool cancelled = (getCbmiList->iStatus == KErrCancel); // Finally, lets just ensure that the object can be resused even after it has been cancelled getCbmiList->Start(); CActiveScheduler::Start(); if (cancelled) INFO_PRINTF2(_L("Test %d - Test CRetrieveMobilePhoneBroadcastIdList (async & cancel (Cancelled Request)) passed"), iTestCount++); else INFO_PRINTF2(_L("Test %d - Test CRetrieveMobilePhoneBroadcastIdList (async & cancel (Request Not Cancelled)) passed"), iTestCount++); CleanupStack::PopAndDestroy(); // getCbmiList // test.Next(_L("OK: RMobileCbmiStore's Read All Entries")); // Test StoreCbmiList CTestStoreCbmiList *storeList = CTestStoreCbmiList::NewLC(cbsMessaging, this); storeList->StartL(); CActiveScheduler::Start(); // Lets just perform the operation twice to make sure etelmm handles the cleanup of all // internal buffers correctly. storeList->StartL(); CActiveScheduler::Start(); CleanupStack::PopAndDestroy(); // Test Cancel storeList = CTestStoreCbmiList::NewLC(cbsMessaging, this); storeList->StartL(); storeList->RetrieveCancelPtr()->Call(); CActiveScheduler::Start(); if (storeList->iStatus == KErrCancel) INFO_PRINTF2(_L("Test %d - Test StoreBroadcastIdListL (async & cancel (Cancelled Request)) passed"), iTestCount++); else INFO_PRINTF2(_L("Test %d - Test StoreBroadcastIdListL (async & cancel (Request Not Cancelled)) passed"), iTestCount++); CleanupStack::PopAndDestroy(); // Test NotifyCbmi List Change cbsMessaging.NotifyBroadcastIdListChange(reqStatus); User::WaitForRequest(reqStatus); TEST(reqStatus.Int()==KErrNone); // asynchronous & cancel cbsMessaging.NotifyBroadcastIdListChange(reqStatus); cbsMessaging.CancelAsyncRequest(EMobileBroadcastMessagingNotifyIdListChange); User::WaitForRequest(reqStatus); TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel); if (reqStatus.Int()==KErrCancel) INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::NotifyBroadcastIdListChange (async & cancel (Cancelled Request)) passed"), iTestCount++); else INFO_PRINTF2(_L("Test %d - RMobileBroadcastMessaging::NotifyBroadcastIdListChange (async & cancel (Request Not Cancelled)) passed"), iTestCount++); // test.Next(_L("OK: RMobileBroadcastMessaging Ok")); INFO_PRINTF1(_L("")); cbsMessaging.Close(); mmPhone.Close(); return TestStepResult(); }