53
|
1 |
/*
|
60
|
2 |
* Copyright (c) 2010 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:
|
|
15 |
* WLAN Wizard test context.
|
|
16 |
*/
|
53
|
17 |
|
|
18 |
// System includes
|
60
|
19 |
|
53
|
20 |
#include <HbApplication>
|
|
21 |
#include <HbDocumentLoader>
|
|
22 |
#include <HbStackedWidget>
|
|
23 |
#include <HbRadioButtonList>
|
|
24 |
#include <HbAction>
|
|
25 |
#include <HbLineEdit>
|
|
26 |
#include <HbLabel>
|
|
27 |
#include <HbCheckBox>
|
60
|
28 |
#include <HbListWidget>
|
|
29 |
#include <HbListWidgetItem>
|
|
30 |
#include <HbParameterLengthLimiter>
|
|
31 |
|
53
|
32 |
#include <QGraphicsWidget>
|
|
33 |
#include <QObjectList>
|
|
34 |
#include <QtCore>
|
|
35 |
#include <QTest>
|
|
36 |
#include <QDebug>
|
|
37 |
#include <QList>
|
|
38 |
|
|
39 |
// User includes
|
60
|
40 |
|
53
|
41 |
#include "testwlanwizardcontext.h"
|
|
42 |
#include "hbautotest.h"
|
|
43 |
#include "wlanwizard.h"
|
|
44 |
#include "wlanwizard_p.h"
|
|
45 |
#include "wlanwizardpageinternal.h"
|
|
46 |
#include "wlanwizardhelper.h"
|
|
47 |
#include "wlanqtutils_context.h"
|
|
48 |
#include "wlanqtutils.h"
|
|
49 |
#include "wlanqtutilsap.h"
|
|
50 |
#include "eapqtconfiginterface_context.h"
|
|
51 |
#include "eapwizard.h"
|
|
52 |
#include "eapwizard_p.h"
|
|
53 |
#include "eapwizardpage.h"
|
|
54 |
#include "wpswizardpage.h"
|
|
55 |
#include "wlanmgmtclient_context.h"
|
|
56 |
#include "wpswizardstepfour.h"
|
|
57 |
#include "wpswizardstepfour_p.h"
|
|
58 |
#include "cwpsactiverunner.h"
|
|
59 |
|
|
60 |
// External function prototypes
|
|
61 |
|
|
62 |
// Local constants
|
|
63 |
class TestRadioButtonList: public HbRadioButtonList
|
|
64 |
{
|
|
65 |
public:
|
|
66 |
void emitActivated(const QModelIndex &modelIndex)
|
|
67 |
{ HbRadioButtonList::emitActivated(modelIndex); }
|
|
68 |
};
|
|
69 |
|
|
70 |
|
|
71 |
// ---------------------------------------------------------
|
|
72 |
// FRAMEWORK FUNCTIONS
|
|
73 |
// ---------------------------------------------------------
|
|
74 |
|
|
75 |
ContextWlanApList::ContextWlanApList()
|
|
76 |
{
|
|
77 |
|
|
78 |
}
|
|
79 |
|
|
80 |
ContextWlanApList::~ContextWlanApList()
|
|
81 |
{
|
|
82 |
clear();
|
|
83 |
}
|
|
84 |
|
60
|
85 |
void ContextWlanApList::Add(
|
|
86 |
QString name,
|
|
87 |
int netMode,
|
|
88 |
int secMode,
|
|
89 |
bool wpaPskInUse,
|
|
90 |
bool wpsSupported,
|
|
91 |
int signalStrength)
|
53
|
92 |
{
|
|
93 |
QSharedPointer<WlanQtUtilsAp> temp = QSharedPointer<WlanQtUtilsAp>(new WlanQtUtilsAp());
|
60
|
94 |
temp->setValue(WlanQtUtilsAp::ConfIdName, name);
|
|
95 |
temp->setValue(WlanQtUtilsAp::ConfIdSsid, name.toUtf8());
|
53
|
96 |
temp->setValue(WlanQtUtilsAp::ConfIdConnectionMode, netMode);
|
|
97 |
temp->setValue(WlanQtUtilsAp::ConfIdSecurityMode, secMode);
|
|
98 |
temp->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, wpaPskInUse);
|
|
99 |
temp->setValue(WlanQtUtilsAp::ConfIdWpsSupported, wpsSupported);
|
|
100 |
temp->setValue(WlanQtUtilsAp::ConfIdSignalStrength, signalStrength);
|
|
101 |
|
|
102 |
mList.append(temp);
|
|
103 |
}
|
|
104 |
|
|
105 |
void ContextWlanApList::clear()
|
|
106 |
{
|
|
107 |
mList.clear();
|
|
108 |
}
|
|
109 |
|
|
110 |
|
|
111 |
TestWlanWizardContext::TestWlanWizardContext() :
|
|
112 |
mView(NULL),
|
|
113 |
mMainWindow(NULL),
|
|
114 |
mWlanQtUtilsContext(NULL),
|
|
115 |
mEapQtUtilsContext(NULL),
|
|
116 |
mWlanMgmtClientContext(NULL),
|
|
117 |
mApList(NULL),
|
|
118 |
mApOpenList(NULL)
|
|
119 |
{
|
|
120 |
|
|
121 |
}
|
|
122 |
TestWlanWizardContext::~TestWlanWizardContext()
|
|
123 |
{
|
|
124 |
|
|
125 |
}
|
|
126 |
|
|
127 |
/**
|
|
128 |
* This function will be called before the first test function is executed.
|
|
129 |
*/
|
|
130 |
void TestWlanWizardContext::initTestCase()
|
|
131 |
{
|
|
132 |
qDebug("TestWlanWizardContext::initTestCase");
|
|
133 |
|
|
134 |
mMainWindow = new HbAutoTestMainWindow;
|
|
135 |
|
|
136 |
mView = new TestView();
|
|
137 |
|
|
138 |
mMainWindow->addView(mView);
|
|
139 |
mMainWindow->setCurrentView(mView);
|
|
140 |
mMainWindow->installEventFilter(this);
|
|
141 |
mMainWindow->show();
|
|
142 |
|
|
143 |
QTest::qWait(1);
|
|
144 |
while (!mEvent) {
|
|
145 |
QTest::qWait(WaitTimeForUi);
|
|
146 |
}
|
|
147 |
mEvent = false;
|
|
148 |
mApList = new ContextWlanApList();
|
|
149 |
mApOpenList = new ContextWlanApList();
|
|
150 |
|
|
151 |
}
|
|
152 |
|
|
153 |
/**
|
|
154 |
* This function will be called after the last test function was executed.
|
|
155 |
*/
|
|
156 |
void TestWlanWizardContext::cleanupTestCase()
|
|
157 |
{
|
|
158 |
qDebug("TestWlanWizardContext::cleanupTestCase");
|
|
159 |
|
|
160 |
qDebug("delete mApList");
|
|
161 |
delete mApList;
|
|
162 |
mApList = NULL;
|
|
163 |
delete mApOpenList;
|
|
164 |
mApOpenList = NULL;
|
|
165 |
|
|
166 |
qDebug("delete mMainWindow");
|
|
167 |
mMainWindow->setAttribute( Qt::WA_DeleteOnClose, true );
|
|
168 |
mMainWindow->close();
|
|
169 |
mMainWindow = NULL;
|
|
170 |
QTest::qWait(WaitTimeForUi);
|
|
171 |
qDebug("TestWlanWizardContext::cleanupTestCase exit");
|
|
172 |
}
|
|
173 |
|
|
174 |
/**
|
|
175 |
* This function will be called before each test function is executed.
|
|
176 |
*/
|
|
177 |
void TestWlanWizardContext::init()
|
|
178 |
{
|
|
179 |
qDebug("TestWlanWizardContext::init()");
|
|
180 |
|
|
181 |
mView->createWizard();
|
|
182 |
mWlanQtUtilsContext = new WlanQtUtilsContext(mView->mWizard->d_ptr->mWlanQtUtils.data());
|
|
183 |
|
|
184 |
mEapQtUtilsContext = new EapQtConfigInterfaceContext();
|
|
185 |
mEapQtUtilsContext->setObject(getEapQtConfig());
|
|
186 |
|
|
187 |
mWlanMgmtClientContext = new WlanMgmtClientContext();
|
|
188 |
//mWlanMgmtClientContext->setObject(mWlanMgmtClient);
|
|
189 |
|
|
190 |
WpsPageStepFour* wps = (WpsPageStepFour*)(mView->mWizard->d_ptr->mPages[WpsWizardPage::PageWpsWizardStep4]);
|
|
191 |
Q_ASSERT(wps);
|
|
192 |
mWlanMgmtClientContext->setObject(wps->d_ptr->mWpsActiveRunner->iWLANMgmtClient);
|
|
193 |
}
|
|
194 |
|
|
195 |
/**
|
|
196 |
* This function will be called after each test function is executed.
|
|
197 |
*/
|
|
198 |
void TestWlanWizardContext::cleanup()
|
|
199 |
{
|
|
200 |
qDebug("TestWlanWizardContext::cleanup()");
|
|
201 |
|
|
202 |
delete mWlanQtUtilsContext;
|
|
203 |
delete mEapQtUtilsContext;
|
|
204 |
delete mWlanMgmtClientContext;
|
|
205 |
|
|
206 |
mView->deleteWizard();
|
|
207 |
mApList->clear();
|
|
208 |
mApOpenList->clear();
|
|
209 |
QTest::qWait(1);
|
|
210 |
}
|
|
211 |
|
|
212 |
|
|
213 |
/*!
|
|
214 |
* Filter to catch focus event to the text editor widget.
|
|
215 |
*/
|
|
216 |
bool TestWlanWizardContext::eventFilter(QObject *obj, QEvent *event)
|
|
217 |
{
|
|
218 |
if (obj == mMainWindow && event->type() == QEvent::Show) {
|
|
219 |
mMainWindow->removeEventFilter(this);
|
|
220 |
mEvent = true;
|
|
221 |
}
|
|
222 |
return false;
|
|
223 |
}
|
|
224 |
|
|
225 |
QGraphicsWidget* TestWlanWizardContext::findChildItem(const QString &itemName, QGraphicsItem *widget)
|
|
226 |
{
|
|
227 |
QList<QGraphicsItem*> list = widget->childItems();
|
|
228 |
for (int i = 0; i < list.size(); i++) {
|
|
229 |
QGraphicsItem* item = list[i];
|
|
230 |
|
|
231 |
QGraphicsWidget* widget = NULL;
|
|
232 |
if (item->isWidget()) {
|
|
233 |
widget = (QGraphicsWidget*)item;
|
|
234 |
}
|
|
235 |
if (widget && widget->objectName() == itemName) {
|
|
236 |
return widget;
|
|
237 |
}
|
|
238 |
else if ((item = findChildItem(itemName, item))) {
|
|
239 |
return (QGraphicsWidget*)item;
|
|
240 |
}
|
|
241 |
}
|
|
242 |
return 0;
|
|
243 |
}
|
|
244 |
|
|
245 |
bool TestWlanWizardContext::verifyStatus(WizardStatusSignal status, int iapId)
|
|
246 |
{
|
|
247 |
return mView->verifyStatus(status, iapId);
|
|
248 |
}
|
|
249 |
|
|
250 |
bool TestWlanWizardContext::verifyCurrentPage(int pageId, int retries, int wait_ms)
|
|
251 |
{
|
|
252 |
bool ret = true;
|
|
253 |
for (int i = 0; i < retries; i++) {
|
|
254 |
QTest::qWait(wait_ms);
|
|
255 |
WlanWizardPrivate *pPrivate = mView->mWizard->d_ptr;
|
|
256 |
HbWidget* current = qobject_cast<HbWidget*> (pPrivate->mStackedWidget->currentWidget());
|
|
257 |
WlanWizardPage *page = pPrivate->mPageMapper[current];
|
|
258 |
|
|
259 |
// TODO: verify title in this method
|
|
260 |
|
|
261 |
if (page == pPrivate->mPages[pageId]) {
|
|
262 |
switch(pageId) {
|
|
263 |
case WlanWizardPageInternal::PageNetworkMode:
|
|
264 |
return verifyDialogText("dialog_6", hbTrId("txt_occ_dialog_select_network_mode_and_status"));
|
|
265 |
|
|
266 |
case WlanWizardPageInternal::PageNetworkSecurity:
|
|
267 |
return verifyDialogText("dialog_6", hbTrId("txt_occ_dialog_select_network_security_mode"));
|
|
268 |
|
|
269 |
case WlanWizardPageInternal::PageSsid:
|
|
270 |
return verifyDialogText("dialog", hbTrId("txt_occ_dialog_insert_the_name_of_the_new_wlan_net"));
|
|
271 |
|
|
272 |
case WlanWizardPageInternal::PageSummary:
|
|
273 |
if (pPrivate->mTitle->plainText() != hbTrId("txt_occ_title_wlan_setup_wizard_summary")){
|
|
274 |
qWarning("TestWlanWizardContext::verifyCurrentPage: Invalid title");
|
|
275 |
return false;
|
|
276 |
}
|
|
277 |
return true;
|
|
278 |
|
|
279 |
case EapWizardPage::PageOuterType:
|
|
280 |
return verifyDialogText("title", hbTrId("txt_occ_title_select_eap_type"));
|
|
281 |
|
|
282 |
case EapWizardPage::PageCertificateCa:
|
|
283 |
return verifyDialogText("title", hbTrId("txt_occ_title_select_authority_certificate"));
|
|
284 |
|
|
285 |
case EapWizardPage::PageCertificateUser:
|
|
286 |
return verifyDialogText("title", hbTrId("txt_occ_title_select_user_certificate"));
|
|
287 |
|
|
288 |
case EapWizardPage::PageNewPacStorePassword:
|
|
289 |
ret &= verifyDialogText("setlabel_55", hbTrId("txt_occ_setlabel_new_pac_store_password"));
|
|
290 |
ret &= verifyDialogText("setlabel_56", hbTrId("txt_occ_setlabel_confirm_password"));
|
|
291 |
return ret;
|
|
292 |
|
|
293 |
case EapWizardPage::PagePromptPacStorePassword:
|
|
294 |
return verifyDialogText("setlabel_59", hbTrId("txt_occ_setlabel_eap_pac_store_password"));
|
|
295 |
|
|
296 |
case WpsWizardPage::PageWpsWizardStep2:
|
|
297 |
return verifyDialogText("label", hbTrId("txt_occ_dialog_selected_network_supports_wifi_pro"));
|
|
298 |
break;
|
|
299 |
|
|
300 |
case WpsWizardPage::PageWpsWizardStep3_Button:
|
|
301 |
return verifyDialogText("label_heading", hbTrId("txt_occ_dialog_first_press_button_on_the_wireless"));
|
|
302 |
break;
|
|
303 |
|
|
304 |
case WpsWizardPage::PageWpsWizardStep3_Number:
|
|
305 |
// TODO: something better here??
|
|
306 |
return true;
|
|
307 |
|
|
308 |
case WpsWizardPage::PageWpsWizardStep4:
|
|
309 |
return verifyDialogText("label_heading", hbTrId("txt_occ_dialog_negotiating"));
|
|
310 |
|
|
311 |
case WpsWizardPage::PageWpsWizardStep5:
|
|
312 |
return verifyDialogText("label", hbTrId("txt_occ_dialog_settings_received_for_multiple_wlan"));
|
|
313 |
|
|
314 |
default:
|
|
315 |
return false;
|
|
316 |
}
|
|
317 |
}
|
|
318 |
}
|
|
319 |
qWarning("verifyCurrentPage: expected: %d", pageId);
|
|
320 |
return false;
|
|
321 |
}
|
|
322 |
|
|
323 |
bool TestWlanWizardContext::verifyCurrentPageWithInfo(
|
|
324 |
int pageId, const QString &info, int retries, int wait_ms)
|
|
325 |
{
|
|
326 |
bool ret = true;
|
|
327 |
for (int i = 0; i < retries; i++) {
|
|
328 |
QTest::qWait(wait_ms);
|
|
329 |
|
|
330 |
WlanWizardPrivate *pPrivate = mView->mWizard->d_ptr;
|
|
331 |
HbWidget* current = qobject_cast<HbWidget*> (pPrivate->mStackedWidget->currentWidget());
|
|
332 |
WlanWizardPage *page = pPrivate->mPageMapper[current];
|
|
333 |
|
|
334 |
// TODO: verify title in this method
|
|
335 |
|
|
336 |
if (page == pPrivate->mPages[pageId]) {
|
|
337 |
switch(pageId) {
|
|
338 |
case WlanWizardPageInternal::PageGenericError:
|
|
339 |
return verifyDialogText("dialog", info);
|
|
340 |
|
|
341 |
case WlanWizardPageInternal::PageKeyQuery:
|
|
342 |
return verifyDialogText("dialog", HbParameterLengthLimiter("txt_occ_dialog_enter_key_for_1").arg(info));
|
|
343 |
|
|
344 |
case WlanWizardPageInternal::PageProcessSettings:
|
|
345 |
return verifyDialogText("dialog", HbParameterLengthLimiter("txt_occ_dialog_checking_connection_to_1").arg(info));
|
|
346 |
|
|
347 |
case WlanWizardPageInternal::PageScanning:
|
|
348 |
return verifyDialogText("dialog", HbParameterLengthLimiter("txt_occ_dialog_searching").arg(info));
|
|
349 |
|
|
350 |
case EapWizardPage::PageUsernamePassword:
|
|
351 |
ret &= verifyDialogText(
|
|
352 |
"setlabel_55",
|
|
353 |
HbParameterLengthLimiter("txt_occ_setlabel_user_name_for_1").arg(info));
|
|
354 |
ret &= verifyDialogText("setlabel_56", hbTrId("txt_occ_setlabel_eap_password"));
|
|
355 |
return ret;
|
|
356 |
|
|
357 |
case EapWizardPage::PageIdentity:
|
|
358 |
ret &= verifyDialogText("setlabel_53", HbParameterLengthLimiter("txt_occ_setlabel_user_name_for_1").arg(info));
|
|
359 |
ret &= verifyDialogText("setlabel_53_val", hbTrId("txt_occ_setlabel_user_name_val_generate_automatic"));
|
|
360 |
ret &= verifyDialogText("setlabel_54", hbTrId("txt_occ_setlabel_eap_realm"));
|
|
361 |
ret &= verifyDialogText("setlabel_54_val", hbTrId("txt_occ_setlabel_eap_realm_val_generate_automatically"));
|
|
362 |
return ret;
|
|
363 |
|
|
364 |
case EapWizardPage::PageInnerTypePeap:
|
|
365 |
case EapWizardPage::PageInnerTypeEapTtls:
|
|
366 |
return verifyDialogText("title", HbParameterLengthLimiter("txt_occ_title_select_innear_eap_type_for_1").arg(info));
|
|
367 |
|
|
368 |
default:
|
|
369 |
return verifyCurrentPage(pageId, retries, wait_ms);
|
|
370 |
}
|
|
371 |
}
|
|
372 |
}
|
|
373 |
qWarning("verifyCurrentPage: expected: %d", pageId);
|
|
374 |
return false;
|
|
375 |
}
|
|
376 |
|
|
377 |
|
|
378 |
bool TestWlanWizardContext::verifyDialogText(const QString objName, const QString text)
|
|
379 |
{
|
|
380 |
HbWidget* current = qobject_cast<HbWidget*> (
|
|
381 |
mView->mWizard->d_ptr->mStackedWidget->currentWidget());
|
|
382 |
HbWidget* widget = qobject_cast<HbWidget*> (
|
|
383 |
findChildItem(objName, current));
|
|
384 |
|
|
385 |
if (widget) {
|
|
386 |
HbLabel *label = qobject_cast<HbLabel*>(widget);
|
|
387 |
if (label) {
|
|
388 |
if(label->plainText() == text) {
|
|
389 |
if (!label->isVisible()){
|
|
390 |
qWarning("verifyDialogText: not visible");
|
|
391 |
return false;
|
|
392 |
}
|
|
393 |
return true;
|
|
394 |
|
|
395 |
} else {
|
|
396 |
qWarning("verifyDialogText: not match");
|
|
397 |
qDebug() << "expect: " << text;
|
|
398 |
qDebug() << "actual: " << label->plainText();
|
|
399 |
return false;
|
|
400 |
}
|
|
401 |
}
|
|
402 |
HbCheckBox *checkBox = qobject_cast<HbCheckBox*>(widget);
|
|
403 |
|
|
404 |
if (checkBox) {
|
|
405 |
if(checkBox->text() == text) {
|
|
406 |
if (!checkBox->isVisible()){
|
|
407 |
qWarning("verifyDialogText: not visible");
|
|
408 |
return false;
|
|
409 |
}
|
|
410 |
return true;
|
|
411 |
|
|
412 |
} else {
|
|
413 |
qWarning("verifyDialogText: not match");
|
|
414 |
qDebug() << "expect: " << text;
|
|
415 |
qDebug() << "actual: " << checkBox->text();
|
|
416 |
return false;
|
|
417 |
}
|
|
418 |
}
|
|
419 |
}
|
|
420 |
|
|
421 |
qWarning("verifyDialogText: object not found");
|
|
422 |
|
|
423 |
return false;
|
|
424 |
}
|
|
425 |
|
|
426 |
bool TestWlanWizardContext::verifyActionButtons(ButtonStatus prevStatus,
|
|
427 |
ButtonStatus cancelStatus,
|
|
428 |
ButtonStatus nextStatus,
|
|
429 |
ButtonStatus finishStatus)
|
|
430 |
{
|
|
431 |
WlanWizardPrivate *pPrivate = mView->mWizard->d_ptr;
|
|
432 |
ButtonStatus prevReally = ButtonHidden;
|
|
433 |
ButtonStatus cancelReally = ButtonHidden;
|
|
434 |
ButtonStatus nextReally = ButtonHidden;
|
|
435 |
ButtonStatus finishReally = ButtonHidden;
|
|
436 |
|
|
437 |
if(pPrivate->mActionPrevious->isVisible()) {
|
|
438 |
if(pPrivate->mActionPrevious->isEnabled()) {
|
|
439 |
prevReally = ButtonEnabled;
|
|
440 |
} else {
|
|
441 |
prevReally = ButtonDisabled;
|
|
442 |
}
|
|
443 |
}
|
|
444 |
|
|
445 |
if(pPrivate->mActionCancel->isVisible()) {
|
|
446 |
if(pPrivate->mActionCancel->isEnabled()) {
|
|
447 |
cancelReally = ButtonEnabled;
|
|
448 |
} else {
|
|
449 |
cancelReally = ButtonDisabled;
|
|
450 |
}
|
|
451 |
}
|
|
452 |
|
|
453 |
if(pPrivate->mActionNext->isVisible()) {
|
|
454 |
if(pPrivate->mActionNext->isEnabled()) {
|
|
455 |
nextReally = ButtonEnabled;
|
|
456 |
} else {
|
|
457 |
nextReally = ButtonDisabled;
|
|
458 |
}
|
|
459 |
}
|
|
460 |
|
|
461 |
if(pPrivate->mActionFinish->isVisible()) {
|
|
462 |
if(pPrivate->mActionFinish->isEnabled()) {
|
|
463 |
finishReally = ButtonEnabled;
|
|
464 |
} else {
|
|
465 |
finishReally = ButtonDisabled;
|
|
466 |
}
|
|
467 |
}
|
|
468 |
bool ret = true;
|
|
469 |
if (prevReally != prevStatus){
|
|
470 |
qWarning("Previous Button: really: %d, status: %d", prevReally, prevStatus);
|
|
471 |
ret = false;
|
|
472 |
}
|
|
473 |
if (cancelReally != cancelStatus){
|
|
474 |
qWarning("Cancel Button: really: %d, status: %d", cancelReally, cancelStatus);
|
|
475 |
ret = false;
|
|
476 |
}
|
|
477 |
if (nextReally != nextStatus){
|
|
478 |
qWarning("Next Button: really: %d, status: %d", nextReally, nextStatus);
|
|
479 |
ret = false;
|
|
480 |
}
|
|
481 |
if (finishReally != finishStatus){
|
|
482 |
qWarning("Finish Button: really: %d, status: %d", finishReally, finishStatus);
|
|
483 |
ret = false;
|
|
484 |
}
|
|
485 |
|
|
486 |
return ret;
|
|
487 |
}
|
|
488 |
|
|
489 |
bool TestWlanWizardContext::verifySummaryPage(
|
|
490 |
const QString &ssid,
|
|
491 |
int netMode,
|
|
492 |
bool hidden,
|
|
493 |
int secMode,
|
|
494 |
bool useWpaPsk,
|
|
495 |
const QString &destination,
|
|
496 |
int outerType,
|
|
497 |
int innerType,
|
|
498 |
bool eapFastProvMode)
|
|
499 |
{
|
|
500 |
bool ret = true;
|
|
501 |
int i = 0;
|
|
502 |
HbListWidget* listWidget = qobject_cast<HbListWidget*> (
|
|
503 |
mView->mWizard->d_ptr->mStackedWidget->currentWidget());
|
|
504 |
|
|
505 |
if (!listWidget){
|
|
506 |
qWarning("verifySummaryPage: ListWidget not found");
|
|
507 |
return false;
|
|
508 |
}
|
|
509 |
|
|
510 |
// VERIFY: NETWORK NAME
|
|
511 |
HbListWidgetItem *item = listWidget->item(i++);
|
|
512 |
if (item->text() != hbTrId("txt_occ_dblist_network_name")) {
|
|
513 |
qWarning("verifySummaryPage: no match network name");
|
|
514 |
ret = false;
|
|
515 |
}
|
|
516 |
|
|
517 |
if (item->secondaryText() != ssid){
|
|
518 |
qWarning("verifySummaryPage: no match ssid");
|
|
519 |
ret = false;
|
|
520 |
}
|
|
521 |
|
|
522 |
// VERIFY: NETWORK MODE
|
|
523 |
item = listWidget->item(i++);
|
|
524 |
if (item->text() != hbTrId("txt_occ_dblist_network_mode")) {
|
|
525 |
qWarning("verifySummaryPage: no match network mode");
|
|
526 |
ret = false;
|
|
527 |
}
|
|
528 |
QString netModeString(toNetworkModeString(netMode, hidden));
|
|
529 |
if (item->secondaryText() != netModeString){
|
|
530 |
qWarning("verifySummaryPage: no match network mode value");
|
|
531 |
qDebug() << "Actual: " << item->secondaryText();
|
|
532 |
qDebug() << "Expected: " << netModeString;
|
|
533 |
ret = false;
|
|
534 |
}
|
|
535 |
|
|
536 |
// VERIFY: SECURITY MODE
|
|
537 |
item = listWidget->item(i++);
|
|
538 |
if (item->text() != hbTrId("txt_occ_dblist_security_mode")) {
|
|
539 |
qWarning("verifySummaryPage: no match security mode");
|
|
540 |
ret = false;
|
|
541 |
}
|
|
542 |
|
|
543 |
if (item->secondaryText() != toSecurityModeString(secMode, useWpaPsk)){
|
|
544 |
qWarning("verifySummaryPage: no match security mode value");
|
|
545 |
ret = false;
|
|
546 |
}
|
|
547 |
|
|
548 |
// VERIFY: EAP OUTER TYPE
|
|
549 |
if (outerType != -1) {
|
|
550 |
item = listWidget->item(i++);
|
|
551 |
if (item->text() != hbTrId("txt_occ_dblist_outer_eap")) {
|
|
552 |
qWarning("verifySummaryPage: no match eap outer type");
|
|
553 |
ret = false;
|
|
554 |
}
|
|
555 |
if (item->secondaryText() != eapTypeToString(outerType)){
|
|
556 |
qWarning("verifySummaryPage: no match eap outer type value");
|
|
557 |
ret = false;
|
|
558 |
}
|
|
559 |
}
|
|
560 |
|
|
561 |
// VERIFY: EAP INNER TYPE
|
|
562 |
if (innerType != -1) {
|
|
563 |
item = listWidget->item(i++);
|
|
564 |
if (item->text() != hbTrId("txt_occ_dblist_inner_eap")) {
|
|
565 |
qWarning("verifySummaryPage: no match eap inner type");
|
|
566 |
ret = false;
|
|
567 |
}
|
|
568 |
if (item->secondaryText() != eapTypeToString(innerType)){
|
|
569 |
qWarning("verifySummaryPage: no match eap inner type value");
|
|
570 |
ret = false;
|
|
571 |
}
|
|
572 |
}
|
|
573 |
|
|
574 |
// VERIFY: EAP FAST PROVISIONING MODE
|
|
575 |
if (eapFastProvMode) {
|
|
576 |
item = listWidget->item(i++);
|
|
577 |
if (item->text() != hbTrId("txt_occ_dblist_provisioning_mode_for_eapfast")) {
|
|
578 |
qWarning("verifySummaryPage: no match eap prov mode");
|
|
579 |
ret = false;
|
|
580 |
}
|
|
581 |
if (item->secondaryText() != hbTrId("txt_occ_dblist_provisioning_mode_for_val_unauthent")){
|
|
582 |
qWarning("verifySummaryPage: no match eap prov mode value");
|
|
583 |
ret = false;
|
|
584 |
}
|
|
585 |
}
|
|
586 |
|
|
587 |
// VERIFY: DESTINATION
|
|
588 |
if (destination.length() > 0) {
|
|
589 |
item = listWidget->item(i++);
|
|
590 |
if (item->text() != hbTrId("txt_occ_dblist_destination")) {
|
|
591 |
qWarning("verifySummaryPage: no match destination");
|
|
592 |
ret = false;
|
|
593 |
}
|
|
594 |
if (item->secondaryText() != destination){
|
|
595 |
qWarning("verifySummaryPage: no match destination value");
|
|
596 |
ret = false;
|
|
597 |
}
|
|
598 |
}
|
|
599 |
|
|
600 |
|
|
601 |
return ret;
|
|
602 |
}
|
|
603 |
|
|
604 |
bool TestWlanWizardContext::mouseClickObject(const QString objName)
|
|
605 |
{
|
|
606 |
HbWidget* current = qobject_cast<HbWidget*> (
|
|
607 |
mView->mWizard->d_ptr->mStackedWidget->currentWidget());
|
|
608 |
HbWidget* widget = (HbWidget*) findChildItem(objName, current);
|
|
609 |
|
|
610 |
if (widget) {
|
|
611 |
HbAutoTest::mouseClick(mMainWindow, widget);
|
|
612 |
widget->clearFocus();
|
|
613 |
widget->setFocus();
|
|
614 |
return true;
|
|
615 |
}
|
|
616 |
qWarning("mouseClickObject: object not found");
|
|
617 |
|
|
618 |
return false;
|
|
619 |
}
|
|
620 |
|
|
621 |
bool TestWlanWizardContext::insertTextToObject(const QString objName, const QString text)
|
|
622 |
{
|
|
623 |
HbWidget* current = qobject_cast<HbWidget*> (
|
|
624 |
mView->mWizard->d_ptr->mStackedWidget->currentWidget());
|
|
625 |
HbWidget* widget = (HbWidget*) findChildItem(objName, current);
|
|
626 |
|
|
627 |
if (widget) {
|
|
628 |
for (int i = 0; i < text.size(); i++) {
|
|
629 |
HbAutoTest::keyPress(mMainWindow, text.at(i).toAscii(), 0, 10);
|
|
630 |
QTest::qWait(20);
|
|
631 |
}
|
|
632 |
return true;
|
|
633 |
}
|
|
634 |
qWarning("insertTextToObject: object not found");
|
|
635 |
return false;
|
|
636 |
}
|
|
637 |
|
|
638 |
bool TestWlanWizardContext::selectRadioButton(const QString objName, int index)
|
|
639 |
{
|
|
640 |
HbWidget* current = qobject_cast<HbWidget*> (
|
|
641 |
mView->mWizard->d_ptr->mStackedWidget->currentWidget());
|
|
642 |
TestRadioButtonList* widget = (TestRadioButtonList*) findChildItem(objName, current);
|
|
643 |
|
|
644 |
if (widget) {
|
|
645 |
if (widget->items().length() <= index) {
|
|
646 |
qWarning("selectRadioButton: index out of range");
|
|
647 |
return false;
|
|
648 |
}
|
|
649 |
widget->setSelected(index);
|
|
650 |
widget->emitActivated(widget->currentIndex());
|
|
651 |
return true;
|
|
652 |
}
|
|
653 |
qWarning("selectRadioButton: object not found");
|
|
654 |
|
|
655 |
return false;
|
|
656 |
}
|
|
657 |
|
|
658 |
bool TestWlanWizardContext::verifyRadioButtonState(
|
|
659 |
const QString objName,
|
|
660 |
int index,
|
|
661 |
const QString &text)
|
|
662 |
{
|
|
663 |
HbWidget* current = qobject_cast<HbWidget*> (
|
|
664 |
mView->mWizard->d_ptr->mStackedWidget->currentWidget());
|
|
665 |
|
|
666 |
HbRadioButtonList* widget = qobject_cast<HbRadioButtonList*>(
|
|
667 |
findChildItem(objName, current));
|
|
668 |
|
|
669 |
if (widget) {
|
|
670 |
if (widget->selected() != index) {
|
|
671 |
qWarning("verifyRadioButtonState: invalid index");
|
|
672 |
return false;
|
|
673 |
}
|
|
674 |
|
|
675 |
if (widget->items().at(index) != text) {
|
|
676 |
qWarning("verifyRadioButtonState: text does not match");
|
|
677 |
return false;
|
|
678 |
}
|
|
679 |
|
|
680 |
return true;
|
|
681 |
}
|
|
682 |
qWarning("verifyRadioButtonState: object not found");
|
|
683 |
|
|
684 |
return false;
|
|
685 |
}
|
|
686 |
|
|
687 |
QStringList TestWlanWizardContext::verifyRadioButtons(const QString objName)
|
|
688 |
{
|
|
689 |
HbWidget* current = qobject_cast<HbWidget*> (
|
|
690 |
mView->mWizard->d_ptr->mStackedWidget->currentWidget());
|
|
691 |
|
|
692 |
HbRadioButtonList* widget = qobject_cast<HbRadioButtonList*>(
|
|
693 |
findChildItem(objName, current));
|
|
694 |
|
|
695 |
QStringList ret;
|
|
696 |
|
|
697 |
if (widget) {
|
|
698 |
ret = widget->items();
|
|
699 |
}
|
|
700 |
else {
|
|
701 |
qWarning("verifyRadioButtons: object not found");
|
|
702 |
}
|
|
703 |
|
|
704 |
return ret;
|
|
705 |
}
|
|
706 |
|
|
707 |
int TestWlanWizardContext::verifySelectedRadioButton(const QString objName)
|
|
708 |
{
|
|
709 |
HbWidget* current = qobject_cast<HbWidget*> (
|
|
710 |
mView->mWizard->d_ptr->mStackedWidget->currentWidget());
|
|
711 |
|
|
712 |
HbRadioButtonList* widget = qobject_cast<HbRadioButtonList*>(
|
|
713 |
findChildItem(objName, current));
|
|
714 |
|
|
715 |
int ret = ListNotFound;
|
|
716 |
|
|
717 |
if (widget) {
|
|
718 |
ret = widget->selected();
|
|
719 |
}
|
|
720 |
else {
|
|
721 |
qWarning("verifySelectedRadioButton: object not found");
|
|
722 |
}
|
|
723 |
|
|
724 |
return ret;
|
|
725 |
}
|
|
726 |
|
|
727 |
bool TestWlanWizardContext::verifyCheckBoxState(const QString &objName, bool checked)
|
|
728 |
{
|
|
729 |
HbWidget* current = qobject_cast<HbWidget*> (
|
|
730 |
mView->mWizard->d_ptr->mStackedWidget->currentWidget());
|
|
731 |
HbCheckBox* widget = qobject_cast<HbCheckBox*>(
|
|
732 |
findChildItem(objName, current));
|
|
733 |
|
|
734 |
if (widget) {
|
|
735 |
if (widget->isChecked() != checked) {
|
|
736 |
qWarning("Checkbox in wrong state");
|
|
737 |
return false;
|
|
738 |
}
|
|
739 |
return true;
|
|
740 |
}
|
|
741 |
qWarning("verifyCheckBoxState: object not found");
|
|
742 |
return false;
|
|
743 |
}
|
|
744 |
|
|
745 |
bool TestWlanWizardContext::selectCheckBoxState(const QString &objName, bool check)
|
|
746 |
{
|
|
747 |
HbWidget* current = qobject_cast<HbWidget*> (
|
|
748 |
mView->mWizard->d_ptr->mStackedWidget->currentWidget());
|
|
749 |
HbCheckBox* widget = qobject_cast<HbCheckBox*>(
|
|
750 |
findChildItem(objName, current));
|
|
751 |
|
|
752 |
if (widget) {
|
|
753 |
if (check) {
|
|
754 |
widget->setCheckState(Qt::Checked);
|
|
755 |
} else {
|
|
756 |
widget->setCheckState(Qt::Unchecked);
|
|
757 |
}
|
|
758 |
return true;
|
|
759 |
|
|
760 |
}
|
|
761 |
qWarning("selectCheckBoxState: object not found");
|
|
762 |
return false;
|
|
763 |
}
|
|
764 |
|
|
765 |
bool TestWlanWizardContext::mouseClickNext()
|
|
766 |
{
|
|
767 |
if (mView->mWizard->d_ptr->mActionNext->isEnabled()) {
|
|
768 |
mView->mWizard->d_ptr->mActionNext->activate(QAction::Trigger);
|
|
769 |
return true;
|
|
770 |
}
|
|
771 |
qWarning("Next button not enabled");
|
|
772 |
return false;
|
|
773 |
}
|
|
774 |
|
|
775 |
bool TestWlanWizardContext::mouseClickPrevious()
|
|
776 |
{
|
|
777 |
if (mView->mWizard->d_ptr->mActionPrevious->isEnabled()) {
|
|
778 |
mView->mWizard->d_ptr->mActionPrevious->activate(QAction::Trigger);
|
|
779 |
return true;
|
|
780 |
}
|
|
781 |
qWarning("mouseClickPrevious: Previous button not enabled");
|
|
782 |
|
|
783 |
return false;
|
|
784 |
}
|
|
785 |
|
|
786 |
bool TestWlanWizardContext::mouseClickCancel()
|
|
787 |
{
|
|
788 |
if (mView->mWizard->d_ptr->mActionCancel->isEnabled()) {
|
|
789 |
mView->mWizard->d_ptr->mActionCancel->activate(QAction::Trigger);
|
|
790 |
return true;
|
|
791 |
}
|
|
792 |
qWarning("mouseClickCancel: Cancel button not enabled");
|
|
793 |
|
|
794 |
return false;
|
|
795 |
}
|
|
796 |
|
|
797 |
bool TestWlanWizardContext::mouseClickFinish()
|
|
798 |
{
|
|
799 |
if (mView->mWizard->d_ptr->mActionFinish->isEnabled()) {
|
|
800 |
mView->mWizard->d_ptr->mActionFinish->activate(QAction::Trigger);
|
|
801 |
return true;
|
|
802 |
}
|
|
803 |
qWarning("mouseClickFinish: Finish button not enabled");
|
|
804 |
|
|
805 |
return false;
|
|
806 |
}
|
|
807 |
|
|
808 |
QString TestWlanWizardContext::toNetworkModeString(int netMode, bool isHidden)
|
|
809 |
{
|
|
810 |
QString ret;
|
|
811 |
switch (netMode) {
|
|
812 |
case CMManagerShim::Adhoc:
|
|
813 |
ret = hbTrId("txt_occ_dblist_network_mode_val_adhoc");
|
|
814 |
break;
|
|
815 |
|
|
816 |
default:
|
|
817 |
if (isHidden) {
|
|
818 |
ret = hbTrId("txt_occ_dblist_network_mode_val_infrastructure_hi");
|
|
819 |
} else {
|
|
820 |
ret = hbTrId("txt_occ_dblist_network_mode_val_infrastructure_pu");
|
|
821 |
}
|
|
822 |
break;
|
|
823 |
}
|
|
824 |
return ret;
|
|
825 |
}
|
|
826 |
|
|
827 |
QString TestWlanWizardContext::toSecurityModeString(int secMode, int useWpaPsk)
|
|
828 |
{
|
|
829 |
QString ret;
|
|
830 |
switch (secMode) {
|
|
831 |
case CMManagerShim::WlanSecMode802_1x:
|
|
832 |
ret = hbTrId("txt_occ_dblist_security_mode_val_8021x");
|
|
833 |
break;
|
|
834 |
|
|
835 |
case CMManagerShim::WlanSecModeWep:
|
|
836 |
ret = hbTrId("txt_occ_dblist_security_mode_val_wep");
|
|
837 |
break;
|
|
838 |
|
|
839 |
case CMManagerShim::WlanSecModeWpa:
|
|
840 |
if (useWpaPsk) {
|
|
841 |
ret = hbTrId("txt_occ_dblist_security_mode_val_wpawpa2psk");
|
|
842 |
} else {
|
|
843 |
ret = hbTrId("txt_occ_dblist_security_mode_val_wpawpa2_with_eap");
|
|
844 |
}
|
|
845 |
break;
|
|
846 |
|
|
847 |
case CMManagerShim::WlanSecModeWpa2:
|
|
848 |
if (useWpaPsk) {
|
|
849 |
ret = hbTrId("txt_occ_dblist_security_mode_val_wpa2_with_passwor");
|
|
850 |
} else {
|
|
851 |
ret = hbTrId("txt_occ_dblist_security_mode_val_wpa2_with_eap");
|
|
852 |
}
|
|
853 |
break;
|
|
854 |
|
|
855 |
default:
|
|
856 |
Q_ASSERT(secMode == CMManagerShim::WlanSecModeOpen);
|
|
857 |
ret = hbTrId("txt_occ_dblist_security_mode_val_open");
|
|
858 |
break;
|
|
859 |
}
|
|
860 |
return ret;
|
|
861 |
}
|
|
862 |
|
|
863 |
|
|
864 |
EapQtConfigInterface *TestWlanWizardContext::getEapQtConfig()
|
|
865 |
{
|
|
866 |
return mView->mWizard->d_ptr->mEapWizard->d_ptr->mEapConfIf.data();
|
|
867 |
}
|
|
868 |
|
|
869 |
QString TestWlanWizardContext::eapTypeToString(int type)
|
|
870 |
{
|
|
871 |
QCOMPARE(mView->mWizard->d_ptr->mEapWizard != NULL, true);
|
|
872 |
return mView->mWizard->d_ptr->mEapWizard->d_ptr->eapTypeToString(type);
|
|
873 |
}
|
|
874 |
|
|
875 |
void TestWlanWizardContext::callWlanWizard_startPageOperation()
|
|
876 |
{
|
|
877 |
mView->mWizard->d_ptr->startPageOperation();
|
|
878 |
}
|
|
879 |
|
|
880 |
|
|
881 |
void TestWlanWizardContext::setWlanMgmtClientObject(CWlanMgmtClient* object)
|
|
882 |
{
|
|
883 |
// TODO: mWlanMgmtClient = object;
|
|
884 |
}
|
|
885 |
|
|
886 |
TestView::TestView() : mWizard(NULL)
|
|
887 |
{
|
|
888 |
qDebug("TestView::TestView()");
|
|
889 |
}
|
|
890 |
|
|
891 |
TestView::~TestView()
|
|
892 |
{
|
|
893 |
qDebug("TestView::~TestView()");
|
|
894 |
}
|
|
895 |
|
|
896 |
void TestView::createWizard()
|
|
897 |
{
|
|
898 |
qDebug("TestView::createWizard");
|
|
899 |
Q_ASSERT(mWizard == NULL);
|
|
900 |
mWizard = new WlanWizard(mainWindow());
|
|
901 |
bool ok;
|
|
902 |
ok = connect(
|
|
903 |
mWizard, SIGNAL(finished(int, bool)),
|
|
904 |
this, SLOT(finished(int, bool)),
|
|
905 |
Qt::QueuedConnection);
|
|
906 |
Q_ASSERT(ok);
|
|
907 |
|
|
908 |
ok = connect(
|
|
909 |
mWizard, SIGNAL(cancelled()),
|
|
910 |
this, SLOT(cancelled()),
|
|
911 |
Qt::QueuedConnection);
|
|
912 |
Q_ASSERT(ok);
|
|
913 |
|
|
914 |
mWizardStatus = WizardStatusSignalNone;
|
|
915 |
mConnectedIapId = -100;
|
|
916 |
}
|
|
917 |
|
|
918 |
void TestView::showWizard()
|
|
919 |
{
|
|
920 |
qDebug("TestView::showWizard()");
|
|
921 |
Q_ASSERT(mWizard);
|
|
922 |
mWizard->show();
|
|
923 |
}
|
|
924 |
|
|
925 |
void TestView::deleteWizard()
|
|
926 |
{
|
|
927 |
qDebug("TestView::deleteWizard");
|
|
928 |
|
|
929 |
Q_ASSERT(mWizard != NULL);
|
|
930 |
QMetaObject::invokeMethod(mWizard, "deleteLater", Qt::QueuedConnection);
|
|
931 |
QTest::qWait(100);
|
|
932 |
mWizard = NULL;
|
|
933 |
}
|
|
934 |
|
|
935 |
void TestView::finished(int iapId, bool connected)
|
|
936 |
{
|
|
937 |
qDebug("TestView::complete(), iap id: %d, connected: %d", iapId, connected);
|
|
938 |
|
|
939 |
if (mWizardStatus != WizardStatusSignalNone) {
|
|
940 |
qWarning("TestView::finished: multiple signals received");
|
|
941 |
mWizardStatus = WizardStatusSignalUndefined;
|
|
942 |
} else {
|
|
943 |
mWizardStatus = WizardStatusSignalFinished;
|
|
944 |
mConnectedIapId = iapId;
|
|
945 |
}
|
|
946 |
}
|
|
947 |
|
|
948 |
void TestView::cancelled()
|
|
949 |
{
|
|
950 |
qDebug("TestView::cancelled()");
|
|
951 |
if (mWizardStatus != WizardStatusSignalNone) {
|
|
952 |
qWarning("TestView::cancelled: multiple signals received");
|
|
953 |
mWizardStatus = WizardStatusSignalUndefined;
|
|
954 |
} else {
|
|
955 |
mWizardStatus = WizardStatusSignalCancelled;
|
|
956 |
}
|
|
957 |
}
|
|
958 |
|
|
959 |
bool TestView::verifyStatus(WizardStatusSignal status, int iapId )
|
|
960 |
{
|
|
961 |
// Since connections to cancelled and finished signals are queued
|
|
962 |
// we need to use qWait() here.
|
|
963 |
QTest::qWait(100);
|
|
964 |
bool ret = true;
|
|
965 |
if (status != mWizardStatus){
|
|
966 |
qWarning("TestView::verifyStatus, status: expected: %d, actual: %d", status, mWizardStatus);
|
|
967 |
ret = false;
|
|
968 |
}
|
|
969 |
if (status == WizardStatusSignalFinished) {
|
|
970 |
if (iapId != mConnectedIapId) {
|
|
971 |
qWarning("TestView::verifyStatus, iapid: expected: %d, actual: %d", iapId, mConnectedIapId);
|
|
972 |
ret = false;
|
|
973 |
}
|
|
974 |
}
|
|
975 |
return ret;
|
|
976 |
}
|