|
1 /* |
|
2 * Copyright (c) 2009 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 // INTERNAL INCLUDES |
|
20 #include "ut_musengorientationhandler.h" |
|
21 #include "musengorientationhandler.h" |
|
22 #include "musengstubs.h" |
|
23 #include "musengtestdefs.h" |
|
24 #include "musenglivesession.h" |
|
25 #include "musengmceutils.h" |
|
26 #include <mcecamerasource.h> |
|
27 #include <mcedisplaysink.h> |
|
28 |
|
29 // SYSTEM INCLUDES |
|
30 #include <digia/eunit/eunitmacros.h> |
|
31 |
|
32 |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 // ----------------------------------------------------------------------------- |
|
36 // |
|
37 UT_CMusEngOrientationHandler* UT_CMusEngOrientationHandler::NewL() |
|
38 { |
|
39 UT_CMusEngOrientationHandler* self = UT_CMusEngOrientationHandler::NewLC(); |
|
40 CleanupStack::Pop( self ); |
|
41 return self; |
|
42 } |
|
43 |
|
44 |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 UT_CMusEngOrientationHandler* UT_CMusEngOrientationHandler::NewLC() |
|
50 { |
|
51 UT_CMusEngOrientationHandler* self = new( ELeave ) UT_CMusEngOrientationHandler(); |
|
52 CleanupStack::PushL( self ); |
|
53 self->ConstructL(); |
|
54 return self; |
|
55 } |
|
56 |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 UT_CMusEngOrientationHandler::~UT_CMusEngOrientationHandler() |
|
63 { |
|
64 // NOP |
|
65 } |
|
66 |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // Default constructor |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 UT_CMusEngOrientationHandler::UT_CMusEngOrientationHandler() |
|
73 { |
|
74 // NOP |
|
75 } |
|
76 |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // Second phase construct |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 void UT_CMusEngOrientationHandler::ConstructL() |
|
83 { |
|
84 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
85 // It generates the test case table. |
|
86 CEUnitTestSuiteClass::ConstructL(); |
|
87 } |
|
88 |
|
89 |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 // ----------------------------------------------------------------------------- |
|
93 // |
|
94 void UT_CMusEngOrientationHandler::SetupL() |
|
95 { |
|
96 iObserver = new( ELeave ) CMusEngObserverStub; |
|
97 |
|
98 iLiveSession = CMusEngLiveSession::NewL( TRect(0, 0, 100, 100), |
|
99 *iObserver, |
|
100 *iObserver, |
|
101 *iObserver ); |
|
102 |
|
103 iLiveSession->iOperatorVariant = EFalse; |
|
104 |
|
105 iHandler = CMusEngOrientationHandler::NewL( *iLiveSession, *iObserver ); |
|
106 } |
|
107 |
|
108 |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 // ----------------------------------------------------------------------------- |
|
112 // |
|
113 void UT_CMusEngOrientationHandler::Teardown() |
|
114 { |
|
115 delete iHandler; |
|
116 delete iLiveSession; |
|
117 delete iObserver; |
|
118 } |
|
119 |
|
120 |
|
121 |
|
122 // TEST CASES |
|
123 |
|
124 |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 // ----------------------------------------------------------------------------- |
|
128 // |
|
129 void UT_CMusEngOrientationHandler::UT_NewLL() |
|
130 { |
|
131 EUNIT_ASSERT( iHandler ); |
|
132 } |
|
133 |
|
134 // ----------------------------------------------------------------------------- |
|
135 // |
|
136 // ----------------------------------------------------------------------------- |
|
137 // |
|
138 void UT_CMusEngOrientationHandler::UT_RefreshOrientationL() |
|
139 { |
|
140 ESTABLISH_OUT_SESSION( iLiveSession ) |
|
141 |
|
142 // Refresh when both camera and display are enabled |
|
143 CMceCameraSource* camera = |
|
144 MusEngMceUtils::GetCameraL( *(iLiveSession->iSession) ); |
|
145 camera->iIsEnabled = ETrue; |
|
146 CMceDisplaySink* display = |
|
147 MusEngMceUtils::GetDisplayL( *(iLiveSession->iSession) ); |
|
148 display->iIsEnabled = ETrue; |
|
149 EUNIT_ASSERT( !iHandler->IsActive() ); |
|
150 iHandler->RefreshOrientationL(); |
|
151 EUNIT_ASSERT( iHandler->IsActive() ); |
|
152 EUNIT_ASSERT( !camera->iIsEnabled ); |
|
153 EUNIT_ASSERT( !display->iIsEnabled ); |
|
154 iHandler->Cancel(); |
|
155 iHandler->RunL(); // Simulate completion |
|
156 EUNIT_ASSERT( !iHandler->IsActive() ); |
|
157 EUNIT_ASSERT( camera->iIsEnabled ); |
|
158 EUNIT_ASSERT( display->iIsEnabled ); |
|
159 |
|
160 // Refresh when camera is disabled, display disabled |
|
161 camera->iIsEnabled = EFalse; |
|
162 display->iIsEnabled = ETrue; |
|
163 iHandler->RefreshOrientationL(); |
|
164 EUNIT_ASSERT( iHandler->IsActive() ); |
|
165 EUNIT_ASSERT( !camera->iIsEnabled ); |
|
166 EUNIT_ASSERT( !display->iIsEnabled ); |
|
167 iHandler->Cancel(); |
|
168 iHandler->RunL(); // Simulate completion |
|
169 EUNIT_ASSERT( !iHandler->IsActive() ); |
|
170 EUNIT_ASSERT( !camera->iIsEnabled ); |
|
171 EUNIT_ASSERT( display->iIsEnabled ); |
|
172 |
|
173 // Display and camera gets resumed while delayed orientation handling is ongoing, pausing |
|
174 // display after handling completes should not happen |
|
175 camera->iIsEnabled = ETrue; |
|
176 display->iIsEnabled = EFalse; |
|
177 iHandler->RefreshOrientationL(); |
|
178 EUNIT_ASSERT( iHandler->IsActive() ); |
|
179 EUNIT_ASSERT( !camera->iIsEnabled ); |
|
180 EUNIT_ASSERT( !display->iIsEnabled ); |
|
181 display->iIsEnabled = ETrue; |
|
182 camera->iIsEnabled = ETrue; |
|
183 iHandler->UpdateL(); |
|
184 iHandler->Cancel(); |
|
185 iHandler->RunL(); // Simulate completion |
|
186 EUNIT_ASSERT( !iHandler->IsActive() ); |
|
187 EUNIT_ASSERT( camera->iIsEnabled ); |
|
188 EUNIT_ASSERT( display->iIsEnabled ); |
|
189 } |
|
190 |
|
191 |
|
192 // TEST TABLE |
|
193 |
|
194 EUNIT_BEGIN_TEST_TABLE( |
|
195 UT_CMusEngOrientationHandler, |
|
196 "UT_CMusEngLiveSesssion", |
|
197 "UNIT" ) |
|
198 |
|
199 EUNIT_TEST( |
|
200 "NewL - test ", |
|
201 "CMusEngOrienationHandler", |
|
202 "NewL", |
|
203 "FUNCTIONALITY", |
|
204 SetupL, UT_NewLL, Teardown) |
|
205 |
|
206 EUNIT_TEST( |
|
207 "UT_RefreshOrientationL - test ", |
|
208 "CMusEngOrienationHandler", |
|
209 "NewL", |
|
210 "FUNCTIONALITY", |
|
211 SetupL, UT_RefreshOrientationL, Teardown) |
|
212 |
|
213 EUNIT_END_TEST_TABLE |
|
214 |
|
215 // END OF FILE |
|
216 |
|
217 |