|
58
|
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: tester for methods in VideoProxyModelCollections
|
|
|
15 |
*
|
|
|
16 |
*/
|
|
|
17 |
|
|
|
18 |
#include <QModelIndex>
|
|
|
19 |
#include <QModelIndexList>
|
|
|
20 |
#include <hbapplication.h>
|
|
|
21 |
|
|
|
22 |
#include <vcxmyvideosdefs.h>
|
|
|
23 |
#include "videoproxymodelgeneric.h"
|
|
|
24 |
#include "videolistdatamodel.h"
|
|
|
25 |
|
|
|
26 |
#define private public
|
|
|
27 |
#include "videoproxymodelcollections.h"
|
|
|
28 |
#undef private
|
|
|
29 |
|
|
|
30 |
#include "filterproxytester.h"
|
|
|
31 |
#include "videocollectioncommon.h"
|
|
|
32 |
#include "testvideoproxymodelcollections.h"
|
|
|
33 |
|
|
|
34 |
// ---------------------------------------------------------------------------
|
|
|
35 |
// main
|
|
|
36 |
// ---------------------------------------------------------------------------
|
|
|
37 |
//
|
|
|
38 |
int main(int argc, char *argv[])
|
|
|
39 |
{
|
|
|
40 |
HbApplication app(argc, argv);
|
|
|
41 |
|
|
|
42 |
TestVideoProxyModelCollections tv;
|
|
|
43 |
|
|
|
44 |
int res;
|
|
|
45 |
if(argc > 1)
|
|
|
46 |
{
|
|
|
47 |
res = QTest::qExec(&tv, argc, argv);
|
|
|
48 |
}
|
|
|
49 |
else
|
|
|
50 |
{
|
|
|
51 |
char *pass[3];
|
|
|
52 |
pass[0] = argv[0];
|
|
|
53 |
pass[1] = "-o";
|
|
|
54 |
pass[2] = "c:\\data\\testVideoProxyModelCollections.txt";
|
|
|
55 |
res = QTest::qExec(&tv, 3, pass);
|
|
|
56 |
}
|
|
|
57 |
|
|
|
58 |
return res;
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
// ---------------------------------------------------------------------------
|
|
|
62 |
// init
|
|
|
63 |
// ---------------------------------------------------------------------------
|
|
|
64 |
//
|
|
|
65 |
void TestVideoProxyModelCollections::init()
|
|
|
66 |
{
|
|
|
67 |
qRegisterMetaType<TMPXItemId>("TMPXItemId");
|
|
|
68 |
|
|
|
69 |
mTestObject = new FilterProxyTester();
|
|
|
70 |
}
|
|
|
71 |
|
|
|
72 |
// ---------------------------------------------------------------------------
|
|
|
73 |
// cleanup
|
|
|
74 |
// ---------------------------------------------------------------------------
|
|
|
75 |
//
|
|
|
76 |
void TestVideoProxyModelCollections::cleanup()
|
|
|
77 |
{
|
|
|
78 |
delete mTestObject;
|
|
|
79 |
mTestObject = 0;
|
|
|
80 |
}
|
|
|
81 |
|
|
|
82 |
// ---------------------------------------------------------------------------
|
|
|
83 |
// testLessThan
|
|
|
84 |
// ---------------------------------------------------------------------------
|
|
|
85 |
//
|
|
|
86 |
void TestVideoProxyModelCollections::testLessThan()
|
|
|
87 |
{
|
|
|
88 |
QModelIndex left;
|
|
|
89 |
QModelIndex right;
|
|
|
90 |
|
|
|
91 |
// No model.
|
|
|
92 |
QVERIFY(mTestObject->callLessThan(left, right) == false);
|
|
|
93 |
QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 0);
|
|
|
94 |
|
|
|
95 |
// Set model.
|
|
|
96 |
VideoListDataModel *model = 0;
|
|
|
97 |
model = new VideoListDataModel();
|
|
|
98 |
mTestObject->mModel = model;
|
|
|
99 |
|
|
|
100 |
// Default categories are always first in the following order:
|
|
|
101 |
// Recently played (missing currently)
|
|
|
102 |
// Captured
|
|
|
103 |
// Downloaded
|
|
|
104 |
// Podcasts (missing currently)
|
|
|
105 |
|
|
|
106 |
// Items are not categories.
|
|
|
107 |
VideoProxyModelGeneric::mLessThanCallCount = 0;
|
|
|
108 |
VideoListDataModel::mMediaIdAtIndexCallCount = 0;
|
|
|
109 |
VideoListDataModel::mMediaIdAtIndexReturnValues.append(TMPXItemId(0, KVcxMvcMediaTypeVideo));
|
|
|
110 |
VideoListDataModel::mMediaIdAtIndexReturnValues.append(TMPXItemId(1, KVcxMvcMediaTypeAlbum));
|
|
|
111 |
QVERIFY(mTestObject->callLessThan(left, right) == true);
|
|
|
112 |
QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 2);
|
|
|
113 |
QCOMPARE(VideoProxyModelGeneric::mLessThanCallCount, 1);
|
|
|
114 |
|
|
|
115 |
// Both are categories, left is captured
|
|
|
116 |
VideoProxyModelGeneric::mLessThanCallCount = 0;
|
|
|
117 |
VideoListDataModel::mMediaIdAtIndexCallCount = 0;
|
|
|
118 |
VideoListDataModel::mMediaIdAtIndexReturnValues.append(
|
|
|
119 |
TMPXItemId(KVcxMvcCategoryIdCaptured, KVcxMvcMediaTypeCategory));
|
|
|
120 |
VideoListDataModel::mMediaIdAtIndexReturnValues.append(
|
|
|
121 |
TMPXItemId(KVcxMvcCategoryIdDownloads, KVcxMvcMediaTypeCategory));
|
|
|
122 |
QVERIFY(mTestObject->callLessThan(left, right) == true);
|
|
|
123 |
QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 2);
|
|
|
124 |
QCOMPARE(VideoProxyModelGeneric::mLessThanCallCount, 0);
|
|
|
125 |
|
|
|
126 |
// Both are categories, left is downloads, right some other
|
|
|
127 |
VideoProxyModelGeneric::mLessThanCallCount = 0;
|
|
|
128 |
VideoListDataModel::mMediaIdAtIndexCallCount = 0;
|
|
|
129 |
VideoListDataModel::mMediaIdAtIndexReturnValues.append(
|
|
|
130 |
TMPXItemId(KVcxMvcCategoryIdDownloads, KVcxMvcMediaTypeCategory));
|
|
|
131 |
VideoListDataModel::mMediaIdAtIndexReturnValues.append(
|
|
|
132 |
TMPXItemId(KVcxMvcCategoryIdOther, KVcxMvcMediaTypeCategory));
|
|
|
133 |
QVERIFY(mTestObject->callLessThan(left, right) == true);
|
|
|
134 |
QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 2);
|
|
|
135 |
QCOMPARE(VideoProxyModelGeneric::mLessThanCallCount, 0);
|
|
|
136 |
|
|
|
137 |
// Both are categories, left is downloads, right captured
|
|
|
138 |
VideoProxyModelGeneric::mLessThanCallCount = 0;
|
|
|
139 |
VideoListDataModel::mMediaIdAtIndexCallCount = 0;
|
|
|
140 |
VideoListDataModel::mMediaIdAtIndexReturnValues.append(
|
|
|
141 |
TMPXItemId(KVcxMvcCategoryIdDownloads, KVcxMvcMediaTypeCategory));
|
|
|
142 |
VideoListDataModel::mMediaIdAtIndexReturnValues.append(
|
|
|
143 |
TMPXItemId(KVcxMvcCategoryIdCaptured, KVcxMvcMediaTypeCategory));
|
|
|
144 |
QVERIFY(mTestObject->callLessThan(left, right) == false);
|
|
|
145 |
QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 2);
|
|
|
146 |
QCOMPARE(VideoProxyModelGeneric::mLessThanCallCount, 0);
|
|
|
147 |
|
|
|
148 |
// Only left is category
|
|
|
149 |
VideoProxyModelGeneric::mLessThanCallCount = 0;
|
|
|
150 |
VideoListDataModel::mMediaIdAtIndexCallCount = 0;
|
|
|
151 |
VideoListDataModel::mMediaIdAtIndexReturnValues.append(
|
|
|
152 |
TMPXItemId(KVcxMvcCategoryIdDownloads, KVcxMvcMediaTypeCategory));
|
|
|
153 |
VideoListDataModel::mMediaIdAtIndexReturnValues.append(
|
|
|
154 |
TMPXItemId(1, KVcxMvcMediaTypeVideo));
|
|
|
155 |
QVERIFY(mTestObject->callLessThan(left, right) == true);
|
|
|
156 |
QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 2);
|
|
|
157 |
QCOMPARE(VideoProxyModelGeneric::mLessThanCallCount, 0);
|
|
|
158 |
|
|
|
159 |
// Only right is category
|
|
|
160 |
VideoProxyModelGeneric::mLessThanCallCount = 0;
|
|
|
161 |
VideoListDataModel::mMediaIdAtIndexCallCount = 0;
|
|
|
162 |
VideoListDataModel::mMediaIdAtIndexReturnValues.append(
|
|
|
163 |
TMPXItemId(1, KVcxMvcMediaTypeVideo));
|
|
|
164 |
VideoListDataModel::mMediaIdAtIndexReturnValues.append(
|
|
|
165 |
TMPXItemId(KVcxMvcCategoryIdDownloads, KVcxMvcMediaTypeCategory));
|
|
|
166 |
QVERIFY(mTestObject->callLessThan(left, right) == false);
|
|
|
167 |
QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 2);
|
|
|
168 |
QCOMPARE(VideoProxyModelGeneric::mLessThanCallCount, 0);
|
|
|
169 |
|
|
|
170 |
// Sort order is descending. Both are categories, left is captured.
|
|
|
171 |
mTestObject->mWantedSortOrder = Qt::DescendingOrder;
|
|
|
172 |
VideoProxyModelGeneric::mLessThanCallCount = 0;
|
|
|
173 |
VideoListDataModel::mMediaIdAtIndexCallCount = 0;
|
|
|
174 |
VideoListDataModel::mMediaIdAtIndexReturnValues.append(
|
|
|
175 |
TMPXItemId(KVcxMvcCategoryIdCaptured, KVcxMvcMediaTypeCategory));
|
|
|
176 |
VideoListDataModel::mMediaIdAtIndexReturnValues.append(
|
|
|
177 |
TMPXItemId(KVcxMvcCategoryIdDownloads, KVcxMvcMediaTypeCategory));
|
|
|
178 |
QVERIFY(mTestObject->callLessThan(left, right) == false);
|
|
|
179 |
QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 2);
|
|
|
180 |
QCOMPARE(VideoProxyModelGeneric::mLessThanCallCount, 0);
|
|
|
181 |
}
|
|
|
182 |
|
|
|
183 |
// ---------------------------------------------------------------------------
|
|
|
184 |
// testFilterAcceptsRow
|
|
|
185 |
// ---------------------------------------------------------------------------
|
|
|
186 |
//
|
|
|
187 |
void TestVideoProxyModelCollections::testFilterAcceptsRow()
|
|
|
188 |
{
|
|
|
189 |
// No source model
|
|
|
190 |
VideoListDataModel *model = 0;
|
|
|
191 |
mTestObject->mModel = model;
|
|
|
192 |
VideoListDataModel::mMediaIdAtIndexCallCount = 0;
|
|
|
193 |
VideoListDataModel::mRowCountReturnValue = 0;
|
|
|
194 |
QVERIFY(mTestObject->callFilterAcceptsRow(0, QModelIndex()) == false);
|
|
|
195 |
QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 0);
|
|
|
196 |
|
|
|
197 |
// Source row < 0
|
|
|
198 |
model = new VideoListDataModel();
|
|
|
199 |
mTestObject->mModel = model;
|
|
|
200 |
VideoListDataModel::mMediaIdAtIndexCallCount = 0;
|
|
|
201 |
VideoListDataModel::mRowCountReturnValue = 0;
|
|
|
202 |
QVERIFY(mTestObject->callFilterAcceptsRow(-1, QModelIndex()) == false);
|
|
|
203 |
QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 0);
|
|
|
204 |
|
|
|
205 |
// Source row > model row count
|
|
|
206 |
VideoListDataModel::mMediaIdAtIndexCallCount = 0;
|
|
|
207 |
VideoListDataModel::mRowCountReturnValue = 0;
|
|
|
208 |
QVERIFY(mTestObject->callFilterAcceptsRow(10, QModelIndex()) == false);
|
|
|
209 |
QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 0);
|
|
|
210 |
|
|
|
211 |
// Current level is not category
|
|
|
212 |
mTestObject->mLevel = VideoCollectionCommon::ELevelVideos;
|
|
|
213 |
VideoListDataModel::mMediaIdAtIndexReturnValues.clear();
|
|
|
214 |
VideoListDataModel::mMediaIdAtIndexReturnValues.append(TMPXItemId(0, KVcxMvcMediaTypeAlbum));
|
|
|
215 |
VideoListDataModel::mMediaIdAtIndexCallCount = 0;
|
|
|
216 |
VideoListDataModel::mRowCountReturnValue = 1;
|
|
|
217 |
QVERIFY(mTestObject->callFilterAcceptsRow(0, QModelIndex()) == false);
|
|
|
218 |
QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 1);
|
|
|
219 |
|
|
|
220 |
// Item id is not an album
|
|
|
221 |
mTestObject->mLevel = VideoCollectionCommon::ELevelCategory;
|
|
|
222 |
VideoListDataModel::mMediaIdAtIndexReturnValues.clear();
|
|
|
223 |
VideoListDataModel::mMediaIdAtIndexReturnValues.append(TMPXItemId(0, KVcxMvcMediaTypeVideo));
|
|
|
224 |
VideoListDataModel::mMediaIdAtIndexCallCount = 0;
|
|
|
225 |
VideoListDataModel::mRowCountReturnValue = 1;
|
|
|
226 |
QVERIFY(mTestObject->callFilterAcceptsRow(0, QModelIndex()) == false);
|
|
|
227 |
QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 1);
|
|
|
228 |
|
|
|
229 |
// Item is album
|
|
|
230 |
mTestObject->mLevel = VideoCollectionCommon::ELevelCategory;
|
|
|
231 |
VideoListDataModel::mMediaIdAtIndexReturnValues.clear();
|
|
|
232 |
VideoListDataModel::mMediaIdAtIndexReturnValues.append(TMPXItemId(0, KVcxMvcMediaTypeAlbum));
|
|
|
233 |
VideoListDataModel::mMediaIdAtIndexCallCount = 0;
|
|
|
234 |
VideoListDataModel::mRowCountReturnValue = 1;
|
|
|
235 |
QVERIFY(mTestObject->callFilterAcceptsRow(0, QModelIndex()) == true);
|
|
|
236 |
QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 1);
|
|
|
237 |
|
|
|
238 |
// Item is category
|
|
|
239 |
mTestObject->mLevel = VideoCollectionCommon::ELevelCategory;
|
|
|
240 |
VideoListDataModel::mMediaIdAtIndexReturnValues.clear();
|
|
|
241 |
VideoListDataModel::mMediaIdAtIndexReturnValues.append(TMPXItemId(0, KVcxMvcMediaTypeCategory));
|
|
|
242 |
VideoListDataModel::mMediaIdAtIndexCallCount = 0;
|
|
|
243 |
VideoListDataModel::mRowCountReturnValue = 1;
|
|
|
244 |
QVERIFY(mTestObject->callFilterAcceptsRow(0, QModelIndex()) == true);
|
|
|
245 |
QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 1);
|
|
|
246 |
}
|
|
|
247 |
|
|
|
248 |
// End of file
|