|
1 // Copyright (c) 2007-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 @test |
|
20 */ |
|
21 |
|
22 #include <e32std.h> |
|
23 #include "COEAUI.H" |
|
24 #include "tconestateobs.h" |
|
25 #include "statecon.h" |
|
26 |
|
27 /** |
|
28 Handles calls from the Mop interface on the control enviroment |
|
29 */ |
|
30 TInt CStepStateObsEnv::HandleControlStateChange(CCoeControl* aControl,MCoeControlStateObserver::TCoeState aState) |
|
31 { |
|
32 if (iPassOn) |
|
33 return iPassOn->ControlStateChangePassOn(aControl,aState); |
|
34 return KErrNone; |
|
35 } |
|
36 |
|
37 /** |
|
38 Returns the Mop interface provided by this control enviroment |
|
39 */ |
|
40 TTypeUid::Ptr CStepStateObsEnv::MopSupplyObject(TTypeUid aId) |
|
41 { |
|
42 if (aId.iUid==MCoeControlStateObserver::ETypeId && iRetObserver) |
|
43 return aId.MakePtr(static_cast<MCoeControlStateObserver*>(this)); |
|
44 return CCoeEnv::MopSupplyObject(aId); |
|
45 } |
|
46 |
|
47 /** |
|
48 Constructor for the APP UI for this test |
|
49 */ |
|
50 CConeStateObsAppUi::CConeStateObsAppUi(CTmsTestStep* aStep,CStepStateObsEnv* aCoe) |
|
51 : CTestCoeAppUi(aStep), iCoe(aCoe) |
|
52 {} |
|
53 |
|
54 /** |
|
55 Destructor for the APP UI for this test |
|
56 */ |
|
57 CConeStateObsAppUi::~CConeStateObsAppUi() |
|
58 { |
|
59 delete iStateObCnt; |
|
60 } |
|
61 |
|
62 /** |
|
63 Creates font and control for this test and sets state need by all sub-tests |
|
64 */ |
|
65 void CConeStateObsAppUi::ConstructL() |
|
66 { |
|
67 CTestCoeAppUi::ConstructL(); |
|
68 AutoTestManager().StartAutoTest(); |
|
69 //Creating the first font allocates memory that is never deleted so must do this outside heap checks |
|
70 CFbsFont* font=iCoe->CreateScreenFontL(CStateObserverControl::iFontSpec); |
|
71 iCoe->ReleaseScreenFont(font); |
|
72 iStateObCnt=new(ELeave) CStateObserverControl(); |
|
73 iStateObCnt->ConstructL(); |
|
74 iStateObCnt->SetEnv(iCoe); |
|
75 iCoe->SetPassOn(iStateObCnt); |
|
76 iCoe->SetReturnObserver(ETrue); |
|
77 } |
|
78 |
|
79 /** |
|
80 Do a sub test |
|
81 */ |
|
82 void CConeStateObsAppUi::DoStateObserverTest() |
|
83 { |
|
84 __UHEAP_MARK; |
|
85 TInt failAt=iStateObCnt->DoTest(); |
|
86 if (failAt>0) |
|
87 { |
|
88 TEST(EFalse); |
|
89 _LIT(KLog,"StateObserverTest failed on subtest: %d"); |
|
90 INFO_PRINTF2(KLog,failAt); |
|
91 } |
|
92 __UHEAP_MARKEND; |
|
93 } |
|
94 |
|
95 /** |
|
96 @SYMTestCaseID UIF-CONE-0029 |
|
97 |
|
98 @SYMCR CR1251 |
|
99 |
|
100 @SYMTestCaseDesc Tests calling MakeVisible or SetDimmed calls the new Mop interface |
|
101 when only the control enviroment provides the relevant Mop interface |
|
102 |
|
103 @SYMTestPriority High |
|
104 |
|
105 @SYMTestStatus Implemented |
|
106 |
|
107 @SYMTestActions Makes many calls to MakeVisible or SetDimmed in different situations |
|
108 and checks if the new Mop interface is called or not on each time. |
|
109 |
|
110 @SYMTestExpectedResults The new interface is called if there is a change in the controls state |
|
111 |
|
112 @SYMTestType : Unit Test |
|
113 */ |
|
114 void CConeStateObsAppUi::StateObserverTestEnvOnly() |
|
115 { |
|
116 iStateObCnt->SetReturnObserver(CStateObserverControl::ENoObserver); |
|
117 iStateObCnt->SetRecievers(EFalse,ETrue); |
|
118 DoStateObserverTest(); |
|
119 } |
|
120 |
|
121 /** |
|
122 @SYMTestCaseID UIF-CONE-0030 |
|
123 |
|
124 @SYMCR CR1251 |
|
125 |
|
126 @SYMTestCaseDesc Tests calling MakeVisible or SetDimmed calls the new Mop interface |
|
127 when both the control the control enviroment provides the relevant Mop interface |
|
128 |
|
129 @SYMTestPriority High |
|
130 |
|
131 @SYMTestStatus Implemented |
|
132 |
|
133 @SYMTestActions Makes many calls to MakeVisible or SetDimmed in different situations |
|
134 and checks if the new Mop interface is called or not on each time. |
|
135 |
|
136 @SYMTestExpectedResults The new interface is called if there is a change in the controls state |
|
137 |
|
138 @SYMTestType : Unit Test |
|
139 */ |
|
140 void CConeStateObsAppUi::StateObserverTestBoth() |
|
141 { |
|
142 iStateObCnt->ResetCount(); |
|
143 iStateObCnt->SetReturnObserver(CStateObserverControl::EObserver); |
|
144 iStateObCnt->SetRecievers(ETrue,ETrue); |
|
145 DoStateObserverTest(); |
|
146 } |
|
147 |
|
148 /** |
|
149 @SYMTestCaseID UIF-CONE-0031 |
|
150 |
|
151 @SYMCR CR1251 |
|
152 |
|
153 @SYMTestCaseDesc Tests calling MakeVisible or SetDimmed calls the new Mop interface |
|
154 when both the control the control enviroment provides the relevant Mop interface but |
|
155 do so using the same object |
|
156 |
|
157 @SYMTestPriority High |
|
158 |
|
159 @SYMTestStatus Implemented |
|
160 |
|
161 @SYMTestActions Makes many calls to MakeVisible or SetDimmed in different situations |
|
162 and checks if the new Mop interface is called or not on each time. |
|
163 |
|
164 @SYMTestExpectedResults The new interface is called if there is a change in the controls state |
|
165 |
|
166 @SYMTestType : Unit Test |
|
167 */ |
|
168 void CConeStateObsAppUi::StateObserverTestBothAtEnv() |
|
169 { |
|
170 iStateObCnt->ResetCount(); |
|
171 iStateObCnt->SetReturnObserver(CStateObserverControl::ECoeEnvObserver); |
|
172 iStateObCnt->SetRecievers(EFalse,ETrue); |
|
173 DoStateObserverTest(); |
|
174 } |
|
175 |
|
176 /** |
|
177 Function to call each of the tests in turn |
|
178 */ |
|
179 void CConeStateObsAppUi::RunTestStepL(TInt aStepNum) |
|
180 { |
|
181 _LIT(KTest1,"Test 1: MCoeControlStateObserver event recieved through control enviroment only"); |
|
182 _LIT(KTest2,"Test 2: MCoeControlStateObserver event recieved through both control enviroment and control"); |
|
183 _LIT(KTest3,"Test 3: MCoeControlStateObserver event recieved through both control enviroment and control but by the same object"); |
|
184 switch(aStepNum) |
|
185 { |
|
186 case 1: |
|
187 SetTestStepID(_L("UIF-CONE-0029")); |
|
188 INFO_PRINTF1(KTest1); |
|
189 StateObserverTestEnvOnly(); |
|
190 RecordTestResultL(); |
|
191 break; |
|
192 case 2: |
|
193 SetTestStepID(_L("UIF-CONE-0030")); |
|
194 INFO_PRINTF1(KTest2); |
|
195 StateObserverTestBoth(); |
|
196 RecordTestResultL(); |
|
197 break; |
|
198 case 3: |
|
199 SetTestStepID(_L("UIF-CONE-0031")); |
|
200 INFO_PRINTF1(KTest3); |
|
201 StateObserverTestBothAtEnv(); |
|
202 RecordTestResultL(); |
|
203 CloseTMSGraphicsStep(); |
|
204 break; |
|
205 default: |
|
206 AutoTestManager().FinishAllTestCases(CAutoTestManager::EPass); |
|
207 break; |
|
208 } |
|
209 } |
|
210 |
|
211 /** |
|
212 Constructor for the main test class |
|
213 */ |
|
214 CTConeStateObs::CTConeStateObs() |
|
215 { |
|
216 SetTestStepName(KTConeStateObs); |
|
217 } |
|
218 |
|
219 /** |
|
220 Finish creating the Control Enviroment and create the App UI. |
|
221 */ |
|
222 void CTConeStateObs::ConstructL() |
|
223 { |
|
224 //Would like to do this line here but this gives a panic in the cleanup stack code. |
|
225 //iCoe=new(ELeave) CStepStateObsEnv(); |
|
226 iCoe->ConstructL(); |
|
227 CConeStateObsAppUi* appUi=new(ELeave) CConeStateObsAppUi(this,iCoe); |
|
228 iCoe->SetAppUi(appUi); |
|
229 appUi->ConstructL(); |
|
230 } |
|
231 |
|
232 /** |
|
233 Entry function for CTConeStateObs Test Step. |
|
234 */ |
|
235 TVerdict CTConeStateObs::doTestStepL() |
|
236 { |
|
237 INFO_PRINTF1(_L("Test Started")); |
|
238 iCoe=new(ELeave) CStepStateObsEnv(); |
|
239 TRAPD(err,ConstructL()); |
|
240 if (!err) |
|
241 iCoe->ExecuteD(); |
|
242 else |
|
243 { |
|
244 SetTestStepResult(EFail); |
|
245 delete iCoe; |
|
246 } |
|
247 INFO_PRINTF1(_L("Test Finished")); |
|
248 return TestStepResult(); |
|
249 } |