|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDES |
|
20 #include <AknUtils.h> |
|
21 |
|
22 #include <alf/AlfEnv.h> |
|
23 #include <alf/AlfDisplay.h> |
|
24 #include <alf/alfimageloaderutil.h> |
|
25 #include <alf/alftexturemanager.h> |
|
26 #include <alf/alfevent.h> |
|
27 #include <alf/alfcontrolgroup.h> |
|
28 #include <alf/alfviewportlayout.h> |
|
29 #include <alf/alfgridlayout.h> |
|
30 #include <alf/alfdecklayout.h> |
|
31 #include <alf/alfimagevisual.h> |
|
32 #include <alf/alftextvisual.h> |
|
33 #include <alf/alfgradientbrush.h> |
|
34 #include <alf/alfborderbrush.h> |
|
35 #include <alf/AlfBrushArray.h> |
|
36 #include <alf/AlfTextStyle.h> |
|
37 |
|
38 #include <alfperfapp_imagetest.mbg> |
|
39 |
|
40 #include "AlfPerfApp.hrh" |
|
41 #include "AlfPerfAppSuiteTestCaseScroll.h" |
|
42 #include "AlfPerfAppSuitePeopleControl.h" |
|
43 #include "AlfPerfAppSuiteEPGControl.h" |
|
44 #include "AlfPerfAppSuiteTestCase.h" |
|
45 #include "alfperfappconfigconstants.h" |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 // ============================= MEMBER FUNCTIONS ============================== |
|
51 |
|
52 CAlfPerfAppSuiteTestCaseScroll::CAlfPerfAppSuiteTestCaseScroll(CAlfPerfAppSuiteTestCase* aAppSuiteTestCase) |
|
53 :iAppSuiteTestCase(aAppSuiteTestCase) |
|
54 { |
|
55 } |
|
56 |
|
57 CAlfPerfAppSuiteTestCaseScroll::~CAlfPerfAppSuiteTestCaseScroll() |
|
58 { |
|
59 } |
|
60 |
|
61 void CAlfPerfAppSuiteTestCaseScroll::ConstructL( |
|
62 CAlfEnv& aEnv, TInt aCaseId, const TRect& aVisibleArea ) |
|
63 { |
|
64 CAlfPerfAppSuiteTestCaseControl::ConstructL( aEnv, aCaseId, aVisibleArea ); |
|
65 |
|
66 // Setup scrolling cycle lenght |
|
67 switch( aCaseId ) |
|
68 { |
|
69 case EAlfPerfAppSuiteCaseScrollContinuousPortrait: |
|
70 case EAlfPerfAppSuiteCaseScrollContinuousLandscape: |
|
71 iCycleLenght = KCycleLenghtContinuous; |
|
72 break; |
|
73 |
|
74 case EAlfPerfAppSuiteCaseScrollIncrementalPortrait: |
|
75 case EAlfPerfAppSuiteCaseScrollIncrementalLandscape: |
|
76 iCycleLenght = KCycleLenghtIncremental; |
|
77 break; |
|
78 |
|
79 default: |
|
80 User::Leave( KErrNotFound ); |
|
81 break; |
|
82 } |
|
83 |
|
84 // Use a viewport layout as a base |
|
85 iViewPortLayout = CAlfViewportLayout::AddNewL( *this ); |
|
86 |
|
87 // Visible viewport is full screen |
|
88 iViewPortLayout->SetViewportSize( aVisibleArea.Size(), 0 ); |
|
89 |
|
90 // Then use a gird to hold suites |
|
91 CAlfGridLayout* baseGridLayout = CAlfGridLayout::AddNewL( *this, 1, 1, iViewPortLayout ); |
|
92 |
|
93 // Construct suites |
|
94 |
|
95 iLoadedImages = 0; |
|
96 iSuiteCount = 3; |
|
97 // EPG suite |
|
98 CAlfPerfAppSuiteEPGControl* epg = new (ELeave) CAlfPerfAppSuiteEPGControl(this); |
|
99 epg->ConstructL( aEnv, aVisibleArea.Size(), baseGridLayout ); |
|
100 aEnv.ControlGroup( KAlfPerfAppSuiteControlGroup ).AppendL( epg ); |
|
101 |
|
102 // PEOPLE suite |
|
103 CAlfPerfAppSuitePeopleControl* people = new (ELeave) CAlfPerfAppSuitePeopleControl(this); |
|
104 people->ConstructL( aEnv, aVisibleArea.Size(), baseGridLayout ); |
|
105 aEnv.ControlGroup( KAlfPerfAppSuiteControlGroup ).AppendL( people ); |
|
106 |
|
107 // Another EPG suite |
|
108 epg = new (ELeave) CAlfPerfAppSuiteEPGControl(this); |
|
109 epg->ConstructL( aEnv, aVisibleArea.Size(), baseGridLayout ); |
|
110 aEnv.ControlGroup( KAlfPerfAppSuiteControlGroup ).AppendL( epg ); |
|
111 |
|
112 // Set correct number of columns to grid |
|
113 baseGridLayout->SetColumns( iSuiteCount ); |
|
114 |
|
115 // Virtual viewport depends on the number of suites |
|
116 TSize size = iVisibleArea.Size(); |
|
117 size.iWidth = iVisibleArea.Width()*iSuiteCount; |
|
118 iViewPortLayout->SetVirtualSize( size, 0 ); |
|
119 |
|
120 // TextureLoadingCompleted() call back is handled now in epg, people control classes. |
|
121 // so no need of explicit wait in this thread. |
|
122 // ImagesLoaded() does the request completion functionlaity. |
|
123 } |
|
124 |
|
125 void CAlfPerfAppSuiteTestCaseScroll::ImagesLoaded( TInt aErrorCode ) |
|
126 { |
|
127 // inform if there is any error |
|
128 if( aErrorCode != KErrNone ) |
|
129 { |
|
130 iAppSuiteTestCase->ImagesLoaded( aErrorCode ); |
|
131 } |
|
132 |
|
133 iLoadedImages++; |
|
134 if (iLoadedImages == iSuiteCount) |
|
135 { |
|
136 iAppSuiteTestCase->ImagesLoaded(KErrNone); |
|
137 } |
|
138 } |
|
139 |
|
140 void CAlfPerfAppSuiteTestCaseScroll::DoStartExecuteL() |
|
141 { |
|
142 NextCycleL(); |
|
143 } |
|
144 |
|
145 void CAlfPerfAppSuiteTestCaseScroll::SetVisibleArea( |
|
146 const TRect& /*aVisibleArea*/ ) |
|
147 { |
|
148 if ( IsExecutionOngoing() ) |
|
149 { |
|
150 Env().CancelCustomCommands( this, KAlfPerfAppSuiteCmdNext ); |
|
151 TRAPD( err, NextCycleL() ); |
|
152 if ( err != KErrNone ) |
|
153 { |
|
154 CompleteNow( err ); |
|
155 } |
|
156 } |
|
157 } |
|
158 |
|
159 TBool CAlfPerfAppSuiteTestCaseScroll::OfferEventL( const TAlfEvent& aEvent ) |
|
160 { |
|
161 if ( aEvent.IsCustomEvent() && |
|
162 aEvent.CustomParameter() == KAlfPerfAppSuiteCmdNext ) |
|
163 { |
|
164 TRAPD( err, NextCycleL() ); |
|
165 if ( err != KErrNone ) |
|
166 { |
|
167 CompleteNow( err ); |
|
168 } |
|
169 return ETrue; |
|
170 } |
|
171 |
|
172 return CAlfPerfAppSuiteTestCaseControl::OfferEventL( aEvent ); |
|
173 } |
|
174 |
|
175 void CAlfPerfAppSuiteTestCaseScroll::NextCycleL() |
|
176 { |
|
177 switch( iCaseId ) |
|
178 { |
|
179 case EAlfPerfAppSuiteCaseScrollContinuousPortrait: |
|
180 case EAlfPerfAppSuiteCaseScrollContinuousLandscape: |
|
181 { |
|
182 if( iCycleCounter == KNumberOfRepeats ) |
|
183 { |
|
184 CompleteNow( KErrNone ); |
|
185 return; |
|
186 } |
|
187 |
|
188 // Bounce between first and last suites |
|
189 if( iCycleCounter % 2 ) |
|
190 { |
|
191 iViewPortPos = TAlfRealPoint( 0, 0 ); |
|
192 } |
|
193 else |
|
194 { |
|
195 iViewPortPos = TAlfRealPoint( iVisibleArea.Width()*(iSuiteCount-1), 0 ); |
|
196 } |
|
197 } |
|
198 break; |
|
199 |
|
200 case EAlfPerfAppSuiteCaseScrollIncrementalPortrait: |
|
201 case EAlfPerfAppSuiteCaseScrollIncrementalLandscape: |
|
202 { |
|
203 if( iCycleCounter == (iSuiteCount*2*KNumberOfRepeats)-1 ) |
|
204 { |
|
205 CompleteNow( KErrNone ); |
|
206 return; |
|
207 } |
|
208 |
|
209 // Bounce between suites |
|
210 if( (iCycleCounter / (iSuiteCount-1)) % 2 ) |
|
211 { |
|
212 iViewPortPos.iX -= iVisibleArea.Width(); |
|
213 } |
|
214 else |
|
215 { |
|
216 iViewPortPos.iX += iVisibleArea.Width(); |
|
217 } |
|
218 } |
|
219 break; |
|
220 |
|
221 default: |
|
222 CompleteNow( KErrNotFound ); |
|
223 return; |
|
224 } |
|
225 |
|
226 iViewPortLayout->SetViewportPos( iViewPortPos, iCycleLenght ); |
|
227 |
|
228 iCycleCounter++; |
|
229 |
|
230 TAlfCustomEventCommand command( KAlfPerfAppSuiteCmdNext, this ); |
|
231 User::LeaveIfError( Env().Send( command, iCycleLenght ) ); |
|
232 } |
|
233 |
|
234 // end of file |
|
235 |