1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of "Eclipse Public License v1.0" |
4 // under the terms of "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
32 */ |
32 */ |
33 |
33 |
34 |
34 |
35 #include <apgcli.h> |
35 #include <apgcli.h> |
36 #include "T_AppListFileUpdateStep.h" |
36 #include "T_AppListFileUpdateStep.h" |
37 |
37 #include "T_SisFileInstaller.h" |
38 _LIT(KTestAppZPath,"Z:\\ApparcTest\\TestAppInstall_reg.RSC"); |
38 |
|
39 _LIT(KApparcTestAppSisFile, "z:\\apparctest\\apparctestsisfiles\\TApparcTestApp.sis"); |
|
40 _LIT(KApparcTestAppComponent, "TApparcTestApp"); |
|
41 |
39 _LIT(KAppListFileName,"C:\\private\\10003a3f\\AppsListCache\\AppsList.bin"); |
42 _LIT(KAppListFileName,"C:\\private\\10003a3f\\AppsListCache\\AppsList.bin"); |
40 _LIT(KAppTimeFormat,"%:0%H%:1%T%:2%S%:3"); |
43 _LIT(KAppTimeFormat,"%:0%H%:1%T%:2%S%:3"); |
41 _LIT(KAppDirectory,"C:\\Private\\10003a3f\\Import\\apps\\"); |
|
42 _LIT(KTestAppObsolutePath1,"C:\\Private\\10003a3f\\Import\\apps\\TestAppInstall_reg.RSC"); |
|
43 |
44 |
44 const TInt KMaxTimeCount = 18; // 18 * 10 is 180 Seconds |
45 const TInt KMaxTimeCount = 18; // 18 * 10 is 180 Seconds |
45 |
46 |
46 |
47 |
47 CT_AppListFileUpdateStep::CT_AppListFileUpdateStep() |
48 CT_AppListFileUpdateStep::CT_AppListFileUpdateStep() |
126 @SYMTestExpectedResults Modified time of AppsList.bin after installation must be greater than before installation. |
127 @SYMTestExpectedResults Modified time of AppsList.bin after installation must be greater than before installation. |
127 */ |
128 */ |
128 |
129 |
129 void CT_AppListFileUpdateStep::TestTimeStampL() |
130 void CT_AppListFileUpdateStep::TestTimeStampL() |
130 { |
131 { |
131 // Create KAppDirectory |
|
132 TInt err = iUtils.CreateDirectoryL(KAppDirectory); |
|
133 TEST(err == KErrNone || err == KErrAlreadyExists); |
|
134 |
132 |
135 // Wait until KAppListFileName is present and check that the file has been created indeed |
133 // Wait until KAppListFileName is present and check that the file has been created indeed |
136 TBool present = CheckForFilePresent(); |
134 TBool present = CheckForFilePresent(); |
137 TEST(present); |
135 TEST(present); |
138 |
136 |
141 TTime timeBeforeAppListModification; |
139 TTime timeBeforeAppListModification; |
142 AppsListModifiedTimeL(timeBeforeAppListModification); |
140 AppsListModifiedTimeL(timeBeforeAppListModification); |
143 |
141 |
144 // Install an application |
142 // Install an application |
145 INFO_PRINTF1(_L("Install application...")); |
143 INFO_PRINTF1(_L("Install application...")); |
146 InstallApplicationL(KTestAppObsolutePath1); |
144 |
147 |
145 CSisFileInstaller sisFileInstaller; |
|
146 INFO_PRINTF2(_L("Installing sis file from -> %S"), &KApparcTestAppSisFile); |
|
147 sisFileInstaller.InstallSisAndWaitForAppListUpdateL(KApparcTestAppSisFile); |
|
148 |
148 // wait 5 seconds for the app to be properly installed |
149 // wait 5 seconds for the app to be properly installed |
149 User::After(5 * 1000000); |
150 User::After(5 * 1000000); |
150 |
151 |
151 // Wait until KAppListFileName is present and check that the file has been created indeed. |
152 // Wait until KAppListFileName is present and check that the file has been created indeed. |
152 present = CheckForFilePresent(); |
153 present = CheckForFilePresent(); |
160 // Check that the modification time "after" is after the modification time "before" |
161 // Check that the modification time "after" is after the modification time "before" |
161 TEST(timeAfterAppListModification > timeBeforeAppListModification); |
162 TEST(timeAfterAppListModification > timeBeforeAppListModification); |
162 |
163 |
163 // Uninstall & delete... |
164 // Uninstall & delete... |
164 INFO_PRINTF1(_L("Uninstalling application...")); |
165 INFO_PRINTF1(_L("Uninstalling application...")); |
165 DeleteApplicationL(KTestAppObsolutePath1); |
166 sisFileInstaller.UninstallSisAndWaitForAppListUpdateL(KApparcTestAppComponent); |
166 } |
167 } |
167 |
168 |
168 |
169 |
169 /* |
|
170 Delete a registration resource file (TestAppInstall.rsc) in the path "C:\private\10003a3f\import\apps" . |
|
171 */ |
|
172 void CT_AppListFileUpdateStep::DeleteApplicationL(const TDesC& aAppName) |
|
173 { |
|
174 INFO_PRINTF2(_L("Deleting file '%S'"), &aAppName); |
|
175 |
|
176 TInt ret = iUtils.SetReadOnly(aAppName, 0); |
|
177 TEST(ret == KErrNone); |
|
178 ret = iUtils.DeleteFileL(aAppName); |
|
179 TEST(ret == KErrNone); |
|
180 } |
|
181 |
|
182 |
|
183 /* |
|
184 Copy a registration resource file (TestAppInstall.rsc) in the path "c:\private\10003a3f\import\apps" . |
|
185 */ |
|
186 void CT_AppListFileUpdateStep::InstallApplicationL(const TDesC& aAppName) |
|
187 { |
|
188 INFO_PRINTF3(_L("Copying file '%S' to folder '%S'"), &aAppName, &KTestAppZPath); |
|
189 |
|
190 TInt ret = iUtils.CopyFileL(KTestAppZPath, aAppName); |
|
191 TEST(ret == KErrNone); |
|
192 } |
|
193 |
170 |
194 |
171 |
195 /* |
172 /* |
196 Gets the modified time for AppsList.bin |
173 Gets the modified time for AppsList.bin |
197 */ |
174 */ |
245 present = CheckForFilePresent(); |
222 present = CheckForFilePresent(); |
246 TEST(!present); |
223 TEST(!present); |
247 |
224 |
248 // Do a rescan and check that the file exists again. |
225 // Do a rescan and check that the file exists again. |
249 INFO_PRINTF1(_L("Do a rescan and check that the file exists again....")); |
226 INFO_PRINTF1(_L("Do a rescan and check that the file exists again....")); |
250 RPointerArray<TDesC> dummy; |
227 CSisFileInstaller sisFileInstaller; |
251 TEST(iSession.ForceRegistration(dummy) == KErrNone); |
228 INFO_PRINTF2(_L("Installing sis file from -> %S"), &KApparcTestAppSisFile); |
|
229 sisFileInstaller.InstallSisAndWaitForAppListUpdateL(KApparcTestAppSisFile); |
|
230 |
252 present = CheckForFilePresent(); |
231 present = CheckForFilePresent(); |
253 TEST(present); |
232 TEST(present); |
|
233 sisFileInstaller.UninstallSisAndWaitForAppListUpdateL(KApparcTestAppComponent); |
254 } |
234 } |
255 |
235 |
256 |
236 |
257 /* |
237 /* |
258 Checks whether the "AppList.Bin" exists, if not waits for a maximum time of (KMaxTimeCount * 10) seconds for the file to create. |
238 Checks whether the "AppList.Bin" exists, if not waits for a maximum time of (KMaxTimeCount * 10) seconds for the file to create. |