|
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 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @internalComponent - Internal Symbian test code |
|
19 */ |
|
20 |
|
21 |
|
22 #include "TOomStep.h" |
|
23 #include "AnimationConfig.h" |
|
24 #include "AnimationTestServer.h" |
|
25 |
|
26 _LIT(KSymBallFile, "Z:\\Private\\10204F5B\\symball.gif"); |
|
27 |
|
28 // |
|
29 // Windows: |
|
30 // |
|
31 COomAnimationWindow::COomAnimationWindow(RWsSession& aWsSession, CTestWindowGroup& aGroup, CWindowGc& aGc) : CTestWindow(aWsSession, aGroup, aGc) |
|
32 { |
|
33 } |
|
34 |
|
35 void COomAnimationWindow::SetAnimation(CBasicAnimation* aAnimation) |
|
36 { |
|
37 iAnimation = aAnimation; |
|
38 } |
|
39 |
|
40 void COomAnimationWindow::DrawL() |
|
41 { |
|
42 if(iAnimation) |
|
43 iAnimation->Draw(iGc); |
|
44 } |
|
45 |
|
46 // |
|
47 // The test: |
|
48 // |
|
49 COomStep::COomStep() |
|
50 { |
|
51 SetTestStepName(KOomStep); |
|
52 } |
|
53 |
|
54 COomStep::~COomStep() |
|
55 { |
|
56 delete iOomWin; |
|
57 } |
|
58 |
|
59 void COomStep::InitialiseL() |
|
60 { |
|
61 CAnimationTestStep::InitialiseL(); |
|
62 |
|
63 ANIM_INFO1(_L("Begin test OOM")); |
|
64 |
|
65 TInt winborder = 2; |
|
66 iWinSize = Screen()->SizeInPixels(); |
|
67 iWinSize.iWidth /= 2; |
|
68 iWinPosition = TPoint(iWinSize.iWidth + winborder, winborder); |
|
69 iWinSize.iWidth -= winborder * 2; |
|
70 iWinSize.iHeight -= winborder * 2; |
|
71 |
|
72 iOomWin = new (ELeave) COomAnimationWindow(Ws(), *GroupWin(), *Gc()); |
|
73 iOomWin->Window()->SetRequiredDisplayMode(EColor256); |
|
74 iOomWin->Window()->SetExtent(iWinPosition, iWinSize); |
|
75 iOomWin->Window()->SetBackgroundColor(iBackgroundColor1); |
|
76 iOomWin->Window()->SetVisible(ETrue); |
|
77 iOomWin->Window()->Activate(); |
|
78 } |
|
79 |
|
80 /** |
|
81 @SYMTestCaseID UIF-animation-TOomStep-TestLoopingL |
|
82 |
|
83 @SYMTestCaseDesc |
|
84 This tests basic animation and sprite animation in a low memory |
|
85 condition. |
|
86 |
|
87 @SYMPREQ 269 |
|
88 |
|
89 @SYMTestStatus Implemented |
|
90 |
|
91 @SYMTestPriority Medium |
|
92 |
|
93 @SYMTestActions |
|
94 The test starts and stops animation for a basic and sprite |
|
95 animation group in a low memory condition. It initializes an animation |
|
96 group with a basic and sprite animation and which it then starts and stops. |
|
97 Finally the animation group and the animations are destroyed. |
|
98 |
|
99 @SYMTestExpectedResults This function leaves with a memory failure if there |
|
100 is insufficient memory for the test to run. |
|
101 |
|
102 */ |
|
103 void COomStep::TestLoopingL() |
|
104 { |
|
105 TAnimationConfig config; |
|
106 config.iFlags = TAnimationConfig::ELoop; |
|
107 config.iData = -1; |
|
108 |
|
109 CICLAnimationDataProvider* dataProvider; |
|
110 dataProvider=new(ELeave)CICLAnimationDataProvider; |
|
111 CleanupStack::PushL(dataProvider); |
|
112 dataProvider->SetFileL(iFs, KSymBallFile()); |
|
113 CleanupStack::Pop(dataProvider); |
|
114 CBasicAnimation * basicAnimation = CBasicAnimation::NewL(dataProvider, TPoint(0,0), Ws(), *iOomWin->Window()); |
|
115 CleanupStack::PushL(basicAnimation); |
|
116 iOomWin->SetAnimation(basicAnimation); |
|
117 |
|
118 dataProvider=new(ELeave)CICLAnimationDataProvider; |
|
119 CleanupStack::PushL(dataProvider); |
|
120 dataProvider->SetFileL(iFs, KSymBallFile()); |
|
121 CleanupStack::Pop(dataProvider); |
|
122 CSpriteAnimation * spriteAnimation = CSpriteAnimation::NewL(dataProvider, TPoint(100,100), Ws(), *iOomWin->Window()); |
|
123 CleanupStack::PushL(spriteAnimation); |
|
124 |
|
125 CAnimationGroup * animationGroup = CAnimationGroup::NewL(); |
|
126 CleanupStack::PushL(animationGroup); |
|
127 animationGroup->Animations().Append(basicAnimation); |
|
128 animationGroup->Animations().Append(spriteAnimation); |
|
129 |
|
130 Wait(2000000); // Wait for the initialisation to complete |
|
131 animationGroup->Start(config); |
|
132 Wait(5000000); |
|
133 animationGroup->Stop(); |
|
134 |
|
135 Wait(500000); |
|
136 |
|
137 CleanupStack::PopAndDestroy(animationGroup); |
|
138 CleanupStack::PopAndDestroy(spriteAnimation); |
|
139 CleanupStack::PopAndDestroy(basicAnimation); |
|
140 } |
|
141 |
|
142 void COomStep::RunTestL(TInt aTest) |
|
143 { |
|
144 switch(aTest) |
|
145 { |
|
146 case 0: |
|
147 TestLoopingL(); |
|
148 break; |
|
149 default: |
|
150 User::Leave(KErrArgument); |
|
151 } |
|
152 } |
|
153 /** |
|
154 |
|
155 @SYMTestCaseID UIF-animation-TOomStep-doActiveTestStepL |
|
156 |
|
157 @SYMTestCaseDesc |
|
158 This tests basic animation and sprite animation in a low memory |
|
159 condition. |
|
160 |
|
161 @SYMPREQ 269 |
|
162 |
|
163 @SYMTestStatus Implemented |
|
164 |
|
165 @SYMTestPriority Medium |
|
166 |
|
167 @SYMTestActions |
|
168 The test starts and stops animation for a basic and sprite |
|
169 animation group in a low memory condition, and records how many cells are |
|
170 required to be available for the test to pass. It starts at 1 free cell, and calls |
|
171 test RunTestL and increments then increments the number of free cells until TestLoopingL |
|
172 operates without leaving. |
|
173 |
|
174 @SYMTestExpectedResults Pass |
|
175 |
|
176 */ |
|
177 TVerdict COomStep::doActiveTestStepL() |
|
178 { |
|
179 InitialiseL(); |
|
180 |
|
181 // ## Immediately return. It looks as though ICL leaks. Once that is fixed we can |
|
182 // ## try running this test. |
|
183 // ## see DEF050483 |
|
184 |
|
185 const TInt KNumTests = 1; |
|
186 Wait(2000000); // Wait for windows and things to initialise their own memory. |
|
187 |
|
188 if(TestStepResult() == EPass) |
|
189 { |
|
190 __UHEAP_MARK; |
|
191 SetTestStepID(_L("UIF-animation-TOomStep-TestLoopingL")); |
|
192 for (TInt stage = 0; stage < KNumTests; ++stage) |
|
193 { |
|
194 TInt fail = 1; |
|
195 TInt passes = 0; |
|
196 while (passes < 6) |
|
197 { |
|
198 __UHEAP_FAILNEXT(fail); |
|
199 TRAPD(err, RunTestL(stage)); |
|
200 if (err == KErrNone) |
|
201 ++passes; |
|
202 else if (err == KErrNoMemory) |
|
203 passes = 0; |
|
204 else |
|
205 User::Leave(err); |
|
206 __UHEAP_RESET; |
|
207 ++fail; |
|
208 } |
|
209 INFO_PRINTF3(_L("OOM Test %d passed after %d attempts"), stage, fail - passes); |
|
210 } |
|
211 REComSession::FinalClose(); |
|
212 iAnimTestWin->iScreen.ReleaseFont(iAnimTestWin->iFont); |
|
213 delete iScreen; |
|
214 RFbsSession::Disconnect(); |
|
215 RecordTestResultL(); |
|
216 CloseTMSGraphicsStep(); |
|
217 __UHEAP_MARKEND; |
|
218 RFbsSession::Connect(); |
|
219 } |
|
220 |
|
221 return TestStepResult(); |
|
222 } |
|
223 |