|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @internalComponent - Internal Symbian test code |
|
19 */ |
|
20 |
|
21 |
|
22 #include <coeaui.h> |
|
23 #include <coemain.h> |
|
24 #include <coecntrl.h> |
|
25 #include <coesndpy.h> |
|
26 #include <e32keys.h> |
|
27 #include <basched.h> |
|
28 #include <bassnd.h> |
|
29 |
|
30 #include "TMenu1Step.h" |
|
31 |
|
32 |
|
33 |
|
34 //#include <e32test.h> |
|
35 //RTest test(_L("tmenu1")); |
|
36 |
|
37 //#define FORCE_AUT |
|
38 // class CTestMenu1 |
|
39 |
|
40 /** |
|
41 Returns the number of bytes a menu item actually consists of.\n |
|
42 */ |
|
43 TInt TSimpleMenuItem::RealLengthOfData() const |
|
44 { |
|
45 return(sizeof(TSimpleMenuItem)-(ENominalTextLength-iText.Length())*sizeof(TText)); |
|
46 } |
|
47 |
|
48 |
|
49 /** |
|
50 Destructor\n |
|
51 Frees all memory allocated by the menu and fonts.\n |
|
52 */ |
|
53 CTestMenu1::~CTestMenu1() |
|
54 { |
|
55 FreeData(); |
|
56 iCoeEnv->ReleaseScreenFont(iFont); |
|
57 } |
|
58 |
|
59 /** |
|
60 Creates a font.\n |
|
61 */ |
|
62 void CTestMenu1::CreateFontL() |
|
63 { |
|
64 TFontSpec spec(_L("Arial"),240); |
|
65 iFont=iCoeEnv->CreateScreenFontL(spec); |
|
66 } |
|
67 |
|
68 /** |
|
69 Handles pointer events.\n |
|
70 Closes the menu if pointer button has been pressed or been released |
|
71 and the pointer is outside the displayed menu.\n |
|
72 If inside, find out where and highlight the correct menu item. Report |
|
73 the event if pointer button was released.\n |
|
74 */ |
|
75 void CTestMenu1::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
76 { |
|
77 TRect rect=Rect(); |
|
78 if (!rect.Contains(aPointerEvent.iPosition)) |
|
79 { |
|
80 switch (aPointerEvent.iType) |
|
81 { |
|
82 case TPointerEvent::EButton1Down: |
|
83 case TPointerEvent::EButton1Up: |
|
84 CloseMenu(); |
|
85 default: |
|
86 break; |
|
87 } |
|
88 } |
|
89 rect.Shrink(EBorderWidth,EBorderWidth); |
|
90 if (!rect.Contains(aPointerEvent.iPosition)) |
|
91 return; |
|
92 TInt n=(aPointerEvent.iPosition.iY-EBorderWidth)/iFont->HeightInPixels(); |
|
93 HighlightTo(n); |
|
94 if (aPointerEvent.iType==TPointerEvent::EButton1Up) |
|
95 { |
|
96 ReportSelectionMadeL(); |
|
97 CloseMenu(); |
|
98 } |
|
99 } |
|
100 |
|
101 /** |
|
102 Display the entire menu with the selected item hilighted.\n |
|
103 */ |
|
104 void CTestMenu1::Draw(const TRect& /*aRect*/) const |
|
105 { |
|
106 CWindowGc& gc=SystemGc(); |
|
107 TRect rect=Rect(); |
|
108 gc.DrawRect(rect); |
|
109 rect.Shrink(1,1); |
|
110 gc.SetPenColor(KRgbWhite); |
|
111 gc.DrawRect(rect); |
|
112 PrepareGcForDrawingItems(); |
|
113 TInt count=iItemArray->Count(); |
|
114 for (TInt i=0; i<count; i++) |
|
115 DrawItem(i,i==iItemSelected); |
|
116 } |
|
117 |
|
118 /** |
|
119 Prepares the system graphical context.\n |
|
120 */ |
|
121 void CTestMenu1::PrepareGcForDrawingItems() const |
|
122 { |
|
123 CWindowGc& gc=SystemGc(); |
|
124 gc.UseFont(iFont); |
|
125 gc.SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
126 } |
|
127 |
|
128 /** |
|
129 Display a menu item either hilighted or not.\n |
|
130 */ |
|
131 void CTestMenu1::DrawItem(TInt aItem,TInt aHighlight) const |
|
132 { |
|
133 TInt itemHeight=iFont->HeightInPixels(); |
|
134 TPoint tl(2,2+aItem*itemHeight); |
|
135 TSize sz(iSize.iWidth-4,itemHeight); |
|
136 TRect rect(tl,sz); |
|
137 CWindowGc& gc=SystemGc(); |
|
138 if (!aHighlight) |
|
139 { |
|
140 gc.SetPenColor(KRgbBlack); |
|
141 gc.SetBrushColor(KRgbWhite); |
|
142 } |
|
143 else |
|
144 { |
|
145 gc.SetPenColor(KRgbWhite); |
|
146 gc.SetBrushColor(KRgbBlack); |
|
147 } |
|
148 TSimpleMenuItem& tmp=(*iItemArray)[aItem]; |
|
149 gc.DrawText(tmp.iText,rect,iFont->AscentInPixels()); |
|
150 } |
|
151 |
|
152 /** |
|
153 Report to the window which menu item was selected.\n |
|
154 */ |
|
155 void CTestMenu1::ReportSelectionMadeL() |
|
156 { |
|
157 TSimpleMenuItem& tmp=(*iItemArray)[iItemSelected]; |
|
158 iObserver->MenuSelectionMadeL(tmp.iCommand); |
|
159 } |
|
160 |
|
161 /** |
|
162 Binds hot keys to menu items.\n |
|
163 */ |
|
164 void CTestMenu1::InitializeHotKeyCommands() |
|
165 { |
|
166 iHotKeyCommand[CTRL('b')]=EMenuCommandBold; |
|
167 iHotKeyCommand[CTRL('i')]=EMenuCommandItalic; |
|
168 iHotKeyCommand[CTRL('u')]=EMenuCommandUnderline; |
|
169 iHotKeyCommand[CTRL('s')]=EMenuCommandStrikethrough; |
|
170 iHotKeyCommand[CTRL('a')]=EMenuCommandAddWindow; |
|
171 iHotKeyCommand[CTRL('r')]=EMenuCommandRemoveWindow; |
|
172 iHotKeyCommand[CTRL('d')]=EMenuCommandDrag; |
|
173 iHotKeyCommand[CTRL('e')]=EMenuCommandExit; |
|
174 iHotKeyCommand[CTRL('c')]=EMenuCommandColor; |
|
175 iHotKeyCommand[CTRL('p')]=EMenuCommandPlaySound; |
|
176 } |
|
177 |
|
178 /** |
|
179 Second phase constructor for the test menu.\n |
|
180 */ |
|
181 void CTestMenu1::ConstructL(MTestMenu1MenuObserver* aObserver,CCoeAppUi* aStack) |
|
182 { |
|
183 iObserver=aObserver; |
|
184 iStack=aStack; |
|
185 InitializeHotKeyCommands(); |
|
186 CreateFontL(); |
|
187 } |
|
188 |
|
189 /** |
|
190 Frees the memory the menu occupied.\n |
|
191 */ |
|
192 void CTestMenu1::FreeData() |
|
193 { |
|
194 delete(iItemArray); |
|
195 iItemArray=NULL; |
|
196 } |
|
197 |
|
198 /** |
|
199 Closes the menu if it is displayed.\n |
|
200 */ |
|
201 void CTestMenu1::CloseMenu() |
|
202 { |
|
203 if (!iDisplayed) |
|
204 return; |
|
205 CloseWindow(); |
|
206 iDisplayed=EFalse; |
|
207 FreeData(); |
|
208 } |
|
209 |
|
210 /** |
|
211 Constructs a single menu item.\n |
|
212 */ |
|
213 void CTestMenu1::AddMenuItemL(TMenuCommand aCommand,const TDesC& aText) |
|
214 { |
|
215 TSimpleMenuItem tmp; |
|
216 tmp.iCommand=aCommand; |
|
217 tmp.iText=aText; |
|
218 iItemArray->AppendL(tmp,tmp.RealLengthOfData()); |
|
219 } |
|
220 |
|
221 /** |
|
222 Adds individual menu items.\n |
|
223 */ |
|
224 void CTestMenu1::DoLoadDataL() |
|
225 { |
|
226 AddMenuItemL(EMenuCommandBold,_L("Toggle bold (Ctrl+B)")); |
|
227 AddMenuItemL(EMenuCommandItalic,_L("Toggle italic (Ctrl+I)")); |
|
228 AddMenuItemL(EMenuCommandUnderline,_L("Toggle underline (Ctrl+U)")); |
|
229 AddMenuItemL(EMenuCommandStrikethrough,_L("Toggle strikethrough (Ctrl+S)")); |
|
230 AddMenuItemL(EMenuCommandAddWindow,_L("Add window (Ctrl+A)")); |
|
231 AddMenuItemL(EMenuCommandRemoveWindow,_L("Remove window (Ctrl+R)")); |
|
232 AddMenuItemL(EMenuCommandDrag,_L("Toggle drag enablement (Ctrl+D)")); |
|
233 AddMenuItemL(EMenuCommandColor,_L("Override colours (Ctrl+C)")); |
|
234 AddMenuItemL(EMenuCommandPlaySound,_L("Play sounds (Ctrl+P)")); |
|
235 AddMenuItemL(EMenuCommandExit,_L("Exit (Ctrl+E)")); |
|
236 } |
|
237 |
|
238 /** |
|
239 Constructs a menu.\n |
|
240 */ |
|
241 void CTestMenu1::LoadDataL() |
|
242 { |
|
243 iItemArray=new(ELeave) CArrayVarFlat<TSimpleMenuItem> (16); |
|
244 TRAPD(ret,DoLoadDataL()); |
|
245 if (ret) |
|
246 { |
|
247 FreeData(); |
|
248 User::Leave(ret); |
|
249 } |
|
250 } |
|
251 |
|
252 /** |
|
253 Calculates the size of all items in the menu.\n |
|
254 */ |
|
255 void CTestMenu1::CalculateSize(TSize& aSize) |
|
256 { |
|
257 TInt count=iItemArray->Count(); |
|
258 aSize.iHeight=count*iFont->HeightInPixels(); |
|
259 aSize.iHeight+=2+2; // 2 pixels at top and 2 at bottom |
|
260 for (TInt i=0; i<count; i++) |
|
261 { |
|
262 TSimpleMenuItem& tmp=(*iItemArray)[i]; |
|
263 TInt itemWidth=iFont->TextWidthInPixels(tmp.iText); |
|
264 if (itemWidth>aSize.iWidth) |
|
265 aSize.iWidth=itemWidth; |
|
266 } |
|
267 aSize.iWidth+=2+2; // 2 pixels at left and 2 at right |
|
268 } |
|
269 |
|
270 /** |
|
271 Creates a menu in a newly created window.\n |
|
272 */ |
|
273 void CTestMenu1::CreateMenuL() |
|
274 { |
|
275 LoadDataL(); |
|
276 TRAPD(err,CreateWindowL()); |
|
277 if (err) |
|
278 { |
|
279 FreeData(); |
|
280 User::Leave(err); |
|
281 } |
|
282 EnableDragEvents(); |
|
283 SetPointerCapture(); |
|
284 iDisplayed=ETrue; |
|
285 TSize size; |
|
286 CalculateSize(size); |
|
287 SetExtent(TPoint(5,5),size); |
|
288 ActivateL(); |
|
289 } |
|
290 |
|
291 /** |
|
292 Hilights the current menu item.\n |
|
293 */ |
|
294 void CTestMenu1::HighlightTo(TInt aNewItemSelected) |
|
295 { |
|
296 if (aNewItemSelected==iItemSelected) |
|
297 return; |
|
298 ActivateGc(); |
|
299 PrepareGcForDrawingItems(); |
|
300 DrawItem(iItemSelected,EFalse); |
|
301 iItemSelected=aNewItemSelected; |
|
302 DrawItem(iItemSelected,ETrue); |
|
303 DeactivateGc(); |
|
304 } |
|
305 |
|
306 /** |
|
307 The method is an override from CCoeControl.\n |
|
308 The function is called to handle key events.\n |
|
309 Handles the up and down arrow keys which hilights previous/next item in the menu.\n |
|
310 PageUp causes first item in menu to be hilighted and PageDown causes the last to be hilighted.\n |
|
311 The enter key executes the current menu item.\n |
|
312 The escape key closes the menu.\n |
|
313 F9 and Tab show the menu.\n |
|
314 If <Ctrl> + key is pressed it is checked if it is a hot key. If so execute the menu selection.\n |
|
315 */ |
|
316 TKeyResponse CTestMenu1::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) |
|
317 { |
|
318 if (aType!=EEventKey) |
|
319 return(EKeyWasNotConsumed); |
|
320 TInt modifiers=aKeyEvent.iModifiers; |
|
321 TInt code=aKeyEvent.iCode; |
|
322 if ((modifiers&EAllStdModifiers)==EModifierCtrl) |
|
323 { |
|
324 if (code<27) |
|
325 { |
|
326 TMenuCommand command=iHotKeyCommand[code]; |
|
327 if (command) |
|
328 { |
|
329 iObserver->MenuSelectionMadeL(command); |
|
330 CloseMenu(); |
|
331 } |
|
332 } |
|
333 return(EKeyWasConsumed); |
|
334 } |
|
335 if (!iDisplayed) |
|
336 { |
|
337 if (code==EKeyF9 || code==EKeyTab) |
|
338 { |
|
339 CreateMenuL(); |
|
340 return(EKeyWasConsumed); |
|
341 } |
|
342 } |
|
343 else |
|
344 { |
|
345 TInt count=iItemArray->Count(); |
|
346 switch (code) |
|
347 { |
|
348 case EKeyDownArrow: |
|
349 if (iItemSelected<count-1) |
|
350 HighlightTo(iItemSelected+1); |
|
351 break; |
|
352 case EKeyUpArrow: |
|
353 if (iItemSelected) |
|
354 HighlightTo(iItemSelected-1); |
|
355 break; |
|
356 case EKeyPageUp: |
|
357 HighlightTo(0); |
|
358 break; |
|
359 case EKeyPageDown: |
|
360 HighlightTo(count-1); |
|
361 break; |
|
362 case EKeyEnter: |
|
363 ReportSelectionMadeL(); |
|
364 case EKeyEscape: |
|
365 CloseMenu(); |
|
366 break; |
|
367 default: |
|
368 break; |
|
369 } |
|
370 return(EKeyWasConsumed); |
|
371 } |
|
372 return(EKeyWasNotConsumed); |
|
373 } |
|
374 |
|
375 |
|
376 |
|
377 // |
|
378 // class CMenu1MessageControl |
|
379 // |
|
380 |
|
381 |
|
382 |
|
383 void CMenu1MessageControl::ToggleDragState() |
|
384 { |
|
385 TInt filter=EPointerFilterDrag; // means to filter out drags |
|
386 if (iDragsEnabled) |
|
387 { |
|
388 iDragsEnabled=EFalse; |
|
389 SetMessage(_L8("Pointer drag events disabled")); |
|
390 } |
|
391 else |
|
392 { |
|
393 iDragsEnabled=ETrue; |
|
394 SetMessage(_L8("Pointer drag events enabled")); |
|
395 filter=0; |
|
396 } |
|
397 BackedUpWindow().PointerFilter(EPointerFilterDrag,filter); |
|
398 } |
|
399 |
|
400 /** |
|
401 Second phase constructor for CMenu1MessageControl.\n |
|
402 Creates a control's window.\n |
|
403 The created window is the child of the application's window group.\n |
|
404 Sets a Font and display a message.\n |
|
405 */ |
|
406 void CMenu1MessageControl::ConstructL() |
|
407 { |
|
408 CreateBackedUpWindowL(iCoeEnv->RootWin(),EGray2); |
|
409 SetExtent(TPoint(20,20),TSize(600,200)); |
|
410 TFontSpec spec(_L("Arial"),220); |
|
411 SetFontL(spec); |
|
412 SetMessage(_L8("Press Tab for Menu...")); |
|
413 ActivateL(); |
|
414 } |
|
415 |
|
416 /** |
|
417 Destructor for the CMenu1MessageControl class.\n |
|
418 Calls the ReleaseScreenFont API of CCoeEnv to free all resources used by the font.\n |
|
419 */ |
|
420 CMenu1MessageControl::~CMenu1MessageControl() |
|
421 { |
|
422 iCoeEnv->ReleaseScreenFont(iFont); |
|
423 //delete iPeriodic; |
|
424 } |
|
425 |
|
426 /** |
|
427 Auxiliary Function to a set a new font.\n |
|
428 */ |
|
429 void CMenu1MessageControl::SetFontL(const TFontSpec& aFontSpec) |
|
430 { |
|
431 CFbsFont* font=iCoeEnv->CreateScreenFontL(aFontSpec); |
|
432 iCoeEnv->ReleaseScreenFont(iFont); // after previous line succeeds |
|
433 iFont=font; |
|
434 iFontSpec=aFontSpec; |
|
435 } |
|
436 |
|
437 /** |
|
438 Auxiliary Function to change the font style.\n |
|
439 */ |
|
440 void CMenu1MessageControl::ToggleFontStyleL(TMessageControlFontStyle aStyleElement) |
|
441 { |
|
442 TFontSpec spec=iFontSpec; |
|
443 TBool doSet=EFalse; |
|
444 switch (aStyleElement) |
|
445 { |
|
446 case EStyleElementBold: |
|
447 spec.iFontStyle.SetStrokeWeight(spec.iFontStyle.StrokeWeight()? EStrokeWeightNormal: EStrokeWeightBold); |
|
448 doSet=ETrue; |
|
449 break; |
|
450 case EStyleElementItalic: |
|
451 spec.iFontStyle.SetPosture(spec.iFontStyle.Posture()? EPostureUpright: EPostureItalic); |
|
452 doSet=ETrue; |
|
453 break; |
|
454 case EStyleElementUnderline: |
|
455 iFontUnderline=(iFontUnderline? EUnderlineOff: EUnderlineOn); |
|
456 break; |
|
457 case EStyleElementStrikethrough: |
|
458 iFontStrikethrough=(iFontStrikethrough? EStrikethroughOff: EStrikethroughOn); |
|
459 } |
|
460 if (doSet) |
|
461 SetFontL(spec); // otherwise change effective at Draw time |
|
462 DrawMessageNow(); |
|
463 } |
|
464 |
|
465 /** |
|
466 Handles Pointer events.\n |
|
467 Just logs that a pointer events has happend and redraws the window.\n |
|
468 */ |
|
469 void CMenu1MessageControl::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
470 { |
|
471 iMessage.Format(_L8("Pointer event %d at (%d,%d)"),aPointerEvent.iType,aPointerEvent.iPosition.iX,aPointerEvent.iPosition.iY); |
|
472 DrawMessageNow(); |
|
473 } |
|
474 |
|
475 /** |
|
476 Responds to focus change.\n |
|
477 This function is called whenever a control gains or loses focus\n |
|
478 as a result of a call to SetFocus().\n |
|
479 */ |
|
480 void CMenu1MessageControl::FocusChanged(TDrawNow aDrawNow) |
|
481 { |
|
482 if (aDrawNow) |
|
483 { |
|
484 ActivateGc(); |
|
485 DrawBorder(); |
|
486 DeactivateGc(); |
|
487 } |
|
488 } |
|
489 |
|
490 /** |
|
491 Draws a border around the window CMessageControl owns.\n |
|
492 */ |
|
493 void CMenu1MessageControl::DrawBorder() const |
|
494 { |
|
495 CWindowGc& gc=SystemGc(); |
|
496 TRect rect=Rect(); |
|
497 gc.DrawRect(rect); |
|
498 if (!IsFocused()) |
|
499 gc.SetPenColor(KRgbWhite); |
|
500 rect.Shrink(1,1); |
|
501 gc.DrawRect(rect); |
|
502 rect.Shrink(1,1); |
|
503 gc.DrawRect(rect); |
|
504 } |
|
505 |
|
506 /** |
|
507 Draws border and display a message in the window CMenu1MessageControl owns.\n |
|
508 */ |
|
509 void CMenu1MessageControl::Draw(const TRect& /*aRect*/) const |
|
510 { |
|
511 DrawBorder(); |
|
512 DrawMessage(); |
|
513 } |
|
514 |
|
515 /** |
|
516 Displays a message stored in iMessage centered both vertically and horisontally.\n |
|
517 */ |
|
518 void CMenu1MessageControl::DrawMessage() const |
|
519 { |
|
520 TRect rect=Rect(); |
|
521 rect.Shrink(3,3); |
|
522 TInt ascent=(rect.iBr.iY-rect.iTl.iY-iFont->HeightInPixels())/2 + iFont->AscentInPixels(); |
|
523 CWindowGc& gc=SystemGc(); |
|
524 gc.SetPenColor(KRgbBlack); |
|
525 gc.UseFont(iFont); |
|
526 if (iFontUnderline) |
|
527 gc.SetUnderlineStyle(iFontUnderline); |
|
528 if (iFontStrikethrough) |
|
529 gc.SetStrikethroughStyle(iFontStrikethrough); |
|
530 gc.SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
531 #if !defined(_UNICODE) |
|
532 gc.DrawText(iMessage,rect,ascent,CGraphicsContext::ECenter); |
|
533 #else |
|
534 TBuf<40> text; |
|
535 text.Copy(iMessage); |
|
536 gc.DrawText(text,rect,ascent,CGraphicsContext::ECenter); |
|
537 #endif |
|
538 } |
|
539 |
|
540 /** |
|
541 Displays a message stored in iMessage, centered both vertically and horisontally.\n |
|
542 Draw the message as soon as possible.\n |
|
543 */ |
|
544 void CMenu1MessageControl::DrawMessageNow() const |
|
545 { |
|
546 ActivateGc(); |
|
547 DrawMessage(); |
|
548 DeactivateGc(); |
|
549 } |
|
550 |
|
551 /** |
|
552 Changed the message displayed in the window.\n |
|
553 */ |
|
554 void CMenu1MessageControl::SetMessage(const TDesC8& aMessage) |
|
555 { |
|
556 iMessage=aMessage; |
|
557 DrawMessageNow(); |
|
558 } |
|
559 |
|
560 /** |
|
561 The method is an override from CCoeControl.\n |
|
562 The function is called to handle the key events. It handles the following key events.\n |
|
563 1. Shift + KeyLeft Arrow Key Event.\n |
|
564 2. Shift + KeyRight Arrow Key Event.\n |
|
565 3. Shift + KeyDown Arrow Key Event.\n |
|
566 4. Shift + KeyUp Arrow Key Event.\n |
|
567 |
|
568 */ |
|
569 TKeyResponse CMenu1MessageControl::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) |
|
570 { |
|
571 if (aType!=EEventKey) |
|
572 return(EKeyWasConsumed); |
|
573 TInt modifiers=aKeyEvent.iModifiers; |
|
574 TInt code=aKeyEvent.iCode; |
|
575 iMessage.Format(_L8("Key 0x%x, modifier 0x%x"),code,modifiers); |
|
576 DrawMessageNow(); |
|
577 if ((modifiers&EAllStdModifiers)==(EModifierShift|EModifierCtrl)) |
|
578 { |
|
579 TPoint pos=Position(); |
|
580 switch (code) |
|
581 { |
|
582 case EKeyLeftArrow: |
|
583 pos.iX--; |
|
584 break; |
|
585 case EKeyRightArrow: |
|
586 pos.iX++; |
|
587 break; |
|
588 case EKeyUpArrow: |
|
589 pos.iY--; |
|
590 break; |
|
591 case EKeyDownArrow: |
|
592 pos.iY++; |
|
593 break; |
|
594 default: |
|
595 break; |
|
596 } |
|
597 if (pos != Position()) |
|
598 { |
|
599 SetPosition(pos); |
|
600 } |
|
601 } |
|
602 return(EKeyWasConsumed); |
|
603 } |
|
604 |
|
605 |
|
606 /** |
|
607 Moves the window x steps horizontally and y steps vertically.\n |
|
608 */ |
|
609 void CMenu1MessageControl::MoveWindow(TInt aStepX, TInt aStepY) |
|
610 { |
|
611 TPoint pos=Position(); |
|
612 pos.iX += aStepX; |
|
613 pos.iY += aStepY; |
|
614 |
|
615 SetPosition(pos); |
|
616 |
|
617 } |
|
618 /* |
|
619 TInt CMenu1MessageControl::Execute(TAny* aControl) |
|
620 { |
|
621 CMenu1MessageControl* theControl = (CMenu1MessageControl*)aControl; |
|
622 return theControl->DoExecute(); |
|
623 } |
|
624 |
|
625 TInt CMenu1MessageControl::DoExecute() |
|
626 { |
|
627 iNumAttempt++; |
|
628 switch(iNumAttempt) |
|
629 { |
|
630 case 1: |
|
631 iPeriodic->Cancel(); |
|
632 return 1; |
|
633 break; |
|
634 } |
|
635 |
|
636 return 0; |
|
637 } |
|
638 */ |
|
639 |
|
640 // |
|
641 // class CTrivialWindow |
|
642 // |
|
643 |
|
644 /** |
|
645 Constructs a CTrivialWindow.\n |
|
646 */ |
|
647 void CTrivialWindow::ConstructL(const TPoint& aPoint,const TSize& aSize) |
|
648 { |
|
649 CreateWindowL(); |
|
650 SetExtent(aPoint,aSize); |
|
651 Window().SetShadowHeight(4); |
|
652 ActivateL(); |
|
653 } |
|
654 |
|
655 void CTrivialWindow::Draw(const TRect& /*aRect*/) const |
|
656 { |
|
657 CWindowGc& gc=SystemGc(); |
|
658 gc.SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
659 gc.DrawRect(Rect()); |
|
660 } |
|
661 |
|
662 |
|
663 // |
|
664 // class CTestAppUi |
|
665 // |
|
666 |
|
667 |
|
668 /** |
|
669 Destructor of CTestMenu1AppUi.\n |
|
670 */ |
|
671 |
|
672 CTestMenu1AppUi::~CTestMenu1AppUi() |
|
673 { |
|
674 RemoveFromStack(iMessageControl); |
|
675 delete(iMessageControl); |
|
676 if (!iWindows) |
|
677 return; |
|
678 TInt i=iWindows->Count(); |
|
679 while (i--) |
|
680 delete((*iWindows)[i]); |
|
681 delete(iWindows); |
|
682 delete iTimer; |
|
683 } |
|
684 |
|
685 void CTestMenu1AppUi::DoAddWindowL(CTrivialWindow* aWindow,const TPoint& aPoint,const TSize& aSize) |
|
686 { |
|
687 aWindow->ConstructL(aPoint,aSize); |
|
688 iWindows->AppendL(aWindow); |
|
689 } |
|
690 |
|
691 /** |
|
692 @SYMTestCaseID UIF-TMenu1Step-AddWindowL |
|
693 |
|
694 @SYMPREQ PREQ0000 |
|
695 |
|
696 @SYMTestPriority High |
|
697 |
|
698 @SYMTestStatus Implemented |
|
699 |
|
700 @SYMTestActions Adds a window to the display |
|
701 |
|
702 @SYMTestExpectedResults Window is added. |
|
703 |
|
704 @SYMTestType CIT |
|
705 |
|
706 */ |
|
707 void CTestMenu1AppUi::AddWindowL() |
|
708 { |
|
709 TInt offset=iWindows->Count()*5; |
|
710 TSize size(40,40); |
|
711 TPoint pos(640-40-offset,offset); |
|
712 CTrivialWindow* window=new(ELeave) CTrivialWindow; |
|
713 TRAPD(err,DoAddWindowL(window,pos,size)); |
|
714 if (err) |
|
715 { |
|
716 delete(window); |
|
717 User::Leave(err); |
|
718 } |
|
719 } |
|
720 |
|
721 /** |
|
722 @SYMTestCaseID UIF-TMenu1Step-RemoveWindow |
|
723 |
|
724 @SYMPREQ PREQ0000 |
|
725 |
|
726 @SYMTestPriority High |
|
727 |
|
728 @SYMTestStatus Implemented |
|
729 |
|
730 @SYMTestActions Removes a window from the display |
|
731 |
|
732 @SYMTestExpectedResults Window is removed. |
|
733 |
|
734 @SYMTestType CIT |
|
735 |
|
736 */ |
|
737 void CTestMenu1AppUi::RemoveWindow() |
|
738 { |
|
739 TInt i=iWindows->Count(); |
|
740 if (i--) |
|
741 { |
|
742 delete((*iWindows)[i]); |
|
743 iWindows->Delete(i); |
|
744 } |
|
745 } |
|
746 |
|
747 /** |
|
748 @SYMTestCaseID UIF-TMenu1Step-TestColorOverridesL |
|
749 |
|
750 @SYMPREQ PREQ0000 |
|
751 |
|
752 @SYMTestPriority High |
|
753 |
|
754 @SYMTestStatus Implemented |
|
755 |
|
756 @SYMTestActions Tests that it possible to override the current colour of a control. |
|
757 |
|
758 @SYMTestExpectedResults The function doesn't panic by calling User::Invariant (IMHO test code should not be allowed to panic. Better to fail the test. JohanG) |
|
759 |
|
760 @SYMTestType CIT |
|
761 |
|
762 */ |
|
763 void CTestMenu1AppUi::TestColorOverridesL() |
|
764 { |
|
765 CCoeControl* ctrl=new(ELeave) CCoeControl; |
|
766 CleanupStack::PushL(ctrl); |
|
767 TRgb color=KRgbDarkYellow; |
|
768 if (ctrl->GetColor(0,color)) |
|
769 User::Invariant(); |
|
770 ctrl->OverrideColorL(0,KRgbBlack); |
|
771 if (!ctrl->GetColor(0,color)) |
|
772 User::Invariant(); |
|
773 if (color!=KRgbBlack) |
|
774 User::Invariant(); |
|
775 if (ctrl->GetColor(3,color)) |
|
776 User::Invariant(); |
|
777 ctrl->OverrideColorL(6,KRgbMagenta); |
|
778 ctrl->OverrideColorL(5,KRgbGreen); |
|
779 if (!ctrl->GetColor(5,color)) |
|
780 User::Invariant(); |
|
781 if (color!=KRgbGreen) |
|
782 User::Invariant(); |
|
783 if (!ctrl->GetColor(6,color)) |
|
784 User::Invariant(); |
|
785 if (color!=KRgbMagenta) |
|
786 User::Invariant(); |
|
787 CleanupStack::PopAndDestroy(); // ctrl |
|
788 iMessageControl->SetMessage(_L8("passed tests")); |
|
789 } |
|
790 |
|
791 _LIT(KWavName1,"C:\\system\\systemsounds\\message.wav"); |
|
792 _LIT(KWavName2,"C:\\system\\systemsounds\\ring.wav"); |
|
793 |
|
794 const TUid KTestSoundType1={4567}; |
|
795 const TUid KTestSoundType2={4568}; |
|
796 const TUid KTestSoundType3={4569}; |
|
797 const TUid KTestSoundType4={4570}; |
|
798 |
|
799 /** |
|
800 Sets up the sound environment.\n |
|
801 */ |
|
802 LOCAL_C void SetupSoundsL(const CCoeEnv& aEnv) |
|
803 { |
|
804 // TFileName drv; |
|
805 // Dll::FileName(drv); |
|
806 TBaSystemSoundInfo info; |
|
807 info.iVolume=65530; |
|
808 |
|
809 info.iType=TBaSystemSoundType(KTestSoundType1); |
|
810 info.iPriority=100; |
|
811 TFileName name=KWavName1(); |
|
812 // name.Insert(0,drv.Left(1)); // allow sound files on the same drive as the test code |
|
813 info.SetFileName(name); |
|
814 BaSystemSound::SetSoundL(aEnv.FsSession(),info); |
|
815 |
|
816 info.iType=TBaSystemSoundType(KTestSoundType2); |
|
817 info.iPriority=100; |
|
818 name=KWavName2(); |
|
819 // name.Insert(0,drv.Left(1)); // allow sound files on the same drive as the test code |
|
820 info.SetFileName(name); |
|
821 BaSystemSound::SetSoundL(aEnv.FsSession(),info); |
|
822 |
|
823 info.iType=TBaSystemSoundType(KTestSoundType4); |
|
824 info.iPriority=180; |
|
825 info.SetFixedSequenceNumber(0); |
|
826 BaSystemSound::SetSoundL(aEnv.FsSession(),info); |
|
827 |
|
828 info.iType=TBaSystemSoundType(KTestSoundType3); |
|
829 info.iPriority=120; |
|
830 TBaSystemSoundInfo::TTone tone(440,TTimeIntervalMicroSeconds32(250000)); |
|
831 info.SetTone(tone); |
|
832 BaSystemSound::SetSoundL(aEnv.FsSession(),info); |
|
833 } |
|
834 |
|
835 /** |
|
836 @SYMTestCaseID UIF-TMenu1Step-DoTestSoundsL |
|
837 |
|
838 @SYMPREQ PREQ0000 |
|
839 |
|
840 @SYMTestPriority High |
|
841 |
|
842 @SYMTestStatus Implemented |
|
843 |
|
844 @SYMTestActions Tests different sounds. This function is never called. Probably because it has nothing to do with menus. |
|
845 |
|
846 @SYMTestExpectedResults Different sounds can be heard. |
|
847 |
|
848 @SYMTestType CIT |
|
849 |
|
850 */ |
|
851 void CTestMenu1AppUi::DoTestSoundsL() |
|
852 { |
|
853 // play each sound in turn |
|
854 TBaSystemSoundType type(KTestSoundType4); |
|
855 CoeSoundPlayer::PlaySound(type); |
|
856 Wait(); |
|
857 type.iMajor=KTestSoundType1; |
|
858 CoeSoundPlayer::PlaySound(type); |
|
859 Wait(); |
|
860 type.iMajor=KTestSoundType2; |
|
861 CoeSoundPlayer::PlaySound(type); |
|
862 Wait(); |
|
863 type.iMajor=KTestSoundType3; |
|
864 CoeSoundPlayer::PlaySound(type,3,TTimeIntervalMicroSeconds32(100000)); |
|
865 Wait(); |
|
866 Wait(); |
|
867 |
|
868 // play then cancel sound 3 |
|
869 type.iMajor=KTestSoundType3; |
|
870 CoeSoundPlayer::PlaySound(type,3,TTimeIntervalMicroSeconds32(200000)); |
|
871 Wait(); |
|
872 CoeSoundPlayer::CancelSound(type); |
|
873 |
|
874 // start 1, queue 2 then cancel them both |
|
875 type.iMajor=KTestSoundType1; |
|
876 CoeSoundPlayer::PlaySound(type); |
|
877 type.iMajor=KTestSoundType2; |
|
878 CoeSoundPlayer::PlaySound(type); |
|
879 Wait(); |
|
880 CoeSoundPlayer::CancelSound(type); |
|
881 |
|
882 // start 2 then interrupt it with 1 |
|
883 type.iMajor=KTestSoundType2; |
|
884 CoeSoundPlayer::PlaySound(type); |
|
885 type.iMajor=KTestSoundType1; |
|
886 CoeSoundPlayer::PlaySoundNow(type,CoeSoundPlayer::ENoRepeat,TTimeIntervalMicroSeconds32(0)); |
|
887 Wait(); |
|
888 |
|
889 // interrupt this with the higher priority sound 3 |
|
890 type.iMajor=KTestSoundType3; |
|
891 CoeSoundPlayer::PlaySound(type,3,100000); |
|
892 Wait(); |
|
893 } |
|
894 |
|
895 /** |
|
896 Sets up sound environment and calls the test code.\n |
|
897 N.B. Function never called.\n |
|
898 */ |
|
899 void CTestMenu1AppUi::TestPlaySoundL() |
|
900 { |
|
901 SetupSoundsL(*iCoeEnv); |
|
902 DoTestSoundsL(); |
|
903 } |
|
904 |
|
905 /** |
|
906 Sets the timer to 10 sec.\n |
|
907 */ |
|
908 void CTestMenu1AppUi::Wait() |
|
909 { |
|
910 iTimer->Start(10000000,10000000,TCallBack(TimerCallBack,this)); |
|
911 CActiveScheduler::Start(); |
|
912 } |
|
913 |
|
914 /** |
|
915 Callback that is called when timer expires.\n |
|
916 */ |
|
917 TInt CTestMenu1AppUi::TimerCallBack(TAny* aSelf) |
|
918 { // static |
|
919 REINTERPRET_CAST(CTestMenu1AppUi*,aSelf)->iTimer->Cancel(); |
|
920 CActiveScheduler::Stop(); |
|
921 return 0; |
|
922 } |
|
923 |
|
924 /** |
|
925 Handles different menu selections.\n |
|
926 */ |
|
927 void CTestMenu1AppUi::MenuSelectionMadeL(TMenuCommand aSelection) |
|
928 { |
|
929 switch (aSelection) |
|
930 { |
|
931 case EMenuCommandBold: |
|
932 case EMenuCommandItalic: |
|
933 case EMenuCommandUnderline: |
|
934 case EMenuCommandStrikethrough: |
|
935 { |
|
936 TRAPD(ret, iMessageControl->ToggleFontStyleL((TMessageControlFontStyle)aSelection)); |
|
937 TEST(ret == KErrNone); |
|
938 break; |
|
939 } |
|
940 case EMenuCommandDrag: |
|
941 { |
|
942 TRAPD(ret, iMessageControl->ToggleDragState()); |
|
943 TEST(ret == KErrNone); |
|
944 break; |
|
945 } |
|
946 case EMenuCommandExit: |
|
947 { |
|
948 iMessageControl->SetMessage(_L8("About to exit...")); |
|
949 iCoeEnv->Flush(200000); |
|
950 CBaActiveScheduler::Exit(); |
|
951 break; |
|
952 } |
|
953 case EMenuCommandAddWindow: |
|
954 { |
|
955 TRAPD(ret, AddWindowL()); |
|
956 TEST(ret == KErrNone); |
|
957 break; |
|
958 } |
|
959 case EMenuCommandRemoveWindow: |
|
960 { |
|
961 TRAPD(ret, RemoveWindow()); |
|
962 TEST(ret == KErrNone); |
|
963 break; |
|
964 } |
|
965 case EMenuCommandColor: |
|
966 { |
|
967 TRAPD(ret, TestColorOverridesL()); |
|
968 TEST(ret == KErrNone); |
|
969 break; |
|
970 } |
|
971 case EMenuCommandPlaySound: |
|
972 { |
|
973 TRAPD(ret, TestPlaySoundL()); |
|
974 TEST(ret == KErrNone); |
|
975 break; |
|
976 } |
|
977 default: |
|
978 break; |
|
979 } |
|
980 } |
|
981 |
|
982 /** |
|
983 Sets the message in the window to aMessageParameters but never returns a reponse.\n |
|
984 */ |
|
985 MCoeMessageObserver::TMessageResponse CTestMenu1AppUi::HandleMessageL(TUint32, TUid, const TDesC8& aMessageParameters) |
|
986 { |
|
987 iMessageControl->SetMessage(aMessageParameters); |
|
988 return EMessageNotHandled; |
|
989 } |
|
990 |
|
991 /** |
|
992 Handles application specific events.\n |
|
993 In this case it adds/removes a window.\n |
|
994 A reply message of how many windows there are in the window group is sent back.\n |
|
995 */ |
|
996 void CTestMenu1AppUi::HandleApplicationSpecificEventL(TInt aType,const TWsEvent& aEvent) |
|
997 { |
|
998 TInt senderWgId=(*(TInt*)aEvent.EventData()); |
|
999 TInt count=iWindows->Count(); |
|
1000 TMenuAsiEventReply reply=EReplyWindowsCounted; |
|
1001 switch (aType) |
|
1002 { |
|
1003 case ESendCountWindows: |
|
1004 break; |
|
1005 case ESendAddWindow: |
|
1006 reply=EReplyWindowAdded; |
|
1007 TRAPD(err,AddWindowL()); |
|
1008 if (err) |
|
1009 reply=EReplyFailedToAddWindow; |
|
1010 break; |
|
1011 case ESendRemoveWindow: |
|
1012 if (!count) |
|
1013 reply=EReplyNoWindowToRemove; |
|
1014 else |
|
1015 { |
|
1016 RemoveWindow(); |
|
1017 reply=EReplyWindowRemoved; |
|
1018 } |
|
1019 break; |
|
1020 default: |
|
1021 break; |
|
1022 } |
|
1023 TWsEvent data; |
|
1024 data.SetType(reply); |
|
1025 *(TInt*)data.EventData()=count; |
|
1026 iCoeEnv->WsSession().SendEventToWindowGroup(senderWgId,data); |
|
1027 } |
|
1028 |
|
1029 CTestMenu1AppUi::CTestMenu1AppUi(CTmsTestStep* aStep) : |
|
1030 CTestCoeAppUi(aStep) |
|
1031 {} |
|
1032 |
|
1033 |
|
1034 |
|
1035 void CTestMenu1AppUi::ConstructL() |
|
1036 { |
|
1037 CTestCoeAppUi::ConstructL(); |
|
1038 |
|
1039 iMessageControl=new(ELeave) CMenu1MessageControl; |
|
1040 iMessageControl->ConstructL(); |
|
1041 AddToStackL(iMessageControl); |
|
1042 iMenu=new(ELeave) CTestMenu1; |
|
1043 iMenu->ConstructL(this,this); |
|
1044 AddToStackL(iMenu,ECoeStackPriorityMenu,ECoeStackFlagRefusesFocus|ECoeStackFlagOwnershipTransfered); |
|
1045 iWindows=new(ELeave) CArrayFixFlat<CTrivialWindow*>(4); |
|
1046 iCoeEnv->RootWin().SetName(TMenu1GroupName); |
|
1047 iTimer=CPeriodic::NewL(0); |
|
1048 |
|
1049 AutoTestManager().StartAutoTest(); |
|
1050 |
|
1051 } |
|
1052 |
|
1053 |
|
1054 /** |
|
1055 The method is an override from CTestCoeAppUi.\n |
|
1056 This function is called asynchronously by RunL function of the |
|
1057 AutotestManager after previous test case is executed.\n |
|
1058 */ |
|
1059 void CTestMenu1AppUi::RunTestStepL(TInt aNextStep) |
|
1060 { |
|
1061 |
|
1062 User::After(TTimeIntervalMicroSeconds32(1000000)); |
|
1063 |
|
1064 |
|
1065 switch(aNextStep) |
|
1066 { |
|
1067 case 1: //toggle bold |
|
1068 INFO_PRINTF1(_L("toggle bold")); |
|
1069 iMenu->CreateMenuL(); |
|
1070 break; |
|
1071 case 2: |
|
1072 iMenu->ReportSelectionMadeL(); |
|
1073 iMenu->CloseMenu(); |
|
1074 break; |
|
1075 |
|
1076 case 3: //toggle italic |
|
1077 INFO_PRINTF1(_L("toggle italic")); |
|
1078 iMenu->CreateMenuL(); |
|
1079 break; |
|
1080 case 4: |
|
1081 iMenu->HighlightTo(iMenu->iItemSelected+1); |
|
1082 break; |
|
1083 case 5: |
|
1084 iMenu->ReportSelectionMadeL(); |
|
1085 iMenu->CloseMenu(); |
|
1086 break; |
|
1087 |
|
1088 case 6: //toggle underline |
|
1089 INFO_PRINTF1(_L("toggle underline")); |
|
1090 iMenu->CreateMenuL(); |
|
1091 break; |
|
1092 case 7: |
|
1093 iMenu->HighlightTo(iMenu->iItemSelected+1); |
|
1094 break; |
|
1095 case 8: |
|
1096 iMenu->ReportSelectionMadeL(); |
|
1097 iMenu->CloseMenu(); |
|
1098 break; |
|
1099 |
|
1100 case 9://toggle strikethrough |
|
1101 INFO_PRINTF1(_L("toggle strikethrough\n")); |
|
1102 iMenu->CreateMenuL(); |
|
1103 break; |
|
1104 case 10: |
|
1105 iMenu->HighlightTo(iMenu->iItemSelected+1); |
|
1106 break; |
|
1107 case 11: |
|
1108 iMenu->ReportSelectionMadeL(); |
|
1109 iMenu->CloseMenu(); |
|
1110 break; |
|
1111 |
|
1112 case 12://add window |
|
1113 SetTestStepID(_L("UIF-TMenu1Step-AddWindowL")); |
|
1114 INFO_PRINTF1(_L("add window")); |
|
1115 iMenu->CreateMenuL(); |
|
1116 RecordTestResultL(); |
|
1117 break; |
|
1118 case 13: |
|
1119 iMenu->HighlightTo(iMenu->iItemSelected+1); |
|
1120 break; |
|
1121 case 14: |
|
1122 iMenu->ReportSelectionMadeL(); |
|
1123 iMenu->CloseMenu(); |
|
1124 break; |
|
1125 |
|
1126 case 15: //remove window |
|
1127 SetTestStepID(_L("UIF-TMenu1Step-RemoveWindow")); |
|
1128 INFO_PRINTF1(_L("remove window\n")); |
|
1129 iMenu->CreateMenuL(); |
|
1130 RecordTestResultL(); |
|
1131 break; |
|
1132 case 16: |
|
1133 iMenu->HighlightTo(iMenu->iItemSelected+1); |
|
1134 break; |
|
1135 case 17: |
|
1136 iMenu->ReportSelectionMadeL(); |
|
1137 iMenu->CloseMenu(); |
|
1138 break; |
|
1139 |
|
1140 case 18: //toggle drag enablement |
|
1141 INFO_PRINTF1(_L("toggle drag enablement")); |
|
1142 iMenu->CreateMenuL(); |
|
1143 break; |
|
1144 case 19: |
|
1145 iMenu->HighlightTo(iMenu->iItemSelected+1); |
|
1146 break; |
|
1147 case 20: |
|
1148 iMenu->ReportSelectionMadeL(); |
|
1149 iMenu->CloseMenu(); |
|
1150 break; |
|
1151 |
|
1152 case 21: //overide colours |
|
1153 SetTestStepID(_L("UIF-TMenu1Step-TestColorOverridesL")); |
|
1154 INFO_PRINTF1(_L("overide colours")); |
|
1155 iMenu->CreateMenuL(); |
|
1156 RecordTestResultL(); |
|
1157 CloseTMSGraphicsStep(); |
|
1158 break; |
|
1159 case 22: |
|
1160 iMenu->HighlightTo(iMenu->iItemSelected+1); |
|
1161 break; |
|
1162 case 23: |
|
1163 iMenu->ReportSelectionMadeL(); |
|
1164 iMenu->CloseMenu(); |
|
1165 break; |
|
1166 |
|
1167 /* case 24: //play sound |
|
1168 iMenu->CreateMenuL(); |
|
1169 break; |
|
1170 case 25: |
|
1171 iMenu->HighlightTo(iMenu->iItemSelected+1); |
|
1172 break; |
|
1173 case 26: |
|
1174 iMenu->ReportSelectionMadeL(); |
|
1175 iMenu->CloseMenu(); |
|
1176 break; |
|
1177 */ |
|
1178 case 30: case 31: case 32: case 33: case 34: |
|
1179 iMessageControl->MoveWindow(5, 0); |
|
1180 INFO_PRINTF1(_L("Move the window to right")); |
|
1181 break; |
|
1182 |
|
1183 case 35: case 36: case 37: case 38: case 39: |
|
1184 iMessageControl->MoveWindow(-5, 0); |
|
1185 INFO_PRINTF1(_L("Move the window to left")); |
|
1186 break; |
|
1187 |
|
1188 case 40: case 41: case 42: case 43: case 44: |
|
1189 iMessageControl->MoveWindow(0, 5); |
|
1190 INFO_PRINTF1(_L("Move the window to down")); |
|
1191 break; |
|
1192 |
|
1193 case 45: case 46: case 47: case 48: case 49: |
|
1194 iMessageControl->MoveWindow(0, -5); |
|
1195 INFO_PRINTF1(_L("Move the window to up")); |
|
1196 break; |
|
1197 |
|
1198 case 50: |
|
1199 AutoTestManager().FinishAllTestCases(CAutoTestManager::EPass); |
|
1200 |
|
1201 break; |
|
1202 } |
|
1203 } |
|
1204 |
|
1205 // |
|
1206 // Main |
|
1207 // |
|
1208 |
|
1209 /** |
|
1210 Completes the construction of the Control Environment(CCoeEnv object).\n |
|
1211 Instantiates the CCone0TestAppUi class which serves as a AppUi class.\n |
|
1212 Sets the CCone0TestAppUi object as the application's user interface object.\n |
|
1213 Invokes the second phase constructor of the application's UI.\n |
|
1214 |
|
1215 */ |
|
1216 void CTMenu1Step::ConstructAppL(CCoeEnv* aCoe) |
|
1217 { // runs inside a TRAP harness |
|
1218 aCoe->ConstructL(); |
|
1219 CTestMenu1AppUi* appUi=new(ELeave) CTestMenu1AppUi(this); |
|
1220 aCoe->SetAppUi(appUi); |
|
1221 appUi->ConstructL(); |
|
1222 } |
|
1223 |
|
1224 |
|
1225 CTMenu1Step::~CTMenu1Step() |
|
1226 { |
|
1227 } |
|
1228 |
|
1229 |
|
1230 CTMenu1Step::CTMenu1Step() |
|
1231 { |
|
1232 SetTestStepName(KTMenu1Step); |
|
1233 } |
|
1234 |
|
1235 |
|
1236 TVerdict CTMenu1Step::doTestStepL()// main function called by E32 |
|
1237 { |
|
1238 INFO_PRINTF1(_L("Test Started")); |
|
1239 |
|
1240 __UHEAP_MARK; |
|
1241 |
|
1242 CCoeEnv* coe=new CCoeEnv; |
|
1243 TRAPD(err,ConstructAppL(coe)); |
|
1244 if (!err) |
|
1245 coe->ExecuteD(); |
|
1246 |
|
1247 __UHEAP_MARKEND; |
|
1248 |
|
1249 INFO_PRINTF1(_L("Test Finished")); |
|
1250 return TestStepResult(); |
|
1251 } |
|
1252 |
|
1253 |
|
1254 |
|
1255 |