|
1 // Copyright (c) 2006-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 @test |
|
19 @internalComponent - Internal Symbian test code |
|
20 */ |
|
21 |
|
22 #if !defined(__TMENU1STEP_H__) |
|
23 #define __TMENU1STEP_H__ |
|
24 |
|
25 #include <test/testexecutestepbase.h> |
|
26 #include "TMenuTestServer.h" |
|
27 #include "appfwk_test_AppUi.h" |
|
28 #include "TMENUASI.H" |
|
29 |
|
30 |
|
31 enum TMenuCommand |
|
32 { |
|
33 EMenuCommandBold=EStyleElementBold, |
|
34 EMenuCommandItalic=EStyleElementItalic, |
|
35 EMenuCommandUnderline=EStyleElementUnderline, |
|
36 EMenuCommandStrikethrough=EStyleElementStrikethrough, |
|
37 EMenuCommandAddWindow, |
|
38 EMenuCommandRemoveWindow, |
|
39 EMenuCommandDrag, |
|
40 EMenuCommandColor, |
|
41 EMenuCommandPlaySound, |
|
42 EMenuCommandExit |
|
43 }; |
|
44 |
|
45 |
|
46 |
|
47 class CTMenu1Step : public CTmsTestStep |
|
48 { |
|
49 public: |
|
50 CTMenu1Step(); |
|
51 ~CTMenu1Step(); |
|
52 virtual TVerdict doTestStepL(); |
|
53 void ConstructAppL(CCoeEnv* aCoe); |
|
54 }; |
|
55 |
|
56 |
|
57 |
|
58 class MTestMenu1MenuObserver |
|
59 { |
|
60 public: |
|
61 virtual void MenuSelectionMadeL(TMenuCommand aSelection)=0; |
|
62 }; |
|
63 |
|
64 |
|
65 |
|
66 class TSimpleMenuItem |
|
67 { |
|
68 private: |
|
69 enum { ENominalTextLength=80 }; |
|
70 public: |
|
71 TMenuCommand iCommand; |
|
72 TBuf<ENominalTextLength> iText; // less than this actually stored |
|
73 public: |
|
74 TInt RealLengthOfData() const; |
|
75 }; |
|
76 |
|
77 |
|
78 |
|
79 class CTestMenu1 : public CCoeControl |
|
80 { |
|
81 public: |
|
82 ~CTestMenu1(); |
|
83 void ConstructL(MTestMenu1MenuObserver* aObserver,CCoeAppUi* aStack); |
|
84 void CreateMenuL(); |
|
85 void ReportSelectionMadeL(); |
|
86 void CloseMenu(); |
|
87 void HighlightTo(TInt aNewItemSelected); |
|
88 TInt iItemSelected; |
|
89 private: // framework |
|
90 TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType); |
|
91 void HandlePointerEventL(const TPointerEvent& aPointerEvent); |
|
92 void Draw(const TRect& aRect) const; |
|
93 private: // new functions |
|
94 void InitializeHotKeyCommands(); |
|
95 void CreateFontL(); |
|
96 void LoadDataL(); |
|
97 void DoLoadDataL(); |
|
98 void FreeData(); |
|
99 void AddMenuItemL(TMenuCommand aCommand,const TDesC& aText); |
|
100 void PrepareGcForDrawingItems() const; |
|
101 void DrawItem(TInt aItem,TInt aHighlight) const; |
|
102 void CalculateSize(TSize& aSize); |
|
103 private: |
|
104 enum { EBorderWidth=2 }; |
|
105 MTestMenu1MenuObserver* iObserver; |
|
106 CFont* iFont; |
|
107 CCoeAppUi* iStack; |
|
108 TBool iDisplayed; |
|
109 TMenuCommand iHotKeyCommand[27]; |
|
110 CArrayVarFlat<TSimpleMenuItem>* iItemArray; |
|
111 }; |
|
112 |
|
113 |
|
114 |
|
115 class CMenu1MessageControl : public CCoeControl |
|
116 { |
|
117 public: |
|
118 ~CMenu1MessageControl(); |
|
119 void ConstructL(); |
|
120 void ToggleFontStyleL(TMessageControlFontStyle aStyleElement); |
|
121 void ToggleDragState(); |
|
122 void SetMessage(const TDesC8& aMessage); |
|
123 //static TInt Execute(TAny* aApplication); |
|
124 //TInt DoExecute(); |
|
125 void MoveWindow(TInt aStepX, TInt aStepY); |
|
126 |
|
127 private: // framework |
|
128 TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType); |
|
129 void HandlePointerEventL(const TPointerEvent& aPointerEvent); |
|
130 void Draw(const TRect& aRect) const; |
|
131 void FocusChanged(TDrawNow aDrawNow); |
|
132 private: // new functions |
|
133 void DrawBorder() const; |
|
134 void SetFontL(const TFontSpec& aFontSpec); |
|
135 void DrawMessage() const; |
|
136 void DrawMessageNow() const; |
|
137 private: |
|
138 TBuf8<40> iMessage; |
|
139 TFontSpec iFontSpec; |
|
140 TFontUnderline iFontUnderline; |
|
141 TFontStrikethrough iFontStrikethrough; |
|
142 CFbsFont* iFont; |
|
143 TBool iDragsEnabled; |
|
144 }; |
|
145 |
|
146 |
|
147 |
|
148 class CTrivialWindow : public CCoeControl |
|
149 { |
|
150 public: |
|
151 void ConstructL(const TPoint& aPoint,const TSize& aSize); |
|
152 private: |
|
153 void Draw(const TRect& aRect) const; |
|
154 }; |
|
155 |
|
156 |
|
157 |
|
158 class CTestMenu1AppUi : public CTestCoeAppUi, public MCoeMessageObserver, public MTestMenu1MenuObserver |
|
159 { |
|
160 public: |
|
161 CTestMenu1AppUi(CTmsTestStep* aStep); |
|
162 ~CTestMenu1AppUi(); |
|
163 void ConstructL(); |
|
164 private: // from MTestMenu1MenuObserver |
|
165 void MenuSelectionMadeL(TMenuCommand aSelection); |
|
166 private: // from CCoeAppUi |
|
167 void HandleApplicationSpecificEventL(TInt aType,const TWsEvent& aEvent); |
|
168 private: // from MCoeMessageObserver |
|
169 MCoeMessageObserver::TMessageResponse HandleMessageL(TUint32 aClientHandleOfTargetWindowGroup, TUid aMessageUid, const TDesC8& aMessageParameters); |
|
170 private: // new functions |
|
171 void AddWindowL(); |
|
172 void RemoveWindow(); |
|
173 void TestColorOverridesL(); |
|
174 void TestPlaySoundL(); |
|
175 void DoTestSoundsL(); |
|
176 void Wait(); |
|
177 static TInt TimerCallBack(TAny* aSelf); |
|
178 void DoAddWindowL(CTrivialWindow* aWindow,const TPoint& aPoint,const TSize& aSize); |
|
179 void RunTestStepL(TInt aNextStep); |
|
180 private: |
|
181 CArrayFixFlat<CTrivialWindow*>* iWindows; |
|
182 CPeriodic* iTimer; |
|
183 public: |
|
184 CMenu1MessageControl* iMessageControl; |
|
185 CTestMenu1* iMenu; |
|
186 }; |
|
187 |
|
188 _LIT(KTMenu1Step,"TMenu1"); |
|
189 |
|
190 #endif |
|
191 |
|
192 |