|
1 // Copyright (c) 2006-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 the License "Symbian Foundation License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Note: With PREQ1228, we introduced "REQ5896:Load application information from a single file". |
|
15 // This PREQ is tested with the following two test steps: |
|
16 // T_AppListBootStep (only run for emulator, as it requires epoc restart) |
|
17 // |___ (APPFWK-APPARC-0033) Tests that the application information file (AppsList.bin) is created |
|
18 // | if it does not exists, and we reboot the phone. |
|
19 // |___ (APPFWK-APPARC-0034) Tests that the Short Caption associated with an app is restored to |
|
20 // its original value when the phone is restarted. |
|
21 // T_AppListUpdateStep |
|
22 // |___ (APPFWK-APPARC-0035) Tests that the application information file (AppsList.bin) is created |
|
23 // | if it does not exists, and we force a registration. |
|
24 // |___ (APPFWK-APPARC-0032) Tests that the application information file (AppsList.bin) is updated |
|
25 // whenever a new application is installed. |
|
26 // |
|
27 // |
|
28 |
|
29 |
|
30 |
|
31 /** |
|
32 @file |
|
33 @test |
|
34 @internalComponent - Internal Symbian test code |
|
35 */ |
|
36 |
|
37 |
|
38 #include <apgcli.h> |
|
39 #include "T_AppListFileBootStep.h" |
|
40 |
|
41 |
|
42 _LIT(KAppListFileName,"c:\\private\\10003a3f\\AppsListCache\\AppsList.bin"); |
|
43 _LIT(KShortCaption1, "SC1"); |
|
44 _LIT(KOriginalShortCaption, "TC UK"); |
|
45 |
|
46 const TUid KUidTestApp={10}; |
|
47 const TInt KMaxTimeCount = 18; // 18 * 10 sec == 180 seconds |
|
48 |
|
49 |
|
50 /** |
|
51 Call base class method to set up the human readable name for logging TestStepName |
|
52 iBootType value set as per aBootType |
|
53 */ |
|
54 CT_AppListFileBootStep::CT_AppListFileBootStep(TInt aBootType) |
|
55 { |
|
56 iBootType = aBootType; |
|
57 if(iBootType == 1) |
|
58 { |
|
59 SetTestStepName(KT_AppListFile_Boot1); |
|
60 } |
|
61 else if(iBootType == 2) |
|
62 { |
|
63 SetTestStepName(KT_AppListFile_Boot2); |
|
64 } |
|
65 else |
|
66 { |
|
67 SetTestStepName(KT_AppListFile_Boot3); |
|
68 } |
|
69 } |
|
70 |
|
71 |
|
72 CT_AppListFileBootStep::~CT_AppListFileBootStep() |
|
73 { |
|
74 } |
|
75 |
|
76 |
|
77 TVerdict CT_AppListFileBootStep::doTestStepL() |
|
78 { |
|
79 INFO_PRINTF1(_L("Test step started....")); |
|
80 |
|
81 #ifdef __WINS__ |
|
82 __UHEAP_MARK; |
|
83 TRAPD(ret, DoTestL()); |
|
84 TEST(ret == KErrNone); |
|
85 INFO_PRINTF2(_L("DoTestL() finished with return code '%d'"), ret); |
|
86 __UHEAP_MARKEND; |
|
87 #else |
|
88 INFO_PRINTF1(_L("TEST NOT RUN! - T_AppListFile_BootX tests are meant only to run on Emulator")); |
|
89 TEST(EFalse); |
|
90 #endif |
|
91 |
|
92 INFO_PRINTF1(_L("....test step finished!")); |
|
93 return TestStepResult(); |
|
94 } |
|
95 |
|
96 |
|
97 /** |
|
98 @SYMTestCaseID APPFWK-APPARC-0033, APPFWK-APPARC-0034 |
|
99 |
|
100 @SYMPREQ PREQ1228 (CR0831) |
|
101 |
|
102 @SYMREQ REQ5896 |
|
103 |
|
104 @SYMTestPriority High |
|
105 |
|
106 @SYMTestType CIT |
|
107 |
|
108 @SYMTestCaseDesc Tests that the application information file (AppsList.bin) is created if it does |
|
109 not exists, and we reboot the phone. |
|
110 Tests that the Short Caption associated with an app is restored to its original |
|
111 value when the phone is restarted. |
|
112 |
|
113 @SYMTestStatus Implemented |
|
114 |
|
115 @SYMTestActions This tests the update of the applist file in \\private\\10003a3f\\import\\\apps\\. |
|
116 The sequence is as follows: |
|
117 (BOOT - 1) |
|
118 1.- Check the applist file exists. It must exists. |
|
119 2.- Delete the applist file. |
|
120 (BOOT - 2) |
|
121 3.- Check the applist file does not exist. |
|
122 4.- Check the applist is created after a short period of time. |
|
123 5.- Set short caption of a test app to a custom value. |
|
124 (BOOT - 3) |
|
125 6.- Check short caption of the test app is restored to its original value. |
|
126 |
|
127 @SYMTestExpectedResults For Boot1 AppList File must exist when the test starts, but not when it finishes. |
|
128 For Boot2 AppList File must not exist when the test starts, but is created later on. |
|
129 For Boot3 ShortCaption for tstapp.exe must return to original short caption |
|
130 */ |
|
131 |
|
132 void CT_AppListFileBootStep::DoTestL() |
|
133 { |
|
134 TInt ret = iUtils.Connect(); |
|
135 TEST(ret==KErrNone); |
|
136 |
|
137 TBool present = EFalse; |
|
138 ret = iUtils.IsFilePresent(KAppListFileName, present); |
|
139 TEST(ret == KErrNone); |
|
140 |
|
141 switch(iBootType) |
|
142 { |
|
143 case 1: |
|
144 { |
|
145 INFO_PRINTF1(_L("Starting test case: APPFWK-APPARC-0033")); |
|
146 // Check the file is present, or wait until it is. When/If present, delete it. |
|
147 INFO_PRINTF1(_L("The should file exists (as no other test have removed it), so then this test should delete it:")); |
|
148 present = CheckForFilePresent(); |
|
149 TEST(present); |
|
150 if (present) |
|
151 { |
|
152 DeleteAppListFileL(KAppListFileName); |
|
153 } |
|
154 INFO_PRINTF1(_L("APPFWK-APPARC-0033 Test Continues... with Boot2 script")); |
|
155 } |
|
156 break; |
|
157 |
|
158 case 2: |
|
159 { |
|
160 INFO_PRINTF1(_L("APPFWK-APPARC-0033 Test Continues... from Boot1 script")); |
|
161 // Check the file not present, and then wait until it is. |
|
162 INFO_PRINTF1(_L("The file should not exist as it has been deleted by Boot1, otherwise the test fails:")); |
|
163 TEST(!present); |
|
164 present = CheckForFilePresent(); |
|
165 TEST(present); |
|
166 INFO_PRINTF1(_L("APPFWK-APPARC-0033 Test Finished!")); |
|
167 |
|
168 INFO_PRINTF1(_L("Starting test case: APPFWK-APPARC-0034")); |
|
169 SetShortCaptionSettings(); |
|
170 INFO_PRINTF1(_L("APPFWK-APPARC-0034 Test Continues... with Boot3 script")); |
|
171 } |
|
172 break; |
|
173 |
|
174 case 3: |
|
175 { |
|
176 INFO_PRINTF1(_L("APPFWK-APPARC-0034 Test Continues... from Boot2 script")); |
|
177 TestShortCaptionSettings(); |
|
178 INFO_PRINTF1(_L("APPFWK-APPARC-0034 Test Finished!")); |
|
179 } |
|
180 break; |
|
181 } |
|
182 iUtils.Close(); |
|
183 } |
|
184 |
|
185 |
|
186 /* |
|
187 It will delete the applistfile created by apparc component to test the change in the bootup time. |
|
188 */ |
|
189 void CT_AppListFileBootStep::DeleteAppListFileL(const TDesC& aFileName) |
|
190 { |
|
191 INFO_PRINTF2(_L("Delete AppList file '%S'..."), &aFileName); |
|
192 |
|
193 TInt ret = iUtils.SetReadOnly(aFileName, 0); |
|
194 TEST(ret == KErrNone); |
|
195 |
|
196 ret = iUtils.DeleteFileL(aFileName); |
|
197 TEST(ret == KErrNone); |
|
198 } |
|
199 |
|
200 |
|
201 /* |
|
202 Checks whether the "AppList.Bin" exists, if not waits for a maximum time of (KMaxTimeCount * 10) seconds for the file to create. |
|
203 Else the test fails. |
|
204 */ |
|
205 TBool CT_AppListFileBootStep::CheckForFilePresent() |
|
206 { |
|
207 INFO_PRINTF2(_L("Wait for a maximum time of '%d' secs for the file to be created"), KMaxTimeCount * 10); |
|
208 |
|
209 TBool present = EFalse; |
|
210 for (TInt index = 0; present == EFalse && index < KMaxTimeCount; index++) |
|
211 { |
|
212 TEST(iUtils.IsFilePresent(KAppListFileName, present) == KErrNone); |
|
213 if (present) |
|
214 { |
|
215 INFO_PRINTF2(_L("AppList file is successfully created after '%d' seconds!"), index * 10); |
|
216 break; |
|
217 } |
|
218 // wait 10 secs before trying again in the next loop |
|
219 User::After(10 * 1000000); |
|
220 } |
|
221 |
|
222 if (!present) |
|
223 { |
|
224 INFO_PRINTF2(_L("AppList file was NOT created after '%d' seconds"), KMaxTimeCount * 10); |
|
225 } |
|
226 |
|
227 return present; |
|
228 } |
|
229 |
|
230 |
|
231 /* |
|
232 Testing whether short caption for test app is set as the original short caption |
|
233 */ |
|
234 void CT_AppListFileBootStep::TestShortCaptionSettings() |
|
235 { |
|
236 INFO_PRINTF1(_L("Testing whether short caption for test app is set as the original short caption")); |
|
237 |
|
238 TInt err = iSession.Connect(); |
|
239 TEST(err == KErrNone); |
|
240 |
|
241 TApaAppInfo info1; |
|
242 err = iSession.GetAppInfo(info1, KUidTestApp); |
|
243 TEST(err == KErrNone); |
|
244 |
|
245 TBuf<10> expected; |
|
246 expected.Format(KOriginalShortCaption); |
|
247 TBuf<10> actual; |
|
248 actual.Format(info1.iShortCaption); |
|
249 INFO_PRINTF3(_L("Short Caption Settings: Expected '%S', Actual '%S'"), &expected, &actual); |
|
250 TEST(info1.iShortCaption==KOriginalShortCaption); |
|
251 |
|
252 // close session and finish |
|
253 iSession.Close(); |
|
254 } |
|
255 |
|
256 |
|
257 /* |
|
258 Sets the short caption for tstapp.exe to KShortCaption1 |
|
259 */ |
|
260 void CT_AppListFileBootStep::SetShortCaptionSettings() |
|
261 { |
|
262 INFO_PRINTF2(_L("Setting short caption settings to '%S'..."), &KShortCaption1); |
|
263 |
|
264 TInt err = iSession.Connect(); |
|
265 TEST(err == KErrNone); |
|
266 err = iSession.SetAppShortCaption(KShortCaption1, ELangEnglish, KUidTestApp); |
|
267 TEST(err == KErrNone); |
|
268 |
|
269 // wait 2.5 secs for the caption to be updated |
|
270 User::After(2500000); |
|
271 |
|
272 TApaAppInfo info1; |
|
273 err = iSession.GetAppInfo(info1, KUidTestApp); |
|
274 TEST(err == KErrNone); |
|
275 |
|
276 TBuf<10> expected; |
|
277 expected.Format(KShortCaption1); |
|
278 TBuf<10> actual; |
|
279 actual.Format(info1.iShortCaption); |
|
280 INFO_PRINTF3(_L("Short Caption Settings: Expected '%S', Actual '%S'"), &expected, &actual); |
|
281 TEST(info1.iShortCaption==KShortCaption1); |
|
282 |
|
283 // close session and finish |
|
284 iSession.Close(); |
|
285 } |