|
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 #include <e32test.h> |
|
17 #include "testserver.h" |
|
18 #include <vtzrules.h> |
|
19 #include "ctzswiplugintester.h" |
|
20 |
|
21 _LIT8(KEuropeLondon, "Europe/London"); |
|
22 _LIT(KTzDatabaseToBeDeleted, "c:\\private\\1020383e\\tzdb.dbz"); |
|
23 _LIT(KROM_SISFile, "z:\\testresourcefiles\\signed_timezone_upgrade.sis"); |
|
24 _LIT(KFlash_SISFile, "c:\\signed_timezone_upgrade.sis"); |
|
25 _LIT(KTimeZonePackageUid, "200020B0"); |
|
26 _LIT(KTimeZonePackageName, "TimeZone-Database-patch"); |
|
27 _LIT(KTimeZoneVendorName, "Symbian Software Ltd."); |
|
28 |
|
29 RTest test (_L("t_tzdatabaseupdate")); |
|
30 |
|
31 LOCAL_C void DeleteFileL(const TDesC& aFilename) |
|
32 { |
|
33 RPIMTestServer serv; |
|
34 CleanupClosePushL(serv); |
|
35 TInt err = serv.Connect(); |
|
36 if (err != KErrNone) |
|
37 { |
|
38 _LIT(KErrTestServerConnection, "Couldn't connect to PIMTestServer\n"); |
|
39 test.Printf(KErrTestServerConnection); |
|
40 User::Leave(err); |
|
41 } |
|
42 serv.DeleteFileL(aFilename); |
|
43 CleanupStack::PopAndDestroy(&serv); |
|
44 } |
|
45 |
|
46 LOCAL_C void CopyFileL(const TDesC& aCopyFromFile, const TDesC& aCopyToFile) |
|
47 { |
|
48 RPIMTestServer serv; |
|
49 CleanupClosePushL(serv); |
|
50 User::LeaveIfError(serv.Connect()); |
|
51 |
|
52 serv.CopyFileL(aCopyFromFile, aCopyToFile); |
|
53 |
|
54 CleanupStack::PopAndDestroy(&serv); |
|
55 } |
|
56 |
|
57 /** |
|
58 @SYMTestCaseID PIM-TZDATABASEUPDATE-0001 |
|
59 @SYMTestCaseDesc The purpose of this test is to verify that eclipsing is taken into account |
|
60 even if the time zone server is running. |
|
61 @SYMTestActions 1. Use the RTz API to obtain a copy of the first TZ rule (preUpdateRule) |
|
62 for a given time zone. |
|
63 2. Copy a system TZ rules database that modifies the TZ rule obtained in |
|
64 action 1 to the appropriate location the C: drive. The server is still |
|
65 running when this happens. |
|
66 3. Use the RTz API to obtain a copy of the first TZ rule (postUpdateRule) |
|
67 for the same time zone used in action 2. |
|
68 |
|
69 @SYMTestExpectedResults The preUpdateRule object is not the same as the postUpdateRule object. |
|
70 @SYMREQ REQ9952 |
|
71 @SYMTestType CT |
|
72 @SYMTestPriority 1 |
|
73 */ |
|
74 LOCAL_C void TestRulesInTzDatabaseLiveUpdateL() |
|
75 { |
|
76 RTz tz; |
|
77 CleanupClosePushL(tz); |
|
78 User::LeaveIfError(tz.Connect()); |
|
79 |
|
80 CTzId* tzId = CTzId::NewL(KEuropeLondon); |
|
81 CleanupStack::PushL(tzId); |
|
82 tz.SetTimeZoneL(*tzId); |
|
83 |
|
84 TDateTime startDateTime(2008,EJanuary,0,0,0,0,0); |
|
85 TDateTime endDateTime(2008,EDecember,30,23,59,59,0); |
|
86 CTzRules* tzRules = tz.GetTimeZoneRulesL(*tzId,startDateTime,endDateTime,ETzUtcTimeReference); |
|
87 CleanupStack::PushL(tzRules); |
|
88 TInt count = tzRules->Count(); |
|
89 test.Printf(_L("The number of rules found in default database are %d\n"), count); |
|
90 CleanupStack::PopAndDestroy(tzRules); |
|
91 |
|
92 CopyFileL(KROM_SISFile(), KFlash_SISFile()); |
|
93 |
|
94 TRequestStatus reqStatus; |
|
95 CCTzSwiPluginTester* sisInstaller = CCTzSwiPluginTester::NewLC(); |
|
96 //Make an async call to ensure the changes have been flagged before proceeding. |
|
97 sisInstaller->InstallSIS(KFlash_SISFile(), CCTzSwiPluginTester::EPropertyRules, reqStatus); |
|
98 CActiveScheduler::Start(); |
|
99 |
|
100 CTzRules* tzRulesFlash = tz.GetTimeZoneRulesL(*tzId,startDateTime,endDateTime,ETzUtcTimeReference); |
|
101 CleanupStack::PushL(tzRulesFlash); |
|
102 |
|
103 TInt countFlash = tzRulesFlash->Count(); |
|
104 test.Printf(_L("The number of rules found in the database on flash are %d\n"), countFlash); |
|
105 |
|
106 test(count != countFlash); |
|
107 |
|
108 sisInstaller->UninstallSIS(KTimeZonePackageUid(), KTimeZonePackageName(), KTimeZoneVendorName()); |
|
109 //Need this to allow the notification plug-in code to run |
|
110 User::After(1000000); |
|
111 |
|
112 CTzRules* tzRulesRom = tz.GetTimeZoneRulesL(*tzId,startDateTime,endDateTime,ETzUtcTimeReference); |
|
113 CleanupStack::PushL(tzRulesRom); |
|
114 |
|
115 TInt countRom = tzRulesRom->Count(); |
|
116 test.Printf(_L("The number of rules found in the database on rom are %d\n"), countRom); |
|
117 |
|
118 test(count == countRom); |
|
119 CleanupStack::PopAndDestroy(tzRulesRom); |
|
120 |
|
121 |
|
122 DeleteFileL(KTzDatabaseToBeDeleted); |
|
123 |
|
124 CleanupStack::PopAndDestroy(tzRulesFlash); |
|
125 CleanupStack::PopAndDestroy(sisInstaller); |
|
126 CleanupStack::PopAndDestroy(tzId); |
|
127 CleanupStack::PopAndDestroy(&tz); |
|
128 } |
|
129 |
|
130 LOCAL_C void DoStartL() |
|
131 { |
|
132 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler(); |
|
133 CleanupStack::PushL(scheduler); |
|
134 |
|
135 CActiveScheduler::Install(scheduler); |
|
136 TRAP_IGNORE(DeleteFileL(KTzDatabaseToBeDeleted())); |
|
137 TestRulesInTzDatabaseLiveUpdateL(); |
|
138 // Delete active scheduler |
|
139 CleanupStack::PopAndDestroy(scheduler); |
|
140 } |
|
141 |
|
142 // Global Functions |
|
143 |
|
144 |
|
145 GLDEF_C TInt E32Main() |
|
146 { |
|
147 // Create cleanup stack |
|
148 __UHEAP_MARK; |
|
149 test.Start(_L("@SYMTestCaseID PIM-TZDATABASEUPDATE-0001 Starting Test t_tzdatabaseupdate")); |
|
150 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
151 |
|
152 // Run application code inside TRAP harness. |
|
153 TRAPD(mainError, DoStartL()); |
|
154 |
|
155 test(mainError == KErrNone); |
|
156 |
|
157 delete cleanup; |
|
158 test.End(); |
|
159 test.Close(); |
|
160 __UHEAP_MARKEND; |
|
161 return KErrNone; |
|
162 } |
|
163 |