|
1 /* |
|
2 * Copyright (c) 2002 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: LandmarkUi Content File |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 // [INCLUDE FILES] - do not remove |
|
26 #include <e32svr.h> |
|
27 #include <StifParser.h> |
|
28 #include <Stiftestinterface.h> |
|
29 #include "UTAppLmkAddEdit.h" |
|
30 |
|
31 #include <CLmkEditorDlg.h> |
|
32 #include <Epos_CPosLandmarkDatabase.h> |
|
33 #include <Epos_Landmarks.h> |
|
34 #include <coecntrl.h> |
|
35 #include <lbsposition.h> |
|
36 #include "UTAppLmkEditorEngine.h" |
|
37 |
|
38 // EXTERNAL DATA STRUCTURES |
|
39 //extern ?external_data; |
|
40 |
|
41 // EXTERNAL FUNCTION PROTOTYPES |
|
42 //extern ?external_function( ?arg_type,?arg_type ); |
|
43 |
|
44 // CONSTANTS |
|
45 //const ?type ?constant_var = ?constant; |
|
46 |
|
47 // MACROS |
|
48 //#define ?macro ?macro_def |
|
49 |
|
50 // LOCAL CONSTANTS AND MACROS |
|
51 //const ?type ?constant_var = ?constant; |
|
52 //#define ?macro_name ?macro_def |
|
53 |
|
54 // MODULE DATA STRUCTURES |
|
55 //enum ?declaration |
|
56 //typedef ?declaration |
|
57 |
|
58 // LOCAL FUNCTION PROTOTYPES |
|
59 //?type ?function_name( ?arg_type, ?arg_type ); |
|
60 |
|
61 // FORWARD DECLARATIONS |
|
62 //class ?FORWARD_CLASSNAME; |
|
63 |
|
64 // ============================= LOCAL FUNCTIONS =============================== |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // ?function_name ?description. |
|
68 // ?description |
|
69 // Returns: ?value_1: ?description |
|
70 // ?value_n: ?description_line1 |
|
71 // ?description_line2 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 /* |
|
75 ?type ?function_name( |
|
76 ?arg_type arg, // ?description |
|
77 ?arg_type arg) // ?description |
|
78 { |
|
79 |
|
80 ?code // ?comment |
|
81 |
|
82 // ?comment |
|
83 ?code |
|
84 } |
|
85 */ |
|
86 |
|
87 // ============================ MEMBER FUNCTIONS =============================== |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // CUTAppLmkAddEdit::Delete |
|
91 // Delete here all resources allocated and opened from test methods. |
|
92 // Called from destructor. |
|
93 // ----------------------------------------------------------------------------- |
|
94 // |
|
95 void CUTAppLmkAddEdit::Delete() |
|
96 { |
|
97 |
|
98 } |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // CUTAppLmkAddEdit::RunMethodL |
|
102 // Run specified method. Contains also table of test mothods and their names. |
|
103 // ----------------------------------------------------------------------------- |
|
104 // |
|
105 TInt CUTAppLmkAddEdit::RunMethodL( |
|
106 CStifItemParser& aItem ) |
|
107 { |
|
108 |
|
109 static TStifFunctionInfo const KFunctions[] = |
|
110 { |
|
111 // Copy this line for every implemented function. |
|
112 // First string is the function name used in TestScripter script file. |
|
113 // Second is the actual implementation member function. |
|
114 ENTRY( "Example", CUTAppLmkAddEdit::ExampleL ), |
|
115 ENTRY( "TestNewL", CUTAppLmkAddEdit::TestNewL ), |
|
116 ENTRY( "TestNew2L", CUTAppLmkAddEdit::TestNew2L ), |
|
117 ENTRY( "TestExecuteLD", CUTAppLmkAddEdit::TestExecuteLD ), |
|
118 ENTRY( "TestSetMopParent", CUTAppLmkAddEdit::TestSetMopParentL ), |
|
119 ENTRY( "TestSetHelpContext", CUTAppLmkAddEdit::TestSetHelpContextL ), |
|
120 ENTRY( "TestDisableMapAndNaviOptions", CUTAppLmkAddEdit::TestDisableMapAndNaviOptionsL ), |
|
121 //ADD NEW ENTRY HERE |
|
122 // [test cases entries] - Do not remove |
|
123 |
|
124 }; |
|
125 |
|
126 const TInt count = sizeof( KFunctions ) / |
|
127 sizeof( TStifFunctionInfo ); |
|
128 |
|
129 return RunInternalL( KFunctions, count, aItem ); |
|
130 |
|
131 } |
|
132 |
|
133 // ----------------------------------------------------------------------------- |
|
134 // CUTAppLmkAddEdit::ExampleL |
|
135 // Example test method function. |
|
136 // (other items were commented in a header). |
|
137 // ----------------------------------------------------------------------------- |
|
138 // |
|
139 TInt CUTAppLmkAddEdit::ExampleL( CStifItemParser& aItem ) |
|
140 { |
|
141 |
|
142 // Print to UI |
|
143 _LIT( KUTAppLmkAddEdit, "UTAppLmkAddEdit" ); |
|
144 _LIT( KExample, "In Example" ); |
|
145 TestModuleIf().Printf( 0, KUTAppLmkAddEdit, KExample ); |
|
146 // Print to log file |
|
147 iLog->Log( KExample ); |
|
148 |
|
149 TInt i = 0; |
|
150 TPtrC string; |
|
151 _LIT( KParam, "Param[%i]: %S" ); |
|
152 while ( aItem.GetNextString ( string ) == KErrNone ) |
|
153 { |
|
154 TestModuleIf().Printf( i, KUTAppLmkAddEdit, |
|
155 KParam, i, &string ); |
|
156 i++; |
|
157 } |
|
158 |
|
159 return KErrNone; |
|
160 |
|
161 } |
|
162 |
|
163 // ----------------------------------------------------------------------------- |
|
164 // CUTAppLmkAddEdit::TestNewL |
|
165 // This function tests NewL based on landmark id, which exist in the database |
|
166 // (other items were commented in a header). |
|
167 // ----------------------------------------------------------------------------- |
|
168 // |
|
169 TInt CUTAppLmkAddEdit::TestNewL( CStifItemParser& aItem ) |
|
170 { |
|
171 TInt result = KErrNone; |
|
172 |
|
173 CPosLandmarkDatabase* ilDb = CPosLandmarkDatabase::OpenL(); |
|
174 CPosLmOperation* operation = NULL; |
|
175 |
|
176 if( ilDb->IsInitializingNeeded() ) |
|
177 { |
|
178 operation = ilDb->InitializeL(); |
|
179 operation->ExecuteL(); |
|
180 } |
|
181 |
|
182 CLmkEditorDlg::TLmkEditorParams editParams; |
|
183 editParams.iAttributes = CLmkEditorDlg::ELmkAll; |
|
184 editParams.iEditorMode = CLmkEditorDlg::ELmkEditor; |
|
185 |
|
186 CPosLandmark* LmkEditor = CPosLandmark::NewL(); |
|
187 CleanupStack::PushL( LmkEditor ); |
|
188 TInt aCase = 0; |
|
189 CLmkEditorDlg* editDlg= NULL; |
|
190 aItem.GetNextInt(aCase); |
|
191 |
|
192 switch(aCase) |
|
193 { |
|
194 default: |
|
195 case DEFAULT: |
|
196 TRAPD(error, editDlg = CLmkEditorDlg::NewL(*ilDb,*LmkEditor,editParams)); |
|
197 if(error != KErrNone||!(editDlg)) |
|
198 { |
|
199 result = KErrGeneral; |
|
200 iLog->Log(_L("FAILED: NewL returns %d"), error); |
|
201 } |
|
202 else |
|
203 { |
|
204 iLog->Log(_L("PASSED: NewL returns expected results")); |
|
205 } |
|
206 CleanupStack::PushL( editDlg ); |
|
207 CleanupStack::PopAndDestroy(2); |
|
208 break; |
|
209 |
|
210 case NULL_DB: |
|
211 delete ilDb; |
|
212 ilDb = NULL; |
|
213 TRAPD(error1, editDlg = CLmkEditorDlg::NewL(*ilDb,*LmkEditor,editParams)); |
|
214 if(error1 != KErrNone||!(editDlg)) |
|
215 { |
|
216 result = KErrGeneral; |
|
217 iLog->Log(_L("FAILED: NewL returns %d"), error1); |
|
218 } |
|
219 else |
|
220 { |
|
221 iLog->Log(_L("PASSED: NewL returns expected results")); |
|
222 } |
|
223 CleanupStack::PushL( editDlg ); |
|
224 CleanupStack::PopAndDestroy(2); |
|
225 break; |
|
226 |
|
227 case NON_EXISTING_LM: |
|
228 TRAPD(error2, editDlg = CLmkEditorDlg::NewL(*ilDb,NULL,editParams)); |
|
229 if(error2 != KErrNotFound) |
|
230 { |
|
231 result = KErrGeneral; |
|
232 iLog->Log(_L("FAILED: NewL returns %d"), error2); |
|
233 } |
|
234 else |
|
235 { |
|
236 iLog->Log(_L("PASSED: NewL returns expected results")); |
|
237 } |
|
238 CleanupStack::PopAndDestroy(); |
|
239 break; |
|
240 } |
|
241 |
|
242 //ReleaseLandmarkResources(); |
|
243 |
|
244 if(ilDb) |
|
245 { |
|
246 delete ilDb; |
|
247 ilDb=NULL; |
|
248 } |
|
249 if(operation) |
|
250 { |
|
251 delete operation; |
|
252 operation=NULL; |
|
253 } |
|
254 return result; |
|
255 } |
|
256 // ----------------------------------------------------------------------------- |
|
257 // CUTAppLmkAddEdit::TestNew2L |
|
258 // This function tests NewL based on the landmark object which does not exist |
|
259 // the database |
|
260 // (other items were commented in a header). |
|
261 // ----------------------------------------------------------------------------- |
|
262 // |
|
263 TInt CUTAppLmkAddEdit::TestNew2L( CStifItemParser& /*aItem*/ ) |
|
264 { |
|
265 //Create an empty landmark object |
|
266 CPosLandmark* lmk = CPosLandmark::NewL(); |
|
267 CleanupStack::PushL(lmk); |
|
268 //Specify the various fields for landmark |
|
269 TLocality locality; |
|
270 locality.SetAccuracy(32.2,32.4); |
|
271 locality.SetCoordinate(56,25); |
|
272 locality.SetHorizontalAccuracy(33.1); |
|
273 locality.SetVerticalAccuracy(24.2); |
|
274 lmk->SetLandmarkNameL(_L("Forum Mall")); |
|
275 lmk->SetLandmarkDescriptionL(_L("Shopping Complex")); |
|
276 //Populate the landmark with the specified field information |
|
277 lmk->SetPositionL(locality); |
|
278 //lmk->SetLandmarkIdL( 1 ); |
|
279 |
|
280 CPosLandmarkDatabase* ilDb = CPosLandmarkDatabase::OpenL(); |
|
281 //CleanupStack::PushL(ilDb); |
|
282 ilDb->AddLandmarkL(*lmk); |
|
283 CPosLmOperation* operation = NULL; |
|
284 if ( ilDb->IsInitializingNeeded() ) |
|
285 { |
|
286 operation = ilDb->InitializeL(); |
|
287 operation->ExecuteL(); |
|
288 } |
|
289 |
|
290 CLmkEditorDlg::TLmkEditorParams editParams; |
|
291 editParams.iAttributes = CLmkEditorDlg::ELmkOnlyName; |
|
292 editParams.iEditorMode = CLmkEditorDlg::ELmkViewer; |
|
293 TPosLmItemId lmItem = lmk->LandmarkId(); |
|
294 CLmkEditorDlg* editDlg = CLmkEditorDlg::NewL(*ilDb,lmItem,editParams); |
|
295 CleanupStack::PushL( editDlg ); |
|
296 |
|
297 //ReleaseLandmarkResources(); |
|
298 CleanupStack::PopAndDestroy(2); //ilDb, lmk |
|
299 //delete ilDb; ilDb=NULL; |
|
300 delete operation; operation=NULL; |
|
301 return KErrNone; |
|
302 } |
|
303 |
|
304 // ----------------------------------------------------------------------------- |
|
305 // CUTAppLmkAddEdit::TestExecuteLD |
|
306 // This function tests the launching of the dialog |
|
307 // (other items were commented in a header). |
|
308 // ----------------------------------------------------------------------------- |
|
309 // |
|
310 TInt CUTAppLmkAddEdit::TestExecuteLD( CStifItemParser& aItem ) |
|
311 { |
|
312 TInt result = KErrNone; |
|
313 TPosLmItemId lmItem = 0; |
|
314 TInt aCase = 0; |
|
315 |
|
316 CPosLandmarkDatabase* ilDb = CPosLandmarkDatabase::OpenL(); |
|
317 CPosLmOperation* operation = NULL; |
|
318 |
|
319 if ( ilDb->IsInitializingNeeded() ) |
|
320 { |
|
321 operation = ilDb->InitializeL(); |
|
322 operation->ExecuteL(); |
|
323 } |
|
324 |
|
325 |
|
326 CPosLandmark* landmark = CPosLandmark::NewL(); |
|
327 CleanupStack::PushL( landmark ); |
|
328 |
|
329 CLmkEditorDlg::TLmkEditorParams editParams; |
|
330 aItem.GetNextInt(aCase); |
|
331 switch(aCase) |
|
332 { |
|
333 default: |
|
334 case 0: |
|
335 editParams.iAttributes = CLmkEditorDlg::ELmkAll; |
|
336 editParams.iEditorMode = CLmkEditorDlg::ELmkEditor; |
|
337 break; |
|
338 |
|
339 case 1: |
|
340 editParams.iAttributes = CLmkEditorDlg::ELmkAll; |
|
341 editParams.iEditorMode = CLmkEditorDlg::ELmkViewer; |
|
342 break; |
|
343 } |
|
344 CLmkEditorDlg* editDlg = CLmkEditorDlg::NewL(*ilDb,*landmark,editParams); |
|
345 CleanupStack::PushL( editDlg ); |
|
346 |
|
347 aItem.GetNextInt(aCase); |
|
348 |
|
349 switch(aCase) |
|
350 { |
|
351 default: |
|
352 case EDIT_MODE://Edit mode |
|
353 TRAPD(error, result=editDlg->ExecuteLD()); |
|
354 if(error != 0 ) |
|
355 { |
|
356 iLog->Log(_L("FAILED: ExecuteLD returns %d in Edit mode"), error); |
|
357 result = KErrGeneral; |
|
358 } |
|
359 else |
|
360 { |
|
361 iLog->Log(_L("PASSED: ExecuteLD returns %d in Edit mode"), result); |
|
362 result = KErrNone; |
|
363 } |
|
364 break; |
|
365 |
|
366 case VIEW_MODE: //ViewMode |
|
367 TRAPD(error1, result=editDlg->ExecuteLD()); |
|
368 if(error1 != 0) |
|
369 { |
|
370 iLog->Log(_L("FAILED: ExecuteLD returns %d in View mode"), error1); |
|
371 result = KErrGeneral; |
|
372 } |
|
373 else |
|
374 result = KErrNone; |
|
375 break; |
|
376 |
|
377 case 2: |
|
378 // TestModuleIf().SetExitReason(CTestModuleIf::EPanic ,47); |
|
379 // DrainMemory(); |
|
380 // TRAPD(error2, result=editDlg->ExecuteLD()); |
|
381 // RestoreMemory(); |
|
382 // if(result != 0) |
|
383 // iLog->Log(_L("FAILED: ExecuteLD returns %d in Edit mode under low memory condition"), result); |
|
384 break; |
|
385 } |
|
386 |
|
387 //ReleaseLandmarkResources(); |
|
388 CleanupStack::Pop(2); |
|
389 |
|
390 if(ilDb) |
|
391 { |
|
392 delete ilDb; |
|
393 ilDb=NULL; |
|
394 } |
|
395 if(operation) |
|
396 { |
|
397 delete operation; |
|
398 operation=NULL; |
|
399 } |
|
400 return result; |
|
401 } |
|
402 // ----------------------------------------------------------------------------- |
|
403 // CUTAppLmkAddEdit::TestSetMopParent |
|
404 // This function tests setting up of the context |
|
405 // (other items were commented in a header). |
|
406 // ----------------------------------------------------------------------------- |
|
407 // |
|
408 |
|
409 TInt CUTAppLmkAddEdit::TestSetMopParentL( CStifItemParser& /*aItem*/ ) |
|
410 { |
|
411 CPosLandmarkDatabase* ilDb = CPosLandmarkDatabase::OpenL(); |
|
412 CPosLmOperation* operation = NULL; |
|
413 if ( ilDb->IsInitializingNeeded() ) |
|
414 { |
|
415 operation = ilDb->InitializeL(); |
|
416 operation->ExecuteL(); |
|
417 } |
|
418 |
|
419 CPosLandmark* landmark = CPosLandmark::NewL(); |
|
420 CleanupStack::PushL( landmark ); |
|
421 |
|
422 CLmkEditorDlg::TLmkEditorParams editParams; |
|
423 editParams.iAttributes = CLmkEditorDlg::ELmkAll; |
|
424 editParams.iEditorMode = CLmkEditorDlg::ELmkEditor; |
|
425 |
|
426 engine = new (ELeave) CLmkAddEditEngine; |
|
427 |
|
428 CLmkEditorDlg* editDlg = CLmkEditorDlg::NewL(*ilDb,*landmark,editParams); |
|
429 CleanupStack::PushL( editDlg ); |
|
430 |
|
431 TRAPD(result,editDlg->SetMopParent(engine)); |
|
432 |
|
433 //ReleaseLandmarkResources(); |
|
434 CleanupStack::Pop(2); |
|
435 |
|
436 delete ilDb; ilDb=NULL; |
|
437 delete operation; |
|
438 operation=NULL; |
|
439 |
|
440 return KErrNone; |
|
441 } |
|
442 // ----------------------------------------------------------------------------- |
|
443 // CUTAppLmkAddEdit::TestSetHelpContext |
|
444 // This function tests setting up of the help context |
|
445 // (other items were commented in a header). |
|
446 // ----------------------------------------------------------------------------- |
|
447 // |
|
448 TInt CUTAppLmkAddEdit::TestSetHelpContextL( CStifItemParser& /*aItem*/ ) |
|
449 { |
|
450 CPosLandmarkDatabase* ilDb = CPosLandmarkDatabase::OpenL(); |
|
451 CPosLmOperation* operation = NULL; |
|
452 if ( ilDb->IsInitializingNeeded() ) |
|
453 { |
|
454 operation = ilDb->InitializeL(); |
|
455 operation->ExecuteL(); |
|
456 } |
|
457 |
|
458 CPosLandmark* landmark = CPosLandmark::NewL(); |
|
459 CleanupStack::PushL( landmark ); |
|
460 |
|
461 CLmkEditorDlg::TLmkEditorParams editParams; |
|
462 editParams.iAttributes = CLmkEditorDlg::ELmkAll; |
|
463 editParams.iEditorMode = CLmkEditorDlg::ELmkEditor; |
|
464 |
|
465 TCoeHelpContext aContext; |
|
466 CLmkEditorDlg* editDlg = CLmkEditorDlg::NewL(*ilDb,*landmark,editParams); |
|
467 CleanupStack::PushL( editDlg ); |
|
468 |
|
469 editDlg->SetHelpContext(aContext); |
|
470 |
|
471 //ReleaseLandmarkResources(); |
|
472 CleanupStack::PopAndDestroy(2); |
|
473 |
|
474 delete ilDb; ilDb=NULL; |
|
475 delete operation; operation=NULL; |
|
476 return KErrNone; |
|
477 } |
|
478 // ----------------------------------------------------------------------------- |
|
479 // CUTAppLmkAddEdit::TestDisableMapAndNaviOptions |
|
480 // This function tests disabling the Map and Navigation related Menu Options |
|
481 // (other items were commented in a header). |
|
482 // ----------------------------------------------------------------------------- |
|
483 // |
|
484 TInt CUTAppLmkAddEdit::TestDisableMapAndNaviOptionsL( CStifItemParser& /*aItem*/ ) |
|
485 { |
|
486 // #ifdef __SERIES60_31__ |
|
487 CPosLandmarkDatabase* ilDb = CPosLandmarkDatabase::OpenL(); |
|
488 CPosLmOperation* operation = NULL; |
|
489 if ( ilDb->IsInitializingNeeded() ) |
|
490 { |
|
491 operation = ilDb->InitializeL(); |
|
492 operation->ExecuteL(); |
|
493 } |
|
494 |
|
495 CPosLandmark* landmark = CPosLandmark::NewL(); |
|
496 CleanupStack::PushL( landmark ); |
|
497 |
|
498 CLmkEditorDlg::TLmkEditorParams editParams; |
|
499 editParams.iAttributes = CLmkEditorDlg::ELmkAll; |
|
500 editParams.iEditorMode = CLmkEditorDlg::ELmkEditor; |
|
501 |
|
502 CLmkEditorDlg* editDlg = CLmkEditorDlg::NewL(*ilDb,*landmark,editParams); |
|
503 editDlg->DisableMapAndNavigationMenuOptions(); |
|
504 TRAP_IGNORE(editDlg->ExecuteLD()); |
|
505 CleanupStack::PopAndDestroy(); |
|
506 //ReleaseLandmarkResources(); |
|
507 delete ilDb; |
|
508 delete operation; |
|
509 // #endif |
|
510 return KErrNone; |
|
511 } |
|
512 |
|
513 |
|
514 // ----------------------------------------------------------------------------- |
|
515 // CUTAppLmkAddEdit::?member_function |
|
516 // ?implementation_description |
|
517 // (other items were commented in a header). |
|
518 // ----------------------------------------------------------------------------- |
|
519 // |
|
520 /* |
|
521 TInt CUTAppLmkAddEdit::?member_function( |
|
522 CItemParser& aItem ) |
|
523 { |
|
524 |
|
525 ?code |
|
526 |
|
527 } |
|
528 */ |
|
529 // ----------------------------------------------------------------------------- |
|
530 // CCSatelliteUITest::DrainMemory |
|
531 // Eats the memory |
|
532 // ----------------------------------------------------------------------------- |
|
533 // |
|
534 void CUTAppLmkAddEdit::DrainMemory() |
|
535 { |
|
536 for( TInt i = 0; i < MAX_EXPONENT1; i++ ) |
|
537 { |
|
538 cells[i] = NULL; |
|
539 } |
|
540 // consume all available heap memory |
|
541 TInt j=0; |
|
542 for (TInt i = KMaxTInt/2-1; i > 0; ) |
|
543 { |
|
544 cells[j] = User::Alloc(i); |
|
545 if( !( cells[j] ) ) |
|
546 { |
|
547 i/=2; |
|
548 } |
|
549 else |
|
550 { |
|
551 j++; |
|
552 } |
|
553 } |
|
554 } |
|
555 // ----------------------------------------------------------------------------- |
|
556 // CCSatelliteUITest::RestoreMemory |
|
557 // Restores the memory |
|
558 // ----------------------------------------------------------------------------- |
|
559 // |
|
560 void CUTAppLmkAddEdit::RestoreMemory() |
|
561 { |
|
562 for ( TInt cellIndex = 0; cellIndex < MAX_EXPONENT1; cellIndex++ ) |
|
563 { |
|
564 if ( cells[cellIndex] ) |
|
565 { |
|
566 User::Free( cells[cellIndex] ); |
|
567 } |
|
568 } |
|
569 } |
|
570 // ----------------------------------------------------------------------------- |
|
571 |
|
572 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
573 // None |
|
574 |
|
575 // [End of File] - Do not remove |