30
|
1 |
|
|
2 |
/**
|
|
3 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
4 |
* All rights reserved.
|
|
5 |
* This component and the accompanying materials are made available
|
|
6 |
* under the terms of "Eclipse Public License v1.0"
|
|
7 |
* which accompanies this distribution, and is available
|
|
8 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
9 |
*
|
|
10 |
* Initial Contributors:
|
|
11 |
* Nokia Corporation - initial contribution.
|
|
12 |
*
|
|
13 |
* Contributors:
|
|
14 |
*
|
|
15 |
* Description: tester for methods in CVideoCollectionWrapperPrivate
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
|
|
20 |
// INCLUDES
|
|
21 |
|
|
22 |
#include "testvideocollectionclient.h"
|
|
23 |
#include "videocollectioncommon.h"
|
|
24 |
#include "stub/inc/videocollectionlistener.h"
|
|
25 |
|
|
26 |
#define private public
|
|
27 |
#include "videocollectionclient.h"
|
|
28 |
#undef private
|
|
29 |
|
|
30 |
#include "stub/inc/stubcollectionsignalclasses.h"
|
|
31 |
|
|
32 |
Q_DECLARE_METATYPE(QList<int>)
|
|
33 |
|
|
34 |
// -----------------------------------------------------------------------------
|
|
35 |
// main
|
|
36 |
// -----------------------------------------------------------------------------
|
|
37 |
//
|
|
38 |
int main(int argc, char *argv[])
|
|
39 |
{
|
|
40 |
TestVideoCollectionClient tv;
|
|
41 |
|
|
42 |
char *pass[3];
|
|
43 |
pass[0] = argv[0];
|
|
44 |
pass[1] = "-o";
|
|
45 |
pass[2] = "c:\\data\\testvideocollectionclient.txt";
|
|
46 |
|
|
47 |
int res = QTest::qExec(&tv, 3, pass);
|
|
48 |
|
|
49 |
return res;
|
|
50 |
}
|
|
51 |
|
|
52 |
Q_DECLARE_METATYPE(QList<TMPXItemId>)
|
|
53 |
|
|
54 |
// -----------------------------------------------------------------------------
|
|
55 |
// init
|
|
56 |
// -----------------------------------------------------------------------------
|
|
57 |
//
|
|
58 |
void TestVideoCollectionClient::init()
|
|
59 |
{
|
|
60 |
mTestObject = new VideoCollectionClient();
|
|
61 |
}
|
|
62 |
|
|
63 |
// -----------------------------------------------------------------------------
|
|
64 |
// cleanup
|
|
65 |
// -----------------------------------------------------------------------------
|
|
66 |
//
|
|
67 |
void TestVideoCollectionClient::cleanup()
|
|
68 |
{
|
|
69 |
delete mTestObject;
|
|
70 |
mTestObject = 0;
|
|
71 |
}
|
|
72 |
|
|
73 |
// -----------------------------------------------------------------------------
|
|
74 |
// testInitializeCollUtilityExists
|
|
75 |
// -----------------------------------------------------------------------------
|
|
76 |
//
|
|
77 |
void TestVideoCollectionClient::testInitializeCollUtilityExists()
|
|
78 |
{
|
|
79 |
MMPXCollectionUtility *tmpUtility = new MMPXCollectionUtility();
|
|
80 |
mTestObject->mCollectionUtility = tmpUtility;
|
|
81 |
QVERIFY(mTestObject->initialize() == 0);
|
|
82 |
QVERIFY(mTestObject->mCollectionUtility != 0);
|
|
83 |
QVERIFY(mTestObject->mCollectionListener != 0);
|
|
84 |
}
|
|
85 |
|
|
86 |
// -----------------------------------------------------------------------------
|
|
87 |
// testInitializeCollUtilityExists
|
|
88 |
// -----------------------------------------------------------------------------
|
|
89 |
//
|
|
90 |
void TestVideoCollectionClient::testInitializeCollListenerExist()
|
|
91 |
{
|
|
92 |
VideoCollectionListener *tmpListener = new VideoCollectionListener(*mTestObject);
|
|
93 |
mTestObject->mCollectionListener = tmpListener;
|
|
94 |
QVERIFY(mTestObject->initialize() == 0);
|
|
95 |
QVERIFY(mTestObject->mCollectionUtility != 0);
|
|
96 |
QVERIFY(mTestObject->mCollectionListener != 0);
|
|
97 |
}
|
|
98 |
|
|
99 |
// -----------------------------------------------------------------------------
|
|
100 |
// testInitializeCollUtilityExists
|
|
101 |
// -----------------------------------------------------------------------------
|
|
102 |
//
|
|
103 |
void TestVideoCollectionClient::testInitializeUtilCreateFail()
|
|
104 |
{
|
|
105 |
MMPXCollectionUtility::setNewLLeave(true);
|
|
106 |
QVERIFY(mTestObject->initialize() < 0);
|
|
107 |
QVERIFY(mTestObject->mCollectionUtility == 0);
|
|
108 |
QVERIFY(mTestObject->mCollectionListener == 0);
|
|
109 |
MMPXCollectionUtility::setNewLLeave(false);
|
|
110 |
}
|
|
111 |
|
|
112 |
// -----------------------------------------------------------------------------
|
|
113 |
// testInitializeCollUtilityExists
|
|
114 |
// -----------------------------------------------------------------------------
|
|
115 |
//
|
|
116 |
void TestVideoCollectionClient::testInitializeSucceed()
|
|
117 |
{
|
|
118 |
MMPXCollectionUtility::setNewLLeave(false);
|
|
119 |
QVERIFY(mTestObject->initialize() == 0);
|
|
120 |
// none exists
|
|
121 |
QVERIFY(mTestObject->initialize() == 0);
|
|
122 |
QVERIFY(mTestObject->mCollectionUtility != 0);
|
|
123 |
QVERIFY(mTestObject->mCollectionListener != 0);
|
|
124 |
|
|
125 |
// both items exists
|
|
126 |
QVERIFY(mTestObject->initialize() == 0);
|
|
127 |
QVERIFY(mTestObject->mCollectionUtility != 0);
|
|
128 |
QVERIFY(mTestObject->mCollectionListener != 0);
|
|
129 |
|
|
130 |
MMPXCollectionUtility::resetCloseCounter();
|
|
131 |
QPointer<VideoCollectionListener> listener = mTestObject->mCollectionListener;
|
|
132 |
|
|
133 |
cleanup();
|
|
134 |
|
|
135 |
QVERIFY(MMPXCollectionUtility::getCloseCounter() == 1);
|
|
136 |
QVERIFY(listener == 0);
|
|
137 |
}
|
|
138 |
|
|
139 |
// -----------------------------------------------------------------------------
|
|
140 |
// testInitializeCollUtilityExists
|
|
141 |
// -----------------------------------------------------------------------------
|
|
142 |
//
|
|
143 |
void TestVideoCollectionClient::testConnectCollectionSignalReceiver()
|
|
144 |
{
|
|
145 |
// no collection listener or signal receiver
|
|
146 |
QVERIFY(mTestObject->connectCollectionSignalReceiver(0) == -1);
|
|
147 |
|
|
148 |
// no collection listener
|
|
149 |
StubSignalReceiver stubReceiver;
|
|
150 |
QVERIFY(mTestObject->connectCollectionSignalReceiver(&stubReceiver) == -1);
|
|
151 |
|
|
152 |
// collection listener exists, no signal receiver
|
|
153 |
QVERIFY(mTestObject->initialize() == 0);
|
|
154 |
QVERIFY(mTestObject->connectCollectionSignalReceiver(0) == -1);
|
|
155 |
|
|
156 |
VideoCollectionListener *tmp = mTestObject->mCollectionListener;
|
|
157 |
|
|
158 |
// no newVideoList signal
|
|
159 |
StubListenerNoNewVideoList *noNewVideoList =
|
|
160 |
new StubListenerNoNewVideoList(*mTestObject);
|
|
161 |
mTestObject->mCollectionListener = noNewVideoList;
|
|
162 |
QVERIFY(mTestObject->connectCollectionSignalReceiver(&stubReceiver) == -1);
|
|
163 |
delete noNewVideoList;
|
|
164 |
|
|
165 |
// no videoListAppended signal
|
|
166 |
StubListenerNoVideoListAppended *noVideoListAppended =
|
|
167 |
new StubListenerNoVideoListAppended(*mTestObject);
|
|
168 |
mTestObject->mCollectionListener = noVideoListAppended;
|
|
169 |
QVERIFY(mTestObject->connectCollectionSignalReceiver(&stubReceiver) == -1);
|
|
170 |
delete noVideoListAppended;
|
|
171 |
|
|
172 |
// no newVideoAvailable signal
|
|
173 |
StubListenerNoNewVideoAvailable *noNewVideo =
|
|
174 |
new StubListenerNoNewVideoAvailable(*mTestObject);
|
|
175 |
mTestObject->mCollectionListener = noNewVideo;
|
|
176 |
QVERIFY(mTestObject->connectCollectionSignalReceiver(&stubReceiver) == -1);
|
|
177 |
delete noNewVideo;
|
|
178 |
|
|
179 |
// no videoDeleted signal
|
|
180 |
StubListenerNoVideoDeleted *noVideoDeleted =
|
|
181 |
new StubListenerNoVideoDeleted(*mTestObject);
|
|
182 |
mTestObject->mCollectionListener = noVideoDeleted;
|
|
183 |
QVERIFY(mTestObject->connectCollectionSignalReceiver(&stubReceiver) == -1);
|
|
184 |
delete noVideoDeleted;
|
|
185 |
|
|
186 |
// no videoDeleteCompleted signal
|
|
187 |
StubListenerNoVideoDeleteCompleted *noVideoDelCompl =
|
|
188 |
new StubListenerNoVideoDeleteCompleted(*mTestObject);
|
|
189 |
mTestObject->mCollectionListener = noVideoDelCompl;
|
|
190 |
QVERIFY(mTestObject->connectCollectionSignalReceiver(&stubReceiver) == -1);
|
|
191 |
delete noVideoDelCompl;
|
|
192 |
|
|
193 |
// no videoDetailsCompleted signal
|
|
194 |
StubListenerNoVideoDetailsCompleted *noVideoDetails =
|
|
195 |
new StubListenerNoVideoDetailsCompleted(*mTestObject);
|
|
196 |
mTestObject->mCollectionListener = noVideoDetails;
|
|
197 |
QVERIFY(mTestObject->connectCollectionSignalReceiver(&stubReceiver) == -1);
|
|
198 |
delete noVideoDetails;
|
|
199 |
|
|
200 |
// all signals exists
|
|
201 |
StubListenerAllSignals *allSignals =
|
|
202 |
new StubListenerAllSignals(*mTestObject);
|
|
203 |
mTestObject->mCollectionListener = allSignals;
|
|
204 |
QVERIFY(mTestObject->connectCollectionSignalReceiver(&stubReceiver) == 0);
|
|
205 |
delete allSignals;
|
|
206 |
|
|
207 |
mTestObject->mCollectionListener = tmp;
|
|
208 |
}
|
|
209 |
|
|
210 |
// -----------------------------------------------------------------------------
|
|
211 |
// testInitializeCollUtilityExists
|
|
212 |
// -----------------------------------------------------------------------------
|
|
213 |
//
|
|
214 |
void TestVideoCollectionClient::testCollectionLevel()
|
|
215 |
{
|
|
216 |
// no collection utility
|
|
217 |
QVERIFY(mTestObject->getCollectionLevel() == -1);
|
|
218 |
|
|
219 |
QVERIFY(mTestObject->initialize() == 0);
|
|
220 |
|
|
221 |
// path level not setted
|
|
222 |
QVERIFY(mTestObject->getCollectionLevel() == -1);
|
|
223 |
|
|
224 |
// succeeds
|
|
225 |
mTestObject->mCollectionPathLevel = VideoCollectionClient::ELevelCategory;
|
|
226 |
QVERIFY(mTestObject->getCollectionLevel() == VideoCollectionClient::ELevelCategory);
|
|
227 |
}
|
|
228 |
|
|
229 |
// -----------------------------------------------------------------------------
|
|
230 |
// testInitializeCollUtilityExists
|
|
231 |
// -----------------------------------------------------------------------------
|
|
232 |
//
|
|
233 |
void TestVideoCollectionClient::testGetOpenStatus()
|
|
234 |
{
|
|
235 |
QVERIFY(mTestObject->getOpenStatus() == VideoCollectionClient::ECollectionNotOpen);
|
|
236 |
|
|
237 |
mTestObject->setOpenStatus(100);
|
|
238 |
|
|
239 |
QVERIFY(mTestObject->getOpenStatus() == 100);
|
|
240 |
}
|
|
241 |
|
|
242 |
// -----------------------------------------------------------------------------
|
|
243 |
// testInitializeCollUtilityExists
|
|
244 |
// -----------------------------------------------------------------------------
|
|
245 |
//
|
|
246 |
void TestVideoCollectionClient::testSetOpenStatus()
|
|
247 |
{
|
|
248 |
mTestObject->setOpenStatus(VideoCollectionClient::ECollectionNotOpen);
|
|
249 |
QVERIFY(mTestObject->getOpenStatus() == VideoCollectionClient::ECollectionNotOpen);
|
|
250 |
|
|
251 |
mTestObject->setOpenStatus(VideoCollectionClient::ECollectionOpened);
|
|
252 |
QVERIFY(mTestObject->getOpenStatus() == VideoCollectionClient::ECollectionOpened);
|
|
253 |
|
|
254 |
mTestObject->setOpenStatus(100);
|
|
255 |
QVERIFY(mTestObject->getOpenStatus() == 100);
|
|
256 |
|
|
257 |
}
|
|
258 |
|
|
259 |
// -----------------------------------------------------------------------------
|
|
260 |
// testInitializeCollUtilityExists
|
|
261 |
// -----------------------------------------------------------------------------
|
|
262 |
//
|
|
263 |
void TestVideoCollectionClient::testStartOpenCollection()
|
|
264 |
{
|
|
265 |
// no collection utility
|
|
266 |
QVERIFY(mTestObject->startOpenCollection(VideoCollectionClient::ELevelVideos) == -1);
|
|
267 |
|
|
268 |
QVERIFY(mTestObject->startOpenCollection(VideoCollectionClient::ELevelCategory) == -1);
|
|
269 |
|
|
270 |
QVERIFY(mTestObject->initialize() == 0);
|
|
271 |
// open status setted allready
|
|
272 |
mTestObject->setOpenStatus(VideoCollectionClient::ECollectionOpening);
|
|
273 |
QVERIFY(mTestObject->startOpenCollection(VideoCollectionClient::ELevelVideos) == 0);
|
|
274 |
mTestObject->setOpenStatus(VideoCollectionClient::ECollectionOpened);
|
|
275 |
QVERIFY(mTestObject->startOpenCollection(VideoCollectionClient::ELevelVideos) == 0);
|
|
276 |
|
|
277 |
mTestObject->setOpenStatus(VideoCollectionClient::ECollectionOpening);
|
|
278 |
QVERIFY(mTestObject->startOpenCollection(VideoCollectionClient::ELevelCategory) == 0);
|
|
279 |
mTestObject->setOpenStatus(VideoCollectionClient::ECollectionOpened);
|
|
280 |
QVERIFY(mTestObject->startOpenCollection(VideoCollectionClient::ELevelCategory) == 0);
|
|
281 |
|
|
282 |
// open status and level setted allready
|
|
283 |
mTestObject->setOpenStatus(VideoCollectionClient::ECollectionOpening);
|
|
284 |
mTestObject->mCollectionPathLevel = VideoCollectionClient::ELevelVideos;
|
|
285 |
QVERIFY(mTestObject->startOpenCollection(VideoCollectionClient::ELevelVideos) == 0);
|
|
286 |
mTestObject->setOpenStatus(VideoCollectionClient::ECollectionOpened);
|
|
287 |
QVERIFY(mTestObject->startOpenCollection(VideoCollectionClient::ELevelVideos) == 0);
|
|
288 |
|
|
289 |
mTestObject->mCollectionPathLevel = VideoCollectionClient::ELevelCategory;
|
|
290 |
mTestObject->setOpenStatus(VideoCollectionClient::ECollectionOpening);
|
|
291 |
QVERIFY(mTestObject->startOpenCollection(VideoCollectionClient::ELevelCategory) == 0);
|
|
292 |
mTestObject->setOpenStatus(VideoCollectionClient::ECollectionOpened);
|
|
293 |
QVERIFY(mTestObject->startOpenCollection(VideoCollectionClient::ELevelCategory) == 0);
|
|
294 |
|
|
295 |
mTestObject->setOpenStatus(VideoCollectionClient::ECollectionNotOpen);
|
|
296 |
// startOpenCollectionL -leaves
|
|
297 |
MMPXCollection::setOpenLPathLeave(true);
|
|
298 |
QVERIFY(mTestObject->startOpenCollection(VideoCollectionClient::ELevelVideos) < 0);
|
|
299 |
|
|
300 |
QVERIFY(mTestObject->startOpenCollection(VideoCollectionClient::ELevelCategory) < 0);
|
|
301 |
|
|
302 |
MMPXCollection::setOpenLPathLeave(false);
|
|
303 |
QVERIFY(mTestObject->startOpenCollection(VideoCollectionClient::ELevelVideos) == 0);
|
|
304 |
QVERIFY(mTestObject->getOpenStatus() == VideoCollectionClient::ECollectionOpening);
|
|
305 |
int id = 0;
|
|
306 |
int type = 0;
|
|
307 |
mTestObject->getCategoryIds(id, type);
|
|
308 |
QVERIFY(id == KVcxMvcCategoryIdAll);
|
|
309 |
QVERIFY(type == 1);
|
|
310 |
|
|
311 |
mTestObject->setOpenStatus(VideoCollectionClient::ECollectionOpened);
|
|
312 |
QVERIFY(mTestObject->startOpenCollection(VideoCollectionClient::ELevelCategory) == 0);
|
|
313 |
QVERIFY(mTestObject->getOpenStatus() == VideoCollectionClient::ECollectionOpening);
|
|
314 |
mTestObject->getCategoryIds(id, type);
|
|
315 |
QVERIFY(id == 0);
|
|
316 |
QVERIFY(type == 9);
|
|
317 |
|
|
318 |
mTestObject->setOpenStatus(VideoCollectionClient::ECollectionOpened);
|
|
319 |
QVERIFY(mTestObject->startOpenCollection(VideoCollectionClient::ELevelVideos) == 0);
|
|
320 |
QVERIFY(mTestObject->getOpenStatus() == VideoCollectionClient::ECollectionOpening);
|
|
321 |
|
|
322 |
}
|
|
323 |
|
|
324 |
// -----------------------------------------------------------------------------
|
|
325 |
// testStartOpenCurrentState
|
|
326 |
// -----------------------------------------------------------------------------
|
|
327 |
//
|
|
328 |
void TestVideoCollectionClient::testStartOpenCurrentState()
|
|
329 |
{
|
|
330 |
// no collection utility
|
|
331 |
QVERIFY(mTestObject->startOpenCurrentState() == -1);
|
|
332 |
mTestObject->setOpenStatus(VideoCollectionClient::ECollectionNotOpen);
|
|
333 |
QVERIFY(mTestObject->startOpenCurrentState() == -1);
|
|
334 |
|
|
335 |
// collection not opened
|
|
336 |
QVERIFY(mTestObject->initialize() == 0);
|
|
337 |
QVERIFY(mTestObject->startOpenCurrentState() == -1);
|
|
338 |
|
|
339 |
// OpenL -leaves
|
|
340 |
mTestObject->setOpenStatus(VideoCollectionClient::ECollectionOpened);
|
|
341 |
MMPXCollection::setOpenLLeave(true);
|
|
342 |
QVERIFY(mTestObject->startOpenCurrentState() < 0);
|
|
343 |
|
|
344 |
// succeed
|
|
345 |
MMPXCollection::setOpenLLeave(false);
|
|
346 |
QVERIFY(mTestObject->startOpenCurrentState() == 0);
|
|
347 |
|
|
348 |
}
|
|
349 |
|
|
350 |
// -----------------------------------------------------------------------------
|
|
351 |
// testDeleteVideos
|
|
352 |
// -----------------------------------------------------------------------------
|
|
353 |
//
|
|
354 |
void TestVideoCollectionClient::testDeleteVideos()
|
|
355 |
{
|
|
356 |
// no collection utility
|
|
357 |
QVERIFY(mTestObject->deleteVideos(0) == -1);
|
|
358 |
QList<TMPXItemId> ids;
|
|
359 |
QVERIFY(mTestObject->deleteVideos(&ids) == -1);
|
|
360 |
|
|
361 |
QVERIFY(mTestObject->initialize() == 0);
|
|
362 |
// empty list
|
|
363 |
QVERIFY(mTestObject->deleteVideos(&ids) < 0);
|
|
364 |
|
|
365 |
// one item
|
|
366 |
ids.append(TMPXItemId(1,0));
|
|
367 |
MMPXCollection::setCommandLLeave(true);
|
|
368 |
QVERIFY(mTestObject->deleteVideos(&ids) < 0);
|
|
369 |
MMPXCollection::setCommandLLeave(false);
|
|
370 |
QVERIFY(mTestObject->deleteVideos(&ids) == 0);
|
|
371 |
|
|
372 |
// more than one
|
|
373 |
ids.append(TMPXItemId(2,0));
|
|
374 |
ids.append(TMPXItemId(3,0));
|
|
375 |
MMPXCollection::setCommandLLeave(true);
|
|
376 |
QVERIFY(mTestObject->deleteVideos(&ids) < 0);
|
|
377 |
MMPXCollection::setCommandLLeave(false);
|
|
378 |
QVERIFY(mTestObject->deleteVideos(&ids) == 0);
|
|
379 |
|
|
380 |
}
|
|
381 |
|
|
382 |
// -----------------------------------------------------------------------------
|
|
383 |
// testOpenCategory
|
|
384 |
// -----------------------------------------------------------------------------
|
|
385 |
//
|
|
386 |
void TestVideoCollectionClient::testOpenCategory()
|
|
387 |
{
|
|
388 |
TMPXItemId id(0,0);
|
|
389 |
// no collection utility
|
|
390 |
QVERIFY(mTestObject->openVideo(id) == -1);
|
|
391 |
|
|
392 |
// collection exists
|
|
393 |
QVERIFY(mTestObject->initialize() == 0);
|
|
394 |
|
|
395 |
MMPXCollection::setOpenLPathLeave(true);
|
|
396 |
QVERIFY(mTestObject->openVideo(id)< 0);
|
|
397 |
|
|
398 |
MMPXCollection::setOpenLPathLeave(false);
|
|
399 |
|
|
400 |
|
|
401 |
mTestObject->mCollectionPathLevel = VideoCollectionClient::ELevelCategory;
|
|
402 |
QVERIFY(mTestObject->openVideo(id) == 0);
|
|
403 |
|
|
404 |
}
|
|
405 |
|
|
406 |
// -----------------------------------------------------------------------------
|
|
407 |
// testOpenVideo
|
|
408 |
// -----------------------------------------------------------------------------
|
|
409 |
//
|
|
410 |
void TestVideoCollectionClient::testOpenVideo()
|
|
411 |
{
|
|
412 |
TMPXItemId id(0,0);
|
|
413 |
// no collection utility
|
|
414 |
QVERIFY(mTestObject->openVideo(id) == -1);
|
|
415 |
|
|
416 |
// collection exists
|
|
417 |
QVERIFY(mTestObject->initialize() == 0);
|
|
418 |
mTestObject->mCollectionPathLevel = VideoCollectionClient::ELevelVideos;
|
|
419 |
MMPXCollection::setOpenLPathLeave(true);
|
|
420 |
QVERIFY(mTestObject->openVideo(id)< 0);
|
|
421 |
MMPXCollection::setOpenLPathLeave(false);
|
|
422 |
|
|
423 |
QVERIFY(mTestObject->openVideo(id) == 0);
|
|
424 |
}
|
|
425 |
|
|
426 |
// -----------------------------------------------------------------------------
|
|
427 |
// testFetchMpxMediaByMpxId
|
|
428 |
// -----------------------------------------------------------------------------
|
|
429 |
//
|
|
430 |
void TestVideoCollectionClient::testFetchMpxMediaByMpxId()
|
|
431 |
{
|
|
432 |
// no collection utility
|
|
433 |
TMPXItemId id;
|
|
434 |
QVERIFY(mTestObject->fetchMpxMediaByMpxId(id) == -1);
|
|
435 |
|
|
436 |
// collection exists
|
|
437 |
QVERIFY(mTestObject->initialize() == 0);
|
|
438 |
|
|
439 |
MMPXCollection::setCommandLLeave(true);
|
|
440 |
QVERIFY(mTestObject->fetchMpxMediaByMpxId(id) < 0);
|
|
441 |
|
|
442 |
MMPXCollection::setCommandLLeave(false);
|
|
443 |
QVERIFY(mTestObject->fetchMpxMediaByMpxId(id) == 0);
|
|
444 |
|
|
445 |
}
|
|
446 |
|
|
447 |
// -----------------------------------------------------------------------------
|
|
448 |
// testGetVideoDetails
|
|
449 |
// -----------------------------------------------------------------------------
|
|
450 |
//
|
|
451 |
void TestVideoCollectionClient::testGetVideoDetails()
|
|
452 |
{
|
|
453 |
// no collection utility
|
|
454 |
TMPXItemId id(0,0);
|
|
455 |
QVERIFY(mTestObject->getVideoDetails(id) == -1);
|
|
456 |
|
|
457 |
// collection exists
|
|
458 |
QVERIFY(mTestObject->initialize() == 0);
|
|
459 |
|
|
460 |
MMPXCollection::setCommandLLeave(true);
|
|
461 |
QVERIFY(mTestObject->getVideoDetails(id) < 0);
|
|
462 |
|
|
463 |
MMPXCollection::setCommandLLeave(false);
|
|
464 |
QVERIFY(mTestObject->getVideoDetails(id) == 0);
|
|
465 |
|
|
466 |
}
|
|
467 |
|
|
468 |
// -----------------------------------------------------------------------------
|
|
469 |
// testAddNewCollection_data
|
|
470 |
// -----------------------------------------------------------------------------
|
|
471 |
//
|
|
472 |
void TestVideoCollectionClient::testAddNewCollection_data()
|
|
473 |
{
|
|
474 |
QTest::addColumn<QString>("name");
|
|
475 |
QTest::addColumn<QString>("thumb");
|
|
476 |
QTest::addColumn<QList<TMPXItemId> >("ids");
|
|
477 |
|
|
478 |
|
|
479 |
|
|
480 |
QList<TMPXItemId> testIds;
|
|
481 |
testIds.append(TMPXItemId(5,0));
|
|
482 |
testIds.append(TMPXItemId(9,0));
|
|
483 |
|
|
484 |
QTest::newRow("All params empty")
|
|
485 |
<< QString()
|
|
486 |
<< QString()
|
|
487 |
<< QList<TMPXItemId>();
|
|
488 |
|
|
489 |
QTest::newRow("Only name")
|
|
490 |
<< QString("testname")
|
|
491 |
<< QString()
|
|
492 |
<< QList<TMPXItemId>();
|
|
493 |
|
|
494 |
QTest::newRow("Only thumb")
|
|
495 |
<< QString()
|
|
496 |
<< QString("testthumb")
|
|
497 |
<< QList<TMPXItemId>();
|
|
498 |
|
|
499 |
QTest::newRow("Name and thumb")
|
|
500 |
<< QString("testname")
|
|
501 |
<< QString("testthumb")
|
|
502 |
<< QList<TMPXItemId>();
|
|
503 |
|
|
504 |
QTest::newRow("Only ids")
|
|
505 |
<< QString()
|
|
506 |
<< QString()
|
|
507 |
<< testIds;
|
|
508 |
|
|
509 |
QTest::newRow("Name and ids")
|
|
510 |
<< QString("testname")
|
|
511 |
<< QString()
|
|
512 |
<< testIds;
|
|
513 |
|
|
514 |
QTest::newRow("Thumb and ids")
|
|
515 |
<< QString()
|
|
516 |
<< QString("testthumb")
|
|
517 |
<< testIds;
|
|
518 |
|
|
519 |
QTest::newRow("All params")
|
|
520 |
<< QString("testname")
|
|
521 |
<< QString("testthumb")
|
|
522 |
<< testIds;
|
|
523 |
|
|
524 |
}
|
|
525 |
|
|
526 |
// -----------------------------------------------------------------------------
|
|
527 |
// testAddNewCollection
|
|
528 |
// -----------------------------------------------------------------------------
|
|
529 |
//
|
|
530 |
void TestVideoCollectionClient::testAddNewCollection()
|
|
531 |
{
|
|
532 |
|
|
533 |
QFETCH(QString, name);
|
|
534 |
QFETCH(QString, thumb);
|
|
535 |
QFETCH(QList<TMPXItemId>, ids);
|
|
536 |
|
|
537 |
QCOMPARE(mTestObject->addNewCollection(name, thumb, ids), -1);
|
|
538 |
|
|
539 |
mTestObject->initialize();
|
|
540 |
|
|
541 |
QCOMPARE(mTestObject->addNewCollection(name, thumb, ids), 0);
|
|
542 |
|
|
543 |
// TODO needs proper verification after the method has been fully implemented.
|
|
544 |
}
|
|
545 |
|
|
546 |
// -----------------------------------------------------------------------------
|
|
547 |
// testBack
|
|
548 |
// -----------------------------------------------------------------------------
|
|
549 |
//
|
|
550 |
void TestVideoCollectionClient::testBack()
|
|
551 |
{
|
|
552 |
|
|
553 |
CMPXCollectionPath::setLevel(3);
|
|
554 |
// not initialized
|
|
555 |
QVERIFY(mTestObject->back() == -1);
|
|
556 |
|
|
557 |
QVERIFY(mTestObject->initialize() == 0);
|
|
558 |
mTestObject->mCollectionPathLevel = VideoCollectionClient::ELevelVideos;
|
|
559 |
MMPXCollection::setBackLLeave(true);
|
|
560 |
QVERIFY(mTestObject->back()< 0);
|
|
561 |
MMPXCollection::setBackLLeave(false);
|
|
562 |
QVERIFY(mTestObject->back() == 0);
|
|
563 |
|
|
564 |
mTestObject->mCollectionPathLevel = VideoCollectionClient::ELevelCategory;
|
|
565 |
QVERIFY(mTestObject->back() == 0);
|
|
566 |
}
|
|
567 |
|
|
568 |
// End of file
|
|
569 |
|