|
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 // |
|
15 |
|
16 #include "TestExBDayLocal.h" |
|
17 |
|
18 CTestExBDayLocal::~CTestExBDayLocal() |
|
19 /** |
|
20 * Destructor |
|
21 */ |
|
22 { |
|
23 } |
|
24 |
|
25 CTestExBDayLocal::CTestExBDayLocal() |
|
26 /** |
|
27 * Constructor |
|
28 */ |
|
29 { |
|
30 // Call base class method to set up the human readable name for logging |
|
31 SetTestStepName(KTestExBDayLocal); |
|
32 } |
|
33 |
|
34 TVerdict CTestExBDayLocal::doTestStepPreambleL() |
|
35 /** |
|
36 * @return - TVerdict code |
|
37 * Override of base class virtual |
|
38 */ |
|
39 { |
|
40 INFO_PRINTF1(_L("Start Export of vCards (birthday in Local) Tests")); |
|
41 |
|
42 iScheduler = new (ELeave) CActiveScheduler; |
|
43 CActiveScheduler::Install(iScheduler); |
|
44 |
|
45 SetTestStepResult(EPass); |
|
46 return TestStepResult(); |
|
47 } |
|
48 |
|
49 TBool CTestExBDayLocal::CheckImportedBDay() |
|
50 { |
|
51 TDateTime importedDateTime = iBDayFromImport.DateTime(); |
|
52 TDateTime exportedDateTime = iBDayLocal.DateTime(); |
|
53 |
|
54 //checks if exported and imported birthday macthes, which it should, otherwise test failed |
|
55 if((importedDateTime.Year() != exportedDateTime.Year()) || |
|
56 (importedDateTime.Month() != exportedDateTime.Month()) || |
|
57 (importedDateTime.Day() != exportedDateTime.Day()) ) |
|
58 { |
|
59 INFO_PRINTF1(_L("Export and Import of birthday does not match (incorrect)")); |
|
60 return EFalse; |
|
61 } |
|
62 else |
|
63 { |
|
64 INFO_PRINTF1(_L("Export and Import of birthday macthes (correct)")); |
|
65 return ETrue; |
|
66 } |
|
67 } |
|
68 |
|
69 TVerdict CTestExBDayLocal::doTestStepL() |
|
70 /** |
|
71 * @return - TVerdict code |
|
72 * Override of base class pure virtual |
|
73 */ |
|
74 { |
|
75 SetTestStepResult(EFail); |
|
76 |
|
77 TInt numberOfCases = 0; |
|
78 |
|
79 while (ETrue) |
|
80 { |
|
81 TPtrC ptrBDay = GetBDayL(numberOfCases); |
|
82 if(ptrBDay==KNullDesC) |
|
83 { |
|
84 break; |
|
85 } |
|
86 |
|
87 INFO_PRINTF2(_L("TEST: %d"), numberOfCases+1); |
|
88 |
|
89 iBDayLocal = FormatDateTime(ptrBDay); |
|
90 TDateTime t = iBDayLocal.DateTime(); |
|
91 INFO_PRINTF7(_L("Birthday to be exported, Year: %d, Month: %d, Day: %d, Hr: %d, Min: %d, Sec: %d"), t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second()); |
|
92 |
|
93 iName = GetNameL(numberOfCases); |
|
94 |
|
95 iPhone = GetPhoneL(numberOfCases); |
|
96 |
|
97 TBuf<90> pathVCF(KExportBDayFile); |
|
98 ExportItemL(pathVCF, ETrue); |
|
99 // read from the disk. |
|
100 ImportItemL(pathVCF, ETrue); |
|
101 |
|
102 if(!CheckImportedBDay()) |
|
103 { |
|
104 SetTestStepResult(EFail); |
|
105 return TestStepResult(); |
|
106 } |
|
107 |
|
108 numberOfCases++; |
|
109 }// End Of While Loop |
|
110 |
|
111 SetTestStepResult(EPass); |
|
112 return TestStepResult(); |
|
113 } |
|
114 |
|
115 TVerdict CTestExBDayLocal::doTestStepPostambleL() |
|
116 /** |
|
117 * @return - TVerdict code |
|
118 * Override of base class virtual |
|
119 */ |
|
120 { |
|
121 CActiveScheduler::Install(NULL); |
|
122 delete iScheduler; |
|
123 INFO_PRINTF1(_L("Completed Export of vCards (birthday in Local) Tests")); |
|
124 return TestStepResult(); |
|
125 } |
|
126 |
|
127 TPtrC CTestExBDayLocal::GetBDayL(TInt numberOfCases) |
|
128 { |
|
129 TPtrC bDay; |
|
130 |
|
131 TPtrC config = KVCard(); |
|
132 HBufC *configval = HBufC::NewLC(config.Length()+2); |
|
133 |
|
134 TPtr configSection = configval->Des(); |
|
135 |
|
136 configSection.Append(config); |
|
137 configSection.AppendNum(numberOfCases); |
|
138 |
|
139 GetStringFromConfig(configSection,KBDayLocal,bDay); |
|
140 |
|
141 CleanupStack::PopAndDestroy(configval); |
|
142 |
|
143 return bDay; |
|
144 } |
|
145 |
|
146 TPtrC CTestExBDayLocal::GetNameL(TInt numberOfCases) |
|
147 { |
|
148 TPtrC name; |
|
149 |
|
150 TPtrC config = KVCard(); |
|
151 HBufC *configval = HBufC::NewLC(config.Length()+2); |
|
152 |
|
153 TPtr configSection = configval->Des(); |
|
154 |
|
155 configSection.Append(config); |
|
156 configSection.AppendNum(numberOfCases); |
|
157 |
|
158 GetStringFromConfig(configSection,KName,name); |
|
159 |
|
160 CleanupStack::PopAndDestroy(configval); |
|
161 |
|
162 return name; |
|
163 } |
|
164 |
|
165 TPtrC CTestExBDayLocal::GetPhoneL(TInt numberOfCases) |
|
166 { |
|
167 TPtrC phone; |
|
168 |
|
169 TPtrC config = KVCard(); |
|
170 HBufC *configval = HBufC::NewLC(config.Length()+2); |
|
171 |
|
172 TPtr configSection = configval->Des(); |
|
173 |
|
174 configSection.Append(config); |
|
175 configSection.AppendNum(numberOfCases); |
|
176 |
|
177 GetStringFromConfig(configSection,KPhone,phone); |
|
178 |
|
179 CleanupStack::PopAndDestroy(configval); |
|
180 |
|
181 return phone; |
|
182 } |
|
183 |