sl@0: /* sl@0: * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: #include sl@0: #include sl@0: sl@0: #include "cafserver.h" sl@0: #include "ManagerStep.h" sl@0: #include "manager.h" sl@0: #include "dirstreamable.h" sl@0: #include "virtualpathptr.h" sl@0: #include "agent.h" sl@0: #include "attributeset.h" sl@0: #include "stringattributeset.h" sl@0: #include "contentIterator.h" sl@0: sl@0: using namespace ContentAccess; sl@0: sl@0: sl@0: sl@0: /* sl@0: * This step deletes a file using the CAF framework sl@0: * sl@0: */ sl@0: sl@0: CCAFDeleteStep::~CCAFDeleteStep() sl@0: { sl@0: } sl@0: sl@0: CCAFDeleteStep::CCAFDeleteStep(CCAFServer& aParent) : iParent(aParent) sl@0: { sl@0: SetTestStepName(KCAFDeleteStep); sl@0: } sl@0: sl@0: sl@0: TVerdict CCAFDeleteStep::doTestStepL() sl@0: { sl@0: TPtrC fileName; sl@0: sl@0: TInt expectedResult; sl@0: TInt result; sl@0: sl@0: SetTestStepResult(EFail); sl@0: sl@0: // Find the file to delete and the expected return code from the INI file sl@0: GetStringFromConfig(ConfigSection(),_L("filename"),fileName); sl@0: GetIntFromConfig(ConfigSection(),_L("result"),expectedResult); sl@0: sl@0: INFO_PRINTF3(_L("Delete File %S Expected result: %d"), &fileName, expectedResult); sl@0: sl@0: __UHEAP_MARK; sl@0: sl@0: TRAP(result, CManager::DeleteFileL(fileName)); sl@0: sl@0: if(result != KErrNone) sl@0: { sl@0: INFO_PRINTF2(_L("Delete file left: %d"), result); sl@0: if(result== expectedResult) sl@0: { sl@0: SetTestStepResult(EPass); sl@0: } sl@0: } sl@0: else if(result == expectedResult) sl@0: { sl@0: SetTestStepResult(EPass); sl@0: } sl@0: else INFO_PRINTF2(_L("Delete file left with error: %d"), result); sl@0: sl@0: __UHEAP_MARKEND; sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: /* sl@0: * This step copies a file using the CAF framework sl@0: * sl@0: */ sl@0: sl@0: CCAFCopyFileStep::~CCAFCopyFileStep() sl@0: { sl@0: } sl@0: sl@0: CCAFCopyFileStep::CCAFCopyFileStep(CCAFServer& aParent) : iParent(aParent) sl@0: { sl@0: SetTestStepName(KCAFCopyFileStep); sl@0: } sl@0: sl@0: sl@0: TVerdict CCAFCopyFileStep::doTestStepL() sl@0: { sl@0: TPtrC source; sl@0: TPtrC destination; sl@0: sl@0: TInt expectedResult; sl@0: TInt result; sl@0: sl@0: SetTestStepResult(EFail); sl@0: sl@0: // Find the file to copy and the expected return code from the INI file sl@0: GetStringFromConfig(ConfigSection(),_L("source"),source); sl@0: GetStringFromConfig(ConfigSection(),_L("destination"),destination); sl@0: GetIntFromConfig(ConfigSection(),_L("result"),expectedResult); sl@0: sl@0: INFO_PRINTF4(_L("Copy %S to %S, Expected result: %d"), &source, &destination, expectedResult); sl@0: sl@0: __UHEAP_MARK; sl@0: sl@0: CManager *manager = CManager::NewLC(); sl@0: sl@0: result = manager->CopyFile(source, destination); sl@0: if(result == expectedResult) sl@0: { sl@0: SetTestStepResult(EPass); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF2(_L("CopyFile(source as filename overload) returned with unexpected error: %d"), result); sl@0: } sl@0: // set up 2nd overload testing sl@0: RFs fs; sl@0: RFile file; sl@0: sl@0: // read the input file and pass it to the CAF sl@0: fs.Connect(); sl@0: CleanupClosePushL(fs); sl@0: User::LeaveIfError(fs.ShareProtected()); sl@0: sl@0: result = file.Open(fs, source, EFileRead | EFileStream | EFileShareAny); sl@0: if (result == KErrNone) sl@0: { sl@0: CleanupClosePushL(file); sl@0: sl@0: // test the RFile overload sl@0: result = manager->CopyFile(file, destination); sl@0: sl@0: if ((result == expectedResult)&&(TestStepResult()==EPass)) sl@0: { sl@0: SetTestStepResult(EPass); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF2(_L("CopyFile(source as RFile handle overload) returned with unexpected error: %d"), result); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(&file); sl@0: sl@0: } sl@0: else if ((result == expectedResult)&&(TestStepResult()==EPass)) sl@0: { sl@0: SetTestStepResult(EPass); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF2(_L("CopyFile(source as RFile handle overload) returned with unexpected error: %d"), result); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(&fs); sl@0: sl@0: CleanupStack::PopAndDestroy(manager); sl@0: sl@0: __UHEAP_MARKEND; sl@0: return TestStepResult(); sl@0: } sl@0: /* sl@0: * This step renames a file using the CAF framework sl@0: * sl@0: */ sl@0: sl@0: CCAFRenameFileStep::~CCAFRenameFileStep() sl@0: { sl@0: } sl@0: sl@0: CCAFRenameFileStep::CCAFRenameFileStep(CCAFServer& aParent) : iParent(aParent) sl@0: { sl@0: SetTestStepName(KCAFRenameFileStep); sl@0: } sl@0: sl@0: sl@0: TVerdict CCAFRenameFileStep::doTestStepL() sl@0: { sl@0: TPtrC source; sl@0: TPtrC destination; sl@0: sl@0: TInt expectedResult; sl@0: TInt result; sl@0: sl@0: SetTestStepResult(EFail); sl@0: sl@0: // Find the file to copy and the expected return code from the INI file sl@0: GetStringFromConfig(ConfigSection(),_L("source"),source); sl@0: GetStringFromConfig(ConfigSection(),_L("destination"),destination); sl@0: GetIntFromConfig(ConfigSection(),_L("result"),expectedResult); sl@0: sl@0: INFO_PRINTF4(_L("Rename from %S to %S, Expected result: %d"), &source, &destination, expectedResult); sl@0: sl@0: __UHEAP_MARK; sl@0: sl@0: CManager *manager = CManager::NewLC(); sl@0: result = manager->RenameFile(source, destination); sl@0: CleanupStack::PopAndDestroy(manager); sl@0: sl@0: if(result == expectedResult) sl@0: { sl@0: SetTestStepResult(EPass); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF2(_L("RenameFile() returned with unexpected error: %d"), result); sl@0: } sl@0: sl@0: __UHEAP_MARKEND; sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: /* sl@0: * This step creates a directory using the CAF framework sl@0: * sl@0: */ sl@0: sl@0: CCAFMkDirStep::~CCAFMkDirStep() sl@0: { sl@0: } sl@0: sl@0: CCAFMkDirStep::CCAFMkDirStep(CCAFServer& aParent) : iParent(aParent) sl@0: { sl@0: SetTestStepName(KCAFMkDirStep); sl@0: } sl@0: sl@0: sl@0: TVerdict CCAFMkDirStep::doTestStepL() sl@0: { sl@0: TPtrC path; sl@0: TInt expectedResult; sl@0: TInt result; sl@0: sl@0: SetTestStepResult(EFail); sl@0: sl@0: // Find the file to copy and the expected return code from the INI file sl@0: GetStringFromConfig(ConfigSection(),_L("path"),path); sl@0: GetIntFromConfig(ConfigSection(),_L("result"),expectedResult); sl@0: sl@0: INFO_PRINTF3(_L("Create directory %S, Expected result: %d"), &path, expectedResult); sl@0: sl@0: __UHEAP_MARK; sl@0: sl@0: CManager *manager = CManager::NewLC(); sl@0: result = manager->MkDir(path); sl@0: CleanupStack::PopAndDestroy(manager); sl@0: sl@0: if(result == expectedResult) sl@0: { sl@0: SetTestStepResult(EPass); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF2(_L("MkDir() returned with unexpected error: %d"), result); sl@0: } sl@0: sl@0: __UHEAP_MARKEND; sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: /* sl@0: * This step creates several directory using the CAF framework sl@0: * sl@0: */ sl@0: sl@0: CCAFMkDirAllStep::~CCAFMkDirAllStep() sl@0: { sl@0: } sl@0: sl@0: CCAFMkDirAllStep::CCAFMkDirAllStep(CCAFServer& aParent) : iParent(aParent) sl@0: { sl@0: SetTestStepName(KCAFMkDirAllStep); sl@0: } sl@0: sl@0: sl@0: TVerdict CCAFMkDirAllStep::doTestStepL() sl@0: { sl@0: TPtrC path; sl@0: TInt expectedResult; sl@0: TInt result; sl@0: sl@0: SetTestStepResult(EFail); sl@0: sl@0: // Find the file to copy and the expected return code from the INI file sl@0: GetStringFromConfig(ConfigSection(),_L("path"),path); sl@0: GetIntFromConfig(ConfigSection(),_L("result"),expectedResult); sl@0: sl@0: INFO_PRINTF3(_L("Create directory %S, Expected result: %d"), &path, expectedResult); sl@0: sl@0: __UHEAP_MARK; sl@0: sl@0: CManager *manager = CManager::NewLC(); sl@0: // remove directory in case it already exists sl@0: manager->RmDir(path); sl@0: result = manager->MkDirAll(path); sl@0: CleanupStack::PopAndDestroy(manager); sl@0: sl@0: if(result == expectedResult) sl@0: { sl@0: SetTestStepResult(EPass); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF2(_L("MkDirAll() returned with unexpected error: %d"), result); sl@0: } sl@0: sl@0: __UHEAP_MARKEND; sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: /* sl@0: * This step removes a directory using the CAF framework sl@0: * sl@0: */ sl@0: sl@0: CCAFRmDirStep::~CCAFRmDirStep() sl@0: { sl@0: } sl@0: sl@0: CCAFRmDirStep::CCAFRmDirStep(CCAFServer& aParent) : iParent(aParent) sl@0: { sl@0: SetTestStepName(KCAFRmDirStep); sl@0: } sl@0: sl@0: sl@0: TVerdict CCAFRmDirStep::doTestStepL() sl@0: { sl@0: TPtrC path; sl@0: TInt expectedResult; sl@0: TInt result; sl@0: sl@0: SetTestStepResult(EFail); sl@0: sl@0: // Find the file to copy and the expected return code from the INI file sl@0: GetStringFromConfig(ConfigSection(),_L("path"),path); sl@0: GetIntFromConfig(ConfigSection(),_L("result"),expectedResult); sl@0: sl@0: INFO_PRINTF3(_L("Remove directory %S, Expected result: %d"), &path, expectedResult); sl@0: sl@0: __UHEAP_MARK; sl@0: sl@0: CManager *manager = CManager::NewLC(); sl@0: result = manager->RmDir(path); sl@0: CleanupStack::PopAndDestroy(manager); sl@0: sl@0: if(result == expectedResult) sl@0: { sl@0: SetTestStepResult(EPass); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF2(_L("RmDir() returned with unexpected error: %d"), result); sl@0: } sl@0: sl@0: __UHEAP_MARKEND; sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: /* sl@0: * This step lists the contents of a directory using the CAF framework sl@0: * sl@0: */ sl@0: sl@0: CCAFGetDirStep::~CCAFGetDirStep() sl@0: { sl@0: } sl@0: sl@0: CCAFGetDirStep::CCAFGetDirStep(CCAFServer& aParent) : iParent(aParent) sl@0: { sl@0: SetTestStepName(KCAFGetDirStep); sl@0: } sl@0: sl@0: sl@0: TVerdict CCAFGetDirStep::doTestStepL() sl@0: { sl@0: TPtrC path; sl@0: TInt expectedResult; sl@0: TInt result; sl@0: TInt GetDirAPI = 0; sl@0: sl@0: CDir *entrylist = NULL; sl@0: CDir *dirlist = NULL; sl@0: CDir *filelist = NULL; sl@0: sl@0: sl@0: SetTestStepResult(EFail); sl@0: sl@0: // Find the file to copy and the expected return code from the INI file sl@0: GetStringFromConfig(ConfigSection(),_L("path"),path); sl@0: GetIntFromConfig(ConfigSection(),_L("API"),GetDirAPI); sl@0: GetIntFromConfig(ConfigSection(),_L("result"),expectedResult); sl@0: sl@0: INFO_PRINTF3(_L("List contents of directory %S, Expected result: %d"), &path, expectedResult); sl@0: sl@0: __UHEAP_MARK; sl@0: sl@0: CManager *manager = CManager::NewLC(); sl@0: if(GetDirAPI == 1) sl@0: { sl@0: result = manager->GetDir(path,ESortByName, KEntryAttNormal, entrylist); sl@0: } sl@0: else if(GetDirAPI == 2) sl@0: { sl@0: result = manager->GetDir(path,ESortByName, KEntryAttNormal, entrylist, dirlist); sl@0: } sl@0: else sl@0: { sl@0: result = manager->GetDir(path,TUidType(), ESortByName, filelist); sl@0: } sl@0: CleanupStack::PopAndDestroy(manager); sl@0: sl@0: if(entrylist) sl@0: { sl@0: INFO_PRINTF2(_L("%d items in EntryList:"), entrylist->Count()); sl@0: DisplayList(*entrylist); sl@0: delete entrylist; sl@0: entrylist = NULL; sl@0: } sl@0: sl@0: if(dirlist) sl@0: { sl@0: INFO_PRINTF2(_L("%d items in DirList:"), dirlist->Count()); sl@0: DisplayList(*dirlist); sl@0: delete dirlist; sl@0: dirlist = NULL; sl@0: } sl@0: sl@0: if(filelist) sl@0: { sl@0: INFO_PRINTF2(_L("%d items in FileList:"), filelist->Count()); sl@0: DisplayList(*filelist); sl@0: delete filelist; sl@0: filelist = NULL; sl@0: } sl@0: sl@0: if(result == expectedResult) sl@0: { sl@0: SetTestStepResult(EPass); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF2(_L("GetDir() returned with unexpected error: %d"), result); sl@0: } sl@0: sl@0: __UHEAP_MARKEND; sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: void CCAFGetDirStep::DisplayList(CDir& aDir) sl@0: { sl@0: TInt i = 0; sl@0: for(i = 0; i < aDir.Count(); i++) sl@0: { sl@0: INFO_PRINTF2(_L(" %S"), &aDir[i].iName ); sl@0: } sl@0: } sl@0: sl@0: sl@0: /* sl@0: * This step tests the notification functions sl@0: * sl@0: */ sl@0: sl@0: CCAFManagerNotifyStep::~CCAFManagerNotifyStep() sl@0: { sl@0: } sl@0: sl@0: CCAFManagerNotifyStep::CCAFManagerNotifyStep(CCAFServer& aParent) : iParent(aParent) sl@0: { sl@0: SetTestStepName(KCAFManagerNotifyStep); sl@0: } sl@0: sl@0: sl@0: TVerdict CCAFManagerNotifyStep::doTestStepL() sl@0: { sl@0: TPtrC uri; sl@0: TInt result; sl@0: TRequestStatus status = KRequestPending; sl@0: sl@0: TInt Status1; sl@0: TInt Cancel1; sl@0: TInt Cancel2; sl@0: sl@0: sl@0: SetTestStepResult(EPass); sl@0: sl@0: // Find the file to copy and the expected return code from the INI file sl@0: GetStringFromConfig(ConfigSection(),_L("path"),uri); sl@0: GetIntFromConfig(ConfigSection(),_L("Status1"),Status1); sl@0: GetIntFromConfig(ConfigSection(),_L("Cancel1"),Cancel1); sl@0: GetIntFromConfig(ConfigSection(),_L("Cancel2"),Cancel2); sl@0: sl@0: INFO_PRINTF2(_L("Performing notification tests on %S"), &uri); sl@0: sl@0: __UHEAP_MARK; sl@0: CManager *manager = CManager::NewLC(); sl@0: // Wait for rights sl@0: manager->NotifyStatusChange(uri, ERightsAvailable, status); sl@0: User::WaitForRequest(status); sl@0: if(status.Int() != Status1) sl@0: { sl@0: INFO_PRINTF3(_L("Status expected: %d returned unexpected status %d"), Status1, status.Int()); sl@0: SetTestStepResult(EFail); sl@0: } sl@0: result = manager->CancelNotifyStatusChange(uri, status); sl@0: if(result != Cancel1) sl@0: { sl@0: INFO_PRINTF3(_L("Cancel request expected return value: %d returned unexpected value %d"), Cancel1, result); sl@0: SetTestStepResult(EFail); sl@0: } sl@0: sl@0: // Wait for rights expired but cancel before they arrive sl@0: manager->NotifyStatusChange(uri, ERightsExpired, status); sl@0: result = manager->CancelNotifyStatusChange(uri, status); sl@0: if(result != Cancel2) sl@0: { sl@0: INFO_PRINTF3(_L("Cancel2 request expected return value: %d returned unexpected value %d"), Cancel2, result); sl@0: SetTestStepResult(EFail); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(manager); sl@0: sl@0: sl@0: __UHEAP_MARKEND; sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: /* sl@0: * This step sets a property in the agents sl@0: * sl@0: */ sl@0: sl@0: CCAFManagerSetPropertyStep::~CCAFManagerSetPropertyStep() sl@0: { sl@0: } sl@0: sl@0: CCAFManagerSetPropertyStep::CCAFManagerSetPropertyStep(CCAFServer& aParent) : iParent(aParent) sl@0: { sl@0: SetTestStepName(KCAFManagerSetPropertyStep); sl@0: } sl@0: sl@0: sl@0: TVerdict CCAFManagerSetPropertyStep::doTestStepL() sl@0: { sl@0: TInt expectedResult; sl@0: TInt result; sl@0: sl@0: SetTestStepResult(EFail); sl@0: sl@0: // Find the file to copy and the expected return code from the INI file sl@0: GetIntFromConfig(ConfigSection(),_L("result"),expectedResult); sl@0: sl@0: INFO_PRINTF2(_L("Set Property expected result: %d"), expectedResult); sl@0: sl@0: __UHEAP_MARK; sl@0: sl@0: CManager *manager = CManager::NewLC(); sl@0: result = manager->SetProperty(EAgentPropertyBufferSize, 100); sl@0: CleanupStack::PopAndDestroy(manager); sl@0: sl@0: // dummy test Agent expects KErrNotSupported sl@0: if(result == expectedResult || result == KErrNotSupported) sl@0: { sl@0: SetTestStepResult(EPass); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF2(_L("SetProperty() returned with unexpected error: %d"), result); sl@0: } sl@0: sl@0: __UHEAP_MARKEND; sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: /* sl@0: * This step asks the agent to display information about a file sl@0: * sl@0: */ sl@0: sl@0: CCAFManagerDisplayInfoStep::~CCAFManagerDisplayInfoStep() sl@0: { sl@0: } sl@0: sl@0: CCAFManagerDisplayInfoStep::CCAFManagerDisplayInfoStep(CCAFServer& aParent) : iParent(aParent) sl@0: { sl@0: SetTestStepName(KCAFManagerDisplayInfoStep); sl@0: } sl@0: sl@0: sl@0: TVerdict CCAFManagerDisplayInfoStep::doTestStepL() sl@0: { sl@0: TPtrC uri; sl@0: TInt expectedResult; sl@0: TInt result; sl@0: sl@0: SetTestStepResult(EFail); sl@0: sl@0: // Find the file to copy and the expected return code from the INI file sl@0: GetStringFromConfig(ConfigSection(),_L("uri"),uri); sl@0: GetIntFromConfig(ConfigSection(),_L("result"),expectedResult); sl@0: sl@0: INFO_PRINTF3(_L("DisplayInfo for %S expected result: %d"), &uri, expectedResult); sl@0: sl@0: __UHEAP_MARK; sl@0: sl@0: CManager *manager = CManager::NewLC(); sl@0: TRAP(result, manager->DisplayInfoL(EFileProperties, TVirtualPathPtr(uri))); sl@0: CleanupStack::PopAndDestroy(manager); sl@0: sl@0: if(result == expectedResult) sl@0: { sl@0: SetTestStepResult(EPass); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF2(_L("DisplayInfoL() left with unexpected error: %d"), result); sl@0: } sl@0: sl@0: __UHEAP_MARKEND; sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: /* sl@0: * This step asks CAF for a list of agents sl@0: * sl@0: */ sl@0: sl@0: CCAFManagerListAgentsStep::~CCAFManagerListAgentsStep() sl@0: { sl@0: } sl@0: sl@0: CCAFManagerListAgentsStep::CCAFManagerListAgentsStep(CCAFServer& aParent) : iParent(aParent) sl@0: { sl@0: SetTestStepName(KCAFManagerListAgentsStep); sl@0: } sl@0: sl@0: sl@0: TVerdict CCAFManagerListAgentsStep::doTestStepL() sl@0: { sl@0: TPtrC uri; sl@0: TInt expectedResult; sl@0: TInt expectedNumber; sl@0: TInt result; sl@0: sl@0: RArray agents; sl@0: sl@0: SetTestStepResult(EFail); sl@0: sl@0: // Find the file to copy and the expected return code from the INI file sl@0: GetIntFromConfig(ConfigSection(),_L("count"),expectedNumber); sl@0: GetIntFromConfig(ConfigSection(),_L("result"),expectedResult); sl@0: sl@0: INFO_PRINTF2(_L("List agents expected result: %d"), expectedResult); sl@0: sl@0: __UHEAP_MARK; sl@0: sl@0: CManager *manager = CManager::NewLC(); sl@0: TRAP(result, manager->ListAgentsL(agents)); sl@0: CleanupStack::PopAndDestroy(manager); sl@0: sl@0: TInt i = 0; sl@0: for (i = 0; i < agents.Count(); i++) sl@0: { sl@0: TPtrC agentName = agents[i].Name(); sl@0: INFO_PRINTF2(_L(" %S"), &agentName); sl@0: } sl@0: sl@0: INFO_PRINTF2(_L("List agents expected result: %d"), expectedResult); sl@0: sl@0: if(result == expectedResult) sl@0: { sl@0: if(expectedNumber == agents.Count()) sl@0: { sl@0: SetTestStepResult(EPass); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF2(_L("Expected number of agents: %d"), expectedNumber); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF2(_L("ListAgents left with unexpected error: %d"), result); sl@0: } sl@0: sl@0: agents.Close(); sl@0: sl@0: __UHEAP_MARKEND; sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: /* sl@0: * This step attempts to perform an agent specific command sl@0: * sl@0: */ sl@0: sl@0: CCAFManagerAgentSpecificStep::~CCAFManagerAgentSpecificStep() sl@0: { sl@0: } sl@0: sl@0: CCAFManagerAgentSpecificStep::CCAFManagerAgentSpecificStep(CCAFServer& aParent) : iParent(aParent) sl@0: { sl@0: SetTestStepName(KCAFManagerAgentSpecificStep); sl@0: } sl@0: sl@0: sl@0: TVerdict CCAFManagerAgentSpecificStep::doTestStepL() sl@0: { sl@0: TPtrC input16; sl@0: TPtrC output16; sl@0: TInt expectedResult; sl@0: TInt command; sl@0: TInt result; sl@0: TBuf8 <100> actualOutput; sl@0: TBuf8 <100> output; sl@0: TBuf8 <100> input; sl@0: TInt index = 0; sl@0: sl@0: RArray agents; sl@0: _LIT(KTestAgentName, "Reference Test Agent"); sl@0: sl@0: SetTestStepResult(EPass); sl@0: sl@0: GetIntFromConfig(ConfigSection(),_L("command"),command); sl@0: GetStringFromConfig(ConfigSection(),_L("input"),input16); sl@0: GetStringFromConfig(ConfigSection(),_L("output"),output16); sl@0: GetIntFromConfig(ConfigSection(),_L("result"),expectedResult); sl@0: sl@0: input.Copy(input16); sl@0: output.Copy(output16); sl@0: sl@0: __UHEAP_MARK; sl@0: CManager *manager = CManager::NewLC(); sl@0: TRAP(result, manager->ListAgentsL(agents)); sl@0: sl@0: INFO_PRINTF1(_L("Running synchronous Agent specific command")); sl@0: actualOutput.SetLength(0); sl@0: if(result == KErrNone && agents.Count() > 0) sl@0: { sl@0: for(index = 0; index < agents.Count(); index++) sl@0: { sl@0: if(agents[index].Name() == KTestAgentName()) sl@0: { sl@0: break; sl@0: } sl@0: } sl@0: result = manager->AgentSpecificCommand(agents[index],command, input, actualOutput); sl@0: } sl@0: else sl@0: { sl@0: SetTestStepResult(EFail); sl@0: } sl@0: if(result != expectedResult) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: INFO_PRINTF3(_L("Async Expected result: %d, actual result: %d"), expectedResult, result); sl@0: } sl@0: else if(actualOutput != output) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: INFO_PRINTF3(_L("Async Expected output: %S, actual output: %S"), &output, &actualOutput); sl@0: } sl@0: sl@0: INFO_PRINTF1(_L("Running asynchronous Agent specific command")); sl@0: TRequestStatus status; sl@0: actualOutput.SetLength(0); sl@0: if((result == KErrNone || result == expectedResult) && agents.Count() > 0) sl@0: { sl@0: manager->AgentSpecificCommand(agents[index], command, input, actualOutput, status); sl@0: User::WaitForRequest(status); sl@0: } sl@0: else sl@0: { sl@0: SetTestStepResult(EFail); sl@0: } sl@0: if(status.Int() != expectedResult) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: INFO_PRINTF3(_L("Async Expected result: %d, actual result: %d"), expectedResult, status.Int()); sl@0: } sl@0: else if(actualOutput != output) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: INFO_PRINTF3(_L("Async Expected output: %S, actual output: %S"), &output, &actualOutput); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(manager); sl@0: agents.Close(); sl@0: sl@0: __UHEAP_MARKEND; sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: /* sl@0: * This step attempts to display configuration information sl@0: * sl@0: */ sl@0: sl@0: CCAFManagerDisplayConfigStep::~CCAFManagerDisplayConfigStep() sl@0: { sl@0: } sl@0: sl@0: CCAFManagerDisplayConfigStep::CCAFManagerDisplayConfigStep(CCAFServer& aParent) : iParent(aParent) sl@0: { sl@0: SetTestStepName(KCAFManagerDisplayConfigStep); sl@0: } sl@0: sl@0: TVerdict CCAFManagerDisplayConfigStep::doTestStepL() sl@0: { sl@0: TInt expectedResult; sl@0: TInt result = KErrNone; sl@0: sl@0: RArray agents; sl@0: CManager *manager; sl@0: sl@0: SetTestStepResult(EPass); sl@0: sl@0: GetIntFromConfig(ConfigSection(),_L("result"),expectedResult); sl@0: sl@0: __UHEAP_MARK; sl@0: manager = CManager::NewL(); sl@0: CleanupStack::PushL(manager); sl@0: TRAP(result, manager->ListAgentsL(agents)); sl@0: sl@0: if(result == KErrNone && agents.Count() > 0) sl@0: { sl@0: TRAP(result, manager->DisplayManagementInfoL(agents[0])); sl@0: } sl@0: else sl@0: { sl@0: SetTestStepResult(EFail); sl@0: } sl@0: if(result != expectedResult && result != KErrNotSupported) // dummy test agent expects -5 sl@0: { sl@0: SetTestStepResult(EFail); sl@0: INFO_PRINTF3(_L("Expected result: %d, actual result: %d"), expectedResult, result); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(manager); sl@0: agents.Close(); sl@0: sl@0: __UHEAP_MARKEND; sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: /* sl@0: * Manager attribute step sl@0: * sl@0: */ sl@0: sl@0: CCAFManagerAttributeStep::~CCAFManagerAttributeStep() sl@0: { sl@0: } sl@0: sl@0: CCAFManagerAttributeStep::CCAFManagerAttributeStep(CCAFServer& aParent) : iParent(aParent) sl@0: { sl@0: SetTestStepName(KCAFManagerAttributeStep); sl@0: } sl@0: sl@0: TVerdict CCAFManagerAttributeStep::doTestStepL() sl@0: { sl@0: #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT sl@0: TBool wmdrmFlag = EFalse; sl@0: GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag); sl@0: sl@0: if(wmdrmFlag) sl@0: { sl@0: TVerdict verdict = doWmdrmTestStepL(); sl@0: return verdict; sl@0: } sl@0: #endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT sl@0: sl@0: TInt attribute; sl@0: TInt value = KErrNone; sl@0: TInt expectedValue; sl@0: TPtrC uri; sl@0: TPtrC uniqueId; sl@0: sl@0: CManager *manager; sl@0: sl@0: SetTestStepResult(EPass); sl@0: sl@0: GetIntFromConfig(ConfigSection(),_L("attribute"),attribute); sl@0: GetStringFromConfig(ConfigSection(),_L("uri"),uri); sl@0: GetStringFromConfig(ConfigSection(),_L("uniqueid"),uniqueId); sl@0: GetIntFromConfig(ConfigSection(),_L("value"),expectedValue); sl@0: sl@0: __UHEAP_MARK; sl@0: manager = CManager::NewL(); sl@0: if(manager) sl@0: { sl@0: CleanupStack::PushL(manager); sl@0: User::LeaveIfError(manager->GetAttribute(attribute, value, TVirtualPathPtr(uri, uniqueId))); sl@0: if(expectedValue!= value) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: INFO_PRINTF3(_L("CManager::GetAttribute() Expected value: %d, actual value: %d"), expectedValue, value); sl@0: } sl@0: CleanupStack::PopAndDestroy(manager); sl@0: } sl@0: else sl@0: { sl@0: SetTestStepResult(EFail); sl@0: INFO_PRINTF1(_L("CManager construction failed")); sl@0: } sl@0: sl@0: sl@0: __UHEAP_MARKEND; sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: /* sl@0: * Manager attributeset step sl@0: * sl@0: */ sl@0: sl@0: CCAFManagerAttributeSetStep::~CCAFManagerAttributeSetStep() sl@0: { sl@0: } sl@0: sl@0: CCAFManagerAttributeSetStep::CCAFManagerAttributeSetStep(CCAFServer& aParent) : iParent(aParent) sl@0: { sl@0: SetTestStepName(KCAFManagerAttributeSetStep); sl@0: } sl@0: sl@0: TVerdict CCAFManagerAttributeSetStep::doTestStepL() sl@0: { sl@0: #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT sl@0: TBool wmdrmFlag = EFalse; sl@0: GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag); sl@0: sl@0: if(wmdrmFlag) sl@0: { sl@0: TVerdict verdict = doWmdrmTestStepL(); sl@0: return verdict; sl@0: } sl@0: #endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT sl@0: sl@0: TInt value1; sl@0: TInt value2; sl@0: TInt expectedValue1; sl@0: TInt expectedValue2; sl@0: TInt attribute1; sl@0: TInt attribute2; sl@0: TInt result = KErrNone; sl@0: TPtrC uri; sl@0: TPtrC uniqueId; sl@0: sl@0: CManager *manager; sl@0: sl@0: SetTestStepResult(EPass); sl@0: sl@0: GetStringFromConfig(ConfigSection(),_L("uri"),uri); sl@0: GetStringFromConfig(ConfigSection(),_L("uniqueid"),uniqueId); sl@0: GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1); sl@0: GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2); sl@0: GetIntFromConfig(ConfigSection(),_L("value1"),expectedValue1); sl@0: GetIntFromConfig(ConfigSection(),_L("value2"),expectedValue2); sl@0: sl@0: __UHEAP_MARK; sl@0: manager = CManager::NewL(); sl@0: if(manager) sl@0: { sl@0: CleanupStack::PushL(manager); sl@0: RAttributeSet attributeSet; sl@0: CleanupClosePushL(attributeSet); sl@0: attributeSet.AddL(attribute1); sl@0: attributeSet.AddL(attribute2); sl@0: result = manager->GetAttributeSet(attributeSet, TVirtualPathPtr(uri, uniqueId)); sl@0: if(result != KErrNone) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: INFO_PRINTF1(_L("CManager::GetAttribute() failed")); sl@0: } sl@0: User::LeaveIfError(attributeSet.GetValue(attribute1, value1)); sl@0: User::LeaveIfError(attributeSet.GetValue(attribute2, value2)); sl@0: if(expectedValue1 != value1 || expectedValue2 != value2 || attributeSet.Count() != 2) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: INFO_PRINTF1(_L("CManager::GetAttributeSet() values don't match expected values")); sl@0: } sl@0: CleanupStack::PopAndDestroy(&attributeSet); sl@0: CleanupStack::PopAndDestroy(manager); sl@0: } sl@0: else sl@0: { sl@0: SetTestStepResult(EFail); sl@0: INFO_PRINTF1(_L("CManager construction failed")); sl@0: } sl@0: sl@0: sl@0: __UHEAP_MARKEND; sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: /* sl@0: * Manager string attribute step sl@0: * sl@0: */ sl@0: sl@0: CCAFManagerStringAttributeStep::~CCAFManagerStringAttributeStep() sl@0: { sl@0: } sl@0: sl@0: CCAFManagerStringAttributeStep::CCAFManagerStringAttributeStep(CCAFServer& aParent) : iParent(aParent) sl@0: { sl@0: SetTestStepName(KCAFManagerStringAttributeStep); sl@0: } sl@0: sl@0: TVerdict CCAFManagerStringAttributeStep::doTestStepL() sl@0: { sl@0: #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT sl@0: TBool wmdrmFlag = EFalse; sl@0: GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag); sl@0: sl@0: if(wmdrmFlag) sl@0: { sl@0: TVerdict verdict = doWmdrmTestStepL(); sl@0: return verdict; sl@0: } sl@0: #endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT sl@0: sl@0: TInt expectedResult; sl@0: TInt attribute; sl@0: TPtrC expectedValue; sl@0: TBuf <200> value; sl@0: TInt result = KErrNone; sl@0: TPtrC uri; sl@0: TPtrC uniqueId; sl@0: sl@0: CManager *manager; sl@0: sl@0: SetTestStepResult(EPass); sl@0: sl@0: GetIntFromConfig(ConfigSection(),_L("attribute"),attribute); sl@0: GetStringFromConfig(ConfigSection(),_L("uri"),uri); sl@0: GetStringFromConfig(ConfigSection(),_L("uniqueid"),uniqueId); sl@0: GetStringFromConfig(ConfigSection(),_L("value"),expectedValue); sl@0: GetIntFromConfig(ConfigSection(),_L("result"),expectedResult); sl@0: sl@0: __UHEAP_MARK; sl@0: manager = CManager::NewL(); sl@0: if(manager) sl@0: { sl@0: CleanupStack::PushL(manager); sl@0: result = manager->GetStringAttribute(attribute, value, TVirtualPathPtr(uri, uniqueId)); sl@0: if(result != expectedResult) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: INFO_PRINTF3(_L("CManager::GetStringAttribute() Expected result: %d, actual result: %d"), expectedResult, result); sl@0: } sl@0: if(value != expectedValue) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: INFO_PRINTF3(_L("CManager::GetStringAttribute() Expected value: %S, actual result: %S"), &expectedValue, &value); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(manager); sl@0: } sl@0: else sl@0: { sl@0: SetTestStepResult(EFail); sl@0: INFO_PRINTF1(_L("CManager construction failed")); sl@0: } sl@0: sl@0: sl@0: __UHEAP_MARKEND; sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: /* sl@0: * Manager StringAttributeSet step sl@0: * sl@0: */ sl@0: sl@0: CCAFManagerStringAttributeSetStep::~CCAFManagerStringAttributeSetStep() sl@0: { sl@0: } sl@0: sl@0: CCAFManagerStringAttributeSetStep::CCAFManagerStringAttributeSetStep(CCAFServer& aParent) : iParent(aParent) sl@0: { sl@0: SetTestStepName(KCAFManagerStringAttributeSetStep); sl@0: } sl@0: sl@0: TVerdict CCAFManagerStringAttributeSetStep::doTestStepL() sl@0: { sl@0: #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT sl@0: TBool wmdrmFlag = EFalse; sl@0: GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag); sl@0: sl@0: if(wmdrmFlag) sl@0: { sl@0: TVerdict verdict = doWmdrmTestStepL(); sl@0: return verdict; sl@0: } sl@0: #endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT sl@0: sl@0: TPtrC expectedValue1; sl@0: TPtrC expectedValue2; sl@0: TBuf <200> value1; sl@0: TBuf <200> value2; sl@0: TInt result1; sl@0: TInt result2; sl@0: TInt attribute1; sl@0: TInt attribute2; sl@0: TInt result = KErrNone; sl@0: TPtrC uri; sl@0: TPtrC uniqueId; sl@0: sl@0: CManager *manager; sl@0: sl@0: SetTestStepResult(EPass); sl@0: sl@0: GetStringFromConfig(ConfigSection(),_L("uri"),uri); sl@0: GetStringFromConfig(ConfigSection(),_L("uniqueid"),uniqueId); sl@0: GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1); sl@0: GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2); sl@0: GetStringFromConfig(ConfigSection(),_L("value1"),expectedValue1); sl@0: GetStringFromConfig(ConfigSection(),_L("value2"),expectedValue2); sl@0: GetIntFromConfig(ConfigSection(),_L("result1"),result1); sl@0: GetIntFromConfig(ConfigSection(),_L("result2"),result2); sl@0: sl@0: sl@0: __UHEAP_MARK; sl@0: manager = CManager::NewL(); sl@0: if(manager) sl@0: { sl@0: CleanupStack::PushL(manager); sl@0: RStringAttributeSet attributeSet; sl@0: CleanupClosePushL(attributeSet); sl@0: attributeSet.AddL(attribute1); sl@0: attributeSet.AddL(attribute2); sl@0: result = manager->GetStringAttributeSet(attributeSet, TVirtualPathPtr(uri, uniqueId)); sl@0: if(result != KErrNone) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: INFO_PRINTF1(_L("CManager::GetAttribute() failed")); sl@0: } sl@0: if(result1 != attributeSet.GetValue(attribute1, value1)) sl@0: { sl@0: INFO_PRINTF1(_L("RStringAttributeSet::GetValue failed")); sl@0: } sl@0: if(result2 != attributeSet.GetValue(attribute2, value2)) sl@0: { sl@0: INFO_PRINTF1(_L("RStringAttributeSet::GetValue failed")); sl@0: } sl@0: if(value1 != expectedValue1 || value2 != expectedValue2 || attributeSet.Count() != 2) sl@0: { sl@0: SetTestStepResult(EFail); sl@0: INFO_PRINTF1(_L("CManager::GetAttributeSet() values don't match expected values")); sl@0: } sl@0: CleanupStack::PopAndDestroy(&attributeSet); sl@0: CleanupStack::PopAndDestroy(manager); sl@0: } sl@0: else sl@0: { sl@0: SetTestStepResult(EFail); sl@0: INFO_PRINTF1(_L("CManager construction failed")); sl@0: } sl@0: sl@0: sl@0: __UHEAP_MARKEND; sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: CIteratorTestStateMachine::CIteratorTestStateMachine(CCAFContentIteratorStep *aParent) : CActive(EPriorityStandard) sl@0: { sl@0: iParent = aParent; sl@0: } sl@0: sl@0: CIteratorTestStateMachine::~CIteratorTestStateMachine() sl@0: { sl@0: delete iter; sl@0: delete iPath; sl@0: delete iMimeType; sl@0: } sl@0: sl@0: void CIteratorTestStateMachine::DoCancel() sl@0: { sl@0: // Not used sl@0: CActiveScheduler::Stop(); sl@0: } sl@0: sl@0: sl@0: void CIteratorTestStateMachine::RunTestL(const TDesC& aPath, TBool aRecursive, const TDesC8& aMimeType) sl@0: { sl@0: iPath = aPath.AllocL(); sl@0: iMimeType = aMimeType.AllocL(); sl@0: iRecursive = aRecursive; sl@0: sl@0: // This function will only return once all files have been found sl@0: // and the RunL() method calls CActiveScheduler::Stop() sl@0: CActiveScheduler::Add(this); sl@0: iStatus = KRequestPending; sl@0: SetActive(); sl@0: TRequestStatus *ptr = &iStatus; sl@0: User::RequestComplete(ptr, KErrNone); sl@0: CActiveScheduler::Start(); sl@0: } sl@0: sl@0: void CIteratorTestStateMachine::RunL() sl@0: { sl@0: TBuf mime16; sl@0: TVirtualPathPtr location(KNullDesC(), KNullDesC()); sl@0: sl@0: if(iStatus.Int() != KErrNone) sl@0: { sl@0: delete iter; sl@0: iter = NULL; sl@0: CActiveScheduler::Stop(); sl@0: } sl@0: else sl@0: { sl@0: switch(iState) sl@0: { sl@0: case 0: // create iterator sl@0: iter = CContentIterator::NewL(*iPath, iRecursive, *iMimeType); sl@0: iStatus = KRequestPending; sl@0: iter->Next(iStatus); sl@0: SetActive(); sl@0: iState = 1; sl@0: break; sl@0: sl@0: case 1: // get result of Next request sl@0: location = iter->VirtualPath(); sl@0: mime16.Copy(iter->MimeType()); sl@0: iParent->PrintResult(location.URI(), location.UniqueId(), mime16); sl@0: iStatus = KRequestPending; sl@0: iter->Next(iStatus); sl@0: SetActive(); sl@0: break; sl@0: default: sl@0: CActiveScheduler::Stop(); sl@0: break; sl@0: }; sl@0: } sl@0: } sl@0: sl@0: /* sl@0: * Content Iterator Step sl@0: * sl@0: */ sl@0: sl@0: CCAFContentIteratorStep::~CCAFContentIteratorStep() sl@0: { sl@0: } sl@0: sl@0: CCAFContentIteratorStep::CCAFContentIteratorStep(CCAFServer& aParent) : iParent(aParent) sl@0: { sl@0: SetTestStepName(KCAFContentIteratorStep); sl@0: } sl@0: sl@0: TVerdict CCAFContentIteratorStep::doTestStepL() sl@0: { sl@0: TPtrC path; sl@0: TPtrC mimeType; sl@0: TBuf8 mimeType8; sl@0: sl@0: SetTestStepResult(EPass); sl@0: sl@0: GetStringFromConfig(ConfigSection(),_L("path"),path); sl@0: GetStringFromConfig(ConfigSection(),_L("mimetype"),mimeType); sl@0: sl@0: mimeType8.Copy(mimeType); sl@0: sl@0: __UHEAP_MARK; sl@0: sl@0: CIteratorTestStateMachine *t = new CIteratorTestStateMachine(this); sl@0: sl@0: t->RunTestL(path, ETrue, mimeType8); sl@0: sl@0: delete t; sl@0: __UHEAP_MARKEND; sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: void CCAFContentIteratorStep::PrintResult(const TDesC& aFileName, const TDesC& aUniqueId, const TDesC& aMimeType) sl@0: { sl@0: INFO_PRINTF4(_L("File: %S, UniqueId: %S, MimeType: %S"), &aFileName, &aUniqueId, &aMimeType); sl@0: } sl@0: sl@0: sl@0: /* sl@0: * This step asks the agent to display information about a file using the file handle sl@0: * sl@0: */ sl@0: CCAFManagerDisplayInfoByFileHandleStep::~CCAFManagerDisplayInfoByFileHandleStep() sl@0: { sl@0: } sl@0: sl@0: CCAFManagerDisplayInfoByFileHandleStep::CCAFManagerDisplayInfoByFileHandleStep(CCAFServer& aParent) : iParent(aParent) sl@0: { sl@0: SetTestStepName(KCAFManagerDisplayInfoByFileHandleStep); sl@0: } sl@0: sl@0: sl@0: TVerdict CCAFManagerDisplayInfoByFileHandleStep::doTestStepL() sl@0: { sl@0: TInt result; sl@0: sl@0: //initialisation for testing purposes such as iUri, iFs, iFile, iExpectedResult and iUniqueId. sl@0: InitialiseFileHandleParametersL(); sl@0: sl@0: SetTestStepResult(EFail); sl@0: sl@0: __UHEAP_MARK; sl@0: CManager *manager = CManager::NewLC(); sl@0: sl@0: TRAP(result, manager->DisplayInfoL(EFileProperties, iFile, iUniqueId)); sl@0: if(result == iExpectedResult) sl@0: { sl@0: SetTestStepResult(EPass); sl@0: INFO_PRINTF1(_L("CManager::DisplayInfoL()(RFile handle overload) PASSED")); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("CManager::DisplayInfoL()(RFile handle overload) returned unexpected error")); sl@0: INFO_PRINTF3(_L("CManager::DisplayInfoL()(RFile handle overload) Expected result: %d, actual result: %d"), iExpectedResult, result); sl@0: } sl@0: sl@0: //cleanup manager instance sl@0: CleanupStack::PopAndDestroy(manager); sl@0: //cleanup iFs and iFile instances by closing the handles. sl@0: CleanupStack::PopAndDestroy(2, &iFs); sl@0: sl@0: __UHEAP_MARKEND; sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: /* sl@0: * Manager attribute step using file handle. sl@0: * sl@0: */ sl@0: sl@0: CCAFManagerAttributeByFileHandleStep::~CCAFManagerAttributeByFileHandleStep() sl@0: { sl@0: } sl@0: sl@0: CCAFManagerAttributeByFileHandleStep::CCAFManagerAttributeByFileHandleStep(CCAFServer& aParent) : iParent(aParent) sl@0: { sl@0: SetTestStepName(KCAFManagerAttributeByFileHandleStep); sl@0: } sl@0: sl@0: TVerdict CCAFManagerAttributeByFileHandleStep::doTestStepL() sl@0: { sl@0: TInt attribute; sl@0: TInt value = KErrNone; sl@0: TInt result= KErrNone; sl@0: TInt expectedValue; sl@0: sl@0: //initialisation for testing purposes such as iUri, iFs, iFile, iExpectedResult and iUniqueId. sl@0: InitialiseFileHandleParametersL(); sl@0: GetIntFromConfig(ConfigSection(),_L("attribute"),attribute); sl@0: GetIntFromConfig(ConfigSection(),_L("value"),expectedValue); sl@0: sl@0: SetTestStepResult(EFail); sl@0: sl@0: __UHEAP_MARK; sl@0: CManager *manager = CManager::NewLC(); sl@0: sl@0: result = manager->GetAttribute(attribute, value, iFile, iUniqueId); sl@0: //expectedResult has priority over the values collected. sl@0: if(result == iExpectedResult) sl@0: { sl@0: if(value == expectedValue) sl@0: { sl@0: SetTestStepResult(EPass); sl@0: INFO_PRINTF1(_L("CManager::GetAttribute()(RFile handle overload) PASSED")); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("CManager::GetAttribute()(RFile handle overload) values don't match expected values")); sl@0: INFO_PRINTF3(_L("CManager::GetAttribute()(RFile handle overload) Expected value: %d, actual value: %d"), expectedValue, value); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("CManager::GetAttribute()(RFile handle overload) returned unexpected error")); sl@0: INFO_PRINTF3(_L("CManager::GetAttribute()(RFile handle overload) Expected result: %d, actual result: %d"), iExpectedResult, result); sl@0: } sl@0: sl@0: //cleanup manager instance sl@0: CleanupStack::PopAndDestroy(manager); sl@0: //cleanup iFs and iFile instances by closing the handles. sl@0: CleanupStack::PopAndDestroy(2, &iFs); sl@0: sl@0: __UHEAP_MARKEND; sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: /* sl@0: * Manager attributeset step by file handle. sl@0: * sl@0: */ sl@0: sl@0: CCAFManagerAttributeSetByFileHandleStep::~CCAFManagerAttributeSetByFileHandleStep() sl@0: { sl@0: } sl@0: sl@0: CCAFManagerAttributeSetByFileHandleStep::CCAFManagerAttributeSetByFileHandleStep(CCAFServer& aParent) : iParent(aParent) sl@0: { sl@0: SetTestStepName(KCAFManagerAttributeSetByFileHandleStep); sl@0: } sl@0: sl@0: TVerdict CCAFManagerAttributeSetByFileHandleStep::doTestStepL() sl@0: { sl@0: TInt value1; sl@0: TInt value2; sl@0: TInt expectedValue1; sl@0: TInt expectedValue2; sl@0: TInt attribute1; sl@0: TInt attribute2; sl@0: TInt result = KErrNone; sl@0: sl@0: //initialisation for testing purposes such as iUri, iFs, iFile, iExpectedResult and iUniqueId. sl@0: InitialiseFileHandleParametersL(); sl@0: GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1); sl@0: GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2); sl@0: GetIntFromConfig(ConfigSection(),_L("value1"),expectedValue1); sl@0: GetIntFromConfig(ConfigSection(),_L("value2"),expectedValue2); sl@0: sl@0: SetTestStepResult(EFail); sl@0: sl@0: __UHEAP_MARK; sl@0: CManager *manager = CManager::NewLC(); sl@0: sl@0: RAttributeSet attributeSet; sl@0: CleanupClosePushL(attributeSet); sl@0: attributeSet.AddL(attribute1); sl@0: attributeSet.AddL(attribute2); sl@0: sl@0: result = manager->GetAttributeSet(attributeSet, iFile, iUniqueId); sl@0: //expectedResult has priority over the values collected. sl@0: if(result == iExpectedResult) sl@0: { sl@0: User::LeaveIfError(attributeSet.GetValue(attribute1, value1)); sl@0: User::LeaveIfError(attributeSet.GetValue(attribute2, value2)); sl@0: if(value1 == expectedValue1 && value2 == expectedValue2) sl@0: { sl@0: SetTestStepResult(EPass); sl@0: INFO_PRINTF1(_L("CManager::GetAttributeSet()(RFile handle overload) PASSED")); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("CManager::GetAttributeSet()(RFile handle overload) values don't match expected values")); sl@0: INFO_PRINTF3(_L("CManager::GetAttributeSet()(RFile handle overload) Expected value: %d, actual value: %d"), expectedValue1, value1); sl@0: INFO_PRINTF3(_L("CManager::GetAttributeSet()(RFile handle overload) Expected value: %d, actual value: %d"), expectedValue2, value2); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("CManager::GetAttributeSet()(RFile handle overload) returned unexpected error")); sl@0: INFO_PRINTF3(_L("CManager::GetAttributeSet()(RFile handle overload) Expected result: %d, actual result: %d"), iExpectedResult, result); sl@0: } sl@0: sl@0: //cleanup manager and attributeSet instances sl@0: CleanupStack::PopAndDestroy(2, manager); sl@0: //cleanup iFs and iFile instances by closing the handles. sl@0: CleanupStack::PopAndDestroy(2, &iFs); sl@0: sl@0: __UHEAP_MARKEND; sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: /* sl@0: * Manager string attribute step by file handle sl@0: * sl@0: */ sl@0: sl@0: CCAFManagerStringAttributeByFileHandleStep::~CCAFManagerStringAttributeByFileHandleStep() sl@0: { sl@0: } sl@0: sl@0: CCAFManagerStringAttributeByFileHandleStep::CCAFManagerStringAttributeByFileHandleStep(CCAFServer& aParent) : iParent(aParent) sl@0: { sl@0: SetTestStepName(KCAFManagerStringAttributeByFileHandleStep); sl@0: } sl@0: sl@0: TVerdict CCAFManagerStringAttributeByFileHandleStep::doTestStepL() sl@0: { sl@0: TInt attribute; sl@0: TInt result = KErrNone; sl@0: TPtrC expectedValue; sl@0: TBuf <200> value; sl@0: sl@0: //initialisation for testing purposes such as iUri, iFs, iFile, iExpectedResult and iUniqueId. sl@0: InitialiseFileHandleParametersL(); sl@0: GetIntFromConfig(ConfigSection(),_L("attribute"),attribute); sl@0: GetStringFromConfig(ConfigSection(),_L("value"),expectedValue); sl@0: sl@0: SetTestStepResult(EFail); sl@0: sl@0: __UHEAP_MARK; sl@0: CManager* manager = CManager::NewLC(); sl@0: sl@0: result = manager->GetStringAttribute(attribute, value, iFile, iUniqueId); sl@0: //expectedResult has priority over the values collected. sl@0: if(result == iExpectedResult) sl@0: { sl@0: if (value == expectedValue) sl@0: { sl@0: SetTestStepResult(EPass); sl@0: INFO_PRINTF1(_L("CManager::GetStringAttribute()(RFile handle overload) PASSED")); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("CManager::GetStringAttribute()(RFile handle overload) values don't match expected values")); sl@0: INFO_PRINTF3(_L("CManager::GetStringAttribute()(RFile handle overload) Expected value: %S, actual value: %S"), &expectedValue, &value); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("CManager::GetStringAttribute()(RFile handle overload) returned unexpected error")); sl@0: INFO_PRINTF3(_L("CManager::GetStringAttribute()(RFile handle overload) Expected result: %d, actual result: %d"), iExpectedResult, result); sl@0: } sl@0: sl@0: //cleanup manager instance sl@0: CleanupStack::PopAndDestroy(manager); sl@0: //cleanup iFs and iFile instances by closing the handles. sl@0: CleanupStack::PopAndDestroy(2, &iFs); sl@0: sl@0: __UHEAP_MARKEND; sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: /* sl@0: * Manager StringAttributeSet step by file handle. sl@0: * sl@0: */ sl@0: sl@0: CCAFManagerStringAttributeSetByFileHandleStep::~CCAFManagerStringAttributeSetByFileHandleStep() sl@0: { sl@0: } sl@0: sl@0: CCAFManagerStringAttributeSetByFileHandleStep::CCAFManagerStringAttributeSetByFileHandleStep(CCAFServer& aParent) : iParent(aParent) sl@0: { sl@0: SetTestStepName(KCAFManagerStringAttributeSetByFileHandleStep); sl@0: } sl@0: sl@0: TVerdict CCAFManagerStringAttributeSetByFileHandleStep::doTestStepL() sl@0: { sl@0: TInt attribute1; sl@0: TInt attribute2; sl@0: TInt result = KErrNone; sl@0: TPtrC expectedValue1; sl@0: TPtrC expectedValue2; sl@0: TBuf <200> value1; sl@0: TBuf <200> value2; sl@0: sl@0: //initialisation for testing purposes such as iUri, iFs, iFile, iExpectedResult and iUniqueId. sl@0: InitialiseFileHandleParametersL(); sl@0: GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1); sl@0: GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2); sl@0: GetStringFromConfig(ConfigSection(),_L("value1"),expectedValue1); sl@0: GetStringFromConfig(ConfigSection(),_L("value2"),expectedValue2); sl@0: sl@0: SetTestStepResult(EFail); sl@0: sl@0: __UHEAP_MARK; sl@0: CManager* manager = CManager::NewLC(); sl@0: sl@0: RStringAttributeSet attributeSet; sl@0: CleanupClosePushL(attributeSet); sl@0: attributeSet.AddL(attribute1); sl@0: attributeSet.AddL(attribute2); sl@0: sl@0: result = manager->GetStringAttributeSet(attributeSet, iFile, iUniqueId); sl@0: //expectedResult has priority over the values collected. sl@0: if(result == iExpectedResult) sl@0: { sl@0: User::LeaveIfError(attributeSet.GetValue(attribute1, value1)); sl@0: User::LeaveIfError(attributeSet.GetValue(attribute2, value2)); sl@0: if (value1 == expectedValue1 && value2 == expectedValue2) sl@0: { sl@0: SetTestStepResult(EPass); sl@0: INFO_PRINTF1(_L("CManager::GetStringAttributeSet()(RFile handle overload) PASSED")); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("CManager::GetStringAttributeSet()(RFile handle overload) values don't match expected values")); sl@0: INFO_PRINTF3(_L("CManager::GetStringAttributeSet()(RFile handle overload) Expected value: %S, actual value: %S"), &expectedValue1, &value1); sl@0: INFO_PRINTF3(_L("CManager::GetStringAttributeSet()(RFile handle overload) Expected value: %S, actual value: %S"), &expectedValue2, &value2); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("CManager::GetStringAttributeSet()(RFile handle overload) returned unexpected error")); sl@0: INFO_PRINTF3(_L("CManager::GetStringAttributeSet()(RFile handle overload) Expected result: %d, actual result: %d"), iExpectedResult, result); sl@0: } sl@0: sl@0: //cleanup manager and attributeSet instances sl@0: CleanupStack::PopAndDestroy(2, manager); sl@0: //cleanup iFs and iFile instances by closing the handles. sl@0: CleanupStack::PopAndDestroy(2, &iFs); sl@0: sl@0: __UHEAP_MARKEND; sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT sl@0: sl@0: // The following methods test the various manager attribute APIs for WMDRM content. sl@0: sl@0: TVerdict CCAFManagerAttributeStep::doWmdrmTestStepL() sl@0: { sl@0: SetTestStepResult(EFail); sl@0: sl@0: TInt attribVal; sl@0: GetIntFromConfig(ConfigSection(),_L("attribute"), attribVal); sl@0: sl@0: TInt expectedValue; sl@0: GetIntFromConfig(ConfigSection(),_L("value"), expectedValue); sl@0: sl@0: __UHEAP_MARK; sl@0: sl@0: TPtrC header; sl@0: HBufC8* headerData = NULL; sl@0: sl@0: if(GetStringFromConfig(ConfigSection(),_L("header"), header)) sl@0: { sl@0: headerData = ConvertDes16toHBufC8LC(header); sl@0: } sl@0: else sl@0: { sl@0: headerData = CreateWmdrmHeaderLC(); sl@0: } sl@0: sl@0: TInt value; sl@0: CManager *manager = CManager::NewLC(); sl@0: sl@0: User::LeaveIfError(manager->GetAttribute(*headerData, attribVal, value)); sl@0: if(expectedValue == value) sl@0: { sl@0: SetTestStepResult(EPass); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF3(_L("CManager::GetAttribute() Expected value: %d, actual value: %d"), expectedValue, value); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(2, headerData); sl@0: sl@0: __UHEAP_MARKEND; sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: TVerdict CCAFManagerAttributeSetStep::doWmdrmTestStepL() sl@0: { sl@0: SetTestStepResult(EFail); sl@0: sl@0: TInt attribute1; sl@0: GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1); sl@0: sl@0: TInt attribute2; sl@0: GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2); sl@0: sl@0: TInt expectedValue1; sl@0: GetIntFromConfig(ConfigSection(),_L("value1"),expectedValue1); sl@0: sl@0: TInt expectedValue2; sl@0: GetIntFromConfig(ConfigSection(),_L("value2"),expectedValue2); sl@0: sl@0: __UHEAP_MARK; sl@0: sl@0: TPtrC header; sl@0: HBufC8* headerData = NULL; sl@0: sl@0: if(GetStringFromConfig(ConfigSection(),_L("header"), header)) sl@0: { sl@0: headerData = ConvertDes16toHBufC8LC(header); sl@0: } sl@0: else sl@0: { sl@0: headerData = CreateWmdrmHeaderLC(); sl@0: } sl@0: sl@0: RAttributeSet attributeSet; sl@0: CleanupClosePushL(attributeSet); sl@0: attributeSet.AddL(attribute1); sl@0: attributeSet.AddL(attribute2); sl@0: sl@0: CManager *manager = CManager::NewLC(); sl@0: TInt result = manager->GetAttributeSet(*headerData, attributeSet); sl@0: if(result == KErrNone) sl@0: { sl@0: SetTestStepResult(EPass); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("CManager::GetAttributeSet() failed")); sl@0: } sl@0: sl@0: TInt value1; sl@0: User::LeaveIfError(attributeSet.GetValue(attribute1, value1)); sl@0: sl@0: TInt value2; sl@0: User::LeaveIfError(attributeSet.GetValue(attribute2, value2)); sl@0: sl@0: if(expectedValue1 == value1 && expectedValue2 == value2 && attributeSet.Count() == 2) sl@0: { sl@0: SetTestStepResult(EPass); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("CManager::GetAttributeSet() values don't match expected values")); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(3, headerData); sl@0: sl@0: __UHEAP_MARKEND; sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: TVerdict CCAFManagerStringAttributeStep::doWmdrmTestStepL() sl@0: { sl@0: SetTestStepResult(EFail); sl@0: sl@0: TInt attribVal; sl@0: GetIntFromConfig(ConfigSection(),_L("attribute"),attribVal); sl@0: sl@0: TPtrC expectedValue; sl@0: GetStringFromConfig(ConfigSection(),_L("value"),expectedValue); sl@0: sl@0: TInt expectedResult; sl@0: GetIntFromConfig(ConfigSection(),_L("result"),expectedResult); sl@0: sl@0: __UHEAP_MARK; sl@0: sl@0: TPtrC header; sl@0: HBufC8* headerData = NULL; sl@0: sl@0: if(GetStringFromConfig(ConfigSection(),_L("header"), header)) sl@0: { sl@0: headerData = ConvertDes16toHBufC8LC(header); sl@0: } sl@0: else sl@0: { sl@0: headerData = CreateWmdrmHeaderLC(); sl@0: } sl@0: sl@0: CManager* manager = CManager::NewLC(); sl@0: TBuf <200> value; sl@0: TInt result = manager->GetStringAttribute(*headerData, attribVal, value); sl@0: if(result == expectedResult && value == expectedValue) sl@0: { sl@0: SetTestStepResult(EPass); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF3(_L("CManager::GetStringAttribute() Expected result: %d, actual result: %d"), expectedResult, result); sl@0: INFO_PRINTF3(_L("CManager::GetStringAttribute() Expected value: %S, actual value: %S"), &expectedValue, &value); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(2, headerData); sl@0: sl@0: __UHEAP_MARKEND; sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: TVerdict CCAFManagerStringAttributeSetStep::doWmdrmTestStepL() sl@0: { sl@0: SetTestStepResult(EFail); sl@0: sl@0: TInt attribute1; sl@0: GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1); sl@0: sl@0: TInt attribute2; sl@0: GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2); sl@0: sl@0: TPtrC expectedValue1; sl@0: GetStringFromConfig(ConfigSection(),_L("value1"),expectedValue1); sl@0: sl@0: TPtrC expectedValue2; sl@0: GetStringFromConfig(ConfigSection(),_L("value2"),expectedValue2); sl@0: sl@0: __UHEAP_MARK; sl@0: sl@0: TPtrC header; sl@0: HBufC8* headerData = NULL; sl@0: sl@0: if(GetStringFromConfig(ConfigSection(),_L("header"), header)) sl@0: { sl@0: headerData = ConvertDes16toHBufC8LC(header); sl@0: } sl@0: else sl@0: { sl@0: headerData = CreateWmdrmHeaderLC(); sl@0: } sl@0: sl@0: RStringAttributeSet attributeSet; sl@0: CleanupClosePushL(attributeSet); sl@0: attributeSet.AddL(attribute1); sl@0: attributeSet.AddL(attribute2); sl@0: sl@0: CManager* manager = CManager::NewLC(); sl@0: TInt result = manager->GetStringAttributeSet(*headerData, attributeSet); sl@0: TBuf <200> value1; sl@0: TBuf <200> value2; sl@0: if(result == KErrNone) sl@0: { sl@0: TInt result3 = attributeSet.GetValue(attribute1, value1); sl@0: TInt result4 = attributeSet.GetValue(attribute2, value2); sl@0: sl@0: if(value1 == expectedValue1 && value2 == expectedValue2 && attributeSet.Count() == 2 sl@0: && result3 == KErrNone && result4 == KErrNone) sl@0: { sl@0: SetTestStepResult(EPass); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF3(_L("RStringAttributeSet::GetValue() for attribute1.Expected value: %S, actual value: %S"), &expectedValue1, &value1); sl@0: INFO_PRINTF3(_L("RStringAttributeSet::GetValue() for attribute2.Expected value: %S, actual value: %S"), &expectedValue2, &value2); sl@0: INFO_PRINTF3(_L("RStringAttributeSet::GetValue() for attribute1. Expected result: %d, actual result: %d"), 0, result3); sl@0: INFO_PRINTF3(_L("RStringAttributeSet::GetValue() for attribute2. Expected result: %d, actual result: %d"), 0, result4); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("CManager::GetStringAttributeSet() failed")); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(3, headerData); sl@0: sl@0: __UHEAP_MARKEND; sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: #endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT