30
|
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 VideoListWidget
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
34
|
18 |
#include <qmap.h>
|
|
19 |
#include <vcxmyvideosdefs.h>
|
|
20 |
#include <mpxhbvideocommondefs.h>
|
|
21 |
|
|
22 |
#include "hbglobal.h"
|
30
|
23 |
#include "hblistview.h"
|
|
24 |
#include "hbview.h"
|
|
25 |
#include "videoservices.h"
|
|
26 |
#include "videosortfilterproxymodel.h"
|
|
27 |
#include "hbscrollbar.h"
|
|
28 |
#include "hbmenu.h"
|
|
29 |
#include "hbmessagebox.h"
|
|
30 |
#include "hbinstance.h"
|
|
31 |
#include "hbmainwindow.h"
|
35
|
32 |
#include "hbstyleloader.h"
|
30
|
33 |
#include "videothumbnaildata.h"
|
|
34 |
#include "videocollectioncommon.h"
|
34
|
35 |
#include "videocollectionwrapper.h"
|
|
36 |
#include "videocollectionwrapperdata.h"
|
|
37 |
#include "hbmenudata.h"
|
|
38 |
#include "videothumbnailtestdata.h"
|
|
39 |
#include "videolistdatamodel.h"
|
|
40 |
#include "videolistdatamodeldata.h"
|
|
41 |
#include "videosortfilterproxymodeldata.h"
|
35
|
42 |
#include "videoservices.h"
|
|
43 |
#include "videocollectionuiloader.h"
|
|
44 |
#include "videocollectionuiloaderdata.h"
|
|
45 |
#include "videolistselectiondialog.h"
|
|
46 |
#include "videolistselectiondialogdata.h"
|
34
|
47 |
#include "hbmessageboxdata.h"
|
30
|
48 |
|
|
49 |
#include "testlistwidget.h"
|
|
50 |
|
|
51 |
#define private public
|
|
52 |
#include "videolistwidget.h"
|
|
53 |
#undef private
|
|
54 |
|
|
55 |
static const int CONTEXT_MENU_COUNT = 8;
|
|
56 |
|
|
57 |
/**
|
|
58 |
* helper class to run protected member of the test object
|
|
59 |
*/
|
|
60 |
class ListWidgetTester : public VideoListWidget
|
|
61 |
{
|
|
62 |
public:
|
|
63 |
/**
|
|
64 |
* constructor
|
|
65 |
*/
|
34
|
66 |
ListWidgetTester(VideoCollectionUiLoader* uiLoader, HbView *parent) :
|
|
67 |
VideoListWidget(uiLoader, parent)
|
30
|
68 |
{
|
|
69 |
|
|
70 |
}
|
|
71 |
|
|
72 |
/**
|
|
73 |
* calls emitActivated
|
|
74 |
*/
|
|
75 |
void callEmiteActivated(QModelIndex index)
|
|
76 |
{
|
|
77 |
VideoListWidget::emitActivated(index);
|
|
78 |
}
|
|
79 |
|
|
80 |
/**
|
|
81 |
* calls longPressGesture
|
|
82 |
*/
|
|
83 |
void callLongPressGesture(const QPointF &point)
|
|
84 |
{
|
|
85 |
VideoListWidget::longPressGesture (point);
|
|
86 |
}
|
|
87 |
};
|
|
88 |
|
|
89 |
// ---------------------------------------------------------------------------
|
|
90 |
// main
|
|
91 |
// ---------------------------------------------------------------------------
|
|
92 |
//
|
34
|
93 |
int main(int argc, char *argv[])
|
30
|
94 |
{
|
|
95 |
TestListWidget tv;
|
35
|
96 |
QApplication app(argc, argv);
|
34
|
97 |
int res;
|
|
98 |
if(argc > 1)
|
|
99 |
{
|
|
100 |
res = QTest::qExec(&tv, argc, argv);
|
|
101 |
}
|
|
102 |
else
|
|
103 |
{
|
|
104 |
char *pass[3];
|
|
105 |
pass[0] = argv[0];
|
|
106 |
pass[1] = "-o";
|
|
107 |
pass[2] = "c:\\data\\testlistwidget.txt";
|
|
108 |
res = QTest::qExec(&tv, 3, pass);
|
|
109 |
}
|
|
110 |
|
|
111 |
return res;
|
|
112 |
}
|
30
|
113 |
|
34
|
114 |
// ---------------------------------------------------------------------------
|
|
115 |
//
|
|
116 |
// ---------------------------------------------------------------------------
|
|
117 |
//
|
|
118 |
void TestListWidget::setRowCount(int count, int type, VideoListDataModel *model)
|
|
119 |
{
|
|
120 |
if (!model)
|
|
121 |
{
|
|
122 |
VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance();
|
|
123 |
VideoSortFilterProxyModel *model = wrapper.getModel(type);
|
|
124 |
QVERIFY(model);
|
|
125 |
|
|
126 |
VideoListDataModel *sourceModel = qobject_cast<VideoListDataModel*>(model->sourceModel());
|
|
127 |
QVERIFY(sourceModel);
|
|
128 |
|
|
129 |
VideoListDataModelData::setRowCount(*sourceModel, count);
|
|
130 |
sourceModel->initialize();
|
|
131 |
}
|
|
132 |
else
|
|
133 |
{
|
|
134 |
VideoListDataModelData::setRowCount(*model, count);
|
|
135 |
model->initialize();
|
|
136 |
}
|
30
|
137 |
}
|
|
138 |
|
|
139 |
// ---------------------------------------------------------------------------
|
35
|
140 |
// initTestCase
|
|
141 |
// ---------------------------------------------------------------------------
|
|
142 |
//
|
|
143 |
void TestListWidget::initTestCase()
|
|
144 |
{
|
|
145 |
qRegisterMetaType<QModelIndex>("QModelIndex");
|
|
146 |
}
|
|
147 |
|
|
148 |
// ---------------------------------------------------------------------------
|
30
|
149 |
// init
|
|
150 |
// ---------------------------------------------------------------------------
|
|
151 |
//
|
|
152 |
void TestListWidget::init()
|
|
153 |
{
|
|
154 |
mDummyMainWnd = new HbMainWindow;
|
|
155 |
mTempView = new HbView;
|
35
|
156 |
mTestUiLoader = new VideoCollectionUiLoader();
|
|
157 |
hbInstance->mWindowses.append(mDummyMainWnd);
|
|
158 |
mTestWidget = new ListWidgetTester(mTestUiLoader, mTempView);
|
30
|
159 |
}
|
|
160 |
|
|
161 |
// ---------------------------------------------------------------------------
|
|
162 |
// cleanup
|
|
163 |
// ---------------------------------------------------------------------------
|
|
164 |
//
|
|
165 |
void TestListWidget::cleanup()
|
|
166 |
{
|
|
167 |
delete mTestWidget;
|
|
168 |
mTestWidget = 0;
|
|
169 |
|
|
170 |
delete mTempView;
|
|
171 |
mTempView = 0;
|
|
172 |
|
|
173 |
delete mDummyMainWnd;
|
|
174 |
mDummyMainWnd = 0;
|
|
175 |
|
|
176 |
hbInstance->mWindowses.clear();
|
34
|
177 |
|
|
178 |
VideoCollectionWrapperData::reset();
|
|
179 |
HbMenuData::reset();
|
|
180 |
VideoThumbnailTestData::reset();
|
|
181 |
VideoListDataModelData::reset();
|
|
182 |
VideoSortFilterProxyModelData::reset();
|
|
183 |
HbMessageBoxData::reset();
|
30
|
184 |
}
|
|
185 |
|
|
186 |
// ---------------------------------------------------------------------------
|
|
187 |
// testInitialize
|
|
188 |
// ---------------------------------------------------------------------------
|
|
189 |
//
|
|
190 |
void TestListWidget::testInitialize()
|
|
191 |
{
|
34
|
192 |
VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance();
|
|
193 |
VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionWrapper::EAllVideos);
|
30
|
194 |
|
|
195 |
// succeed case ( new operator cannot be stubbed)
|
34
|
196 |
QVERIFY(mTestWidget->initialize(*model) == 0);
|
|
197 |
QVERIFY(mTestWidget->mModel == model);
|
30
|
198 |
QVERIFY(mTestWidget->mVideoServices == 0);
|
|
199 |
QVERIFY(mTestWidget->mIsService == false);
|
35
|
200 |
|
|
201 |
// service initialization
|
|
202 |
VideoServices *service = VideoServices::instance();
|
|
203 |
QVERIFY(mTestWidget->initialize(*model, service) == 0);
|
|
204 |
QVERIFY(mTestWidget->mModel == model);
|
|
205 |
QVERIFY(mTestWidget->mVideoServices == service);
|
|
206 |
QVERIFY(mTestWidget->mIsService == true);
|
|
207 |
service->decreaseReferenceCount();
|
|
208 |
service = 0;
|
|
209 |
|
30
|
210 |
}
|
|
211 |
|
|
212 |
// ---------------------------------------------------------------------------
|
|
213 |
// testActivate
|
|
214 |
// ---------------------------------------------------------------------------
|
|
215 |
//
|
|
216 |
void TestListWidget::testActivate()
|
|
217 |
{
|
34
|
218 |
VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance();
|
|
219 |
VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionWrapper::EAllVideos);
|
|
220 |
|
30
|
221 |
// no model: fails
|
|
222 |
QVERIFY(mTestWidget->activate() == -1);
|
34
|
223 |
QCOMPARE(HbMenuData::mEnabledSetted, false);
|
30
|
224 |
QCOMPARE(HbListView::mLatestVisibility, false);
|
35
|
225 |
QCOMPARE(VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled, 0);
|
30
|
226 |
|
35
|
227 |
// model exist, no current view default level: succeeds
|
34
|
228 |
QVERIFY(mTestWidget->initialize(*model) == 0);
|
30
|
229 |
QVERIFY(mTestWidget->activate() == 0);
|
34
|
230 |
QCOMPARE(HbMenuData::mEnabledSetted, false);
|
30
|
231 |
QCOMPARE(HbListView::mLatestVisibility, true);
|
34
|
232 |
QCOMPARE(VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled, 1);
|
30
|
233 |
|
34
|
234 |
HbMenuData::mEnabledSetted = true;
|
30
|
235 |
HbListView::mLatestVisibility = false;
|
|
236 |
HbListView::mLatestEnableValue = false;
|
34
|
237 |
VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled = 0;
|
30
|
238 |
|
35
|
239 |
// model exists, current view exists, level neither ELevelAlbum nor ELevelDefaultColl,
|
|
240 |
// no mNavKeyQuitAction
|
|
241 |
HbView *tmpView = new HbView();
|
|
242 |
hbInstance->allMainWindows().value(0)->addView(tmpView);
|
|
243 |
HbAction *tmpAction = mTestWidget->mNavKeyQuitAction;
|
|
244 |
mTestWidget->mNavKeyQuitAction = 0;
|
|
245 |
QVERIFY(mTestWidget->activate() == 0);
|
|
246 |
QCOMPARE(HbMenuData::mEnabledSetted, true);
|
|
247 |
QCOMPARE(HbListView::mLatestVisibility, true);
|
|
248 |
QCOMPARE(VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled, 1);
|
|
249 |
QVERIFY(!tmpView->mNavigationAction);
|
|
250 |
|
|
251 |
HbMenuData::mEnabledSetted = true;
|
|
252 |
HbListView::mLatestVisibility = false;
|
|
253 |
HbListView::mLatestEnableValue = false;
|
|
254 |
VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled = 0;
|
|
255 |
mTestWidget->mNavKeyQuitAction = tmpAction;
|
|
256 |
|
|
257 |
// model exists, current view exists, level neither ELevelAlbum nor ELevelDefaultColl,
|
|
258 |
// mNavKeyQuitAction exists
|
30
|
259 |
QVERIFY(mTestWidget->activate() == 0);
|
34
|
260 |
QCOMPARE(HbMenuData::mEnabledSetted, true);
|
30
|
261 |
QCOMPARE(HbListView::mLatestVisibility, true);
|
35
|
262 |
QCOMPARE(VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled, 1);
|
|
263 |
QVERIFY(tmpView->mNavigationAction == tmpAction);
|
|
264 |
|
|
265 |
HbMenuData::mEnabledSetted = true;
|
|
266 |
HbListView::mLatestVisibility = false;
|
|
267 |
HbListView::mLatestEnableValue = false;
|
|
268 |
VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled = 0;
|
|
269 |
|
|
270 |
// model exists, current view exists, level is ELevelAlbum
|
|
271 |
// no mNavKeyBackAction
|
|
272 |
tmpView->mNavigationAction = 0;
|
|
273 |
tmpAction = mTestWidget->mNavKeyBackAction;
|
|
274 |
mTestWidget->mNavKeyBackAction = 0;
|
|
275 |
QVERIFY(mTestWidget->activate(VideoCollectionCommon::ELevelAlbum) == 0);
|
|
276 |
QCOMPARE(HbMenuData::mEnabledSetted, true);
|
|
277 |
QCOMPARE(HbListView::mLatestVisibility, true);
|
34
|
278 |
QCOMPARE(VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled, 1);
|
35
|
279 |
QVERIFY(!tmpView->mNavigationAction);
|
|
280 |
|
|
281 |
HbMenuData::mEnabledSetted = true;
|
|
282 |
HbListView::mLatestVisibility = false;
|
|
283 |
HbListView::mLatestEnableValue = false;
|
|
284 |
VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled = 0;
|
|
285 |
|
|
286 |
mTestWidget->mNavKeyBackAction = tmpAction;
|
|
287 |
// model exists, current view exists, level neither ELevelAlbum nor ELevelDefaultColl,
|
|
288 |
// mNavKeyBackAction exists
|
|
289 |
QVERIFY(mTestWidget->activate(VideoCollectionCommon::ELevelAlbum) == 0);
|
|
290 |
QCOMPARE(HbMenuData::mEnabledSetted, true);
|
|
291 |
QCOMPARE(HbListView::mLatestVisibility, true);
|
|
292 |
QCOMPARE(VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled, 1);
|
|
293 |
QVERIFY(tmpView->mNavigationAction == tmpAction);
|
|
294 |
|
|
295 |
HbMenuData::mEnabledSetted = true;
|
|
296 |
HbListView::mLatestVisibility = false;
|
|
297 |
HbListView::mLatestEnableValue = false;
|
|
298 |
VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled = 0;
|
|
299 |
|
|
300 |
hbInstance->allMainWindows().value(0)->removeView(tmpView);
|
|
301 |
delete tmpView;
|
30
|
302 |
}
|
|
303 |
|
|
304 |
// ---------------------------------------------------------------------------
|
|
305 |
// testDeactivate
|
|
306 |
// ---------------------------------------------------------------------------
|
|
307 |
//
|
|
308 |
void TestListWidget::testDeactivate()
|
|
309 |
{
|
34
|
310 |
VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance();
|
|
311 |
VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionWrapper::EAllVideos);
|
|
312 |
|
35
|
313 |
HbListView::mLatestVisibility = true;
|
|
314 |
VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled = 1;
|
30
|
315 |
|
|
316 |
mTestWidget->activate();
|
|
317 |
|
|
318 |
// no context menu and activated without model
|
|
319 |
mTestWidget->deactivate();
|
|
320 |
QCOMPARE(HbListView::mLatestVisibility, false);
|
34
|
321 |
QCOMPARE(VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled, 0);
|
30
|
322 |
|
35
|
323 |
HbListView::mLatestVisibility = true;
|
|
324 |
VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled = 1;
|
|
325 |
|
30
|
326 |
// context menu exists and activated with model
|
|
327 |
mTestWidget->mContextMenu = new HbMenu;
|
34
|
328 |
QVERIFY(mTestWidget->initialize(*model) == 0);
|
30
|
329 |
mTestWidget->activate();
|
|
330 |
mTestWidget->deactivate();
|
35
|
331 |
QCOMPARE(HbListView::mLatestVisibility, false);
|
34
|
332 |
QCOMPARE(VideoThumbnailTestData::mBackgroundThumbnailFetchingEnabled, 0);
|
30
|
333 |
|
|
334 |
}
|
|
335 |
|
|
336 |
// ---------------------------------------------------------------------------
|
|
337 |
// testGetLevel
|
|
338 |
// ---------------------------------------------------------------------------
|
|
339 |
//
|
34
|
340 |
void TestListWidget::testGetLevel()
|
30
|
341 |
{
|
34
|
342 |
VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance();
|
|
343 |
VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionWrapper::EAllVideos);
|
|
344 |
|
|
345 |
mTestWidget->initialize(*model);
|
30
|
346 |
|
34
|
347 |
mTestWidget->mCurrentLevel = VideoCollectionCommon::ELevelVideos;
|
|
348 |
QCOMPARE(mTestWidget->getLevel(), VideoCollectionCommon::ELevelVideos);
|
30
|
349 |
}
|
|
350 |
|
|
351 |
// ---------------------------------------------------------------------------
|
|
352 |
// testGetModel
|
|
353 |
// ---------------------------------------------------------------------------
|
|
354 |
//
|
|
355 |
void TestListWidget::testGetModel()
|
|
356 |
{
|
34
|
357 |
VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance();
|
|
358 |
VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionWrapper::EAllVideos);
|
|
359 |
|
30
|
360 |
QVERIFY(&(mTestWidget->getModel()) == 0);
|
|
361 |
|
|
362 |
HbListView::mVScrollBarIsNull = false;
|
|
363 |
HbListView::mReturnNullPrototype = false;
|
34
|
364 |
mTestWidget->initialize(*model);
|
30
|
365 |
|
34
|
366 |
QVERIFY(&(mTestWidget->getModel()) == model);
|
30
|
367 |
}
|
|
368 |
|
|
369 |
// ---------------------------------------------------------------------------
|
|
370 |
// testEmitActivated
|
|
371 |
// ---------------------------------------------------------------------------
|
|
372 |
//
|
|
373 |
void TestListWidget::testEmitActivated()
|
|
374 |
{
|
34
|
375 |
VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance();
|
|
376 |
VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionWrapper::EAllVideos);
|
|
377 |
|
35
|
378 |
QSignalSpy spysignal(mTestWidget, SIGNAL(collectionOpened(bool, const QString&, const QModelIndex&)));
|
|
379 |
QSignalSpy spysignalFileUri(mTestWidget, SIGNAL(fileUri(const QString&)));
|
|
380 |
QSignalSpy spysignalActivated(mTestWidget, SIGNAL(activated(const QModelIndex&)));
|
|
381 |
|
34
|
382 |
mTestWidget->initialize(*model);
|
35
|
383 |
mTestWidget->activate();
|
30
|
384 |
|
35
|
385 |
VideoSortFilterProxyModelData::mLastItemId = TMPXItemId::InvalidId();
|
|
386 |
TMPXItemId savedId = TMPXItemId(1,1);
|
|
387 |
VideoSortFilterProxyModelData::mItemIds.clear();
|
|
388 |
VideoSortFilterProxyModelData::mItemIds.append(savedId);
|
30
|
389 |
QVariant data = QString("test");
|
34
|
390 |
VideoListDataModelData::setData( Qt::DisplayRole, data);
|
35
|
391 |
setRowCount(2);
|
34
|
392 |
VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId(0,0));
|
30
|
393 |
|
34
|
394 |
QModelIndex fetchIndex = model->index(0, 0, QModelIndex());
|
30
|
395 |
|
|
396 |
// selection mode == HbAbstractItemView::MultiSelection
|
35
|
397 |
mTestWidget->setSelectionMode(HbAbstractItemView::MultiSelection);
|
30
|
398 |
mTestWidget->callEmiteActivated(fetchIndex);
|
|
399 |
QVERIFY(spysignal.count() == 0);
|
35
|
400 |
QVERIFY(spysignalFileUri.count() == 0);
|
|
401 |
QVERIFY(spysignalActivated.count() == 1);
|
|
402 |
QVERIFY(VideoSortFilterProxyModelData::mLastItemId == TMPXItemId::InvalidId());
|
|
403 |
spysignal.clear();
|
|
404 |
spysignalFileUri.clear();
|
|
405 |
spysignalActivated.clear();
|
30
|
406 |
|
|
407 |
// modelIndex is not valid
|
35
|
408 |
mTestWidget->setSelectionMode(HbAbstractItemView::NoSelection);
|
30
|
409 |
fetchIndex = QModelIndex();
|
|
410 |
mTestWidget->callEmiteActivated(fetchIndex);
|
|
411 |
QVERIFY(spysignal.count() == 0);
|
35
|
412 |
QVERIFY(spysignalFileUri.count() == 0);
|
|
413 |
QVERIFY(spysignalActivated.count() == 0);
|
|
414 |
QVERIFY(VideoSortFilterProxyModelData::mLastItemId == TMPXItemId::InvalidId());
|
|
415 |
|
|
416 |
// current level is ELevelCategory
|
|
417 |
mTestWidget->mCurrentLevel = VideoCollectionCommon::ELevelCategory;
|
|
418 |
// --> variant is not valid
|
|
419 |
VideoListDataModelData::setData( Qt::DisplayRole, QVariant());
|
34
|
420 |
fetchIndex = model->index(0, 0, QModelIndex());
|
30
|
421 |
mTestWidget->callEmiteActivated(fetchIndex);
|
|
422 |
QVERIFY(spysignal.count() == 0);
|
35
|
423 |
QVERIFY(spysignalFileUri.count() == 0);
|
|
424 |
QVERIFY(spysignalActivated.count() == 0);
|
|
425 |
QVERIFY(VideoSortFilterProxyModelData::mLastItemId == TMPXItemId::InvalidId());
|
30
|
426 |
|
34
|
427 |
|
35
|
428 |
// --> variant is valid, collectionOpened -signal should be emitted
|
|
429 |
VideoListDataModelData::setData( Qt::DisplayRole, data);
|
|
430 |
fetchIndex = model->index(1, 0, QModelIndex());
|
|
431 |
mTestWidget->callEmiteActivated(fetchIndex);
|
|
432 |
QVERIFY(spysignal.count() == 1);
|
|
433 |
QVERIFY(spysignalFileUri.count() == 0);
|
|
434 |
QVERIFY(spysignalActivated.count() == 0);
|
|
435 |
QVERIFY(VideoSortFilterProxyModelData::mLastItemId == TMPXItemId::InvalidId());
|
|
436 |
|
|
437 |
spysignal.clear();
|
|
438 |
spysignalFileUri.clear();
|
|
439 |
spysignalActivated.clear();
|
|
440 |
|
|
441 |
// current level is not ELevelCategory
|
|
442 |
// mIsService is true, variant gotten is invalid
|
|
443 |
VideoListDataModelData::setData( Qt::DisplayRole, QVariant());
|
|
444 |
mTestWidget->mCurrentLevel = VideoCollectionCommon::ELevelVideos;
|
|
445 |
mTestWidget->mIsService = true;
|
|
446 |
fetchIndex = model->index(0, 0, QModelIndex());
|
30
|
447 |
mTestWidget->callEmiteActivated(fetchIndex);
|
|
448 |
QVERIFY(spysignal.count() == 0);
|
35
|
449 |
QVERIFY(spysignalFileUri.count() == 0);
|
|
450 |
QVERIFY(spysignalActivated.count() == 0);
|
|
451 |
QVERIFY(VideoSortFilterProxyModelData::mLastItemId == TMPXItemId::InvalidId());
|
30
|
452 |
|
35
|
453 |
// current level is not ELevelCategory
|
|
454 |
// mIsService is true, variant gotten is valid
|
|
455 |
VideoListDataModelData::setData( VideoCollectionCommon::KeyFilePath, data);
|
|
456 |
fetchIndex = model->index(0, 0, QModelIndex());
|
30
|
457 |
mTestWidget->callEmiteActivated(fetchIndex);
|
|
458 |
QVERIFY(spysignal.count() == 0);
|
35
|
459 |
QVERIFY(spysignalFileUri.count() == 1);
|
|
460 |
QVERIFY(spysignalActivated.count() == 0);
|
|
461 |
QVERIFY(VideoSortFilterProxyModelData::mLastItemId == TMPXItemId::InvalidId());
|
|
462 |
|
|
463 |
spysignal.clear();
|
|
464 |
spysignalFileUri.clear();
|
|
465 |
spysignalActivated.clear();
|
|
466 |
|
|
467 |
// current level is not ELevelCategory
|
|
468 |
// mIsService is false
|
|
469 |
mTestWidget->mIsService = false;
|
34
|
470 |
fetchIndex = model->index(0, 0, QModelIndex());
|
30
|
471 |
mTestWidget->callEmiteActivated(fetchIndex);
|
35
|
472 |
QVERIFY(spysignal.count() == 0);
|
|
473 |
QVERIFY(spysignalFileUri.count() == 0);
|
|
474 |
QVERIFY(spysignalActivated.count() == 0);
|
|
475 |
QVERIFY(VideoSortFilterProxyModelData::mLastItemId == savedId);
|
|
476 |
|
|
477 |
// context menu is visible
|
|
478 |
if (!mTestWidget->mContextMenu)
|
|
479 |
{
|
|
480 |
mTestWidget->mContextMenu = new HbMenu;
|
|
481 |
}
|
|
482 |
mTestWidget->mContextMenu->show();
|
|
483 |
VideoSortFilterProxyModelData::mLastItemId = TMPXItemId::InvalidId();
|
|
484 |
fetchIndex = model->index(0, 0, QModelIndex());
|
|
485 |
mTestWidget->callEmiteActivated(fetchIndex);
|
|
486 |
QVERIFY(spysignal.count() == 0);
|
|
487 |
QVERIFY(spysignalFileUri.count() == 0);
|
|
488 |
QVERIFY(spysignalActivated.count() == 0);
|
|
489 |
QVERIFY(VideoSortFilterProxyModelData::mLastItemId == TMPXItemId::InvalidId());
|
30
|
490 |
}
|
|
491 |
|
|
492 |
|
|
493 |
// ---------------------------------------------------------------------------
|
|
494 |
// testLongPressGesture
|
|
495 |
// ---------------------------------------------------------------------------
|
|
496 |
//
|
|
497 |
void TestListWidget::testLongPressGesture()
|
|
498 |
{
|
34
|
499 |
VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance();
|
|
500 |
VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionWrapper::EAllVideos);
|
|
501 |
|
30
|
502 |
QVariant data = QString("test");
|
|
503 |
// correct data to index 0
|
34
|
504 |
VideoListDataModelData::setData( Qt::DisplayRole, data);
|
35
|
505 |
setRowCount(2);
|
30
|
506 |
|
|
507 |
QPointF point(1,1);
|
34
|
508 |
mTestWidget->initialize(*model);
|
30
|
509 |
|
35
|
510 |
mTestWidget->setSelectionMode(HbAbstractItemView::MultiSelection);
|
30
|
511 |
// mDetailsReady is false
|
|
512 |
mTestWidget->callLongPressGesture(point);
|
34
|
513 |
QVERIFY(HbMenuData::mExecPoint != point);
|
30
|
514 |
QVERIFY(HbListView::mLongPressedPoint != point);
|
|
515 |
|
|
516 |
// multiselection is on
|
|
517 |
mTestWidget->callLongPressGesture(point);
|
35
|
518 |
QVERIFY(HbMenuData::mExecPoint != point);
|
|
519 |
|
|
520 |
// selection mode is custom
|
|
521 |
mTestWidget->setSelectionMode(-1);
|
|
522 |
|
|
523 |
mTestWidget->callLongPressGesture(point);
|
34
|
524 |
QVERIFY(HbMenuData::mExecPoint != point);
|
30
|
525 |
|
35
|
526 |
// item at position is null
|
|
527 |
HbListViewItem *pTmp = mTestWidget->mItem;
|
|
528 |
mTestWidget->mItem = 0;
|
|
529 |
mTestWidget->setSelectionMode(HbAbstractItemView::NoSelection);
|
30
|
530 |
HbListView::mCurrentIndex = QModelIndex();
|
|
531 |
mTestWidget->callLongPressGesture(point);
|
34
|
532 |
QVERIFY(HbMenuData::mExecPoint != point);
|
30
|
533 |
QVERIFY(HbListView::mLongPressedPoint == point);
|
|
534 |
|
35
|
535 |
// item at position is not null, but returns invalid index
|
|
536 |
mTestWidget->mItem = pTmp;
|
|
537 |
mTestWidget->mItem->mModelIndex = QModelIndex();
|
|
538 |
mTestWidget->callLongPressGesture(point);
|
|
539 |
QVERIFY(HbMenuData::mExecPoint != point);
|
|
540 |
QVERIFY(HbListView::mLongPressedPoint == point);
|
|
541 |
|
|
542 |
// item at position is not null, returns current index is valid
|
34
|
543 |
HbListView::mCurrentIndex = model->index(0, 0, QModelIndex());
|
35
|
544 |
mTestWidget->mItem->mModelIndex = HbListView::mCurrentIndex ;
|
30
|
545 |
|
|
546 |
// model is == 0
|
|
547 |
VideoSortFilterProxyModel *tmp = mTestWidget->mModel;
|
|
548 |
mTestWidget->mModel = 0;
|
|
549 |
mTestWidget->callLongPressGesture(point);
|
34
|
550 |
QVERIFY(HbMenuData::mExecPoint != point);
|
30
|
551 |
QVERIFY(HbListView::mLongPressedPoint == point);
|
|
552 |
mTestWidget->mModel = tmp;
|
35
|
553 |
HbListView::mLongPressedPoint = QPointF();
|
30
|
554 |
|
35
|
555 |
// gotten id != KVcxMvcMediaTypeVideo, service is true and id != KVcxMvcMediaTypeAlbum
|
|
556 |
VideoSortFilterProxyModelData::mItemIds.clear();
|
|
557 |
VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId(1,1));
|
|
558 |
mTestWidget->mIsService = true;
|
30
|
559 |
mTestWidget->callLongPressGesture(point);
|
35
|
560 |
QVERIFY(HbMenuData::mExecPoint != point);
|
30
|
561 |
QVERIFY(HbListView::mLongPressedPoint == point);
|
35
|
562 |
HbListView::mLongPressedPoint = QPointF();
|
30
|
563 |
|
35
|
564 |
// gotten id != KVcxMvcMediaTypeVideo, service is false and id != KVcxMvcMediaTypeAlbum
|
|
565 |
VideoSortFilterProxyModelData::mItemIds.clear();
|
|
566 |
VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId(1,1));
|
|
567 |
mTestWidget->mIsService = false;
|
|
568 |
mTestWidget->callLongPressGesture(point);
|
|
569 |
QVERIFY(HbMenuData::mExecPoint != point);
|
|
570 |
QVERIFY(HbListView::mLongPressedPoint == point);
|
|
571 |
HbListView::mLongPressedPoint = QPointF();
|
30
|
572 |
|
35
|
573 |
// gotten id != KVcxMvcMediaTypeVideo, service is false and id == KVcxMvcMediaTypeAlbum
|
|
574 |
VideoSortFilterProxyModelData::mItemIds.clear();
|
|
575 |
VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId(1,2));
|
|
576 |
mTestWidget->mIsService = false;
|
30
|
577 |
mTestWidget->callLongPressGesture(point);
|
34
|
578 |
QVERIFY(HbMenuData::mExecPoint == point);
|
30
|
579 |
QVERIFY(HbListView::mLongPressedPoint == point);
|
34
|
580 |
HbMenuData::mExecPoint = QPointF();
|
35
|
581 |
HbListView::mLongPressedPoint = QPointF();
|
30
|
582 |
|
35
|
583 |
// gotten id == KVcxMvcMediaTypeVideo
|
|
584 |
VideoSortFilterProxyModelData::mItemIds.clear();
|
|
585 |
VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId(1,02));
|
|
586 |
mTestWidget->mIsService = false;
|
30
|
587 |
mTestWidget->callLongPressGesture(point);
|
34
|
588 |
QVERIFY(HbMenuData::mExecPoint == point);
|
30
|
589 |
QVERIFY(HbListView::mLongPressedPoint == point);
|
34
|
590 |
HbMenuData::mExecPoint = QPointF();
|
35
|
591 |
HbListView::mLongPressedPoint = QPointF();
|
30
|
592 |
|
35
|
593 |
// no context menu
|
|
594 |
// (context menu setup fails, due invalid amount of correct actions)
|
30
|
595 |
QMap<VideoListWidget::TContextActionIds, HbAction*>::iterator iter = mTestWidget->mContextMenuActions.begin();
|
|
596 |
iter++;
|
|
597 |
HbAction *nullAction = 0;
|
|
598 |
iter.value() = nullAction;
|
|
599 |
mTestWidget->callLongPressGesture(point);
|
34
|
600 |
QVERIFY(HbMenuData::mExecPoint != point);
|
30
|
601 |
QVERIFY(HbListView::mLongPressedPoint == point);
|
|
602 |
}
|
|
603 |
|
|
604 |
// ---------------------------------------------------------------------------
|
|
605 |
// testSetContextMenu
|
|
606 |
// ---------------------------------------------------------------------------
|
|
607 |
//
|
|
608 |
void TestListWidget::testSetContextMenu()
|
|
609 |
{
|
34
|
610 |
VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance();
|
|
611 |
VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionWrapper::EAllVideos);
|
|
612 |
VideoListDataModel *sourceModel = qobject_cast<VideoListDataModel*>(model->sourceModel());
|
|
613 |
VideoSortFilterProxyModelData::mItemIds.clear();
|
|
614 |
mTestWidget->initialize(*model);
|
35
|
615 |
|
|
616 |
setRowCount(1);
|
|
617 |
HbListView::mCurrentIndex = model->index(0, 0, QModelIndex());
|
|
618 |
mTestWidget->mItem->mModelIndex = HbListView::mCurrentIndex ;
|
30
|
619 |
|
|
620 |
TMPXItemId itemId;
|
|
621 |
QPointF point(1,1);
|
|
622 |
itemId.iId2 = 0;
|
34
|
623 |
VideoSortFilterProxyModelData::mItemIds.append(itemId);
|
30
|
624 |
|
|
625 |
// no context menu
|
|
626 |
delete mTestWidget->mContextMenu;
|
|
627 |
mTestWidget->mContextMenu = 0;
|
|
628 |
|
|
629 |
// mCurrentLevel == ELevelVideos
|
|
630 |
int visibleCount = 0;
|
34
|
631 |
mTestWidget->mCurrentLevel = VideoCollectionCommon::ELevelVideos;
|
30
|
632 |
mTestWidget->callLongPressGesture(point);
|
|
633 |
|
|
634 |
QMap<VideoListWidget::TContextActionIds, HbAction*>::iterator iter = mTestWidget->mContextMenuActions.begin();
|
|
635 |
QVERIFY(iter != mTestWidget->mContextMenuActions.end());
|
|
636 |
|
|
637 |
while(iter != mTestWidget->mContextMenuActions.end())
|
|
638 |
{
|
|
639 |
if(iter.value()->mVisible)
|
|
640 |
{
|
|
641 |
visibleCount++;
|
|
642 |
}
|
|
643 |
++iter;
|
|
644 |
}
|
35
|
645 |
QVERIFY(visibleCount == 3);
|
30
|
646 |
|
|
647 |
// invalid amount of actions -> invalid items gets removed
|
|
648 |
HbAction *nullAction = 0;
|
|
649 |
iter = mTestWidget->mContextMenuActions.begin();
|
|
650 |
iter++;
|
|
651 |
iter.value() = nullAction;
|
|
652 |
mTestWidget->callLongPressGesture(point);
|
|
653 |
QVERIFY(!mTestWidget->mContextMenu);
|
|
654 |
QVERIFY(mTestWidget->mContextMenuActions.count() == 0);
|
|
655 |
|
|
656 |
// mCurrentLevel == ELevelCategory
|
34
|
657 |
mTestWidget->mCurrentLevel = VideoCollectionCommon::ELevelCategory;
|
35
|
658 |
// mIsService is false
|
|
659 |
mTestWidget->mIsService = false;
|
30
|
660 |
mTestWidget->callLongPressGesture(point);
|
|
661 |
iter = mTestWidget->mContextMenuActions.begin();
|
|
662 |
QVERIFY(iter != mTestWidget->mContextMenuActions.end());
|
|
663 |
visibleCount = 0;
|
|
664 |
while(iter != mTestWidget->mContextMenuActions.end())
|
|
665 |
{
|
|
666 |
if(iter.value()->mVisible)
|
|
667 |
{
|
|
668 |
visibleCount++;
|
|
669 |
}
|
35
|
670 |
++iter;
|
|
671 |
}
|
|
672 |
QVERIFY(visibleCount == 2);
|
30
|
673 |
|
35
|
674 |
// mIsService is true
|
|
675 |
mTestWidget->mIsService = true;
|
|
676 |
mTestWidget->callLongPressGesture(point);
|
|
677 |
iter = mTestWidget->mContextMenuActions.begin();
|
|
678 |
QVERIFY(iter != mTestWidget->mContextMenuActions.end());
|
|
679 |
visibleCount = 0;
|
|
680 |
while(iter != mTestWidget->mContextMenuActions.end())
|
|
681 |
{
|
|
682 |
if(iter.value()->mVisible)
|
|
683 |
{
|
|
684 |
visibleCount++;
|
|
685 |
}
|
|
686 |
++iter;
|
|
687 |
}
|
|
688 |
QVERIFY(visibleCount == 0);
|
|
689 |
|
|
690 |
// mCurrentLevel == ELevelAlbum
|
|
691 |
mTestWidget->mCurrentLevel = VideoCollectionCommon::ELevelAlbum;
|
|
692 |
// mIsService is false
|
|
693 |
mTestWidget->mIsService = false;
|
|
694 |
mTestWidget->callLongPressGesture(point);
|
|
695 |
iter = mTestWidget->mContextMenuActions.begin();
|
|
696 |
QVERIFY(iter != mTestWidget->mContextMenuActions.end());
|
|
697 |
visibleCount = 0;
|
|
698 |
while(iter != mTestWidget->mContextMenuActions.end())
|
|
699 |
{
|
|
700 |
if(iter.value()->mVisible)
|
|
701 |
{
|
|
702 |
visibleCount++;
|
|
703 |
}
|
|
704 |
++iter;
|
|
705 |
}
|
|
706 |
QVERIFY(visibleCount == 3);
|
30
|
707 |
|
35
|
708 |
// mIsService is true
|
|
709 |
// object needs to be resetted for the service use
|
|
710 |
cleanup();
|
|
711 |
init();
|
|
712 |
setRowCount(1);
|
|
713 |
model = wrapper.getModel(VideoCollectionWrapper::EAllVideos);
|
|
714 |
mTestWidget->initialize(*model);
|
|
715 |
HbListView::mCurrentIndex = model->index(0, 0, QModelIndex());
|
|
716 |
mTestWidget->mItem->mModelIndex = HbListView::mCurrentIndex ;
|
|
717 |
|
|
718 |
mTestWidget->mCurrentLevel = VideoCollectionCommon::ELevelAlbum;
|
|
719 |
VideoSortFilterProxyModelData::mItemIds.append(itemId);
|
|
720 |
mTestWidget->mIsService = true;
|
|
721 |
mTestWidget->callLongPressGesture(point);
|
|
722 |
iter = mTestWidget->mContextMenuActions.begin();
|
|
723 |
QVERIFY(iter != mTestWidget->mContextMenuActions.end());
|
|
724 |
visibleCount = 0;
|
|
725 |
while(iter != mTestWidget->mContextMenuActions.end())
|
|
726 |
{
|
|
727 |
if(iter.value()->mVisible)
|
|
728 |
{
|
|
729 |
visibleCount++;
|
|
730 |
}
|
|
731 |
++iter;
|
|
732 |
}
|
|
733 |
QVERIFY(visibleCount == 2);
|
|
734 |
|
|
735 |
//invalid level
|
|
736 |
mTestWidget->mCurrentLevel = (VideoCollectionCommon::TCollectionLevels)0;
|
|
737 |
mTestWidget->callLongPressGesture(point);
|
|
738 |
iter = mTestWidget->mContextMenuActions.begin();
|
|
739 |
QVERIFY(iter != mTestWidget->mContextMenuActions.end());
|
|
740 |
visibleCount = 0;
|
|
741 |
while(iter != mTestWidget->mContextMenuActions.end())
|
|
742 |
{
|
|
743 |
if(iter.value()->mVisible)
|
|
744 |
{
|
|
745 |
visibleCount++;
|
|
746 |
}
|
|
747 |
++iter;
|
|
748 |
}
|
|
749 |
QVERIFY(visibleCount == 0);
|
30
|
750 |
}
|
35
|
751 |
|
|
752 |
void TestListWidget::testDoDelayedsSlot()
|
30
|
753 |
{
|
35
|
754 |
connect(this, SIGNAL(testSignal()), mTestWidget, SLOT(doDelayedsSlot()));
|
|
755 |
|
|
756 |
//dodelayed calls create context menu, which is already tested at
|
|
757 |
// testSetContextMenu -method, these tests are just for coverity's sake
|
34
|
758 |
VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance();
|
|
759 |
VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionWrapper::EAllVideos);
|
35
|
760 |
mTestWidget->initialize(*model);
|
|
761 |
|
|
762 |
delete mTestWidget->mContextMenu;
|
|
763 |
mTestWidget->mContextMenu = 0;
|
|
764 |
int visibleCount = 0;
|
|
765 |
mTestWidget->mCurrentLevel = VideoCollectionCommon::ELevelVideos;
|
|
766 |
|
|
767 |
// no context menu
|
|
768 |
emit testSignal();
|
|
769 |
|
|
770 |
QVERIFY(mTestWidget->mContextMenuActions.count() == 6);
|
|
771 |
|
|
772 |
// context menu exists
|
|
773 |
emit testSignal();
|
|
774 |
|
|
775 |
QVERIFY(mTestWidget->mContextMenuActions.count() == 6);
|
|
776 |
|
|
777 |
disconnect(this, SIGNAL(testSignal()), mTestWidget, SLOT(scrollingStartedSlot()));
|
|
778 |
}
|
34
|
779 |
|
30
|
780 |
// ---------------------------------------------------------------------------
|
|
781 |
// testDeleteItemSlot
|
|
782 |
// ---------------------------------------------------------------------------
|
|
783 |
//
|
|
784 |
void TestListWidget::testDeleteItemSlot()
|
|
785 |
{
|
34
|
786 |
VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance();
|
|
787 |
VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionWrapper::EAllVideos);
|
|
788 |
|
|
789 |
HbMessageBoxData::mLatestTxt = "";
|
|
790 |
VideoSortFilterProxyModelData::mLastIndex = QModelIndex();
|
|
791 |
mTestWidget->initialize(*model);
|
30
|
792 |
connect(this, SIGNAL(testSignal()), mTestWidget, SLOT(deleteItemSlot()));
|
|
793 |
|
|
794 |
// no model
|
|
795 |
VideoSortFilterProxyModel *tmp = mTestWidget->mModel;
|
|
796 |
mTestWidget->mModel = 0;
|
|
797 |
emit testSignal();
|
34
|
798 |
QVERIFY(VideoListDataModelData::dataAccessCount() == 0);
|
|
799 |
QVERIFY(HbMessageBoxData::mLatestTxt.isEmpty());
|
|
800 |
QVERIFY(!VideoSortFilterProxyModelData::mLastIndex.isValid());
|
|
801 |
setRowCount(1);
|
30
|
802 |
mTestWidget->mModel = tmp;
|
|
803 |
|
|
804 |
// data fetched from item is invalid
|
34
|
805 |
setRowCount(1);
|
|
806 |
mTestWidget->mCurrentIndex = model->index(0, 0, QModelIndex());
|
30
|
807 |
emit testSignal();
|
34
|
808 |
QVERIFY(VideoListDataModelData::dataAccessCount() == 1);
|
|
809 |
QVERIFY(HbMessageBoxData::mLatestTxt.isEmpty());
|
|
810 |
QVERIFY(!VideoSortFilterProxyModelData::mLastIndex.isValid());
|
|
811 |
setRowCount(0);
|
30
|
812 |
|
|
813 |
// data is valid
|
34
|
814 |
setRowCount(1);
|
30
|
815 |
QVariant data = QString("test");
|
34
|
816 |
VideoListDataModelData::setData( Qt::DisplayRole, data);
|
|
817 |
mTestWidget->mCurrentIndex = model->index(0, 0, QModelIndex());
|
30
|
818 |
|
|
819 |
// messagebox question returns false
|
34
|
820 |
HbMessageBoxData::mQuestionReturnValue = false;
|
30
|
821 |
emit testSignal();
|
35
|
822 |
QVERIFY(VideoListDataModelData::dataAccessCount() == 2);
|
34
|
823 |
QVERIFY(!HbMessageBoxData::mLatestTxt.isEmpty());
|
35
|
824 |
QVERIFY(!VideoSortFilterProxyModelData::mLastIndex.isValid());
|
34
|
825 |
HbMessageBoxData::mLatestTxt = "";
|
|
826 |
setRowCount(1);
|
30
|
827 |
data = QString("test");
|
34
|
828 |
VideoListDataModelData::setData( Qt::DisplayRole, data);
|
30
|
829 |
|
|
830 |
// messagebox question returns true
|
35
|
831 |
VideoSortFilterProxyModelData::mDeleteItemsFails = false;
|
34
|
832 |
HbMessageBoxData::mQuestionReturnValue = true;
|
30
|
833 |
emit testSignal();
|
35
|
834 |
QVERIFY(VideoListDataModelData::dataAccessCount() == 3);
|
34
|
835 |
QVERIFY(!HbMessageBoxData::mLatestTxt.isEmpty());
|
|
836 |
QVERIFY(VideoSortFilterProxyModelData::mLastIndex.row() == 0);
|
30
|
837 |
|
|
838 |
disconnect(this, SIGNAL(testSignal()), mTestWidget, SLOT(deleteItemSlot()));
|
|
839 |
}
|
|
840 |
|
|
841 |
// ---------------------------------------------------------------------------
|
|
842 |
// testRenameSlot
|
|
843 |
// ---------------------------------------------------------------------------
|
|
844 |
//
|
|
845 |
void TestListWidget::testRenameSlot()
|
|
846 |
{
|
34
|
847 |
VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance();
|
|
848 |
VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionWrapper::EAllVideos);
|
|
849 |
|
30
|
850 |
// nothing to test yet
|
34
|
851 |
HbMessageBoxData::mLatestTxt = "";
|
|
852 |
mTestWidget->initialize(*model);
|
30
|
853 |
connect(this, SIGNAL(testSignal()), mTestWidget, SLOT(renameSlot()));
|
|
854 |
emit testSignal();
|
34
|
855 |
QVERIFY(!HbMessageBoxData::mLatestTxt.isEmpty());
|
30
|
856 |
disconnect(this, SIGNAL(testSignal()), mTestWidget, SLOT(renameSlot()));
|
|
857 |
}
|
|
858 |
|
|
859 |
// ---------------------------------------------------------------------------
|
35
|
860 |
// testPlayItemSlot
|
|
861 |
// ---------------------------------------------------------------------------
|
|
862 |
//
|
|
863 |
void TestListWidget::testPlayItemSlot()
|
|
864 |
{
|
|
865 |
VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance();
|
|
866 |
VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionWrapper::EAllVideos);
|
|
867 |
mTestWidget->initialize(*model);
|
|
868 |
connect(this, SIGNAL(testSignal()), mTestWidget, SLOT(playItemSlot()));
|
|
869 |
setRowCount(1);
|
|
870 |
TMPXItemId savedId = TMPXItemId(1,1);
|
|
871 |
VideoSortFilterProxyModelData::mItemIds.clear();
|
|
872 |
VideoSortFilterProxyModelData::mItemIds.append(savedId);
|
|
873 |
HbListView::mCurrentIndex = model->index(0, 0, QModelIndex());
|
|
874 |
|
|
875 |
emit testSignal();
|
|
876 |
|
|
877 |
QVERIFY(VideoSortFilterProxyModelData::mLastItemId == savedId);
|
|
878 |
|
|
879 |
disconnect(this, SIGNAL(testSignal()), mTestWidget, SLOT(playItemSlot()));
|
|
880 |
}
|
|
881 |
|
|
882 |
// ---------------------------------------------------------------------------
|
30
|
883 |
// testPlayAllSlot
|
|
884 |
// ---------------------------------------------------------------------------
|
|
885 |
//
|
|
886 |
void TestListWidget::testPlayAllSlot()
|
|
887 |
{
|
35
|
888 |
connect(this, SIGNAL(testSignal()), mTestWidget, SLOT(playAllSlot()));
|
30
|
889 |
emit testSignal();
|
|
890 |
disconnect(this, SIGNAL(testSignal()), mTestWidget, SLOT(playAllSlot()));
|
|
891 |
}
|
|
892 |
|
|
893 |
// ---------------------------------------------------------------------------
|
|
894 |
// testAddToCollectionSlot
|
|
895 |
// ---------------------------------------------------------------------------
|
|
896 |
//
|
|
897 |
void TestListWidget::testAddToCollectionSlot()
|
|
898 |
{
|
34
|
899 |
VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance();
|
|
900 |
VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionWrapper::EAllVideos);
|
|
901 |
|
35
|
902 |
VideoListSelectionDialogData::mSelectionType = -1;
|
|
903 |
VideoListSelectionDialogData::mSettedMpxId = TMPXItemId::InvalidId();
|
|
904 |
|
30
|
905 |
connect(this, SIGNAL(testSignal()), mTestWidget, SLOT(addToCollectionSlot()));
|
35
|
906 |
setRowCount(1);
|
|
907 |
TMPXItemId savedId = TMPXItemId(1,1);
|
|
908 |
VideoSortFilterProxyModelData::mItemIds.clear();
|
|
909 |
VideoSortFilterProxyModelData::mItemIds.append(savedId);
|
|
910 |
HbListView::mCurrentIndex = model->index(0, 0, QModelIndex());
|
|
911 |
|
|
912 |
// no model
|
30
|
913 |
emit testSignal();
|
35
|
914 |
QVERIFY(VideoListSelectionDialogData::mSelectionType == -1 );
|
|
915 |
QVERIFY(VideoListSelectionDialogData::mSettedMpxId == TMPXItemId::InvalidId());
|
|
916 |
|
|
917 |
mTestWidget->initialize(*model);
|
|
918 |
// dialog finding fails
|
|
919 |
VideoCollectionUiLoaderData::mFindFailureNameList.append(DOCML_NAME_DIALOG);
|
|
920 |
emit testSignal();
|
|
921 |
QVERIFY(VideoListSelectionDialogData::mSelectionType == -1 );
|
|
922 |
QVERIFY(VideoListSelectionDialogData::mSettedMpxId == TMPXItemId::InvalidId());
|
|
923 |
VideoCollectionUiLoaderData::mFindFailureNameList.clear();
|
|
924 |
|
|
925 |
// invalid id at current index
|
|
926 |
VideoSortFilterProxyModelData::mItemIds.clear();
|
|
927 |
VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId::InvalidId());
|
|
928 |
emit testSignal();
|
|
929 |
QVERIFY(VideoListSelectionDialogData::mSelectionType == -1 );
|
|
930 |
QVERIFY(VideoListSelectionDialogData::mSettedMpxId == TMPXItemId::InvalidId());
|
|
931 |
|
|
932 |
// valid id at current index
|
|
933 |
VideoSortFilterProxyModelData::mItemIds.clear();
|
|
934 |
VideoSortFilterProxyModelData::mItemIds.append(savedId);
|
|
935 |
emit testSignal();
|
|
936 |
QVERIFY(VideoListSelectionDialogData::mSelectionType == VideoListSelectionDialog::ESelectCollection );
|
|
937 |
QVERIFY(VideoListSelectionDialogData::mSettedMpxId == savedId);
|
|
938 |
|
|
939 |
disconnect(this, SIGNAL(testSignal()), mTestWidget, SLOT(addToCollectionSlot()));
|
|
940 |
|
30
|
941 |
}
|
|
942 |
|
|
943 |
// ---------------------------------------------------------------------------
|
35
|
944 |
// testRemoveFromCollectionSlot
|
|
945 |
// ---------------------------------------------------------------------------
|
|
946 |
//
|
|
947 |
void TestListWidget::testRemoveFromCollectionSlot()
|
|
948 |
{
|
|
949 |
VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance();
|
|
950 |
VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionWrapper::EAllVideos);
|
|
951 |
|
|
952 |
VideoSortFilterProxyModelData::mRemoveItemsFromAlbumReturnValue = 0;
|
|
953 |
VideoSortFilterProxyModelData::mLastItemId = TMPXItemId::InvalidId();
|
|
954 |
VideoSortFilterProxyModelData::mItemIds.clear();
|
|
955 |
|
|
956 |
connect(this, SIGNAL(testSignal()), mTestWidget, SLOT(removeFromCollectionSlot()));
|
|
957 |
setRowCount(2);
|
|
958 |
TMPXItemId savedId = TMPXItemId(1,1);
|
|
959 |
VideoSortFilterProxyModelData::mItemIds.clear();
|
|
960 |
// invalid id at index 0
|
|
961 |
VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId::InvalidId());
|
|
962 |
VideoSortFilterProxyModelData::mItemIds.append(savedId);
|
|
963 |
HbListView::mCurrentIndex = model->index(1, 0, QModelIndex());
|
|
964 |
|
|
965 |
// no model
|
|
966 |
emit testSignal();
|
|
967 |
QVERIFY(VideoSortFilterProxyModelData::mLastItemId == TMPXItemId::InvalidId());
|
|
968 |
|
|
969 |
mTestWidget->initialize(*model);
|
|
970 |
VideoSortFilterProxyModelData::mOpenedItemId = TMPXItemId::InvalidId();
|
|
971 |
|
|
972 |
// collection id is invalid
|
|
973 |
emit testSignal();
|
|
974 |
QVERIFY(VideoSortFilterProxyModelData::mLastItemId == TMPXItemId::InvalidId());
|
|
975 |
VideoSortFilterProxyModelData::mOpenedItemId = TMPXItemId(1,2);
|
|
976 |
|
|
977 |
// media at current index is invalid
|
|
978 |
HbListView::mCurrentIndex = model->index(0, 0, QModelIndex());
|
|
979 |
emit testSignal();
|
|
980 |
QVERIFY(VideoSortFilterProxyModelData::mLastItemId == TMPXItemId::InvalidId());
|
|
981 |
|
|
982 |
// all is ok
|
|
983 |
HbListView::mCurrentIndex = model->index(1, 0, QModelIndex());
|
|
984 |
emit testSignal();
|
|
985 |
|
|
986 |
QVERIFY(VideoSortFilterProxyModelData::mLastItemId == TMPXItemId(1,2));
|
|
987 |
// ids are to be saved at VideoSortFilterProxyModelData::mItemIds
|
|
988 |
QVERIFY(VideoSortFilterProxyModelData::mItemIds.at(0) == savedId);
|
|
989 |
|
|
990 |
disconnect(this, SIGNAL(testSignal()), mTestWidget, SLOT(removeFromCollectionSlot()));
|
|
991 |
}
|
|
992 |
|
|
993 |
// ---------------------------------------------------------------------------
|
|
994 |
// testRemoveCollectionSlot
|
|
995 |
// ---------------------------------------------------------------------------
|
|
996 |
//
|
|
997 |
void TestListWidget::testRemoveCollectionSlot()
|
|
998 |
{
|
|
999 |
VideoSortFilterProxyModelData::mRemoveAlbumsFails = false;
|
|
1000 |
VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance();
|
|
1001 |
VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionWrapper::EAllVideos);
|
|
1002 |
|
|
1003 |
HbMessageBoxData::mQuestionReturnValue = true;
|
|
1004 |
HbMessageBoxData::mLatestTxt = "";
|
|
1005 |
VideoSortFilterProxyModelData::mLastIndex = QModelIndex();
|
|
1006 |
|
|
1007 |
setRowCount(1);
|
|
1008 |
HbListView::mCurrentIndex = model->index(0, 0, QModelIndex());
|
|
1009 |
|
|
1010 |
connect(this, SIGNAL(testSignal()), mTestWidget, SLOT(removeCollectionSlot()));
|
|
1011 |
|
|
1012 |
setRowCount(2);
|
|
1013 |
TMPXItemId savedId = TMPXItemId(1,1);
|
|
1014 |
VideoSortFilterProxyModelData::mItemIds.clear();
|
|
1015 |
// invalid id at index 0
|
|
1016 |
VideoSortFilterProxyModelData::mItemIds.append(TMPXItemId::InvalidId());
|
|
1017 |
VideoSortFilterProxyModelData::mItemIds.append(savedId);
|
|
1018 |
HbListView::mCurrentIndex = model->index(1, 0, QModelIndex());
|
|
1019 |
|
|
1020 |
// no model
|
|
1021 |
emit testSignal();
|
|
1022 |
QVERIFY(!VideoSortFilterProxyModelData::mLastIndex.isValid());
|
|
1023 |
QVERIFY(HbMessageBoxData::mLatestTxt.isEmpty());
|
|
1024 |
|
|
1025 |
mTestWidget->initialize(*model);
|
|
1026 |
|
|
1027 |
// invalid data
|
|
1028 |
VideoListDataModelData::setData( Qt::DisplayRole, QVariant());
|
|
1029 |
emit testSignal();
|
|
1030 |
QVERIFY(!VideoSortFilterProxyModelData::mLastIndex.isValid());
|
|
1031 |
QVERIFY(HbMessageBoxData::mLatestTxt.isEmpty());
|
|
1032 |
|
|
1033 |
// valid data
|
|
1034 |
VideoListDataModelData::setData( Qt::DisplayRole, "test");
|
|
1035 |
emit testSignal();
|
|
1036 |
QVERIFY(VideoSortFilterProxyModelData::mLastIndex.isValid());
|
|
1037 |
QVERIFY(VideoSortFilterProxyModelData::mLastIndex.row() == 1);
|
|
1038 |
QVERIFY(!HbMessageBoxData::mLatestTxt.isEmpty());
|
|
1039 |
|
|
1040 |
// msg box return false (for coverity)
|
|
1041 |
VideoSortFilterProxyModelData::mLastIndex = QModelIndex();
|
|
1042 |
HbMessageBoxData::mLatestTxt = "";
|
|
1043 |
HbMessageBoxData::mQuestionReturnValue = false;
|
|
1044 |
emit testSignal();
|
|
1045 |
QVERIFY(!VideoSortFilterProxyModelData::mLastIndex.isValid());
|
|
1046 |
QVERIFY(!HbMessageBoxData::mLatestTxt.isEmpty());
|
|
1047 |
|
|
1048 |
disconnect(this, SIGNAL(testSignal()), mTestWidget, SLOT(removeCollectionSlot()));
|
|
1049 |
}
|
|
1050 |
|
|
1051 |
// ---------------------------------------------------------------------------
|
30
|
1052 |
// testOpenDetailsSlot
|
|
1053 |
// ---------------------------------------------------------------------------
|
|
1054 |
//
|
|
1055 |
void TestListWidget::testOpenDetailsSlot()
|
|
1056 |
{
|
34
|
1057 |
VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance();
|
|
1058 |
VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionWrapper::EAllVideos);
|
|
1059 |
|
30
|
1060 |
QSignalSpy spysignal(mTestWidget, SIGNAL(command(int)));
|
34
|
1061 |
HbMessageBoxData::mLatestTxt = "";
|
|
1062 |
VideoSortFilterProxyModelData::mLastIndex = QModelIndex();
|
|
1063 |
setRowCount(0);
|
|
1064 |
mTestWidget->initialize(*model);
|
30
|
1065 |
connect(this, SIGNAL(testSignal()), mTestWidget, SLOT(openDetailsSlot()));
|
|
1066 |
|
|
1067 |
// no model
|
|
1068 |
VideoSortFilterProxyModel *tmp = mTestWidget->mModel;
|
|
1069 |
mTestWidget->mModel = 0;
|
|
1070 |
emit testSignal();
|
|
1071 |
QVERIFY(spysignal.count() == 0);
|
34
|
1072 |
QVERIFY(!VideoSortFilterProxyModelData::mLastIndex.isValid());
|
30
|
1073 |
mTestWidget->mModel = tmp;
|
|
1074 |
|
|
1075 |
// detail fetch fails
|
34
|
1076 |
setRowCount(1);
|
30
|
1077 |
QVariant data = QString("test");
|
34
|
1078 |
VideoListDataModelData::setData( Qt::DisplayRole, data);
|
|
1079 |
mTestWidget->mCurrentIndex = model->index(0, 0, QModelIndex());
|
|
1080 |
VideoSortFilterProxyModelData::mDetailsReturnValue = -1;
|
30
|
1081 |
|
|
1082 |
emit testSignal();
|
|
1083 |
QVERIFY(spysignal.count() == 0);
|
34
|
1084 |
QVERIFY(VideoSortFilterProxyModelData::mLastIndex.row() == 0);
|
30
|
1085 |
|
|
1086 |
// detail fetch succeeds
|
34
|
1087 |
VideoSortFilterProxyModelData::mDetailsReturnValue = 0;
|
|
1088 |
VideoSortFilterProxyModelData::mLastIndex = QModelIndex();
|
30
|
1089 |
emit testSignal();
|
|
1090 |
QVERIFY(spysignal.count() == 1);
|
|
1091 |
QVERIFY(spysignal.at(0).at(0).isValid());
|
|
1092 |
QVERIFY(spysignal.at(0).at(0).toInt() == MpxHbVideoCommon::ActivateVideoDetailsView);
|
34
|
1093 |
QVERIFY(VideoSortFilterProxyModelData::mLastIndex.row() == 0);
|
30
|
1094 |
|
|
1095 |
disconnect(this, SIGNAL(testSignal()), mTestWidget, SLOT(openDetailsSlot()));
|
|
1096 |
}
|
|
1097 |
|
|
1098 |
// ---------------------------------------------------------------------------
|
|
1099 |
// testBack
|
|
1100 |
// ---------------------------------------------------------------------------
|
|
1101 |
//
|
|
1102 |
void TestListWidget::testBack()
|
|
1103 |
{
|
34
|
1104 |
VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance();
|
|
1105 |
VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionWrapper::EAllVideos);
|
|
1106 |
|
35
|
1107 |
QSignalSpy spysignal(mTestWidget, SIGNAL(collectionOpened(bool, const QString&, const QModelIndex&)));
|
30
|
1108 |
connect(this, SIGNAL(testSignal()), mTestWidget, SLOT(back()));
|
|
1109 |
// no model
|
|
1110 |
emit testSignal();
|
|
1111 |
QVERIFY(spysignal.count() == 0);
|
|
1112 |
|
|
1113 |
// model exist
|
34
|
1114 |
mTestWidget->initialize(*model);
|
30
|
1115 |
emit testSignal();
|
|
1116 |
QVERIFY(spysignal.count() == 1);
|
|
1117 |
QVERIFY(spysignal.value(0).at(0).isValid());
|
|
1118 |
QVERIFY(spysignal.value(0).at(0).toBool() == false);
|
|
1119 |
QVERIFY(spysignal.value(0).at(1).isValid());
|
|
1120 |
QVERIFY(spysignal.value(0).at(1).toString().isEmpty());
|
|
1121 |
|
|
1122 |
disconnect(this, SIGNAL(testSignal()), mTestWidget, SLOT(back()));
|
|
1123 |
}
|
35
|
1124 |
|
|
1125 |
// ---------------------------------------------------------------------------
|
|
1126 |
// testScrollingEndedSlot
|
|
1127 |
// ---------------------------------------------------------------------------
|
|
1128 |
//
|
|
1129 |
void TestListWidget::testScrollingStartedSlot()
|
|
1130 |
{
|
|
1131 |
connect(this, SIGNAL(testSignal()), mTestWidget, SLOT(scrollingStartedSlot()));
|
|
1132 |
|
|
1133 |
emit testSignal();
|
|
1134 |
|
|
1135 |
|
|
1136 |
disconnect(this, SIGNAL(testSignal()), mTestWidget, SLOT(scrollingStartedSlot()));
|
|
1137 |
}
|
|
1138 |
|
30
|
1139 |
// ---------------------------------------------------------------------------
|
|
1140 |
// testScrollingEndedSlot
|
|
1141 |
// ---------------------------------------------------------------------------
|
|
1142 |
//
|
|
1143 |
void TestListWidget::testScrollingEndedSlot()
|
|
1144 |
{
|
34
|
1145 |
VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance();
|
|
1146 |
VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionWrapper::EAllVideos);
|
|
1147 |
|
|
1148 |
mTestWidget->initialize(*model);
|
30
|
1149 |
connect(this, SIGNAL(testSignal()), mTestWidget, SLOT(scrollingEndedSlot()));
|
|
1150 |
|
|
1151 |
// no visible items
|
|
1152 |
HbListView::mVisibleItems.clear();
|
|
1153 |
emit testSignal();
|
34
|
1154 |
QVERIFY(VideoThumbnailTestData::mStartBackgroundFetchingCallCount == 0);
|
30
|
1155 |
QVERIFY(!mTestWidget->mScrollPositionTimer->isActive());
|
|
1156 |
|
|
1157 |
// setup few "visible" items and make sure item count match at thumbnail data
|
|
1158 |
int count = 10;
|
34
|
1159 |
setRowCount(count);
|
30
|
1160 |
HbAbstractViewItem *item = 0;
|
|
1161 |
for(int i = 0; i < count; ++i)
|
|
1162 |
{
|
|
1163 |
item = new HbAbstractViewItem();
|
34
|
1164 |
item->mModelIndex = model->index(i, 0, QModelIndex());
|
30
|
1165 |
HbListView::mVisibleItems.append(item);
|
|
1166 |
}
|
|
1167 |
|
|
1168 |
// Test
|
|
1169 |
emit testSignal();
|
34
|
1170 |
QVERIFY(VideoThumbnailTestData::mStartBackgroundFetchingCallCount == 1);
|
30
|
1171 |
QVERIFY(!mTestWidget->mScrollPositionTimer->isActive());
|
|
1172 |
|
|
1173 |
// Test again when timer is null.
|
34
|
1174 |
VideoThumbnailTestData::mStartBackgroundFetchingCallCount = 0;
|
30
|
1175 |
QTimer *backup = mTestWidget->mScrollPositionTimer;
|
|
1176 |
mTestWidget->mScrollPositionTimer = 0;
|
|
1177 |
emit testSignal();
|
34
|
1178 |
QVERIFY(VideoThumbnailTestData::mStartBackgroundFetchingCallCount == 1);
|
30
|
1179 |
mTestWidget->mScrollPositionTimer = backup;
|
|
1180 |
backup = 0;
|
|
1181 |
|
|
1182 |
disconnect(this, SIGNAL(testSignal()), mTestWidget, SLOT(scrollingEndedSlot()));
|
|
1183 |
}
|
|
1184 |
|
|
1185 |
// ---------------------------------------------------------------------------
|
35
|
1186 |
// testScrollPositionChangedSlot
|
30
|
1187 |
// ---------------------------------------------------------------------------
|
|
1188 |
//
|
|
1189 |
void TestListWidget::testScrollPositionChangedSlot()
|
|
1190 |
{
|
34
|
1191 |
VideoCollectionWrapper &wrapper = VideoCollectionWrapper::instance();
|
|
1192 |
VideoSortFilterProxyModel *model = wrapper.getModel(VideoCollectionWrapper::EAllVideos);
|
|
1193 |
|
|
1194 |
mTestWidget->initialize(*model);
|
30
|
1195 |
const QPointF point;
|
|
1196 |
|
|
1197 |
connect(this, SIGNAL(testSignal(const QPointF&)), mTestWidget, SLOT(scrollPositionChangedSlot(const QPointF&)));
|
|
1198 |
|
|
1199 |
// Test
|
|
1200 |
emit testSignal(point);
|
|
1201 |
|
|
1202 |
// Test again when timer is running.
|
|
1203 |
mTestWidget->mScrollPositionTimer->start(1000*30);
|
|
1204 |
emit testSignal(point);
|
|
1205 |
|
|
1206 |
// Test when timer is null.
|
|
1207 |
QTimer *backup = mTestWidget->mScrollPositionTimer;
|
|
1208 |
mTestWidget->mScrollPositionTimer = 0;
|
|
1209 |
emit testSignal(point);
|
|
1210 |
mTestWidget->mScrollPositionTimer = backup;
|
|
1211 |
backup = 0;
|
|
1212 |
|
|
1213 |
disconnect(this, SIGNAL(testSignal(const QPointF&)), mTestWidget, SLOT(scrollPositionChangedSlot(const QPointF&)));
|
|
1214 |
}
|
|
1215 |
|
35
|
1216 |
void TestListWidget::testScrollPositionTimerSlot()
|
|
1217 |
{
|
|
1218 |
connect(this, SIGNAL(testSignal()), mTestWidget, SLOT(scrollPositionTimerSlot()));
|
|
1219 |
emit testSignal();
|
|
1220 |
disconnect(this, SIGNAL(testSignal()), mTestWidget, SLOT(scrollPositionTimerSlot()));
|
|
1221 |
|
|
1222 |
}
|
|
1223 |
|
30
|
1224 |
// end of file
|