|
1 /* |
|
2 * Copyright (c) 2007 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: Implements unit tests for CMusIndicatorApi class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "ut_cmusindicatorapi.h" |
|
21 #include "musindicatorapi.h" |
|
22 #include "mussoundplayer.h" |
|
23 #include "mussettingskeys.h" |
|
24 #include <digia/eunit/eunitmacros.h> |
|
25 #include <AknGlobalMsgQuery.h> |
|
26 #include <AknGlobalConfirmationQuery.h> |
|
27 #include <coreapplicationuisdomainpskeys.h> |
|
28 |
|
29 // Next row is to disable warning emerging from EUnit code. |
|
30 #pragma warn_illtokenpasting off |
|
31 |
|
32 |
|
33 // ======== MEMBER FUNCTIONS ======== |
|
34 |
|
35 |
|
36 UT_CMusIndicatorApi* UT_CMusIndicatorApi::NewL() |
|
37 { |
|
38 UT_CMusIndicatorApi* self = UT_CMusIndicatorApi::NewLC(); |
|
39 CleanupStack::Pop( self ); |
|
40 return self; |
|
41 } |
|
42 |
|
43 |
|
44 UT_CMusIndicatorApi* UT_CMusIndicatorApi::NewLC() |
|
45 { |
|
46 UT_CMusIndicatorApi* self = new( ELeave ) UT_CMusIndicatorApi(); |
|
47 CleanupStack::PushL( self ); |
|
48 self->ConstructL(); |
|
49 return self; |
|
50 } |
|
51 |
|
52 |
|
53 UT_CMusIndicatorApi::~UT_CMusIndicatorApi() |
|
54 { |
|
55 } |
|
56 |
|
57 |
|
58 UT_CMusIndicatorApi::UT_CMusIndicatorApi() |
|
59 { |
|
60 } |
|
61 |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
65 // It generates the test case table. |
|
66 // --------------------------------------------------------------------------- |
|
67 // |
|
68 void UT_CMusIndicatorApi::ConstructL() |
|
69 { |
|
70 CEUnitTestSuiteClass::ConstructL(); |
|
71 } |
|
72 |
|
73 |
|
74 // ---------------------------------------------------------------------------- |
|
75 // Prepares a test for execution. |
|
76 // ---------------------------------------------------------------------------- |
|
77 // |
|
78 void UT_CMusIndicatorApi::SetupL() |
|
79 { |
|
80 iIndicatorApi = CMusIndicatorApi::NewL( *this ); |
|
81 iStartLiveSharingLCalled = EFalse; |
|
82 } |
|
83 |
|
84 |
|
85 // ---------------------------------------------------------------------------- |
|
86 // Finalizes a test by releasing used resources. |
|
87 // ---------------------------------------------------------------------------- |
|
88 // |
|
89 void UT_CMusIndicatorApi::Teardown() |
|
90 { |
|
91 delete iIndicatorApi; |
|
92 PropertyHelper::Close(); |
|
93 |
|
94 } |
|
95 |
|
96 |
|
97 // ---------------------------------------------------------------------------- |
|
98 // From MMusIndicatorObserver. |
|
99 // Instructs to start live video sharing. |
|
100 // ---------------------------------------------------------------------------- |
|
101 // |
|
102 void UT_CMusIndicatorApi::StartLiveSharingL() |
|
103 { |
|
104 iStartLiveSharingLCalled = ETrue; |
|
105 } |
|
106 |
|
107 |
|
108 // ======== UNIT TEST METHODS ======== |
|
109 |
|
110 |
|
111 // ---------------------------------------------------------------------------- |
|
112 // Asserts that instantiation is successful. |
|
113 // ---------------------------------------------------------------------------- |
|
114 // |
|
115 void UT_CMusIndicatorApi::UT_CMusIndicatorApi_NewLL() |
|
116 { |
|
117 EUNIT_ASSERT( iIndicatorApi ); |
|
118 } |
|
119 |
|
120 |
|
121 // ---------------------------------------------------------------------------- |
|
122 // Dummy test. @TODO: Can this be tested? |
|
123 // ---------------------------------------------------------------------------- |
|
124 // |
|
125 void UT_CMusIndicatorApi::UT_CMusIndicatorApi_IndicateAvailabilityLL() |
|
126 { |
|
127 iIndicatorApi->IndicateAvailabilityL(); |
|
128 } |
|
129 |
|
130 |
|
131 // ---------------------------------------------------------------------------- |
|
132 // Asserts that start livesharing is called only when there is no error. |
|
133 // ---------------------------------------------------------------------------- |
|
134 // |
|
135 void UT_CMusIndicatorApi::UT_CMusIndicatorApi_RunLL() |
|
136 { |
|
137 User::LeaveIfError( RProperty::Define( |
|
138 KPSUidCoreApplicationUIs, |
|
139 KCoreAppUIsVideoSharingIndicator, |
|
140 RProperty::EInt, |
|
141 0 ) ); |
|
142 |
|
143 User::LeaveIfError( RProperty::Set( |
|
144 KPSUidCoreApplicationUIs, |
|
145 KCoreAppUIsVideoSharingIndicator, |
|
146 ( TInt ) ECoreAppUIsVideoSharingIndicatorOn ) ); |
|
147 |
|
148 iIndicatorApi->Cancel(); |
|
149 iIndicatorApi->iStatus = KErrNotFound; |
|
150 iIndicatorApi->RunL(); |
|
151 EUNIT_ASSERT( !iStartLiveSharingLCalled ); |
|
152 |
|
153 iIndicatorApi->Cancel(); |
|
154 iIndicatorApi->iStatus = KErrNone; |
|
155 iIndicatorApi->RunL(); |
|
156 EUNIT_ASSERT( iStartLiveSharingLCalled ); |
|
157 |
|
158 EUNIT_ASSERT( !iIndicatorApi->IsSubscriber() ); |
|
159 |
|
160 iIndicatorApi->iObserver = NULL; |
|
161 EUNIT_ASSERT( iIndicatorApi->IsSubscriber() ); |
|
162 iIndicatorApi->Indicator( ETrue ); |
|
163 |
|
164 iIndicatorApi->Cancel(); |
|
165 |
|
166 iIndicatorApi->RunL(); |
|
167 |
|
168 } |
|
169 |
|
170 |
|
171 // ---------------------------------------------------------------------------- |
|
172 // Asserts that DoCancel removes current activity. |
|
173 // ---------------------------------------------------------------------------- |
|
174 // |
|
175 void UT_CMusIndicatorApi::UT_CMusIndicatorApi_DoCancelL() |
|
176 { |
|
177 iIndicatorApi->Cancel(); |
|
178 EUNIT_ASSERT( !iIndicatorApi->IsActive() ); |
|
179 |
|
180 } |
|
181 |
|
182 |
|
183 // ---------------------------------------------------------------------------- |
|
184 // Asserts that method returns KErrNone. |
|
185 // ---------------------------------------------------------------------------- |
|
186 // |
|
187 void UT_CMusIndicatorApi::UT_CMusIndicatorApi_RunErrorL() |
|
188 { |
|
189 EUNIT_ASSERT( KErrNone == iIndicatorApi->RunError( KErrGeneral ) ); |
|
190 EUNIT_ASSERT( KErrNone == iIndicatorApi->RunError( KErrNone ) ); |
|
191 EUNIT_ASSERT( KErrNone == iIndicatorApi->RunError( KErrCancel ) ); |
|
192 } |
|
193 |
|
194 |
|
195 // ---------------------------------------------------------------------------- |
|
196 // Asserts that tested method deletes soundplayer. |
|
197 // ---------------------------------------------------------------------------- |
|
198 // |
|
199 void UT_CMusIndicatorApi::UT_CMusIndicatorApi_PlaySoundCompleteL() |
|
200 { |
|
201 iIndicatorApi->iSoundPlayer = CMusSoundPlayer::NewL( *iIndicatorApi ); |
|
202 iIndicatorApi->PlaySoundComplete( KErrNone ); |
|
203 EUNIT_ASSERT( !iIndicatorApi->iSoundPlayer ); |
|
204 iIndicatorApi->PlaySoundComplete( KErrGeneral ); |
|
205 EUNIT_ASSERT( !iIndicatorApi->iSoundPlayer ); |
|
206 } |
|
207 |
|
208 |
|
209 // ---------------------------------------------------------------------------- |
|
210 // Asserts that method creates sound player. |
|
211 // ---------------------------------------------------------------------------- |
|
212 // |
|
213 void UT_CMusIndicatorApi::UT_CMusIndicatorApi_PlayToneLL() |
|
214 { |
|
215 iIndicatorApi->PlayToneL(); |
|
216 EUNIT_ASSERT( iIndicatorApi->iSoundPlayer ); |
|
217 } |
|
218 |
|
219 |
|
220 // ======== EUNIT TEST TABLE ======== |
|
221 |
|
222 |
|
223 EUNIT_BEGIN_TEST_TABLE( |
|
224 UT_CMusIndicatorApi, |
|
225 "UT_CMusIndicatorApi", |
|
226 "UNIT" ) |
|
227 |
|
228 EUNIT_TEST( |
|
229 "NewL - test ", |
|
230 "CMusIndicatorApi", |
|
231 "NewL", |
|
232 "FUNCTIONALITY", |
|
233 SetupL, UT_CMusIndicatorApi_NewLL, Teardown ) |
|
234 |
|
235 EUNIT_TEST( |
|
236 "IndicateAvailabilityL - test ", |
|
237 "CMusIndicatorApi", |
|
238 "IndicateAvailabilityL", |
|
239 "FUNCTIONALITY", |
|
240 SetupL, UT_CMusIndicatorApi_IndicateAvailabilityLL, Teardown ) |
|
241 |
|
242 EUNIT_TEST( |
|
243 "RunL - test ", |
|
244 "CMusIndicatorApi", |
|
245 "RunL", |
|
246 "FUNCTIONALITY", |
|
247 SetupL, UT_CMusIndicatorApi_RunLL, Teardown ) |
|
248 |
|
249 EUNIT_TEST( |
|
250 "DoCancel - test ", |
|
251 "CMusIndicatorApi", |
|
252 "DoCancel", |
|
253 "FUNCTIONALITY", |
|
254 SetupL, UT_CMusIndicatorApi_DoCancelL, Teardown ) |
|
255 |
|
256 EUNIT_TEST( |
|
257 "RunError - test ", |
|
258 "CMusIndicatorApi", |
|
259 "RunError", |
|
260 "FUNCTIONALITY", |
|
261 SetupL, UT_CMusIndicatorApi_RunErrorL, Teardown ) |
|
262 |
|
263 EUNIT_TEST( |
|
264 "PlaySoundComplete - test ", |
|
265 "CMusIndicatorApi", |
|
266 "PlaySoundComplete", |
|
267 "FUNCTIONALITY", |
|
268 SetupL, UT_CMusIndicatorApi_PlaySoundCompleteL, Teardown ) |
|
269 |
|
270 EUNIT_TEST( |
|
271 "PlayToneL - test ", |
|
272 "CMusIndicatorApi", |
|
273 "PlayToneL", |
|
274 "FUNCTIONALITY", |
|
275 SetupL, UT_CMusIndicatorApi_PlayToneLL, Teardown ) |
|
276 |
|
277 |
|
278 |
|
279 EUNIT_END_TEST_TABLE |