/** Function : ExecuteActionL Description : Installs a new group of MTMs @internalTechnology @param : none @return : void @pre : @post : none */ void CMtfTestActionInstallMtmGroup::ExecuteActionL() { TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionInstallMtmGroup); // Obtain input parameters CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(), ActionParameters().Parameter(0)); HBufC* paramFileName = ObtainParameterReferenceL<HBufC>(TestCase(), ActionParameters().Parameter(1)); // If valid parameters received, call install MTM group if( (paramFileName != NULL) && (paramSession != NULL) ) { TInt result = paramSession->InstallMtmGroup(*paramFileName); // Print the result if(result == KErrAlreadyExists) { TestCase().INFO_PRINTF1(_L("MTM already installed")); } else if(result == KErrNone) { TestCase().INFO_PRINTF1(_L("MTM installed successfully")); } else { TestCase().ERR_PRINTF2(_L("MTM installation Failed with error %d"), result); User::Leave(result); } } else { // Invaid parameters received, leave the Test Action User::Leave(KErrArgument); } TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionInstallMtmGroup); TestCase().ActionCompletedL(*this); }
LOCAL_C void TestUiMtmLoadPanicL() { // Make sure the server is closed CMsgsTestUtils::WaitForServerClose(); User::After(500000); TChar driveChar= theUtils->FileSession().GetSystemDriveChar(); TBuf<2> systemDrive; systemDrive.Append(driveChar); systemDrive.Append(KDriveDelimiter); TPath pathName(systemDrive); pathName.Append(KDefaultRegistryFileStoreName); theUtils->FileSession().Delete(pathName); CMtmDllInfoArray* mtmdllinfoarray=new(ELeave) CMtmDllInfoArray(); CleanupStack::PushL(mtmdllinfoarray); // Create library info with silly imports CMtmDllInfo* mtmdllinfo=CMtmDllInfo::NewL(KMtmName, TUidType(KDynamicLibraryUid, KUidMtmServerComponent, TUid::Uid(KUidMtmDefaultSpecificVal)),KMtmDllName,1,TVersion(2,0,0)); mtmdllinfoarray->AddMtmDllInfoL(mtmdllinfo); mtmdllinfo=CMtmDllInfo::NewL(KMtmName, TUidType(KDynamicLibraryUid, KUidMtmClientComponent, TUid::Uid(KUidMtmDefaultSpecificVal)),KMtmDllName,1,TVersion(2,0,0)); mtmdllinfoarray->AddMtmDllInfoL(mtmdllinfo); mtmdllinfo=CMtmDllInfo::NewL(KMtmName, TUidType(KDynamicLibraryUid, KUidMtmUiComponent, TUid::Uid(KUidMtmDefaultSpecificVal)),KMtmDllName,345,TVersion(2,0,0)); mtmdllinfoarray->AddMtmDllInfoL(mtmdllinfo); mtmdllinfo=CMtmDllInfo::NewL(KMtmName, TUidType(KDynamicLibraryUid, KUidMtmUiDataComponent, TUid::Uid(KUidMtmDefaultSpecificVal)),KMtmDllName,456,TVersion(2,0,0)); mtmdllinfoarray->AddMtmDllInfoL(mtmdllinfo); TCapabilitySet capSet; capSet.SetEmpty(); CleanupStack::Pop(mtmdllinfoarray); // next line takes ownership CMtmGroupData* mtmgroupdata=CMtmGroupData::NewL(KUidTestMtm, KUidTestMtm, mtmdllinfoarray, capSet); CleanupStack::PushL(mtmgroupdata); CFileStore* filestore = CPermanentFileStore::ReplaceLC(theUtils->FileSession(), KMtmDataFile, EFileShareExclusive|EFileStream|EFileWrite); TUidType uidtype(KPermanentFileStoreLayoutUid,KUidMsvDataComponent, KUidTestMtm); filestore->SetTypeL(uidtype); RStoreWriteStream out; TStreamId streamid=out.CreateLC(*filestore); // Push to stack mtmgroupdata->ExternalizeL(out); out.CommitL(); CleanupStack::PopAndDestroy(); // out filestore->SetRootL(streamid); filestore->CommitL(); CleanupStack::PopAndDestroy(2, mtmgroupdata); // filestore, mtmgroupdata CDummyObserver* ob = new(ELeave)CDummyObserver; CleanupStack::PushL(ob); CMsvSession* session = CMsvSession::OpenSyncL(*ob); CleanupStack::PushL(session); TInt err = session->InstallMtmGroup(KMtmDataFile); test(err == KErrNone || err == KErrAlreadyExists); CClientMtmRegistry* clientReg = CClientMtmRegistry::NewL(*session); CleanupStack::PushL(clientReg); CBaseMtm* client = NULL; client = clientReg->NewMtmL(KUidTestMtm); CleanupStack::PushL(client); CMtmUiRegistry* uiReg = CMtmUiRegistry::NewL(*session); CleanupStack::PushL(uiReg); if (client !=NULL) { TRAPD(error, uiReg->NewMtmUiL(*client)); test(error == KErrBadLibraryEntryPoint); } CleanupStack::PopAndDestroy(5); // uiReg, client, clientReg, session, ob }