|
1 /* |
|
2 * Copyright (c) 2002 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: Camcorder MMF API Test DLL, Tests for memory Failures |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "camcTest_3.h" |
|
22 |
|
23 // EXTERNAL DATA STRUCTURES |
|
24 |
|
25 // EXTERNAL FUNCTION PROTOTYPES |
|
26 |
|
27 // CONSTANTS |
|
28 |
|
29 // MACROS |
|
30 |
|
31 // LOCAL CONSTANTS AND MACROS |
|
32 |
|
33 // MODULE DATA STRUCTURES |
|
34 |
|
35 // LOCAL FUNCTION PROTOTYPES |
|
36 |
|
37 // FORWARD DECLARATIONS |
|
38 |
|
39 |
|
40 /////////////////////////////////////////////////////////////////// |
|
41 // Tests for memory Failures |
|
42 // |
|
43 // Should be used together with CppUnit Memory Failure option. |
|
44 // |
|
45 /////////////////////////////////////////////////////////////////// |
|
46 |
|
47 CCamcTest_3::CCamcTest_3 () |
|
48 { |
|
49 } |
|
50 |
|
51 |
|
52 |
|
53 CCamcTest_3::~CCamcTest_3 () |
|
54 { |
|
55 delete iCamcTestClient; |
|
56 iCamcTestClient = NULL; |
|
57 } |
|
58 |
|
59 |
|
60 void CCamcTest_3::setUpL () |
|
61 { |
|
62 // Do nothing in the setUp to get Memory Failure functionality |
|
63 } |
|
64 |
|
65 |
|
66 void CCamcTest_3::tearDown () |
|
67 { |
|
68 delete iCamcTestClient; |
|
69 iCamcTestClient = NULL; |
|
70 REComSession::FinalClose(); |
|
71 } |
|
72 |
|
73 |
|
74 // |
|
75 // Own test functions. |
|
76 // |
|
77 |
|
78 // ////////////////////////////////////////////////////////////////// |
|
79 // Memory Failure tests |
|
80 // ////////////////////////////////////////////////////////////////// |
|
81 |
|
82 void CCamcTest_3::NewL_001_L() |
|
83 { |
|
84 /////////////////////////////////////// |
|
85 // ID: CAMC_API.NEWL_001 |
|
86 // Action : |
|
87 // CppUnit will generate all possible Memory Failure |
|
88 // Problems. |
|
89 // Output : |
|
90 // Function should leave gracefully. |
|
91 // Precondition : |
|
92 // None |
|
93 /////////////////////////////////////// |
|
94 |
|
95 |
|
96 iWaitScheduler = new (ELeave) CActiveSchedulerWait; |
|
97 // Create a new Camera API implementation object, if supported |
|
98 TRAPD( err, iUiLevelCamera = CCamera::New2L( static_cast<MCameraObserver2&>(*this), 0 /*index*/, 0 /*Priority*/ ) ); |
|
99 if ( err ) |
|
100 { |
|
101 PRINT( ( _L( "CCamcTest_3::setUpL CCamera::New2L return code=%d" ), err ) ); |
|
102 // Create old Camera API implementation object. |
|
103 iUiLevelCamera = CCamera::NewL( static_cast<MCameraObserver&>(*this), 0 /*Index*/ ); |
|
104 } |
|
105 else |
|
106 { |
|
107 PRINT( ( _L( "CCamcTest_3::setUp() using new MCameraObserver2" )) ); |
|
108 } |
|
109 iUiLevelCameraHandle = iUiLevelCamera->Handle(); |
|
110 iUiLevelCamera->Reserve(); |
|
111 iWaitScheduler->Start(); |
|
112 |
|
113 iCamcTestClient = CCamcTestClient_3::NewL( iUiLevelCameraHandle ); |
|
114 |
|
115 delete iWaitScheduler; |
|
116 delete iUiLevelCamera; |
|
117 // Succeed, if it doesn't leave. |
|
118 } |
|
119 |
|
120 |
|
121 |
|
122 // ////////////////////////////////////////////////////////////////// |
|
123 // Dummy Camera API callback functions |
|
124 // ////////////////////////////////////////////////////////////////// |
|
125 void CCamcTest_3::ReserveComplete(TInt /*aError*/) |
|
126 { |
|
127 RDebug::Print(_L("CCamcTest_3::ReserveComplete")); |
|
128 |
|
129 // UI level camera is being initialized |
|
130 if (iWaitScheduler->IsStarted()) |
|
131 { |
|
132 iUiLevelCamera->PowerOn(); |
|
133 return; |
|
134 } |
|
135 } |
|
136 |
|
137 void CCamcTest_3::PowerOnComplete(TInt /*aError*/) |
|
138 { |
|
139 RDebug::Print(_L("CCamcTest_3::PowerOnComplete")); |
|
140 |
|
141 // UI level camera is being initialized |
|
142 if (iWaitScheduler->IsStarted()) |
|
143 { |
|
144 iWaitScheduler->AsyncStop(); |
|
145 return; |
|
146 } |
|
147 } |
|
148 |
|
149 void CCamcTest_3::ViewFinderFrameReady(CFbsBitmap& /*aFrame*/) |
|
150 { |
|
151 } |
|
152 void CCamcTest_3::ImageReady(CFbsBitmap* /*aBitmap */,HBufC8* /*aData*/,TInt /*aError*/) |
|
153 { |
|
154 } |
|
155 void CCamcTest_3::FrameBufferReady(MFrameBuffer* /*aFrameBuffer*/,TInt /*aError*/ ) |
|
156 { |
|
157 } |
|
158 |
|
159 // ----------------------------------------------------------------------------- |
|
160 // CCamcTest_3::HandleEvent |
|
161 // MCameraObserver2 call-back handler |
|
162 // ----------------------------------------------------------------------------- |
|
163 // |
|
164 void CCamcTest_3::HandleEvent( const TECAMEvent& aEvent) |
|
165 { |
|
166 PRINT(( _L( "CCamcTest_3::HandleEvent() entering, type=%x, err=%d" ), aEvent.iEventType.iUid, aEvent.iErrorCode )); |
|
167 |
|
168 if ( aEvent.iEventType == KUidECamEventCameraNoLongerReserved ) |
|
169 { |
|
170 PRINT(( _L( "CCamcTest_3::HandleEvent() KUidECamEventCameraNoLongerReserved" ) )); |
|
171 } |
|
172 else if ( aEvent.iEventType == KUidECamEventPowerOnComplete ) |
|
173 { |
|
174 PRINT(( _L( "CCamcTest_3::HandleEvent() KUidECamEventPowerOnComplete" ) )); |
|
175 PowerOnComplete( aEvent.iErrorCode ); |
|
176 } |
|
177 else if ( aEvent.iEventType == KUidECamEventReserveComplete ) |
|
178 { |
|
179 PRINT(( _L( "CCamcTest_3::HandleEvent() KUidECamEventReserveComplete" ) )); |
|
180 ReserveComplete( aEvent.iErrorCode ); |
|
181 } |
|
182 |
|
183 PRINT(( _L( "CCamcTestClient_7::HandleEvent() returning" ) )); |
|
184 } |
|
185 |
|
186 // ----------------------------------------------------------------------------- |
|
187 // CCamcTest_3::ViewFinderReady |
|
188 // MCameraObserver2 call-back handler |
|
189 // ----------------------------------------------------------------------------- |
|
190 // |
|
191 void CCamcTest_3::ViewFinderReady( MCameraBuffer& aCameraBuffer, TInt aError) |
|
192 { |
|
193 PRINT(( _L( "CCamcTest_3::ViewFinderReady() NOT HANDLED err=%d, NumFrames=%d" ), aError, aCameraBuffer.NumFrames() )); |
|
194 CFbsBitmap *buffer = NULL; |
|
195 if ( !aError ) |
|
196 { |
|
197 aCameraBuffer.Release(); |
|
198 } |
|
199 ViewFinderFrameReady( *buffer ); |
|
200 } |
|
201 |
|
202 // ----------------------------------------------------------------------------- |
|
203 // CCamcTest_3::ImageBufferReady |
|
204 // MCameraObserver2 call-back handler |
|
205 // ----------------------------------------------------------------------------- |
|
206 // |
|
207 void CCamcTest_3::ImageBufferReady( MCameraBuffer& aCameraBuffer, TInt aError) |
|
208 { |
|
209 PRINT(( _L( "CCamcTest_3::ImageBufferReady() BUFFER NOT HANDLED, err=%d, NumFrames=%d" ), aError, aCameraBuffer.NumFrames() )); |
|
210 |
|
211 if ( !aError ) |
|
212 { |
|
213 aCameraBuffer.Release(); |
|
214 } |
|
215 ImageReady( NULL, NULL, aError ); |
|
216 } |
|
217 |
|
218 // ----------------------------------------------------------------------------- |
|
219 // CCamcTest_3::VideoBufferReady |
|
220 // MCameraObserver2 call-back handler |
|
221 // ----------------------------------------------------------------------------- |
|
222 // |
|
223 void CCamcTest_3::VideoBufferReady( MCameraBuffer& aCameraBuffer, TInt aError) |
|
224 { |
|
225 PRINT(( _L( "CCamcTest_3::VideoBufferReady() entering, err=%d, NumFrames=%d" ), aError, aCameraBuffer.NumFrames() )); |
|
226 MFrameBuffer* buffer = NULL; |
|
227 |
|
228 if ( !aError ) |
|
229 { |
|
230 aCameraBuffer.Release(); |
|
231 } |
|
232 // Call old Camera-API observer handler |
|
233 FrameBufferReady( buffer, aError ); |
|
234 |
|
235 PRINT(( _L( "CCamcTest_3::VideoBufferReady() returning" ))); |
|
236 } |
|
237 |
|
238 |
|
239 // |
|
240 // An own static function to collect the test functions into one |
|
241 // suite of tests. The framework will run the tests and free the |
|
242 // memory allocated for the test suite. |
|
243 // |
|
244 |
|
245 MTest* CCamcTest_3::suiteL () |
|
246 { |
|
247 // Always use NewL (Do not use NewLC) !!! |
|
248 CTestSuite *suite = CTestSuite::NewL(_L8("CCamcTest_3")); |
|
249 |
|
250 suite->addTestL(CTestCaller<CCamcTest_3>::NewL(_L8("CAMC_API.NEWL_001"), &NewL_001_L)); |
|
251 return suite; |
|
252 } |
|
253 |