|
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: Unit tests |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef __C_GLXLISTTESTBASE_H__ |
|
22 #define __C_GLXLISTTESTBASE_H__ |
|
23 |
|
24 // EXTERNAL INCLUDES |
|
25 #include <digia/eunit/ceunittestsuiteclass.h> |
|
26 #include <digia/eunit/eunitdecorators.h> |
|
27 #include <glxlistdefs.h> |
|
28 |
|
29 // INTERNAL INCLUDES |
|
30 #include "mglxmediapool.h" |
|
31 #include "mglxmediauser.h" |
|
32 #include "_glxlisttesthelpers.h" |
|
33 |
|
34 // FORWARD DECLARATIONS |
|
35 class CGlxItemListReconstruction; |
|
36 class CMPXCollectionPath; |
|
37 class TNotification; |
|
38 |
|
39 template < class _ListClass, class _ReconstructionClass > |
|
40 class CGlxListTestBase : public CEUnitTestSuiteClass, public MGlxMediaPool, |
|
41 public MGlxMediaUser |
|
42 { |
|
43 protected: |
|
44 ~CGlxListTestBase(); |
|
45 void DeleteMembers(); |
|
46 |
|
47 // From MGlxMediaPool |
|
48 CGlxMedia* Media( const TGlxIdSpaceId& aIdSpaceId, |
|
49 const TGlxMediaId& aId) const; |
|
50 |
|
51 /** |
|
52 * Create a collection path from a string, in which each char |
|
53 * is an id |
|
54 */ |
|
55 CMPXCollectionPath* CreatePathLC( const TDesC8& aString ); |
|
56 |
|
57 /** |
|
58 * Add a static item - can be only used for _ListClass |
|
59 * that support AddStaticItemL(...) |
|
60 */ |
|
61 void AddStaticItemL( TChar aId, NGlxListDefs::TInsertionPosition aPosition ); |
|
62 void AddStaticItemsL( NGlxListTestHelpers::TStaticItemInfo::TData* aInfos ); |
|
63 |
|
64 /** |
|
65 * Test if counts equal - can only be used for _ListClass that supports |
|
66 * Count( NGlxListDefs::TCountType ) and SetStaticItemsEnabled |
|
67 * Note: Will test with both static items enabled and disabled, so sends |
|
68 * notifications to list observer, which will affect notification list |
|
69 * of the reconstruction. So don't use when notifications list is being tested. |
|
70 */ |
|
71 TBool CountEqualsL( TInt aCountAll, TInt aCountNonStatic, |
|
72 TInt aCountAllStatic, TInt aCountPreStatic, TInt aCountPostStatic ); |
|
73 |
|
74 void CreateListL( const TDesC8& aString ); |
|
75 void CreateListL( const TDesC8& aString, const TDesC8& aLinkedToMedia ); |
|
76 void CreateListL( const TDesC8& aString, TBool aStaticItemsEnabled, |
|
77 NGlxListTestHelpers::TStaticItemInfo::TData* aStaticItemInfos ); |
|
78 |
|
79 void CreateReconstructionL(); |
|
80 TBool Equals( const TDesC8& aNewString ); |
|
81 TBool Equals( const TDesC8& aNewString, const TNotification::TData* aNotificationList ); |
|
82 TBool Equals( const TDesC8& aStringWithoutStaticItems, |
|
83 const TDesC8& aStringWithStaticItems, TBool aStaticItemsEnabled, |
|
84 const TNotification::TData* aNotificationList); |
|
85 |
|
86 /** |
|
87 * Checks if items are linked to media objects |
|
88 * @param aAnswers expected linking, format "tttft", in which |
|
89 * 't' indicates "yes, is linked", |
|
90 * and 'f' indicates "no, is not linked" |
|
91 */ |
|
92 TBool IsLinkedToMedia( const TDesC8& aAnswers ) const; |
|
93 /** |
|
94 * Creates a media object in pool, and offers to list. |
|
95 * @param aAnswers See IsLinkedToMedia |
|
96 * @param aShouldAccept ETrue if list should accept the offer |
|
97 */ |
|
98 //TBool TryOfferMedia( TChar aId, const TDesC8& aAnswers, TBool aShouldAccept ); |
|
99 |
|
100 /** |
|
101 * Tries to remove reference of list from media |
|
102 * @param aAnswers See IsLinkedToMedia |
|
103 */ |
|
104 TBool TryRemoveReference( TInt aIndex, const TDesC8& aAnswers ); |
|
105 |
|
106 /** Set contents, compare result */ |
|
107 TBool TrySetContentsL( const TDesC8& aOldString, const TDesC8& aNewString ); |
|
108 /** Set contents, compare result and notifications list */ |
|
109 TBool TrySetContentsL( const TDesC8& aOldString, const TDesC8& aNewString, |
|
110 const TNotification::TData* aNotificationList ); |
|
111 /** Set contents with and without static items, compare result and notifications list */ |
|
112 TBool TrySetContentsL( const TDesC8& aOldString, const TDesC8& aNewString, |
|
113 const TDesC8& aNewStringWithStaticItems, |
|
114 const TNotification::TData* aNotificationListStaticItemsEnabled, |
|
115 const TNotification::TData* aNotificationListStaticItemsDisabled, |
|
116 NGlxListTestHelpers::TStaticItemInfo::TData* aStaticItemInfos ); |
|
117 |
|
118 TBool TryRemoveL( const TDesC8& aOldString, const TChar aItemToRemove, |
|
119 const TDesC8& aNewString, const TNotification::TData* aNotificationList ); |
|
120 TBool TryRemoveL( const TDesC8& aOldString, |
|
121 const TChar aItemToRemove, TBool aIsStaticId, |
|
122 const TDesC8& aNewStringWithoutStaticItems, |
|
123 const TDesC8& aNewStringWithStaticItems, |
|
124 const TNotification::TData* aNotificationListStaticItemsDisabled, |
|
125 const TNotification::TData* aNotificationListStaticItemsEnabled, |
|
126 NGlxListTestHelpers::TStaticItemInfo::TData* aStaticItemInfos); |
|
127 /** |
|
128 * Test setting static items enabled |
|
129 */ |
|
130 TBool TrySetStaticItemsEnabledL( const TDesC8& aStringWithoutStaticItems, |
|
131 const TDesC8& aStringWithStaticItems, |
|
132 NGlxListTestHelpers::TStaticItemInfo::TData* aInfos, |
|
133 const TNotification::TData* aNotificationListForEnable, |
|
134 const TNotification::TData* aNotificationListForDisable ); |
|
135 |
|
136 TBool TryAddStaticItemL( const TDesC8& aInitString, |
|
137 TChar aStaticItemId, NGlxListDefs::TInsertionPosition aInsertPos, |
|
138 const TDesC8& aStringAfter, const TNotification::TData* aNotificationListForAdd, |
|
139 const TNotification::TData* aNotificationListForAllStatic, |
|
140 NGlxListTestHelpers::TStaticItemInfo::TData* aStaticItemInfos ); |
|
141 |
|
142 /** Sets contents, does not create a list */ |
|
143 TBool SetContentsL( const TDesC8& aString ); |
|
144 |
|
145 /** Reorders contents, does not create a list */ |
|
146 TBool ReorderContentsL( const TDesC8& aString ); |
|
147 |
|
148 /** Run test for OfferMedia */ |
|
149 void TestOfferMediaL(); |
|
150 /** Run test for RemoveReference */ |
|
151 void TestRemoveReferenceL(); |
|
152 /** Run test for IdSpaceId */ |
|
153 void TestIdSpaceIdL(); |
|
154 /** Run test for Count, requires static items support in deriving class */ |
|
155 void TestCountL(); |
|
156 /** Run test for Index, requires static items support in deriving class */ |
|
157 void TestIndexL(); |
|
158 /** Run test for Item, requires static items support in deriving class */ |
|
159 void TestItemL(); |
|
160 |
|
161 private: |
|
162 TBool TrySetContentsL( const TDesC8& aOldString, |
|
163 const TDesC8& aNewString, const TDesC8& aNewStringWithStaticItems, |
|
164 const TNotification::TData* aNotificationList, |
|
165 TBool aStaticItemsEnabled, |
|
166 NGlxListTestHelpers::TStaticItemInfo::TData* aStaticItemInfos ); |
|
167 |
|
168 TBool TryRemoveL( const TDesC8& aOldString, |
|
169 const TChar aItemToRemove, TBool aIsStaticId, |
|
170 const TDesC8& aNewString, |
|
171 const TNotification::TData* aNotificationList, |
|
172 TBool aStaticItemsEnabled, |
|
173 NGlxListTestHelpers::TStaticItemInfo::TData* aStaticItemInfos ); |
|
174 |
|
175 TBool TryAddStaticItemL( const TDesC8& aInitString, TChar aStaticItemId, |
|
176 NGlxListDefs::TInsertionPosition aInsertPos, |
|
177 const TDesC8& aStringAfter, |
|
178 const TNotification::TData* aNotificationList, |
|
179 TBool aStaticItemsEnabled, |
|
180 NGlxListTestHelpers::TStaticItemInfo::TData* aStaticItemInfos ); |
|
181 |
|
182 void GetRequiredAttributesL( TInt aIndex, RArray< TMPXAttribute >& aAttributes ); |
|
183 void HandleAttributesAvailableL( TInt aIndex, const RArray< TMPXAttribute >& aAttributes ); |
|
184 void RemoveReference( TInt aIndex ); |
|
185 void HandleError( TInt aError ); |
|
186 |
|
187 protected: |
|
188 // class under test |
|
189 _ListClass* iList; |
|
190 // reconstruction of list based on notifications |
|
191 _ReconstructionClass* iReconstruction; |
|
192 // Pool of media items |
|
193 RPointerArray< CGlxMedia > iMediaPool; |
|
194 }; |
|
195 |
|
196 #include "glxlisttestbase.inl" |
|
197 |
|
198 #endif // __C_GLXLISTTESTBASE_H__ |