/
tst_connectionagent.cpp
84 lines (68 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/****************************************************************************
**
** Copyright (C) 2013 Jolla Ltd
** Contact: lorn.potter@jollamobile.com
**
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QString>
#include <QtTest>
23
#include <QProcess>
25
#include "../../../connd/qconnectionagent.h"
26
27
28
29
30
31
32
33
34
#include <networkmanager.h>
#include <networktechnology.h>
#include <networkservice.h>
class Tst_connectionagent : public QObject
{
Q_OBJECT
36
private Q_SLOTS:
37
38
void tst_onErrorReported();
void tst_onConnectionRequest();
40
41
42
private:
QConnectionAgent agent;
};
44
45
void Tst_connectionagent::tst_onErrorReported()
{
46
47
QSignalSpy spy(&agent, SIGNAL(errorReported(QString,QString)));
agent.onErrorReported("test_path","Test error");
48
49
50
51
52
53
54
QCOMPARE(spy.count(),1);
QList<QVariant> arguments;
arguments = spy.takeFirst();
QCOMPARE(arguments.at(0).toString(), QString("test_path"));
QCOMPARE(arguments.at(1).toString(), QString("Test error"));
55
agent.connectToType("test");
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
QCOMPARE(spy.count(),1);
arguments = spy.takeFirst();
QCOMPARE(arguments.at(0).toString(), QString(""));
QCOMPARE(arguments.at(1).toString(), QString("Type not valid"));
}
void Tst_connectionagent::tst_onConnectionRequest()
{
NetworkManager *netman = NetworkManagerFactory::createInstance();
QString currentState = netman->state();
if (currentState == "online") {
NetworkService *service = netman->defaultRoute();
service->requestDisconnect();
// service->requestConnect();
}
72
73
QSignalSpy spy(&agent, SIGNAL(connectionRequest()));
agent.onConnectionRequest();
74
75
76
77
78
79
80
81
if (currentState == "online")
QCOMPARE(spy.count(),0);
else
QCOMPARE(spy.count(),0);
}
82
83
84
QTEST_APPLESS_MAIN(Tst_connectionagent)
#include "tst_connectionagent.moc"