|
1 // Copyright (c) 2008-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 |
|
17 #include <e32base.h> |
|
18 #include <e32std.h> |
|
19 #include <e32des16.h> |
|
20 #include <e32test.h> |
|
21 #include <tzlocalizer.h> |
|
22 #include <tzlocalizedcityrecord.h> |
|
23 #include "testserver.h" |
|
24 #include <f32file.h> |
|
25 |
|
26 _LIT(KDefaultLocale, "elocl.loc"); |
|
27 #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL |
|
28 _LIT(KFrenchLocale, "elocl_lan.002"); |
|
29 #else |
|
30 _LIT(KFrenchLocale, "elocl.02"); |
|
31 #endif |
|
32 const TInt KDefaultTzId = 2592; |
|
33 const TInt KDefaultCityGroupId = 1; |
|
34 const TInt KParisTzId = 2656; |
|
35 |
|
36 _LIT(KSrcTzLocRscFile1, "z:\\timezonelocalization\\timezonegroups.r01"); |
|
37 _LIT(KSrcTzLocRscFile2, "z:\\timezonelocalization\\timezonegroups.r02"); |
|
38 _LIT(KSrcTzLocRscFile3, "z:\\timezonelocalization\\timezonegroups.rsc"); |
|
39 _LIT(KSrcTzLocRscFile4, "z:\\timezonelocalization\\timezones.r01"); |
|
40 _LIT(KSrcTzLocRscFile5, "z:\\timezonelocalization\\timezones.r02"); |
|
41 _LIT(KSrcTzLocRscFile6, "z:\\timezonelocalization\\timezones.rsc"); |
|
42 |
|
43 _LIT(KDestTzLocRscDir, "c:\\resource\\timezonelocalization\\"); |
|
44 _LIT(KDestTzLocRscFile1, "c:\\resource\\timezonelocalization\\timezonegroups.r01"); |
|
45 _LIT(KDestTzLocRscFile2, "c:\\resource\\timezonelocalization\\timezonegroups.r02"); |
|
46 _LIT(KDestTzLocRscFile3, "c:\\resource\\timezonelocalization\\timezonegroups.rsc"); |
|
47 _LIT(KDestTzLocRscFile4, "c:\\resource\\timezonelocalization\\timezones.r01"); |
|
48 _LIT(KDestTzLocRscFile5, "c:\\resource\\timezonelocalization\\timezones.r02"); |
|
49 _LIT(KDestTzLocRscFile6, "c:\\resource\\timezonelocalization\\timezones.rsc"); |
|
50 |
|
51 _LIT(KTzLocTemporaryFile,"c:\\private\\100012a5\\DBS_2000836D_DBS_DSC.db"); |
|
52 _LIT(KTzLocDb,"c:\\private\\100012a5\\DBS_10206A8B_TzLocalization.db"); |
|
53 |
|
54 _LIT(KSrcTzLocModifiedDir, "z:\\timezonelocalization\\modified"); |
|
55 |
|
56 _LIT(KSrcTzLocLocaleModifiedDir, "z:\\timezonelocalization\\locale\\"); |
|
57 |
|
58 _LIT(KAgendaServer,"agsvexe*"); |
|
59 _LIT(KTzServer,"Tzserver*"); |
|
60 |
|
61 RTest test(_L("TZ Localization Resource Files Update Test Suite")); |
|
62 |
|
63 |
|
64 LOCAL_C void CopyFilesL(RPIMTestServer& aTestServer) |
|
65 { |
|
66 aTestServer.CopyFileL(KSrcTzLocRscFile1,KDestTzLocRscFile1); |
|
67 aTestServer.CopyFileL(KSrcTzLocRscFile2,KDestTzLocRscFile2); |
|
68 aTestServer.CopyFileL(KSrcTzLocRscFile3,KDestTzLocRscFile3); |
|
69 aTestServer.CopyFileL(KSrcTzLocRscFile4,KDestTzLocRscFile4); |
|
70 aTestServer.CopyFileL(KSrcTzLocRscFile5,KDestTzLocRscFile5); |
|
71 aTestServer.CopyFileL(KSrcTzLocRscFile6,KDestTzLocRscFile6); |
|
72 } |
|
73 |
|
74 |
|
75 LOCAL_C void DeleteFilesL(RPIMTestServer& aTestServer) |
|
76 { |
|
77 aTestServer.DeleteFileL(KDestTzLocRscFile1); |
|
78 aTestServer.DeleteFileL(KDestTzLocRscFile2); |
|
79 aTestServer.DeleteFileL(KDestTzLocRscFile3); |
|
80 aTestServer.DeleteFileL(KDestTzLocRscFile4); |
|
81 aTestServer.DeleteFileL(KDestTzLocRscFile5); |
|
82 aTestServer.DeleteFileL(KDestTzLocRscFile6); |
|
83 aTestServer.DeleteDirL(KDestTzLocRscDir); |
|
84 } |
|
85 |
|
86 LOCAL_C void DeleteEnglishFilesL(RPIMTestServer& aTestServer) |
|
87 { |
|
88 aTestServer.DeleteFileL(KDestTzLocRscFile1); |
|
89 aTestServer.DeleteFileL(KDestTzLocRscFile3); |
|
90 aTestServer.DeleteFileL(KDestTzLocRscFile4); |
|
91 aTestServer.DeleteFileL(KDestTzLocRscFile6); |
|
92 aTestServer.DeleteDirL(KDestTzLocRscDir); |
|
93 } |
|
94 |
|
95 /** |
|
96 @SYMTestCaseID PIM-APPSERV-LOC-TZL-ECL-0001 |
|
97 |
|
98 @SYMTestCaseDesc |
|
99 The purpose of this test is to verify the use of eclipsed system TZ |
|
100 localization resources. |
|
101 |
|
102 @SYMTestActions |
|
103 1. Use the CTzLocalizer API to obtain a copy of the cities |
|
104 (preUpdateCities) for a given city group identifier. |
|
105 |
|
106 2. Copy system TZ localization resources that adds a city to the city group |
|
107 used in action 1 to the appropriate location on the C: drive. |
|
108 |
|
109 3. Use the CTzLocalizer API to obtain a copy of the cities |
|
110 (postUpdateCities) for the same city group identifier used in action 1. |
|
111 |
|
112 @SYMTestExpectedResults |
|
113 The preUpdateCities object should not contain the added city and the |
|
114 postUpdateCities object should contain the added city. |
|
115 |
|
116 @SYMREQ |
|
117 REQ9952 |
|
118 |
|
119 @SYMTestType |
|
120 CT |
|
121 |
|
122 @SYMTestPriority |
|
123 1 |
|
124 */ |
|
125 LOCAL_C void TestUpdatedLocalizationFilesL() |
|
126 { |
|
127 RPIMTestServer serv; |
|
128 CleanupClosePushL(serv); |
|
129 User::LeaveIfError(serv.Connect()); |
|
130 |
|
131 serv.CloseTzSession(); |
|
132 TRAP_IGNORE(serv.KillProcessL(KAgendaServer)); |
|
133 TRAP_IGNORE(serv.KillProcessL(KTzServer)); |
|
134 |
|
135 DeleteFilesL(serv); |
|
136 serv.DeleteDirL(KDestTzLocRscDir); |
|
137 serv.DeleteFileL(KTzLocDb); |
|
138 |
|
139 CTzLocalizer* localizer = CTzLocalizer::NewLC(); |
|
140 // Set timezone to be London. |
|
141 localizer->SetTimeZoneL(KDefaultTzId); |
|
142 |
|
143 CTzLocalizedCityGroup* group = localizer->GetCityGroupL(KDefaultCityGroupId); |
|
144 CleanupStack::PushL(group); |
|
145 CTzLocalizedCityArray* cities = localizer->GetCitiesInGroupL(*group); |
|
146 CleanupStack::PushL(cities); |
|
147 |
|
148 TInt countDefault = cities->Count(); |
|
149 test.Printf(_L("The number of cities found in a city group in the default files are %d\n"), countDefault); |
|
150 |
|
151 CleanupStack::PopAndDestroy(cities); |
|
152 CleanupStack::PopAndDestroy(group); |
|
153 CleanupStack::PopAndDestroy(localizer); |
|
154 |
|
155 CopyFilesL(serv); |
|
156 |
|
157 CTzLocalizer* localizerFlash = CTzLocalizer::NewLC(); |
|
158 localizerFlash->SetTimeZoneL(KDefaultTzId); |
|
159 |
|
160 CTzLocalizedCityGroup* groupFlash = localizerFlash->GetCityGroupL(KDefaultCityGroupId); |
|
161 CleanupStack::PushL(groupFlash); |
|
162 CTzLocalizedCityArray* citiesFlash = localizerFlash->GetCitiesInGroupL(*groupFlash); |
|
163 CleanupStack::PushL(citiesFlash); |
|
164 TInt countFlash = citiesFlash->Count(); |
|
165 |
|
166 test.Printf(_L("The number of cities found in a city group in the files under system drive are %d\n"), countFlash); |
|
167 __ASSERT_ALWAYS(countDefault < countFlash, User::Panic(_L("Number of cities found in the file on ROM and flash is the same"), 1)); |
|
168 |
|
169 CleanupStack::PopAndDestroy(citiesFlash); |
|
170 CleanupStack::PopAndDestroy(groupFlash); |
|
171 CleanupStack::PopAndDestroy(localizerFlash); |
|
172 |
|
173 DeleteFilesL(serv); |
|
174 serv.DeleteDirL(KDestTzLocRscDir); |
|
175 |
|
176 CleanupStack::PopAndDestroy(&serv); |
|
177 } |
|
178 |
|
179 /** |
|
180 @SYMTestCaseID PIM-localizationupdate-0001 |
|
181 |
|
182 @SYMTestCaseDesc |
|
183 The purpose of this test is to verify the use of eclipsed system |
|
184 TZ localization resources. |
|
185 |
|
186 @SYMTestActions |
|
187 1. The current locale of the system is changed to French |
|
188 |
|
189 2. Fetch the number of cities in the group |
|
190 |
|
191 3. Files are copied to system drive |
|
192 |
|
193 4. Fetch the number of cities in the group |
|
194 |
|
195 5. Delete the files on system drive |
|
196 |
|
197 6. Fetch the number of cities in the group |
|
198 |
|
199 @SYMTestExpectedResults |
|
200 Number of cities in Step 2 and 6 is 2 |
|
201 |
|
202 Number of cities in Step 4 is 52 |
|
203 |
|
204 @SYMREQ |
|
205 REQ9952 |
|
206 @SYMTestType |
|
207 CT |
|
208 |
|
209 @SYMTestPriority |
|
210 1 |
|
211 */ |
|
212 LOCAL_C void TestEclipsingOfRscFileL() |
|
213 { |
|
214 _LIT(KLocaleChangeStart, "Changing locale to French\n"); |
|
215 test.Printf(KLocaleChangeStart); |
|
216 |
|
217 TExtendedLocale extendedLocale; |
|
218 extendedLocale.LoadSystemSettings(); |
|
219 TBuf<100> localeDllLocationString ; |
|
220 localeDllLocationString.Copy(KFrenchLocale); |
|
221 extendedLocale.LoadLocaleAspect(ELocaleLanguageSettings, localeDllLocationString) ; |
|
222 extendedLocale.SaveSystemSettings(); |
|
223 |
|
224 RPIMTestServer serv; |
|
225 CleanupClosePushL(serv); |
|
226 User::LeaveIfError(serv.Connect()); |
|
227 |
|
228 serv.CloseTzSession(); |
|
229 TRAP_IGNORE(serv.KillProcessL(KAgendaServer)); |
|
230 TRAP_IGNORE(serv.KillProcessL(KTzServer)); |
|
231 |
|
232 DeleteFilesL(serv); |
|
233 serv.DeleteDirL(KDestTzLocRscDir); |
|
234 serv.DeleteFileL(KTzLocDb); |
|
235 |
|
236 CTzLocalizer* localizer = CTzLocalizer::NewLC(); |
|
237 // Set timezone to be London |
|
238 localizer->SetTimeZoneL(KDefaultTzId); |
|
239 |
|
240 // Get the default city and cities within the group |
|
241 CTzLocalizedCityGroup* group = localizer->GetCityGroupL(KDefaultCityGroupId); |
|
242 CleanupStack::PushL(group); |
|
243 CTzLocalizedCityArray* cities = localizer->GetCitiesInGroupL(*group); |
|
244 CleanupStack::PushL(cities); |
|
245 |
|
246 // Get the number of cities |
|
247 TInt countDefault = cities->Count(); |
|
248 test.Printf(_L("The number of cities found in a city group in the default files are %d\n"), countDefault); |
|
249 |
|
250 CleanupStack::PopAndDestroy(cities); |
|
251 CleanupStack::PopAndDestroy(group); |
|
252 CleanupStack::PopAndDestroy(localizer); |
|
253 |
|
254 // Copy files on to system drive |
|
255 serv.CopyFileL(KSrcTzLocLocaleModifiedDir, KDestTzLocRscDir); |
|
256 |
|
257 // Get cities and city group |
|
258 CTzLocalizer* localizerFlash = CTzLocalizer::NewLC(); |
|
259 localizerFlash->SetTimeZoneL(KDefaultTzId); |
|
260 |
|
261 // Fetch cities |
|
262 CTzLocalizedCityGroup* groupFlash = localizerFlash->GetCityGroupL(KDefaultCityGroupId); |
|
263 CleanupStack::PushL(groupFlash); |
|
264 CTzLocalizedCityArray* citiesFlash = localizerFlash->GetCitiesInGroupL(*groupFlash); |
|
265 CleanupStack::PushL(citiesFlash); |
|
266 |
|
267 // Get the number of cities in the group |
|
268 TInt countFlash = citiesFlash->Count(); |
|
269 test.Printf(_L("The number of cities found in a city group in the files under system drive are %d\n"), countFlash); |
|
270 |
|
271 // Test whether number of cities from system drive is more than ones on ROM |
|
272 test(countDefault < countFlash); |
|
273 |
|
274 // Cleanup |
|
275 CleanupStack::PopAndDestroy(citiesFlash); |
|
276 CleanupStack::PopAndDestroy(groupFlash); |
|
277 CleanupStack::PopAndDestroy(localizerFlash); |
|
278 |
|
279 // Delete the resource files |
|
280 DeleteEnglishFilesL(serv); |
|
281 serv.DeleteFileL(KTzLocDb); |
|
282 |
|
283 // Get cities and city group |
|
284 CTzLocalizer* newLocalizer = CTzLocalizer::NewLC(); |
|
285 CTzLocalizedCityGroup* newGroup = newLocalizer->GetCityGroupL(KDefaultCityGroupId); |
|
286 CleanupStack::PushL(newGroup); |
|
287 CTzLocalizedCityArray* newCities = newLocalizer->GetCitiesInGroupL(*newGroup); |
|
288 CleanupStack::PushL(newCities); |
|
289 |
|
290 // Get the count of cities |
|
291 TInt newCount = newCities->Count(); |
|
292 test.Printf(_L("The number of cities found in a city group in the files under ROM are %d\n"), newCount); |
|
293 test(newCount < countFlash); |
|
294 |
|
295 // Cleanup |
|
296 CleanupStack::PopAndDestroy(newCities); |
|
297 CleanupStack::PopAndDestroy(newGroup); |
|
298 CleanupStack::PopAndDestroy(newLocalizer); |
|
299 CleanupStack::PopAndDestroy(&serv); |
|
300 |
|
301 // Revert the system locale to English |
|
302 localeDllLocationString.Copy(KDefaultLocale); |
|
303 TInt ret = extendedLocale.LoadLocaleAspect(ELocaleLanguageSettings, localeDllLocationString) ; |
|
304 if(ret != KErrNone) |
|
305 { |
|
306 test.Printf(_L("Could not revert to default locale. Error code is %d"), ret); |
|
307 } |
|
308 extendedLocale.SaveSystemSettings(); |
|
309 } |
|
310 |
|
311 LOCAL_C void TestImpactOfTimeZoneDeleteOnCityL() |
|
312 { |
|
313 RPIMTestServer serv; |
|
314 CleanupClosePushL(serv); |
|
315 User::LeaveIfError(serv.Connect()); |
|
316 |
|
317 serv.CloseTzSession(); |
|
318 |
|
319 TRAP_IGNORE(serv.KillProcessL(KAgendaServer)); |
|
320 TRAP_IGNORE(serv.KillProcessL(KTzServer)); |
|
321 |
|
322 DeleteFilesL(serv); |
|
323 serv.DeleteDirL(KDestTzLocRscDir); |
|
324 serv.DeleteFileL(KTzLocDb); |
|
325 |
|
326 RTz tz; |
|
327 CleanupClosePushL(tz); |
|
328 User::LeaveIfError(tz.Connect()); |
|
329 |
|
330 CTzLocalizer* localizer = CTzLocalizer::NewLC(); |
|
331 localizer->SetTimeZoneL(KDefaultTzId); |
|
332 |
|
333 _LIT(KUserCity1, "UserCity1"); |
|
334 CTzLocalizedCity* city1 = localizer->AddCityL(KDefaultTzId, KUserCity1); |
|
335 delete city1; |
|
336 |
|
337 _LIT(KUserCity2, "UserCity2"); |
|
338 CTzLocalizedCity* city2 = localizer->AddCityL(KDefaultTzId, KUserCity2); |
|
339 delete city2; |
|
340 |
|
341 _LIT(KUserCity3, "UserCity3"); |
|
342 CTzLocalizedCity* city3 = localizer->AddCityL(KParisTzId, KUserCity3); |
|
343 delete city3; |
|
344 |
|
345 //Read the number of cities |
|
346 RPointerArray<CTzLocalizedCityRecord> cityRecords; |
|
347 tz.LocalizationReadCitiesL(cityRecords); |
|
348 test.Printf(_L("Check if the number of cities read is correct\n")); |
|
349 test(cityRecords.Count() == 3); |
|
350 cityRecords.ResetAndDestroy(); |
|
351 cityRecords.Close(); |
|
352 CleanupStack::PopAndDestroy(localizer); |
|
353 |
|
354 // Copy the files that do not contain information on Paris |
|
355 TRAPD(err, serv.CopyFileL(KSrcTzLocModifiedDir, KDestTzLocRscDir)); |
|
356 if (err != KErrNone) |
|
357 { |
|
358 _LIT(KErrCopyFiles, "Couldn't copy database file\n"); |
|
359 test.Printf(KErrCopyFiles); |
|
360 User::Leave(err); |
|
361 } |
|
362 tz.SwiObsBeginL(); |
|
363 tz.SwiObsFileChangedL(RTz::EFilterResourceTimezonelocalization); |
|
364 tz.SwiObsEndL(); |
|
365 |
|
366 CTzLocalizer* newLocalizer = CTzLocalizer::NewLC(); |
|
367 newLocalizer->SetTimeZoneL(KDefaultTzId); |
|
368 //Read the number of cities again |
|
369 RPointerArray<CTzLocalizedCityRecord> cityRecords2; |
|
370 tz.LocalizationReadCitiesL(cityRecords2); |
|
371 test.Printf(_L("Again, check if the number of cities read is correct\n")); |
|
372 test(cityRecords2.Count() == 2); |
|
373 cityRecords2.ResetAndDestroy(); |
|
374 cityRecords2.Close(); |
|
375 CleanupStack::PopAndDestroy(newLocalizer); |
|
376 CleanupStack::PopAndDestroy(&tz); |
|
377 |
|
378 DeleteFilesL(serv); |
|
379 serv.DeleteDirL(KDestTzLocRscDir); |
|
380 serv.DeleteFileL(KTzLocDb); |
|
381 |
|
382 CleanupStack::PopAndDestroy(&serv); |
|
383 } |
|
384 |
|
385 LOCAL_C void TestImpactOfTimeZoneDeleteOnZoneL() |
|
386 { |
|
387 RPIMTestServer serv; |
|
388 CleanupClosePushL(serv); |
|
389 User::LeaveIfError(serv.Connect()); |
|
390 |
|
391 serv.CloseTzSession(); |
|
392 TRAP_IGNORE(serv.KillProcessL(KAgendaServer)); |
|
393 TRAP_IGNORE(serv.KillProcessL(KTzServer)); |
|
394 |
|
395 DeleteFilesL(serv); |
|
396 serv.DeleteDirL(KDestTzLocRscDir); |
|
397 serv.DeleteFileL(KTzLocDb); |
|
398 |
|
399 RTz tz; |
|
400 CleanupClosePushL(tz); |
|
401 User::LeaveIfError(tz.Connect()); |
|
402 |
|
403 CTzLocalizer* localizer = CTzLocalizer::NewLC(); |
|
404 localizer->SetFrequentlyUsedZoneL(KParisTzId, CTzLocalizedTimeZone::EHomeZone); |
|
405 CleanupStack::PopAndDestroy(localizer); |
|
406 |
|
407 // Copy the resource files that do not have Paris in them |
|
408 test.Printf(_L("Copy resource files to flash drive\n")); |
|
409 TRAPD(err, serv.CopyFileL(KSrcTzLocModifiedDir, KDestTzLocRscDir)); |
|
410 if (err != KErrNone) |
|
411 { |
|
412 _LIT(KErrCopyFiles, "Couldn't copy database file\n"); |
|
413 test.Printf(KErrCopyFiles); |
|
414 User::Leave(err); |
|
415 } |
|
416 tz.SwiObsBeginL(); |
|
417 tz.SwiObsFileChangedL(RTz::EFilterResourceTimezonelocalization); |
|
418 tz.SwiObsEndL(); |
|
419 |
|
420 CTzLocalizer* newLocalizer = CTzLocalizer::NewLC(); |
|
421 //Extract zone information, same city should be returned by GetFrequentlyUsedZoneCityL below. |
|
422 CTzLocalizedCity* cityToCompareWith = newLocalizer->GetDefaultCityL(KDefaultTzId); |
|
423 CleanupStack::PushL(cityToCompareWith); |
|
424 |
|
425 //Extract zone information, same zone should be returned by GetFrequentlyUsedZoneL below. |
|
426 CTzLocalizedTimeZone* zoneToCompareWith = newLocalizer->GetLocalizedTimeZoneL(KDefaultTzId); |
|
427 CleanupStack::PushL(zoneToCompareWith); |
|
428 |
|
429 CTzLocalizedCity* city = newLocalizer->GetFrequentlyUsedZoneCityL(CTzLocalizedTimeZone::EHomeZone); |
|
430 test.Printf(_L("Check if the frequently used city read from the database is same as the one expected\n")); |
|
431 test(city->TimeZoneId() == cityToCompareWith->TimeZoneId()); |
|
432 test(city->GroupId() == cityToCompareWith->GroupId()); |
|
433 test(city->Name() == cityToCompareWith->Name()); |
|
434 delete city; |
|
435 |
|
436 CTzLocalizedTimeZone* timeZone = newLocalizer->GetFrequentlyUsedZoneL(CTzLocalizedTimeZone::EHomeZone); |
|
437 test.Printf(_L("Check if the frequently used zone read from the database is same as the one expected\n")); |
|
438 test(timeZone->TimeZoneId() == zoneToCompareWith->TimeZoneId()); |
|
439 test(timeZone->StandardName() == zoneToCompareWith->StandardName()); |
|
440 test(timeZone->ShortStandardName() == zoneToCompareWith->ShortStandardName()); |
|
441 test(timeZone->DaylightName() == zoneToCompareWith->DaylightName()); |
|
442 test(timeZone->ShortDaylightName() == zoneToCompareWith->ShortDaylightName()); |
|
443 delete timeZone; |
|
444 |
|
445 CleanupStack::PopAndDestroy(2, cityToCompareWith); |
|
446 CleanupStack::PopAndDestroy(newLocalizer); |
|
447 CleanupStack::PopAndDestroy(&tz); |
|
448 |
|
449 DeleteFilesL(serv); |
|
450 serv.DeleteDirL(KDestTzLocRscDir); |
|
451 serv.DeleteFileL(KTzLocDb); |
|
452 |
|
453 CleanupStack::PopAndDestroy(&serv); |
|
454 } |
|
455 |
|
456 LOCAL_C void TestImpactOfTimeZoneUpdateL() |
|
457 { |
|
458 RPIMTestServer serv; |
|
459 CleanupClosePushL(serv); |
|
460 User::LeaveIfError(serv.Connect()); |
|
461 |
|
462 serv.CloseTzSession(); |
|
463 TRAP_IGNORE(serv.KillProcessL(KAgendaServer)); |
|
464 TRAP_IGNORE(serv.KillProcessL(KTzServer)); |
|
465 |
|
466 DeleteFilesL(serv); |
|
467 serv.DeleteDirL(KDestTzLocRscDir); |
|
468 serv.DeleteFileL(KTzLocDb); |
|
469 |
|
470 RTz tz; |
|
471 CleanupClosePushL(tz); |
|
472 User::LeaveIfError(tz.Connect()); |
|
473 |
|
474 CTzLocalizer* localizer = CTzLocalizer::NewLC(); |
|
475 localizer->SetFrequentlyUsedZoneL(KDefaultTzId, CTzLocalizedTimeZone::EHomeZone); |
|
476 CleanupStack::PopAndDestroy(localizer); |
|
477 // Copy the resource files that have updated information for London |
|
478 TRAPD(err, serv.CopyFileL(KSrcTzLocModifiedDir, KDestTzLocRscDir)); |
|
479 if (err != KErrNone) |
|
480 { |
|
481 _LIT(KErrCopyFiles, "Couldn't copy database file\n"); |
|
482 test.Printf(KErrCopyFiles); |
|
483 User::Leave(err); |
|
484 } |
|
485 tz.SwiObsBeginL(); |
|
486 tz.SwiObsFileChangedL(RTz::EFilterResourceTimezonelocalization); |
|
487 tz.SwiObsEndL(); |
|
488 |
|
489 CTzLocalizer* newLocalizer = CTzLocalizer::NewLC(); |
|
490 //Extract zone information, same city should be returned by GetFrequentlyUsedZoneCityL below. |
|
491 CTzLocalizedCity* cityToCompareWith = newLocalizer->GetDefaultCityL(KDefaultTzId); |
|
492 CleanupStack::PushL(cityToCompareWith); |
|
493 |
|
494 //Extract zone information, same zone should be returned by GetFrequentlyUsedZoneL below. |
|
495 CTzLocalizedTimeZone* zoneToCompareWith = newLocalizer->GetLocalizedTimeZoneL(KDefaultTzId); |
|
496 CleanupStack::PushL(zoneToCompareWith); |
|
497 |
|
498 CTzLocalizedCity* city = newLocalizer->GetFrequentlyUsedZoneCityL(CTzLocalizedTimeZone::EHomeZone); |
|
499 test.Printf(_L("Check if the frequently used city read from the database is same as the one expected\n")); |
|
500 test(city->TimeZoneId() == cityToCompareWith->TimeZoneId()); |
|
501 test(city->GroupId() == cityToCompareWith->GroupId()); |
|
502 test(city->Name() == cityToCompareWith->Name()); |
|
503 delete city; |
|
504 |
|
505 CTzLocalizedTimeZone* timeZone = newLocalizer->GetFrequentlyUsedZoneL(CTzLocalizedTimeZone::EHomeZone); |
|
506 test.Printf(_L("Check if the frequently used zone read from the database is same as the one expected\n")); |
|
507 test(timeZone->TimeZoneId() == zoneToCompareWith->TimeZoneId()); |
|
508 test(timeZone->StandardName() == zoneToCompareWith->StandardName()); |
|
509 test(timeZone->ShortStandardName() == zoneToCompareWith->ShortStandardName()); |
|
510 test(timeZone->DaylightName() == zoneToCompareWith->DaylightName()); |
|
511 test(timeZone->ShortDaylightName() == zoneToCompareWith->ShortDaylightName()); |
|
512 delete timeZone; |
|
513 CleanupStack::PopAndDestroy(2, cityToCompareWith); |
|
514 CleanupStack::PopAndDestroy(newLocalizer); |
|
515 CleanupStack::PopAndDestroy(&tz); |
|
516 |
|
517 DeleteFilesL(serv); |
|
518 serv.DeleteDirL(KDestTzLocRscDir); |
|
519 serv.DeleteFileL(KTzLocDb); |
|
520 serv.DeleteFileL(KTzLocTemporaryFile); |
|
521 |
|
522 CleanupStack::PopAndDestroy(&serv); |
|
523 } |
|
524 |
|
525 LOCAL_C void DoTestsL() |
|
526 { |
|
527 test.Title(); |
|
528 |
|
529 |
|
530 test.Start(_L(" @SYMTestCaseID PIM-APPSERV-LOC-TZL-ECL-0001 Test Updated Localization Files")); |
|
531 TestUpdatedLocalizationFilesL(); |
|
532 |
|
533 test.Next(_L(" @SYMTestCaseID PIM-localizationupdate-0001 Test Eclipsing of Files with locale changes")); |
|
534 TestEclipsingOfRscFileL(); |
|
535 |
|
536 |
|
537 test.Next(_L("Test the impact of deleting time zone id on user cities table")); |
|
538 TestImpactOfTimeZoneDeleteOnCityL(); |
|
539 |
|
540 test.Next(_L("Test the impact of deleting time zone id on frequently used zone table")); |
|
541 TestImpactOfTimeZoneDeleteOnZoneL(); |
|
542 |
|
543 test.Next(_L("Test the impact of updating time zone id on frequently used zone table")); |
|
544 TestImpactOfTimeZoneUpdateL(); |
|
545 |
|
546 test.End(); |
|
547 } |
|
548 |
|
549 |
|
550 GLDEF_C TInt E32Main() |
|
551 { |
|
552 __UHEAP_MARK; |
|
553 |
|
554 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
555 |
|
556 TRAPD(ret, DoTestsL()); |
|
557 test.Printf(_L("Trapped return value from DoTestsL(): %d\n"), ret); |
|
558 test(ret == KErrNone); |
|
559 |
|
560 delete cleanup; |
|
561 |
|
562 test.Close(); |
|
563 |
|
564 __UHEAP_MARKEND; |
|
565 |
|
566 return KErrNone; |
|
567 } |