|
1 /* |
|
2 * Copyright (c) 2004 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: CGlxMediaListCommandHandler unit test cases |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // CLASS HEADER |
|
22 #include "UT_CGlxMediaListCommandHandler.h" |
|
23 |
|
24 // EXTERNAL INCLUDES |
|
25 #include <digia/eunit/eunitmacros.h> |
|
26 #include <glxmedia.h> |
|
27 #include <glxmediageneraldefs.h> |
|
28 #include <mglxmedialistprovider.h> |
|
29 #include <mglxmedialist.h> |
|
30 #include <mpxmediadrmdefs.h> |
|
31 #include <mpxmediageneraldefs.h> |
|
32 |
|
33 // ----------------------------------------------------------------------------- |
|
34 // Set the value for a specific attribute |
|
35 // ----------------------------------------------------------------------------- |
|
36 // |
|
37 // |
|
38 CGlxMedia::CGlxMedia(const TGlxMediaId& aId) |
|
39 : iId(aId) |
|
40 { |
|
41 } |
|
42 |
|
43 CGlxMedia::~CGlxMedia() |
|
44 { |
|
45 iUsers.Close(); |
|
46 |
|
47 Reset(); |
|
48 iValues.Close(); |
|
49 iAttributes.Close(); |
|
50 } |
|
51 |
|
52 class _CGlxTestMediaList: public CBase, public MGlxMediaList |
|
53 { |
|
54 public: |
|
55 ~_CGlxTestMediaList() |
|
56 { |
|
57 iItems.Close(); |
|
58 iMedia.ResetAndDestroy(); |
|
59 iSelectedItems.Close(); |
|
60 } |
|
61 |
|
62 virtual void Close() |
|
63 { |
|
64 }; |
|
65 virtual TGlxMediaListId Id() const |
|
66 { |
|
67 return KGlxIdNone; |
|
68 } |
|
69 |
|
70 virtual TInt Count(NGlxListDefs::TCountType /*aType*/) const |
|
71 { |
|
72 return iItems.Count(); |
|
73 } |
|
74 |
|
75 virtual TInt FocusIndex() const |
|
76 { |
|
77 return iFocusIndex; |
|
78 } |
|
79 |
|
80 virtual void SetFocusL(NGlxListDefs::TFocusSetType /*aType*/, TInt aValue) |
|
81 { |
|
82 iFocusIndex = aValue; |
|
83 } |
|
84 |
|
85 virtual const TGlxMedia& Item(TInt aIndex) const |
|
86 { |
|
87 return iItems[aIndex]; |
|
88 } |
|
89 |
|
90 virtual TInt Index(const TGlxIdSpaceId& /* aIdSpaceId */, const TGlxMediaId& aId) const |
|
91 { |
|
92 TInt count = iItems.Count(); |
|
93 for (TInt i = 0; i < count; i++) |
|
94 { |
|
95 if (iItems[i].Id() == aId) |
|
96 { |
|
97 return i; |
|
98 } |
|
99 } |
|
100 return KErrNotFound; |
|
101 } |
|
102 |
|
103 virtual void AddMediaListObserverL(MGlxMediaListObserver* /*aObserver*/) |
|
104 { |
|
105 } |
|
106 |
|
107 virtual void RemoveMediaListObserver(MGlxMediaListObserver* /*aObserver*/) |
|
108 { |
|
109 } |
|
110 |
|
111 virtual void AddContextL(const MGlxFetchContext* /*aContext*/, TInt /*aPriority*/) |
|
112 { |
|
113 } |
|
114 |
|
115 virtual void RemoveContext(const MGlxFetchContext* /*aContext*/) |
|
116 { |
|
117 } |
|
118 |
|
119 virtual MMPXCollection& Collection() const |
|
120 { |
|
121 // we know that this method is not called in our tests, this is just to make the code compile |
|
122 MMPXCollection* empty = NULL; |
|
123 return *empty; |
|
124 } |
|
125 |
|
126 virtual TBool IsSelected(TInt aIndex) const |
|
127 { |
|
128 return iSelectedItems.Find(aIndex); |
|
129 } |
|
130 |
|
131 virtual void SetSelectedL(TInt aIndex, TBool aSelected) |
|
132 { |
|
133 if (aSelected) |
|
134 { |
|
135 iSelectedItems.InsertInOrder(aIndex); |
|
136 } |
|
137 else |
|
138 { |
|
139 iSelectedItems.Remove(iSelectedItems.Find(aIndex)); |
|
140 } |
|
141 } |
|
142 |
|
143 virtual const TArray<TInt> Selection() const |
|
144 { |
|
145 return iSelectedItems.Array(); |
|
146 } |
|
147 |
|
148 virtual void CommandL(CMPXCommand& /*aCommand*/) |
|
149 { |
|
150 } |
|
151 |
|
152 virtual void CancelCommand() |
|
153 { |
|
154 } |
|
155 |
|
156 virtual void SetFilterL(CMPXFilter* /*aFilter*/) |
|
157 { |
|
158 } |
|
159 |
|
160 virtual CMPXFilter* Filter() const |
|
161 { |
|
162 return NULL; |
|
163 } |
|
164 |
|
165 virtual TGlxIdSpaceId IdSpaceId(TInt /*aIndex*/) const |
|
166 { |
|
167 return KGlxIdNone; |
|
168 } |
|
169 |
|
170 void AppendL(TInt aId, TBool aCreateMedia) |
|
171 { |
|
172 if (aCreateMedia) |
|
173 { |
|
174 CGlxMedia* media = new (ELeave) CGlxMedia(TGlxMediaId(aId)); |
|
175 CleanupStack::PushL(media); |
|
176 iMedia.AppendL(media); |
|
177 CleanupStack::Pop(media); |
|
178 iItems.AppendL(TGlxMedia(TGlxMediaId(aId), media)); |
|
179 } |
|
180 else |
|
181 { |
|
182 iItems.AppendL(TGlxMedia(TGlxMediaId(aId))); |
|
183 } |
|
184 } |
|
185 |
|
186 CGlxMedia* MediaObj(TInt aIndex) const |
|
187 { |
|
188 return const_cast<CGlxMedia*>(static_cast<const CGlxMedia*>(iItems[aIndex].Properties())); |
|
189 } |
|
190 |
|
191 CMPXCollectionPath* PathLC(NGlxListDefs::TPathType /*aType*/) const |
|
192 { |
|
193 return NULL; |
|
194 } |
|
195 |
|
196 TInt SelectionCount() const |
|
197 { |
|
198 return iSelectedItems.Count(); |
|
199 } |
|
200 |
|
201 TInt SelectedItemIndex(TInt aSelectionIndex) const |
|
202 { |
|
203 TInt idx = KErrNotFound; |
|
204 if(aSelectionIndex<iSelectedItems.Count()) |
|
205 { |
|
206 idx = iSelectedItems[aSelectionIndex]; |
|
207 } |
|
208 return idx; |
|
209 } |
|
210 |
|
211 TBool IsPopulated() const |
|
212 { |
|
213 return ETrue; |
|
214 } |
|
215 |
|
216 void AddStaticItemL( CGlxMedia* /*aStaticItem*/, |
|
217 NGlxListDefs::TInsertionPosition /*aTargetPosition*/ ) {}; |
|
218 |
|
219 void RemoveStaticItem(const TGlxMediaId& /*aItemId*/) {}; |
|
220 |
|
221 void SetStaticItemsEnabled( TBool aEnabled ) { iStaticItemsEnabled = aEnabled; }; |
|
222 |
|
223 TBool IsStaticItemsEnabled() const { return iStaticItemsEnabled; }; |
|
224 |
|
225 virtual void SetFocusInitialPosition(NGlxListDefs::TFocusInitialPosition aFocusInitialPosition) {}; |
|
226 |
|
227 virtual void ResetFocus(){}; |
|
228 |
|
229 virtual void SetVisibleWindowIndexL( TInt aIndex) {}; |
|
230 |
|
231 virtual TInt VisibleWindowIndex() const {}; |
|
232 |
|
233 RArray<TGlxMedia> iItems; |
|
234 RPointerArray<CGlxMedia> iMedia; |
|
235 RArray<TInt> iSelectedItems; |
|
236 TInt iFocusIndex; |
|
237 TBool iStaticItemsEnabled; |
|
238 }; |
|
239 |
|
240 // INTERNAL INCLUDES |
|
241 #include "glxmedialistcommandhandler.h" |
|
242 |
|
243 // CONSTRUCTION |
|
244 UT_CGlxMediaListCommandHandler* UT_CGlxMediaListCommandHandler::NewL() |
|
245 { |
|
246 UT_CGlxMediaListCommandHandler* self = UT_CGlxMediaListCommandHandler::NewLC(); |
|
247 CleanupStack::Pop(); |
|
248 |
|
249 return self; |
|
250 } |
|
251 |
|
252 UT_CGlxMediaListCommandHandler* UT_CGlxMediaListCommandHandler::NewLC() |
|
253 { |
|
254 UT_CGlxMediaListCommandHandler* self = new( ELeave ) UT_CGlxMediaListCommandHandler(); |
|
255 CleanupStack::PushL( self ); |
|
256 |
|
257 self->ConstructL(); |
|
258 |
|
259 return self; |
|
260 } |
|
261 |
|
262 // Destructor (virtual by CBase) |
|
263 UT_CGlxMediaListCommandHandler::~UT_CGlxMediaListCommandHandler() |
|
264 { |
|
265 delete iML; |
|
266 } |
|
267 |
|
268 // Default constructor |
|
269 UT_CGlxMediaListCommandHandler::UT_CGlxMediaListCommandHandler() |
|
270 { |
|
271 } |
|
272 |
|
273 // Second phase construct |
|
274 void UT_CGlxMediaListCommandHandler::ConstructL() |
|
275 { |
|
276 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
277 // It generates the test case table. |
|
278 CEUnitTestSuiteClass::ConstructL(); |
|
279 } |
|
280 |
|
281 // METHODS |
|
282 |
|
283 |
|
284 |
|
285 void UT_CGlxMediaListCommandHandler::SetupL( ) |
|
286 { |
|
287 } |
|
288 |
|
289 void UT_CGlxMediaListCommandHandler::Teardown( ) |
|
290 { |
|
291 delete iML; |
|
292 iML = NULL; |
|
293 } |
|
294 |
|
295 |
|
296 struct CTestHandler : public CGlxMediaListCommandHandler, public MGlxMediaListProvider |
|
297 { |
|
298 CTestHandler(MGlxMediaList* aList) : CGlxMediaListCommandHandler(this) |
|
299 { |
|
300 iList = aList; |
|
301 } |
|
302 |
|
303 virtual TBool DoExecuteL(TInt /*aCommandId*/, MGlxMediaList& /*aList*/) |
|
304 { |
|
305 return ETrue; |
|
306 } |
|
307 |
|
308 virtual MGlxMediaList& MediaList() |
|
309 { |
|
310 return *iList; |
|
311 } |
|
312 |
|
313 virtual TBool DoIsDisabled(TInt aCommandId, MGlxMediaList& /*aMediaList*/) const |
|
314 { |
|
315 EUNIT_ASSERT( aCommandId == iCommandId ); |
|
316 return iDisabled; |
|
317 } |
|
318 |
|
319 TBool iDisabled; |
|
320 TInt iCommandId; |
|
321 MGlxMediaList* iList; |
|
322 }; |
|
323 |
|
324 // ----------------------------------------------------------------------------- |
|
325 // Test: static TInt SelectionLength(MGlxMediaList& aMediaList); |
|
326 // ----------------------------------------------------------------------------- |
|
327 // |
|
328 void UT_CGlxMediaListCommandHandler::Test_SelectionLengthL( ) |
|
329 { |
|
330 #if 1 // This unit test needs to be re-wirtten after changes to SelectionLength() method. |
|
331 iML = new (ELeave) _CGlxTestMediaList; |
|
332 |
|
333 CTestHandler* ch = new (ELeave) CTestHandler(iML); |
|
334 CleanupStack::PushL(ch); |
|
335 |
|
336 EUNIT_ASSERT( ch->SelectionLength() == 0); |
|
337 |
|
338 iML->AppendL(1, ETrue); |
|
339 iML->AppendL(2, ETrue); |
|
340 iML->AppendL(3, ETrue); |
|
341 iML->iFocusIndex = 0; |
|
342 |
|
343 EUNIT_ASSERT( ch->SelectionLength() == 1); |
|
344 iML->iFocusIndex = 1; |
|
345 EUNIT_ASSERT( ch->SelectionLength() == 1); |
|
346 |
|
347 iML->SetSelectedL(0, ETrue); |
|
348 EUNIT_ASSERT( ch->SelectionLength() == 1); |
|
349 iML->SetSelectedL(1, ETrue); |
|
350 EUNIT_ASSERT( ch->SelectionLength() == 2); |
|
351 iML->SetSelectedL(2, ETrue); |
|
352 EUNIT_ASSERT( ch->SelectionLength() == 3); |
|
353 |
|
354 CleanupStack::PopAndDestroy(ch); |
|
355 delete iML; |
|
356 iML = NULL; |
|
357 #endif |
|
358 } |
|
359 |
|
360 // ----------------------------------------------------------------------------- |
|
361 // Test: IMPORT_C virtual TBool IsDisabled(TInt aCommandId, MGlxMediaList& aList) const; |
|
362 // ----------------------------------------------------------------------------- |
|
363 // |
|
364 void UT_CGlxMediaListCommandHandler::Test_IsDisabledL() |
|
365 { |
|
366 iML = new (ELeave) _CGlxTestMediaList; |
|
367 iML->iFocusIndex = -1; |
|
368 |
|
369 CTestHandler* ch = new (ELeave) CTestHandler(iML); |
|
370 CleanupStack::PushL(ch); |
|
371 ch->iCommandId = 1; |
|
372 CGlxMediaListCommandHandler::TCommandInfo info(1); |
|
373 ch->AddCommandL(info); |
|
374 |
|
375 ////////////////////////////////////////////////////// |
|
376 // NO FILTERING |
|
377 // Empty view, no filtering |
|
378 EUNIT_ASSERT_DESC( !ch->IsDisabledL(1, *iML), |
|
379 "in empty view with no filtering command is not disabled" ); |
|
380 ch->CommandInfo(1).iMinSelectionLength = 1; |
|
381 EUNIT_ASSERT( ch->IsDisabledL(1, *iML) ); |
|
382 ch->CommandInfo(1).iMinSelectionLength = 0; |
|
383 |
|
384 // Add items |
|
385 iML->AppendL(1, ETrue); |
|
386 iML->AppendL(2, ETrue); |
|
387 iML->AppendL(3, ETrue); |
|
388 iML->AppendL(4, ETrue); |
|
389 iML->iFocusIndex = 0; |
|
390 |
|
391 // Empty view, no filtering |
|
392 EUNIT_ASSERT( !ch->IsDisabledL(1, *iML) ); |
|
393 |
|
394 // Selection 0-1 |
|
395 iML->SetSelectedL(0, ETrue); |
|
396 iML->SetSelectedL(1, ETrue); |
|
397 EUNIT_ASSERT( !ch->IsDisabledL(1, *iML) ); |
|
398 |
|
399 ////////////////////////////////////////////////////// |
|
400 // Filter size |
|
401 EUNIT_ASSERT( !ch->IsDisabledL(1, *iML) ); |
|
402 // Selection 0-1 |
|
403 ch->CommandInfo(1).iMinSelectionLength = 1; |
|
404 ch->CommandInfo(1).iMaxSelectionLength = 2; |
|
405 EUNIT_ASSERT( !ch->IsDisabledL(1, *iML) ); |
|
406 iML->SetSelectedL(2, ETrue); |
|
407 // Selection 0-1-2 |
|
408 EUNIT_ASSERT( ch->IsDisabledL(1, *iML) ); |
|
409 iML->SetSelectedL(2, EFalse); |
|
410 // Selection 0-1 |
|
411 EUNIT_ASSERT( !ch->IsDisabledL(1, *iML) ); |
|
412 iML->SetSelectedL(1, EFalse); |
|
413 // Selection 0 |
|
414 EUNIT_ASSERT( !ch->IsDisabledL(1, *iML) ); |
|
415 iML->SetSelectedL(0, EFalse); |
|
416 // Selection none (not empty view( |
|
417 EUNIT_ASSERT( !ch->IsDisabledL(1, *iML) ); |
|
418 |
|
419 ////////////////////////////////////////////////////// |
|
420 // Filter category |
|
421 { |
|
422 EUNIT_ASSERT( !ch->IsDisabledL(1, *iML) ); |
|
423 ch->CommandInfo(1).iMinSelectionLength = 0; |
|
424 ch->CommandInfo(1).iMaxSelectionLength = KMaxTInt; |
|
425 iML->MediaObj(0)->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXImage); |
|
426 iML->MediaObj(1)->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXImage); |
|
427 iML->MediaObj(2)->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXVideo); |
|
428 iML->MediaObj(3)->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXImage); |
|
429 |
|
430 // Require all images |
|
431 ch->CommandInfo(1).iCategoryFilter = EMPXImage; |
|
432 ch->CommandInfo(1).iCategoryRule = CGlxMediaListCommandHandler::TCommandInfo::ERequireAll; |
|
433 |
|
434 // No selection, focus on 0 |
|
435 iML->iFocusIndex = 0; |
|
436 EUNIT_ASSERT( !ch->IsDisabledL(1, *iML) ); |
|
437 // No selection, focus on 2 |
|
438 iML->iFocusIndex = 2; |
|
439 EUNIT_ASSERT( ch->IsDisabledL(1, *iML) ); |
|
440 |
|
441 // Selection 0,1 |
|
442 iML->SetSelectedL(0, ETrue); |
|
443 iML->SetSelectedL(1, ETrue); |
|
444 EUNIT_ASSERT( !ch->IsDisabledL(1, *iML) ); |
|
445 // Selection 0,1,2 |
|
446 iML->SetSelectedL(2, ETrue); |
|
447 EUNIT_ASSERT_DESC( ch->IsDisabledL(1, *iML), "no all are images so IsDisabled" ); |
|
448 // Selection 0,1,2,3 |
|
449 iML->SetSelectedL(3, ETrue); |
|
450 EUNIT_ASSERT_DESC( ch->IsDisabledL(1, *iML), "no all are images so IsDisabled" ); |
|
451 |
|
452 // Disable if all are not images |
|
453 ch->CommandInfo(1).iCategoryRule = CGlxMediaListCommandHandler::TCommandInfo::EForbidAll; |
|
454 EUNIT_ASSERT( !ch->IsDisabledL(1, *iML) ); |
|
455 iML->SetSelectedL(2, EFalse); |
|
456 EUNIT_ASSERT( ch->IsDisabledL(1, *iML) ); |
|
457 |
|
458 // Cleanup for next test |
|
459 ch->CommandInfo(1).iCategoryRule = CGlxMediaListCommandHandler::TCommandInfo::EIgnore; |
|
460 iML->SetSelectedL(0, EFalse); |
|
461 iML->SetSelectedL(1, EFalse); |
|
462 iML->SetSelectedL(3, EFalse); |
|
463 } |
|
464 |
|
465 ////////////////////////////////////////////////////// |
|
466 // Filter drm |
|
467 { |
|
468 EUNIT_ASSERT( !ch->IsDisabledL(1, *iML) ); |
|
469 iML->MediaObj(0)->SetTObjectValueL<TBool>(KMPXMediaDrmProtected, ETrue); |
|
470 iML->MediaObj(1)->SetTObjectValueL<TBool>(KMPXMediaDrmProtected, ETrue); |
|
471 iML->MediaObj(2)->SetTObjectValueL<TBool>(KMPXMediaDrmProtected, EFalse); |
|
472 iML->MediaObj(3)->SetTObjectValueL<TBool>(KMPXMediaDrmProtected, ETrue); |
|
473 |
|
474 // dont allow DRM |
|
475 ch->CommandInfo(1).iDisallowDRM = ETrue; |
|
476 |
|
477 // No selection, focus on 0 |
|
478 iML->iFocusIndex = 0; |
|
479 EUNIT_ASSERT( ch->IsDisabledL(1, *iML) ); |
|
480 // No selection, focus on 2 |
|
481 iML->iFocusIndex = 2; |
|
482 EUNIT_ASSERT( !ch->IsDisabledL(1, *iML) ); |
|
483 |
|
484 // Selection 1,2 |
|
485 iML->SetSelectedL(0, ETrue); |
|
486 iML->SetSelectedL(1, ETrue); |
|
487 EUNIT_ASSERT( ch->IsDisabledL(1, *iML) ); |
|
488 // Selection 1,2,3 |
|
489 iML->SetSelectedL(2, ETrue); |
|
490 EUNIT_ASSERT( !ch->IsDisabledL(1, *iML) ); |
|
491 |
|
492 // Cleanup for next test |
|
493 ch->CommandInfo(1).iDisallowDRM = EFalse; |
|
494 iML->SetSelectedL(0, EFalse); |
|
495 iML->SetSelectedL(1, EFalse); |
|
496 iML->SetSelectedL(2, EFalse); |
|
497 } |
|
498 |
|
499 ////////////////////////////////////////////////////// |
|
500 // Filter system items |
|
501 { |
|
502 EUNIT_ASSERT( !ch->IsDisabledL(1, *iML) ); |
|
503 iML->MediaObj(0)->SetTObjectValueL<TBool>(KGlxMediaGeneralSystemItem, ETrue); |
|
504 iML->MediaObj(1)->SetTObjectValueL<TBool>(KGlxMediaGeneralSystemItem, ETrue); |
|
505 iML->MediaObj(2)->SetTObjectValueL<TBool>(KGlxMediaGeneralSystemItem, EFalse); |
|
506 iML->MediaObj(3)->SetTObjectValueL<TBool>(KGlxMediaGeneralSystemItem, ETrue); |
|
507 |
|
508 // Dont allow system items |
|
509 ch->CommandInfo(1).iDisallowSystemItems = ETrue; |
|
510 |
|
511 // No selection, focus on 0 |
|
512 iML->iFocusIndex = 0; |
|
513 EUNIT_ASSERT( ch->IsDisabledL(1, *iML) ); |
|
514 // No selection, focus on 2 |
|
515 iML->iFocusIndex = 2; |
|
516 EUNIT_ASSERT( !ch->IsDisabledL(1, *iML) ); |
|
517 |
|
518 // Selection 1,2 |
|
519 iML->SetSelectedL(0, ETrue); |
|
520 iML->SetSelectedL(1, ETrue); |
|
521 EUNIT_ASSERT( ch->IsDisabledL(1, *iML) ); |
|
522 // Selection 1,2,3 |
|
523 iML->SetSelectedL(2, ETrue); |
|
524 EUNIT_ASSERT( !ch->IsDisabledL(1, *iML) ); |
|
525 } |
|
526 |
|
527 ////////////////////////////////////////////////////// |
|
528 // Filter deriving class |
|
529 { |
|
530 EUNIT_ASSERT( !ch->IsDisabledL(1, *iML) ); |
|
531 ch->iDisabled = ETrue; |
|
532 EUNIT_ASSERT( ch->IsDisabledL(1, *iML) ); |
|
533 ch->iDisabled = EFalse; |
|
534 } |
|
535 |
|
536 |
|
537 ////////////////////////////////////////////////////// |
|
538 // Combined Filter |
|
539 { |
|
540 // create a few more items |
|
541 iML->AppendL(5, ETrue); |
|
542 iML->AppendL(6, ETrue); |
|
543 iML->AppendL(7, ETrue); |
|
544 |
|
545 // set attributes |
|
546 // item 0 is a DRM protected video |
|
547 iML->MediaObj(0)->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXVideo); |
|
548 iML->MediaObj(0)->SetTObjectValueL<TBool>(KMPXMediaDrmProtected, ETrue); |
|
549 iML->MediaObj(0)->SetTObjectValueL<TBool>(KGlxMediaGeneralSystemItem, EFalse); |
|
550 iML->MediaObj(0)->SetTObjectValueL<TInt>(KGlxMediaGeneralFramecount, 1); |
|
551 iML->MediaObj(0)->SetTObjectValueL<TInt>(KMPXMediaGeneralCount, 1); |
|
552 // item 1 is a Animated GIF, non DRM protected |
|
553 iML->MediaObj(1)->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXImage); |
|
554 iML->MediaObj(1)->SetTObjectValueL<TBool>(KMPXMediaDrmProtected, EFalse); |
|
555 iML->MediaObj(1)->SetTObjectValueL<TBool>(KGlxMediaGeneralSystemItem, EFalse); |
|
556 iML->MediaObj(1)->SetTObjectValueL<TInt>(KGlxMediaGeneralFramecount, 10); |
|
557 iML->MediaObj(1)->SetTObjectValueL<TInt>(KMPXMediaGeneralCount, 1); |
|
558 // item 2 is an Album with 5 items, also a system item |
|
559 iML->MediaObj(2)->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXAlbum); |
|
560 iML->MediaObj(2)->SetTObjectValueL<TBool>(KMPXMediaDrmProtected, EFalse); |
|
561 iML->MediaObj(2)->SetTObjectValueL<TBool>(KGlxMediaGeneralSystemItem, ETrue); |
|
562 iML->MediaObj(2)->SetTObjectValueL<TInt>(KGlxMediaGeneralFramecount, 1); |
|
563 iML->MediaObj(2)->SetTObjectValueL<TInt>(KMPXMediaGeneralCount, 5); |
|
564 // item 3 is a DRM protected image |
|
565 iML->MediaObj(3)->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXImage); |
|
566 iML->MediaObj(3)->SetTObjectValueL<TBool>(KMPXMediaDrmProtected, ETrue); |
|
567 iML->MediaObj(3)->SetTObjectValueL<TBool>(KGlxMediaGeneralSystemItem, EFalse); |
|
568 iML->MediaObj(3)->SetTObjectValueL<TInt>(KGlxMediaGeneralFramecount, 1); |
|
569 iML->MediaObj(3)->SetTObjectValueL<TInt>(KMPXMediaGeneralCount, 1); |
|
570 // item 4 is a non DRM protected image, but a system item |
|
571 iML->MediaObj(4)->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXImage); |
|
572 iML->MediaObj(4)->SetTObjectValueL<TBool>(KMPXMediaDrmProtected, EFalse); |
|
573 iML->MediaObj(4)->SetTObjectValueL<TBool>(KGlxMediaGeneralSystemItem, ETrue); |
|
574 iML->MediaObj(4)->SetTObjectValueL<TInt>(KGlxMediaGeneralFramecount, 1); |
|
575 iML->MediaObj(4)->SetTObjectValueL<TInt>(KMPXMediaGeneralCount, 1); |
|
576 // item 5 is a non DRM protected video |
|
577 iML->MediaObj(5)->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXVideo); |
|
578 iML->MediaObj(5)->SetTObjectValueL<TBool>(KMPXMediaDrmProtected, EFalse); |
|
579 iML->MediaObj(5)->SetTObjectValueL<TBool>(KGlxMediaGeneralSystemItem, EFalse); |
|
580 iML->MediaObj(5)->SetTObjectValueL<TInt>(KGlxMediaGeneralFramecount, 1); |
|
581 iML->MediaObj(5)->SetTObjectValueL<TInt>(KMPXMediaGeneralCount, 1); |
|
582 // item 6 is an Album with 0 items |
|
583 iML->MediaObj(6)->SetTObjectValueL<TMPXGeneralCategory>(KMPXMediaGeneralCategory, EMPXAlbum); |
|
584 iML->MediaObj(6)->SetTObjectValueL<TBool>(KMPXMediaDrmProtected, EFalse); |
|
585 iML->MediaObj(6)->SetTObjectValueL<TBool>(KGlxMediaGeneralSystemItem, EFalse); |
|
586 iML->MediaObj(6)->SetTObjectValueL<TInt>(KGlxMediaGeneralFramecount, 1); |
|
587 iML->MediaObj(6)->SetTObjectValueL<TInt>(KMPXMediaGeneralCount, 0); |
|
588 |
|
589 // set selection |
|
590 ch->CommandInfo(1).iMinSelectionLength = 0; |
|
591 ch->CommandInfo(1).iMaxSelectionLength = 7; |
|
592 // Drop all videos |
|
593 ch->CommandInfo(1).iCategoryFilter = EMPXVideo; |
|
594 ch->CommandInfo(1).iCategoryRule = CGlxMediaListCommandHandler::TCommandInfo::EForbidAll; |
|
595 // Dont allow system items |
|
596 ch->CommandInfo(1).iDisallowSystemItems = ETrue; |
|
597 // dont allow DRM |
|
598 ch->CommandInfo(1).iDisallowDRM = ETrue; |
|
599 // dont allow animated gif |
|
600 ch->CommandInfo(1).iDisallowAnimatedGIFs = ETrue; |
|
601 // allow only containers with 1 or more items |
|
602 ch->CommandInfo(1).iMinSlideshowPlayableContainedItemCount = 1; |
|
603 |
|
604 // Set selection, select all |
|
605 iML->SetSelectedL(0, ETrue); |
|
606 iML->SetSelectedL(1, ETrue); |
|
607 iML->SetSelectedL(2, ETrue); |
|
608 iML->SetSelectedL(3, ETrue); |
|
609 iML->SetSelectedL(4, ETrue); |
|
610 iML->SetSelectedL(5, ETrue); |
|
611 iML->SetSelectedL(6, ETrue); |
|
612 EUNIT_ASSERT_DESC( ch->IsDisabledL(1, *iML), "no valid items to show so IsDisabled" ); |
|
613 // Allow system items |
|
614 ch->CommandInfo(1).iDisallowSystemItems = EFalse; |
|
615 EUNIT_ASSERT_DESC( !ch->IsDisabledL(1, *iML), "valid items to show so not disabled" ); |
|
616 // unselect item 4 |
|
617 iML->SetSelectedL(4, EFalse); |
|
618 EUNIT_ASSERT_DESC( !ch->IsDisabledL(1, *iML), "valid items to show so not disabled" ); |
|
619 // unselect item 2 |
|
620 iML->SetSelectedL(2, EFalse); |
|
621 EUNIT_ASSERT_DESC( ch->IsDisabledL(1, *iML), "no valid items to show so IsDisabled" ); |
|
622 // re-select item 4 |
|
623 iML->SetSelectedL(4, ETrue); |
|
624 EUNIT_ASSERT_DESC( !ch->IsDisabledL(1, *iML), "valid items to show so not disabled" ); |
|
625 // unselect item 4 |
|
626 iML->SetSelectedL(4, EFalse); |
|
627 EUNIT_ASSERT_DESC( ch->IsDisabledL(1, *iML), "no valid items to show so IsDisabled" ); |
|
628 // Allow DRM |
|
629 ch->CommandInfo(1).iDisallowDRM = EFalse; |
|
630 EUNIT_ASSERT_DESC( !ch->IsDisabledL(1, *iML), "valid items to show so not disabled" ); |
|
631 // unselect item 3 |
|
632 iML->SetSelectedL(3, EFalse); |
|
633 EUNIT_ASSERT_DESC( ch->IsDisabledL(1, *iML), "no valid items to show so IsDisabled" ); |
|
634 } |
|
635 |
|
636 |
|
637 CleanupStack::PopAndDestroy(ch); |
|
638 |
|
639 delete iML; |
|
640 iML = NULL; |
|
641 } |
|
642 |
|
643 // TEST TABLE |
|
644 |
|
645 EUNIT_BEGIN_TEST_TABLE( |
|
646 UT_CGlxMediaListCommandHandler, |
|
647 "Medialist command handler", |
|
648 "UNIT" ) |
|
649 |
|
650 EUNIT_TEST( |
|
651 "SelectionLength", |
|
652 "CGlxMediaListCommandHandler", |
|
653 "SelectionLength", |
|
654 "FUNCTIONALITY", |
|
655 SetupL, Test_SelectionLengthL, Teardown) |
|
656 |
|
657 /*EUNIT_TEST( |
|
658 "IsDisabledL", |
|
659 "CGlxMediaListCommandHandler", |
|
660 "IsDisabledL", |
|
661 "FUNCTIONALITY", |
|
662 SetupL, Test_IsDisabledL, Teardown)*/ |
|
663 |
|
664 EUNIT_END_TEST_TABLE |
|
665 |
|
666 // END OF FILE |