First public contribution.
2 * Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
19 #include <test/testexecutelog.h>
20 #include <caf/content.h>
22 #include <caf/attribute.h>
23 #include "cafserver.h"
25 #include "contentstep.h"
26 #include "EmbeddedObject.h"
27 #include "StreamablePtrArray.h"
28 #include "attributeset.h"
29 #include "stringattributeset.h"
30 #include <caf/agentfactory.h>
32 using namespace ContentAccess;
35 * Content attribute step
39 CCAFContentAttributeStep::~CCAFContentAttributeStep()
43 CCAFContentAttributeStep::CCAFContentAttributeStep(CCAFServer& aParent) : iParent(aParent)
45 SetTestStepName(KCAFContentAttributeStep);
48 TVerdict CCAFContentAttributeStep::doTestStepL()
50 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
51 TBool wmdrmFlag = EFalse;
52 GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag);
56 TVerdict verdict = doWmdrmTestStepL();
59 #endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
62 TInt value = KErrNone;
64 TInt unresolvedUri = EFalse;
68 SetTestStepResult(EPass);
70 GetIntFromConfig(ConfigSection(),_L("attribute"),attribute);
71 GetStringFromConfig(ConfigSection(),_L("uri"),uri);
72 GetStringFromConfig(ConfigSection(),_L("uniqueid"),uniqueId);
73 GetIntFromConfig(ConfigSection(),_L("value"),expectedValue);
74 GetIntFromConfig(ConfigSection(),_L("unresolveduri"),unresolvedUri);
79 // Open using file name
80 CContent *content = CContent::NewLC(uri);
81 value = expectedValue+1;
82 User::LeaveIfError(content->GetAttribute(attribute, value, uniqueId));
83 if(expectedValue != value )
85 SetTestStepResult(EFail);
86 INFO_PRINTF3(_L("CContent::GetAttribute() Expected value: %d, actual value: %d"), expectedValue, value);
88 CleanupStack::PopAndDestroy(content);
90 // Open using file handle
91 // cannot do if URI is unresolved - i.e. if it contains "Reference Test Agent" instead of actual private directory name
95 file.Open(iParent.Fs(), uri, EFileShareReadersOnly);
96 content = CContent::NewLC(file);
98 value = expectedValue+1;
99 User::LeaveIfError(content->GetAttribute(attribute, value, uniqueId));
100 if(expectedValue != value)
102 SetTestStepResult(EFail);
103 INFO_PRINTF3(_L("CContent::GetAttribute() Expected value: %d, actual value: %d"), expectedValue, value);
105 CleanupStack::PopAndDestroy(content);
109 return TestStepResult();
113 * Content attributeset step
117 CCAFContentAttributeSetStep::~CCAFContentAttributeSetStep()
121 CCAFContentAttributeSetStep::CCAFContentAttributeSetStep(CCAFServer& aParent) : iParent(aParent)
123 SetTestStepName(KCAFContentAttributeSetStep);
126 TVerdict CCAFContentAttributeSetStep::doTestStepL()
128 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
129 TBool wmdrmFlag = EFalse;
130 GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag);
134 TVerdict verdict = doWmdrmTestStepL();
137 #endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
145 TInt result = KErrNone;
146 TInt unresolvedUri = EFalse;
150 SetTestStepResult(EPass);
152 GetStringFromConfig(ConfigSection(),_L("uri"),uri);
153 GetStringFromConfig(ConfigSection(),_L("uniqueid"),uniqueId);
154 GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1);
155 GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2);
156 GetIntFromConfig(ConfigSection(),_L("value1"),expectedValue1);
157 GetIntFromConfig(ConfigSection(),_L("value2"),expectedValue2);
158 GetIntFromConfig(ConfigSection(),_L("unresolveduri"),unresolvedUri);
161 // open using filename
162 CContent *content = CContent::NewLC(uri);
163 RAttributeSet attributeSet;
164 CleanupClosePushL(attributeSet);
165 attributeSet.AddL(attribute1);
166 attributeSet.AddL(attribute2);
168 if(uniqueId == KDefaultContentObject())
170 result = content->GetAttributeSet(attributeSet);
174 result = content->GetAttributeSet(attributeSet, uniqueId);
176 if(result != KErrNone)
178 SetTestStepResult(EFail);
179 INFO_PRINTF1(_L("CContent::GetAttribute() failed"));
182 User::LeaveIfError(attributeSet.GetValue(attribute1, value1));
183 User::LeaveIfError(attributeSet.GetValue(attribute2, value2));
184 if(expectedValue1 != value1 || expectedValue2 != value2 || attributeSet.Count() != 2)
186 SetTestStepResult(EFail);
187 INFO_PRINTF1(_L("CContent::GetAttributeSet() values don't match expected values"));
189 CleanupStack::PopAndDestroy(&attributeSet);
190 CleanupStack::PopAndDestroy(content);
192 // Open using file handle
193 // cannot do if URI is unresolved - i.e. if it contains "Reference Test Agent" instead of actual private directory name
197 file.Open(iParent.Fs(), uri, EFileShareReadersOnly);
198 content = CContent::NewLC(file);
201 CleanupClosePushL(attributeSet);
202 attributeSet.AddL(attribute1);
203 attributeSet.AddL(attribute2);
205 result = content->GetAttributeSet(attributeSet, uniqueId);
206 if(result != KErrNone)
208 SetTestStepResult(EFail);
209 INFO_PRINTF1(_L("CContent::GetAttribute() failed"));
212 User::LeaveIfError(attributeSet.GetValue(attribute1, value1));
213 User::LeaveIfError(attributeSet.GetValue(attribute2, value2));
214 if(expectedValue1 != value1 || expectedValue2 != value2 || attributeSet.Count() != 2)
216 SetTestStepResult(EFail);
217 INFO_PRINTF1(_L("CContent::GetAttributeSet() values don't match expected values"));
219 CleanupStack::PopAndDestroy(&attributeSet);
220 CleanupStack::PopAndDestroy(content);
223 return TestStepResult();
228 * Content string attribute step
232 CCAFContentStringAttributeStep::~CCAFContentStringAttributeStep()
236 CCAFContentStringAttributeStep::CCAFContentStringAttributeStep(CCAFServer& aParent) : iParent(aParent)
238 SetTestStepName(KCAFContentStringAttributeStep);
241 TVerdict CCAFContentStringAttributeStep::doTestStepL()
243 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
244 TBool wmdrmFlag = EFalse;
245 GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag);
249 TVerdict verdict = doWmdrmTestStepL();
252 #endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
256 TInt unresolvedUri = EFalse;
259 TInt result = KErrNone;
263 SetTestStepResult(EPass);
265 GetIntFromConfig(ConfigSection(),_L("attribute"),attribute);
266 GetStringFromConfig(ConfigSection(),_L("uri"),uri);
267 GetStringFromConfig(ConfigSection(),_L("uniqueid"),uniqueId);
268 GetStringFromConfig(ConfigSection(),_L("value"),expectedValue);
269 GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
270 GetIntFromConfig(ConfigSection(),_L("unresolveduri"),unresolvedUri);
274 // Open using file name
275 CContent *content = CContent::NewLC(uri);
277 if(uniqueId == KDefaultContentObject())
279 result = content->GetStringAttribute(attribute, value);
283 result = content->GetStringAttribute(attribute, value, uniqueId);
285 if(result != expectedResult)
287 SetTestStepResult(EFail);
288 INFO_PRINTF3(_L("CContent::GetStringAttribute() Expected result: %d, actual result: %d"), expectedResult, result);
290 if(value != expectedValue)
292 SetTestStepResult(EFail);
293 INFO_PRINTF3(_L("CContent::GetStringAttribute() Expected value: %S, actual result: %S"), &expectedValue, &value);
296 CleanupStack::PopAndDestroy(content);
298 // Open using file handle
299 // cannot do if URI is unresolved - i.e. if it contains "Reference Test Agent" instead of actual private directory name
303 file.Open(iParent.Fs(), uri, EFileShareReadersOnly);
304 content = CContent::NewLC(file);
307 result = content->GetStringAttribute(attribute, value, uniqueId);
308 if(result != expectedResult)
310 SetTestStepResult(EFail);
311 INFO_PRINTF3(_L("CContent::GetStringAttribute() Expected result: %d, actual result: %d"), expectedResult, result);
313 else if(value != expectedValue)
315 SetTestStepResult(EFail);
316 INFO_PRINTF3(_L("CContent::GetStringAttribute() Expected value: %S, actual result: %S"), &expectedValue, &value);
318 CleanupStack::PopAndDestroy(content);
323 return TestStepResult();
327 * Content StringAttributeSet step
331 CCAFContentStringAttributeSetStep::~CCAFContentStringAttributeSetStep()
335 CCAFContentStringAttributeSetStep::CCAFContentStringAttributeSetStep(CCAFServer& aParent) : iParent(aParent)
337 SetTestStepName(KCAFContentStringAttributeSetStep);
340 TVerdict CCAFContentStringAttributeSetStep::doTestStepL()
342 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
343 TBool wmdrmFlag = EFalse;
344 GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag);
348 TVerdict verdict = doWmdrmTestStepL();
351 #endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
353 TPtrC expectedValue1;
354 TPtrC expectedValue2;
361 TInt result = KErrNone;
362 TInt unresolvedUri = EFalse;
366 SetTestStepResult(EPass);
368 GetStringFromConfig(ConfigSection(),_L("uri"),uri);
369 GetStringFromConfig(ConfigSection(),_L("uniqueid"),uniqueId);
370 GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1);
371 GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2);
372 GetStringFromConfig(ConfigSection(),_L("value1"),expectedValue1);
373 GetStringFromConfig(ConfigSection(),_L("value2"),expectedValue2);
374 GetIntFromConfig(ConfigSection(),_L("result1"),result1);
375 GetIntFromConfig(ConfigSection(),_L("result2"),result2);
376 GetIntFromConfig(ConfigSection(),_L("unresolveduri"),unresolvedUri);
380 // Open using file name
381 CContent *content = CContent::NewLC(uri);
382 RStringAttributeSet attributeSet;
383 CleanupClosePushL(attributeSet);
384 attributeSet.AddL(attribute1);
385 attributeSet.AddL(attribute2);
387 if(uniqueId == KDefaultContentObject())
389 result = content->GetStringAttributeSet(attributeSet);
393 result = content->GetStringAttributeSet(attributeSet, uniqueId);
395 if(result != KErrNone)
397 SetTestStepResult(EFail);
398 INFO_PRINTF1(_L("CContent::GetAttribute() failed"));
400 if(result1 != attributeSet.GetValue(attribute1, value1))
402 INFO_PRINTF1(_L("RStringAttributeSet::GetValue failed"));
404 if(result2 != attributeSet.GetValue(attribute2, value2))
406 INFO_PRINTF1(_L("RStringAttributeSet::GetValue failed"));
408 if(value1 != expectedValue1 || value2 != expectedValue2 || attributeSet.Count() != 2)
410 SetTestStepResult(EFail);
411 INFO_PRINTF1(_L("CContent::GetAttributeSet() values don't match expected values"));
413 CleanupStack::PopAndDestroy(&attributeSet);
414 CleanupStack::PopAndDestroy(content);
417 // Open using file handle
418 // cannot do if URI is unresolved - i.e. if it contains "Reference Test Agent" instead of actual private directory name
422 file.Open(iParent.Fs(), uri, EFileShareReadersOnly);
423 content = CContent::NewLC(file);
426 CleanupClosePushL(attributeSet);
427 attributeSet.AddL(attribute1);
428 attributeSet.AddL(attribute2);
430 result = content->GetStringAttributeSet(attributeSet, uniqueId);
432 if(result != KErrNone)
434 SetTestStepResult(EFail);
435 INFO_PRINTF1(_L("CContent::GetAttribute() failed"));
438 if(result1 != attributeSet.GetValue(attribute1, value1))
440 INFO_PRINTF1(_L("RStringAttributeSet::GetValue failed"));
442 if(result2 != attributeSet.GetValue(attribute2, value2))
444 INFO_PRINTF1(_L("RStringAttributeSet::GetValue failed"));
447 if(value1 != expectedValue1 || value2 != expectedValue2 || attributeSet.Count() != 2)
449 SetTestStepResult(EFail);
450 INFO_PRINTF1(_L("CContent::GetAttributeSet() values don't match expected values"));
452 CleanupStack::PopAndDestroy(&attributeSet);
453 CleanupStack::PopAndDestroy(content);
456 return TestStepResult();
462 * This step tests the notification functions
466 CCAFContentNotifyStep::~CCAFContentNotifyStep()
470 CCAFContentNotifyStep::CCAFContentNotifyStep(CCAFServer& aParent) : iParent(aParent)
472 SetTestStepName(KCAFContentNotifyStep);
476 TVerdict CCAFContentNotifyStep::doTestStepL()
480 TRequestStatus status = KRequestPending;
487 SetTestStepResult(EPass);
489 // Find the file to copy and the expected return code from the INI file
490 GetStringFromConfig(ConfigSection(),_L("uri"),uri);
491 GetIntFromConfig(ConfigSection(),_L("Status1"),Status1);
492 GetIntFromConfig(ConfigSection(),_L("Cancel1"),Cancel1);
493 GetIntFromConfig(ConfigSection(),_L("Cancel2"),Cancel2);
495 INFO_PRINTF2(_L("Performing notification tests on %S"), &uri);
498 CContent *content = CContent::NewLC(uri);
500 content->NotifyStatusChange(ERightsAvailable, status);
501 User::WaitForRequest(status);
502 if(status.Int() != Status1)
504 INFO_PRINTF3(_L("Status expected: %d returned unexpected status %d"), Status1, status.Int());
505 SetTestStepResult(EFail);
507 result = content->CancelNotifyStatusChange(status);
508 if(result != Cancel1)
510 INFO_PRINTF3(_L("Cancel request expected return value: %d returned unexpected value %d"), Cancel1, result);
511 SetTestStepResult(EFail);
514 // Wait for rights expired but cancel before they arrive
515 content->NotifyStatusChange(ERightsExpired, status);
516 result = content->CancelNotifyStatusChange(status);
517 if(result != Cancel2)
519 INFO_PRINTF3(_L("Cancel2 request expected return value: %d returned unexpected value %d"), Cancel2, result);
520 SetTestStepResult(EFail);
523 CleanupStack::PopAndDestroy(content);
527 return TestStepResult();
531 * This step sets a property in the agents
535 CCAFContentSetPropertyStep::~CCAFContentSetPropertyStep()
539 CCAFContentSetPropertyStep::CCAFContentSetPropertyStep(CCAFServer& aParent) : iParent(aParent)
541 SetTestStepName(KCAFContentSetPropertyStep);
545 TVerdict CCAFContentSetPropertyStep::doTestStepL()
551 SetTestStepResult(EFail);
553 // Find the file to copy and the expected return code from the INI file
554 GetStringFromConfig(ConfigSection(),_L("uri"),uri);
555 GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
557 INFO_PRINTF2(_L("Set Property expected result: %d"), expectedResult);
561 CContent *content = CContent::NewLC(uri);
562 result = content->SetProperty(EAgentPropertyBufferSize, 100);
563 CleanupStack::PopAndDestroy(content);
565 if(result == expectedResult)
567 SetTestStepResult(EPass);
571 INFO_PRINTF2(_L("SetProperty() returned with unexpected error: %d"), result);
575 return TestStepResult();
580 * This step asks the agent to display information about a file
584 CCAFContentDisplayInfoStep::~CCAFContentDisplayInfoStep()
588 CCAFContentDisplayInfoStep::CCAFContentDisplayInfoStep(CCAFServer& aParent) : iParent(aParent)
590 SetTestStepName(KCAFContentDisplayInfoStep);
594 TVerdict CCAFContentDisplayInfoStep::doTestStepL()
600 SetTestStepResult(EFail);
602 // Find the file to copy and the expected return code from the INI file
603 GetStringFromConfig(ConfigSection(),_L("uri"),uri);
604 GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
606 INFO_PRINTF3(_L("DisplayInfo for %S expected result: %d"), &uri, expectedResult);
610 CContent *content = CContent::NewLC(uri);
611 TRAP(result, content->DisplayInfoL(EFileProperties));
612 CleanupStack::PopAndDestroy(content);
614 if(result == expectedResult)
616 SetTestStepResult(EPass);
620 INFO_PRINTF2(_L("DisplayInfoL() left with unexpected error: %d"), result);
624 return TestStepResult();
628 * This step attempts to perform an agent specific command
632 CCAFContentAgentSpecificStep::~CCAFContentAgentSpecificStep()
636 CCAFContentAgentSpecificStep::CCAFContentAgentSpecificStep(CCAFServer& aParent) : iParent(aParent)
638 SetTestStepName(KCAFContentAgentSpecificStep);
642 TVerdict CCAFContentAgentSpecificStep::doTestStepL()
650 TBuf8 <100> actualOutput;
655 SetTestStepResult(EPass);
657 GetStringFromConfig(ConfigSection(),_L("uri"),uri);
658 GetIntFromConfig(ConfigSection(),_L("command"),command);
659 GetStringFromConfig(ConfigSection(),_L("input"),input16);
660 GetStringFromConfig(ConfigSection(),_L("output"),output16);
661 GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
664 output.Copy(output16);
667 CContent *content = CContent::NewLC(uri);
669 INFO_PRINTF1(_L("Running synchronous Agent specific command"));
670 actualOutput.SetLength(0);
671 result = content->AgentSpecificCommand(command, input, actualOutput);
672 if(result != expectedResult)
674 SetTestStepResult(EFail);
675 INFO_PRINTF3(_L("Async Expected result: %d, actual result: %d"), expectedResult, result);
677 else if(actualOutput != output)
679 SetTestStepResult(EFail);
680 INFO_PRINTF3(_L("Async Expected output: %S, actual output: %S"), &output, &actualOutput);
683 INFO_PRINTF1(_L("Running asynchronous Agent specific command"));
684 TRequestStatus status;
685 actualOutput.SetLength(0);
686 content->AgentSpecificCommand(command, input, actualOutput, status);
687 User::WaitForRequest(status);
688 if(status.Int() != expectedResult)
690 SetTestStepResult(EFail);
691 INFO_PRINTF3(_L("Async Expected result: %d, actual result: %d"), expectedResult, status.Int());
693 else if(actualOutput != output)
695 SetTestStepResult(EFail);
696 INFO_PRINTF3(_L("Async Expected output: %S, actual output: %S"), &output, &actualOutput);
699 CleanupStack::PopAndDestroy(content);
702 return TestStepResult();
707 * This step tests the rights request functions
711 CCAFContentRequestRightsStep::~CCAFContentRequestRightsStep()
715 CCAFContentRequestRightsStep::CCAFContentRequestRightsStep(CCAFServer& aParent) : iParent(aParent)
717 SetTestStepName(KCAFContentRequestRightsStep);
721 TVerdict CCAFContentRequestRightsStep::doTestStepL()
725 TRequestStatus status = KRequestPending;
732 SetTestStepResult(EPass);
734 // Find the file to copy and the expected return code from the INI file
735 GetStringFromConfig(ConfigSection(),_L("uri"),uri);
736 GetIntFromConfig(ConfigSection(),_L("Status1"),Status1);
737 GetIntFromConfig(ConfigSection(),_L("Cancel1"),Cancel1);
738 GetIntFromConfig(ConfigSection(),_L("Cancel2"),Cancel2);
740 INFO_PRINTF2(_L("Performing Request Rights tests on %S"), &uri);
743 CContent *content = CContent::NewLC(uri);
745 content->RequestRights(status);
746 User::WaitForRequest(status);
747 if(status.Int() != Status1)
749 INFO_PRINTF3(_L("Status expected: %d returned unexpected status %d"), Status1, status.Int());
750 SetTestStepResult(EFail);
752 result = content->CancelRequestRights(status);
753 if(result != Cancel1)
755 INFO_PRINTF3(_L("Cancel request expected return value: %d returned unexpected value %d"), Cancel1, result);
756 SetTestStepResult(EFail);
759 // Wait for rights expired but cancel before they arrive
760 content->RequestRights(status);
761 result = content->CancelRequestRights(status);
762 if(result != Cancel2)
764 INFO_PRINTF3(_L("Cancel2 request expected return value: %d returned unexpected value %d"), Cancel2, result);
765 SetTestStepResult(EFail);
768 CleanupStack::PopAndDestroy(content);
772 return TestStepResult();
778 * This step tests the rights request functions
782 CCAFContentEmbeddedObjectsStep::~CCAFContentEmbeddedObjectsStep()
786 CCAFContentEmbeddedObjectsStep::CCAFContentEmbeddedObjectsStep(CCAFServer& aParent) : iParent(aParent)
788 SetTestStepName(KCAFContentEmbeddedObjectsStep);
792 TVerdict CCAFContentEmbeddedObjectsStep::doTestStepL()
798 SetTestStepResult(EPass);
800 // Find the file to copy and the expected return code from the INI file
801 GetStringFromConfig(ConfigSection(),_L("uri"),uri);
802 GetIntFromConfig(ConfigSection(),_L("count"),expectedCount);
803 GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
805 INFO_PRINTF2(_L("Finding embedded objects within %S"), &uri);
808 CContent *content = CContent::NewLC(uri);
810 RStreamablePtrArray <CEmbeddedObject> array;
811 CleanupClosePushL(array);
814 TRAPD(result, content->GetEmbeddedObjectsL(array));
815 if(result != expectedResult)
817 INFO_PRINTF3(_L("GetEmbeddedObjectsL() returned result of %d, expected %d"), result, expectedResult);
818 SetTestStepResult(EFail);
821 if((result == KErrNone) && (array.Count() != expectedCount))
823 INFO_PRINTF3(_L("GetEmbeddedObjectsL() found %d objects, expected %d"), array.Count(), expectedCount);
824 SetTestStepResult(EFail);
827 CleanupStack::PopAndDestroy(&array);
828 CleanupStack::PopAndDestroy(content);
832 return TestStepResult();
836 * This step tests the rights request functions
840 CCAFContentEmbeddedObjectTypeStep::~CCAFContentEmbeddedObjectTypeStep()
844 CCAFContentEmbeddedObjectTypeStep::CCAFContentEmbeddedObjectTypeStep(CCAFServer& aParent) : iParent(aParent)
846 SetTestStepName(KCAFContentEmbeddedObjectTypeStep);
850 TVerdict CCAFContentEmbeddedObjectTypeStep::doTestStepL()
853 TInt expectedContent;
854 TInt expectedContainers;
855 TInt expectedContainerResult;
856 TInt expectedContentResult;
858 SetTestStepResult(EPass);
860 // Find the file to copy and the expected return code from the INI file
861 GetStringFromConfig(ConfigSection(),_L("uri"),uri);
862 GetIntFromConfig(ConfigSection(),_L("contentcount"),expectedContent);
863 GetIntFromConfig(ConfigSection(),_L("containercount"),expectedContainers);
864 GetIntFromConfig(ConfigSection(),_L("containerresult"),expectedContainerResult);
865 GetIntFromConfig(ConfigSection(),_L("contentresult"),expectedContentResult);
867 INFO_PRINTF2(_L("Finding embedded objects within %S"), &uri);
870 CContent *content = CContent::NewLC(uri);
872 RStreamablePtrArray <CEmbeddedObject> array;
873 CleanupClosePushL(array);
875 // get embedded objects
876 TRAPD(result, content->GetEmbeddedObjectsL(array, EContainerObject));
878 if(result != expectedContainerResult)
880 INFO_PRINTF3(_L("GetEmbeddedObjectsL() returned result of %d, expected %d"), result, expectedContainerResult);
881 SetTestStepResult(EFail);
884 if((result == KErrNone) && (array.Count() != expectedContainers))
886 INFO_PRINTF3(_L("GetEmbeddedObjectsL() found %d container objects, expected %d"), array.Count(), expectedContainers);
887 SetTestStepResult(EFail);
891 array.ResetAndDestroy();
893 // get embedded objects
894 TRAP(result, content->GetEmbeddedObjectsL(array, EContentObject));
896 if(result != expectedContentResult)
898 INFO_PRINTF3(_L("GetEmbeddedObjectsL() returned result of %d, expected %d"), result, expectedContentResult);
899 SetTestStepResult(EFail);
902 if((result == KErrNone) && (array.Count() != expectedContent))
904 INFO_PRINTF3(_L("GetEmbeddedObjectsL() found %d content objects, expected %d"), array.Count(), expectedContent);
905 SetTestStepResult(EFail);
909 CleanupStack::PopAndDestroy(&array);
910 CleanupStack::PopAndDestroy(content);
914 return TestStepResult();
918 * This step tests the rights request functions
922 CCAFContentSearchStep::~CCAFContentSearchStep()
926 CCAFContentSearchStep::CCAFContentSearchStep(CCAFServer& aParent) : iParent(aParent)
928 SetTestStepName(KCAFContentSearchStep);
932 TVerdict CCAFContentSearchStep::doTestStepL()
939 TBuf8 <255> mimeType8;
941 SetTestStepResult(EPass);
943 // Find the file, mimetype, expected return code and expected count from the INI file
944 GetStringFromConfig(ConfigSection(),_L("uri"),uri);
945 GetIntFromConfig(ConfigSection(),_L("count"),expectedCount);
946 GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
947 GetStringFromConfig(ConfigSection(),_L("mimetype"),mimeType16);
949 mimeType8.Copy(mimeType16);
951 INFO_PRINTF3(_L("Search for embedded %S objects within %S"), &mimeType16, &uri);
954 CContent *content = CContent::NewLC(uri);
956 RStreamablePtrArray <CEmbeddedObject> array;
957 CleanupClosePushL(array);
959 // get embedded objects
960 result = content->Search(array, mimeType8, ETrue);
962 if(result != expectedResult)
964 INFO_PRINTF3(_L("Search() return value %d, expected %d"), result, expectedResult);
965 SetTestStepResult(EFail);
968 if(array.Count() != expectedCount)
970 INFO_PRINTF3(_L("Search() found %d objects, expected %d"), array.Count(), expectedCount);
971 SetTestStepResult(EFail);
974 CleanupStack::PopAndDestroy(&array);
975 CleanupStack::PopAndDestroy(content);
979 return TestStepResult();
983 * This step tests the container open/close functions
987 CCAFContentContainerStep::~CCAFContentContainerStep()
991 CCAFContentContainerStep::CCAFContentContainerStep(CCAFServer& aParent) : iParent(aParent)
993 SetTestStepName(KCAFContentContainerStep);
997 TVerdict CCAFContentContainerStep::doTestStepL()
1006 SetTestStepResult(EPass);
1008 // Find the file to copy and the expected return code from the INI file
1009 GetStringFromConfig(ConfigSection(),_L("uri"),uri);
1010 GetStringFromConfig(ConfigSection(),_L("uniqueId"),uniqueId);
1011 GetIntFromConfig(ConfigSection(),_L("openResult"),openResult);
1012 GetIntFromConfig(ConfigSection(),_L("closeResult"),closeResult);
1014 INFO_PRINTF2(_L("Opening embedded container within %S"), &uri);
1017 CContent *content = CContent::NewLC(uri);
1019 result = content->OpenContainer(uniqueId);
1020 if(result != openResult)
1022 SetTestStepResult(EFail);
1023 INFO_PRINTF3(_L("OpenContainer() returned %d, expected %d"), result, openResult);
1025 result = content->CloseContainer();
1026 if(result != closeResult)
1028 SetTestStepResult(EFail);
1029 INFO_PRINTF3(_L("CloseContainer() returned %d, expected %d"), result, closeResult);
1031 CleanupStack::PopAndDestroy(content);
1034 return TestStepResult();
1037 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
1039 // The following methods test the various content attribute APIs for WMDRM content.
1041 TVerdict CCAFContentAttributeStep::doWmdrmTestStepL()
1043 SetTestStepResult(EFail);
1046 GetIntFromConfig(ConfigSection(),_L("attribute"), attribVal);
1049 GetIntFromConfig(ConfigSection(),_L("value"), expectedValue);
1053 HBufC8* headerData = NULL;
1055 if(GetStringFromConfig(ConfigSection(),_L("header"), header))
1057 headerData = ConvertDes16toHBufC8LC(header);
1061 headerData = CreateWmdrmHeaderLC();
1064 CContent *content = CContent::NewLC(*headerData);
1066 User::LeaveIfError(content->GetAttribute(attribVal, value));
1068 if(expectedValue == value)
1070 SetTestStepResult(EPass);
1074 INFO_PRINTF3(_L("CContent::GetAttribute() Expected value: %d, actual value: %d"), expectedValue, value);
1077 CleanupStack::PopAndDestroy(2, headerData);
1080 return TestStepResult();
1084 TVerdict CCAFContentAttributeSetStep::doWmdrmTestStepL()
1086 SetTestStepResult(EFail);
1089 GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1);
1092 GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2);
1094 TInt expectedValue1;
1095 GetIntFromConfig(ConfigSection(),_L("value1"),expectedValue1);
1097 TInt expectedValue2;
1098 GetIntFromConfig(ConfigSection(),_L("value2"),expectedValue2);
1103 HBufC8* headerData = NULL;
1105 if(GetStringFromConfig(ConfigSection(),_L("header"), header))
1107 headerData = ConvertDes16toHBufC8LC(header);
1111 headerData = CreateWmdrmHeaderLC();
1114 CContent *content = CContent::NewLC(*headerData);
1116 RAttributeSet attributeSet;
1117 CleanupClosePushL(attributeSet);
1118 attributeSet.AddL(attribute1);
1119 attributeSet.AddL(attribute2);
1121 TInt result = content->GetAttributeSet(attributeSet);
1122 if(result == KErrNone)
1125 User::LeaveIfError(attributeSet.GetValue(attribute1, value1));
1128 User::LeaveIfError(attributeSet.GetValue(attribute2, value2));
1130 if(expectedValue1 == value1 && expectedValue2 == value2 && attributeSet.Count() == 2)
1132 SetTestStepResult(EPass);
1136 INFO_PRINTF1(_L("CContent::GetAttributeSet() values don't match expected values"));
1142 INFO_PRINTF1(_L("CContent::GetAttributeSet() failed"));
1145 CleanupStack::PopAndDestroy(3, headerData);
1149 return TestStepResult();
1153 TVerdict CCAFContentStringAttributeStep::doWmdrmTestStepL()
1155 SetTestStepResult(EFail);
1158 GetIntFromConfig(ConfigSection(),_L("attribute"),attribVal);
1160 TPtrC expectedValue;
1161 GetStringFromConfig(ConfigSection(),_L("value"),expectedValue);
1163 TInt expectedResult;
1164 GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
1168 HBufC8* headerData = NULL;
1170 if(GetStringFromConfig(ConfigSection(),_L("header"), header))
1172 headerData = ConvertDes16toHBufC8LC(header);
1176 headerData = CreateWmdrmHeaderLC();
1179 CContent *content = CContent::NewLC(*headerData);
1182 TInt result = content->GetStringAttribute(attribVal, value);
1183 if(result == expectedResult && value == expectedValue)
1185 SetTestStepResult(EPass);
1189 INFO_PRINTF3(_L("CContent::GetStringAttribute() Expected result: %d, actual result: %d"), expectedResult, result);
1190 INFO_PRINTF3(_L("CContent::GetStringAttribute() Expected value: %S, actual value: %S"), &expectedValue, &value);
1193 CleanupStack::PopAndDestroy(2, headerData);
1197 return TestStepResult();
1201 TVerdict CCAFContentStringAttributeSetStep::doWmdrmTestStepL()
1203 SetTestStepResult(EFail);
1206 GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1);
1209 GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2);
1211 TPtrC expectedValue1;
1212 GetStringFromConfig(ConfigSection(),_L("value1"),expectedValue1);
1214 TPtrC expectedValue2;
1215 GetStringFromConfig(ConfigSection(),_L("value2"),expectedValue2);
1219 HBufC8* headerData = NULL;
1221 if(GetStringFromConfig(ConfigSection(),_L("header"), header))
1223 headerData = ConvertDes16toHBufC8LC(header);
1227 headerData = CreateWmdrmHeaderLC();
1230 CContent *content = CContent::NewLC(*headerData);
1232 RStringAttributeSet attributeSet;
1233 CleanupClosePushL(attributeSet);
1234 attributeSet.AddL(attribute1);
1235 attributeSet.AddL(attribute2);
1237 TInt result = content->GetStringAttributeSet(attributeSet);
1240 if(result == KErrNone)
1242 TInt result3 = attributeSet.GetValue(attribute1, value1);
1243 TInt result4 = attributeSet.GetValue(attribute2, value2);
1245 if(value1 == expectedValue1 && value2 == expectedValue2 && attributeSet.Count() == 2
1246 && result3 == KErrNone && result4 == KErrNone)
1248 SetTestStepResult(EPass);
1252 INFO_PRINTF3(_L("RStringAttributeSet::GetValue() for attribute1.Expected value: %S, actual value: %S"), &expectedValue1, &value1);
1253 INFO_PRINTF3(_L("RStringAttributeSet::GetValue() for attribute2.Expected value: %S, actual value: %S"), &expectedValue2, &value2);
1254 INFO_PRINTF3(_L("RStringAttributeSet::GetValue() for attribute1. Expected result: %d, actual result: %d"), 0, result3);
1255 INFO_PRINTF3(_L("RStringAttributeSet::GetValue() for attribute2. Expected result: %d, actual result: %d"), 0, result4);
1260 INFO_PRINTF1(_L("CContent::GetStringAttributeSet() failed"));
1263 CleanupStack::PopAndDestroy(3, headerData);
1267 return TestStepResult();
1270 #endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT