|
1 /* |
|
2 * Copyright (c) 2009 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: This file contains testclass implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 // [INCLUDE FILES] - do not remove |
|
19 #include <e32svr.h> |
|
20 #include <StifParser.h> |
|
21 #include <StifTestInterface.h> |
|
22 #include "dmdevicedialogstest.h" |
|
23 #include <dmdevdialogclient.h> |
|
24 #include <nsmlprivateapi.h> |
|
25 #include <centralrepository.h> |
|
26 #include <devmaninternalcrkeys.h> |
|
27 // EXTERNAL DATA STRUCTURES |
|
28 //extern ?external_data; |
|
29 |
|
30 // EXTERNAL FUNCTION PROTOTYPES |
|
31 //extern ?external_function( ?arg_type,?arg_type ); |
|
32 |
|
33 // CONSTANTS |
|
34 //const ?type ?constant_var = ?constant; |
|
35 |
|
36 // MACROS |
|
37 //#define ?macro ?macro_def |
|
38 |
|
39 // LOCAL CONSTANTS AND MACROS |
|
40 //const ?type ?constant_var = ?constant; |
|
41 //#define ?macro_name ?macro_def |
|
42 |
|
43 // MODULE DATA STRUCTURES |
|
44 //enum ?declaration |
|
45 //typedef ?declaration |
|
46 |
|
47 // LOCAL FUNCTION PROTOTYPES |
|
48 //?type ?function_name( ?arg_type, ?arg_type ); |
|
49 |
|
50 // FORWARD DECLARATIONS |
|
51 //class ?FORWARD_CLASSNAME; |
|
52 |
|
53 // ============================= LOCAL FUNCTIONS =============================== |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // ?function_name ?description. |
|
57 // ?description |
|
58 // Returns: ?value_1: ?description |
|
59 // ?value_n: ?description_line1 |
|
60 // ?description_line2 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 /* |
|
64 ?type ?function_name( |
|
65 ?arg_type arg, // ?description |
|
66 ?arg_type arg) // ?description |
|
67 { |
|
68 |
|
69 ?code // ?comment |
|
70 |
|
71 // ?comment |
|
72 ?code |
|
73 } |
|
74 */ |
|
75 |
|
76 // ============================ MEMBER FUNCTIONS =============================== |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // Cdmdevicedialogstest::Delete |
|
80 // Delete here all resources allocated and opened from test methods. |
|
81 // Called from destructor. |
|
82 // ----------------------------------------------------------------------------- |
|
83 // |
|
84 void Cdmdevicedialogstest::Delete() |
|
85 { |
|
86 |
|
87 } |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // Cdmdevicedialogstest::RunMethodL |
|
91 // Run specified method. Contains also table of test mothods and their names. |
|
92 // ----------------------------------------------------------------------------- |
|
93 // |
|
94 TInt Cdmdevicedialogstest::RunMethodL( |
|
95 CStifItemParser& aItem ) |
|
96 { |
|
97 |
|
98 static TStifFunctionInfo const KFunctions[] = |
|
99 { |
|
100 // Copy this line for every implemented function. |
|
101 // First string is the function name used in TestScripter script file. |
|
102 // Second is the actual implementation member function. |
|
103 ENTRY( "Example", Cdmdevicedialogstest::ExampleL ), |
|
104 ENTRY( "ShowOnlyPkgZeroNoteL", Cdmdevicedialogstest::ShowOnlyPkgZeroNoteL ), |
|
105 ENTRY("ShowPkgZeroandConnectNoteL",Cdmdevicedialogstest::ShowPkgZeroandConnectNoteL), |
|
106 ENTRY("DismissConnectNoteL",Cdmdevicedialogstest::DismissConnectNoteL), |
|
107 ENTRY("ShowConnectNoteAgainL",Cdmdevicedialogstest::ShowConnectNoteAgainL), |
|
108 ENTRY("ShowDisplayAlertL",Cdmdevicedialogstest::ShowDisplayAlertL), |
|
109 ENTRY("ShowConfirmationAlertL",Cdmdevicedialogstest::ShowConfirmationAlertL), |
|
110 ENTRY("CancelPkgZeroNoteL",Cdmdevicedialogstest::CancelPkgZeroNoteL), |
|
111 ENTRY("SilentPkgZeroL",Cdmdevicedialogstest::SilentPkgZeroL), |
|
112 ENTRY("DefaultProfilePkgZeroL",Cdmdevicedialogstest::DefaultProfilePkgZeroL), |
|
113 |
|
114 //ADD NEW ENTRY HERE |
|
115 // [test cases entries] - Do not remove |
|
116 |
|
117 }; |
|
118 |
|
119 const TInt count = sizeof( KFunctions ) / |
|
120 sizeof( TStifFunctionInfo ); |
|
121 |
|
122 return RunInternalL( KFunctions, count, aItem ); |
|
123 |
|
124 } |
|
125 |
|
126 // ----------------------------------------------------------------------------- |
|
127 // Cdmdevicedialogstest::ExampleL |
|
128 // Example test method function. |
|
129 // (other items were commented in a header). |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 TInt Cdmdevicedialogstest::ExampleL( CStifItemParser& aItem ) |
|
133 { |
|
134 |
|
135 // Print to UI |
|
136 /* _LIT( Kdmdevicedialogstest, "dmdevicedialogstest" ); |
|
137 _LIT( KExample, "In Example" ); |
|
138 TestModuleIf().Printf( 0, Kdmdevicedialogstest, KExample ); |
|
139 // Print to log file |
|
140 iLog->Log( KExample ); |
|
141 |
|
142 TInt i = 0; |
|
143 TPtrC string; |
|
144 _LIT( KParam, "Param[%i]: %S" ); |
|
145 while ( aItem.GetNextString ( string ) == KErrNone ) |
|
146 { |
|
147 TestModuleIf().Printf( i, Kdmdevicedialogstest, |
|
148 KParam, i, &string ); |
|
149 i++; |
|
150 }*/ |
|
151 |
|
152 RDmDevDialog DmDevdialog; |
|
153 TInt err = DmDevdialog.OpenL(); |
|
154 if(err) |
|
155 return err; |
|
156 DmDevdialog.Close(); |
|
157 return KErrNone; |
|
158 |
|
159 } |
|
160 |
|
161 TInt Cdmdevicedialogstest::ShowOnlyPkgZeroNoteL( CStifItemParser& aItem ) |
|
162 { |
|
163 RDebug::Print(_L("Cdmdevicedialogstest::ShowOnlyPkgZeroNoteL")); |
|
164 RDmDevDialog DmDevdialog; |
|
165 |
|
166 TInt err = DmDevdialog.OpenL(); |
|
167 RDebug::Print(_L("Cdmdevicedialogstest::ShowOnlyPkgZeroNoteL after openL")); |
|
168 if (err) |
|
169 return err; |
|
170 TRequestStatus status = KRequestPending; |
|
171 TInt ProfileId = 1000001; |
|
172 TInt Jobid = 0; |
|
173 TInt uimode = 0; |
|
174 //TBuf<100> name(_L("Server name 123")); |
|
175 TPckgBuf<TInt> iResBuf; |
|
176 DmDevdialog.LaunchPkgZero(ProfileId, Jobid, uimode, iResBuf, status); |
|
177 User::After(1000000 * 6); |
|
178 //User::WaitForRequest(status); //working |
|
179 err = DmDevdialog.CancelPkgZeroNote(); |
|
180 //Different tests to be performed |
|
181 //Close immediately |
|
182 DmDevdialog.Close(); //See what happens to server whether it is closed or not |
|
183 //Close later |
|
184 /*if (status.Int() == KErrNone || status.Int() == KErrCancel) |
|
185 return KErrNone; |
|
186 else |
|
187 return KErrNotFound;*/ |
|
188 return err; |
|
189 } |
|
190 TInt Cdmdevicedialogstest::SilentPkgZeroL( CStifItemParser& aItem ) |
|
191 { |
|
192 RDebug::Print(_L("Cdmdevicedialogstest::SilentPkgZeroL")); |
|
193 RDmDevDialog DmDevdialog; |
|
194 |
|
195 TInt err = DmDevdialog.OpenL(); |
|
196 RDebug::Print(_L("Cdmdevicedialogstest::SilentPkgZeroL after openL")); |
|
197 if (err) |
|
198 return err; |
|
199 TRequestStatus status = KRequestPending; |
|
200 TInt ProfileId = 1000001; |
|
201 TInt Jobid = 0; |
|
202 TInt uimode = 1; |
|
203 TBuf<100> name(_L("Silent server")); |
|
204 TPckgBuf<TInt> iResBuf; |
|
205 DmDevdialog.LaunchPkgZero(ProfileId, Jobid, uimode, iResBuf, status); |
|
206 // User::After(1000000 * 6); |
|
207 User::WaitForRequest(status); //working |
|
208 //err = DmDevdialog.CancelPkgZeroNote(); |
|
209 //Different tests to be performed |
|
210 //Close immediately |
|
211 DmDevdialog.Close(); //See what happens to server whether it is closed or not |
|
212 //Close later |
|
213 if (status.Int() == KErrNone || status.Int() == KErrCancel) |
|
214 return KErrNone; |
|
215 else |
|
216 return KErrNotFound; |
|
217 return err; |
|
218 } |
|
219 |
|
220 TInt Cdmdevicedialogstest::DefaultProfilePkgZeroL( CStifItemParser& aItem ) |
|
221 { |
|
222 RDebug::Print(_L("Cdmdevicedialogstest::DefaultProfilePkgZeroL")); |
|
223 // Device manager key UID |
|
224 const TUid KCRUidNSmlDMSyncApp = {0x101f6de5}; |
|
225 // CenRep keys for default dm profile used in the |
|
226 // firmware update over the air. |
|
227 const TUint32 KNSmlDMDefaultFotaProfileKey = 0x00000002; |
|
228 TInt ProfileId = 1000001; |
|
229 CRepository* centrep = NULL; |
|
230 TRAPD( err, centrep = CRepository::NewL( KCRUidNSmlDMSyncApp ) ); |
|
231 RDebug::Print(_L("Cdmdevicedialogstest::DefaultProfilePkgZeroL cenrep created")); |
|
232 User::LeaveIfError( err ); |
|
233 RDebug::Print(_L("Cdmdevicedialogstest::DefaultProfilePkgZeroL cenrep fine")); |
|
234 centrep->Set( KNSmlDMDefaultFotaProfileKey, ProfileId ); |
|
235 RDebug::Print(_L("Cdmdevicedialogstest::DefaultProfilePkgZeroL cenrep set fine")); |
|
236 delete centrep; |
|
237 |
|
238 RDmDevDialog DmDevdialog; |
|
239 |
|
240 err = DmDevdialog.OpenL(); |
|
241 RDebug::Print(_L("Cdmdevicedialogstest::DefaultProfilePkgZeroL after openL")); |
|
242 if (err) |
|
243 return err; |
|
244 TRequestStatus status = KRequestPending; |
|
245 |
|
246 TInt Jobid = 0; |
|
247 TInt uimode = 0; |
|
248 TBuf<100> name(_L("non silent def")); |
|
249 TPckgBuf<TInt> iResBuf; |
|
250 DmDevdialog.LaunchPkgZero(ProfileId, Jobid, uimode, iResBuf, status); |
|
251 // User::After(1000000 * 6); |
|
252 User::WaitForRequest(status); //working |
|
253 //err = DmDevdialog.CancelPkgZeroNote(); |
|
254 //Different tests to be performed |
|
255 //Close immediately |
|
256 DmDevdialog.Close(); //See what happens to server whether it is closed or not |
|
257 //Close later |
|
258 if (status.Int() == KErrNone || status.Int() == KErrCancel) |
|
259 return KErrNone; |
|
260 else |
|
261 return KErrNotFound; |
|
262 return err; |
|
263 } |
|
264 |
|
265 TInt Cdmdevicedialogstest::ShowPkgZeroandConnectNoteL( CStifItemParser& aItem ) |
|
266 { |
|
267 RNSmlPrivateAPI privateApi; |
|
268 TPtrC8 messageBody(_L8("test")); |
|
269 |
|
270 TRAPD(openErr, privateApi.OpenL()); |
|
271 |
|
272 if ( openErr != KErrNone ) |
|
273 { |
|
274 return openErr; |
|
275 } |
|
276 |
|
277 TRAPD(err,privateApi.SendL( messageBody, ESmlDevMan, ESmlVersion1_2 )); |
|
278 privateApi.Close(); |
|
279 return err; |
|
280 } |
|
281 |
|
282 TInt Cdmdevicedialogstest::ShowConnectNoteAgainL( CStifItemParser& aItem ) |
|
283 { |
|
284 |
|
285 RDebug::Print(_L("Cdmdevicedialogstest::ShowConnectNoteAgainL")); |
|
286 RDmDevDialog DmDevdialog; |
|
287 |
|
288 TInt err = DmDevdialog.OpenL(); |
|
289 RDebug::Print(_L("Cdmdevicedialogstest::ShowConnectNoteAgainL after openL")); |
|
290 if (err) |
|
291 return err; |
|
292 TInt Status(KErrNotFound); |
|
293 err = DmDevdialog.ShowConnectDialog(); |
|
294 |
|
295 DmDevdialog.Close(); |
|
296 return err; |
|
297 } |
|
298 |
|
299 TInt Cdmdevicedialogstest::CancelPkgZeroNoteL( CStifItemParser& aItem ) |
|
300 { |
|
301 |
|
302 RDebug::Print(_L("Cdmdevicedialogstest::CancelPkgZeroNoteL")); |
|
303 RDmDevDialog DmDevdialog; |
|
304 |
|
305 TInt err = DmDevdialog.OpenL(); |
|
306 RDebug::Print(_L("Cdmdevicedialogstest::CancelPkgZeroNoteL after openL")); |
|
307 if (err) |
|
308 return err; |
|
309 TInt Status(KErrNotFound); |
|
310 err = DmDevdialog.CancelPkgZeroNote(); |
|
311 |
|
312 DmDevdialog.Close(); |
|
313 return err; |
|
314 } |
|
315 TInt Cdmdevicedialogstest::DismissConnectNoteL( CStifItemParser& aItem ) |
|
316 { |
|
317 RDebug::Print(_L("Cdmdevicedialogstest::DismissConnectNoteL")); |
|
318 RDmDevDialog DmDevdialog; |
|
319 |
|
320 TInt err = DmDevdialog.OpenL(); |
|
321 RDebug::Print(_L("Cdmdevicedialogstest::ShowOnlyPkgZeroNoteL after openL")); |
|
322 if (err) |
|
323 return err; |
|
324 TInt Status(KErrNotFound); |
|
325 err = DmDevdialog.IsPkgZeroConnectNoteShown(Status); |
|
326 if (err) |
|
327 { |
|
328 DmDevdialog.Close(); |
|
329 return err; |
|
330 } |
|
331 if(Status == 1) |
|
332 { |
|
333 err = DmDevdialog.DismissConnectDialog(); |
|
334 /* if (err) |
|
335 { |
|
336 DmDevdialog.Close(); |
|
337 return err; |
|
338 }*/ |
|
339 } |
|
340 else |
|
341 return KErrNone; |
|
342 //Different tests to be performed |
|
343 //Close immediately |
|
344 DmDevdialog.Close(); //See what happens to server whether it is closed or not |
|
345 return err; |
|
346 //Close later |
|
347 |
|
348 } |
|
349 TInt Cdmdevicedialogstest::IsConnectNoteShownL( CStifItemParser& aItem ) |
|
350 { |
|
351 return KErrNone; |
|
352 } |
|
353 TInt Cdmdevicedialogstest::ShowDisplayAlertL( CStifItemParser& aItem ) |
|
354 { |
|
355 RDmDevDialog DmDevdialog; |
|
356 TInt err = DmDevdialog.OpenL(); |
|
357 if(err) |
|
358 return err; |
|
359 |
|
360 TRequestStatus status = KRequestPending; |
|
361 TBuf<100> ServerMsg(_L("Information alert....")); |
|
362 DmDevdialog.ShowDisplayAlert(ServerMsg,status); |
|
363 |
|
364 |
|
365 User::WaitForRequest(status); |
|
366 |
|
367 DmDevdialog.Close(); |
|
368 return KErrNone; |
|
369 } |
|
370 TInt Cdmdevicedialogstest::ShowConfirmationAlertL( CStifItemParser& aItem ) |
|
371 { |
|
372 RDmDevDialog DmDevdialog; |
|
373 TInt err = DmDevdialog.OpenL(); |
|
374 if(err) |
|
375 return err; |
|
376 |
|
377 TRequestStatus status = KRequestPending; |
|
378 TBuf<100> ServerMsg(_L("Confirmation alert....")); |
|
379 |
|
380 TInt timeout = 30; // dummy |
|
381 TBuf<30> header; // dummy |
|
382 DmDevdialog.ShowConfirmationAlert(timeout,header,ServerMsg,status); |
|
383 |
|
384 |
|
385 User::WaitForRequest(status); |
|
386 |
|
387 DmDevdialog.Close(); |
|
388 return KErrNone; |
|
389 } |
|
390 |
|
391 |
|
392 |
|
393 // ----------------------------------------------------------------------------- |
|
394 // Cdmdevicedialogstest::?member_function |
|
395 // ?implementation_description |
|
396 // (other items were commented in a header). |
|
397 // ----------------------------------------------------------------------------- |
|
398 // |
|
399 /* |
|
400 TInt Cdmdevicedialogstest::?member_function( |
|
401 CItemParser& aItem ) |
|
402 { |
|
403 |
|
404 ?code |
|
405 |
|
406 } |
|
407 */ |
|
408 |
|
409 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
410 // None |
|
411 |
|
412 // [End of File] - Do not remove |