|
1 // Copyright (c) 2008-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 // Tests semi-transparent window owning control with background display properly when having a child window |
|
15 // owning semi-transparent control. |
|
16 // Creats a window application with two semi-transparent window owning parent controls both with background. |
|
17 // A semi-transparent child window owning control is created for each parent control. One of the child control |
|
18 // enables transparent property properly, the other does not. |
|
19 // The child control which enables transparent property properly should not cause the background of parent control |
|
20 // to redraw thus in all circumstance its parent control background drawing count should be less than the one doesn't |
|
21 // enable transparent control with provided function. |
|
22 // |
|
23 // |
|
24 |
|
25 /** |
|
26 @file |
|
27 @internalComponent - Internal Symbian test code |
|
28 @SYMTestCaseID UIF-Cone-TConeTransparency |
|
29 @SYMPREQ 000 |
|
30 @SYMTestCaseDesc |
|
31 @SYMTestPriority Medium |
|
32 @SYMTestStatus Implemented |
|
33 @SYMTestActions |
|
34 @SYMTestExpectedResults |
|
35 */ |
|
36 |
|
37 |
|
38 #include <coeaui.h> |
|
39 #include <coemain.h> |
|
40 #include <coedef.h> |
|
41 #include <coesndpy.h> |
|
42 #include <basched.h> |
|
43 #include <bassnd.h> |
|
44 #include <coeccntx.h> |
|
45 #include <ecom/ecom.h> |
|
46 #include "TConeTransparency.h" |
|
47 #include "gdi.h" |
|
48 |
|
49 //From MCoeControlBackground, has a mutable iBackgroundDrawnCount to measure how many times the background is drawn |
|
50 void CTransparencyParentControl::Draw(CWindowGc &aGc, const CCoeControl &/*aControl*/, const TRect &aRect) const |
|
51 { |
|
52 |
|
53 aGc.SetClippingRect(aRect); |
|
54 aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
55 aGc.SetBrushColor(TRgb(255,0,0,127)); |
|
56 for(TInt i = 0; i < aRect.Width(); i+=10) |
|
57 { |
|
58 TRect stripe(aRect.iTl.iX + i, aRect.iTl.iY, aRect.iTl.iX + i+5, aRect.iBr.iY); |
|
59 aGc.DrawRect(stripe); |
|
60 } |
|
61 aGc.CancelClippingRect(); |
|
62 iBackgroundDrawnCount++; |
|
63 } |
|
64 |
|
65 //Draw the control |
|
66 void CTransparentControl::Draw(const TRect& aRect) const |
|
67 { |
|
68 |
|
69 CWindowGc& gc=SystemGc(); |
|
70 |
|
71 TRect rc = Rect(); |
|
72 |
|
73 gc.SetClippingRect(aRect); |
|
74 |
|
75 gc.SetPenColor(TRgb(0,0,0,127)); |
|
76 gc.SetBrushColor(TRgb(255,0,0,127)); |
|
77 gc.SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
78 gc.DrawEllipse(rc); |
|
79 gc.CancelClippingRect(); |
|
80 |
|
81 } |
|
82 |
|
83 |
|
84 //Construct the main background control. A parent control with a child control |
|
85 void CTransparencyParentControl::ConstructL(TBool aEnableTransparencyProperly) |
|
86 { |
|
87 CreateWindowL(); |
|
88 TInt xPosOffset = 0; |
|
89 if(aEnableTransparencyProperly) |
|
90 xPosOffset = 300; |
|
91 SetExtent(TPoint(20+xPosOffset ,20),TSize(200,200)); |
|
92 SetBackground(this); |
|
93 |
|
94 iControl = new (ELeave) CTransparentControl(); |
|
95 iControl->CreateWindowL(this); |
|
96 iControl->SetExtent(TPoint(50,36),TSize(128,128)); |
|
97 if(aEnableTransparencyProperly) |
|
98 { |
|
99 iControl->EnableWindowTransparency(); |
|
100 } |
|
101 else |
|
102 { |
|
103 iControl->Window().SetTransparencyAlphaChannel(); |
|
104 iControl->Window().SetBackgroundColor(~0); |
|
105 } |
|
106 |
|
107 iControl->ActivateL(); |
|
108 |
|
109 ActivateL(); |
|
110 } |
|
111 |
|
112 |
|
113 //Destruction of the main control content |
|
114 CTransparencyParentControl::~CTransparencyParentControl() |
|
115 { |
|
116 delete iControl; |
|
117 } |
|
118 |
|
119 |
|
120 //Standard implementation |
|
121 CTConeTransparencyAppUi::CTConeTransparencyAppUi(CTmsTestStep* aStep) : |
|
122 CTestCoeAppUi(aStep) |
|
123 {} |
|
124 |
|
125 //Destruction of the application |
|
126 CTConeTransparencyAppUi::~CTConeTransparencyAppUi() |
|
127 { |
|
128 RemoveFromStack(iViewControl1); |
|
129 delete iViewControl1; |
|
130 RemoveFromStack(iViewControl2); |
|
131 delete iViewControl2; |
|
132 } |
|
133 |
|
134 |
|
135 //Standard Implementation |
|
136 void CTConeTransparencyAppUi::ConstructL() |
|
137 { |
|
138 CTestCoeAppUi::ConstructL(); |
|
139 |
|
140 iViewControl1=new(ELeave) CTransparencyParentControl(); |
|
141 iViewControl1->ConstructL(EFalse); |
|
142 iViewControl2=new(ELeave) CTransparencyParentControl(); |
|
143 iViewControl2->ConstructL(ETrue); |
|
144 AddToStackL(iViewControl1); |
|
145 AddToStackL(iViewControl2); |
|
146 |
|
147 AutoTestManager().StartAutoTest(); |
|
148 } |
|
149 |
|
150 //Standard Implementation |
|
151 TKeyResponse CTConeTransparencyAppUi::HandleKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) |
|
152 { |
|
153 TKeyResponse ret=EKeyWasNotConsumed; |
|
154 if (aType==EEventKey && aKeyEvent.iCode==CTRL('e')) |
|
155 { |
|
156 CBaActiveScheduler::Exit(); |
|
157 ret=EKeyWasConsumed; |
|
158 } |
|
159 return ret; |
|
160 } |
|
161 |
|
162 //The test case/steps, a proper semi-transparent window owning child control should not cause its parent |
|
163 //window owning control's background to redraw |
|
164 void CTConeTransparencyAppUi::RunTestStepL(TInt /*aStepNum*/) |
|
165 { |
|
166 SetTestStepID(_L("@SYMTestCaseID UIF-Cone-TConeTransparency")); |
|
167 TInt firstViewBgDrawnCount = iViewControl1->BgDrawnCount(); |
|
168 TInt secondViewBgDrawnCount = iViewControl2->BgDrawnCount(); |
|
169 INFO_PRINTF2(_L("Background of left picture was drawn %i time(s)"), firstViewBgDrawnCount); |
|
170 INFO_PRINTF2(_L("Background of right picture was drawn %i time(s)"), secondViewBgDrawnCount); |
|
171 if(firstViewBgDrawnCount > secondViewBgDrawnCount) |
|
172 AutoTestManager().FinishAllTestCases(CAutoTestManager::EPass); |
|
173 else |
|
174 { |
|
175 INFO_PRINTF1(_L("Background of left picture was drawn fewer times than that of right, but shouldn't be.")); |
|
176 AutoTestManager().FinishAllTestCases(CAutoTestManager::EFailed); |
|
177 } |
|
178 RecordTestResultL(); |
|
179 CloseTMSGraphicsStep(); |
|
180 } |
|
181 |
|
182 |
|
183 |
|
184 //Construct application |
|
185 void CTConeTransparencyStep::ConstructAppL(CCoeEnv* aCoe) |
|
186 { // runs inside a TRAP harness |
|
187 aCoe->ConstructL(); |
|
188 CTConeTransparencyAppUi* appUi= new (ELeave) CTConeTransparencyAppUi(this); |
|
189 aCoe->SetAppUi(appUi); |
|
190 appUi->ConstructL(); |
|
191 |
|
192 } |
|
193 |
|
194 //Default implementation |
|
195 CTConeTransparencyStep::CTConeTransparencyStep() |
|
196 { |
|
197 SetTestStepName(KTConeTransparencyStep); |
|
198 } |
|
199 |
|
200 //Default implementation |
|
201 CTConeTransparencyStep::~CTConeTransparencyStep() |
|
202 {} |
|
203 |
|
204 //Default implementation |
|
205 TVerdict CTConeTransparencyStep::doTestStepL() // main function called by E32 |
|
206 { |
|
207 INFO_PRINTF1(_L("Test Started")); |
|
208 |
|
209 PreallocateHALBuffer(); |
|
210 |
|
211 __UHEAP_MARK; |
|
212 CCoeEnv* coe=new(ELeave) CCoeEnv; |
|
213 TRAPD(err,ConstructAppL(coe)); |
|
214 |
|
215 if (!err) |
|
216 coe->ExecuteD(); |
|
217 else |
|
218 { |
|
219 SetTestStepResult(EFail); |
|
220 delete coe; |
|
221 } |
|
222 |
|
223 REComSession::FinalClose(); |
|
224 |
|
225 __UHEAP_MARKEND; |
|
226 |
|
227 INFO_PRINTF1(_L("Test Finished")); |
|
228 return TestStepResult(); |
|
229 } |