|
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 // framework visibility event receipt and dispatch to registered message monitor observers. |
|
15 // Creates a three control(window) application (main control(window) and two children). |
|
16 // The two children are flagged to windows server as generators of visibility events. |
|
17 // The application is registered to the framework as a message monitor observer and handles the relevant TWsVisibilityChangedEvent messages. |
|
18 // One window is moved on and off the other window and the visibility status is compared to that expected. |
|
19 // The visibility status returned should match the status of the control as visible or not visible, which is handled |
|
20 // specifically in each test step. |
|
21 // |
|
22 // |
|
23 |
|
24 /** |
|
25 @file |
|
26 @internalComponent - Internal Symbian test code |
|
27 @SYMTestCaseID UIF-Cone-TConeVisibility |
|
28 @SYMPREQ 915 |
|
29 @SYMTestCaseDesc |
|
30 @SYMTestPriority Medium |
|
31 @SYMTestStatus Implemented |
|
32 @SYMTestActions |
|
33 @SYMTestExpectedResults |
|
34 */ |
|
35 |
|
36 |
|
37 #include <coeaui.h> |
|
38 #include <coemain.h> |
|
39 #include <coedef.h> |
|
40 #include <coesndpy.h> |
|
41 #include <basched.h> |
|
42 #include <bassnd.h> |
|
43 #include <coeccntx.h> |
|
44 #include <ecom/ecom.h> |
|
45 #include "TConeVisibility.h" |
|
46 #include "gdi.h" |
|
47 |
|
48 |
|
49 //Draw the control, different colours are used depending on status although this is for cosmetic purposes and is not required |
|
50 //by the test. |
|
51 void CVisibleControl::Draw(const TRect& aRect) const |
|
52 { |
|
53 |
|
54 CWindowGc& gc=SystemGc(); |
|
55 |
|
56 TRect rc = Rect(); |
|
57 |
|
58 gc.SetClippingRect(aRect); |
|
59 |
|
60 gc.SetPenColor(KRgbBlack); |
|
61 |
|
62 switch (iStatus) |
|
63 { |
|
64 case EPartial: gc.SetBrushColor(KRgbBlue); break; |
|
65 case EHidden: gc.SetBrushColor(KRgbRed); break; |
|
66 case EPartiallyVisible: gc.SetBrushColor(KRgbGreen); break; |
|
67 case ENone: gc.SetBrushColor(KRgbYellow); break; |
|
68 case EFullyVisible: gc.SetBrushColor(KRgbMagenta); break; |
|
69 default: gc.SetBrushColor(KRgbBlack); break; |
|
70 } |
|
71 |
|
72 gc.SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
73 gc.DrawRect(rc); |
|
74 gc.CancelClippingRect(); |
|
75 |
|
76 } |
|
77 |
|
78 |
|
79 //Construct the main background control. A parent control with two child controls that receive visibility events. |
|
80 void CVisibilityBackground::ConstructL() |
|
81 { |
|
82 CreateWindowL(); |
|
83 SetExtent(TPoint(20,20),TSize(600,200)); |
|
84 |
|
85 iControl1 = new (ELeave) CVisibleControl(); |
|
86 iControl1->CreateWindowL(this); |
|
87 iControl1->SetExtent(TPoint(200,36),TSize(128,128)); |
|
88 iControl1->ActivateL(); |
|
89 |
|
90 iControl2 = new (ELeave) CVisibleControl(); |
|
91 iControl2->CreateWindowL(this); |
|
92 iControl2->SetExtent(TPoint(200,36),TSize(128,128)); |
|
93 iControl2->ActivateL(); |
|
94 |
|
95 //Enable visibility events for both these windows. |
|
96 iControl1->DrawableWindow()->EnableVisibilityChangeEvents(); |
|
97 iControl2->DrawableWindow()->EnableVisibilityChangeEvents(); |
|
98 |
|
99 ActivateL(); |
|
100 } |
|
101 |
|
102 |
|
103 //Destruction of the main control content |
|
104 CVisibilityBackground::~CVisibilityBackground() |
|
105 { |
|
106 delete iControl1; |
|
107 delete iControl2; |
|
108 } |
|
109 |
|
110 |
|
111 //Standard implementation |
|
112 CTConeVisibilityAppUi::CTConeVisibilityAppUi(CTmsTestStep* aStep) : |
|
113 CTestCoeAppUi(aStep) |
|
114 {} |
|
115 |
|
116 //Destruction of the application |
|
117 CTConeVisibilityAppUi::~CTConeVisibilityAppUi() |
|
118 { |
|
119 RemoveFromStack(iViewControl); |
|
120 delete iViewControl; |
|
121 } |
|
122 |
|
123 |
|
124 //Standard Implementation |
|
125 void CTConeVisibilityAppUi::ConstructL() |
|
126 { |
|
127 CTestCoeAppUi::ConstructL(); |
|
128 |
|
129 iViewControl=new(ELeave) CVisibilityBackground(); |
|
130 iViewControl->ConstructL(); |
|
131 AddToStackL(iViewControl); |
|
132 |
|
133 //Register this MCoeVisibilityChangeObserver class as a cone visibility observer. |
|
134 CCoeEnv::Static()->AddMessageMonitorObserverL(*this); |
|
135 |
|
136 AutoTestManager().StartAutoTest(); |
|
137 } |
|
138 |
|
139 //Standard Implementation |
|
140 TKeyResponse CTConeVisibilityAppUi::HandleKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) |
|
141 { |
|
142 TKeyResponse ret=EKeyWasNotConsumed; |
|
143 if (aType==EEventKey && aKeyEvent.iCode==CTRL('e')) |
|
144 { |
|
145 CBaActiveScheduler::Exit(); |
|
146 ret=EKeyWasConsumed; |
|
147 } |
|
148 return ret; |
|
149 } |
|
150 |
|
151 //The test case/steps, not that the TEST statement compares the result for the PREVIOUS test step. |
|
152 void CTConeVisibilityAppUi::RunTestStepL(TInt aStepNum) |
|
153 { |
|
154 switch (aStepNum) |
|
155 { |
|
156 case 1: |
|
157 SetTestStepID( _L("UIF-cone-TConeVisibility")); |
|
158 //Overlap control1 (expect visible) |
|
159 iViewControl->iControl2->SetExtent(TPoint(300,36),TSize(128,128)); |
|
160 iViewControl->iControl2->ControlEnv()->WsSession().Flush(); |
|
161 User::After(TTimeIntervalMicroSeconds32(1000000)); |
|
162 break; |
|
163 |
|
164 case 2: |
|
165 //Test result 1 |
|
166 TEST(iViewControl->iControl1->iStatus == CVisibleControl::EPartiallyVisible); |
|
167 |
|
168 //Occlude control1 (expect hidden) |
|
169 iViewControl->iControl2->SetExtent(TPoint(200,36),TSize(128,128)); |
|
170 iViewControl->iControl2->ControlEnv()->WsSession().Flush(); |
|
171 User::After(TTimeIntervalMicroSeconds32(1000000)); |
|
172 break; |
|
173 |
|
174 case 3: |
|
175 //Test result 2 |
|
176 TEST(iViewControl->iControl1->iStatus == CVisibleControl::EHidden); |
|
177 |
|
178 //Set next to control1 the window, not-overlapped (expect visible) |
|
179 iViewControl->iControl2->SetExtent(TPoint(450,36),TSize(128,128)); |
|
180 iViewControl->iControl2->ControlEnv()->WsSession().Flush(); |
|
181 User::After(TTimeIntervalMicroSeconds32(1000000)); |
|
182 break; |
|
183 |
|
184 case 4: |
|
185 //Test result 3 |
|
186 TEST( iViewControl->iControl1->iStatus == CVisibleControl::EPartiallyVisible | CVisibleControl::EFullyVisible); |
|
187 |
|
188 //Occlude control1 (expect hidden) |
|
189 iViewControl->iControl2->SetExtent(TPoint(200,36),TSize(128,128)); |
|
190 iViewControl->iControl2->ControlEnv()->WsSession().Flush(); |
|
191 User::After(TTimeIntervalMicroSeconds32(1000000)); |
|
192 break; |
|
193 |
|
194 case 5: |
|
195 //Test result 4 |
|
196 TEST(iViewControl->iControl1->iStatus == CVisibleControl::EHidden); |
|
197 break; |
|
198 |
|
199 case 6: |
|
200 //Unregister this MCoeVisibilityChangeObserver. |
|
201 CCoeEnv::Static()->RemoveMessageMonitorObserver(*this); |
|
202 RecordTestResultL(); |
|
203 CloseTMSGraphicsStep(); |
|
204 break; |
|
205 |
|
206 default: |
|
207 AutoTestManager().FinishAllTestCases(CAutoTestManager::EPass); |
|
208 } |
|
209 } |
|
210 |
|
211 //Overidden visibility message monitor/ |
|
212 |
|
213 void CTConeVisibilityAppUi::MonitorWsMessage(const TWsEvent& aEvent) |
|
214 { |
|
215 //Check for visibility events, the only event we are interested in |
|
216 if (aEvent.Type() == EEventWindowVisibilityChanged) |
|
217 { |
|
218 const TWsVisibilityChangedEvent *pVC = aEvent.VisibilityChanged(); |
|
219 |
|
220 //The window handle for cone controls is the CCoeControl pointer. We know we only receive |
|
221 //events on specific windows so it is safe to cast them. |
|
222 CVisibleControl *pControl = REINTERPRET_CAST(CVisibleControl *, aEvent.Handle()); |
|
223 |
|
224 if (pControl) |
|
225 { |
|
226 //Set the received visibility status of this control |
|
227 pControl->iStatus = pVC->iFlags; |
|
228 //Call a redraw event. |
|
229 pControl->DrawDeferred(); |
|
230 } |
|
231 } |
|
232 } |
|
233 |
|
234 //Construct application |
|
235 void CTConeVisibilityStep::ConstructAppL(CCoeEnv* aCoe) |
|
236 { // runs inside a TRAP harness |
|
237 aCoe->ConstructL(); |
|
238 CTConeVisibilityAppUi* appUi= new (ELeave) CTConeVisibilityAppUi(this); |
|
239 aCoe->SetAppUi(appUi); |
|
240 appUi->ConstructL(); |
|
241 |
|
242 } |
|
243 |
|
244 //Default implementation |
|
245 CTConeVisibilityStep::CTConeVisibilityStep() |
|
246 { |
|
247 SetTestStepName(KTConeVisibilityStep); |
|
248 } |
|
249 |
|
250 //Default implementation |
|
251 CTConeVisibilityStep::~CTConeVisibilityStep() |
|
252 {} |
|
253 |
|
254 //Default implementation |
|
255 TVerdict CTConeVisibilityStep::doTestStepL() // main function called by E32 |
|
256 { |
|
257 INFO_PRINTF1(_L("Test Started")); |
|
258 |
|
259 PreallocateHALBuffer(); |
|
260 |
|
261 __UHEAP_MARK; |
|
262 CCoeEnv* coe=new(ELeave) CCoeEnv; |
|
263 TRAPD(err,ConstructAppL(coe)); |
|
264 |
|
265 if (!err) |
|
266 coe->ExecuteD(); |
|
267 else |
|
268 { |
|
269 SetTestStepResult(EFail); |
|
270 delete coe; |
|
271 } |
|
272 |
|
273 REComSession::FinalClose(); |
|
274 |
|
275 __UHEAP_MARKEND; |
|
276 |
|
277 INFO_PRINTF1(_L("Test Finished")); |
|
278 return TestStepResult(); |
|
279 } |