|
1 /* |
|
2 * Copyright (c) 2010 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: |
|
15 * Header specifying the common test functionality. |
|
16 */ |
|
17 |
|
18 #ifndef TESTAPPBASE_H_ |
|
19 #define TESTAPPBASE_H_ |
|
20 |
|
21 #include <e32base.h> |
|
22 #include <w32std.h> |
|
23 #include <remconcoreapitargetobserver.h> // for volume key handling |
|
24 class CRemConCoreApiTarget; |
|
25 class CRemConInterfaceSelector; |
|
26 |
|
27 #define STR(a) (TText*)L##a |
|
28 |
|
29 // 15 keys are supported. The keys are in this order: |
|
30 // Enter, Up, Down, Left, Right, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 |
|
31 const TInt KSupportedKeysCount = 15; |
|
32 |
|
33 struct TOperationEntry |
|
34 { |
|
35 const TText* text; |
|
36 TInt operation; |
|
37 }; |
|
38 |
|
39 struct TOperationsPage |
|
40 { |
|
41 const TText* pageName; |
|
42 TInt defaultSoftkeyIndex; |
|
43 TOperationEntry mapping[KSupportedKeysCount]; |
|
44 }; |
|
45 |
|
46 // Predefined standard operations |
|
47 const TInt KOperation_None = 0; |
|
48 const TInt KOperation_Exit = 1; |
|
49 const TInt KOperation_PreviousOptionPage = 2; |
|
50 const TInt KOperation_NextOptionPage = 3; |
|
51 const TInt KOperation_NextOption = 4; |
|
52 const TInt KOperation_PreviousOption = 5; |
|
53 const TInt KOperation_ExecuteOption = 6; |
|
54 const TInt KOperation_ToggleHelpVisibility = 7; |
|
55 const TInt KOperation_ToggleHelpTransparency = 8; |
|
56 const TInt KOperation_FirstCustomIndex = 10; // app-specific operations can start here |
|
57 |
|
58 const TUint32 KNullWsHandle = 0xFFFFFFFF; |
|
59 |
|
60 class CTestAppBase : public CActive, private MRemConCoreApiTargetObserver |
|
61 { |
|
62 public: |
|
63 |
|
64 CTestAppBase(TInt aFontSize); |
|
65 |
|
66 ~CTestAppBase(); |
|
67 |
|
68 // inherited from CActive |
|
69 void RunL(); |
|
70 void DoCancel(); |
|
71 |
|
72 protected: |
|
73 |
|
74 virtual void ExecuteOperation(TInt aOperation, |
|
75 const TDesC& aOperationText) = 0; |
|
76 |
|
77 // Subclasses can override this function to take action when the current softkey function has been changed. |
|
78 virtual void SoftkeyFunctionUpdated() |
|
79 { |
|
80 } |
|
81 ; |
|
82 |
|
83 // Subclasses can override this function to override the default key event handling. |
|
84 virtual bool ConsumeKeyEvent(TInt /*aScanCode*/) |
|
85 { |
|
86 return false; |
|
87 } |
|
88 ; |
|
89 |
|
90 void BaseConstructL(const TOperationsPage* aKeyMap, TInt aPageCount); |
|
91 |
|
92 void SetupVolumeKeysL(); |
|
93 |
|
94 void StartMonitoringWindowEvents(); |
|
95 |
|
96 TInt CurrentPageNumber(); |
|
97 |
|
98 TPtrC CurrentPageName(); |
|
99 |
|
100 TPtrC CurrentSoftkeyName(); |
|
101 |
|
102 // Presents a selection list to the user and returns the index of the selected entry. |
|
103 // Synchronous call. |
|
104 // returns -1 if the selection was backed out without making a selection |
|
105 TInt SelectFromListL(TPoint aTopLeft, TSize aSize, |
|
106 const TDesC& aHeaderText, RPointerArray<TDesC>& aSelectionList, |
|
107 TInt aInitialSelectionIndex = 0); |
|
108 |
|
109 // Synchronous call. |
|
110 // returns false if the selection was backed out without making a selection |
|
111 bool SelectDriveL(TPoint aTopLeft, TSize aSize, const TDesC& aHeaderText, |
|
112 TDes& aDrive); |
|
113 |
|
114 // Synchronous call. |
|
115 // returns false if the selection was backed out without making a selection |
|
116 bool SelectFileL(TPoint aTopLeft, TSize aSize, const TDesC& aHeaderText, |
|
117 const TDesC& aDrive, TDes& aFullFilename); |
|
118 |
|
119 // Synchronous call. |
|
120 // returns false if the selection was backed out without making a selection |
|
121 bool SelectFileWithHistoryL(TPoint aTopLeft, TSize aSize, |
|
122 TDes& aFullFilename, const TDesC& aHistoryFilename, |
|
123 TInt aMaxHistoryEntries); |
|
124 |
|
125 // Synchronous call. |
|
126 // returns false if the selection was backed out without making a selection |
|
127 bool SelectIntegerL(TPoint aTopLeft, TSize aSize, |
|
128 const TDesC& aHeaderText, TInt aMin, TInt aMax, TInt& aSelection); // set aSelection to default value |
|
129 |
|
130 // Synchronous call. Returns the scan code of the pressed key. |
|
131 TInt WaitForAnyKey(); |
|
132 |
|
133 const TInt iFontSize; |
|
134 |
|
135 RFs iFs; |
|
136 RWsSession iWs; |
|
137 CWsScreenDevice* iScreenDevice; |
|
138 RWindowGroup* iWindowGroup; |
|
139 CWindowGc* iGc; |
|
140 CFont* iFont; |
|
141 CFbsTypefaceStore* iTypefaceStore; |
|
142 TSize iDisplaySize; |
|
143 RWindow* iSelectionWindow; |
|
144 RWindow* iHelpWindow; |
|
145 |
|
146 private: |
|
147 |
|
148 enum TTestAppPointerEvent |
|
149 { |
|
150 EPointerEvent_None, |
|
151 EPointerEvent_Up, |
|
152 EPointerEvent_Down, |
|
153 EPointerEvent_Left, |
|
154 EPointerEvent_Right, |
|
155 EPointerEvent_Select |
|
156 }; |
|
157 |
|
158 // inherited from MRemConCoreApiTargetObserver |
|
159 void MrccatoCommand(TRemConCoreApiOperationId aOperationId, |
|
160 TRemConCoreApiButtonAction aButtonAct); |
|
161 |
|
162 TInt KeyMapOperation(TInt aIndex, TInt aPage); |
|
163 |
|
164 TPtrC KeyMapText(TInt aIndex, TInt aPage); |
|
165 |
|
166 void IncrementKeymapIndex(TInt& aIndex, TInt aPage); |
|
167 |
|
168 void DecrementKeymapIndex(TInt& aIndex, TInt aPage); |
|
169 |
|
170 void CalculateHelpWindowSize(); |
|
171 |
|
172 void DrawHelpText(); |
|
173 |
|
174 void DoSelectFileL(TPoint aTopRight, TSize aWindowSize, |
|
175 const TDesC& aHeaderText, const TFileName& aDirectory, |
|
176 TInt aDirectoryLevel, TDes& aSelectedDirectory, |
|
177 TDes& aSelectedFilename); |
|
178 |
|
179 void ReadDirectoryEntriesL(const TFileName& aDirectoryName, |
|
180 RPointerArray<TDesC>& aFileNames); |
|
181 |
|
182 void ReadFileHistory(const TDesC& aHistoryFilename); |
|
183 |
|
184 void AddToFileHistory(const TDesC& aFilename, |
|
185 const TDesC& aHistoryFilename, TInt aMaxHistoryEntries); |
|
186 |
|
187 TTestAppPointerEvent CharacterizePointerEvent( |
|
188 TAdvancedPointerEvent& event); |
|
189 |
|
190 const TOperationsPage* iKeyMap; |
|
191 TInt iPageCount; |
|
192 TInt iCurrentPage; |
|
193 TInt iSoftkeyIndex; |
|
194 RPointerArray<HBufC> iFileHistory; |
|
195 |
|
196 CActiveSchedulerWait iWait; |
|
197 |
|
198 TPoint iHelpWindowTopRight; |
|
199 TSize iHelpWindowSize; |
|
200 TInt iHelpWindowColumn1Width; |
|
201 TInt iHelpWindowColumn2Width; |
|
202 bool iHelpActive; |
|
203 bool iHelpSemitransparentBackgroundActive; |
|
204 |
|
205 TPoint iPointerDownPosition; |
|
206 |
|
207 // For volume key support |
|
208 CRemConCoreApiTarget* iCoreTarget; |
|
209 CRemConInterfaceSelector* iInterfaceSelector; |
|
210 }; |
|
211 |
|
212 #endif // TESTAPPBASE_H_ |