|
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 // The test step creates a sample application and uses AutoTest Manager |
|
15 // to create KeyUp and KeyDown Events asynchronously. These events are then handled |
|
16 // by the appropriate handlers.\n |
|
17 // |
|
18 // |
|
19 |
|
20 /** |
|
21 @file |
|
22 @internalComponent - Internal Symbian test code |
|
23 */ |
|
24 #include <coeaui.h> |
|
25 #include <coemain.h> |
|
26 #include <coedef.h> |
|
27 #include <coesndpy.h> |
|
28 #include <basched.h> |
|
29 #include <bassnd.h> |
|
30 #include <ecom/ecom.h> |
|
31 #include "TCone0Step.h" |
|
32 |
|
33 /** |
|
34 Single Argument Constructor for CCone0TestAppUi class.\n |
|
35 */ |
|
36 CCone0TestAppUi::CCone0TestAppUi(CTmsTestStep* aStep) : |
|
37 CTestCoeAppUi(aStep) |
|
38 {} |
|
39 /** |
|
40 Destructor for CCone0TestAppUi class.\n |
|
41 */ |
|
42 CCone0TestAppUi::~CCone0TestAppUi() |
|
43 {} |
|
44 |
|
45 /** |
|
46 Second phase Constructor for CCone0TestAppUi class.\n |
|
47 Invokes the base class CTestCoeAppUi second phase constructor.\n |
|
48 Executes the testcases asynchronously using Autotest Manager.\n |
|
49 */ |
|
50 void CCone0TestAppUi::ConstructL() |
|
51 { |
|
52 CTestCoeAppUi::ConstructL(); |
|
53 |
|
54 AutoTestManager().StartAutoTest(); |
|
55 } |
|
56 |
|
57 /** |
|
58 Auxiliary Function for all Test Cases.\n |
|
59 |
|
60 The method is an override from CTestCoeAppUi.\n |
|
61 |
|
62 */ |
|
63 |
|
64 void CCone0TestAppUi::Beep(TInt /*aFrequency*/) |
|
65 { |
|
66 CoeSoundPlayer::PlaySound(TBaSystemSoundType(KUidSystemSoundEvent)); |
|
67 } |
|
68 |
|
69 |
|
70 /** |
|
71 Auxiliary Function for all Test Cases |
|
72 |
|
73 The method is an override from CTestCoeAppUi. |
|
74 The function handles the following key events.\n |
|
75 Key Up Event and Key down Event.\n |
|
76 */ |
|
77 |
|
78 TKeyResponse CCone0TestAppUi::HandleKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) |
|
79 { |
|
80 TKeyResponse ret=EKeyWasNotConsumed; |
|
81 Beep(1760+(aType-EEventKey)*220); |
|
82 if (aType==EEventKey && aKeyEvent.iCode==CTRL('e')) |
|
83 { |
|
84 CBaActiveScheduler::Exit(); |
|
85 ret=EKeyWasConsumed; |
|
86 } |
|
87 return ret; |
|
88 } |
|
89 /** |
|
90 Handles the foreground events by generating a Beep.\n |
|
91 */ |
|
92 void CCone0TestAppUi::HandleForegroundEventL(TBool aForeground) |
|
93 { |
|
94 Beep(aForeground? 1500: 1200); |
|
95 } |
|
96 |
|
97 |
|
98 /** |
|
99 @SYMTestCaseID UIF-TCCone0TestAppUi-TestStepKeyDownL |
|
100 |
|
101 @SYMPREQ |
|
102 |
|
103 @SYMTestPriority High |
|
104 |
|
105 @SYMTestStatus Implemented |
|
106 |
|
107 @SYMTestActions The method calls CCone0TestAppUi::HandleKeyEventL() to test KeyDown Event |
|
108 |
|
109 @SYMTestExpectedResults. This test is manually verified, the system will play a beep. |
|
110 |
|
111 @SYMTestType: CIT |
|
112 */ |
|
113 |
|
114 void CCone0TestAppUi::TestStepKeyDownL(TKeyEvent aKeyEvent) |
|
115 { |
|
116 INFO_PRINTF1(_L("Emulation the event KeyDown")); |
|
117 HandleKeyEventL(aKeyEvent,EEventKeyDown); |
|
118 } |
|
119 |
|
120 |
|
121 /** |
|
122 @SYMTestCaseID UIF-TCCone0TestAppUi-TestStepKeyUpL |
|
123 |
|
124 @SYMPREQ |
|
125 |
|
126 @SYMTestPriority High |
|
127 |
|
128 @SYMTestStatus Implemented |
|
129 |
|
130 @SYMTestActions The method calls CCone0TestAppUi::HandleKeyEventL() to handle the KeyUp Event |
|
131 |
|
132 @SYMTestExpectedResults. This test is manually verified, the system will play a beep. |
|
133 |
|
134 @SYMTestType : CIT |
|
135 */ |
|
136 |
|
137 void CCone0TestAppUi::TestStepKeyUpL(TKeyEvent aKeyEvent) |
|
138 { |
|
139 INFO_PRINTF1(_L("Emulation the event KeyUp")); |
|
140 HandleKeyEventL(aKeyEvent,EEventKeyUp); |
|
141 } |
|
142 |
|
143 /** |
|
144 Auxiliary Function for all Test Cases.\n |
|
145 |
|
146 The method is an override from CTestCoeAppUi.\n |
|
147 This function is called asynchronously by RunL function of the |
|
148 AutotestManager after previous test case is executed.\n |
|
149 Generates the KeyDown event and KeyUp Events alternatively.\n |
|
150 */ |
|
151 |
|
152 void CCone0TestAppUi::RunTestStepL(TInt aStepNum) |
|
153 { |
|
154 |
|
155 User::After(TTimeIntervalMicroSeconds32(1000000)); |
|
156 |
|
157 TKeyEvent theKeyEvent = {0,0,0,0}; |
|
158 switch(aStepNum) |
|
159 { |
|
160 case 1: |
|
161 SetTestStepID(_L("UIF-TCCone0TestAppUi-TestStepKeyDownL")); |
|
162 // follow on... |
|
163 case 3: case 5: |
|
164 TestStepKeyDownL(theKeyEvent); |
|
165 if( aStepNum == 5 ) |
|
166 { |
|
167 RecordTestResultL(); |
|
168 } |
|
169 break; |
|
170 |
|
171 case 2: |
|
172 SetTestStepID(_L("UIF-TCCone0TestAppUi-TestStepKeyUpL")); |
|
173 // follow on... |
|
174 case 4: case 6: |
|
175 TestStepKeyUpL(theKeyEvent); |
|
176 if( aStepNum == 6 ) |
|
177 { |
|
178 RecordTestResultL(); |
|
179 CloseTMSGraphicsStep(); |
|
180 } |
|
181 break; |
|
182 case 7: |
|
183 AutoTestManager().FinishAllTestCases(CAutoTestManager::EPass); |
|
184 break; |
|
185 |
|
186 } |
|
187 } |
|
188 |
|
189 /** |
|
190 Completes the construction of the Control Environment(CCoeEnv object).\n |
|
191 Instantiates the CCone0TestAppUi class which serves as a AppUi class.\n |
|
192 Sets the CCone0TestAppUi object as the application's user interface object.\n |
|
193 Invokes the second phase constructor of the application's UI.\n |
|
194 */ |
|
195 void CTCone0Step::ConstructAppL(CCoeEnv* aCoe) |
|
196 { // runs inside a TRAP harness |
|
197 aCoe->ConstructL(); |
|
198 CCone0TestAppUi* appUi= new (ELeave) CCone0TestAppUi(this); |
|
199 aCoe->SetAppUi(appUi); |
|
200 appUi->ConstructL(); |
|
201 } |
|
202 /** |
|
203 Constructor for CTCone0Step class.\n |
|
204 Sets the test step name.\n |
|
205 */ |
|
206 CTCone0Step::CTCone0Step() |
|
207 { |
|
208 SetTestStepName(KTCone0Step); |
|
209 } |
|
210 /** |
|
211 Destructor for CTCone0Step class.\n |
|
212 */ |
|
213 CTCone0Step::~CTCone0Step() |
|
214 {} |
|
215 |
|
216 /** |
|
217 Entry function for CTCone0 Test Step.\n |
|
218 Sets up the control environment.\n |
|
219 Constructs and Launches the CTCone0 Test application.\n |
|
220 |
|
221 */ |
|
222 TVerdict CTCone0Step::doTestStepL() // main function called by E32 |
|
223 { |
|
224 INFO_PRINTF1(_L("Test Started")); |
|
225 |
|
226 PreallocateHALBuffer(); |
|
227 |
|
228 __UHEAP_MARK; |
|
229 |
|
230 CCoeEnv* coe=new(ELeave) CCoeEnv; |
|
231 TRAPD(err,ConstructAppL(coe)); |
|
232 |
|
233 if (!err) |
|
234 coe->ExecuteD(); |
|
235 else |
|
236 { |
|
237 SetTestStepResult(EFail); |
|
238 delete coe; |
|
239 } |
|
240 |
|
241 REComSession::FinalClose(); |
|
242 |
|
243 __UHEAP_MARKEND; |
|
244 |
|
245 INFO_PRINTF1(_L("Test Finished")); |
|
246 return TestStepResult(); |
|
247 } |
|
248 |
|
249 |