|
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 <e32cmn.h> |
|
20 #include <e32svr.h> |
|
21 #include <coeaui.h> |
|
22 |
|
23 #include <bitstd.h> // CFbsBitGc |
|
24 #include <fbs.h> // CFbsBitmap |
|
25 #include <bitdev.h> // CFbsBitmapDevice |
|
26 |
|
27 #include <StifParser.h> |
|
28 #include <Stiftestinterface.h> |
|
29 |
|
30 #include <activepalette2ui.h> |
|
31 #include <activepalette2factory.h> |
|
32 #include <activepalette2genericpluginint.h> |
|
33 #include <activepalette2eventdata.h> |
|
34 #include <activepalette2itemvisible.h> |
|
35 #include <activepalette2navigationkeys.h> |
|
36 |
|
37 #include <ActivePalette2ApiTest.mbg> |
|
38 |
|
39 #include "ActivePalette2ApiTest.h" |
|
40 #include "ActivePaletteContainer.h" |
|
41 |
|
42 |
|
43 |
|
44 // EXTERNAL DATA STRUCTURES |
|
45 //extern ?external_data; |
|
46 |
|
47 // EXTERNAL FUNCTION PROTOTYPES |
|
48 //extern ?external_function( ?arg_type,?arg_type ); |
|
49 |
|
50 // CONSTANTS |
|
51 //const ?type ?constant_var = ?constant; |
|
52 |
|
53 // MACROS |
|
54 //#define ?macro ?macro_def |
|
55 #define LOG(text) iLog->Log(_L(text)) |
|
56 #define LOG1(text, param) iLog->Log(_L(text), param) |
|
57 #define LOG2(text, param1, param2) iLog->Log(_L(text), param1, param2) |
|
58 #define LOG3(text, param1, param2, param3) iLog->Log(_L(text), param1, param2, param3) |
|
59 |
|
60 // LOCAL CONSTANTS AND MACROS |
|
61 //const ?type ?constant_var = ?constant; |
|
62 //#define ?macro_name ?macro_def |
|
63 |
|
64 namespace { |
|
65 static const TInt KNaviPrevious = EKeyUpArrow; |
|
66 static const TInt KNaviNext = EKeyDownArrow; |
|
67 static const TInt KNaviSelect = EKeyEnter; |
|
68 |
|
69 _LIT( KTrueString, "true" ); |
|
70 _LIT( KFalseString, "false" ); |
|
71 |
|
72 _LIT( KIconFileName, "\\resource\\apps\\ActivePalette2ApiTest.mif" ); |
|
73 |
|
74 static const TInt KIconIds[] = { |
|
75 EMbmActivepalette2apitestZeroth, |
|
76 EMbmActivepalette2apitestFirst, |
|
77 EMbmActivepalette2apitestSecond, |
|
78 EMbmActivepalette2apitestThird, |
|
79 EMbmActivepalette2apitestFourth, |
|
80 EMbmActivepalette2apitestFifth, |
|
81 EMbmActivepalette2apitestSixth, |
|
82 EMbmActivepalette2apitestSeventh, |
|
83 EMbmActivepalette2apitestEighth, |
|
84 EMbmActivepalette2apitestNinth |
|
85 }; |
|
86 |
|
87 static const TInt KMaskIds[] = { |
|
88 EMbmActivepalette2apitestZeroth_mask, |
|
89 EMbmActivepalette2apitestFirst_mask, |
|
90 EMbmActivepalette2apitestSecond_mask, |
|
91 EMbmActivepalette2apitestThird_mask, |
|
92 EMbmActivepalette2apitestFourth_mask, |
|
93 EMbmActivepalette2apitestFifth_mask, |
|
94 EMbmActivepalette2apitestSixth_mask, |
|
95 EMbmActivepalette2apitestSeventh_mask, |
|
96 EMbmActivepalette2apitestEighth_mask, |
|
97 EMbmActivepalette2apitestNinth_mask |
|
98 }; |
|
99 |
|
100 static const TInt KIconCount = sizeof(KIconIds)/sizeof(TInt); |
|
101 } |
|
102 |
|
103 // MODULE DATA STRUCTURES |
|
104 //enum ?declaration |
|
105 //typedef ?declaration |
|
106 |
|
107 // LOCAL FUNCTION PROTOTYPES |
|
108 //?type ?function_name( ?arg_type, ?arg_type ); |
|
109 |
|
110 // FORWARD DECLARATIONS |
|
111 //class ?FORWARD_CLASSNAME; |
|
112 |
|
113 // ============================= LOCAL FUNCTIONS =============================== |
|
114 |
|
115 // ----------------------------------------------------------------------------- |
|
116 // ?function_name ?description. |
|
117 // ?description |
|
118 // Returns: ?value_1: ?description |
|
119 // ?value_n: ?description_line1 |
|
120 // ?description_line2 |
|
121 // ----------------------------------------------------------------------------- |
|
122 // |
|
123 /* |
|
124 ?type ?function_name( |
|
125 ?arg_type arg, // ?description |
|
126 ?arg_type arg) // ?description |
|
127 { |
|
128 |
|
129 ?code // ?comment |
|
130 |
|
131 // ?comment |
|
132 ?code |
|
133 } |
|
134 */ |
|
135 |
|
136 // ============================ MEMBER FUNCTIONS =============================== |
|
137 |
|
138 // ----------------------------------------------------------------------------- |
|
139 // CActivePalette2ApiTest::Delete |
|
140 // Delete here all resources allocated and opened from test methods. |
|
141 // Called from destructor. |
|
142 // ----------------------------------------------------------------------------- |
|
143 // |
|
144 void CActivePalette2ApiTest::Delete() |
|
145 { |
|
146 // Make sure this is released, although DisposeUi is supposed to be |
|
147 // called within the test case. |
|
148 delete iContainer; |
|
149 iContainer = NULL; |
|
150 } |
|
151 |
|
152 // ----------------------------------------------------------------------------- |
|
153 // CActivePalette2ApiTest::RunMethodL |
|
154 // Run specified method. Contains also table of test mothods and their names. |
|
155 // ----------------------------------------------------------------------------- |
|
156 // |
|
157 TInt CActivePalette2ApiTest::RunMethodL( |
|
158 CStifItemParser& aItem ) |
|
159 { |
|
160 |
|
161 static TStifFunctionInfo const KFunctions[] = |
|
162 { |
|
163 // Copy this line for every implemented function. |
|
164 // First string is the function name used in TestScripter script file. |
|
165 // Second is the actual implementation member function. |
|
166 ENTRY( "CreateUi", CActivePalette2ApiTest::CreateUiL ), |
|
167 ENTRY( "DisposeUi", CActivePalette2ApiTest::DisposeUiL ), |
|
168 ENTRY( "SetNavigationKeys", CActivePalette2ApiTest::SetNavigationKeysL ), |
|
169 ENTRY( "ListPlugins", CActivePalette2ApiTest::ListPluginsL ), |
|
170 ENTRY( "SetPaletteVisibility", CActivePalette2ApiTest::SetPaletteVisibilityL ), |
|
171 ENTRY( "MovePalette", CActivePalette2ApiTest::MovePaletteL ), |
|
172 ENTRY( "AddItems", CActivePalette2ApiTest::AddItemsL ), |
|
173 ENTRY( "RemoveItems", CActivePalette2ApiTest::RemoveItemsL ), |
|
174 ENTRY( "ShowItems", CActivePalette2ApiTest::ShowItemsL ), |
|
175 ENTRY( "HideItems", CActivePalette2ApiTest::HideItemsL ), |
|
176 ENTRY( "SetCurrentItem", CActivePalette2ApiTest::SetCurrentItemL ), |
|
177 ENTRY( "CheckCurrentItem", CActivePalette2ApiTest::CheckCurrentItemL ), |
|
178 ENTRY( "CheckItemList", CActivePalette2ApiTest::CheckItemListL ), |
|
179 ENTRY( "CheckItemVisibilities", CActivePalette2ApiTest::CheckItemVisibilitiesL ), |
|
180 |
|
181 ENTRY( "TestOffscreenDrawing", CActivePalette2ApiTest::TestOffscreenDrawingL ), |
|
182 |
|
183 ENTRY( "TestKeyPrevious", CActivePalette2ApiTest::TestKeyPreviousL ), |
|
184 ENTRY( "TestKeyNext", CActivePalette2ApiTest::TestKeyNextL ), |
|
185 ENTRY( "TestKeySelect", CActivePalette2ApiTest::TestKeySelectL ), |
|
186 |
|
187 //ADD NEW ENTRY HERE |
|
188 // [test cases entries] - Do not remove |
|
189 |
|
190 }; |
|
191 |
|
192 const TInt count = sizeof( KFunctions ) / |
|
193 sizeof( TStifFunctionInfo ); |
|
194 |
|
195 return RunInternalL( KFunctions, count, aItem ); |
|
196 |
|
197 } |
|
198 |
|
199 // ----------------------------------------------------------------------------- |
|
200 // CActivePalette2ApiTest::Log |
|
201 // Get logger instance. |
|
202 // ----------------------------------------------------------------------------- |
|
203 // |
|
204 CStifLogger* |
|
205 CActivePalette2ApiTest::Log() const |
|
206 { |
|
207 return iLog; |
|
208 } |
|
209 |
|
210 // ----------------------------------------------------------------------------- |
|
211 // CActivePalette2ApiTest::CreateUiL |
|
212 // Create Container instance, add it to the view stack and ask Container |
|
213 // to create the Active Palette instance. |
|
214 // (other items were commented in a header). |
|
215 // ----------------------------------------------------------------------------- |
|
216 // |
|
217 TInt |
|
218 CActivePalette2ApiTest::CreateUiL( CStifItemParser& /*aItem*/ ) |
|
219 { |
|
220 LOG("=> CActivePalette2ApiTest::CreateUiL"); |
|
221 delete iContainer; |
|
222 iContainer = NULL; |
|
223 iContainer = new (ELeave) CActivePaletteContainer(); |
|
224 LOG("<> CActivePalette2ApiTest::CreateUiL 1"); |
|
225 iContainer->ConstructL(this); |
|
226 LOG("<> CActivePalette2ApiTest::CreateUiL 2"); |
|
227 CCoeEnv::Static()->AppUi()->RegisterViewL(*iContainer); |
|
228 LOG("<> CActivePalette2ApiTest::CreateUiL 3"); |
|
229 CCoeEnv::Static()->AppUi()->AddToViewStackL(*iContainer, iContainer); |
|
230 LOG("<> CActivePalette2ApiTest::CreateUiL 4"); |
|
231 CCoeEnv::Static()->AppUi()->ActivateViewL(iContainer->ViewId()); |
|
232 LOG("<= CActivePalette2ApiTest::CreateUiL, status"); |
|
233 return KErrNone; |
|
234 } |
|
235 |
|
236 |
|
237 // ----------------------------------------------------------------------------- |
|
238 // CActivePalette2ApiTest::DisposeUiL |
|
239 // Ask Container to dispose the Active Palette and remove the container from |
|
240 // view stack. |
|
241 // (other items were commented in a header). |
|
242 // ----------------------------------------------------------------------------- |
|
243 // |
|
244 TInt |
|
245 CActivePalette2ApiTest::DisposeUiL( CStifItemParser& /*aItem*/ ) |
|
246 { |
|
247 LOG("=> CActivePalette2ApiTest::DisposeUiL"); |
|
248 if( iContainer != NULL ) |
|
249 { |
|
250 CCoeEnv::Static()->AppUi()->DeregisterView(*iContainer); |
|
251 CCoeEnv::Static()->AppUi()->RemoveFromViewStack(*iContainer, iContainer); |
|
252 delete iContainer; |
|
253 iContainer = NULL; |
|
254 } |
|
255 LOG("<= CActivePalette2ApiTest::DisposeUiL"); |
|
256 return KErrNone; |
|
257 } |
|
258 |
|
259 // ----------------------------------------------------------------------------- |
|
260 // CActivePalette2ApiTest::SetNavigationKeysL |
|
261 // Set the Active Palette navigation keys. |
|
262 // (other items were commented in a header). |
|
263 // ----------------------------------------------------------------------------- |
|
264 // |
|
265 TInt |
|
266 CActivePalette2ApiTest::SetNavigationKeysL( CStifItemParser& /*aItem*/ ) |
|
267 { |
|
268 LOG3("=> CActivePalette2ApiTest::SetNavigationKeysL - prev[%d] next[%d] select[%d]", |
|
269 KNaviPrevious, KNaviNext, KNaviSelect); |
|
270 |
|
271 // Cover also the TActivePalette2NavigationKeys default constructor. |
|
272 TActivePalette2NavigationKeys keys; |
|
273 keys = TActivePalette2NavigationKeys(KNaviPrevious,KNaviNext,KNaviSelect); |
|
274 |
|
275 // Set navigation keys. |
|
276 iContainer->ActivePalette()->SetNavigationKeys( keys ); |
|
277 |
|
278 LOG("<= CActivePalette2ApiTest::SetNavigationKeysL"); |
|
279 return KErrNone; |
|
280 } |
|
281 |
|
282 // ----------------------------------------------------------------------------- |
|
283 // CActivePalette2ApiTest::ListPluginsL |
|
284 // Ask the available plugins from Active Palette. |
|
285 // (other items were commented in a header). |
|
286 // ----------------------------------------------------------------------------- |
|
287 // |
|
288 TInt |
|
289 CActivePalette2ApiTest::ListPluginsL( CStifItemParser& /*aItem*/ ) |
|
290 { |
|
291 LOG("=> CActivePalette2ApiTest::ListPluginsL"); |
|
292 RArray<TUid> list; |
|
293 CleanupClosePushL(list); |
|
294 |
|
295 User::LeaveIfError( iContainer->ActivePalette()->GetAvailablePlugins(list) ); |
|
296 for( TInt i = 0; i < list.Count(); i++ ) |
|
297 { |
|
298 LOG1("<> CActivePalette2ApiTest::ListPluginsL - available plugin uid[0x%08X]", list[i].iUid ); |
|
299 } |
|
300 CleanupStack::PopAndDestroy(&list); |
|
301 LOG("<= CActivePalette2ApiTest::ListPluginsL"); |
|
302 return KErrNone; |
|
303 } |
|
304 |
|
305 // ----------------------------------------------------------------------------- |
|
306 // CActivePalette2ApiTest::SetPaletteVisibilityL |
|
307 // Show or hide the whole Active Palette. |
|
308 // (other items were commented in a header). |
|
309 // ----------------------------------------------------------------------------- |
|
310 // |
|
311 TInt |
|
312 CActivePalette2ApiTest::SetPaletteVisibilityL( CStifItemParser& aItem ) |
|
313 { |
|
314 // Define test case as |
|
315 // "instance teststepname <visible> <delay> <animate> <duration>" |
|
316 // where |
|
317 // <visible> = "true" or "false" for whether to show or hide palette. |
|
318 // <delay> = integer, defining the delay for showing or hiding in [ms] |
|
319 // <animate> = "true" or "false" for whether to use animation effect |
|
320 // <duration> = integer, defining the animation (if any) duration in [ms] |
|
321 LOG("=> CActivePalette2ApiTest::SetPaletteVisibilityL"); |
|
322 |
|
323 MActivePalette2UI* ap = iContainer->ActivePalette(); |
|
324 |
|
325 TBool visible( false ); |
|
326 TBool animate( false ); |
|
327 TInt delay( 0 ); |
|
328 TInt duration( 0 ); |
|
329 TInt test( 0 ); |
|
330 |
|
331 LOG("<> CActivePalette2ApiTest::SetPaletteVisibilityL - read visibility parameter.."); |
|
332 User::LeaveIfError( GetNextBooleanFromString(aItem, visible) ); |
|
333 LOG("<> CActivePalette2ApiTest::SetPaletteVisibilityL - read delay parameter.."); |
|
334 User::LeaveIfError( aItem.GetNextInt(delay) ); |
|
335 LOG("<> CActivePalette2ApiTest::SetPaletteVisibilityL - read animation parameter.."); |
|
336 User::LeaveIfError( GetNextBooleanFromString(aItem, animate) ); |
|
337 LOG("<> CActivePalette2ApiTest::SetPaletteVisibilityL - read duration parameter.."); |
|
338 User::LeaveIfError( aItem.GetNextInt(duration) ); |
|
339 |
|
340 LOG("<> CActivePalette2ApiTest::SetPaletteVisibilityL - set animation duration.."); |
|
341 User::LeaveIfError( ap->SetPaletteVisibilityAnimationDuration(duration) ); |
|
342 User::LeaveIfError( ap->GetPaletteVisibilityAnimationDuration(test) ); |
|
343 |
|
344 if( test != duration ) |
|
345 { |
|
346 User::Leave(KErrGeneral); |
|
347 } |
|
348 |
|
349 LOG("<> CActivePalette2ApiTest::SetPaletteVisibilityL - set visibility.."); |
|
350 User::LeaveIfError( ap->SetPaletteVisibility(visible, animate, delay) ); |
|
351 |
|
352 LOG("<= CActivePalette2ApiTest::SetPaletteVisibilityL"); |
|
353 return KErrNone; |
|
354 } |
|
355 |
|
356 // ----------------------------------------------------------------------------- |
|
357 // CActivePalette2ApiTest::MovePaletteL |
|
358 // Move the Active Palette to given location. |
|
359 // (other items were commented in a header). |
|
360 // ----------------------------------------------------------------------------- |
|
361 // |
|
362 TInt |
|
363 CActivePalette2ApiTest::MovePaletteL( CStifItemParser& aItem ) |
|
364 { |
|
365 // Define test case as |
|
366 // "instance teststepname <x> <y>" |
|
367 // where |
|
368 // <x> = integer, defining the x coordinate for target location |
|
369 // <y> = integer, defining the y coordinate for target location |
|
370 LOG("=> CActivePalette2ApiTest::MovePaletteL"); |
|
371 |
|
372 MActivePalette2UI* ap = iContainer->ActivePalette(); |
|
373 |
|
374 TInt x; |
|
375 TInt y; |
|
376 |
|
377 LOG("<> CActivePalette2ApiTest::MovePaletteL - read x coordinate.."); |
|
378 User::LeaveIfError( aItem.GetNextInt(x) ); |
|
379 LOG("<> CActivePalette2ApiTest::MovePaletteL - read y coordinate.."); |
|
380 User::LeaveIfError( aItem.GetNextInt(y) ); |
|
381 |
|
382 LOG2("<> CActivePalette2ApiTest::MovePaletteL - set location to[%d,%d]", x, y); |
|
383 ap->LocateTo( TPoint(x,y) ); |
|
384 iContainer->DrawNow(); |
|
385 LOG("<> CActivePalette2ApiTest::MovePaletteL - check location.."); |
|
386 TPoint moved = ap->Location(); |
|
387 if( moved.iX != x || moved.iY != y ) |
|
388 { |
|
389 User::Leave(KErrGeneral); |
|
390 } |
|
391 |
|
392 LOG("<= CActivePalette2ApiTest::MovePaletteL"); |
|
393 return KErrNone; |
|
394 } |
|
395 |
|
396 |
|
397 // ----------------------------------------------------------------------------- |
|
398 // CActivePalette2ApiTest::AddItemsL |
|
399 // Add items to the Active Palette. |
|
400 // (other items were commented in a header). |
|
401 // ----------------------------------------------------------------------------- |
|
402 // |
|
403 TInt |
|
404 CActivePalette2ApiTest::AddItemsL( CStifItemParser& aItem ) |
|
405 { |
|
406 // Define test case as |
|
407 // "instance teststepname <a> <b> <c> ..." |
|
408 // where |
|
409 // <a>, <b>, <c> ... = integers, id for an item to be added. |
|
410 LOG("=> CActivePalette2ApiTest::AddItemsL"); |
|
411 MActivePalette2UI* ap = iContainer->ActivePalette(); |
|
412 |
|
413 _LIT(KTooltipFormat, "Tooltip: %d"); |
|
414 TBuf<20> buffer; |
|
415 int id; |
|
416 |
|
417 while( aItem.GetNextInt(id) == KErrNone ) |
|
418 { |
|
419 LOG1("<> CActivePalette2ApiTest::AddItemsL - got id[%d]", id); |
|
420 buffer.Format(KTooltipFormat, id); |
|
421 |
|
422 TAP2GenericPluginParams params( |
|
423 TAP2GenericPluginParams::EGenericCustomResFile, |
|
424 KIconFileName, // Icon file name |
|
425 KIconIds[id%KIconCount], // Icon id |
|
426 KMaskIds[id%KIconCount], // Mask id |
|
427 buffer, // Tooltip text |
|
428 id, // msg id |
|
429 0); // custom param |
|
430 TPckg<TAP2GenericPluginParams> params_buf(params); |
|
431 |
|
432 const TBool visibility = true; |
|
433 |
|
434 TActivePalette2ItemVisible itemVisible(id, visibility); |
|
435 |
|
436 if( itemVisible.ItemId() != id && |
|
437 itemVisible.Visible() != visibility ) |
|
438 { |
|
439 LOG("<> CActivePalette2ApiTest::AddItemsL - id or visibility setting failed!"); |
|
440 User::Leave(KErrGeneral); |
|
441 } |
|
442 |
|
443 LOG("<> CActivePalette2ApiTest::AddItemsL - install item.."); |
|
444 ap->InstallItemL(itemVisible, |
|
445 TUid::Uid(KActivePalette2GenericPluginUID), |
|
446 params_buf); |
|
447 |
|
448 LOG("<> CActivePalette2ApiTest::AddItemsL - test sending message, for updating icon.."); |
|
449 TAP2GenericPluginIcon icon(KIconIds[id%KIconCount], KMaskIds[id%KIconCount]); |
|
450 TPckgC<TAP2GenericPluginIcon> update_buf(icon); |
|
451 LOG("<> CActivePalette2ApiTest::AddItemsL - send the message.."); |
|
452 User::LeaveIfError( ap->SendMessage( id, EAPGenericPluginChangeIcon, update_buf) ); |
|
453 } |
|
454 |
|
455 // This constructor is exported, although we have no use for it. |
|
456 // Try this method also. |
|
457 LOG("<> CActivePalette2ApiTest::AddItemsL - test TAP2GenericPluginIcon.."); |
|
458 TAP2GenericPluginIcon tmp( 101, 102 ); |
|
459 if( tmp.iIconId != 101 && tmp.iMaskId != 102 ) |
|
460 { |
|
461 LOG("<> CActivePalette2ApiTest::AddItemsL - TAP2GenericPluginIcon constructor error!"); |
|
462 User::Leave( KErrGeneral); |
|
463 } |
|
464 |
|
465 |
|
466 LOG("<= CActivePalette2ApiTest::AddItemsL"); |
|
467 return KErrNone; |
|
468 } |
|
469 |
|
470 // ----------------------------------------------------------------------------- |
|
471 // CActivePalette2ApiTest::RemoveItemsL |
|
472 // Remove given items from the Active Palette. |
|
473 // (other items were commented in a header). |
|
474 // ----------------------------------------------------------------------------- |
|
475 // |
|
476 TInt |
|
477 CActivePalette2ApiTest::RemoveItemsL( CStifItemParser& aItem ) |
|
478 { |
|
479 // Define test case as |
|
480 // "instance teststepname <a> <b> <c> ..." |
|
481 // where |
|
482 // <a>, <b>, <c> ... = integers, id for an item to be removed. |
|
483 LOG("=> CActivePalette2ApiTest::RemoveItemsL"); |
|
484 MActivePalette2UI* ap = iContainer->ActivePalette(); |
|
485 TInt id = 0; |
|
486 while ( aItem.GetNextInt(id) == KErrNone ) |
|
487 { |
|
488 LOG1("<> CActivePalette2ApiTest::RemoveItemsL - removing id[%d]", id ); |
|
489 User::LeaveIfError( ap->RemoveItem(id) ); |
|
490 } |
|
491 LOG("<= CActivePalette2ApiTest::RemoveItemsL"); |
|
492 return KErrNone; |
|
493 } |
|
494 |
|
495 // ----------------------------------------------------------------------------- |
|
496 // CActivePalette2ApiTest::ShowItemsL |
|
497 // Show given Active Palette items. |
|
498 // Items must already be added to Active Palette. |
|
499 // (other items were commented in a header). |
|
500 // ----------------------------------------------------------------------------- |
|
501 // |
|
502 TInt |
|
503 CActivePalette2ApiTest::ShowItemsL( CStifItemParser& aItem ) |
|
504 { |
|
505 // Define test case as |
|
506 // "instance teststepname <a> <b> <c> ..." |
|
507 // where |
|
508 // <a>, <b>, <c> ... = integers, id for an item to be shown. |
|
509 // |
|
510 LOG("=> CActivePalette2ApiTest::ShowItemsL"); |
|
511 MActivePalette2UI* ap = iContainer->ActivePalette(); |
|
512 TInt id = 0; |
|
513 while ( aItem.GetNextInt(id) == KErrNone ) |
|
514 { |
|
515 LOG1("<> CActivePalette2ApiTest::ShowItemsL - showing id[%d]", id ); |
|
516 User::LeaveIfError( ap->SetItemVisibility(id, true) ); |
|
517 } |
|
518 LOG("<= CActivePalette2ApiTest::ShowItemsL"); |
|
519 return KErrNone; |
|
520 } |
|
521 |
|
522 // ----------------------------------------------------------------------------- |
|
523 // CActivePalette2ApiTest::HideItemsL |
|
524 // Hide given Active Palette items. |
|
525 // Items must already be added to Active Palette. |
|
526 // (other items were commented in a header). |
|
527 // ----------------------------------------------------------------------------- |
|
528 // |
|
529 TInt |
|
530 CActivePalette2ApiTest::HideItemsL( CStifItemParser& aItem ) |
|
531 { |
|
532 // Define test case as |
|
533 // "instance teststepname <a> <b> <c> ..." |
|
534 // where |
|
535 // <a>, <b>, <c> ... = integers, id for an item to be hidden. |
|
536 // |
|
537 LOG("=> CActivePalette2ApiTest::HideItemsL"); |
|
538 MActivePalette2UI* ap = iContainer->ActivePalette(); |
|
539 TInt id = 0; |
|
540 while ( aItem.GetNextInt(id) == KErrNone ) |
|
541 { |
|
542 LOG1("<> CActivePalette2ApiTest::HideItemsL - hiding id[%d]", id ); |
|
543 User::LeaveIfError( ap->SetItemVisibility(id, false) ); |
|
544 } |
|
545 LOG("<= CActivePalette2ApiTest::HideItemsL"); |
|
546 return KErrNone; |
|
547 } |
|
548 |
|
549 // ----------------------------------------------------------------------------- |
|
550 // CActivePalette2ApiTest::SetCurrentItemL |
|
551 // Set the currently focused Active Palette item. |
|
552 // (other items were commented in a header). |
|
553 // ----------------------------------------------------------------------------- |
|
554 // |
|
555 TInt |
|
556 CActivePalette2ApiTest::SetCurrentItemL( CStifItemParser& aItem ) |
|
557 { |
|
558 // Define test case as |
|
559 // "instance teststepname <id>" |
|
560 // where |
|
561 // <id> = integer, id for an item to be set focused. |
|
562 // |
|
563 LOG("=> CActivePalette2ApiTest::SetCurrentItemL"); |
|
564 TInt id = 0; |
|
565 User::LeaveIfError( aItem.GetNextInt(id) ); |
|
566 LOG1("<> CActivePalette2ApiTest::SetCurrentItemL - focusing id[%d]", id ); |
|
567 User::LeaveIfError( iContainer->ActivePalette()->SetCurrentItem(id) ); |
|
568 LOG("<= CActivePalette2ApiTest::SetCurrentItemL"); |
|
569 return KErrNone; |
|
570 } |
|
571 |
|
572 // ----------------------------------------------------------------------------- |
|
573 // CActivePalette2ApiTest::CheckCurrentItemL |
|
574 // Check the currently focused Active Palette item. |
|
575 // (other items were commented in a header). |
|
576 // ----------------------------------------------------------------------------- |
|
577 // |
|
578 TInt |
|
579 CActivePalette2ApiTest::CheckCurrentItemL( CStifItemParser& aItem ) |
|
580 { |
|
581 // Define test case as |
|
582 // "instance teststepname <id>" |
|
583 // where |
|
584 // <id> = integer, id of the item that is expected to be focused. |
|
585 // |
|
586 LOG("=> CActivePalette2ApiTest::CheckCurrentItemL"); |
|
587 TInt expected = 0; |
|
588 TInt current = 0; |
|
589 |
|
590 User::LeaveIfError( aItem.GetNextInt(expected) ); |
|
591 LOG1("<> CActivePalette2ApiTest::CheckCurrentItemL - expecting focused id[%d]", expected ); |
|
592 |
|
593 User::LeaveIfError( iContainer->ActivePalette()->GetCurrentItem(current) ); |
|
594 LOG1("<> CActivePalette2ApiTest::CheckCurrentItemL - actually focused id[%d]", current ); |
|
595 |
|
596 const TInt status = expected == current ? KErrNone : KErrGeneral; |
|
597 LOG1("<= CActivePalette2ApiTest::CheckCurrentItemL - return %d", status); |
|
598 return status; |
|
599 } |
|
600 |
|
601 // ----------------------------------------------------------------------------- |
|
602 // CActivePalette2ApiTest::CheckItemListL |
|
603 // Check the items currently contained in Active Palette. |
|
604 // (other items were commented in a header). |
|
605 // ----------------------------------------------------------------------------- |
|
606 // |
|
607 TInt |
|
608 CActivePalette2ApiTest::CheckItemListL( CStifItemParser& aItem ) |
|
609 { |
|
610 // Define test case as |
|
611 // "instance teststepname <a> <b> <c> ..." |
|
612 // where |
|
613 // <a>, <b>, <c> ... = integers, ids of the items that, and only that, |
|
614 // are expected to be contained in Active Palette. |
|
615 // |
|
616 LOG("=> CActivePalette2ApiTest::CheckItemListL"); |
|
617 RArray<TInt> expected; |
|
618 CleanupClosePushL(expected); |
|
619 |
|
620 LOG("<> CActivePalette2ApiTest::CheckItemListL - get expected items.."); |
|
621 TInt id = 0; |
|
622 while ( aItem.GetNextInt(id) == KErrNone ) |
|
623 { |
|
624 expected.Append(id); |
|
625 } |
|
626 |
|
627 LOG("<> CActivePalette2ApiTest::CheckItemListL - get current items.."); |
|
628 RArray<TActivePalette2ItemVisible> current; |
|
629 CleanupClosePushL(current); |
|
630 User::LeaveIfError( iContainer->ActivePalette()->GetItemList(current) ); |
|
631 |
|
632 if( current.Count() != expected.Count() ) |
|
633 { |
|
634 LOG2("<> CActivePalette2ApiTest::CheckItemListL - counts do not match, currently[%d] expected[%d]!", |
|
635 current.Count(), expected.Count()); |
|
636 User::Leave(KErrGeneral); |
|
637 } |
|
638 for( int i = 0; i < current.Count(); i++ ) |
|
639 { |
|
640 if( expected[i] != current[i].ItemId() ) |
|
641 { |
|
642 LOG3("<> CActivePalette2ApiTest::CheckItemListL - item at[%d] has id[%d] expected id[%d] !", |
|
643 i, current[i].ItemId(), expected[i]); |
|
644 User::Leave(KErrGeneral); |
|
645 } |
|
646 } |
|
647 |
|
648 LOG("<> CActivePalette2ApiTest::CheckItemListL - set current items again.."); |
|
649 User::LeaveIfError( iContainer->ActivePalette()->SetItemList(current) ); |
|
650 |
|
651 CleanupStack::PopAndDestroy(¤t); |
|
652 CleanupStack::PopAndDestroy(&expected); |
|
653 |
|
654 LOG("<= CActivePalette2ApiTest::CheckItemListL"); |
|
655 return KErrNone; |
|
656 } |
|
657 |
|
658 // ----------------------------------------------------------------------------- |
|
659 // CActivePalette2ApiTest::CheckItemVisibilitiesL |
|
660 // Check the items currently visible in Active Palette. |
|
661 // (other items were commented in a header). |
|
662 // ----------------------------------------------------------------------------- |
|
663 // |
|
664 TInt |
|
665 CActivePalette2ApiTest::CheckItemVisibilitiesL( CStifItemParser& aItem ) |
|
666 { |
|
667 // In test case definition, use the following format |
|
668 // "instance teststepname <id1> <visibility> <id2> <visibility> ..." |
|
669 // Where |
|
670 // <id1>, <id2> ... = integer, defining the id for item to be checked. |
|
671 // <visibility> = "true" or "false", defines the expected visibility |
|
672 // of item with the id number given just before. |
|
673 // |
|
674 // Note: All items currently contained in Active Palette must be mentioned. |
|
675 // |
|
676 LOG("=> CActivePalette2ApiTest::CheckItemVisibilitiesL"); |
|
677 |
|
678 MActivePalette2UI* ap = iContainer->ActivePalette(); |
|
679 |
|
680 LOG("<> CActivePalette2ApiTest::CheckItemVisibilitiesL - get expected items.."); |
|
681 TInt count = 0; |
|
682 TInt id = 0; |
|
683 TBool expectVisible = false; |
|
684 TBool isVisible = false; |
|
685 |
|
686 |
|
687 while( aItem.GetNextInt(id) == KErrNone ) |
|
688 { |
|
689 LOG1("<> CActivePalette2ApiTest::CheckItemVisibilitiesL - get expected visibility for id[%d]", id); |
|
690 User::LeaveIfError( GetNextBooleanFromString(aItem, expectVisible) ); |
|
691 |
|
692 LOG1("<> CActivePalette2ApiTest::CheckItemVisibilitiesL - get current visibility for id[%d]", id); |
|
693 User::LeaveIfError( ap->GetItemVisibility(id, isVisible) ); |
|
694 if( isVisible != expectVisible ) |
|
695 { |
|
696 LOG("<> CActivePalette2ApiTest::CheckItemVisibilitiesL - visibilities do not match!"); |
|
697 User::Leave(KErrGeneral); |
|
698 } |
|
699 |
|
700 // Count the items so we can make sure all are checked. |
|
701 count++; |
|
702 } |
|
703 |
|
704 // Check now that all items were checked. |
|
705 LOG("<> CActivePalette2ApiTest::CheckItemVisibilitiesL - get current items.."); |
|
706 RArray<TActivePalette2ItemVisible> current; |
|
707 CleanupClosePushL(current); |
|
708 User::LeaveIfError( iContainer->ActivePalette()->GetItemList(current) ); |
|
709 if( current.Count() != count ) |
|
710 { |
|
711 LOG2("<> CActivePalette2ApiTest::CheckItemVisibilitiesL - counts do not match, currently[%d] expected[%d]!", |
|
712 current.Count(), count); |
|
713 User::Leave(KErrGeneral); |
|
714 } |
|
715 CleanupStack::PopAndDestroy(¤t); |
|
716 |
|
717 LOG("<= CActivePalette2ApiTest::CheckItemVisibilitiesL"); |
|
718 return KErrNone; |
|
719 } |
|
720 |
|
721 |
|
722 // ----------------------------------------------------------------------------- |
|
723 // CActivePalette2ApiTest::TestOffscreenDrawingL |
|
724 // Test the use of offscreen buffer for Active Palette rendering. |
|
725 // (other items were commented in a header). |
|
726 // ----------------------------------------------------------------------------- |
|
727 // |
|
728 TInt |
|
729 CActivePalette2ApiTest::TestOffscreenDrawingL( CStifItemParser& /*aItem*/ ) |
|
730 { |
|
731 LOG("=> CActivePalette2ApiTest::TestOffscreenDrawingL"); |
|
732 MActivePalette2UI* ap = iContainer->ActivePalette(); |
|
733 |
|
734 LOG("<> CActivePalette2ApiTest::TestOffscreenDrawingL - create bitmap.."); |
|
735 CFbsBitmap* bitmap = new ( ELeave ) CFbsBitmap(); |
|
736 CleanupStack::PushL( bitmap ); |
|
737 User::LeaveIfError( bitmap->Create( iContainer->Size(), EColor16MU ) ); |
|
738 |
|
739 LOG("<> CActivePalette2ApiTest::TestOffscreenDrawingL - create device.."); |
|
740 CFbsBitmapDevice* device = CFbsBitmapDevice::NewL( bitmap ); |
|
741 CleanupStack::PushL( device ); |
|
742 |
|
743 LOG("<> CActivePalette2ApiTest::TestOffscreenDrawingL - create context.."); |
|
744 CFbsBitGc* context = NULL; |
|
745 User::LeaveIfError( device->CreateContext( context ) ); |
|
746 CleanupStack::PushL( context ); |
|
747 |
|
748 LOG("<> CActivePalette2ApiTest::TestOffscreenDrawingL - test rendering.."); |
|
749 ap->SetGc( context ); |
|
750 ap->RenderActivePalette( TRect( TPoint(0,0), bitmap->SizeInPixels() ) ); |
|
751 ap->SetGc(); |
|
752 |
|
753 CleanupStack::PopAndDestroy( context ); |
|
754 CleanupStack::PopAndDestroy( device ); |
|
755 CleanupStack::PopAndDestroy( bitmap ); |
|
756 |
|
757 LOG("<= CActivePalette2ApiTest::TestOffscreenDrawingL"); |
|
758 return KErrNone; |
|
759 } |
|
760 |
|
761 |
|
762 // ----------------------------------------------------------------------------- |
|
763 // CActivePalette2ApiTest::TestKeyPreviousL |
|
764 // Test handling key event for moving to previous item. |
|
765 // (other items were commented in a header). |
|
766 // ----------------------------------------------------------------------------- |
|
767 // |
|
768 TInt |
|
769 CActivePalette2ApiTest::TestKeyPreviousL( CStifItemParser& /*aItem*/ ) |
|
770 { |
|
771 LOG("=> CActivePalette2ApiTest::TestKeyPreviousL"); |
|
772 TKeyEvent event; |
|
773 event.iCode = KNaviPrevious; |
|
774 event.iScanCode = KNaviPrevious; |
|
775 |
|
776 TKeyResponse response = iContainer->OfferKeyEventL(event, EEventKey); |
|
777 LOG("<= CActivePalette2ApiTest::TestKeyPreviousL"); |
|
778 return KErrNone; |
|
779 } |
|
780 |
|
781 |
|
782 // ----------------------------------------------------------------------------- |
|
783 // CActivePalette2ApiTest::TestKeyNextL |
|
784 // Test handling key event for moving to next item. |
|
785 // (other items were commented in a header). |
|
786 // ----------------------------------------------------------------------------- |
|
787 // |
|
788 TInt |
|
789 CActivePalette2ApiTest::TestKeyNextL( CStifItemParser& /*aItem*/ ) |
|
790 { |
|
791 LOG("=> CActivePalette2ApiTest::TestKeyNextL"); |
|
792 TKeyEvent event; |
|
793 event.iCode = KNaviNext; |
|
794 event.iScanCode = KNaviNext; |
|
795 |
|
796 TKeyResponse response = iContainer->OfferKeyEventL(event, EEventKey); |
|
797 LOG("<= CActivePalette2ApiTest::TestKeyNextL"); |
|
798 return KErrNone; |
|
799 } |
|
800 |
|
801 |
|
802 // ----------------------------------------------------------------------------- |
|
803 // CActivePalette2ApiTest::TestKeySelectL |
|
804 // Test handling key event for selecting item. |
|
805 // (other items were commented in a header). |
|
806 // ----------------------------------------------------------------------------- |
|
807 // |
|
808 TInt |
|
809 CActivePalette2ApiTest::TestKeySelectL( CStifItemParser& /*aItem*/ ) |
|
810 { |
|
811 LOG("=> CActivePalette2ApiTest::TestKeySelectL"); |
|
812 TKeyEvent event; |
|
813 event.iCode = KNaviSelect; |
|
814 event.iScanCode = KNaviSelect; |
|
815 event.iRepeats = 0; |
|
816 |
|
817 TKeyResponse response = iContainer->OfferKeyEventL(event, EEventKey); |
|
818 |
|
819 |
|
820 LOG("<= CActivePalette2ApiTest::TestKeySelectL"); |
|
821 return KErrNone; |
|
822 } |
|
823 |
|
824 |
|
825 // ----------------------------------------------------------------------------- |
|
826 // CActivePalette2ApiTest::GetNextBooleanFromString |
|
827 // Helper method for reading a string with expected values of |
|
828 // "true" and "false" and converting them to a TBool value. |
|
829 // (other items were commented in a header). |
|
830 // ----------------------------------------------------------------------------- |
|
831 // |
|
832 TInt |
|
833 CActivePalette2ApiTest::GetNextBooleanFromString( CStifItemParser& aItem, TBool& aValue ) |
|
834 { |
|
835 LOG("=> CActivePalette2ApiTest::GetNextBooleanFromString"); |
|
836 |
|
837 TPtrC content; |
|
838 TInt status = aItem.GetNextString(content); |
|
839 |
|
840 if( status == KErrNone ) |
|
841 { |
|
842 LOG("<> CActivePalette2ApiTest::GetNextBooleanFromString - about to trace string.."); |
|
843 LOG1("<> CActivePalette2ApiTest::GetNextBooleanFromString - got [%S]", &content ); |
|
844 if( content.Compare(KTrueString) == 0 ) |
|
845 { |
|
846 aValue = ETrue; |
|
847 } |
|
848 else if( content.Compare(KFalseString) == 0 ) |
|
849 { |
|
850 aValue = EFalse; |
|
851 } |
|
852 else |
|
853 { |
|
854 User::Panic(_L("Test case not valid!"), 1); |
|
855 } |
|
856 } |
|
857 |
|
858 LOG("<= CActivePalette2ApiTest::GetNextBooleanFromString"); |
|
859 return status; |
|
860 } |
|
861 |
|
862 |
|
863 // ----------------------------------------------------------------------------- |
|
864 // CActivePalette2ApiTest::?member_function |
|
865 // ?implementation_description |
|
866 // (other items were commented in a header). |
|
867 // ----------------------------------------------------------------------------- |
|
868 // |
|
869 /* |
|
870 TInt CActivePalette2ApiTest::?member_function( |
|
871 CItemParser& aItem ) |
|
872 { |
|
873 |
|
874 ?code |
|
875 |
|
876 } |
|
877 */ |
|
878 |
|
879 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
880 // None |
|
881 |
|
882 // [End of File] - Do not remove |