|
1 // Copyright (c) 2007-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 <e32panic.h> |
|
18 #include <f32file.h> |
|
19 #include <bautils.h> |
|
20 #include <babackup.h> |
|
21 |
|
22 #include <ecom/ecom.h> |
|
23 #include "EComUidCodes.h" |
|
24 #include "Interface.h" // interface to Plugins |
|
25 //Test utils for copying the resolver to C |
|
26 #include "../EcomTestUtils/EcomTestUtils.h" |
|
27 |
|
28 REComSession EComSess; |
|
29 |
|
30 LOCAL_D RTest TEST(_L("ECom BUR Test")); |
|
31 |
|
32 _LIT(KEComExDllOnZ, "Z:\\ramonly\\EComSwiExample.dll"); |
|
33 _LIT(KEComExDllOnC, "C:\\sys\\bin\\EComSwiExample.dll"); |
|
34 _LIT(KEComRscFileOnC, "C:\\resource\\plugins\\EComSwiExample.rsc"); |
|
35 _LIT(KEComRscFileOnZ, "Z:\\ramonly\\EComSwiExample.rsc"); |
|
36 |
|
37 #define UNUSED_VAR(a) a = a |
|
38 inline LOCAL_C TInt DeleteTestPlugin() |
|
39 { |
|
40 TRAPD(err, EComTestUtils::FileManDeleteFileL(KEComExDllOnC)); |
|
41 if((err == KErrNone)||(err == KErrNotFound)) |
|
42 { |
|
43 TRAP(err, EComTestUtils::FileManDeleteFileL(KEComRscFileOnC)); |
|
44 } |
|
45 if(err == KErrNotFound) |
|
46 { |
|
47 err = KErrNone; |
|
48 } |
|
49 return err; |
|
50 } |
|
51 |
|
52 /** |
|
53 Copies the Resolver Plugins to C:\ drive |
|
54 */ |
|
55 LOCAL_C TInt CopyPluginsL() |
|
56 { |
|
57 // Copy the dlls and .rsc files on to RAM |
|
58 TRAPD(err, EComTestUtils::FileManCopyFileL(KEComExDllOnZ, KEComExDllOnC)); |
|
59 TEST(err==KErrNone, __LINE__); |
|
60 TRAP(err, EComTestUtils::FileManCopyFileL(KEComRscFileOnZ, KEComRscFileOnC)); |
|
61 TEST(err==KErrNone, __LINE__); |
|
62 User::After(1000000); |
|
63 return err; |
|
64 } |
|
65 |
|
66 |
|
67 LOCAL_C void FindImplementationsL(TInt aExpected) |
|
68 { |
|
69 REComSession& ecomSession = REComSession::OpenL(); |
|
70 CleanupClosePushL(ecomSession); |
|
71 |
|
72 //Get a list of available implementations |
|
73 TUid interfaceUid={0x10009DD9}; |
|
74 RImplInfoPtrArray ifArray; |
|
75 |
|
76 ecomSession.ListImplementationsL(interfaceUid,ifArray); |
|
77 |
|
78 //Verify that the expected number of implementations were found |
|
79 TInt count = ifArray.Count(); |
|
80 TEST(count == aExpected); |
|
81 |
|
82 TEST.Printf(_L("%d Implementations found...\n"),count); |
|
83 |
|
84 //cleanup |
|
85 ifArray.ResetAndDestroy(); |
|
86 ecomSession.Close(); |
|
87 CleanupStack::PopAndDestroy(); |
|
88 } |
|
89 |
|
90 LOCAL_C TInt SetupTest() |
|
91 { |
|
92 //Ensure plugin files are not on C: |
|
93 TInt res = DeleteTestPlugin(); |
|
94 TEST.Printf(_L("Deleting test plugin...\n")); |
|
95 |
|
96 //Wait to ensure files are deleted |
|
97 User::After(2000000); |
|
98 |
|
99 //Create an ECom session to ensure ECom is up and running |
|
100 EComSess = REComSession::OpenL(); |
|
101 |
|
102 //Wait to ensure ECom startup has occurred |
|
103 //Wait here for 20s as it takes 15s for the server to register its backup notification |
|
104 User::After(20000000); |
|
105 |
|
106 return res; |
|
107 } |
|
108 |
|
109 /** |
|
110 @SYMTestCaseID SYSLIB-ECOM-CT-4003 |
|
111 @SYMTestCaseDesc Tests that notifications will not be ignored during a backup/restore. |
|
112 @SYMTestActions Uses P&S variables to simulate backup/restore |
|
113 Simulates a backup operation, which should suspend the scanning timer |
|
114 Copy plugin to the relevant directory and check to see that this is discovered |
|
115 after the scanning timer is resumed (after backup is complete) |
|
116 @SYMTestExpectedResults Notification of a directory change should occur during backup/restore, but not processed until afterwards |
|
117 @SYMDEF DEF103909 |
|
118 */ |
|
119 LOCAL_C void RunTestL() |
|
120 { |
|
121 __UHEAP_MARK; |
|
122 |
|
123 //ensure that ecom server is already running |
|
124 TInt res = SetupTest(); |
|
125 TEST(res == KErrNone); |
|
126 |
|
127 //use the backup client to initiate a backup |
|
128 CBaBackupSessionWrapper* backupClient= CBaBackupSessionWrapper::NewL(); |
|
129 |
|
130 //emulate start of backup/restore |
|
131 TBackupOperationAttributes attribs; |
|
132 attribs.iFileFlag=MBackupObserver::EReleaseLockReadOnly; |
|
133 attribs.iOperation=MBackupOperationObserver::EStart; |
|
134 backupClient->NotifyBackupOperationL(attribs); |
|
135 |
|
136 TEST(backupClient->IsBackupOperationRunning()); |
|
137 |
|
138 User::After(2000000); |
|
139 |
|
140 //now do copying of some plugin files |
|
141 CopyPluginsL(); |
|
142 |
|
143 User::After(2000000); |
|
144 |
|
145 // check ecom has not discovered the plugins as idle scanning timer is disabled |
|
146 FindImplementationsL(0); |
|
147 |
|
148 //emulate end of backup/restore |
|
149 attribs.iFileFlag=MBackupObserver::EReleaseLockReadOnly; |
|
150 attribs.iOperation=MBackupOperationObserver::EEnd; |
|
151 backupClient->NotifyBackupOperationL(attribs); |
|
152 |
|
153 User::After(2000000); |
|
154 |
|
155 //now check whether our plugins that is installed during the backup is registered |
|
156 FindImplementationsL(1); |
|
157 |
|
158 //Cleanup |
|
159 EComSess.Close(); |
|
160 REComSession::FinalClose(); |
|
161 |
|
162 //Ensure plugin files are not on C: |
|
163 res = DeleteTestPlugin(); |
|
164 TEST(res == KErrNone); |
|
165 |
|
166 delete backupClient; |
|
167 |
|
168 __UHEAP_MARKEND; |
|
169 } |
|
170 |
|
171 GLDEF_C TInt E32Main() |
|
172 { |
|
173 __UHEAP_MARK; |
|
174 |
|
175 TEST.Title(); |
|
176 TEST.Start(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-4003 ECom BUR tests. ")); |
|
177 |
|
178 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
179 CActiveScheduler* scheduler = new(ELeave)CActiveScheduler; |
|
180 CActiveScheduler::Install(scheduler); |
|
181 |
|
182 TRAPD(err,RunTestL()); |
|
183 TEST(err==KErrNone, __LINE__); |
|
184 |
|
185 delete scheduler; |
|
186 delete cleanup; |
|
187 |
|
188 TEST.End(); |
|
189 TEST.Close(); |
|
190 |
|
191 __UHEAP_MARKEND; |
|
192 return(0); |
|
193 } |