|
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 VideoProxyModelAllVideos |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <QModelIndex> |
|
19 #include <QModelIndexList> |
|
20 #include <hbapplication.h> |
|
21 |
|
22 #include <vcxmyvideosdefs.h> |
|
23 #include "videoproxymodelgeneric.h" |
|
24 |
|
25 #define private public |
|
26 #include "videoproxymodelallvideos.h" |
|
27 #undef private |
|
28 |
|
29 #include "videolistdatamodel.h" |
|
30 #include "filterproxytester.h" |
|
31 #include "videocollectioncommon.h" |
|
32 #include "testvideoproxymodelallvideos.h" |
|
33 |
|
34 // --------------------------------------------------------------------------- |
|
35 // main |
|
36 // --------------------------------------------------------------------------- |
|
37 // |
|
38 int main(int argc, char *argv[]) |
|
39 { |
|
40 HbApplication app(argc, argv); |
|
41 |
|
42 TestVideoProxyModelAllVideos 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\\testVideoProxyModelAllVideos.txt"; |
|
55 res = QTest::qExec(&tv, 3, pass); |
|
56 } |
|
57 |
|
58 return res; |
|
59 } |
|
60 |
|
61 // --------------------------------------------------------------------------- |
|
62 // init |
|
63 // --------------------------------------------------------------------------- |
|
64 // |
|
65 void TestVideoProxyModelAllVideos::init() |
|
66 { |
|
67 qRegisterMetaType<TMPXItemId>("TMPXItemId"); |
|
68 |
|
69 mTestObject = new FilterProxyTester(); |
|
70 } |
|
71 |
|
72 // --------------------------------------------------------------------------- |
|
73 // cleanup |
|
74 // --------------------------------------------------------------------------- |
|
75 // |
|
76 void TestVideoProxyModelAllVideos::cleanup() |
|
77 { |
|
78 delete mTestObject; |
|
79 mTestObject = 0; |
|
80 } |
|
81 |
|
82 // --------------------------------------------------------------------------- |
|
83 // testFilterAcceptsRow |
|
84 // --------------------------------------------------------------------------- |
|
85 // |
|
86 void TestVideoProxyModelAllVideos::testFilterAcceptsRow() |
|
87 { |
|
88 // No source model |
|
89 VideoListDataModel *model = 0; |
|
90 mTestObject->mModel = model; |
|
91 VideoListDataModel::mMediaIdAtIndexReturnValue = TMPXItemId::InvalidId(); |
|
92 VideoListDataModel::mMediaIdAtIndexCallCount = 0; |
|
93 VideoListDataModel::mRowCountReturnValue = 0; |
|
94 QVERIFY(mTestObject->callFilterAcceptsRow(0, QModelIndex()) == false); |
|
95 QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 0); |
|
96 |
|
97 // Source row < 0 |
|
98 model = new VideoListDataModel(); |
|
99 mTestObject->mModel = model; |
|
100 VideoListDataModel::mMediaIdAtIndexReturnValue = TMPXItemId::InvalidId(); |
|
101 VideoListDataModel::mMediaIdAtIndexCallCount = 0; |
|
102 VideoListDataModel::mRowCountReturnValue = 0; |
|
103 QVERIFY(mTestObject->callFilterAcceptsRow(-1, QModelIndex()) == false); |
|
104 QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 0); |
|
105 |
|
106 // Source row > model row count |
|
107 VideoListDataModel::mMediaIdAtIndexReturnValue = TMPXItemId::InvalidId(); |
|
108 VideoListDataModel::mMediaIdAtIndexCallCount = 0; |
|
109 VideoListDataModel::mRowCountReturnValue = 0; |
|
110 QVERIFY(mTestObject->callFilterAcceptsRow(10, QModelIndex()) == false); |
|
111 QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 0); |
|
112 |
|
113 // Item id is not video |
|
114 VideoListDataModel::mMediaIdAtIndexReturnValue = TMPXItemId(0, KVcxMvcMediaTypeAlbum); |
|
115 VideoListDataModel::mMediaIdAtIndexCallCount = 0; |
|
116 VideoListDataModel::mRowCountReturnValue = 1; |
|
117 QVERIFY(mTestObject->callFilterAcceptsRow(0, QModelIndex()) == false); |
|
118 QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 1); |
|
119 |
|
120 // Good case |
|
121 VideoListDataModel::mMediaIdAtIndexReturnValue = TMPXItemId(0, KVcxMvcMediaTypeVideo); |
|
122 VideoListDataModel::mMediaIdAtIndexCallCount = 0; |
|
123 VideoListDataModel::mRowCountReturnValue = 1; |
|
124 QVERIFY(mTestObject->callFilterAcceptsRow(0, QModelIndex()) == true); |
|
125 QCOMPARE(VideoListDataModel::mMediaIdAtIndexCallCount, 1); |
|
126 } |
|
127 |
|
128 // --------------------------------------------------------------------------- |
|
129 // testGetOpenItem |
|
130 // --------------------------------------------------------------------------- |
|
131 // |
|
132 void TestVideoProxyModelAllVideos::testGetOpenItem() |
|
133 { |
|
134 TMPXItemId returned = TMPXItemId(1, 1); |
|
135 |
|
136 // No model |
|
137 VideoListDataModel *model = 0; |
|
138 mTestObject->mModel = model; |
|
139 returned = mTestObject->getOpenItem(); |
|
140 QVERIFY(returned == TMPXItemId::InvalidId()); |
|
141 |
|
142 // No collection client |
|
143 model = new VideoListDataModel(); |
|
144 mTestObject->mModel = model; |
|
145 mTestObject->mCollectionClient = 0; |
|
146 returned = mTestObject->getOpenItem(); |
|
147 QVERIFY(returned == TMPXItemId::InvalidId()); |
|
148 |
|
149 // Good case. |
|
150 mTestObject->mModel = model; |
|
151 mTestObject->mCollectionClient = 1; |
|
152 returned = mTestObject->getOpenItem(); |
|
153 QVERIFY(returned == TMPXItemId(KVcxMvcCategoryIdAll, KVcxMvcMediaTypeCategory)); |
|
154 } |
|
155 |
|
156 // End of file |