|
1 /* |
|
2 * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // CLASS HEADER |
|
20 #include "MT_aifw.h" |
|
21 #include "aifw.h" |
|
22 #include "AiFwTestContentPlugin.h" |
|
23 #include "aicontentobserver.h" |
|
24 #include "aipluginactivitypstool.h" |
|
25 #include "caouserafter.h" |
|
26 |
|
27 // EXTERNAL INCLUDES |
|
28 #include <EUnitMacros.h> |
|
29 #include <CEUnitAllocTestCaseDecorator.h> |
|
30 #include <bautils.h> |
|
31 #include <connect/sbdefs.h> |
|
32 #include <screensaverinternalpskeys.h> // this include needs to be last |
|
33 #include <e32property.h> |
|
34 |
|
35 using namespace AiTestUiController; |
|
36 |
|
37 const TUint32 KAiFwCenrepKey( 0x2001952B ); |
|
38 |
|
39 void CopyFile1() |
|
40 { |
|
41 RFs fss; |
|
42 fss.Connect(); |
|
43 TInt err = BaflUtils::CopyFile( fss, |
|
44 _L("z:\\system\\apps\\aifweunit\\10275102_1.cre"), |
|
45 _L("c:\\private\\10202be9\\persists\\10275102.cre") ); |
|
46 fss.Close(); |
|
47 } |
|
48 |
|
49 void CopyFile2() |
|
50 { |
|
51 RFs fss; |
|
52 fss.Connect(); |
|
53 TInt err = BaflUtils::CopyFile( fss, |
|
54 _L("z:\\system\\apps\\aifweunit\\10275102_2.cre"), |
|
55 _L("c:\\private\\10202be9\\persists\\10275102.cre") ); |
|
56 fss.Close(); |
|
57 } |
|
58 |
|
59 void DeleteFile() |
|
60 { |
|
61 RFs fss; |
|
62 fss.Connect(); |
|
63 TInt err = BaflUtils::DeleteFile( fss, |
|
64 _L("c:\\private\\10202be9\\persists\\10275102.cre") ); |
|
65 fss.Close(); |
|
66 } |
|
67 |
|
68 void ChangeSSValueL( TInt aValue ) |
|
69 { |
|
70 RProperty::Define( KPSUidScreenSaver, |
|
71 KScreenSaverOn, |
|
72 RProperty::EInt ); |
|
73 |
|
74 User::LeaveIfError( RProperty::Set( KPSUidScreenSaver, |
|
75 KScreenSaverOn, |
|
76 aValue ) ); |
|
77 |
|
78 } |
|
79 |
|
80 void ChangeBackupValueL( TInt aValue ) |
|
81 { |
|
82 RProperty::Define( KUidSystemCategory, |
|
83 conn::KUidBackupRestoreKey, |
|
84 RProperty::EInt ); |
|
85 |
|
86 User::LeaveIfError( RProperty::Set( KUidSystemCategory, |
|
87 conn::KUidBackupRestoreKey, |
|
88 aValue ) ); |
|
89 |
|
90 } |
|
91 |
|
92 // INTERNAL INCLUDES |
|
93 |
|
94 // CONSTRUCTION |
|
95 MT_aifw* MT_aifw::NewL() |
|
96 { |
|
97 MT_aifw* self = MT_aifw::NewLC(); |
|
98 CleanupStack::Pop(); |
|
99 |
|
100 return self; |
|
101 } |
|
102 |
|
103 MT_aifw* MT_aifw::NewLC() |
|
104 { |
|
105 MT_aifw* self = new( ELeave ) MT_aifw(); |
|
106 CleanupStack::PushL( self ); |
|
107 |
|
108 self->ConstructL(); |
|
109 |
|
110 return self; |
|
111 } |
|
112 |
|
113 // Destructor (virtual by CBase) |
|
114 MT_aifw::~MT_aifw() |
|
115 { |
|
116 delete iFramework; |
|
117 DeleteFile(); |
|
118 } |
|
119 |
|
120 // Default constructor |
|
121 MT_aifw::MT_aifw() |
|
122 { |
|
123 } |
|
124 |
|
125 // Second phase construct |
|
126 void MT_aifw::ConstructL() |
|
127 { |
|
128 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
129 // It generates the test case table. |
|
130 CEUnitTestSuiteClass::ConstructL(); |
|
131 SetupL(); |
|
132 Teardown(); |
|
133 } |
|
134 |
|
135 // METHODS |
|
136 |
|
137 |
|
138 void MT_aifw::SetupL( ) |
|
139 { |
|
140 CopyFile1(); |
|
141 iFramework = CAiFw::NewLC(); |
|
142 CleanupStack::Pop( iFramework ); |
|
143 iControllerPlugin = AiTestUiController::CAiFwTestControllerPlugin::Instance( /**iFramework*/ ); |
|
144 //iControllerPlugin->SetAppEnvReadyL(); |
|
145 //iControllerPlugin->SendReadyEventL(); |
|
146 CAOUserAfter::AfterLD( 1 * 1000000 ); |
|
147 |
|
148 RAiPublisherInfoArray aPlugins; |
|
149 iControllerPlugin->GetPluginsL( aPlugins ); |
|
150 iControllerPlugin->HandleLoadedPlugins( aPlugins ); |
|
151 |
|
152 iContentPlugin = CAiFwTestContentPlugin::Instance(); |
|
153 iContentPlugin->SubscribeL( *iControllerPlugin ); |
|
154 iContentPlugin->Resume(EAiSystemStartup); |
|
155 } |
|
156 |
|
157 |
|
158 void MT_aifw::Teardown( ) |
|
159 { |
|
160 delete iFramework; |
|
161 iFramework = NULL; |
|
162 DeleteFile(); |
|
163 } |
|
164 |
|
165 void MT_aifw::TestStartupL( ) |
|
166 { |
|
167 EUNIT_ASSERT( iControllerPlugin != NULL ); |
|
168 EUNIT_ASSERT( iContentPlugin != NULL ); |
|
169 } |
|
170 |
|
171 void MT_aifw::TestSubscriptionL( ) |
|
172 { |
|
173 RPointerArray<MAiContentObserver>& observers = iContentPlugin->Observers(); |
|
174 TBool match = EFalse; |
|
175 |
|
176 for( TInt i = 0; i < observers.Count(); ++i ) |
|
177 { |
|
178 MAiContentObserver* obs = observers[i]; |
|
179 if( obs == static_cast<MAiContentObserver*>( iControllerPlugin ) ) |
|
180 { |
|
181 match = ETrue; |
|
182 break; |
|
183 } |
|
184 } |
|
185 |
|
186 EUNIT_ASSERT( match ); |
|
187 } |
|
188 |
|
189 void MT_aifw::TestStartupResumeL( ) |
|
190 { |
|
191 /* iControllerPlugin->SetForegroundL( EFalse ); |
|
192 iControllerPlugin->SetForegroundL( ETrue ); |
|
193 CAOUserAfter::AfterLD( 1 * 1000000 ); |
|
194 iControllerPlugin->SetResourceChangedL( 0xfff );*/ |
|
195 EUNIT_ASSERT( iContentPlugin->WasResumed() ); |
|
196 } |
|
197 |
|
198 void MT_aifw::TestUiActivationL( ) |
|
199 { |
|
200 //EUNIT_ASSERT( iControllerPlugin->UiActivated() ); |
|
201 } |
|
202 |
|
203 void MT_aifw::TestUiDefinitionLoadL( ) |
|
204 { |
|
205 //EUNIT_ASSERT( iControllerPlugin->DefinitionLoaded() ); |
|
206 } |
|
207 |
|
208 void MT_aifw::TestSettingsPassingL( ) |
|
209 { |
|
210 EUNIT_ASSERT( iContentPlugin->WasConfigured() ); |
|
211 } |
|
212 |
|
213 void MT_aifw::TestEventForwardingL( ) |
|
214 { |
|
215 iControllerPlugin->SendTestEventL(); |
|
216 EUNIT_ASSERT( iContentPlugin->EventReceived()); |
|
217 /*ChangeSSValueL( ETrue ); |
|
218 ChangeSSValueL( EFalse ); |
|
219 ChangeBackupValueL( conn::EBURNormal ); |
|
220 ChangeBackupValueL( conn::KBURPartTypeMask ^ conn::EBURNormal );*/ |
|
221 } |
|
222 |
|
223 // TEST TABLE |
|
224 |
|
225 EUNIT_BEGIN_TEST_TABLE( |
|
226 MT_aifw, |
|
227 "Module test for XML AI framework.", |
|
228 "MODULE" ) |
|
229 |
|
230 EUNIT_ALLOC_TEST( |
|
231 "System startup setup test", // Test name |
|
232 "Framework", // Class |
|
233 "", // Method |
|
234 "FUNCTIONALITY", |
|
235 SetupL, TestStartupL, Teardown) |
|
236 |
|
237 EUNIT_ALLOC_TEST( |
|
238 "Test plugin subscription", |
|
239 "FW/Plugin manager", |
|
240 "", |
|
241 "FUNCTIONALITY", |
|
242 SetupL, TestSubscriptionL, Teardown) |
|
243 |
|
244 EUNIT_TEST( |
|
245 "Startup resume call", |
|
246 "FW/Plugin manager", |
|
247 "", |
|
248 "FUNCTIONALITY", |
|
249 SetupL, TestStartupResumeL, Teardown) |
|
250 |
|
251 EUNIT_ALLOC_TEST( |
|
252 "Startup UI activation call", |
|
253 "FW/UI Controller manager", |
|
254 "", |
|
255 "FUNCTIONALITY", |
|
256 SetupL, TestUiActivationL, Teardown) |
|
257 |
|
258 EUNIT_ALLOC_TEST( |
|
259 "Startup UI definition load call", |
|
260 "FW/UI Controller manager", |
|
261 "", |
|
262 "FUNCTIONALITY", |
|
263 SetupL, TestUiDefinitionLoadL, Teardown) |
|
264 |
|
265 EUNIT_ALLOC_TEST( |
|
266 "Settings passing", |
|
267 "FW/UI Controller manager", |
|
268 "", |
|
269 "FUNCTIONALITY", |
|
270 SetupL, TestSettingsPassingL, Teardown) |
|
271 |
|
272 EUNIT_ALLOC_TEST( |
|
273 "Plugin event forwarding", |
|
274 "FW/Plugin manager", |
|
275 "", |
|
276 "FUNCTIONALITY", |
|
277 SetupL, TestEventForwardingL, Teardown) |
|
278 |
|
279 EUNIT_END_TEST_TABLE |
|
280 |
|
281 // END OF FILE |