|
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 VideoCollectionWrapperPrivate |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDES |
|
21 #include <qabstractitemmodel.h> |
|
22 #include <hbapplication.h> |
|
23 #include "testvideocollectionwrapper_p.h" |
|
24 #include "videocollectionwrapper.h" |
|
25 #include "videocollectioncommon.h" |
|
26 #include "videolistdatamodel.h" |
|
27 #include "videosortfilterproxymodel.h" |
|
28 #include "videocollectionclient.h" |
|
29 #include "vcxmyvideosdefs.h" |
|
30 |
|
31 #define private public |
|
32 #include "videocollectionwrapper_p.h" |
|
33 #undef private |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // main |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 int main(int argc, char *argv[]) |
|
40 { |
|
41 TestVideCollectionWrapper_p tv; |
|
42 HbApplication app(argc, argv); |
|
43 int res; |
|
44 if(argc > 1) |
|
45 { |
|
46 res = QTest::qExec(&tv, argc, argv); |
|
47 } |
|
48 else |
|
49 { |
|
50 char *pass[3]; |
|
51 pass[0] = argv[0]; |
|
52 pass[1] = "-o"; |
|
53 pass[2] = "c:\\data\\testvideocollectionwrapper_p.txt"; |
|
54 res = QTest::qExec(&tv, 3, pass); |
|
55 } |
|
56 |
|
57 return res; |
|
58 } |
|
59 |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // init |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 void TestVideCollectionWrapper_p::init() |
|
66 { |
|
67 mTestObject = new VideoCollectionWrapperPrivate(); |
|
68 QVERIFY(mTestObject); |
|
69 } |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // cleanup |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 void TestVideCollectionWrapper_p::cleanup() |
|
76 { |
|
77 delete mTestObject; |
|
78 mTestObject = 0; |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // testGetModelInitFail |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 void TestVideCollectionWrapper_p::testGetModelInitFail() |
|
86 { |
|
87 QVERIFY(mTestObject); |
|
88 |
|
89 VideoSortFilterProxyModel *proxyGotten = 0; |
|
90 |
|
91 // source model init fails |
|
92 VideoListDataModel::mInitFails = true; |
|
93 VideoCollectionCommon::TModelType type = VideoCollectionCommon::EModelTypeAllVideos; |
|
94 proxyGotten = mTestObject->getModel(type); |
|
95 QVERIFY(!proxyGotten); |
|
96 |
|
97 VideoListDataModel::mInitFails = false; |
|
98 VideoSortFilterProxyModel::setInitFailure(true); |
|
99 |
|
100 // VideoCollectionWrapper::EAllvideos -> init fails |
|
101 type = VideoCollectionCommon::EModelTypeAllVideos; |
|
102 proxyGotten = mTestObject->getModel(type); |
|
103 QVERIFY(!proxyGotten); |
|
104 |
|
105 // VideoCollectionWrapper::ECollections -> init fails |
|
106 type = VideoCollectionCommon::EModelTypeAllVideos; |
|
107 proxyGotten = mTestObject->getModel(type); |
|
108 QVERIFY(!proxyGotten); |
|
109 |
|
110 // VideoCollectionWrapper::EGeneric -> init fails |
|
111 type = VideoCollectionCommon::EModelTypeGeneric; |
|
112 proxyGotten = mTestObject->getModel(type); |
|
113 QVERIFY(!proxyGotten); |
|
114 |
|
115 type = VideoCollectionCommon::EModelTypeCollectionContent; |
|
116 proxyGotten = mTestObject->getModel(type); |
|
117 QVERIFY(!proxyGotten); |
|
118 } |
|
119 |
|
120 |
|
121 // ----------------------------------------------------------------------------- |
|
122 // testGetModelSucceed |
|
123 // ----------------------------------------------------------------------------- |
|
124 // |
|
125 void TestVideCollectionWrapper_p::testGetModelSucceed() |
|
126 { |
|
127 QVERIFY(mTestObject); |
|
128 |
|
129 VideoSortFilterProxyModel *proxyGotten = 0; |
|
130 VideoSortFilterProxyModel::setInitFailure(false); |
|
131 VideoCollectionCommon::TModelType type = VideoCollectionCommon::EModelTypeAllVideos; |
|
132 |
|
133 // VideoCollectionWrapper::EAllvideos |
|
134 type = VideoCollectionCommon::EModelTypeAllVideos; |
|
135 proxyGotten = mTestObject->getModel(type); |
|
136 QVERIFY(proxyGotten); |
|
137 QVERIFY(proxyGotten->mType == type); |
|
138 proxyGotten = mTestObject->getModel(type); |
|
139 QVERIFY(proxyGotten); |
|
140 QVERIFY(proxyGotten->mType == type); |
|
141 delete proxyGotten; |
|
142 proxyGotten = 0; |
|
143 |
|
144 // VideoCollectionWrapper::ECollections |
|
145 type = VideoCollectionCommon::EModelTypeCollections; |
|
146 proxyGotten = mTestObject->getModel(type); |
|
147 QVERIFY(proxyGotten); |
|
148 QVERIFY(proxyGotten->mType == type); |
|
149 proxyGotten = mTestObject->getModel(type); |
|
150 QVERIFY(proxyGotten); |
|
151 QVERIFY(proxyGotten->mType == type); |
|
152 delete proxyGotten; |
|
153 proxyGotten = 0; |
|
154 |
|
155 // VideoCollectionWrapper::EGeneric |
|
156 type = VideoCollectionCommon::EModelTypeGeneric; |
|
157 proxyGotten = mTestObject->getModel(type); |
|
158 QVERIFY(proxyGotten); |
|
159 QVERIFY(proxyGotten->mType == type); |
|
160 proxyGotten = mTestObject->getModel(type); |
|
161 QVERIFY(proxyGotten); |
|
162 QVERIFY(proxyGotten->mType == type); |
|
163 delete proxyGotten; |
|
164 proxyGotten = 0; |
|
165 |
|
166 // VideoCollectionWrapper::ECollectionContent |
|
167 type = VideoCollectionCommon::EModelTypeCollectionContent; |
|
168 proxyGotten = mTestObject->getModel(type); |
|
169 QVERIFY(proxyGotten); |
|
170 QVERIFY(proxyGotten->mType == type); |
|
171 proxyGotten = mTestObject->getModel(type); |
|
172 QVERIFY(proxyGotten); |
|
173 QVERIFY(proxyGotten->mType == type); |
|
174 delete proxyGotten; |
|
175 proxyGotten = 0; |
|
176 } |
|
177 |
|
178 // ----------------------------------------------------------------------------- |
|
179 // testAboutToQuitSlot |
|
180 // ----------------------------------------------------------------------------- |
|
181 // |
|
182 void TestVideCollectionWrapper_p::testAboutToQuitSlot() |
|
183 { |
|
184 QVERIFY(mTestObject); |
|
185 connect(this, SIGNAL(testSignal()), mTestObject, SLOT(aboutToQuitSlot())); |
|
186 |
|
187 VideoSortFilterProxyModel *proxyGotten = 0; |
|
188 VideoSortFilterProxyModel::setInitFailure(false); |
|
189 VideoCollectionCommon::TModelType type = VideoCollectionCommon::EModelTypeAllVideos; |
|
190 proxyGotten = mTestObject->getModel(type); |
|
191 QVERIFY(proxyGotten); |
|
192 QVERIFY(!mTestObject->mSourceModel.isNull()); |
|
193 emit testSignal(); |
|
194 QVERIFY(mTestObject->mSourceModel.isNull()); |
|
195 |
|
196 emit testSignal(); |
|
197 QVERIFY(mTestObject->mSourceModel.isNull()); |
|
198 |
|
199 disconnect(this, SIGNAL(testSignal()), mTestObject, SLOT(aboutToQuitSlot())); |
|
200 } |
|
201 |
|
202 |
|
203 // End of file |
|
204 |
|
205 |
|
206 |