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 VideoCollectionViewUtils
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <qapplication.h>
|
34
|
19 |
#include "centralrepository.h"
|
30
|
20 |
#include "testvideocollectionviewutils.h"
|
|
21 |
#include "hblabel.h"
|
|
22 |
#include "hbaction.h"
|
|
23 |
#include "videocollectioncommon.h"
|
|
24 |
#include "centralrepository.h"
|
34
|
25 |
#include "hbmessageboxdata.h"
|
|
26 |
|
30
|
27 |
#define private public
|
|
28 |
#include "videocollectionviewutils.h"
|
|
29 |
#undef private
|
|
30 |
|
|
31 |
// ---------------------------------------------------------------------------
|
|
32 |
// main
|
|
33 |
// ---------------------------------------------------------------------------
|
|
34 |
//
|
|
35 |
int main(int argc, char *argv[])
|
|
36 |
{
|
|
37 |
QApplication app(argc, argv);
|
|
38 |
|
|
39 |
TestVideoVideoCollectionViewUtils tv;
|
|
40 |
|
34
|
41 |
int res;
|
|
42 |
if(argc > 1)
|
|
43 |
{
|
|
44 |
res = QTest::qExec(&tv, argc, argv);
|
|
45 |
}
|
|
46 |
else
|
|
47 |
{
|
|
48 |
char *pass[3];
|
|
49 |
pass[0] = argv[0];
|
|
50 |
pass[1] = "-o";
|
|
51 |
pass[2] = "c:\\data\\testvideocollectionviewutils.txt";
|
|
52 |
res = QTest::qExec(&tv, 3, pass);
|
|
53 |
}
|
|
54 |
|
30
|
55 |
return res;
|
|
56 |
}
|
|
57 |
|
|
58 |
// ---------------------------------------------------------------------------
|
|
59 |
// init
|
|
60 |
// ---------------------------------------------------------------------------
|
|
61 |
//
|
|
62 |
void TestVideoVideoCollectionViewUtils::init()
|
|
63 |
{
|
|
64 |
|
|
65 |
}
|
|
66 |
|
|
67 |
// ---------------------------------------------------------------------------
|
|
68 |
// cleanup
|
|
69 |
// ---------------------------------------------------------------------------
|
|
70 |
//
|
|
71 |
void TestVideoVideoCollectionViewUtils::cleanup()
|
|
72 |
{
|
|
73 |
|
|
74 |
}
|
|
75 |
|
|
76 |
// ---------------------------------------------------------------------------
|
|
77 |
// testShowErrorMsgSlot
|
|
78 |
// ---------------------------------------------------------------------------
|
|
79 |
//
|
|
80 |
void TestVideoVideoCollectionViewUtils::testShowErrorMsgSlot()
|
|
81 |
{
|
|
82 |
VideoCollectionViewUtils &testObject(VideoCollectionViewUtils::instance());
|
|
83 |
QVariant additional;
|
|
84 |
QString txt = "__test__";
|
34
|
85 |
HbMessageBoxData::mWarningCallCount = 0;
|
|
86 |
HbMessageBoxData::mInformationCallCount = 0;
|
30
|
87 |
|
|
88 |
// status: VideoCollectionCommon::statusSingleDeleteFail
|
35
|
89 |
additional = txt;
|
30
|
90 |
testObject.showStatusMsgSlot(VideoCollectionCommon::statusSingleDeleteFail, additional);
|
34
|
91 |
QVERIFY(HbMessageBoxData::mWarningCallCount == 1);
|
|
92 |
QVERIFY(HbMessageBoxData::mInformationCallCount == 0);
|
|
93 |
HbMessageBoxData::mWarningCallCount = 0;
|
|
94 |
HbMessageBoxData::mInformationCallCount = 0;
|
30
|
95 |
|
|
96 |
// - invalid additional
|
35
|
97 |
additional = QVariant();
|
30
|
98 |
testObject.showStatusMsgSlot(VideoCollectionCommon::statusSingleDeleteFail, additional);
|
34
|
99 |
QVERIFY(HbMessageBoxData::mWarningCallCount == 0);
|
|
100 |
QVERIFY(HbMessageBoxData::mInformationCallCount == 0);
|
30
|
101 |
|
35
|
102 |
// status: VideoCollectionCommon::statusMultipleDeleteFail
|
|
103 |
additional = txt;
|
30
|
104 |
testObject.showStatusMsgSlot(VideoCollectionCommon::statusMultipleDeleteFail, additional);
|
34
|
105 |
QVERIFY(HbMessageBoxData::mWarningCallCount == 1);
|
|
106 |
QVERIFY(HbMessageBoxData::mInformationCallCount == 0);
|
|
107 |
HbMessageBoxData::mWarningCallCount = 0;
|
|
108 |
HbMessageBoxData::mInformationCallCount = 0;
|
35
|
109 |
|
|
110 |
// - invalid additional
|
30
|
111 |
additional = QVariant();
|
35
|
112 |
testObject.showStatusMsgSlot(VideoCollectionCommon::statusMultipleDeleteFail, additional);
|
|
113 |
HbMessageBoxData::mWarningCallCount = 0;
|
|
114 |
HbMessageBoxData::mInformationCallCount = 0;
|
30
|
115 |
|
35
|
116 |
// status: VideoCollectionCommon::statusMultipleRemoveFail (additional not needed)
|
|
117 |
additional = QVariant();
|
|
118 |
testObject.showStatusMsgSlot(VideoCollectionCommon::statusMultiRemoveFail, additional);
|
|
119 |
QVERIFY(HbMessageBoxData::mWarningCallCount == 1);
|
|
120 |
QVERIFY(HbMessageBoxData::mInformationCallCount == 0);
|
|
121 |
HbMessageBoxData::mWarningCallCount = 0;
|
|
122 |
HbMessageBoxData::mInformationCallCount = 0;
|
|
123 |
|
|
124 |
// status: VideoCollectionCommon::statusVideosAddedToCollection
|
|
125 |
additional = txt;
|
|
126 |
testObject.showStatusMsgSlot(VideoCollectionCommon::statusVideosAddedToCollection, additional);
|
34
|
127 |
QVERIFY(HbMessageBoxData::mWarningCallCount == 0);
|
|
128 |
QVERIFY(HbMessageBoxData::mInformationCallCount == 1);
|
|
129 |
HbMessageBoxData::mWarningCallCount = 0;
|
|
130 |
HbMessageBoxData::mInformationCallCount = 0;
|
35
|
131 |
|
|
132 |
// - invalid additional
|
30
|
133 |
additional = QVariant();
|
35
|
134 |
testObject.showStatusMsgSlot(VideoCollectionCommon::statusVideosAddedToCollection, additional);
|
34
|
135 |
QVERIFY(HbMessageBoxData::mWarningCallCount == 0);
|
|
136 |
QVERIFY(HbMessageBoxData::mInformationCallCount == 0);
|
30
|
137 |
|
35
|
138 |
// status: VideoCollectionCommon::statusAllVideosAlreadyInCollection
|
|
139 |
testObject.showStatusMsgSlot(VideoCollectionCommon::statusAllVideosAlreadyInCollection, additional);
|
|
140 |
QVERIFY(HbMessageBoxData::mWarningCallCount == 1);
|
|
141 |
QVERIFY(HbMessageBoxData::mInformationCallCount == 0);
|
|
142 |
HbMessageBoxData::mWarningCallCount = 0;
|
|
143 |
HbMessageBoxData::mInformationCallCount = 0;
|
30
|
144 |
|
35
|
145 |
// status: VideoCollectionCommon::statusDeleteInProgress
|
30
|
146 |
additional = txt;
|
35
|
147 |
testObject.showStatusMsgSlot(VideoCollectionCommon::statusDeleteInProgress, additional);
|
|
148 |
QVERIFY(HbMessageBoxData::mWarningCallCount == 0);
|
|
149 |
QVERIFY(HbMessageBoxData::mInformationCallCount == 1);
|
|
150 |
HbMessageBoxData::mWarningCallCount = 0;
|
|
151 |
HbMessageBoxData::mInformationCallCount = 0;
|
|
152 |
|
|
153 |
// - invalid additional
|
|
154 |
additional = QVariant();
|
|
155 |
testObject.showStatusMsgSlot(VideoCollectionCommon::statusDeleteInProgress, additional);
|
|
156 |
QVERIFY(HbMessageBoxData::mWarningCallCount == 0);
|
|
157 |
QVERIFY(HbMessageBoxData::mInformationCallCount == 0);
|
30
|
158 |
}
|
|
159 |
|
|
160 |
// -----------------------------------------------------------------------------
|
|
161 |
// testSaveSortingValues
|
|
162 |
// -----------------------------------------------------------------------------
|
|
163 |
//
|
|
164 |
void TestVideoVideoCollectionViewUtils::testSaveSortingValues()
|
|
165 |
{
|
|
166 |
VideoCollectionViewUtils &testObject(VideoCollectionViewUtils::instance());
|
|
167 |
CRepository::setNewLLeave(true);
|
|
168 |
int sortRole = VideoCollectionCommon::KeyDateTime;
|
|
169 |
Qt::SortOrder sortOrder = Qt::AscendingOrder;
|
|
170 |
|
|
171 |
QVERIFY(testObject.saveSortingValues(sortRole, sortOrder) < 0);
|
|
172 |
CRepository::setNewLLeave(false);
|
|
173 |
|
|
174 |
CRepository::setSetFail(0);
|
|
175 |
QVERIFY(testObject.saveSortingValues(sortRole, sortOrder) < 0);
|
|
176 |
|
|
177 |
CRepository::setSetFail(1);
|
|
178 |
QVERIFY(testObject.saveSortingValues(sortRole, sortOrder) < 0);
|
|
179 |
|
|
180 |
CRepository::setSetFail(255);
|
|
181 |
QVERIFY(testObject.saveSortingValues(sortRole, sortOrder) == 0);
|
|
182 |
QCOMPARE(CRepository::getRoleValue(), sortRole);
|
|
183 |
QCOMPARE(CRepository::getOrderValue(), (int)sortOrder);
|
|
184 |
}
|
|
185 |
|
|
186 |
// -----------------------------------------------------------------------------
|
|
187 |
// testLoadSortingValues
|
|
188 |
// -----------------------------------------------------------------------------
|
|
189 |
//
|
|
190 |
void TestVideoVideoCollectionViewUtils::testLoadSortingValues()
|
|
191 |
{
|
|
192 |
VideoCollectionViewUtils &testObject(VideoCollectionViewUtils::instance());
|
|
193 |
|
|
194 |
int sortRole(-1);
|
|
195 |
Qt::SortOrder sortOrder(Qt::AscendingOrder);
|
|
196 |
|
35
|
197 |
CRepository::setRoleValue(Qt::DisplayRole);
|
|
198 |
CRepository::setOrderValue(Qt::AscendingOrder);
|
|
199 |
|
|
200 |
CRepository::setNewLLeave(true);
|
|
201 |
testObject.mSortRole = -1;
|
|
202 |
testObject.mSortOrder = Qt::DescendingOrder;
|
30
|
203 |
QVERIFY(testObject.loadSortingValues(sortRole, sortOrder) < 0);
|
|
204 |
QCOMPARE(sortRole, -1);
|
35
|
205 |
QCOMPARE(sortOrder, Qt::DescendingOrder);
|
|
206 |
|
30
|
207 |
CRepository::setNewLLeave(false);
|
|
208 |
CRepository::setGetFail(0);
|
35
|
209 |
testObject.mSortRole = -1;
|
|
210 |
testObject.mSortOrder = Qt::DescendingOrder;
|
30
|
211 |
QVERIFY(testObject.loadSortingValues(sortRole, sortOrder) < 0);
|
|
212 |
QCOMPARE(sortRole, -1);
|
35
|
213 |
QCOMPARE(sortOrder, Qt::DescendingOrder);
|
30
|
214 |
|
|
215 |
CRepository::setGetFail(1);
|
35
|
216 |
testObject.mSortRole = -1;
|
|
217 |
testObject.mSortOrder = Qt::DescendingOrder;
|
30
|
218 |
QVERIFY(testObject.loadSortingValues(sortRole, sortOrder) < 0);
|
35
|
219 |
QCOMPARE(sortRole, (int)Qt::DisplayRole);
|
|
220 |
QCOMPARE(sortOrder, Qt::DescendingOrder);
|
30
|
221 |
|
|
222 |
CRepository::setGetFail(255);
|
35
|
223 |
testObject.mSortRole = -1;
|
|
224 |
testObject.mSortOrder = Qt::DescendingOrder;
|
30
|
225 |
QVERIFY(testObject.loadSortingValues(sortRole, sortOrder) == 0);
|
|
226 |
QCOMPARE(sortRole, (int)Qt::DisplayRole);
|
35
|
227 |
QCOMPARE(sortOrder, Qt::AscendingOrder);
|
30
|
228 |
}
|
|
229 |
|
34
|
230 |
// -----------------------------------------------------------------------------
|
|
231 |
// testGetServiceIconStrings
|
|
232 |
// -----------------------------------------------------------------------------
|
|
233 |
//
|
|
234 |
void TestVideoVideoCollectionViewUtils::testGetServiceIconStrings()
|
|
235 |
{
|
|
236 |
VideoCollectionViewUtils &testObject(VideoCollectionViewUtils::instance());
|
|
237 |
CRepository::setNewLLeave(true);
|
|
238 |
_LIT(KExpectedTDesValue, "expected");
|
|
239 |
CRepository::setTDesValue(KExpectedTDesValue());
|
|
240 |
QString expected((QChar*)KExpectedTDesValue().Ptr(),KExpectedTDesValue().Length());
|
|
241 |
|
|
242 |
QString icon;
|
|
243 |
QString pressed;
|
|
244 |
QVERIFY(testObject.getServiceIconStrings(icon, pressed) < 0);
|
|
245 |
QVERIFY(icon.isNull());
|
|
246 |
QVERIFY(pressed.isNull());
|
|
247 |
|
|
248 |
CRepository::setNewLLeave(false);
|
|
249 |
CRepository::setGetFail(0);
|
|
250 |
QVERIFY(testObject.getServiceIconStrings(icon, pressed) < 0);
|
|
251 |
QVERIFY(icon.isNull());
|
|
252 |
QVERIFY(pressed.isNull());
|
|
253 |
|
|
254 |
CRepository::setGetFail(1);
|
|
255 |
QVERIFY(testObject.getServiceIconStrings(icon, pressed) < 0);
|
|
256 |
QVERIFY(icon.isNull());
|
|
257 |
QVERIFY(pressed.isNull());
|
|
258 |
|
|
259 |
CRepository::setGetFail(255);
|
|
260 |
QVERIFY(testObject.getServiceIconStrings(icon, pressed) == 0);
|
|
261 |
QCOMPARE(icon, expected);
|
|
262 |
QCOMPARE(pressed, expected);
|
|
263 |
}
|
|
264 |
|
|
265 |
// -----------------------------------------------------------------------------
|
|
266 |
// testGetServiceIconStrings
|
|
267 |
// -----------------------------------------------------------------------------
|
|
268 |
//
|
|
269 |
void TestVideoVideoCollectionViewUtils::testGetServiceUriString()
|
|
270 |
{
|
|
271 |
VideoCollectionViewUtils &testObject(VideoCollectionViewUtils::instance());
|
|
272 |
CRepository::setNewLLeave(true);
|
|
273 |
_LIT(KExpectedTDesValue, "expected");
|
|
274 |
CRepository::setTDesValue(KExpectedTDesValue());
|
|
275 |
QString expected((QChar*)KExpectedTDesValue().Ptr(),KExpectedTDesValue().Length());
|
|
276 |
|
|
277 |
QVERIFY(testObject.getServiceUriString().isNull());
|
|
278 |
|
|
279 |
CRepository::setNewLLeave(false);
|
|
280 |
CRepository::setGetFail(0);
|
|
281 |
QVERIFY(testObject.getServiceUriString().isNull());
|
|
282 |
|
|
283 |
CRepository::setGetFail(255);
|
|
284 |
QCOMPARE(testObject.getServiceUriString(), expected);
|
|
285 |
}
|
|
286 |
|
30
|
287 |
// End of file
|
|
288 |
|
|
289 |
|
|
290 |
|