40
|
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: TestVideoSettingsGroup class implementation
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
// INCLUDE FILES
|
|
19 |
#include <QtTest/QtTest>
|
|
20 |
#include <qdebug.h>
|
|
21 |
#include <hbapplication.h>
|
|
22 |
#include <hblineedit.h>
|
|
23 |
#include <hbinputeditorinterface.h>
|
|
24 |
#include <hbinputstandardfilters.h>
|
|
25 |
#include <MPSettEngPluginImplementationUIDs.hrh>
|
|
26 |
|
|
27 |
#include "testvideosettingsgroup.h"
|
|
28 |
#include "videosettingsaccesspointentry.h"
|
|
29 |
#include "mpsettingsmodel.h"
|
|
30 |
#include "hbdataformmodel.h"
|
|
31 |
#include "cpitemdatahelper.h"
|
|
32 |
#include "hbvalidator.h"
|
|
33 |
|
|
34 |
// trick to get access to protected/private members.
|
|
35 |
#define private public
|
|
36 |
#include "videosettingsgroup.h"
|
|
37 |
#undef private
|
|
38 |
|
|
39 |
// ---------------------------------------------------------------------------
|
|
40 |
// main
|
|
41 |
// ---------------------------------------------------------------------------
|
|
42 |
//
|
|
43 |
int main(int argc, char *argv[])
|
|
44 |
{
|
|
45 |
HbApplication app(argc, argv);
|
|
46 |
|
|
47 |
TestVideoSettingsGroup tc;
|
|
48 |
|
|
49 |
char *pass[3];
|
|
50 |
pass[0] = argv[0];
|
|
51 |
pass[1] = "-o";
|
|
52 |
pass[2] = "c:\\data\\testvideosettingsgroup.txt";
|
|
53 |
|
|
54 |
return QTest::qExec(&tc, 3, pass);
|
|
55 |
}
|
|
56 |
|
|
57 |
// ---------------------------------------------------------------------------
|
|
58 |
// initTestCase
|
|
59 |
// ---------------------------------------------------------------------------
|
|
60 |
//
|
|
61 |
void TestVideoSettingsGroup::initTestCase()
|
|
62 |
{
|
|
63 |
mItemHelper = new CpItemDataHelper;
|
|
64 |
}
|
|
65 |
|
|
66 |
// ---------------------------------------------------------------------------
|
|
67 |
// cleanupTestCase
|
|
68 |
// ---------------------------------------------------------------------------
|
|
69 |
//
|
|
70 |
void TestVideoSettingsGroup::cleanupTestCase()
|
|
71 |
{
|
|
72 |
delete mItemHelper;
|
|
73 |
mItemHelper = 0;
|
|
74 |
}
|
|
75 |
|
|
76 |
// ---------------------------------------------------------------------------
|
|
77 |
// init
|
|
78 |
// ---------------------------------------------------------------------------
|
|
79 |
//
|
|
80 |
void TestVideoSettingsGroup::init()
|
|
81 |
{
|
|
82 |
CMPSettingsModel::mImplUid = TUid::Null();
|
|
83 |
CMPSettingsModel::mConfigMode = -1;
|
|
84 |
CMPSettingsModel::mProxyMode = 0;
|
|
85 |
CMPSettingsModel::mHostName = QString("testhostname");
|
|
86 |
CMPSettingsModel::mProxyPort = 4096;
|
|
87 |
CMPSettingsModel::mMinUdpPort = 2048;
|
|
88 |
CMPSettingsModel::mMaxUdpPort = 8080;
|
|
89 |
CMPSettingsModel::mStoreSettingsCount = 0;
|
|
90 |
CMPSettingsModel::mDestructorCount = 0;
|
|
91 |
CMPSettingsModel::mApId = 5;
|
|
92 |
HbEditorInterface::mFilter = 0;
|
|
93 |
|
|
94 |
mTestObject = new VideoSettingsGroup(*mItemHelper);
|
|
95 |
}
|
|
96 |
|
|
97 |
// ---------------------------------------------------------------------------
|
|
98 |
// cleanup
|
|
99 |
// ---------------------------------------------------------------------------
|
|
100 |
//
|
|
101 |
void TestVideoSettingsGroup::cleanup()
|
|
102 |
{
|
|
103 |
disconnect();
|
|
104 |
delete mTestObject;
|
|
105 |
mTestObject = 0;
|
|
106 |
}
|
|
107 |
|
|
108 |
// ---------------------------------------------------------------------------
|
|
109 |
// testSettingsConstruction
|
|
110 |
// ---------------------------------------------------------------------------
|
|
111 |
//
|
|
112 |
void TestVideoSettingsGroup::testSettingsConstruction()
|
|
113 |
{
|
|
114 |
QVERIFY( mTestObject->mSettingsModel != 0 );
|
|
115 |
QCOMPARE( mTestObject->mSettingsModel->mConfigMode, (int)EConfigUser);
|
|
116 |
QVERIFY( CMPSettingsModel::mImplUid == TUid::Uid(KMPSettEngImplUidROP) );
|
|
117 |
|
|
118 |
// verify also the itemShown connection to form here.
|
|
119 |
QCOMPARE( mItemHelper->mFormConnection.signal, SIGNAL(itemShown(const QModelIndex)) );
|
|
120 |
QVERIFY( mItemHelper->mFormConnection.receiver == mTestObject );
|
|
121 |
QCOMPARE( mItemHelper->mFormConnection.method, SLOT(itemShown(const QModelIndex)) );
|
41
|
122 |
|
|
123 |
// and that group has correct label
|
|
124 |
QCOMPARE( mTestObject->label(), hbTrId("txt_videos_subhead_video_streaming_settings") );
|
40
|
125 |
}
|
|
126 |
|
|
127 |
// ---------------------------------------------------------------------------
|
|
128 |
// testAccessPointConstruction
|
|
129 |
// ---------------------------------------------------------------------------
|
|
130 |
//
|
|
131 |
void TestVideoSettingsGroup::testAccessPointConstruction()
|
|
132 |
{
|
|
133 |
QVERIFY( mTestObject->mAccessPointItem != 0 );
|
|
134 |
QVERIFY( mTestObject->indexOf(static_cast<HbDataFormModelItem*>(mTestObject->mAccessPointItem)) >= 0 );
|
|
135 |
QCOMPARE( mTestObject->mAccessPointItem->mText, hbTrId("txt_videos_dblist_access_point") );
|
|
136 |
QCOMPARE( mTestObject->mAccessPointItem->mApId, (uint)CMPSettingsModel::mApId );
|
|
137 |
}
|
|
138 |
|
|
139 |
// ---------------------------------------------------------------------------
|
|
140 |
// testLowestUdpPortConstruction
|
|
141 |
// ---------------------------------------------------------------------------
|
|
142 |
//
|
|
143 |
void TestVideoSettingsGroup::testLowestUdpPortConstruction()
|
|
144 |
{
|
|
145 |
QVERIFY( mTestObject->mLowestUDPPortItem != 0 );
|
|
146 |
QVERIFY( mTestObject->indexOf(mTestObject->mLowestUDPPortItem) >= 0 );
|
|
147 |
QCOMPARE( mTestObject->mLowestUDPPortItem->contentWidgetData(QString("maxRows")).toInt(), 1);
|
|
148 |
QCOMPARE( mTestObject->mLowestUDPPortItem->contentWidgetData(QString("text")).toString(),
|
|
149 |
QString::number(CMPSettingsModel::mMinUdpPort) );
|
|
150 |
|
|
151 |
ConnectionHolder connection = mItemHelper->mConnections[mTestObject->mLowestUDPPortItem];
|
|
152 |
QCOMPARE( connection.signal, SIGNAL(editingFinished()) );
|
|
153 |
QVERIFY( connection.receiver == mTestObject );
|
|
154 |
QCOMPARE( connection.method, SLOT(lowestUdpPortEditingFinished()) );
|
|
155 |
}
|
|
156 |
|
|
157 |
// ---------------------------------------------------------------------------
|
|
158 |
// testHighestUdpPortConstruction
|
|
159 |
// ---------------------------------------------------------------------------
|
|
160 |
//
|
|
161 |
void TestVideoSettingsGroup::testHighestUdpPortConstruction()
|
|
162 |
{
|
|
163 |
QVERIFY( mTestObject->mHighestUDPPortItem != 0 );
|
|
164 |
QVERIFY( mTestObject->indexOf(mTestObject->mHighestUDPPortItem) >= 0 );
|
|
165 |
QCOMPARE( mTestObject->mHighestUDPPortItem->contentWidgetData(QString("maxRows")).toInt(), 1);
|
|
166 |
QCOMPARE( mTestObject->mHighestUDPPortItem->contentWidgetData(QString("text")).toString(),
|
|
167 |
QString::number(CMPSettingsModel::mMaxUdpPort) );
|
|
168 |
|
|
169 |
ConnectionHolder connection = mItemHelper->mConnections[mTestObject->mHighestUDPPortItem];
|
|
170 |
QCOMPARE( connection.signal, SIGNAL(editingFinished()) );
|
|
171 |
QVERIFY( connection.receiver == mTestObject );
|
|
172 |
QCOMPARE( connection.method, SLOT(highestUdpPortEditingFinished()) );
|
|
173 |
}
|
|
174 |
|
|
175 |
// ---------------------------------------------------------------------------
|
|
176 |
// testUseProxyConstruction
|
|
177 |
// ---------------------------------------------------------------------------
|
|
178 |
//
|
|
179 |
void TestVideoSettingsGroup::testUseProxyConstruction()
|
|
180 |
{
|
|
181 |
QVERIFY( mTestObject->mUseProxyItem != 0 );
|
|
182 |
QVERIFY( mTestObject->indexOf(mTestObject->mUseProxyItem) >= 0 );
|
|
183 |
QCOMPARE( mTestObject->mUseProxyItem->contentWidgetData(QString("checked")).toBool(),
|
|
184 |
CMPSettingsModel::mProxyMode == 1 );
|
|
185 |
|
|
186 |
// connection checking in the testItemShown.
|
|
187 |
}
|
|
188 |
|
|
189 |
// ---------------------------------------------------------------------------
|
|
190 |
// testProxyServerConstruction
|
|
191 |
// ---------------------------------------------------------------------------
|
|
192 |
//
|
|
193 |
void TestVideoSettingsGroup::testProxyServerConstruction()
|
|
194 |
{
|
|
195 |
QVERIFY( mTestObject->mProxyServerItem != 0 );
|
|
196 |
QVERIFY( mTestObject->indexOf(mTestObject->mProxyServerItem) >= 0 );
|
|
197 |
QCOMPARE( mTestObject->mProxyServerItem->contentWidgetData(QString("maxRows")).toInt(), 1);
|
|
198 |
QCOMPARE( mTestObject->mProxyServerItem->contentWidgetData(QString("text")).toString(),
|
|
199 |
CMPSettingsModel::mHostName );
|
|
200 |
QCOMPARE( mTestObject->mProxyServerItem->contentWidgetData(QString("placeholderText")).toString(),
|
|
201 |
hbTrId("txt_videos_dblist_none") );
|
|
202 |
|
|
203 |
ConnectionHolder connection = mItemHelper->mConnections[mTestObject->mProxyServerItem];
|
|
204 |
QCOMPARE( connection.signal, SIGNAL(editingFinished()) );
|
|
205 |
QVERIFY( connection.receiver == mTestObject );
|
|
206 |
QCOMPARE( connection.method, SLOT(proxyServerEditingFinished()) );
|
|
207 |
}
|
|
208 |
|
|
209 |
// ---------------------------------------------------------------------------
|
|
210 |
// testProxyPortConstruction
|
|
211 |
// ---------------------------------------------------------------------------
|
|
212 |
//
|
|
213 |
void TestVideoSettingsGroup::testProxyPortConstruction()
|
|
214 |
{
|
|
215 |
QVERIFY( mTestObject->mProxyPortItem != 0 );
|
|
216 |
QVERIFY( mTestObject->indexOf(mTestObject->mProxyPortItem) >= 0 );
|
|
217 |
QCOMPARE( mTestObject->mProxyPortItem->contentWidgetData(QString("maxRows")).toInt(), 1);
|
|
218 |
QCOMPARE( mTestObject->mProxyPortItem->contentWidgetData(QString("text")).toString(),
|
|
219 |
QString::number(CMPSettingsModel::mProxyPort) );
|
|
220 |
|
|
221 |
ConnectionHolder connection = mItemHelper->mConnections[mTestObject->mProxyPortItem];
|
|
222 |
QCOMPARE( connection.signal, SIGNAL(editingFinished()) );
|
|
223 |
QVERIFY( connection.receiver == mTestObject );
|
|
224 |
QCOMPARE( connection.method, SLOT(proxyPortEditingFinished()) );
|
|
225 |
}
|
|
226 |
|
|
227 |
// ---------------------------------------------------------------------------
|
|
228 |
// testDestructor
|
|
229 |
// ---------------------------------------------------------------------------
|
|
230 |
//
|
|
231 |
void TestVideoSettingsGroup::testDestructor()
|
|
232 |
{
|
|
233 |
delete mTestObject;
|
|
234 |
mTestObject = 0;
|
|
235 |
QCOMPARE( CMPSettingsModel::mStoreSettingsCount, 1 );
|
|
236 |
QCOMPARE( CMPSettingsModel::mDestructorCount, 1 );
|
|
237 |
}
|
|
238 |
|
|
239 |
// ---------------------------------------------------------------------------
|
|
240 |
// testDestructor
|
|
241 |
// ---------------------------------------------------------------------------
|
|
242 |
//
|
|
243 |
void TestVideoSettingsGroup::testGetAccessPointId()
|
|
244 |
{
|
|
245 |
CMPSettingsModel::mApId = 4;
|
|
246 |
|
|
247 |
QCOMPARE( mTestObject->getAccessPointId(), (uint)CMPSettingsModel::mApId );
|
|
248 |
}
|
|
249 |
|
|
250 |
// ---------------------------------------------------------------------------
|
|
251 |
// testDestructor
|
|
252 |
// ---------------------------------------------------------------------------
|
|
253 |
//
|
|
254 |
void TestVideoSettingsGroup::testSetAccessPointId()
|
|
255 |
{
|
41
|
256 |
QString string("test");
|
40
|
257 |
CMPSettingsModel::mApId = -1;
|
41
|
258 |
mTestObject->mUseProxyItem->setContentWidgetData(QString("checked"), true);
|
|
259 |
mTestObject->mProxyServerItem->setContentWidgetData(QString("text"), string);
|
|
260 |
CMPSettingsModel::mHostName = string;
|
40
|
261 |
|
41
|
262 |
// given ap id is different from the one that is saved in settingsmodel.
|
|
263 |
uint ap = 3;
|
40
|
264 |
mTestObject->setAccessPointId(ap);
|
41
|
265 |
QCOMPARE( CMPSettingsModel::mApId, (int)ap );
|
|
266 |
QVERIFY( mTestObject->mUseProxyItem->contentWidgetData(QString("checked")).toBool() == false );
|
|
267 |
QCOMPARE( mTestObject->mProxyServerItem->contentWidgetData(QString("text")).toString(), string );
|
|
268 |
QCOMPARE( CMPSettingsModel::mHostName, string );
|
40
|
269 |
|
41
|
270 |
mTestObject->mUseProxyItem->setContentWidgetData(QString("checked"), true);
|
|
271 |
mTestObject->mProxyServerItem->setContentWidgetData(QString("text"), string);
|
|
272 |
CMPSettingsModel::mHostName = string;
|
|
273 |
|
|
274 |
// given ap id is the same than the one that is saved in settingsmodel.
|
|
275 |
mTestObject->setAccessPointId(ap);
|
40
|
276 |
QCOMPARE( CMPSettingsModel::mApId, (int)ap );
|
41
|
277 |
QVERIFY( mTestObject->mUseProxyItem->contentWidgetData(QString("checked")).toBool() );
|
|
278 |
QCOMPARE( mTestObject->mProxyServerItem->contentWidgetData(QString("text")).toString(), string );
|
|
279 |
QCOMPARE( CMPSettingsModel::mHostName, string );
|
40
|
280 |
}
|
|
281 |
|
|
282 |
// ---------------------------------------------------------------------------
|
|
283 |
// testLowestUdpPortEditingFinished
|
|
284 |
// ---------------------------------------------------------------------------
|
|
285 |
//
|
|
286 |
void TestVideoSettingsGroup::testLowestUdpPortEditingFinished()
|
|
287 |
{
|
|
288 |
connect(this, SIGNAL(testTextSignal()),
|
|
289 |
mTestObject, SLOT(lowestUdpPortEditingFinished()));
|
|
290 |
|
41
|
291 |
// normal case where min port is less than max port and both are in acceptable range.
|
|
292 |
QString highText("10000");
|
40
|
293 |
mTestObject->mHighestUDPPortItem->setContentWidgetData(QString("text"), highText);
|
|
294 |
|
41
|
295 |
QString testString("1024");
|
|
296 |
mTestObject->mLowestUDPPortItem->setContentWidgetData(QString("text"), testString);
|
|
297 |
|
|
298 |
emit testTextSignal();
|
|
299 |
|
|
300 |
QCOMPARE( CMPSettingsModel::mMinUdpPort, testString.toInt() );
|
|
301 |
|
|
302 |
// min port greater than max port, both are in acceptable range.
|
|
303 |
CMPSettingsModel::mMinUdpPort = 0;
|
|
304 |
mTestObject->mLowestUDPPortItem->setContentWidgetData(QString("text"), QString("10001"));
|
|
305 |
|
|
306 |
emit testTextSignal();
|
|
307 |
|
|
308 |
QCOMPARE( CMPSettingsModel::mMinUdpPort, highText.toInt() );
|
|
309 |
|
|
310 |
// min port same as max port and in acceptable range.
|
|
311 |
CMPSettingsModel::mMinUdpPort = 0;
|
|
312 |
testString = "10000";
|
40
|
313 |
mTestObject->mLowestUDPPortItem->setContentWidgetData(QString("text"), testString);
|
|
314 |
|
|
315 |
emit testTextSignal();
|
|
316 |
|
|
317 |
QCOMPARE( CMPSettingsModel::mMinUdpPort, testString.toInt() );
|
|
318 |
|
41
|
319 |
// min port less than 1024
|
40
|
320 |
CMPSettingsModel::mMinUdpPort = 0;
|
41
|
321 |
mTestObject->mLowestUDPPortItem->setContentWidgetData(QString("text"), QString("1023"));
|
40
|
322 |
|
|
323 |
emit testTextSignal();
|
|
324 |
|
41
|
325 |
QCOMPARE( CMPSettingsModel::mMinUdpPort, 1024 );
|
|
326 |
QCOMPARE( mTestObject->mLowestUDPPortItem->contentWidgetData(QString("text")).toString(), QString("1024") );
|
40
|
327 |
|
41
|
328 |
// min port greater than 65535
|
40
|
329 |
CMPSettingsModel::mMinUdpPort = 0;
|
41
|
330 |
mTestObject->mHighestUDPPortItem->setContentWidgetData(QString("text"), QString("65536"));
|
|
331 |
mTestObject->mLowestUDPPortItem->setContentWidgetData(QString("text"), QString("65536"));
|
40
|
332 |
|
|
333 |
emit testTextSignal();
|
|
334 |
|
41
|
335 |
QCOMPARE( CMPSettingsModel::mMinUdpPort, 65535 );
|
|
336 |
QCOMPARE( mTestObject->mLowestUDPPortItem->contentWidgetData(QString("text")).toString(), QString("65535") );
|
|
337 |
|
|
338 |
// min port field empty
|
|
339 |
CMPSettingsModel::mMinUdpPort = 0;
|
|
340 |
mTestObject->mLowestUDPPortItem->setContentWidgetData(QString("text"), QString(""));
|
|
341 |
|
|
342 |
emit testTextSignal();
|
|
343 |
|
|
344 |
QCOMPARE( CMPSettingsModel::mMinUdpPort, 1024 );
|
|
345 |
QCOMPARE( mTestObject->mLowestUDPPortItem->contentWidgetData(QString("text")).toString(), QString("1024") );
|
40
|
346 |
}
|
|
347 |
|
|
348 |
// ---------------------------------------------------------------------------
|
|
349 |
// testHighestUdpPortEditingFinished
|
|
350 |
// ---------------------------------------------------------------------------
|
|
351 |
//
|
|
352 |
void TestVideoSettingsGroup::testHighestUdpPortEditingFinished()
|
|
353 |
{
|
|
354 |
connect(this, SIGNAL(testTextSignal()),
|
|
355 |
mTestObject, SLOT(highestUdpPortEditingFinished()));
|
|
356 |
|
41
|
357 |
// normal case where min port is less than max port and both are in acceptable range.
|
|
358 |
QString lowText("2000");
|
40
|
359 |
mTestObject->mLowestUDPPortItem->setContentWidgetData(QString("text"), lowText);
|
|
360 |
|
41
|
361 |
QString testString("65535");
|
40
|
362 |
mTestObject->mHighestUDPPortItem->setContentWidgetData(QString("text"), testString);
|
|
363 |
|
|
364 |
emit testTextSignal();
|
|
365 |
|
|
366 |
QCOMPARE( CMPSettingsModel::mMaxUdpPort, testString.toInt() );
|
|
367 |
|
41
|
368 |
// max port less than min port, both in acceptable range.
|
40
|
369 |
CMPSettingsModel::mMaxUdpPort = 0;
|
41
|
370 |
mTestObject->mHighestUDPPortItem->setContentWidgetData(QString("text"), QString("1999"));
|
40
|
371 |
|
|
372 |
emit testTextSignal();
|
|
373 |
|
|
374 |
QCOMPARE( CMPSettingsModel::mMaxUdpPort, lowText.toInt() );
|
|
375 |
|
41
|
376 |
// max port same as min port and in acceptable range.
|
40
|
377 |
CMPSettingsModel::mMaxUdpPort = 0;
|
41
|
378 |
testString = "2000";
|
40
|
379 |
mTestObject->mHighestUDPPortItem->setContentWidgetData(QString("text"), testString);
|
|
380 |
|
|
381 |
emit testTextSignal();
|
|
382 |
|
|
383 |
QCOMPARE( CMPSettingsModel::mMaxUdpPort, testString.toInt() );
|
41
|
384 |
|
|
385 |
// max port less than 1024
|
|
386 |
CMPSettingsModel::mMaxUdpPort = 0;
|
|
387 |
mTestObject->mHighestUDPPortItem->setContentWidgetData(QString("text"), QString("1023"));
|
|
388 |
mTestObject->mLowestUDPPortItem->setContentWidgetData(QString("text"), QString("1023"));
|
|
389 |
|
|
390 |
emit testTextSignal();
|
|
391 |
|
|
392 |
QCOMPARE( CMPSettingsModel::mMaxUdpPort, 1024 );
|
|
393 |
QCOMPARE( mTestObject->mHighestUDPPortItem->contentWidgetData(QString("text")).toString(), QString("1024") );
|
|
394 |
|
|
395 |
// max port greater than 65535
|
|
396 |
CMPSettingsModel::mMaxUdpPort = 0;
|
|
397 |
mTestObject->mHighestUDPPortItem->setContentWidgetData(QString("text"), QString("65536"));
|
|
398 |
|
|
399 |
emit testTextSignal();
|
|
400 |
|
|
401 |
QCOMPARE( CMPSettingsModel::mMaxUdpPort, 65535 );
|
|
402 |
QCOMPARE( mTestObject->mHighestUDPPortItem->contentWidgetData(QString("text")).toString(), QString("65535") );
|
|
403 |
|
|
404 |
// max port field empty
|
|
405 |
CMPSettingsModel::mMaxUdpPort = 0;
|
|
406 |
mTestObject->mHighestUDPPortItem->setContentWidgetData(QString("text"), QString(""));
|
|
407 |
|
|
408 |
emit testTextSignal();
|
|
409 |
|
|
410 |
QCOMPARE( CMPSettingsModel::mMaxUdpPort, 1024 );
|
|
411 |
QCOMPARE( mTestObject->mHighestUDPPortItem->contentWidgetData(QString("text")).toString(), QString("1024") );
|
40
|
412 |
}
|
|
413 |
|
|
414 |
// ---------------------------------------------------------------------------
|
|
415 |
// testUseProxyToggled
|
|
416 |
// ---------------------------------------------------------------------------
|
|
417 |
//
|
|
418 |
void TestVideoSettingsGroup::testUseProxyToggled()
|
|
419 |
{
|
|
420 |
connect(this, SIGNAL(testIntSignal(int)),
|
|
421 |
mTestObject, SLOT(useProxyToggled(int)));
|
|
422 |
|
|
423 |
emit testIntSignal(Qt::Unchecked);
|
|
424 |
|
|
425 |
QVERIFY( mTestObject->mProxyServerItem->isEnabled() == false );
|
|
426 |
QVERIFY( mTestObject->mProxyPortItem->isEnabled() == false );
|
|
427 |
QCOMPARE( CMPSettingsModel::mProxyMode, 0);
|
|
428 |
|
|
429 |
emit testIntSignal(Qt::Checked);
|
|
430 |
|
|
431 |
QVERIFY( mTestObject->mProxyServerItem->isEnabled() );
|
|
432 |
QVERIFY( mTestObject->mProxyPortItem->isEnabled() );
|
|
433 |
QCOMPARE( CMPSettingsModel::mProxyMode, 1);
|
|
434 |
}
|
|
435 |
|
|
436 |
// ---------------------------------------------------------------------------
|
|
437 |
// testProxyServerEditingFinished
|
|
438 |
// ---------------------------------------------------------------------------
|
|
439 |
//
|
|
440 |
void TestVideoSettingsGroup::testProxyServerEditingFinished()
|
|
441 |
{
|
|
442 |
connect(this, SIGNAL(testTextSignal()),
|
|
443 |
mTestObject, SLOT(proxyServerEditingFinished()));
|
|
444 |
|
|
445 |
QString testString("testtesttest");
|
|
446 |
mTestObject->mProxyServerItem->setContentWidgetData(QString("text"), testString);
|
|
447 |
|
|
448 |
emit testTextSignal();
|
|
449 |
QCOMPARE( CMPSettingsModel::mHostName, testString );
|
|
450 |
}
|
|
451 |
|
|
452 |
// ---------------------------------------------------------------------------
|
|
453 |
// testProxyPortEditingFinished
|
|
454 |
// ---------------------------------------------------------------------------
|
|
455 |
//
|
|
456 |
void TestVideoSettingsGroup::testProxyPortEditingFinished()
|
|
457 |
{
|
|
458 |
connect(this, SIGNAL(testTextSignal()),
|
|
459 |
mTestObject, SLOT(proxyPortEditingFinished()));
|
|
460 |
|
41
|
461 |
// proxy port at lowest accepted range.
|
|
462 |
QString testString("1");
|
|
463 |
mTestObject->mProxyPortItem->setContentWidgetData(QString("text"), testString);
|
|
464 |
|
|
465 |
emit testTextSignal();
|
|
466 |
QCOMPARE( CMPSettingsModel::mProxyPort, testString.toInt() );
|
|
467 |
|
|
468 |
// proxy port at highest accepted range.
|
|
469 |
testString = "65535";
|
40
|
470 |
mTestObject->mProxyPortItem->setContentWidgetData(QString("text"), testString);
|
|
471 |
|
|
472 |
emit testTextSignal();
|
|
473 |
QCOMPARE( CMPSettingsModel::mProxyPort, testString.toInt() );
|
41
|
474 |
|
|
475 |
// proxy port 0
|
|
476 |
mTestObject->mProxyPortItem->setContentWidgetData(QString("text"), QString("0"));
|
|
477 |
|
|
478 |
emit testTextSignal();
|
|
479 |
QCOMPARE( CMPSettingsModel::mProxyPort, 1 );
|
|
480 |
QCOMPARE( mTestObject->mProxyPortItem->contentWidgetData(QString("text")).toString(), QString("1") );
|
|
481 |
|
|
482 |
// proxy port higher than accepted.
|
|
483 |
mTestObject->mProxyPortItem->setContentWidgetData(QString("text"), QString("65536"));
|
|
484 |
|
|
485 |
emit testTextSignal();
|
|
486 |
QCOMPARE( CMPSettingsModel::mProxyPort, 65535 );
|
|
487 |
QCOMPARE( mTestObject->mProxyPortItem->contentWidgetData(QString("text")).toString(), QString("65535") );
|
|
488 |
|
|
489 |
// proxy port empty
|
|
490 |
mTestObject->mProxyPortItem->setContentWidgetData(QString("text"), QString(""));
|
|
491 |
|
|
492 |
emit testTextSignal();
|
|
493 |
QCOMPARE( CMPSettingsModel::mProxyPort, 1 );
|
|
494 |
QCOMPARE( mTestObject->mProxyPortItem->contentWidgetData(QString("text")).toString(), QString("1") );
|
40
|
495 |
}
|
|
496 |
|
|
497 |
// ---------------------------------------------------------------------------
|
|
498 |
// testItemShown
|
|
499 |
// ---------------------------------------------------------------------------
|
|
500 |
//
|
|
501 |
void TestVideoSettingsGroup::testItemShown()
|
|
502 |
{
|
|
503 |
connect(this, SIGNAL(testShownSignal(const QModelIndex&)),
|
|
504 |
mTestObject, SLOT(itemShown(const QModelIndex&)));
|
|
505 |
|
|
506 |
QModelIndex index;
|
|
507 |
|
|
508 |
HbLineEdit* editor = new HbLineEdit();
|
|
509 |
mItemHelper->mWidgetReturnValue = editor;
|
|
510 |
|
|
511 |
mItemHelper->mModelItemReturnValue = mTestObject->mLowestUDPPortItem;
|
|
512 |
HbEditorInterface::mFilter = 0;
|
|
513 |
emit testShownSignal(index);
|
|
514 |
QVERIFY( HbEditorInterface::mFilter == HbDigitsOnlyFilter::instance() );
|
41
|
515 |
QCOMPARE( editor->mMaxLength, 5 );
|
40
|
516 |
|
|
517 |
mItemHelper->mModelItemReturnValue = mTestObject->mProxyPortItem;
|
|
518 |
HbEditorInterface::mFilter = 0;
|
|
519 |
emit testShownSignal(index);
|
|
520 |
QVERIFY( HbEditorInterface::mFilter == HbDigitsOnlyFilter::instance() );
|
41
|
521 |
QCOMPARE( editor->mMaxLength, 5 );
|
40
|
522 |
|
|
523 |
mItemHelper->mModelItemReturnValue = mTestObject->mHighestUDPPortItem;
|
|
524 |
HbEditorInterface::mFilter = 0;
|
|
525 |
emit testShownSignal(index);
|
|
526 |
QVERIFY( HbEditorInterface::mFilter == HbDigitsOnlyFilter::instance() );
|
41
|
527 |
QCOMPARE( editor->mMaxLength, 5 );
|
40
|
528 |
|
|
529 |
mItemHelper->mModelItemReturnValue = mTestObject->mProxyServerItem;
|
|
530 |
HbEditorInterface::mFilter = 0;
|
|
531 |
emit testShownSignal(index);
|
|
532 |
QVERIFY( HbEditorInterface::mFilter == HbUrlFilter::instance() );
|
|
533 |
|
|
534 |
// verify the use proxy connection:
|
|
535 |
ConnectionHolder connection = mItemHelper->mConnections[mTestObject->mUseProxyItem];
|
|
536 |
QCOMPARE( connection.signal, SIGNAL(stateChanged(int)) );
|
|
537 |
QVERIFY( connection.receiver == mTestObject );
|
|
538 |
QCOMPARE( connection.method, SLOT(useProxyToggled(int)) );
|
|
539 |
|
|
540 |
delete editor;
|
|
541 |
}
|
|
542 |
|
|
543 |
// end of file
|