|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // CMtfTestActionCreateOrderedChildrenSelection.cpp |
|
15 // __ACTION_INFO_BEGIN__ |
|
16 // [Action Name] |
|
17 // CompareSelections |
|
18 // [Action Parameters |
|
19 // Session <input>: Reference to the session. |
|
20 // Entry selection 1 <input>: Selection of entries (MsvIds). |
|
21 // Entry selection 2 <input>: Selection of entries (Msvids). |
|
22 // [Action Description] |
|
23 // Compares ordered entry selection 1 (MsvIds) with ordered entry selection 2 to determine if they match. |
|
24 // The date/timestamp of each matching entry is logged. |
|
25 // The test action passes if the selections match. |
|
26 // [APIs Used] |
|
27 // CMsvEntrySelection |
|
28 // CMsvEntry |
|
29 // __ACTION_INFO_END__ |
|
30 // |
|
31 // |
|
32 |
|
33 #include "CMtfTestActionCompareSelections.h" |
|
34 #include "CMtfTestCase.h" |
|
35 #include "CMtfTestActionParameters.h" |
|
36 |
|
37 #include <msvapi.h> |
|
38 |
|
39 CMtfTestAction* CMtfTestActionCompareSelections::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters) |
|
40 { |
|
41 CMtfTestActionCompareSelections* self = new (ELeave) CMtfTestActionCompareSelections(aTestCase); |
|
42 CleanupStack::PushL(self); |
|
43 self->ConstructL(aActionParameters); |
|
44 CleanupStack::Pop(self); |
|
45 return self; |
|
46 } |
|
47 |
|
48 |
|
49 CMtfTestActionCompareSelections::CMtfTestActionCompareSelections(CMtfTestCase& aTestCase) |
|
50 : CMtfSynchronousTestAction(aTestCase) |
|
51 { |
|
52 } |
|
53 |
|
54 |
|
55 CMtfTestActionCompareSelections::~CMtfTestActionCompareSelections() |
|
56 { |
|
57 } |
|
58 |
|
59 |
|
60 void CMtfTestActionCompareSelections::ExecuteActionL() |
|
61 { |
|
62 TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionCompareSelections); |
|
63 CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0)); |
|
64 CMsvEntrySelection* selection1 = ObtainParameterReferenceL<CMsvEntrySelection>(TestCase(),ActionParameters().Parameter(1)); |
|
65 CMsvEntrySelection* selection2 = ObtainParameterReferenceL<CMsvEntrySelection>(TestCase(),ActionParameters().Parameter(2)); |
|
66 |
|
67 TInt count1 = selection1->Count(); |
|
68 TInt count2 = selection2->Count(); |
|
69 |
|
70 if(count1 != count2) |
|
71 { |
|
72 TestCase().INFO_PRINTF4(_L("Test Action %S failed. [count1=%d, count2=%d]"), &KTestActionCompareSelections, count1, count2); |
|
73 TestCase().SetTestStepResult(EFail); |
|
74 TestCase().ActionCompletedL(*this); |
|
75 return; |
|
76 } |
|
77 |
|
78 TBuf<45> dateTimeString; //Format: "dd/mm/yyyy hh:mm:ss am/pm". |
|
79 |
|
80 for(TInt ii=0; ii<count1; ++ii) |
|
81 { |
|
82 TMsvId id1 = selection1->At(ii); |
|
83 TMsvId id2 = selection2->At(ii); |
|
84 |
|
85 if(id1 != id2) |
|
86 { |
|
87 TestCase().ERR_PRINTF2(_L("Test Action %S failed. Ordered selections are different."), &KTestActionCompareSelections); |
|
88 TestCase().SetTestStepResult(EFail); |
|
89 TestCase().ActionCompletedL(*this); |
|
90 return; |
|
91 } |
|
92 else |
|
93 { |
|
94 TestCase().INFO_PRINTF2(_L("Index %d matched"), ii); |
|
95 |
|
96 CMsvEntry* entry=paramSession->GetEntryL((*selection1)[ii]); |
|
97 TMsvEntry entryDetails=entry->Entry(); |
|
98 delete entry; |
|
99 |
|
100 //print the time of the entry to the log file |
|
101 dateTimeString.Zero(); |
|
102 _LIT(KFormat,"%/0%1%/1%2%/2%3%/3 %-B%:0%J%:1%T%:2%S%:3%+B"); |
|
103 entryDetails.iDate.FormatL(dateTimeString,KFormat); |
|
104 |
|
105 TestCase().INFO_PRINTF2(_L("%S"),&dateTimeString); |
|
106 } |
|
107 } |
|
108 |
|
109 TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionCompareSelections); |
|
110 TestCase().ActionCompletedL(*this); |
|
111 } |
|
112 |