|
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 the License "Symbian Foundation License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 |
|
17 |
|
18 /** |
|
19 @file |
|
20 @test |
|
21 @internalComponent - Internal Symbian test code |
|
22 */ |
|
23 |
|
24 |
|
25 #include <eikmenub.h> |
|
26 #include <eikbtgpc.h> |
|
27 #include <eikenv.h> |
|
28 #include <hal.h> |
|
29 |
|
30 #include "appfwk_test_AppUi.h" |
|
31 |
|
32 |
|
33 EXPORT_C void PreallocateHALBuffer() |
|
34 { |
|
35 HAL::SEntry* pE=NULL; |
|
36 TInt entries=0; |
|
37 HAL::GetAll(entries, pE); |
|
38 User::Free(pE); |
|
39 } |
|
40 |
|
41 EXPORT_C void CloseAllPanicWindowsL() |
|
42 { |
|
43 RWsSession ws; |
|
44 User::LeaveIfError(ws.Connect()); |
|
45 |
|
46 TInt wgFocus = ws.GetFocusWindowGroup(); |
|
47 |
|
48 const TUint32 ENullWsHandle = 0xFFFFFFFF; // Events delivered to this handle are thrown away |
|
49 RWindowGroup wg = RWindowGroup(ws); |
|
50 |
|
51 wg.Construct(ENullWsHandle); |
|
52 TInt wgId = wg.Identifier(); |
|
53 |
|
54 TWsEvent event; |
|
55 event.SetType(EEventKey); |
|
56 TKeyEvent *keyEvent = event.Key(); |
|
57 keyEvent->iCode = EKeyEscape; |
|
58 keyEvent->iScanCode = EStdKeyEscape; |
|
59 keyEvent->iModifiers = 0; |
|
60 |
|
61 TInt limit = 0; |
|
62 for(limit = 0; wgFocus != wgId && (limit < 50); limit++) |
|
63 { |
|
64 ws.SendEventToAllWindowGroups(event); |
|
65 wgFocus = ws.GetFocusWindowGroup(); |
|
66 RDebug::Print(_L("CloseAllPanicWindowsL() - EKeyEscape sent to Windows Group")); |
|
67 } |
|
68 |
|
69 // close everything |
|
70 wg.Close(); |
|
71 ws.Close(); |
|
72 } |
|
73 |
|
74 |
|
75 EXPORT_C CAutoTestManager::CAutoTestManager(MAutoTestApp* aAutoTestApp) : |
|
76 CActive(EPriorityIdle), iAutoTestApp(aAutoTestApp) |
|
77 { |
|
78 } |
|
79 |
|
80 |
|
81 EXPORT_C CAutoTestManager::~CAutoTestManager() |
|
82 { |
|
83 Cancel(); |
|
84 } |
|
85 |
|
86 |
|
87 EXPORT_C CAutoTestManager* CAutoTestManager::NewL(MAutoTestApp* aAutoTestApp) |
|
88 { |
|
89 CAutoTestManager *theTestManager=new (ELeave) CAutoTestManager(aAutoTestApp); |
|
90 CActiveScheduler::Add(theTestManager); |
|
91 return theTestManager; |
|
92 } |
|
93 |
|
94 |
|
95 void CAutoTestManager::RunL() |
|
96 { |
|
97 __ASSERT_DEBUG(iAutoTestApp, User::Panic(KPanicNullPointer, KNullPointer)); |
|
98 iAutoTestApp->RunTestStepL(++iNumStep); |
|
99 StartAutoTest(); |
|
100 } |
|
101 |
|
102 |
|
103 void CAutoTestManager::DoCancel() |
|
104 { |
|
105 } |
|
106 |
|
107 |
|
108 /** |
|
109 Init active object and set it active |
|
110 */ |
|
111 EXPORT_C void CAutoTestManager::StartAutoTest() |
|
112 { |
|
113 TRequestStatus *pS=(&iStatus); |
|
114 User::RequestComplete(pS,0); |
|
115 SetActive(); |
|
116 } |
|
117 |
|
118 |
|
119 /** |
|
120 This function must be called after all test cases will be completed |
|
121 */ |
|
122 EXPORT_C void CAutoTestManager::FinishAllTestCases(TTestResult aResult) |
|
123 { |
|
124 iResult = aResult; |
|
125 if(aResult != EPass) |
|
126 { |
|
127 RDebug::Print(_L("\nTest completed with error %d"), aResult); |
|
128 } |
|
129 CCoeEnv::Static()->Flush(); |
|
130 CBaActiveScheduler::Exit(); |
|
131 } |
|
132 |
|
133 |
|
134 /** |
|
135 This function will set the internal test state variable to the user defined state. |
|
136 */ |
|
137 EXPORT_C void CAutoTestManager::SetTestCaseNumber(TInt aNumber) |
|
138 { |
|
139 iNumStep = aNumber; |
|
140 } |
|
141 |
|
142 |
|
143 EXPORT_C CTestCoeAppUi::CTestCoeAppUi(CTestStep* aStep) : |
|
144 iStep(aStep) |
|
145 { |
|
146 } |
|
147 |
|
148 |
|
149 EXPORT_C CTestCoeAppUi::~CTestCoeAppUi() |
|
150 { |
|
151 if(iAutoTestManager) |
|
152 { |
|
153 iAutoTestManager->Cancel(); |
|
154 } |
|
155 delete iAutoTestManager; |
|
156 } |
|
157 |
|
158 |
|
159 /** |
|
160 Read thread local storage read and free thread local storage STL is used for storage Auto attribute, |
|
161 it sets in an export function void ProcessParam(TAny* aParam) |
|
162 */ |
|
163 EXPORT_C void CTestCoeAppUi::ConstructL() |
|
164 { |
|
165 iAutoTestManager = CAutoTestManager::NewL(this); |
|
166 |
|
167 CCoeAppUi::ConstructL(); |
|
168 } |
|
169 |
|
170 |
|
171 EXPORT_C CTestAppUi::CTestAppUi(CTestStep* aStep, const TDesC& aRes, TInt aResourceHotKeysId, TInt aResourceMenuBarId, TInt aResourceToolBarId) : |
|
172 CEikAppUi(), |
|
173 iResourceHotKeysId(aResourceHotKeysId), |
|
174 iResourceMenuBarId(aResourceMenuBarId), |
|
175 iResourceToolBarId(aResourceToolBarId), |
|
176 iStep(aStep) |
|
177 { |
|
178 iRes.Copy(aRes); |
|
179 } |
|
180 |
|
181 |
|
182 EXPORT_C CTestAppUi::~CTestAppUi() |
|
183 { |
|
184 if(iResourceFileFlag) |
|
185 { |
|
186 CCoeEnv::Static()->DeleteResourceFile(iResourceFileFlag); |
|
187 } |
|
188 |
|
189 if(iAutoTestManager) |
|
190 { |
|
191 iAutoTestManager->Cancel(); |
|
192 } |
|
193 delete iAutoTestManager; |
|
194 |
|
195 if(iMenuBar) |
|
196 { |
|
197 RemoveFromStack(iMenuBar); |
|
198 } |
|
199 delete iMenuBar; |
|
200 |
|
201 if(iToolBar) |
|
202 { |
|
203 RemoveFromStack(iToolBar); |
|
204 } |
|
205 delete iToolBar; |
|
206 } |
|
207 |
|
208 |
|
209 /** |
|
210 Load resource, create toolbar & menubar, read and free thread local storage |
|
211 */ |
|
212 EXPORT_C void CTestAppUi::ConstructL() |
|
213 { |
|
214 iAutoTestManager = CAutoTestManager::NewL(this); |
|
215 |
|
216 if(iStep == 0) |
|
217 { |
|
218 BaseConstructL(ENoAppResourceFile); |
|
219 } |
|
220 else |
|
221 { |
|
222 CCoeAppUi::ConstructL(); |
|
223 } |
|
224 |
|
225 if(iRes.Length() > 0) |
|
226 { |
|
227 CCoeEnv* coeEnv = CCoeEnv::Static(); |
|
228 TBuf8<256> buf; |
|
229 buf.Copy(iRes); |
|
230 iResourceFileFlag=coeEnv->AddResourceFileL(iRes); |
|
231 } |
|
232 |
|
233 if(iResourceMenuBarId) |
|
234 { |
|
235 iMenuBar = new (ELeave) CEikMenuBar; |
|
236 iMenuBar->ConstructL(this,iResourceHotKeysId,iResourceMenuBarId); |
|
237 iMenuBar->MakeVisible(ETrue); |
|
238 AddToStackL(iMenuBar); |
|
239 } |
|
240 |
|
241 if(iResourceToolBarId) |
|
242 { |
|
243 iToolBar=CEikButtonGroupContainer::NewL(CEikButtonGroupContainer::EToolbar, CEikButtonGroupContainer::EVertical, this, iResourceToolBarId); |
|
244 const TRect boundingRect = ClientRect(); // make toolband stretch to the screen width by default |
|
245 iToolBar->SetBoundingRect(boundingRect); |
|
246 iToolBar->MakeVisible(ETrue); |
|
247 AddToStackL(iToolBar); |
|
248 } |
|
249 } |
|
250 |
|
251 |
|
252 /** |
|
253 Reduce client rectangle |
|
254 */ |
|
255 EXPORT_C void CTestAppUi::ReduceRect(TRect& aRect) const |
|
256 { |
|
257 if(iMenuBar) |
|
258 { |
|
259 iMenuBar->ReduceRect(aRect); |
|
260 } |
|
261 |
|
262 if(iToolBar) |
|
263 { |
|
264 iToolBar->ReduceRect(aRect); |
|
265 } |
|
266 } |
|
267 |
|
268 |
|
269 /** |
|
270 Hide menu from screen and pass on to the parent method |
|
271 */ |
|
272 EXPORT_C void CTestAppUi::ProcessCommandL(TInt aCommand) |
|
273 { |
|
274 if (iMenuBar && iMenuBar->IsVisible()) |
|
275 { |
|
276 iMenuBar->StopDisplayingMenuBar(); |
|
277 } |
|
278 if(aCommand != EEikCmdCanceled) |
|
279 { |
|
280 CEikAppUi::ProcessCommandL(aCommand); |
|
281 } |
|
282 } |
|
283 |
|
284 |
|
285 TInt E32Dll() |
|
286 { |
|
287 return 0; |
|
288 } |