1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/security/contentmgmt/referencedrmagent/tcaf/source/ManagerStep.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,1860 @@
1.4 +/*
1.5 +* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of the License "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +#include <test/testexecutelog.h>
1.23 +#include <apmstd.h>
1.24 +
1.25 +#include "cafserver.h"
1.26 +#include "ManagerStep.h"
1.27 +#include "manager.h"
1.28 +#include "dirstreamable.h"
1.29 +#include "virtualpathptr.h"
1.30 +#include "agent.h"
1.31 +#include "attributeset.h"
1.32 +#include "stringattributeset.h"
1.33 +#include "contentIterator.h"
1.34 +
1.35 +using namespace ContentAccess;
1.36 +
1.37 +
1.38 +
1.39 +/*
1.40 + * This step deletes a file using the CAF framework
1.41 + *
1.42 + */
1.43 +
1.44 +CCAFDeleteStep::~CCAFDeleteStep()
1.45 + {
1.46 + }
1.47 +
1.48 +CCAFDeleteStep::CCAFDeleteStep(CCAFServer& aParent) : iParent(aParent)
1.49 + {
1.50 + SetTestStepName(KCAFDeleteStep);
1.51 + }
1.52 +
1.53 +
1.54 +TVerdict CCAFDeleteStep::doTestStepL()
1.55 + {
1.56 + TPtrC fileName;
1.57 +
1.58 + TInt expectedResult;
1.59 + TInt result;
1.60 +
1.61 + SetTestStepResult(EFail);
1.62 +
1.63 + // Find the file to delete and the expected return code from the INI file
1.64 + GetStringFromConfig(ConfigSection(),_L("filename"),fileName);
1.65 + GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
1.66 +
1.67 + INFO_PRINTF3(_L("Delete File %S Expected result: %d"), &fileName, expectedResult);
1.68 +
1.69 + __UHEAP_MARK;
1.70 +
1.71 + TRAP(result, CManager::DeleteFileL(fileName));
1.72 +
1.73 + if(result != KErrNone)
1.74 + {
1.75 + INFO_PRINTF2(_L("Delete file left: %d"), result);
1.76 + if(result== expectedResult)
1.77 + {
1.78 + SetTestStepResult(EPass);
1.79 + }
1.80 + }
1.81 + else if(result == expectedResult)
1.82 + {
1.83 + SetTestStepResult(EPass);
1.84 + }
1.85 + else INFO_PRINTF2(_L("Delete file left with error: %d"), result);
1.86 +
1.87 + __UHEAP_MARKEND;
1.88 + return TestStepResult();
1.89 + }
1.90 +
1.91 +
1.92 +/*
1.93 + * This step copies a file using the CAF framework
1.94 + *
1.95 + */
1.96 +
1.97 +CCAFCopyFileStep::~CCAFCopyFileStep()
1.98 + {
1.99 + }
1.100 +
1.101 +CCAFCopyFileStep::CCAFCopyFileStep(CCAFServer& aParent) : iParent(aParent)
1.102 + {
1.103 + SetTestStepName(KCAFCopyFileStep);
1.104 + }
1.105 +
1.106 +
1.107 +TVerdict CCAFCopyFileStep::doTestStepL()
1.108 + {
1.109 + TPtrC source;
1.110 + TPtrC destination;
1.111 +
1.112 + TInt expectedResult;
1.113 + TInt result;
1.114 +
1.115 + SetTestStepResult(EFail);
1.116 +
1.117 + // Find the file to copy and the expected return code from the INI file
1.118 + GetStringFromConfig(ConfigSection(),_L("source"),source);
1.119 + GetStringFromConfig(ConfigSection(),_L("destination"),destination);
1.120 + GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
1.121 +
1.122 + INFO_PRINTF4(_L("Copy %S to %S, Expected result: %d"), &source, &destination, expectedResult);
1.123 +
1.124 + __UHEAP_MARK;
1.125 +
1.126 + CManager *manager = CManager::NewLC();
1.127 +
1.128 + result = manager->CopyFile(source, destination);
1.129 + if(result == expectedResult)
1.130 + {
1.131 + SetTestStepResult(EPass);
1.132 + }
1.133 + else
1.134 + {
1.135 + INFO_PRINTF2(_L("CopyFile(source as filename overload) returned with unexpected error: %d"), result);
1.136 + }
1.137 + // set up 2nd overload testing
1.138 + RFs fs;
1.139 + RFile file;
1.140 +
1.141 + // read the input file and pass it to the CAF
1.142 + fs.Connect();
1.143 + CleanupClosePushL(fs);
1.144 + User::LeaveIfError(fs.ShareProtected());
1.145 +
1.146 + result = file.Open(fs, source, EFileRead | EFileStream | EFileShareAny);
1.147 + if (result == KErrNone)
1.148 + {
1.149 + CleanupClosePushL(file);
1.150 +
1.151 + // test the RFile overload
1.152 + result = manager->CopyFile(file, destination);
1.153 +
1.154 + if ((result == expectedResult)&&(TestStepResult()==EPass))
1.155 + {
1.156 + SetTestStepResult(EPass);
1.157 + }
1.158 + else
1.159 + {
1.160 + INFO_PRINTF2(_L("CopyFile(source as RFile handle overload) returned with unexpected error: %d"), result);
1.161 + }
1.162 +
1.163 + CleanupStack::PopAndDestroy(&file);
1.164 +
1.165 + }
1.166 + else if ((result == expectedResult)&&(TestStepResult()==EPass))
1.167 + {
1.168 + SetTestStepResult(EPass);
1.169 + }
1.170 + else
1.171 + {
1.172 + INFO_PRINTF2(_L("CopyFile(source as RFile handle overload) returned with unexpected error: %d"), result);
1.173 + }
1.174 +
1.175 + CleanupStack::PopAndDestroy(&fs);
1.176 +
1.177 + CleanupStack::PopAndDestroy(manager);
1.178 +
1.179 + __UHEAP_MARKEND;
1.180 + return TestStepResult();
1.181 + }
1.182 +/*
1.183 + * This step renames a file using the CAF framework
1.184 + *
1.185 + */
1.186 +
1.187 +CCAFRenameFileStep::~CCAFRenameFileStep()
1.188 + {
1.189 + }
1.190 +
1.191 +CCAFRenameFileStep::CCAFRenameFileStep(CCAFServer& aParent) : iParent(aParent)
1.192 + {
1.193 + SetTestStepName(KCAFRenameFileStep);
1.194 + }
1.195 +
1.196 +
1.197 +TVerdict CCAFRenameFileStep::doTestStepL()
1.198 + {
1.199 + TPtrC source;
1.200 + TPtrC destination;
1.201 +
1.202 + TInt expectedResult;
1.203 + TInt result;
1.204 +
1.205 + SetTestStepResult(EFail);
1.206 +
1.207 + // Find the file to copy and the expected return code from the INI file
1.208 + GetStringFromConfig(ConfigSection(),_L("source"),source);
1.209 + GetStringFromConfig(ConfigSection(),_L("destination"),destination);
1.210 + GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
1.211 +
1.212 + INFO_PRINTF4(_L("Rename from %S to %S, Expected result: %d"), &source, &destination, expectedResult);
1.213 +
1.214 + __UHEAP_MARK;
1.215 +
1.216 + CManager *manager = CManager::NewLC();
1.217 + result = manager->RenameFile(source, destination);
1.218 + CleanupStack::PopAndDestroy(manager);
1.219 +
1.220 + if(result == expectedResult)
1.221 + {
1.222 + SetTestStepResult(EPass);
1.223 + }
1.224 + else
1.225 + {
1.226 + INFO_PRINTF2(_L("RenameFile() returned with unexpected error: %d"), result);
1.227 + }
1.228 +
1.229 + __UHEAP_MARKEND;
1.230 + return TestStepResult();
1.231 + }
1.232 +
1.233 +
1.234 +/*
1.235 + * This step creates a directory using the CAF framework
1.236 + *
1.237 + */
1.238 +
1.239 +CCAFMkDirStep::~CCAFMkDirStep()
1.240 + {
1.241 + }
1.242 +
1.243 +CCAFMkDirStep::CCAFMkDirStep(CCAFServer& aParent) : iParent(aParent)
1.244 + {
1.245 + SetTestStepName(KCAFMkDirStep);
1.246 + }
1.247 +
1.248 +
1.249 +TVerdict CCAFMkDirStep::doTestStepL()
1.250 + {
1.251 + TPtrC path;
1.252 + TInt expectedResult;
1.253 + TInt result;
1.254 +
1.255 + SetTestStepResult(EFail);
1.256 +
1.257 + // Find the file to copy and the expected return code from the INI file
1.258 + GetStringFromConfig(ConfigSection(),_L("path"),path);
1.259 + GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
1.260 +
1.261 + INFO_PRINTF3(_L("Create directory %S, Expected result: %d"), &path, expectedResult);
1.262 +
1.263 + __UHEAP_MARK;
1.264 +
1.265 + CManager *manager = CManager::NewLC();
1.266 + result = manager->MkDir(path);
1.267 + CleanupStack::PopAndDestroy(manager);
1.268 +
1.269 + if(result == expectedResult)
1.270 + {
1.271 + SetTestStepResult(EPass);
1.272 + }
1.273 + else
1.274 + {
1.275 + INFO_PRINTF2(_L("MkDir() returned with unexpected error: %d"), result);
1.276 + }
1.277 +
1.278 + __UHEAP_MARKEND;
1.279 + return TestStepResult();
1.280 + }
1.281 +
1.282 +
1.283 +/*
1.284 + * This step creates several directory using the CAF framework
1.285 + *
1.286 + */
1.287 +
1.288 +CCAFMkDirAllStep::~CCAFMkDirAllStep()
1.289 + {
1.290 + }
1.291 +
1.292 +CCAFMkDirAllStep::CCAFMkDirAllStep(CCAFServer& aParent) : iParent(aParent)
1.293 + {
1.294 + SetTestStepName(KCAFMkDirAllStep);
1.295 + }
1.296 +
1.297 +
1.298 +TVerdict CCAFMkDirAllStep::doTestStepL()
1.299 + {
1.300 + TPtrC path;
1.301 + TInt expectedResult;
1.302 + TInt result;
1.303 +
1.304 + SetTestStepResult(EFail);
1.305 +
1.306 + // Find the file to copy and the expected return code from the INI file
1.307 + GetStringFromConfig(ConfigSection(),_L("path"),path);
1.308 + GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
1.309 +
1.310 + INFO_PRINTF3(_L("Create directory %S, Expected result: %d"), &path, expectedResult);
1.311 +
1.312 + __UHEAP_MARK;
1.313 +
1.314 + CManager *manager = CManager::NewLC();
1.315 + // remove directory in case it already exists
1.316 + manager->RmDir(path);
1.317 + result = manager->MkDirAll(path);
1.318 + CleanupStack::PopAndDestroy(manager);
1.319 +
1.320 + if(result == expectedResult)
1.321 + {
1.322 + SetTestStepResult(EPass);
1.323 + }
1.324 + else
1.325 + {
1.326 + INFO_PRINTF2(_L("MkDirAll() returned with unexpected error: %d"), result);
1.327 + }
1.328 +
1.329 + __UHEAP_MARKEND;
1.330 + return TestStepResult();
1.331 + }
1.332 +
1.333 +/*
1.334 + * This step removes a directory using the CAF framework
1.335 + *
1.336 + */
1.337 +
1.338 +CCAFRmDirStep::~CCAFRmDirStep()
1.339 + {
1.340 + }
1.341 +
1.342 +CCAFRmDirStep::CCAFRmDirStep(CCAFServer& aParent) : iParent(aParent)
1.343 + {
1.344 + SetTestStepName(KCAFRmDirStep);
1.345 + }
1.346 +
1.347 +
1.348 +TVerdict CCAFRmDirStep::doTestStepL()
1.349 + {
1.350 + TPtrC path;
1.351 + TInt expectedResult;
1.352 + TInt result;
1.353 +
1.354 + SetTestStepResult(EFail);
1.355 +
1.356 + // Find the file to copy and the expected return code from the INI file
1.357 + GetStringFromConfig(ConfigSection(),_L("path"),path);
1.358 + GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
1.359 +
1.360 + INFO_PRINTF3(_L("Remove directory %S, Expected result: %d"), &path, expectedResult);
1.361 +
1.362 + __UHEAP_MARK;
1.363 +
1.364 + CManager *manager = CManager::NewLC();
1.365 + result = manager->RmDir(path);
1.366 + CleanupStack::PopAndDestroy(manager);
1.367 +
1.368 + if(result == expectedResult)
1.369 + {
1.370 + SetTestStepResult(EPass);
1.371 + }
1.372 + else
1.373 + {
1.374 + INFO_PRINTF2(_L("RmDir() returned with unexpected error: %d"), result);
1.375 + }
1.376 +
1.377 + __UHEAP_MARKEND;
1.378 + return TestStepResult();
1.379 + }
1.380 +
1.381 +/*
1.382 + * This step lists the contents of a directory using the CAF framework
1.383 + *
1.384 + */
1.385 +
1.386 +CCAFGetDirStep::~CCAFGetDirStep()
1.387 + {
1.388 + }
1.389 +
1.390 +CCAFGetDirStep::CCAFGetDirStep(CCAFServer& aParent) : iParent(aParent)
1.391 + {
1.392 + SetTestStepName(KCAFGetDirStep);
1.393 + }
1.394 +
1.395 +
1.396 +TVerdict CCAFGetDirStep::doTestStepL()
1.397 + {
1.398 + TPtrC path;
1.399 + TInt expectedResult;
1.400 + TInt result;
1.401 + TInt GetDirAPI = 0;
1.402 +
1.403 + CDir *entrylist = NULL;
1.404 + CDir *dirlist = NULL;
1.405 + CDir *filelist = NULL;
1.406 +
1.407 +
1.408 + SetTestStepResult(EFail);
1.409 +
1.410 + // Find the file to copy and the expected return code from the INI file
1.411 + GetStringFromConfig(ConfigSection(),_L("path"),path);
1.412 + GetIntFromConfig(ConfigSection(),_L("API"),GetDirAPI);
1.413 + GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
1.414 +
1.415 + INFO_PRINTF3(_L("List contents of directory %S, Expected result: %d"), &path, expectedResult);
1.416 +
1.417 + __UHEAP_MARK;
1.418 +
1.419 + CManager *manager = CManager::NewLC();
1.420 + if(GetDirAPI == 1)
1.421 + {
1.422 + result = manager->GetDir(path,ESortByName, KEntryAttNormal, entrylist);
1.423 + }
1.424 + else if(GetDirAPI == 2)
1.425 + {
1.426 + result = manager->GetDir(path,ESortByName, KEntryAttNormal, entrylist, dirlist);
1.427 + }
1.428 + else
1.429 + {
1.430 + result = manager->GetDir(path,TUidType(), ESortByName, filelist);
1.431 + }
1.432 + CleanupStack::PopAndDestroy(manager);
1.433 +
1.434 + if(entrylist)
1.435 + {
1.436 + INFO_PRINTF2(_L("%d items in EntryList:"), entrylist->Count());
1.437 + DisplayList(*entrylist);
1.438 + delete entrylist;
1.439 + entrylist = NULL;
1.440 + }
1.441 +
1.442 + if(dirlist)
1.443 + {
1.444 + INFO_PRINTF2(_L("%d items in DirList:"), dirlist->Count());
1.445 + DisplayList(*dirlist);
1.446 + delete dirlist;
1.447 + dirlist = NULL;
1.448 + }
1.449 +
1.450 + if(filelist)
1.451 + {
1.452 + INFO_PRINTF2(_L("%d items in FileList:"), filelist->Count());
1.453 + DisplayList(*filelist);
1.454 + delete filelist;
1.455 + filelist = NULL;
1.456 + }
1.457 +
1.458 + if(result == expectedResult)
1.459 + {
1.460 + SetTestStepResult(EPass);
1.461 + }
1.462 + else
1.463 + {
1.464 + INFO_PRINTF2(_L("GetDir() returned with unexpected error: %d"), result);
1.465 + }
1.466 +
1.467 + __UHEAP_MARKEND;
1.468 + return TestStepResult();
1.469 + }
1.470 +
1.471 +
1.472 +void CCAFGetDirStep::DisplayList(CDir& aDir)
1.473 + {
1.474 + TInt i = 0;
1.475 + for(i = 0; i < aDir.Count(); i++)
1.476 + {
1.477 + INFO_PRINTF2(_L(" %S"), &aDir[i].iName );
1.478 + }
1.479 + }
1.480 +
1.481 +
1.482 +/*
1.483 + * This step tests the notification functions
1.484 + *
1.485 + */
1.486 +
1.487 +CCAFManagerNotifyStep::~CCAFManagerNotifyStep()
1.488 + {
1.489 + }
1.490 +
1.491 +CCAFManagerNotifyStep::CCAFManagerNotifyStep(CCAFServer& aParent) : iParent(aParent)
1.492 + {
1.493 + SetTestStepName(KCAFManagerNotifyStep);
1.494 + }
1.495 +
1.496 +
1.497 +TVerdict CCAFManagerNotifyStep::doTestStepL()
1.498 + {
1.499 + TPtrC uri;
1.500 + TInt result;
1.501 + TRequestStatus status = KRequestPending;
1.502 +
1.503 + TInt Status1;
1.504 + TInt Cancel1;
1.505 + TInt Cancel2;
1.506 +
1.507 +
1.508 + SetTestStepResult(EPass);
1.509 +
1.510 + // Find the file to copy and the expected return code from the INI file
1.511 + GetStringFromConfig(ConfigSection(),_L("path"),uri);
1.512 + GetIntFromConfig(ConfigSection(),_L("Status1"),Status1);
1.513 + GetIntFromConfig(ConfigSection(),_L("Cancel1"),Cancel1);
1.514 + GetIntFromConfig(ConfigSection(),_L("Cancel2"),Cancel2);
1.515 +
1.516 + INFO_PRINTF2(_L("Performing notification tests on %S"), &uri);
1.517 +
1.518 + __UHEAP_MARK;
1.519 + CManager *manager = CManager::NewLC();
1.520 + // Wait for rights
1.521 + manager->NotifyStatusChange(uri, ERightsAvailable, status);
1.522 + User::WaitForRequest(status);
1.523 + if(status.Int() != Status1)
1.524 + {
1.525 + INFO_PRINTF3(_L("Status expected: %d returned unexpected status %d"), Status1, status.Int());
1.526 + SetTestStepResult(EFail);
1.527 + }
1.528 + result = manager->CancelNotifyStatusChange(uri, status);
1.529 + if(result != Cancel1)
1.530 + {
1.531 + INFO_PRINTF3(_L("Cancel request expected return value: %d returned unexpected value %d"), Cancel1, result);
1.532 + SetTestStepResult(EFail);
1.533 + }
1.534 +
1.535 + // Wait for rights expired but cancel before they arrive
1.536 + manager->NotifyStatusChange(uri, ERightsExpired, status);
1.537 + result = manager->CancelNotifyStatusChange(uri, status);
1.538 + if(result != Cancel2)
1.539 + {
1.540 + INFO_PRINTF3(_L("Cancel2 request expected return value: %d returned unexpected value %d"), Cancel2, result);
1.541 + SetTestStepResult(EFail);
1.542 + }
1.543 +
1.544 + CleanupStack::PopAndDestroy(manager);
1.545 +
1.546 +
1.547 + __UHEAP_MARKEND;
1.548 + return TestStepResult();
1.549 + }
1.550 +
1.551 +/*
1.552 + * This step sets a property in the agents
1.553 + *
1.554 + */
1.555 +
1.556 +CCAFManagerSetPropertyStep::~CCAFManagerSetPropertyStep()
1.557 + {
1.558 + }
1.559 +
1.560 +CCAFManagerSetPropertyStep::CCAFManagerSetPropertyStep(CCAFServer& aParent) : iParent(aParent)
1.561 + {
1.562 + SetTestStepName(KCAFManagerSetPropertyStep);
1.563 + }
1.564 +
1.565 +
1.566 +TVerdict CCAFManagerSetPropertyStep::doTestStepL()
1.567 + {
1.568 + TInt expectedResult;
1.569 + TInt result;
1.570 +
1.571 + SetTestStepResult(EFail);
1.572 +
1.573 + // Find the file to copy and the expected return code from the INI file
1.574 + GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
1.575 +
1.576 + INFO_PRINTF2(_L("Set Property expected result: %d"), expectedResult);
1.577 +
1.578 + __UHEAP_MARK;
1.579 +
1.580 + CManager *manager = CManager::NewLC();
1.581 + result = manager->SetProperty(EAgentPropertyBufferSize, 100);
1.582 + CleanupStack::PopAndDestroy(manager);
1.583 +
1.584 + // dummy test Agent expects KErrNotSupported
1.585 + if(result == expectedResult || result == KErrNotSupported)
1.586 + {
1.587 + SetTestStepResult(EPass);
1.588 + }
1.589 + else
1.590 + {
1.591 + INFO_PRINTF2(_L("SetProperty() returned with unexpected error: %d"), result);
1.592 + }
1.593 +
1.594 + __UHEAP_MARKEND;
1.595 + return TestStepResult();
1.596 + }
1.597 +
1.598 +
1.599 +/*
1.600 + * This step asks the agent to display information about a file
1.601 + *
1.602 + */
1.603 +
1.604 +CCAFManagerDisplayInfoStep::~CCAFManagerDisplayInfoStep()
1.605 + {
1.606 + }
1.607 +
1.608 +CCAFManagerDisplayInfoStep::CCAFManagerDisplayInfoStep(CCAFServer& aParent) : iParent(aParent)
1.609 + {
1.610 + SetTestStepName(KCAFManagerDisplayInfoStep);
1.611 + }
1.612 +
1.613 +
1.614 +TVerdict CCAFManagerDisplayInfoStep::doTestStepL()
1.615 + {
1.616 + TPtrC uri;
1.617 + TInt expectedResult;
1.618 + TInt result;
1.619 +
1.620 + SetTestStepResult(EFail);
1.621 +
1.622 + // Find the file to copy and the expected return code from the INI file
1.623 + GetStringFromConfig(ConfigSection(),_L("uri"),uri);
1.624 + GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
1.625 +
1.626 + INFO_PRINTF3(_L("DisplayInfo for %S expected result: %d"), &uri, expectedResult);
1.627 +
1.628 + __UHEAP_MARK;
1.629 +
1.630 + CManager *manager = CManager::NewLC();
1.631 + TRAP(result, manager->DisplayInfoL(EFileProperties, TVirtualPathPtr(uri)));
1.632 + CleanupStack::PopAndDestroy(manager);
1.633 +
1.634 + if(result == expectedResult)
1.635 + {
1.636 + SetTestStepResult(EPass);
1.637 + }
1.638 + else
1.639 + {
1.640 + INFO_PRINTF2(_L("DisplayInfoL() left with unexpected error: %d"), result);
1.641 + }
1.642 +
1.643 + __UHEAP_MARKEND;
1.644 + return TestStepResult();
1.645 + }
1.646 +
1.647 +/*
1.648 + * This step asks CAF for a list of agents
1.649 + *
1.650 + */
1.651 +
1.652 +CCAFManagerListAgentsStep::~CCAFManagerListAgentsStep()
1.653 + {
1.654 + }
1.655 +
1.656 +CCAFManagerListAgentsStep::CCAFManagerListAgentsStep(CCAFServer& aParent) : iParent(aParent)
1.657 + {
1.658 + SetTestStepName(KCAFManagerListAgentsStep);
1.659 + }
1.660 +
1.661 +
1.662 +TVerdict CCAFManagerListAgentsStep::doTestStepL()
1.663 + {
1.664 + TPtrC uri;
1.665 + TInt expectedResult;
1.666 + TInt expectedNumber;
1.667 + TInt result;
1.668 +
1.669 + RArray <TAgent> agents;
1.670 +
1.671 + SetTestStepResult(EFail);
1.672 +
1.673 + // Find the file to copy and the expected return code from the INI file
1.674 + GetIntFromConfig(ConfigSection(),_L("count"),expectedNumber);
1.675 + GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
1.676 +
1.677 + INFO_PRINTF2(_L("List agents expected result: %d"), expectedResult);
1.678 +
1.679 + __UHEAP_MARK;
1.680 +
1.681 + CManager *manager = CManager::NewLC();
1.682 + TRAP(result, manager->ListAgentsL(agents));
1.683 + CleanupStack::PopAndDestroy(manager);
1.684 +
1.685 + TInt i = 0;
1.686 + for (i = 0; i < agents.Count(); i++)
1.687 + {
1.688 + TPtrC agentName = agents[i].Name();
1.689 + INFO_PRINTF2(_L(" %S"), &agentName);
1.690 + }
1.691 +
1.692 + INFO_PRINTF2(_L("List agents expected result: %d"), expectedResult);
1.693 +
1.694 + if(result == expectedResult)
1.695 + {
1.696 + if(expectedNumber == agents.Count())
1.697 + {
1.698 + SetTestStepResult(EPass);
1.699 + }
1.700 + else
1.701 + {
1.702 + INFO_PRINTF2(_L("Expected number of agents: %d"), expectedNumber);
1.703 + }
1.704 + }
1.705 + else
1.706 + {
1.707 + INFO_PRINTF2(_L("ListAgents left with unexpected error: %d"), result);
1.708 + }
1.709 +
1.710 + agents.Close();
1.711 +
1.712 + __UHEAP_MARKEND;
1.713 + return TestStepResult();
1.714 + }
1.715 +
1.716 +/*
1.717 + * This step attempts to perform an agent specific command
1.718 + *
1.719 + */
1.720 +
1.721 +CCAFManagerAgentSpecificStep::~CCAFManagerAgentSpecificStep()
1.722 + {
1.723 + }
1.724 +
1.725 +CCAFManagerAgentSpecificStep::CCAFManagerAgentSpecificStep(CCAFServer& aParent) : iParent(aParent)
1.726 + {
1.727 + SetTestStepName(KCAFManagerAgentSpecificStep);
1.728 + }
1.729 +
1.730 +
1.731 +TVerdict CCAFManagerAgentSpecificStep::doTestStepL()
1.732 + {
1.733 + TPtrC input16;
1.734 + TPtrC output16;
1.735 + TInt expectedResult;
1.736 + TInt command;
1.737 + TInt result;
1.738 + TBuf8 <100> actualOutput;
1.739 + TBuf8 <100> output;
1.740 + TBuf8 <100> input;
1.741 + TInt index = 0;
1.742 +
1.743 + RArray <TAgent> agents;
1.744 + _LIT(KTestAgentName, "Reference Test Agent");
1.745 +
1.746 + SetTestStepResult(EPass);
1.747 +
1.748 + GetIntFromConfig(ConfigSection(),_L("command"),command);
1.749 + GetStringFromConfig(ConfigSection(),_L("input"),input16);
1.750 + GetStringFromConfig(ConfigSection(),_L("output"),output16);
1.751 + GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
1.752 +
1.753 + input.Copy(input16);
1.754 + output.Copy(output16);
1.755 +
1.756 + __UHEAP_MARK;
1.757 + CManager *manager = CManager::NewLC();
1.758 + TRAP(result, manager->ListAgentsL(agents));
1.759 +
1.760 + INFO_PRINTF1(_L("Running synchronous Agent specific command"));
1.761 + actualOutput.SetLength(0);
1.762 + if(result == KErrNone && agents.Count() > 0)
1.763 + {
1.764 + for(index = 0; index < agents.Count(); index++)
1.765 + {
1.766 + if(agents[index].Name() == KTestAgentName())
1.767 + {
1.768 + break;
1.769 + }
1.770 + }
1.771 + result = manager->AgentSpecificCommand(agents[index],command, input, actualOutput);
1.772 + }
1.773 + else
1.774 + {
1.775 + SetTestStepResult(EFail);
1.776 + }
1.777 + if(result != expectedResult)
1.778 + {
1.779 + SetTestStepResult(EFail);
1.780 + INFO_PRINTF3(_L("Async Expected result: %d, actual result: %d"), expectedResult, result);
1.781 + }
1.782 + else if(actualOutput != output)
1.783 + {
1.784 + SetTestStepResult(EFail);
1.785 + INFO_PRINTF3(_L("Async Expected output: %S, actual output: %S"), &output, &actualOutput);
1.786 + }
1.787 +
1.788 + INFO_PRINTF1(_L("Running asynchronous Agent specific command"));
1.789 + TRequestStatus status;
1.790 + actualOutput.SetLength(0);
1.791 + if((result == KErrNone || result == expectedResult) && agents.Count() > 0)
1.792 + {
1.793 + manager->AgentSpecificCommand(agents[index], command, input, actualOutput, status);
1.794 + User::WaitForRequest(status);
1.795 + }
1.796 + else
1.797 + {
1.798 + SetTestStepResult(EFail);
1.799 + }
1.800 + if(status.Int() != expectedResult)
1.801 + {
1.802 + SetTestStepResult(EFail);
1.803 + INFO_PRINTF3(_L("Async Expected result: %d, actual result: %d"), expectedResult, status.Int());
1.804 + }
1.805 + else if(actualOutput != output)
1.806 + {
1.807 + SetTestStepResult(EFail);
1.808 + INFO_PRINTF3(_L("Async Expected output: %S, actual output: %S"), &output, &actualOutput);
1.809 + }
1.810 +
1.811 + CleanupStack::PopAndDestroy(manager);
1.812 + agents.Close();
1.813 +
1.814 + __UHEAP_MARKEND;
1.815 + return TestStepResult();
1.816 + }
1.817 +
1.818 +/*
1.819 + * This step attempts to display configuration information
1.820 + *
1.821 + */
1.822 +
1.823 +CCAFManagerDisplayConfigStep::~CCAFManagerDisplayConfigStep()
1.824 + {
1.825 + }
1.826 +
1.827 +CCAFManagerDisplayConfigStep::CCAFManagerDisplayConfigStep(CCAFServer& aParent) : iParent(aParent)
1.828 + {
1.829 + SetTestStepName(KCAFManagerDisplayConfigStep);
1.830 + }
1.831 +
1.832 +TVerdict CCAFManagerDisplayConfigStep::doTestStepL()
1.833 + {
1.834 + TInt expectedResult;
1.835 + TInt result = KErrNone;
1.836 +
1.837 + RArray <TAgent> agents;
1.838 + CManager *manager;
1.839 +
1.840 + SetTestStepResult(EPass);
1.841 +
1.842 + GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
1.843 +
1.844 + __UHEAP_MARK;
1.845 + manager = CManager::NewL();
1.846 + CleanupStack::PushL(manager);
1.847 + TRAP(result, manager->ListAgentsL(agents));
1.848 +
1.849 + if(result == KErrNone && agents.Count() > 0)
1.850 + {
1.851 + TRAP(result, manager->DisplayManagementInfoL(agents[0]));
1.852 + }
1.853 + else
1.854 + {
1.855 + SetTestStepResult(EFail);
1.856 + }
1.857 + if(result != expectedResult && result != KErrNotSupported) // dummy test agent expects -5
1.858 + {
1.859 + SetTestStepResult(EFail);
1.860 + INFO_PRINTF3(_L("Expected result: %d, actual result: %d"), expectedResult, result);
1.861 + }
1.862 +
1.863 + CleanupStack::PopAndDestroy(manager);
1.864 + agents.Close();
1.865 +
1.866 + __UHEAP_MARKEND;
1.867 + return TestStepResult();
1.868 + }
1.869 +
1.870 +/*
1.871 + * Manager attribute step
1.872 + *
1.873 + */
1.874 +
1.875 +CCAFManagerAttributeStep::~CCAFManagerAttributeStep()
1.876 + {
1.877 + }
1.878 +
1.879 +CCAFManagerAttributeStep::CCAFManagerAttributeStep(CCAFServer& aParent) : iParent(aParent)
1.880 + {
1.881 + SetTestStepName(KCAFManagerAttributeStep);
1.882 + }
1.883 +
1.884 +TVerdict CCAFManagerAttributeStep::doTestStepL()
1.885 + {
1.886 +#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
1.887 + TBool wmdrmFlag = EFalse;
1.888 + GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag);
1.889 +
1.890 + if(wmdrmFlag)
1.891 + {
1.892 + TVerdict verdict = doWmdrmTestStepL();
1.893 + return verdict;
1.894 + }
1.895 +#endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
1.896 +
1.897 + TInt attribute;
1.898 + TInt value = KErrNone;
1.899 + TInt expectedValue;
1.900 + TPtrC uri;
1.901 + TPtrC uniqueId;
1.902 +
1.903 + CManager *manager;
1.904 +
1.905 + SetTestStepResult(EPass);
1.906 +
1.907 + GetIntFromConfig(ConfigSection(),_L("attribute"),attribute);
1.908 + GetStringFromConfig(ConfigSection(),_L("uri"),uri);
1.909 + GetStringFromConfig(ConfigSection(),_L("uniqueid"),uniqueId);
1.910 + GetIntFromConfig(ConfigSection(),_L("value"),expectedValue);
1.911 +
1.912 + __UHEAP_MARK;
1.913 + manager = CManager::NewL();
1.914 + if(manager)
1.915 + {
1.916 + CleanupStack::PushL(manager);
1.917 + User::LeaveIfError(manager->GetAttribute(attribute, value, TVirtualPathPtr(uri, uniqueId)));
1.918 + if(expectedValue!= value)
1.919 + {
1.920 + SetTestStepResult(EFail);
1.921 + INFO_PRINTF3(_L("CManager::GetAttribute() Expected value: %d, actual value: %d"), expectedValue, value);
1.922 + }
1.923 + CleanupStack::PopAndDestroy(manager);
1.924 + }
1.925 + else
1.926 + {
1.927 + SetTestStepResult(EFail);
1.928 + INFO_PRINTF1(_L("CManager construction failed"));
1.929 + }
1.930 +
1.931 +
1.932 + __UHEAP_MARKEND;
1.933 + return TestStepResult();
1.934 + }
1.935 +
1.936 +/*
1.937 + * Manager attributeset step
1.938 + *
1.939 + */
1.940 +
1.941 +CCAFManagerAttributeSetStep::~CCAFManagerAttributeSetStep()
1.942 + {
1.943 + }
1.944 +
1.945 +CCAFManagerAttributeSetStep::CCAFManagerAttributeSetStep(CCAFServer& aParent) : iParent(aParent)
1.946 + {
1.947 + SetTestStepName(KCAFManagerAttributeSetStep);
1.948 + }
1.949 +
1.950 +TVerdict CCAFManagerAttributeSetStep::doTestStepL()
1.951 + {
1.952 +#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
1.953 + TBool wmdrmFlag = EFalse;
1.954 + GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag);
1.955 +
1.956 + if(wmdrmFlag)
1.957 + {
1.958 + TVerdict verdict = doWmdrmTestStepL();
1.959 + return verdict;
1.960 + }
1.961 +#endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
1.962 +
1.963 + TInt value1;
1.964 + TInt value2;
1.965 + TInt expectedValue1;
1.966 + TInt expectedValue2;
1.967 + TInt attribute1;
1.968 + TInt attribute2;
1.969 + TInt result = KErrNone;
1.970 + TPtrC uri;
1.971 + TPtrC uniqueId;
1.972 +
1.973 + CManager *manager;
1.974 +
1.975 + SetTestStepResult(EPass);
1.976 +
1.977 + GetStringFromConfig(ConfigSection(),_L("uri"),uri);
1.978 + GetStringFromConfig(ConfigSection(),_L("uniqueid"),uniqueId);
1.979 + GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1);
1.980 + GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2);
1.981 + GetIntFromConfig(ConfigSection(),_L("value1"),expectedValue1);
1.982 + GetIntFromConfig(ConfigSection(),_L("value2"),expectedValue2);
1.983 +
1.984 + __UHEAP_MARK;
1.985 + manager = CManager::NewL();
1.986 + if(manager)
1.987 + {
1.988 + CleanupStack::PushL(manager);
1.989 + RAttributeSet attributeSet;
1.990 + CleanupClosePushL(attributeSet);
1.991 + attributeSet.AddL(attribute1);
1.992 + attributeSet.AddL(attribute2);
1.993 + result = manager->GetAttributeSet(attributeSet, TVirtualPathPtr(uri, uniqueId));
1.994 + if(result != KErrNone)
1.995 + {
1.996 + SetTestStepResult(EFail);
1.997 + INFO_PRINTF1(_L("CManager::GetAttribute() failed"));
1.998 + }
1.999 + User::LeaveIfError(attributeSet.GetValue(attribute1, value1));
1.1000 + User::LeaveIfError(attributeSet.GetValue(attribute2, value2));
1.1001 + if(expectedValue1 != value1 || expectedValue2 != value2 || attributeSet.Count() != 2)
1.1002 + {
1.1003 + SetTestStepResult(EFail);
1.1004 + INFO_PRINTF1(_L("CManager::GetAttributeSet() values don't match expected values"));
1.1005 + }
1.1006 + CleanupStack::PopAndDestroy(&attributeSet);
1.1007 + CleanupStack::PopAndDestroy(manager);
1.1008 + }
1.1009 + else
1.1010 + {
1.1011 + SetTestStepResult(EFail);
1.1012 + INFO_PRINTF1(_L("CManager construction failed"));
1.1013 + }
1.1014 +
1.1015 +
1.1016 + __UHEAP_MARKEND;
1.1017 + return TestStepResult();
1.1018 + }
1.1019 +
1.1020 +
1.1021 +/*
1.1022 + * Manager string attribute step
1.1023 + *
1.1024 + */
1.1025 +
1.1026 +CCAFManagerStringAttributeStep::~CCAFManagerStringAttributeStep()
1.1027 + {
1.1028 + }
1.1029 +
1.1030 +CCAFManagerStringAttributeStep::CCAFManagerStringAttributeStep(CCAFServer& aParent) : iParent(aParent)
1.1031 + {
1.1032 + SetTestStepName(KCAFManagerStringAttributeStep);
1.1033 + }
1.1034 +
1.1035 +TVerdict CCAFManagerStringAttributeStep::doTestStepL()
1.1036 + {
1.1037 +#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
1.1038 + TBool wmdrmFlag = EFalse;
1.1039 + GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag);
1.1040 +
1.1041 + if(wmdrmFlag)
1.1042 + {
1.1043 + TVerdict verdict = doWmdrmTestStepL();
1.1044 + return verdict;
1.1045 + }
1.1046 +#endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
1.1047 +
1.1048 + TInt expectedResult;
1.1049 + TInt attribute;
1.1050 + TPtrC expectedValue;
1.1051 + TBuf <200> value;
1.1052 + TInt result = KErrNone;
1.1053 + TPtrC uri;
1.1054 + TPtrC uniqueId;
1.1055 +
1.1056 + CManager *manager;
1.1057 +
1.1058 + SetTestStepResult(EPass);
1.1059 +
1.1060 + GetIntFromConfig(ConfigSection(),_L("attribute"),attribute);
1.1061 + GetStringFromConfig(ConfigSection(),_L("uri"),uri);
1.1062 + GetStringFromConfig(ConfigSection(),_L("uniqueid"),uniqueId);
1.1063 + GetStringFromConfig(ConfigSection(),_L("value"),expectedValue);
1.1064 + GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
1.1065 +
1.1066 + __UHEAP_MARK;
1.1067 + manager = CManager::NewL();
1.1068 + if(manager)
1.1069 + {
1.1070 + CleanupStack::PushL(manager);
1.1071 + result = manager->GetStringAttribute(attribute, value, TVirtualPathPtr(uri, uniqueId));
1.1072 + if(result != expectedResult)
1.1073 + {
1.1074 + SetTestStepResult(EFail);
1.1075 + INFO_PRINTF3(_L("CManager::GetStringAttribute() Expected result: %d, actual result: %d"), expectedResult, result);
1.1076 + }
1.1077 + if(value != expectedValue)
1.1078 + {
1.1079 + SetTestStepResult(EFail);
1.1080 + INFO_PRINTF3(_L("CManager::GetStringAttribute() Expected value: %S, actual result: %S"), &expectedValue, &value);
1.1081 + }
1.1082 +
1.1083 + CleanupStack::PopAndDestroy(manager);
1.1084 + }
1.1085 + else
1.1086 + {
1.1087 + SetTestStepResult(EFail);
1.1088 + INFO_PRINTF1(_L("CManager construction failed"));
1.1089 + }
1.1090 +
1.1091 +
1.1092 + __UHEAP_MARKEND;
1.1093 + return TestStepResult();
1.1094 + }
1.1095 +
1.1096 +/*
1.1097 + * Manager StringAttributeSet step
1.1098 + *
1.1099 + */
1.1100 +
1.1101 +CCAFManagerStringAttributeSetStep::~CCAFManagerStringAttributeSetStep()
1.1102 + {
1.1103 + }
1.1104 +
1.1105 +CCAFManagerStringAttributeSetStep::CCAFManagerStringAttributeSetStep(CCAFServer& aParent) : iParent(aParent)
1.1106 + {
1.1107 + SetTestStepName(KCAFManagerStringAttributeSetStep);
1.1108 + }
1.1109 +
1.1110 +TVerdict CCAFManagerStringAttributeSetStep::doTestStepL()
1.1111 + {
1.1112 +#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
1.1113 + TBool wmdrmFlag = EFalse;
1.1114 + GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag);
1.1115 +
1.1116 + if(wmdrmFlag)
1.1117 + {
1.1118 + TVerdict verdict = doWmdrmTestStepL();
1.1119 + return verdict;
1.1120 + }
1.1121 +#endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
1.1122 +
1.1123 + TPtrC expectedValue1;
1.1124 + TPtrC expectedValue2;
1.1125 + TBuf <200> value1;
1.1126 + TBuf <200> value2;
1.1127 + TInt result1;
1.1128 + TInt result2;
1.1129 + TInt attribute1;
1.1130 + TInt attribute2;
1.1131 + TInt result = KErrNone;
1.1132 + TPtrC uri;
1.1133 + TPtrC uniqueId;
1.1134 +
1.1135 + CManager *manager;
1.1136 +
1.1137 + SetTestStepResult(EPass);
1.1138 +
1.1139 + GetStringFromConfig(ConfigSection(),_L("uri"),uri);
1.1140 + GetStringFromConfig(ConfigSection(),_L("uniqueid"),uniqueId);
1.1141 + GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1);
1.1142 + GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2);
1.1143 + GetStringFromConfig(ConfigSection(),_L("value1"),expectedValue1);
1.1144 + GetStringFromConfig(ConfigSection(),_L("value2"),expectedValue2);
1.1145 + GetIntFromConfig(ConfigSection(),_L("result1"),result1);
1.1146 + GetIntFromConfig(ConfigSection(),_L("result2"),result2);
1.1147 +
1.1148 +
1.1149 + __UHEAP_MARK;
1.1150 + manager = CManager::NewL();
1.1151 + if(manager)
1.1152 + {
1.1153 + CleanupStack::PushL(manager);
1.1154 + RStringAttributeSet attributeSet;
1.1155 + CleanupClosePushL(attributeSet);
1.1156 + attributeSet.AddL(attribute1);
1.1157 + attributeSet.AddL(attribute2);
1.1158 + result = manager->GetStringAttributeSet(attributeSet, TVirtualPathPtr(uri, uniqueId));
1.1159 + if(result != KErrNone)
1.1160 + {
1.1161 + SetTestStepResult(EFail);
1.1162 + INFO_PRINTF1(_L("CManager::GetAttribute() failed"));
1.1163 + }
1.1164 + if(result1 != attributeSet.GetValue(attribute1, value1))
1.1165 + {
1.1166 + INFO_PRINTF1(_L("RStringAttributeSet::GetValue failed"));
1.1167 + }
1.1168 + if(result2 != attributeSet.GetValue(attribute2, value2))
1.1169 + {
1.1170 + INFO_PRINTF1(_L("RStringAttributeSet::GetValue failed"));
1.1171 + }
1.1172 + if(value1 != expectedValue1 || value2 != expectedValue2 || attributeSet.Count() != 2)
1.1173 + {
1.1174 + SetTestStepResult(EFail);
1.1175 + INFO_PRINTF1(_L("CManager::GetAttributeSet() values don't match expected values"));
1.1176 + }
1.1177 + CleanupStack::PopAndDestroy(&attributeSet);
1.1178 + CleanupStack::PopAndDestroy(manager);
1.1179 + }
1.1180 + else
1.1181 + {
1.1182 + SetTestStepResult(EFail);
1.1183 + INFO_PRINTF1(_L("CManager construction failed"));
1.1184 + }
1.1185 +
1.1186 +
1.1187 + __UHEAP_MARKEND;
1.1188 + return TestStepResult();
1.1189 + }
1.1190 +
1.1191 +
1.1192 +
1.1193 +
1.1194 +CIteratorTestStateMachine::CIteratorTestStateMachine(CCAFContentIteratorStep *aParent) : CActive(EPriorityStandard)
1.1195 + {
1.1196 + iParent = aParent;
1.1197 + }
1.1198 +
1.1199 +CIteratorTestStateMachine::~CIteratorTestStateMachine()
1.1200 + {
1.1201 + delete iter;
1.1202 + delete iPath;
1.1203 + delete iMimeType;
1.1204 + }
1.1205 +
1.1206 +void CIteratorTestStateMachine::DoCancel()
1.1207 + {
1.1208 + // Not used
1.1209 + CActiveScheduler::Stop();
1.1210 + }
1.1211 +
1.1212 +
1.1213 +void CIteratorTestStateMachine::RunTestL(const TDesC& aPath, TBool aRecursive, const TDesC8& aMimeType)
1.1214 + {
1.1215 + iPath = aPath.AllocL();
1.1216 + iMimeType = aMimeType.AllocL();
1.1217 + iRecursive = aRecursive;
1.1218 +
1.1219 + // This function will only return once all files have been found
1.1220 + // and the RunL() method calls CActiveScheduler::Stop()
1.1221 + CActiveScheduler::Add(this);
1.1222 + iStatus = KRequestPending;
1.1223 + SetActive();
1.1224 + TRequestStatus *ptr = &iStatus;
1.1225 + User::RequestComplete(ptr, KErrNone);
1.1226 + CActiveScheduler::Start();
1.1227 + }
1.1228 +
1.1229 +void CIteratorTestStateMachine::RunL()
1.1230 + {
1.1231 + TBuf <KMaxDataTypeLength> mime16;
1.1232 + TVirtualPathPtr location(KNullDesC(), KNullDesC());
1.1233 +
1.1234 + if(iStatus.Int() != KErrNone)
1.1235 + {
1.1236 + delete iter;
1.1237 + iter = NULL;
1.1238 + CActiveScheduler::Stop();
1.1239 + }
1.1240 + else
1.1241 + {
1.1242 + switch(iState)
1.1243 + {
1.1244 + case 0: // create iterator
1.1245 + iter = CContentIterator::NewL(*iPath, iRecursive, *iMimeType);
1.1246 + iStatus = KRequestPending;
1.1247 + iter->Next(iStatus);
1.1248 + SetActive();
1.1249 + iState = 1;
1.1250 + break;
1.1251 +
1.1252 + case 1: // get result of Next request
1.1253 + location = iter->VirtualPath();
1.1254 + mime16.Copy(iter->MimeType());
1.1255 + iParent->PrintResult(location.URI(), location.UniqueId(), mime16);
1.1256 + iStatus = KRequestPending;
1.1257 + iter->Next(iStatus);
1.1258 + SetActive();
1.1259 + break;
1.1260 + default:
1.1261 + CActiveScheduler::Stop();
1.1262 + break;
1.1263 + };
1.1264 + }
1.1265 + }
1.1266 +
1.1267 +/*
1.1268 + * Content Iterator Step
1.1269 + *
1.1270 + */
1.1271 +
1.1272 +CCAFContentIteratorStep::~CCAFContentIteratorStep()
1.1273 + {
1.1274 + }
1.1275 +
1.1276 +CCAFContentIteratorStep::CCAFContentIteratorStep(CCAFServer& aParent) : iParent(aParent)
1.1277 + {
1.1278 + SetTestStepName(KCAFContentIteratorStep);
1.1279 + }
1.1280 +
1.1281 +TVerdict CCAFContentIteratorStep::doTestStepL()
1.1282 + {
1.1283 + TPtrC path;
1.1284 + TPtrC mimeType;
1.1285 + TBuf8 <KMaxDataTypeLength> mimeType8;
1.1286 +
1.1287 + SetTestStepResult(EPass);
1.1288 +
1.1289 + GetStringFromConfig(ConfigSection(),_L("path"),path);
1.1290 + GetStringFromConfig(ConfigSection(),_L("mimetype"),mimeType);
1.1291 +
1.1292 + mimeType8.Copy(mimeType);
1.1293 +
1.1294 + __UHEAP_MARK;
1.1295 +
1.1296 + CIteratorTestStateMachine *t = new CIteratorTestStateMachine(this);
1.1297 +
1.1298 + t->RunTestL(path, ETrue, mimeType8);
1.1299 +
1.1300 + delete t;
1.1301 + __UHEAP_MARKEND;
1.1302 + return TestStepResult();
1.1303 + }
1.1304 +
1.1305 +void CCAFContentIteratorStep::PrintResult(const TDesC& aFileName, const TDesC& aUniqueId, const TDesC& aMimeType)
1.1306 + {
1.1307 + INFO_PRINTF4(_L("File: %S, UniqueId: %S, MimeType: %S"), &aFileName, &aUniqueId, &aMimeType);
1.1308 + }
1.1309 +
1.1310 +
1.1311 +/*
1.1312 + * This step asks the agent to display information about a file using the file handle
1.1313 + *
1.1314 + */
1.1315 +CCAFManagerDisplayInfoByFileHandleStep::~CCAFManagerDisplayInfoByFileHandleStep()
1.1316 + {
1.1317 + }
1.1318 +
1.1319 +CCAFManagerDisplayInfoByFileHandleStep::CCAFManagerDisplayInfoByFileHandleStep(CCAFServer& aParent) : iParent(aParent)
1.1320 + {
1.1321 + SetTestStepName(KCAFManagerDisplayInfoByFileHandleStep);
1.1322 + }
1.1323 +
1.1324 +
1.1325 +TVerdict CCAFManagerDisplayInfoByFileHandleStep::doTestStepL()
1.1326 + {
1.1327 + TInt result;
1.1328 +
1.1329 + //initialisation for testing purposes such as iUri, iFs, iFile, iExpectedResult and iUniqueId.
1.1330 + InitialiseFileHandleParametersL();
1.1331 +
1.1332 + SetTestStepResult(EFail);
1.1333 +
1.1334 + __UHEAP_MARK;
1.1335 + CManager *manager = CManager::NewLC();
1.1336 +
1.1337 + TRAP(result, manager->DisplayInfoL(EFileProperties, iFile, iUniqueId));
1.1338 + if(result == iExpectedResult)
1.1339 + {
1.1340 + SetTestStepResult(EPass);
1.1341 + INFO_PRINTF1(_L("CManager::DisplayInfoL()(RFile handle overload) PASSED"));
1.1342 + }
1.1343 + else
1.1344 + {
1.1345 + INFO_PRINTF1(_L("CManager::DisplayInfoL()(RFile handle overload) returned unexpected error"));
1.1346 + INFO_PRINTF3(_L("CManager::DisplayInfoL()(RFile handle overload) Expected result: %d, actual result: %d"), iExpectedResult, result);
1.1347 + }
1.1348 +
1.1349 + //cleanup manager instance
1.1350 + CleanupStack::PopAndDestroy(manager);
1.1351 + //cleanup iFs and iFile instances by closing the handles.
1.1352 + CleanupStack::PopAndDestroy(2, &iFs);
1.1353 +
1.1354 + __UHEAP_MARKEND;
1.1355 + return TestStepResult();
1.1356 + }
1.1357 +
1.1358 +/*
1.1359 + * Manager attribute step using file handle.
1.1360 + *
1.1361 + */
1.1362 +
1.1363 +CCAFManagerAttributeByFileHandleStep::~CCAFManagerAttributeByFileHandleStep()
1.1364 + {
1.1365 + }
1.1366 +
1.1367 +CCAFManagerAttributeByFileHandleStep::CCAFManagerAttributeByFileHandleStep(CCAFServer& aParent) : iParent(aParent)
1.1368 + {
1.1369 + SetTestStepName(KCAFManagerAttributeByFileHandleStep);
1.1370 + }
1.1371 +
1.1372 +TVerdict CCAFManagerAttributeByFileHandleStep::doTestStepL()
1.1373 + {
1.1374 + TInt attribute;
1.1375 + TInt value = KErrNone;
1.1376 + TInt result= KErrNone;
1.1377 + TInt expectedValue;
1.1378 +
1.1379 + //initialisation for testing purposes such as iUri, iFs, iFile, iExpectedResult and iUniqueId.
1.1380 + InitialiseFileHandleParametersL();
1.1381 + GetIntFromConfig(ConfigSection(),_L("attribute"),attribute);
1.1382 + GetIntFromConfig(ConfigSection(),_L("value"),expectedValue);
1.1383 +
1.1384 + SetTestStepResult(EFail);
1.1385 +
1.1386 + __UHEAP_MARK;
1.1387 + CManager *manager = CManager::NewLC();
1.1388 +
1.1389 + result = manager->GetAttribute(attribute, value, iFile, iUniqueId);
1.1390 + //expectedResult has priority over the values collected.
1.1391 + if(result == iExpectedResult)
1.1392 + {
1.1393 + if(value == expectedValue)
1.1394 + {
1.1395 + SetTestStepResult(EPass);
1.1396 + INFO_PRINTF1(_L("CManager::GetAttribute()(RFile handle overload) PASSED"));
1.1397 + }
1.1398 + else
1.1399 + {
1.1400 + INFO_PRINTF1(_L("CManager::GetAttribute()(RFile handle overload) values don't match expected values"));
1.1401 + INFO_PRINTF3(_L("CManager::GetAttribute()(RFile handle overload) Expected value: %d, actual value: %d"), expectedValue, value);
1.1402 + }
1.1403 + }
1.1404 + else
1.1405 + {
1.1406 + INFO_PRINTF1(_L("CManager::GetAttribute()(RFile handle overload) returned unexpected error"));
1.1407 + INFO_PRINTF3(_L("CManager::GetAttribute()(RFile handle overload) Expected result: %d, actual result: %d"), iExpectedResult, result);
1.1408 + }
1.1409 +
1.1410 + //cleanup manager instance
1.1411 + CleanupStack::PopAndDestroy(manager);
1.1412 + //cleanup iFs and iFile instances by closing the handles.
1.1413 + CleanupStack::PopAndDestroy(2, &iFs);
1.1414 +
1.1415 + __UHEAP_MARKEND;
1.1416 + return TestStepResult();
1.1417 + }
1.1418 +
1.1419 +/*
1.1420 + * Manager attributeset step by file handle.
1.1421 + *
1.1422 + */
1.1423 +
1.1424 +CCAFManagerAttributeSetByFileHandleStep::~CCAFManagerAttributeSetByFileHandleStep()
1.1425 + {
1.1426 + }
1.1427 +
1.1428 +CCAFManagerAttributeSetByFileHandleStep::CCAFManagerAttributeSetByFileHandleStep(CCAFServer& aParent) : iParent(aParent)
1.1429 + {
1.1430 + SetTestStepName(KCAFManagerAttributeSetByFileHandleStep);
1.1431 + }
1.1432 +
1.1433 +TVerdict CCAFManagerAttributeSetByFileHandleStep::doTestStepL()
1.1434 + {
1.1435 + TInt value1;
1.1436 + TInt value2;
1.1437 + TInt expectedValue1;
1.1438 + TInt expectedValue2;
1.1439 + TInt attribute1;
1.1440 + TInt attribute2;
1.1441 + TInt result = KErrNone;
1.1442 +
1.1443 + //initialisation for testing purposes such as iUri, iFs, iFile, iExpectedResult and iUniqueId.
1.1444 + InitialiseFileHandleParametersL();
1.1445 + GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1);
1.1446 + GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2);
1.1447 + GetIntFromConfig(ConfigSection(),_L("value1"),expectedValue1);
1.1448 + GetIntFromConfig(ConfigSection(),_L("value2"),expectedValue2);
1.1449 +
1.1450 + SetTestStepResult(EFail);
1.1451 +
1.1452 + __UHEAP_MARK;
1.1453 + CManager *manager = CManager::NewLC();
1.1454 +
1.1455 + RAttributeSet attributeSet;
1.1456 + CleanupClosePushL(attributeSet);
1.1457 + attributeSet.AddL(attribute1);
1.1458 + attributeSet.AddL(attribute2);
1.1459 +
1.1460 + result = manager->GetAttributeSet(attributeSet, iFile, iUniqueId);
1.1461 + //expectedResult has priority over the values collected.
1.1462 + if(result == iExpectedResult)
1.1463 + {
1.1464 + User::LeaveIfError(attributeSet.GetValue(attribute1, value1));
1.1465 + User::LeaveIfError(attributeSet.GetValue(attribute2, value2));
1.1466 + if(value1 == expectedValue1 && value2 == expectedValue2)
1.1467 + {
1.1468 + SetTestStepResult(EPass);
1.1469 + INFO_PRINTF1(_L("CManager::GetAttributeSet()(RFile handle overload) PASSED"));
1.1470 + }
1.1471 + else
1.1472 + {
1.1473 + INFO_PRINTF1(_L("CManager::GetAttributeSet()(RFile handle overload) values don't match expected values"));
1.1474 + INFO_PRINTF3(_L("CManager::GetAttributeSet()(RFile handle overload) Expected value: %d, actual value: %d"), expectedValue1, value1);
1.1475 + INFO_PRINTF3(_L("CManager::GetAttributeSet()(RFile handle overload) Expected value: %d, actual value: %d"), expectedValue2, value2);
1.1476 + }
1.1477 + }
1.1478 + else
1.1479 + {
1.1480 + INFO_PRINTF1(_L("CManager::GetAttributeSet()(RFile handle overload) returned unexpected error"));
1.1481 + INFO_PRINTF3(_L("CManager::GetAttributeSet()(RFile handle overload) Expected result: %d, actual result: %d"), iExpectedResult, result);
1.1482 + }
1.1483 +
1.1484 + //cleanup manager and attributeSet instances
1.1485 + CleanupStack::PopAndDestroy(2, manager);
1.1486 + //cleanup iFs and iFile instances by closing the handles.
1.1487 + CleanupStack::PopAndDestroy(2, &iFs);
1.1488 +
1.1489 + __UHEAP_MARKEND;
1.1490 + return TestStepResult();
1.1491 + }
1.1492 +
1.1493 +
1.1494 +/*
1.1495 + * Manager string attribute step by file handle
1.1496 + *
1.1497 + */
1.1498 +
1.1499 +CCAFManagerStringAttributeByFileHandleStep::~CCAFManagerStringAttributeByFileHandleStep()
1.1500 + {
1.1501 + }
1.1502 +
1.1503 +CCAFManagerStringAttributeByFileHandleStep::CCAFManagerStringAttributeByFileHandleStep(CCAFServer& aParent) : iParent(aParent)
1.1504 + {
1.1505 + SetTestStepName(KCAFManagerStringAttributeByFileHandleStep);
1.1506 + }
1.1507 +
1.1508 +TVerdict CCAFManagerStringAttributeByFileHandleStep::doTestStepL()
1.1509 + {
1.1510 + TInt attribute;
1.1511 + TInt result = KErrNone;
1.1512 + TPtrC expectedValue;
1.1513 + TBuf <200> value;
1.1514 +
1.1515 + //initialisation for testing purposes such as iUri, iFs, iFile, iExpectedResult and iUniqueId.
1.1516 + InitialiseFileHandleParametersL();
1.1517 + GetIntFromConfig(ConfigSection(),_L("attribute"),attribute);
1.1518 + GetStringFromConfig(ConfigSection(),_L("value"),expectedValue);
1.1519 +
1.1520 + SetTestStepResult(EFail);
1.1521 +
1.1522 + __UHEAP_MARK;
1.1523 + CManager* manager = CManager::NewLC();
1.1524 +
1.1525 + result = manager->GetStringAttribute(attribute, value, iFile, iUniqueId);
1.1526 + //expectedResult has priority over the values collected.
1.1527 + if(result == iExpectedResult)
1.1528 + {
1.1529 + if (value == expectedValue)
1.1530 + {
1.1531 + SetTestStepResult(EPass);
1.1532 + INFO_PRINTF1(_L("CManager::GetStringAttribute()(RFile handle overload) PASSED"));
1.1533 + }
1.1534 + else
1.1535 + {
1.1536 + INFO_PRINTF1(_L("CManager::GetStringAttribute()(RFile handle overload) values don't match expected values"));
1.1537 + INFO_PRINTF3(_L("CManager::GetStringAttribute()(RFile handle overload) Expected value: %S, actual value: %S"), &expectedValue, &value);
1.1538 + }
1.1539 + }
1.1540 + else
1.1541 + {
1.1542 + INFO_PRINTF1(_L("CManager::GetStringAttribute()(RFile handle overload) returned unexpected error"));
1.1543 + INFO_PRINTF3(_L("CManager::GetStringAttribute()(RFile handle overload) Expected result: %d, actual result: %d"), iExpectedResult, result);
1.1544 + }
1.1545 +
1.1546 + //cleanup manager instance
1.1547 + CleanupStack::PopAndDestroy(manager);
1.1548 + //cleanup iFs and iFile instances by closing the handles.
1.1549 + CleanupStack::PopAndDestroy(2, &iFs);
1.1550 +
1.1551 + __UHEAP_MARKEND;
1.1552 + return TestStepResult();
1.1553 + }
1.1554 +
1.1555 +/*
1.1556 + * Manager StringAttributeSet step by file handle.
1.1557 + *
1.1558 + */
1.1559 +
1.1560 +CCAFManagerStringAttributeSetByFileHandleStep::~CCAFManagerStringAttributeSetByFileHandleStep()
1.1561 + {
1.1562 + }
1.1563 +
1.1564 +CCAFManagerStringAttributeSetByFileHandleStep::CCAFManagerStringAttributeSetByFileHandleStep(CCAFServer& aParent) : iParent(aParent)
1.1565 + {
1.1566 + SetTestStepName(KCAFManagerStringAttributeSetByFileHandleStep);
1.1567 + }
1.1568 +
1.1569 +TVerdict CCAFManagerStringAttributeSetByFileHandleStep::doTestStepL()
1.1570 + {
1.1571 + TInt attribute1;
1.1572 + TInt attribute2;
1.1573 + TInt result = KErrNone;
1.1574 + TPtrC expectedValue1;
1.1575 + TPtrC expectedValue2;
1.1576 + TBuf <200> value1;
1.1577 + TBuf <200> value2;
1.1578 +
1.1579 + //initialisation for testing purposes such as iUri, iFs, iFile, iExpectedResult and iUniqueId.
1.1580 + InitialiseFileHandleParametersL();
1.1581 + GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1);
1.1582 + GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2);
1.1583 + GetStringFromConfig(ConfigSection(),_L("value1"),expectedValue1);
1.1584 + GetStringFromConfig(ConfigSection(),_L("value2"),expectedValue2);
1.1585 +
1.1586 + SetTestStepResult(EFail);
1.1587 +
1.1588 + __UHEAP_MARK;
1.1589 + CManager* manager = CManager::NewLC();
1.1590 +
1.1591 + RStringAttributeSet attributeSet;
1.1592 + CleanupClosePushL(attributeSet);
1.1593 + attributeSet.AddL(attribute1);
1.1594 + attributeSet.AddL(attribute2);
1.1595 +
1.1596 + result = manager->GetStringAttributeSet(attributeSet, iFile, iUniqueId);
1.1597 + //expectedResult has priority over the values collected.
1.1598 + if(result == iExpectedResult)
1.1599 + {
1.1600 + User::LeaveIfError(attributeSet.GetValue(attribute1, value1));
1.1601 + User::LeaveIfError(attributeSet.GetValue(attribute2, value2));
1.1602 + if (value1 == expectedValue1 && value2 == expectedValue2)
1.1603 + {
1.1604 + SetTestStepResult(EPass);
1.1605 + INFO_PRINTF1(_L("CManager::GetStringAttributeSet()(RFile handle overload) PASSED"));
1.1606 + }
1.1607 + else
1.1608 + {
1.1609 + INFO_PRINTF1(_L("CManager::GetStringAttributeSet()(RFile handle overload) values don't match expected values"));
1.1610 + INFO_PRINTF3(_L("CManager::GetStringAttributeSet()(RFile handle overload) Expected value: %S, actual value: %S"), &expectedValue1, &value1);
1.1611 + INFO_PRINTF3(_L("CManager::GetStringAttributeSet()(RFile handle overload) Expected value: %S, actual value: %S"), &expectedValue2, &value2);
1.1612 + }
1.1613 + }
1.1614 + else
1.1615 + {
1.1616 + INFO_PRINTF1(_L("CManager::GetStringAttributeSet()(RFile handle overload) returned unexpected error"));
1.1617 + INFO_PRINTF3(_L("CManager::GetStringAttributeSet()(RFile handle overload) Expected result: %d, actual result: %d"), iExpectedResult, result);
1.1618 + }
1.1619 +
1.1620 + //cleanup manager and attributeSet instances
1.1621 + CleanupStack::PopAndDestroy(2, manager);
1.1622 + //cleanup iFs and iFile instances by closing the handles.
1.1623 + CleanupStack::PopAndDestroy(2, &iFs);
1.1624 +
1.1625 + __UHEAP_MARKEND;
1.1626 + return TestStepResult();
1.1627 + }
1.1628 +
1.1629 +#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
1.1630 +
1.1631 +// The following methods test the various manager attribute APIs for WMDRM content.
1.1632 +
1.1633 +TVerdict CCAFManagerAttributeStep::doWmdrmTestStepL()
1.1634 + {
1.1635 + SetTestStepResult(EFail);
1.1636 +
1.1637 + TInt attribVal;
1.1638 + GetIntFromConfig(ConfigSection(),_L("attribute"), attribVal);
1.1639 +
1.1640 + TInt expectedValue;
1.1641 + GetIntFromConfig(ConfigSection(),_L("value"), expectedValue);
1.1642 +
1.1643 + __UHEAP_MARK;
1.1644 +
1.1645 + TPtrC header;
1.1646 + HBufC8* headerData = NULL;
1.1647 +
1.1648 + if(GetStringFromConfig(ConfigSection(),_L("header"), header))
1.1649 + {
1.1650 + headerData = ConvertDes16toHBufC8LC(header);
1.1651 + }
1.1652 + else
1.1653 + {
1.1654 + headerData = CreateWmdrmHeaderLC();
1.1655 + }
1.1656 +
1.1657 + TInt value;
1.1658 + CManager *manager = CManager::NewLC();
1.1659 +
1.1660 + User::LeaveIfError(manager->GetAttribute(*headerData, attribVal, value));
1.1661 + if(expectedValue == value)
1.1662 + {
1.1663 + SetTestStepResult(EPass);
1.1664 + }
1.1665 + else
1.1666 + {
1.1667 + INFO_PRINTF3(_L("CManager::GetAttribute() Expected value: %d, actual value: %d"), expectedValue, value);
1.1668 + }
1.1669 +
1.1670 + CleanupStack::PopAndDestroy(2, headerData);
1.1671 +
1.1672 + __UHEAP_MARKEND;
1.1673 + return TestStepResult();
1.1674 + }
1.1675 +
1.1676 +
1.1677 +TVerdict CCAFManagerAttributeSetStep::doWmdrmTestStepL()
1.1678 + {
1.1679 + SetTestStepResult(EFail);
1.1680 +
1.1681 + TInt attribute1;
1.1682 + GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1);
1.1683 +
1.1684 + TInt attribute2;
1.1685 + GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2);
1.1686 +
1.1687 + TInt expectedValue1;
1.1688 + GetIntFromConfig(ConfigSection(),_L("value1"),expectedValue1);
1.1689 +
1.1690 + TInt expectedValue2;
1.1691 + GetIntFromConfig(ConfigSection(),_L("value2"),expectedValue2);
1.1692 +
1.1693 +__UHEAP_MARK;
1.1694 +
1.1695 + TPtrC header;
1.1696 + HBufC8* headerData = NULL;
1.1697 +
1.1698 + if(GetStringFromConfig(ConfigSection(),_L("header"), header))
1.1699 + {
1.1700 + headerData = ConvertDes16toHBufC8LC(header);
1.1701 + }
1.1702 + else
1.1703 + {
1.1704 + headerData = CreateWmdrmHeaderLC();
1.1705 + }
1.1706 +
1.1707 + RAttributeSet attributeSet;
1.1708 + CleanupClosePushL(attributeSet);
1.1709 + attributeSet.AddL(attribute1);
1.1710 + attributeSet.AddL(attribute2);
1.1711 +
1.1712 + CManager *manager = CManager::NewLC();
1.1713 + TInt result = manager->GetAttributeSet(*headerData, attributeSet);
1.1714 + if(result == KErrNone)
1.1715 + {
1.1716 + SetTestStepResult(EPass);
1.1717 + }
1.1718 + else
1.1719 + {
1.1720 + INFO_PRINTF1(_L("CManager::GetAttributeSet() failed"));
1.1721 + }
1.1722 +
1.1723 + TInt value1;
1.1724 + User::LeaveIfError(attributeSet.GetValue(attribute1, value1));
1.1725 +
1.1726 + TInt value2;
1.1727 + User::LeaveIfError(attributeSet.GetValue(attribute2, value2));
1.1728 +
1.1729 + if(expectedValue1 == value1 && expectedValue2 == value2 && attributeSet.Count() == 2)
1.1730 + {
1.1731 + SetTestStepResult(EPass);
1.1732 + }
1.1733 + else
1.1734 + {
1.1735 + INFO_PRINTF1(_L("CManager::GetAttributeSet() values don't match expected values"));
1.1736 + }
1.1737 +
1.1738 + CleanupStack::PopAndDestroy(3, headerData);
1.1739 +
1.1740 +__UHEAP_MARKEND;
1.1741 +
1.1742 + return TestStepResult();
1.1743 + }
1.1744 +
1.1745 +
1.1746 +TVerdict CCAFManagerStringAttributeStep::doWmdrmTestStepL()
1.1747 + {
1.1748 + SetTestStepResult(EFail);
1.1749 +
1.1750 + TInt attribVal;
1.1751 + GetIntFromConfig(ConfigSection(),_L("attribute"),attribVal);
1.1752 +
1.1753 + TPtrC expectedValue;
1.1754 + GetStringFromConfig(ConfigSection(),_L("value"),expectedValue);
1.1755 +
1.1756 + TInt expectedResult;
1.1757 + GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
1.1758 +
1.1759 +__UHEAP_MARK;
1.1760 +
1.1761 + TPtrC header;
1.1762 + HBufC8* headerData = NULL;
1.1763 +
1.1764 + if(GetStringFromConfig(ConfigSection(),_L("header"), header))
1.1765 + {
1.1766 + headerData = ConvertDes16toHBufC8LC(header);
1.1767 + }
1.1768 + else
1.1769 + {
1.1770 + headerData = CreateWmdrmHeaderLC();
1.1771 + }
1.1772 +
1.1773 + CManager* manager = CManager::NewLC();
1.1774 + TBuf <200> value;
1.1775 + TInt result = manager->GetStringAttribute(*headerData, attribVal, value);
1.1776 + if(result == expectedResult && value == expectedValue)
1.1777 + {
1.1778 + SetTestStepResult(EPass);
1.1779 + }
1.1780 + else
1.1781 + {
1.1782 + INFO_PRINTF3(_L("CManager::GetStringAttribute() Expected result: %d, actual result: %d"), expectedResult, result);
1.1783 + INFO_PRINTF3(_L("CManager::GetStringAttribute() Expected value: %S, actual value: %S"), &expectedValue, &value);
1.1784 + }
1.1785 +
1.1786 + CleanupStack::PopAndDestroy(2, headerData);
1.1787 +
1.1788 +__UHEAP_MARKEND;
1.1789 +
1.1790 + return TestStepResult();
1.1791 + }
1.1792 +
1.1793 +
1.1794 +TVerdict CCAFManagerStringAttributeSetStep::doWmdrmTestStepL()
1.1795 + {
1.1796 + SetTestStepResult(EFail);
1.1797 +
1.1798 + TInt attribute1;
1.1799 + GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1);
1.1800 +
1.1801 + TInt attribute2;
1.1802 + GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2);
1.1803 +
1.1804 + TPtrC expectedValue1;
1.1805 + GetStringFromConfig(ConfigSection(),_L("value1"),expectedValue1);
1.1806 +
1.1807 + TPtrC expectedValue2;
1.1808 + GetStringFromConfig(ConfigSection(),_L("value2"),expectedValue2);
1.1809 +
1.1810 +__UHEAP_MARK;
1.1811 +
1.1812 + TPtrC header;
1.1813 + HBufC8* headerData = NULL;
1.1814 +
1.1815 + if(GetStringFromConfig(ConfigSection(),_L("header"), header))
1.1816 + {
1.1817 + headerData = ConvertDes16toHBufC8LC(header);
1.1818 + }
1.1819 + else
1.1820 + {
1.1821 + headerData = CreateWmdrmHeaderLC();
1.1822 + }
1.1823 +
1.1824 + RStringAttributeSet attributeSet;
1.1825 + CleanupClosePushL(attributeSet);
1.1826 + attributeSet.AddL(attribute1);
1.1827 + attributeSet.AddL(attribute2);
1.1828 +
1.1829 + CManager* manager = CManager::NewLC();
1.1830 + TInt result = manager->GetStringAttributeSet(*headerData, attributeSet);
1.1831 + TBuf <200> value1;
1.1832 + TBuf <200> value2;
1.1833 + if(result == KErrNone)
1.1834 + {
1.1835 + TInt result3 = attributeSet.GetValue(attribute1, value1);
1.1836 + TInt result4 = attributeSet.GetValue(attribute2, value2);
1.1837 +
1.1838 + if(value1 == expectedValue1 && value2 == expectedValue2 && attributeSet.Count() == 2
1.1839 + && result3 == KErrNone && result4 == KErrNone)
1.1840 + {
1.1841 + SetTestStepResult(EPass);
1.1842 + }
1.1843 + else
1.1844 + {
1.1845 + INFO_PRINTF3(_L("RStringAttributeSet::GetValue() for attribute1.Expected value: %S, actual value: %S"), &expectedValue1, &value1);
1.1846 + INFO_PRINTF3(_L("RStringAttributeSet::GetValue() for attribute2.Expected value: %S, actual value: %S"), &expectedValue2, &value2);
1.1847 + INFO_PRINTF3(_L("RStringAttributeSet::GetValue() for attribute1. Expected result: %d, actual result: %d"), 0, result3);
1.1848 + INFO_PRINTF3(_L("RStringAttributeSet::GetValue() for attribute2. Expected result: %d, actual result: %d"), 0, result4);
1.1849 + }
1.1850 + }
1.1851 + else
1.1852 + {
1.1853 + INFO_PRINTF1(_L("CManager::GetStringAttributeSet() failed"));
1.1854 + }
1.1855 +
1.1856 + CleanupStack::PopAndDestroy(3, headerData);
1.1857 +
1.1858 +__UHEAP_MARKEND;
1.1859 +
1.1860 + return TestStepResult();
1.1861 + }
1.1862 +
1.1863 +#endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT