|
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: MpMpxCollectionData stub for testing MpCollectionDataModel |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "mptrace.h" |
|
19 #include "stub/inc/mpmpxcollectiondata.h" |
|
20 |
|
21 |
|
22 int gInitCounter = 0; |
|
23 int gItemDataCount = 0; |
|
24 int gRemoveItemCount = 0; |
|
25 int gCachedItemId = 0; |
|
26 int gInsertCachedItemCount = 0; |
|
27 |
|
28 /*! |
|
29 Returns gInitCounter. |
|
30 gInitCounter counts the number of constructor/destructor calls. |
|
31 */ |
|
32 int MpMpxCollectionData::getInitCounter() |
|
33 { |
|
34 return gInitCounter; |
|
35 } |
|
36 |
|
37 /*! |
|
38 Resets gInitCounter to zero. |
|
39 */ |
|
40 void MpMpxCollectionData::resetInitCounter() |
|
41 { |
|
42 gInitCounter = 0; |
|
43 } |
|
44 |
|
45 /*! |
|
46 Returns gItemDataCount. |
|
47 gItemDataCount counts the number of itemData() calls. |
|
48 */ |
|
49 int MpMpxCollectionData::getItemDataCounter() |
|
50 { |
|
51 return gItemDataCount; |
|
52 } |
|
53 |
|
54 /*! |
|
55 Resets gItemDataCount to zero. |
|
56 */ |
|
57 void MpMpxCollectionData::resetItemDataCounter() |
|
58 { |
|
59 gItemDataCount = 0; |
|
60 } |
|
61 |
|
62 /*! |
|
63 Returns gItemDataCount. |
|
64 gRemoveItemCount counts the number of itemData() calls. |
|
65 */ |
|
66 int MpMpxCollectionData::getremoveItemCounter() |
|
67 { |
|
68 return gRemoveItemCount; |
|
69 } |
|
70 |
|
71 /*! |
|
72 Resets gRemoveItemCount to zero. |
|
73 */ |
|
74 void MpMpxCollectionData::resetremoveItemCounter() |
|
75 { |
|
76 gRemoveItemCount = 0; |
|
77 } |
|
78 |
|
79 /*! |
|
80 Sets gCachedItemId. |
|
81 */ |
|
82 void MpMpxCollectionData::setCachedItemId(int id) |
|
83 { |
|
84 gCachedItemId = id; |
|
85 } |
|
86 |
|
87 /*! |
|
88 Returns gInsertCachedItemCount. |
|
89 */ |
|
90 int MpMpxCollectionData::getInsertCachedItemCounter() |
|
91 { |
|
92 return gInsertCachedItemCount; |
|
93 } |
|
94 |
|
95 /*! |
|
96 Resets gInsertCachedItemCount to zero. |
|
97 */ |
|
98 void MpMpxCollectionData::resetInsertCachedItemCounter() |
|
99 { |
|
100 gInsertCachedItemCount = 0; |
|
101 } |
|
102 |
|
103 /*! |
|
104 Stub function. |
|
105 */ |
|
106 MpMpxCollectionData::MpMpxCollectionData( QObject *parent ) |
|
107 : QObject(parent), |
|
108 mContext(ECollectionContextUnknown), |
|
109 mCount(0), |
|
110 mItemDataReturn(true) |
|
111 { |
|
112 gInitCounter++; |
|
113 } |
|
114 |
|
115 /*! |
|
116 Stub function. |
|
117 */ |
|
118 MpMpxCollectionData::~MpMpxCollectionData() |
|
119 { |
|
120 gInitCounter--; |
|
121 } |
|
122 |
|
123 /*! |
|
124 Stub function. |
|
125 */ |
|
126 TCollectionContext MpMpxCollectionData::context() const |
|
127 { |
|
128 return mContext; |
|
129 } |
|
130 |
|
131 /*! |
|
132 Stub function. |
|
133 */ |
|
134 int MpMpxCollectionData::count() const |
|
135 { |
|
136 return mCount; |
|
137 } |
|
138 |
|
139 /*! |
|
140 Stub function. |
|
141 */ |
|
142 QString MpMpxCollectionData::itemData( int index, MpMpxCollectionData::DataType type ) const |
|
143 { |
|
144 if ( index < 0 || index > mCount ) { |
|
145 TX_LOG_ARGS("index=" << index); |
|
146 qFatal("MpMpxCollectionData::itemData called with index out of range"); |
|
147 } |
|
148 gItemDataCount++; |
|
149 QString data; |
|
150 if ( !mItemDataReturn && (type != MpMpxCollectionData::Count) ) { |
|
151 return data; |
|
152 } |
|
153 switch ( type ) { |
|
154 case MpMpxCollectionData::Title: |
|
155 data = QString("Title"); |
|
156 break; |
|
157 case MpMpxCollectionData::Artist: |
|
158 data = QString("Artist"); |
|
159 break; |
|
160 case MpMpxCollectionData::Album: |
|
161 data = QString("Album"); |
|
162 break; |
|
163 case MpMpxCollectionData::Count: |
|
164 data = QString("Count"); |
|
165 break; |
|
166 case MpMpxCollectionData::AlbumArtUri: |
|
167 data = QString("AlbumArtUri"); |
|
168 break; |
|
169 default: |
|
170 qFatal("MpMpxCollectionData::itemData called with unknown type"); |
|
171 break; |
|
172 } |
|
173 return data; |
|
174 } |
|
175 |
|
176 /*! |
|
177 Stub function. |
|
178 */ |
|
179 int MpMpxCollectionData::containerId() |
|
180 { |
|
181 return 65535; |
|
182 } |
|
183 |
|
184 /*! |
|
185 Stub function. |
|
186 */ |
|
187 int MpMpxCollectionData::itemId(int index) |
|
188 { |
|
189 return 2000+index; |
|
190 } |
|
191 |
|
192 /*! |
|
193 Stub function. |
|
194 */ |
|
195 void MpMpxCollectionData::removeItem(int index) |
|
196 { |
|
197 Q_UNUSED(index); |
|
198 gRemoveItemCount++; |
|
199 return ; |
|
200 } |
|
201 |
|
202 /*! |
|
203 Stub function. |
|
204 */ |
|
205 bool MpMpxCollectionData::testCachedItem( int itemId ) |
|
206 { |
|
207 return gCachedItemId == itemId; |
|
208 } |
|
209 |
|
210 /*! |
|
211 Stub function. |
|
212 */ |
|
213 void MpMpxCollectionData::insertCachedItem(int index) |
|
214 { |
|
215 Q_UNUSED(index); |
|
216 gInsertCachedItemCount++; |
|
217 return ; |
|
218 } |
|
219 |