|
1 /* |
|
2 * Copyright (c) 2006 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: AIW Service Handler stub implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // CLASS HEADER |
|
22 #include "t_CGlxAiwServiceHandler.h" |
|
23 |
|
24 // EXTERNAL INCLUDES |
|
25 #include <avkon.hrh> |
|
26 #include <EUnitMacros.h> |
|
27 #include <EUnitDecorators.h> |
|
28 #include <mpxmediageneraldefs.h> // For Attribute constants |
|
29 #include <glxcommandhandlers.hrh> |
|
30 #include <mglxmedialist.h> |
|
31 #include <AiwGenericParam.hrh> |
|
32 #include <AiwGenericParam.h> |
|
33 #include <aiwvariant.h> |
|
34 // INTERNAL INCLUDES |
|
35 #include "glxaiwservicehandler.h" |
|
36 |
|
37 // CONSTRUCTION |
|
38 t_CGlxAiwServiceHandler* t_CGlxAiwServiceHandler::NewL() |
|
39 { |
|
40 t_CGlxAiwServiceHandler* self = t_CGlxAiwServiceHandler::NewLC(); |
|
41 CleanupStack::Pop(); |
|
42 |
|
43 return self; |
|
44 } |
|
45 |
|
46 t_CGlxAiwServiceHandler* t_CGlxAiwServiceHandler::NewLC() |
|
47 { |
|
48 t_CGlxAiwServiceHandler* self = new( ELeave ) t_CGlxAiwServiceHandler(); |
|
49 CleanupStack::PushL( self ); |
|
50 |
|
51 self->ConstructL(); |
|
52 |
|
53 return self; |
|
54 } |
|
55 |
|
56 // Destructor (virtual by CBase) |
|
57 t_CGlxAiwServiceHandler::~t_CGlxAiwServiceHandler() |
|
58 { |
|
59 } |
|
60 |
|
61 // Default constructor |
|
62 t_CGlxAiwServiceHandler::t_CGlxAiwServiceHandler() |
|
63 { |
|
64 } |
|
65 |
|
66 // Second phase construct |
|
67 void t_CGlxAiwServiceHandler::ConstructL() |
|
68 { |
|
69 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
70 // It generates the test case table. |
|
71 CEUnitTestSuiteClass::ConstructL(); |
|
72 } |
|
73 |
|
74 |
|
75 // METHODS |
|
76 void t_CGlxAiwServiceHandler::SetupL( ) |
|
77 { |
|
78 iAiwServiceHandler = CGlxAiwServiceHandler::InstanceL(); |
|
79 } |
|
80 |
|
81 |
|
82 void t_CGlxAiwServiceHandler::Teardown( ) |
|
83 { |
|
84 iAiwServiceHandler->Close(); |
|
85 } |
|
86 |
|
87 void t_CGlxAiwServiceHandler::TestConstructionL( ) |
|
88 { |
|
89 // Only testing for leaks during setup/teardown here |
|
90 EUNIT_ASSERT(ETrue); |
|
91 } |
|
92 |
|
93 void t_CGlxAiwServiceHandler::OneImageUniqueParamsL() |
|
94 { |
|
95 _LIT(KImageUri ,"c:\\Data\\Images\\Image01.jpg"); |
|
96 _LIT(KImageMimeType, "image/jpeg"); |
|
97 |
|
98 // First Create a Dummy Menu pane (for use later) |
|
99 CEikMenuPane* dummyMenuPane = new (ELeave) CEikMenuPane(this); |
|
100 CleanupStack::PushL(dummyMenuPane); |
|
101 |
|
102 // Create a Media Id |
|
103 TGlxMedia Image(TGlxMediaId(1)); |
|
104 |
|
105 // Add the Uri and MimeType parameters to internal array |
|
106 iAiwServiceHandler->AddParamL(Image.Id(), TAiwGenericParam( EGenericParamFile, TAiwVariant( KImageUri ) )); |
|
107 iAiwServiceHandler->AddParamL(Image.Id(), TAiwGenericParam( EGenericParamMIMEType, TAiwVariant( KImageMimeType ) )); |
|
108 |
|
109 // Now transfer the parameters from our array to the InParams |
|
110 iAiwServiceHandler->HandleSubmenuL(*dummyMenuPane); |
|
111 |
|
112 CleanupStack::PopAndDestroy(dummyMenuPane); |
|
113 |
|
114 // Now get the InParams to see if it contains what it should |
|
115 CAiwGenericParamList& InParams = iAiwServiceHandler->GetInParams(); |
|
116 |
|
117 // Check the count is 2 |
|
118 TInt paramCount = InParams.Count(); |
|
119 EUNIT_ASSERT( paramCount == 2); |
|
120 |
|
121 // Check the Uri is correct |
|
122 TPtrC uri; |
|
123 InParams[0].Value().Get(uri); |
|
124 EUNIT_ASSERT(0 == uri.Compare(KImageUri)); |
|
125 |
|
126 // Check the MimeType is correct |
|
127 TPtrC mimeType; |
|
128 InParams[1].Value().Get(mimeType); |
|
129 EUNIT_ASSERT(0 == mimeType.Compare(KImageMimeType)); |
|
130 } |
|
131 |
|
132 void t_CGlxAiwServiceHandler::OneImageDuplicateParamsL() |
|
133 { |
|
134 _LIT(KImageUri ,"c:\\Data\\Images\\Image01.jpg"); |
|
135 _LIT(KImageMimeType, "image/jpeg"); |
|
136 |
|
137 // First Create a Dummy Menu pane (for use later) |
|
138 CEikMenuPane* dummyMenuPane = new (ELeave) CEikMenuPane(this); |
|
139 CleanupStack::PushL(dummyMenuPane); |
|
140 |
|
141 // Create a Media Id |
|
142 TGlxMedia Image(TGlxMediaId(1)); |
|
143 |
|
144 // Add the Uri and MimeType parameters to internal array |
|
145 iAiwServiceHandler->AddParamL(Image.Id(), TAiwGenericParam( EGenericParamFile, TAiwVariant( KImageUri ) )); |
|
146 iAiwServiceHandler->AddParamL(Image.Id(), TAiwGenericParam( EGenericParamMIMEType, TAiwVariant( KImageMimeType ) )); |
|
147 |
|
148 // Now add duplicate parameters (lots of them) |
|
149 iAiwServiceHandler->AddParamL(Image.Id(), TAiwGenericParam( EGenericParamFile, TAiwVariant( KImageUri ) )); |
|
150 iAiwServiceHandler->AddParamL(Image.Id(), TAiwGenericParam( EGenericParamMIMEType, TAiwVariant( KImageMimeType ) )); |
|
151 iAiwServiceHandler->AddParamL(Image.Id(), TAiwGenericParam( EGenericParamFile, TAiwVariant( KImageUri ) )); |
|
152 iAiwServiceHandler->AddParamL(Image.Id(), TAiwGenericParam( EGenericParamMIMEType, TAiwVariant( KImageMimeType ) )); |
|
153 iAiwServiceHandler->AddParamL(Image.Id(), TAiwGenericParam( EGenericParamFile, TAiwVariant( KImageUri ) )); |
|
154 iAiwServiceHandler->AddParamL(Image.Id(), TAiwGenericParam( EGenericParamMIMEType, TAiwVariant( KImageMimeType ) )); |
|
155 iAiwServiceHandler->AddParamL(Image.Id(), TAiwGenericParam( EGenericParamFile, TAiwVariant( KImageUri ) )); |
|
156 iAiwServiceHandler->AddParamL(Image.Id(), TAiwGenericParam( EGenericParamMIMEType, TAiwVariant( KImageMimeType ) )); |
|
157 iAiwServiceHandler->AddParamL(Image.Id(), TAiwGenericParam( EGenericParamFile, TAiwVariant( KImageUri ) )); |
|
158 iAiwServiceHandler->AddParamL(Image.Id(), TAiwGenericParam( EGenericParamMIMEType, TAiwVariant( KImageMimeType ) )); |
|
159 iAiwServiceHandler->AddParamL(Image.Id(), TAiwGenericParam( EGenericParamFile, TAiwVariant( KImageUri ) )); |
|
160 iAiwServiceHandler->AddParamL(Image.Id(), TAiwGenericParam( EGenericParamMIMEType, TAiwVariant( KImageMimeType ) )); |
|
161 iAiwServiceHandler->AddParamL(Image.Id(), TAiwGenericParam( EGenericParamFile, TAiwVariant( KImageUri ) )); |
|
162 iAiwServiceHandler->AddParamL(Image.Id(), TAiwGenericParam( EGenericParamMIMEType, TAiwVariant( KImageMimeType ) )); |
|
163 iAiwServiceHandler->AddParamL(Image.Id(), TAiwGenericParam( EGenericParamFile, TAiwVariant( KImageUri ) )); |
|
164 iAiwServiceHandler->AddParamL(Image.Id(), TAiwGenericParam( EGenericParamMIMEType, TAiwVariant( KImageMimeType ) )); |
|
165 |
|
166 // Now transfer the parameters from our array to the InParams |
|
167 iAiwServiceHandler->HandleSubmenuL(*dummyMenuPane); |
|
168 |
|
169 CleanupStack::PopAndDestroy(dummyMenuPane); |
|
170 |
|
171 // Now get the InParams to see if it contains what it should |
|
172 CAiwGenericParamList& InParams = iAiwServiceHandler->GetInParams(); |
|
173 |
|
174 // Check the count is 2 |
|
175 TInt paramCount = InParams.Count(); |
|
176 EUNIT_ASSERT( paramCount == 2); |
|
177 |
|
178 // Check the Uri is correct |
|
179 TPtrC uri; |
|
180 InParams[0].Value().Get(uri); |
|
181 EUNIT_ASSERT(0 == uri.Compare(KImageUri)); |
|
182 |
|
183 // Check the MimeType is correct |
|
184 TPtrC mimeType; |
|
185 InParams[1].Value().Get(mimeType); |
|
186 EUNIT_ASSERT(0 == mimeType.Compare(KImageMimeType)); |
|
187 } |
|
188 |
|
189 void t_CGlxAiwServiceHandler::TwoItemsUniqueParamsL() |
|
190 { |
|
191 _LIT(KImageUri ,"c:\\Data\\Images\\Image01.jpg"); |
|
192 _LIT(KImageMimeType, "image/jpeg"); |
|
193 _LIT(KVideoUri ,"c:\\Data\\Videos\\Fireworks.mp4"); |
|
194 _LIT(KVideoMimeType, "video/mp4v-es"); |
|
195 |
|
196 // First Create a Dummy Menu pane (for use later) |
|
197 CEikMenuPane* dummyMenuPane = new (ELeave) CEikMenuPane(this); |
|
198 CleanupStack::PushL(dummyMenuPane); |
|
199 |
|
200 // Create a Media Id |
|
201 TGlxMedia Image(TGlxMediaId(1)); |
|
202 TGlxMedia Video(TGlxMediaId(2)); |
|
203 |
|
204 // Add the Uri and MimeType parameters to internal array |
|
205 iAiwServiceHandler->AddParamL(Image.Id(), TAiwGenericParam( EGenericParamFile, TAiwVariant( KImageUri ) )); |
|
206 iAiwServiceHandler->AddParamL(Image.Id(), TAiwGenericParam( EGenericParamMIMEType, TAiwVariant( KImageMimeType ) )); |
|
207 iAiwServiceHandler->AddParamL(Video.Id(), TAiwGenericParam( EGenericParamFile, TAiwVariant( KVideoUri ) )); |
|
208 iAiwServiceHandler->AddParamL(Video.Id(), TAiwGenericParam( EGenericParamMIMEType, TAiwVariant( KVideoMimeType ) )); |
|
209 |
|
210 // Now transfer the parameters from our array to the InParams |
|
211 iAiwServiceHandler->HandleSubmenuL(*dummyMenuPane); |
|
212 |
|
213 CleanupStack::PopAndDestroy(dummyMenuPane); |
|
214 |
|
215 // Now get the InParams to see if it contains what it should |
|
216 CAiwGenericParamList& InParams = iAiwServiceHandler->GetInParams(); |
|
217 |
|
218 // Check the count is correct |
|
219 TInt paramCount = InParams.Count(); |
|
220 EUNIT_ASSERT( paramCount == 4); |
|
221 |
|
222 // Check the Uri is correct |
|
223 TPtrC uri; |
|
224 TPtrC mimeType; |
|
225 |
|
226 InParams[0].Value().Get(uri); |
|
227 EUNIT_ASSERT(0 == uri.Compare(KVideoUri)); |
|
228 |
|
229 // Check the MimeType is correct |
|
230 InParams[1].Value().Get(mimeType); |
|
231 EUNIT_ASSERT(0 == mimeType.Compare(KVideoMimeType)); |
|
232 |
|
233 InParams[2].Value().Get(uri); |
|
234 EUNIT_ASSERT(0 == uri.Compare(KImageUri)); |
|
235 |
|
236 // Check the MimeType is correct |
|
237 InParams[3].Value().Get(mimeType); |
|
238 EUNIT_ASSERT(0 == mimeType.Compare(KImageMimeType)); |
|
239 } |
|
240 |
|
241 void t_CGlxAiwServiceHandler::TwoItemsDuplicateParamsL() |
|
242 { |
|
243 _LIT(KImageUri ,"c:\\Data\\Images\\Image01.jpg"); |
|
244 _LIT(KImageMimeType, "image/jpeg"); |
|
245 _LIT(KVideoUri ,"c:\\Data\\Videos\\Fireworks.mp4"); |
|
246 _LIT(KVideoMimeType, "video/mp4v-es"); |
|
247 |
|
248 // First Create a Dummy Menu pane (for use later) |
|
249 CEikMenuPane* dummyMenuPane = new (ELeave) CEikMenuPane(this); |
|
250 CleanupStack::PushL(dummyMenuPane); |
|
251 |
|
252 // Create a Media Id |
|
253 TGlxMedia Image(TGlxMediaId(1)); |
|
254 TGlxMedia Video(TGlxMediaId(2)); |
|
255 |
|
256 // Add the Uri and MimeType parameters to internal array |
|
257 iAiwServiceHandler->AddParamL(Image.Id(), TAiwGenericParam( EGenericParamFile, TAiwVariant( KImageUri ) )); |
|
258 iAiwServiceHandler->AddParamL(Image.Id(), TAiwGenericParam( EGenericParamMIMEType, TAiwVariant( KImageMimeType ) )); |
|
259 iAiwServiceHandler->AddParamL(Video.Id(), TAiwGenericParam( EGenericParamFile, TAiwVariant( KVideoUri ) )); |
|
260 iAiwServiceHandler->AddParamL(Video.Id(), TAiwGenericParam( EGenericParamMIMEType, TAiwVariant( KVideoMimeType ) )); |
|
261 |
|
262 // Now add duplicate parameters (lots of them) |
|
263 iAiwServiceHandler->AddParamL(Image.Id(), TAiwGenericParam( EGenericParamFile, TAiwVariant( KImageUri ) )); |
|
264 iAiwServiceHandler->AddParamL(Image.Id(), TAiwGenericParam( EGenericParamMIMEType, TAiwVariant( KImageMimeType ) )); |
|
265 iAiwServiceHandler->AddParamL(Video.Id(), TAiwGenericParam( EGenericParamFile, TAiwVariant( KVideoUri ) )); |
|
266 iAiwServiceHandler->AddParamL(Video.Id(), TAiwGenericParam( EGenericParamMIMEType, TAiwVariant( KVideoMimeType ) )); |
|
267 iAiwServiceHandler->AddParamL(Image.Id(), TAiwGenericParam( EGenericParamFile, TAiwVariant( KImageUri ) )); |
|
268 iAiwServiceHandler->AddParamL(Image.Id(), TAiwGenericParam( EGenericParamMIMEType, TAiwVariant( KImageMimeType ) )); |
|
269 iAiwServiceHandler->AddParamL(Video.Id(), TAiwGenericParam( EGenericParamFile, TAiwVariant( KVideoUri ) )); |
|
270 iAiwServiceHandler->AddParamL(Video.Id(), TAiwGenericParam( EGenericParamMIMEType, TAiwVariant( KVideoMimeType ) )); |
|
271 iAiwServiceHandler->AddParamL(Image.Id(), TAiwGenericParam( EGenericParamFile, TAiwVariant( KImageUri ) )); |
|
272 iAiwServiceHandler->AddParamL(Image.Id(), TAiwGenericParam( EGenericParamMIMEType, TAiwVariant( KImageMimeType ) )); |
|
273 iAiwServiceHandler->AddParamL(Video.Id(), TAiwGenericParam( EGenericParamFile, TAiwVariant( KVideoUri ) )); |
|
274 iAiwServiceHandler->AddParamL(Video.Id(), TAiwGenericParam( EGenericParamMIMEType, TAiwVariant( KVideoMimeType ) )); |
|
275 iAiwServiceHandler->AddParamL(Image.Id(), TAiwGenericParam( EGenericParamFile, TAiwVariant( KImageUri ) )); |
|
276 iAiwServiceHandler->AddParamL(Image.Id(), TAiwGenericParam( EGenericParamMIMEType, TAiwVariant( KImageMimeType ) )); |
|
277 iAiwServiceHandler->AddParamL(Video.Id(), TAiwGenericParam( EGenericParamFile, TAiwVariant( KVideoUri ) )); |
|
278 iAiwServiceHandler->AddParamL(Video.Id(), TAiwGenericParam( EGenericParamMIMEType, TAiwVariant( KVideoMimeType ) )); |
|
279 iAiwServiceHandler->AddParamL(Image.Id(), TAiwGenericParam( EGenericParamFile, TAiwVariant( KImageUri ) )); |
|
280 iAiwServiceHandler->AddParamL(Image.Id(), TAiwGenericParam( EGenericParamMIMEType, TAiwVariant( KImageMimeType ) )); |
|
281 iAiwServiceHandler->AddParamL(Video.Id(), TAiwGenericParam( EGenericParamFile, TAiwVariant( KVideoUri ) )); |
|
282 iAiwServiceHandler->AddParamL(Video.Id(), TAiwGenericParam( EGenericParamMIMEType, TAiwVariant( KVideoMimeType ) )); |
|
283 iAiwServiceHandler->AddParamL(Image.Id(), TAiwGenericParam( EGenericParamFile, TAiwVariant( KImageUri ) )); |
|
284 iAiwServiceHandler->AddParamL(Image.Id(), TAiwGenericParam( EGenericParamMIMEType, TAiwVariant( KImageMimeType ) )); |
|
285 iAiwServiceHandler->AddParamL(Video.Id(), TAiwGenericParam( EGenericParamFile, TAiwVariant( KVideoUri ) )); |
|
286 iAiwServiceHandler->AddParamL(Video.Id(), TAiwGenericParam( EGenericParamMIMEType, TAiwVariant( KVideoMimeType ) )); |
|
287 |
|
288 // Now transfer the parameters from our array to the InParams |
|
289 iAiwServiceHandler->HandleSubmenuL(*dummyMenuPane); |
|
290 |
|
291 CleanupStack::PopAndDestroy(dummyMenuPane); |
|
292 |
|
293 // Now get the InParams to see if it contains what it should |
|
294 CAiwGenericParamList& InParams = iAiwServiceHandler->GetInParams(); |
|
295 |
|
296 // Check the count is correct |
|
297 TInt paramCount = InParams.Count(); |
|
298 EUNIT_ASSERT( paramCount == 4); |
|
299 |
|
300 // Check the Uri is correct |
|
301 TPtrC uri; |
|
302 TPtrC mimeType; |
|
303 |
|
304 InParams[0].Value().Get(uri); |
|
305 EUNIT_ASSERT(0 == uri.Compare(KVideoUri)); |
|
306 |
|
307 // Check the MimeType is correct |
|
308 InParams[1].Value().Get(mimeType); |
|
309 EUNIT_ASSERT(0 == mimeType.Compare(KVideoMimeType)); |
|
310 |
|
311 InParams[2].Value().Get(uri); |
|
312 EUNIT_ASSERT(0 == uri.Compare(KImageUri)); |
|
313 |
|
314 // Check the MimeType is correct |
|
315 InParams[3].Value().Get(mimeType); |
|
316 EUNIT_ASSERT(0 == mimeType.Compare(KImageMimeType)); |
|
317 } |
|
318 |
|
319 // From MEikMenuObserver |
|
320 void t_CGlxAiwServiceHandler::SetEmphasis(CCoeControl* /* aMenuControl */,TBool /* aEmphasis */) |
|
321 { |
|
322 |
|
323 } |
|
324 // From MEikMenuObserver |
|
325 void t_CGlxAiwServiceHandler::ProcessCommandL(TInt /* aCommandId */) |
|
326 { |
|
327 |
|
328 } |
|
329 |
|
330 |
|
331 // TEST TABLE |
|
332 EUNIT_BEGIN_TEST_TABLE( |
|
333 t_CGlxAiwServiceHandler, |
|
334 "Unit test suite for CGlxAiwServiceHandler", |
|
335 "UNIT" ) |
|
336 |
|
337 EUNIT_TEST( |
|
338 "Test Construction", |
|
339 "CGlxAiwServiceHandler", |
|
340 "InstanceL", |
|
341 "FUNCTIONALITY", |
|
342 SetupL, TestConstructionL, Teardown) |
|
343 |
|
344 EUNIT_TEST( |
|
345 "1 Item Unique Params", |
|
346 "CGlxAiwServiceHandler", |
|
347 "InstanceL", |
|
348 "FUNCTIONALITY", |
|
349 SetupL, OneImageUniqueParamsL, Teardown) |
|
350 |
|
351 EUNIT_TEST( |
|
352 "1 Item Duplicate Params", |
|
353 "CGlxAiwServiceHandler", |
|
354 "InstanceL", |
|
355 "FUNCTIONALITY", |
|
356 SetupL, OneImageDuplicateParamsL, Teardown) |
|
357 |
|
358 EUNIT_TEST( |
|
359 "2 Items Unique Ps", |
|
360 "CGlxAiwServiceHandler", |
|
361 "InstanceL", |
|
362 "FUNCTIONALITY", |
|
363 SetupL, TwoItemsUniqueParamsL, Teardown) |
|
364 |
|
365 EUNIT_TEST( |
|
366 "2 Items Duplicate Ps", |
|
367 "CGlxAiwServiceHandler", |
|
368 "InstanceL", |
|
369 "FUNCTIONALITY", |
|
370 SetupL, TwoItemsDuplicateParamsL, Teardown) |
|
371 |
|
372 EUNIT_END_TEST_TABLE |
|
373 |
|
374 // END OF FILE |