|
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 |
|
20 // T_AppListUpdateStep |
|
21 // |___ (APPFWK-APPARC-0035) Tests that the application information file (AppsList.bin) is created |
|
22 // | if it does not exists, and we force a registration. |
|
23 // |___ (APPFWK-APPARC-0032) Tests that the application information file (AppsList.bin) is updated |
|
24 // whenever a new application is installed. |
|
25 // |
|
26 // |
|
27 |
|
28 |
|
29 |
|
30 /** |
|
31 @file |
|
32 @test |
|
33 @internalComponent - Internal Symbian test code |
|
34 */ |
|
35 |
|
36 |
|
37 #include <apgcli.h> |
|
38 #include "T_AppListFileUpdateStep.h" |
|
39 |
|
40 _LIT(KTestAppZPath,"Z:\\ApparcTest\\TestAppInstall_reg.RSC"); |
|
41 _LIT(KAppListFileName,"C:\\private\\10003a3f\\AppsListCache\\AppsList.bin"); |
|
42 _LIT(KAppTimeFormat,"%:0%H%:1%T%:2%S%:3"); |
|
43 _LIT(KAppDirectory,"C:\\Private\\10003a3f\\Import\\apps\\"); |
|
44 _LIT(KTestAppObsolutePath1,"C:\\Private\\10003a3f\\Import\\apps\\TestAppInstall_reg.RSC"); |
|
45 |
|
46 const TInt KMaxTimeCount = 18; // 18 * 10 is 180 Seconds |
|
47 |
|
48 |
|
49 CT_AppListFileUpdateStep::CT_AppListFileUpdateStep() |
|
50 { |
|
51 // Call base class method to set up the human readable name for logging |
|
52 SetTestStepName(KT_AppListFileUpdate); |
|
53 } |
|
54 |
|
55 |
|
56 CT_AppListFileUpdateStep::~CT_AppListFileUpdateStep() |
|
57 { |
|
58 } |
|
59 |
|
60 TVerdict CT_AppListFileUpdateStep::doTestStepPreambleL() |
|
61 { |
|
62 User::LeaveIfError(iSession.Connect()); |
|
63 User::LeaveIfError(iUtils.Connect()); |
|
64 User::LeaveIfError(iFs.Connect()); |
|
65 |
|
66 SetTestStepResult(EPass); |
|
67 return TestStepResult(); |
|
68 } |
|
69 |
|
70 TVerdict CT_AppListFileUpdateStep::doTestStepPostambleL() |
|
71 { |
|
72 iFs.Close(); |
|
73 iUtils.Close(); |
|
74 iSession.Close(); |
|
75 return TestStepResult(); |
|
76 } |
|
77 |
|
78 |
|
79 TVerdict CT_AppListFileUpdateStep::doTestStepL() |
|
80 { |
|
81 INFO_PRINTF1(_L("AppListFileUpdateStep test step started...")); |
|
82 |
|
83 __UHEAP_MARK; |
|
84 INFO_PRINTF1(_L("APPFWK-APPARC-0035 Test Started")); |
|
85 TRAPD(ret, TestDeleteAppListFileL()); |
|
86 TEST(ret == KErrNone); |
|
87 INFO_PRINTF2(_L("TestDeleteAppListFileL() finished with return code '%d'\n"), ret); |
|
88 INFO_PRINTF1(_L("APPFWK-APPARC-0035 Test Finished\n")); |
|
89 __UHEAP_MARKEND; |
|
90 |
|
91 __UHEAP_MARK; |
|
92 INFO_PRINTF1(_L("APPFWK-APPARC-0032 Test Started")); |
|
93 TRAP(ret, TestTimeStampL()); |
|
94 TEST(ret == KErrNone); |
|
95 INFO_PRINTF2(_L("TestTimeStampL() finished with return code '%d'"), ret); |
|
96 INFO_PRINTF1(_L("APPFWK-APPARC-0032 Test Finished\n")); |
|
97 __UHEAP_MARKEND; |
|
98 |
|
99 INFO_PRINTF1(_L("...AppListFileUpdateStep test step finished!")); |
|
100 return TestStepResult(); |
|
101 } |
|
102 |
|
103 |
|
104 /** |
|
105 @SYMTestCaseID APPFWK-APPARC-0032 |
|
106 |
|
107 @SYMPREQ PREQ1228 (CR0831) |
|
108 |
|
109 @SYMREQ REQ5896 |
|
110 |
|
111 @SYMTestCaseDesc Tests that the application information file (AppsList.bin) is updated |
|
112 whenever a new application is installed. |
|
113 |
|
114 @SYMTestType CIT |
|
115 |
|
116 @SYMTestPriority High |
|
117 |
|
118 @SYMTestStatus Implemented |
|
119 |
|
120 @SYMTestActions This tests the update of the applist file in \\private\\10003a3f\\import\\\apps\\. |
|
121 The sequence is as follows: |
|
122 1.- Check the file exists. It must exists. |
|
123 2.- Record timestamp for applist file. |
|
124 3.- Install a new test application. |
|
125 4.- Record timestamp for applist file, allowing some time for the file to be updated |
|
126 4.- Compare timestamps before and after test app installation. |
|
127 |
|
128 @SYMTestExpectedResults Modified time of AppsList.bin after installation must be greater than before installation. |
|
129 */ |
|
130 |
|
131 void CT_AppListFileUpdateStep::TestTimeStampL() |
|
132 { |
|
133 // Create KAppDirectory |
|
134 TInt err = iUtils.CreateDirectoryL(KAppDirectory); |
|
135 TEST(err == KErrNone || err == KErrAlreadyExists); |
|
136 |
|
137 // Wait until KAppListFileName is present and check that the file has been created indeed |
|
138 TBool present = CheckForFilePresent(); |
|
139 TEST(present); |
|
140 |
|
141 // Record time before app list was modified |
|
142 INFO_PRINTF1(_L("Record time before app list was modified...")); |
|
143 TTime timeBeforeAppListModification; |
|
144 AppsListModifiedTimeL(timeBeforeAppListModification); |
|
145 |
|
146 // Install an application |
|
147 INFO_PRINTF1(_L("Install application...")); |
|
148 InstallApplicationL(KTestAppObsolutePath1); |
|
149 |
|
150 // wait 5 seconds for the app to be properly installed |
|
151 User::After(5 * 1000000); |
|
152 |
|
153 // Wait until KAppListFileName is present and check that the file has been created indeed. |
|
154 present = CheckForFilePresent(); |
|
155 TEST(present); |
|
156 |
|
157 // Record time after app list was modified |
|
158 INFO_PRINTF1(_L("Record time after app list was modified...")); |
|
159 TTime timeAfterAppListModification; |
|
160 AppsListModifiedTimeL(timeAfterAppListModification); |
|
161 |
|
162 // Check that the modification time "after" is after the modification time "before" |
|
163 TEST(timeAfterAppListModification > timeBeforeAppListModification); |
|
164 |
|
165 // Uninstall & delete... |
|
166 INFO_PRINTF1(_L("Uninstalling application...")); |
|
167 DeleteApplicationL(KTestAppObsolutePath1); |
|
168 } |
|
169 |
|
170 |
|
171 /* |
|
172 Delete a registration resource file (TestAppInstall.rsc) in the path "C:\private\10003a3f\import\apps" . |
|
173 */ |
|
174 void CT_AppListFileUpdateStep::DeleteApplicationL(const TDesC& aAppName) |
|
175 { |
|
176 INFO_PRINTF2(_L("Deleting file '%S'"), &aAppName); |
|
177 |
|
178 TInt ret = iUtils.SetReadOnly(aAppName, 0); |
|
179 TEST(ret == KErrNone); |
|
180 ret = iUtils.DeleteFileL(aAppName); |
|
181 TEST(ret == KErrNone); |
|
182 } |
|
183 |
|
184 |
|
185 /* |
|
186 Copy a registration resource file (TestAppInstall.rsc) in the path "c:\private\10003a3f\import\apps" . |
|
187 */ |
|
188 void CT_AppListFileUpdateStep::InstallApplicationL(const TDesC& aAppName) |
|
189 { |
|
190 INFO_PRINTF3(_L("Copying file '%S' to folder '%S'"), &aAppName, &KTestAppZPath); |
|
191 |
|
192 TInt ret = iUtils.CopyFileL(KTestAppZPath, aAppName); |
|
193 TEST(ret == KErrNone); |
|
194 } |
|
195 |
|
196 |
|
197 /* |
|
198 Gets the modified time for AppsList.bin |
|
199 */ |
|
200 void CT_AppListFileUpdateStep::AppsListModifiedTimeL(TTime& aTime) |
|
201 { |
|
202 INFO_PRINTF2(_L("Retrieving modification time of file '%S'"), &KAppListFileName); |
|
203 TInt ret = iFs.Modified(KAppListFileName, aTime); |
|
204 TEST(ret == KErrNone); |
|
205 |
|
206 TBuf<40> timeString; // Holds the formatted date and time |
|
207 aTime.FormatL(timeString,KAppTimeFormat); |
|
208 INFO_PRINTF2(_L("Recorded modified time is '%S'"), &timeString); |
|
209 } |
|
210 |
|
211 |
|
212 /** |
|
213 @SYMTestCaseID APPFWK-APPARC-0035 |
|
214 |
|
215 @SYMPREQ PREQ1228 (CR0831) |
|
216 |
|
217 @SYMREQ REQ5896 |
|
218 |
|
219 @SYMTestCaseDesc Apparc component repopulates the file list if it has been deleted and a registration is forced. |
|
220 |
|
221 @SYMTestType CIT |
|
222 |
|
223 @SYMTestPriority High |
|
224 |
|
225 @SYMTestStatus Implemented |
|
226 |
|
227 @SYMTestActions This tests the update of the applist file in \\private\\10003a3f\\import\\\apps\\. |
|
228 The sequence is as follows: |
|
229 1.- Check the file exists. It must exists. |
|
230 2.- Delete the file and check it does not exist, and that is not created either. |
|
231 3.- Force Registration, which means that the applist file needs to be created again. |
|
232 4.- Check that the above mentioned file exists again after waiting for a short period of time. |
|
233 |
|
234 @SYMTestExpectedResults AppsList.bin is deleted and created according to the test actions. |
|
235 */ |
|
236 |
|
237 void CT_AppListFileUpdateStep::TestDeleteAppListFileL() |
|
238 { |
|
239 // Check the file IS present |
|
240 TBool present = CheckForFilePresent(); |
|
241 TEST(present); |
|
242 |
|
243 // Delete applist file |
|
244 DeleteAppListFileL(KAppListFileName); |
|
245 |
|
246 // Check the file is NOT present |
|
247 present = CheckForFilePresent(); |
|
248 TEST(!present); |
|
249 |
|
250 // Do a rescan and check that the file exists again. |
|
251 INFO_PRINTF1(_L("Do a rescan and check that the file exists again....")); |
|
252 RPointerArray<TDesC> dummy; |
|
253 TEST(iSession.ForceRegistration(dummy) == KErrNone); |
|
254 present = CheckForFilePresent(); |
|
255 TEST(present); |
|
256 } |
|
257 |
|
258 |
|
259 /* |
|
260 Checks whether the "AppList.Bin" exists, if not waits for a maximum time of (KMaxTimeCount * 10) seconds for the file to create. |
|
261 Else the test fails. |
|
262 */ |
|
263 TBool CT_AppListFileUpdateStep::CheckForFilePresent() |
|
264 { |
|
265 INFO_PRINTF2(_L("Wait for a maximum time of '%d' secs for the file to be created"), KMaxTimeCount * 10); |
|
266 |
|
267 TBool present = EFalse; |
|
268 for (TInt index = 0; present == EFalse && index < KMaxTimeCount; index++) |
|
269 { |
|
270 TEST(iUtils.IsFilePresent(KAppListFileName, present) == KErrNone); |
|
271 if (present) |
|
272 { |
|
273 INFO_PRINTF2(_L("AppList file is successfully created after '%d' seconds!"), index * 10); |
|
274 break; |
|
275 } |
|
276 // wait 10 secs before trying again in the next loop |
|
277 User::After(10 * 1000000); |
|
278 } |
|
279 |
|
280 if (!present) |
|
281 { |
|
282 INFO_PRINTF2(_L("AppList file was NOT created after '%d' seconds"), KMaxTimeCount * 10); |
|
283 } |
|
284 |
|
285 return present; |
|
286 } |
|
287 |
|
288 |
|
289 /* |
|
290 It will delete the applistfile created by apparc component |
|
291 */ |
|
292 void CT_AppListFileUpdateStep::DeleteAppListFileL(const TDesC& aFileName) |
|
293 { |
|
294 INFO_PRINTF2(_L("Delete AppList file '%S'..."), &aFileName); |
|
295 |
|
296 TInt ret = iUtils.SetReadOnly(aFileName, 0); |
|
297 TEST(ret == KErrNone); |
|
298 ret = iUtils.DeleteFileL(aFileName); |
|
299 TEST(ret == KErrNone); |
|
300 } |