|
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/alfcontrolgroup.h> |
|
25 #include <alf/alfroster.h> |
|
26 |
|
27 #include "AlfPerfApp.hrh" |
|
28 #include "AlfPerfAppAppUi.h" |
|
29 #include "AlfPerfAppSuiteTestCase.h" |
|
30 #include "AlfPerfAppSuiteTestCaseScroll.h" |
|
31 |
|
32 // ============================= MEMBER FUNCTIONS ============================== |
|
33 |
|
34 CAlfPerfAppSuiteTestCase* CAlfPerfAppSuiteTestCase::NewL( TInt aCaseId, TInt aSequenceIndex ) |
|
35 { |
|
36 if ( !IsSupported( aCaseId ) ) |
|
37 { |
|
38 User::Leave( KErrNotSupported ); |
|
39 } |
|
40 |
|
41 CAlfPerfAppSuiteTestCase* self = new (ELeave) CAlfPerfAppSuiteTestCase( aCaseId, aSequenceIndex ); |
|
42 CleanupStack::PushL( self ); |
|
43 self->ConstructL(); |
|
44 CleanupStack::Pop( self ); |
|
45 return self; |
|
46 } |
|
47 |
|
48 CAlfPerfAppSuiteTestCase::~CAlfPerfAppSuiteTestCase() |
|
49 { |
|
50 if ( iEnv && iControl ) |
|
51 { |
|
52 iControl->CancelExecution(); |
|
53 iEnv->DeleteControlGroup( KAlfPerfAppSuiteControlGroup ); |
|
54 } |
|
55 } |
|
56 |
|
57 CAlfPerfAppSuiteTestCase::CAlfPerfAppSuiteTestCase( TInt aCaseId, TInt aSequenceIndex ) |
|
58 :CAlfPerfAppTestCase(aSequenceIndex), iCaseId( aCaseId ) |
|
59 { |
|
60 |
|
61 } |
|
62 |
|
63 void CAlfPerfAppSuiteTestCase::ConstructL() |
|
64 { |
|
65 |
|
66 } |
|
67 |
|
68 void CAlfPerfAppSuiteTestCase::SetupL( |
|
69 CAlfEnv& aEnv, |
|
70 const TRect& /*aVisibleArea*/, |
|
71 TRequestStatus& aStatus ) |
|
72 { |
|
73 iEnv = &aEnv; |
|
74 iStatus = &aStatus; |
|
75 |
|
76 // Set screen orientation |
|
77 CAlfPerfAppAppUi* appUi = (CAlfPerfAppAppUi*) EikonEnv()->AppUi(); |
|
78 switch ( iCaseId ) |
|
79 { |
|
80 case EAlfPerfAppSuiteCaseScrollContinuousPortrait: |
|
81 case EAlfPerfAppSuiteCaseScrollIncrementalPortrait: |
|
82 appUi->SetOrientationL( CAknAppUiBase::EAppUiOrientationPortrait ); |
|
83 break; |
|
84 |
|
85 case EAlfPerfAppSuiteCaseScrollContinuousLandscape: |
|
86 case EAlfPerfAppSuiteCaseScrollIncrementalLandscape: |
|
87 appUi->SetOrientationL( CAknAppUiBase::EAppUiOrientationLandscape ); |
|
88 break; |
|
89 |
|
90 default: |
|
91 User::Leave( KErrNotSupported ); |
|
92 break; |
|
93 } |
|
94 |
|
95 |
|
96 // Create new fullscreen display |
|
97 TRect rect; |
|
98 AknLayoutUtils::LayoutMetricsRect( |
|
99 AknLayoutUtils::EApplicationWindow, |
|
100 rect ); |
|
101 |
|
102 iEnv->SetFullScreenDrawing( ETrue ); |
|
103 CAlfDisplay& display = |
|
104 iEnv->NewDisplayL( rect, CAlfEnv::ENewDisplayFullScreen ); |
|
105 |
|
106 display.SetClearBackgroundL( CAlfDisplay::EClearWithSkinBackground ); |
|
107 |
|
108 // Create control group |
|
109 CAlfControlGroup& group = |
|
110 iEnv->NewControlGroupL( KAlfPerfAppSuiteControlGroup ); |
|
111 |
|
112 // Create testcase control |
|
113 CAlfPerfAppSuiteTestCaseControl* control = NULL; |
|
114 switch ( iCaseId ) |
|
115 { |
|
116 case EAlfPerfAppSuiteCaseScrollContinuousPortrait: |
|
117 case EAlfPerfAppSuiteCaseScrollIncrementalPortrait: |
|
118 case EAlfPerfAppSuiteCaseScrollContinuousLandscape: |
|
119 case EAlfPerfAppSuiteCaseScrollIncrementalLandscape: |
|
120 control = new (ELeave) CAlfPerfAppSuiteTestCaseScroll(this); |
|
121 break; |
|
122 |
|
123 default: |
|
124 User::Leave( KErrNotSupported ); |
|
125 break; |
|
126 } |
|
127 |
|
128 CleanupStack::PushL( control ); |
|
129 control->ConstructL( *iEnv, iCaseId, rect ); |
|
130 group.AppendL( control ); // ownership passed to control group. |
|
131 iControl = control; |
|
132 CleanupStack::Pop( control ); |
|
133 |
|
134 // Ready for showing |
|
135 display.Roster().ShowL( group ); |
|
136 |
|
137 // ImagesLoaded() send the status completion. |
|
138 } |
|
139 |
|
140 void CAlfPerfAppSuiteTestCase::ExecuteL( TRequestStatus& aStatus ) |
|
141 { |
|
142 // SetupL must have been called first. |
|
143 __ASSERT_ALWAYS( iEnv, User::Invariant() ); |
|
144 __ASSERT_ALWAYS( iControl, User::Invariant() ); |
|
145 |
|
146 iControl->StartExecuteL( aStatus ); |
|
147 } |
|
148 |
|
149 void CAlfPerfAppSuiteTestCase::TearDown() |
|
150 { |
|
151 // Execution side will delete CAlfEnv, so it will delete everything |
|
152 // related to this. |
|
153 iEnv = NULL; |
|
154 iControl = NULL; |
|
155 |
|
156 // Return orientation back to normal |
|
157 CAlfPerfAppAppUi* appUi = (CAlfPerfAppAppUi*) EikonEnv()->AppUi(); |
|
158 TRAP_IGNORE(appUi->SetOrientationL( CAknAppUiBase::EAppUiOrientationUnspecified )); |
|
159 } |
|
160 |
|
161 void CAlfPerfAppSuiteTestCase::ImagesLoaded( TInt aErrorCode ) |
|
162 { |
|
163 if( iStatus ) |
|
164 { |
|
165 CAlfPerfAppTestCase::CompleteNow( *iStatus, aErrorCode ); |
|
166 iStatus = 0; |
|
167 } |
|
168 } |
|
169 |
|
170 void CAlfPerfAppSuiteTestCase::HandleVisibleAreaChange( const TRect& aRect ) |
|
171 { |
|
172 if ( iEnv && iControl ) |
|
173 { |
|
174 if ( iEnv->DisplayCount() > 0 ) |
|
175 { |
|
176 iEnv->PrimaryDisplay().SetVisibleArea( aRect ); |
|
177 } |
|
178 iControl->SetVisibleArea( aRect ); |
|
179 } |
|
180 } |
|
181 |
|
182 TInt CAlfPerfAppSuiteTestCase::CaseID() |
|
183 { |
|
184 return iCaseId; |
|
185 } |
|
186 |
|
187 TBool CAlfPerfAppSuiteTestCase::IsSupported( TInt aCaseId ) |
|
188 { |
|
189 return aCaseId > EAlfPerfAppSuiteMin && |
|
190 aCaseId < EAlfPerfAppSuiteMax; |
|
191 } |
|
192 |
|
193 // end of file |