|
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 "aioperatornamepublisher.h" |
|
21 #include "UT_DevStaPlg.h" |
|
22 #include "aicontentpublisher.h" |
|
23 #include "aidevicestatuscontentmodel.h" |
|
24 #include "caouserafter.h" |
|
25 #include "logotools.h" |
|
26 #include "testingtools.h" |
|
27 #include "contentobserver.h" |
|
28 #include "ainativeuiplugins.h" |
|
29 #include <aicontentrequest.h> |
|
30 |
|
31 // EXTERNAL INCLUDES |
|
32 #include <digia/eunit/eunitmacros.h> |
|
33 #include <digia/eunit/ceunitalloctestcasedecorator.h> |
|
34 #include <profile.hrh> |
|
35 #include <mprofilechangeobserver.h> |
|
36 #include <e32cmn.h> |
|
37 #include <gulicon.h> |
|
38 |
|
39 #include "aidevicestatusplugin.h" |
|
40 |
|
41 // INTERNAL INCLUDES |
|
42 |
|
43 const TInt KCountryCode = 244; |
|
44 const TInt KNetworkId = 91; |
|
45 |
|
46 // CONSTRUCTION |
|
47 UT_DevStaPlg* UT_DevStaPlg::NewL() |
|
48 { |
|
49 UT_DevStaPlg* self = UT_DevStaPlg::NewLC(); |
|
50 CleanupStack::Pop(); |
|
51 |
|
52 return self; |
|
53 } |
|
54 |
|
55 UT_DevStaPlg* UT_DevStaPlg::NewLC() |
|
56 { |
|
57 UT_DevStaPlg* self = new( ELeave ) UT_DevStaPlg(); |
|
58 CleanupStack::PushL( self ); |
|
59 |
|
60 self->ConstructL(); |
|
61 |
|
62 return self; |
|
63 } |
|
64 |
|
65 // Destructor (virtual by CBase) |
|
66 UT_DevStaPlg::~UT_DevStaPlg() |
|
67 { |
|
68 } |
|
69 |
|
70 // Default constructor |
|
71 UT_DevStaPlg::UT_DevStaPlg() |
|
72 { |
|
73 } |
|
74 |
|
75 // Second phase construct |
|
76 void UT_DevStaPlg::ConstructL() |
|
77 { |
|
78 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
79 // It generates the test case table. |
|
80 CEUnitTestSuiteClass::ConstructL(); |
|
81 } |
|
82 |
|
83 |
|
84 void UT_DevStaPlg::SetupL( ) |
|
85 { |
|
86 CStubDataHolder::InstanceL(); |
|
87 iCache = &CContentObserver::InstanceL(); |
|
88 |
|
89 TUid uid = { AI_UID_ECOM_IMPLEMENTATION_CONTENTPUBLISHER_DEVSTAPLUGIN }; |
|
90 |
|
91 _LIT8( KNameSpace, "1" ); |
|
92 |
|
93 THsPublisherInfo pubInfo( uid, KDeviceStatusPluginName, KNameSpace ); |
|
94 |
|
95 iPublisher = CHsContentPublisher::NewL( pubInfo ); |
|
96 |
|
97 RAiSettingsItemArray settings; |
|
98 iPublisher->ConfigureL( settings ); |
|
99 iPublisher->SubscribeL( *iCache ); |
|
100 iPublisher->Start( CHsContentPublisher::ESystemStartup ); |
|
101 } |
|
102 |
|
103 void UT_DevStaPlg::SetupEmptyL() |
|
104 { |
|
105 // __UHEAP_MARK; |
|
106 } |
|
107 |
|
108 |
|
109 |
|
110 |
|
111 void UT_DevStaPlg::Teardown( ) |
|
112 { |
|
113 if( iPublisher ) |
|
114 { |
|
115 iPublisher->Stop( EAiSystemStartup ); |
|
116 delete iPublisher; |
|
117 iPublisher = NULL; |
|
118 } |
|
119 |
|
120 /*if( iUtils ) |
|
121 { |
|
122 delete iUtils; |
|
123 iUtils =NULL; |
|
124 }*/ |
|
125 |
|
126 if( iCache ) |
|
127 { |
|
128 iCache->Reset(); |
|
129 iCache->Release(); |
|
130 iCache = NULL; |
|
131 } |
|
132 |
|
133 CStubDataHolder::Release(); |
|
134 REComSession::FinalClose(); |
|
135 #if _BullseyeCoverage |
|
136 cov_write(); |
|
137 #endif |
|
138 } |
|
139 |
|
140 |
|
141 |
|
142 void UT_DevStaPlg::TestL() |
|
143 { |
|
144 CAiOperatorNamePublisher* namePub = CAiOperatorNamePublisher::NewL(); |
|
145 /* |
|
146 namePub->Subscribe( *this, |
|
147 *static_cast<MAiPropertyExtension*>(iPublisher->Extension( KExtensionUidProperty )), |
|
148 *this, |
|
149 *this ); |
|
150 */ |
|
151 namePub->Subscribe( *this, |
|
152 *iPublisher, |
|
153 *this, |
|
154 *this ); |
|
155 |
|
156 MAiNetworkInfoObserver* name = namePub; |
|
157 name->HandleNetworkInfoChange( MNWMessageObserver::ENWMessageNetworkInfoChange, |
|
158 *CStubDataHolder::Instance()->NWInfo(), |
|
159 ETrue ); |
|
160 name->HandleNetworkInfoChange( MNWMessageObserver::ENWMessageNetworkInfoChange, |
|
161 *CStubDataHolder::Instance()->NWInfo(), |
|
162 EFalse ); |
|
163 _LIT( KProfSilent, "Silent" ); |
|
164 _LIT( KProfOffline, "Offline" ); |
|
165 |
|
166 //when publisher is resumed, profile is updated |
|
167 //wait for a while |
|
168 |
|
169 CStubDataHolder::InstanceL()->SetCurrentProfileL( KProfSilent, EProfileSilentId ); |
|
170 |
|
171 //when publisher is resumed, profile update should be published |
|
172 iPublisher->Resume( EAiSystemStartup ); |
|
173 |
|
174 CAOUserAfter::AfterLD( 100000 ); |
|
175 |
|
176 //iBuf should now contain TAiDeviceStatusContentProfile structure |
|
177 |
|
178 CContentCache* cache = iCache->GetContent( EAiDeviceStatusContentSilentIndicator ); |
|
179 EUNIT_ASSERT( cache ); |
|
180 |
|
181 iCache->Reset(); |
|
182 |
|
183 //change profile |
|
184 CStubDataHolder::InstanceL()->SetCurrentProfileL( KProfOffline, EProfileOffLineId ); |
|
185 |
|
186 RArray<TProfileObserver>& obs = CStubDataHolder::InstanceL()->ProfileChangeObservers(); |
|
187 const TInt count = obs.Count(); |
|
188 for( TInt i( 0 ); i < count; i++ ) |
|
189 { |
|
190 obs[i].iObserver->HandleActiveProfileEventL( EProfileActiveProfileModified , EProfileOffLineId ); |
|
191 } |
|
192 |
|
193 |
|
194 //iBuf should now contain updated TAiDeviceStatusContentProfile structure |
|
195 |
|
196 cache = iCache->GetContent( EAiDeviceStatusContentNetworkIdentity ); |
|
197 |
|
198 if( !cache ) |
|
199 { |
|
200 User::Leave( KErrNoMemory ); |
|
201 } |
|
202 |
|
203 |
|
204 EUNIT_ASSERT( KProfOffline() == *cache->iText ); |
|
205 |
|
206 iCache->Reset(); |
|
207 } |
|
208 |
|
209 // TEST TABLE |
|
210 |
|
211 EUNIT_BEGIN_TEST_TABLE( |
|
212 UT_DevStaPlg, |
|
213 "Device Status Plugin test cases", |
|
214 "MODULE" ) |
|
215 |
|
216 EUNIT_TEST( |
|
217 "Test", |
|
218 "Add tested class name here", |
|
219 "Add tested function name here", |
|
220 "FUNCTIONALITY", |
|
221 SetupL, TestL, Teardown) |
|
222 |
|
223 /* |
|
224 EUNIT_ALLOC_TEST( |
|
225 "(Alloc) Test initializing", |
|
226 "Add tested class name here", |
|
227 "Add tested function name here", |
|
228 "ERRORHANDLING", |
|
229 SetupEmptyL, TestL, Teardown) |
|
230 |
|
231 EUNIT_ALLOC_TEST( |
|
232 "(Alloc) Test plugin property", |
|
233 "Add tested class name here", |
|
234 "Add tested function name here", |
|
235 "ERRORHANDLING", |
|
236 SetupL, TestPropertyL, Teardown) |
|
237 |
|
238 EUNIT_ALLOC_TEST( |
|
239 "(Alloc) Test profile publisher", |
|
240 "Add tested class name here", |
|
241 "Add tested function name here", |
|
242 "ERRORHANDLING", |
|
243 SetupL, TestProfilePublisherL, Teardown) |
|
244 |
|
245 EUNIT_ALLOC_TEST( |
|
246 "(Alloc) Test operator logo publisher", |
|
247 "Add tested class name here", |
|
248 "Add tested function name here", |
|
249 "ERRORHANDLING", |
|
250 SetupL, TestOperatorLogoPublisherL, Teardown) |
|
251 |
|
252 |
|
253 EUNIT_ALLOC_TEST( |
|
254 "(Alloc) Test operator prog name publisher", |
|
255 "Add tested class name here", |
|
256 "Add tested function name here", |
|
257 "ERRORHANDLING", |
|
258 SetupL, TestOperatorProgNamePublisherL, Teardown) |
|
259 |
|
260 EUNIT_ALLOC_TEST( |
|
261 "(Alloc) Test operator netinfo name publisher - long", |
|
262 "Add tested class name here", |
|
263 "Add tested function name here", |
|
264 "ERRORHANDLING", |
|
265 SetupL, TestOperatorNetinfoNamePublisher_LongL, Teardown) |
|
266 |
|
267 EUNIT_ALLOC_TEST( |
|
268 "(Alloc) Test operator netinfo name publisher - short", |
|
269 "Add tested class name here", |
|
270 "Add tested function name here", |
|
271 "ERRORHANDLING", |
|
272 SetupL, TestOperatorNetinfoNamePublisher_ShortL, Teardown) |
|
273 |
|
274 EUNIT_ALLOC_TEST( |
|
275 "(Alloc) Test operator netinfo name publisher - tag", |
|
276 "Add tested class name here", |
|
277 "Add tested function name here", |
|
278 "ERRORHANDLING", |
|
279 SetupL, TestOperatorNetinfoNamePublisher_TagL, Teardown) |
|
280 |
|
281 EUNIT_ALLOC_TEST( |
|
282 "(Alloc) Test operator provider name publisher - in SPDI don't show PLMN", |
|
283 "Add tested class name here", |
|
284 "Add tested function name here", |
|
285 "ERRORHANDLING", |
|
286 SetupL, TestOperatorProviderNamePublisher_InSPDINoPLMNL, Teardown) |
|
287 |
|
288 EUNIT_ALLOC_TEST( |
|
289 "(Alloc) Test operator provider name publisher - in SPDI show PLMN", |
|
290 "Add tested class name here", |
|
291 "Add tested function name here", |
|
292 "ERRORHANDLING", |
|
293 SetupL, TestOperatorProviderNamePublisher_InSPDIPLMNL, Teardown) |
|
294 |
|
295 |
|
296 EUNIT_ALLOC_TEST( |
|
297 "(Alloc) Test BTSAP publisher", |
|
298 "Add tested class name here", |
|
299 "Add tested function name here", |
|
300 "ERRORHANDLING", |
|
301 SetupL, TestBTSAPPublisherL, Teardown) |
|
302 |
|
303 EUNIT_ALLOC_TEST( |
|
304 "(Alloc) Test SimReg publisher", |
|
305 "Add tested class name here", |
|
306 "Add tested function name here", |
|
307 "ERRORHANDLING", |
|
308 SetupL, TestSimRegPublisherL, Teardown) |
|
309 |
|
310 EUNIT_ALLOC_TEST( |
|
311 "(Alloc) Test HCZ publisher", |
|
312 "Add tested class name here", |
|
313 "Add tested function name here", |
|
314 "ERRORHANDLING", |
|
315 SetupL, TestHCZPublisherL, Teardown) |
|
316 |
|
317 EUNIT_ALLOC_TEST( |
|
318 "(Alloc) Test CUG publisher", |
|
319 "Add tested class name here", |
|
320 "Add tested function name here", |
|
321 "ERRORHANDLING", |
|
322 SetupL, TestCUGPublisherL, Teardown) |
|
323 |
|
324 EUNIT_ALLOC_TEST( |
|
325 "(Alloc) Test MCN publisher", |
|
326 "Add tested class name here", |
|
327 "Add tested function name here", |
|
328 "ERRORHANDLING", |
|
329 SetupL, TestMCNPublisherL, Teardown) |
|
330 */ |
|
331 |
|
332 EUNIT_END_TEST_TABLE |
|
333 |
|
334 // END OF FILE |