Skip to content

Commit

Permalink
[connectionagent] add initial plugin test, and fix nasty crash it found.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lorn Potter committed May 28, 2013
1 parent 12ba5eb commit 074e848
Show file tree
Hide file tree
Showing 12 changed files with 213 additions and 26 deletions.
7 changes: 3 additions & 4 deletions connd/connd.pro
Expand Up @@ -4,13 +4,12 @@ QT -= gui

equals(QT_MAJOR_VERSION, 4): {
TARGET = connectionagent
INCLUDEPATH += libconnman-qt
LIBS += -lconnman-qt4
PKGCONFIG += connman-qt4

}
equals(QT_MAJOR_VERSION, 5): {
TARGET = connectionagent
INCLUDEPATH += libconnman-qt5
LIBS += -lconnman-qt5
PKGCONFIG += connman-qt5
}

CONFIG += console link_pkgconfig
Expand Down
13 changes: 13 additions & 0 deletions connd/qconnectionmanager.cpp
Expand Up @@ -134,26 +134,32 @@ QConnectionManager & QConnectionManager::instance()
// from useragent
void QConnectionManager::onUserInputRequested(const QString &servicePath, const QVariantMap &fields)
{
qDebug() << Q_FUNC_INFO;

// gets called when a connman service gets called to connect and needs more configurations.
Q_EMIT userInputRequested(servicePath, fields);
}

// from useragent
void QConnectionManager::onUserInputCanceled()
{
qDebug() << Q_FUNC_INFO;

Q_EMIT userInputCanceled();
}

// from useragent
void QConnectionManager::onErrorReported(const QString &error)
{
qDebug() << Q_FUNC_INFO;
Q_EMIT errorReported(error);

}

// from useragent
void QConnectionManager::onConnectionRequest()
{
qDebug() << Q_FUNC_INFO;
sendConnectReply("Suppress", 15);
if (!autoConnect()) {
Q_EMIT connectionRequest();
Expand Down Expand Up @@ -298,6 +304,12 @@ void QConnectionManager::connectToType(const QString &type)
{
currentType = type;
QString techPath = netman->technologyPathForType(type);
qDebug() << Q_FUNC_INFO << techPath;

if (techPath.isEmpty()) {
Q_EMIT errorReported("Type not valid");
return;
}

NetworkTechnology netTech;
netTech.setPath(techPath);
Expand All @@ -316,6 +328,7 @@ void QConnectionManager::connectToType(const QString &type)
} else {
qDebug() << Q_FUNC_INFO << "services list is empty";
needConfig = true;
// Q_EMIT errorReported("Service not found"); ?? do we want to report an error
}
} else {
currentType = "";
Expand Down
3 changes: 2 additions & 1 deletion connectionagent.pro
Expand Up @@ -2,9 +2,10 @@ TEMPLATE = subdirs

TEMPLATE += ordered

SUBDIRS += config
SUBDIRS += config
SUBDIRS += connd
SUBDIRS += connectionagentplugin
SUBDIRS += test

equals(QT_MAJOR_VERSION, 4): {
SUBDIRS += test/testqml
Expand Down
1 change: 1 addition & 0 deletions connectionagentplugin/connectionagentplugin.cpp
Expand Up @@ -140,6 +140,7 @@ void ConnectionAgentPlugin::onUserInputRequested(const QString &service, const Q

void ConnectionAgentPlugin::onConnectionRequested()
{
qDebug() << Q_FUNC_INFO;
Q_EMIT connectionRequest();
}

Expand Down
13 changes: 7 additions & 6 deletions rpm/connectionagent-qt5.spec
Expand Up @@ -9,7 +9,7 @@ Name: connectionagent-qt5
# << macros

Summary: User Agent daemon
Version: 0.6.8
Version: 0.6.9
Release: 0
Group: Communications/Connectivity Adaptation
License: LGPLv2
Expand All @@ -20,6 +20,9 @@ Requires: connman-qt5-declarative
BuildRequires: pkgconfig(Qt5Core)
BuildRequires: pkgconfig(Qt5DBus)
BuildRequires: pkgconfig(connman-qt5)
BuildRequires: pkgconfig(Qt5Network)
BuildRequires: pkgconfig(Qt5Test)
BuildRequires: pkgconfig(Qt5Quick)

%description
Connection Agent provides multi user access to connman's User Agent.
Expand All @@ -36,13 +39,13 @@ Requires: %{name} = %{version}
This package contains the declarative plugin for connection agent.

%package test
Summary: Declarative test for connection agent.
Summary: auto test for connection agent.
Group: Development/Tools
Requires: %{name} = %{version}-%{release}
Requires: %{name} = %{version}

%description test
This package contains the declarative plugin for connection agent.
This package contains the auto tests for connection agent.

%prep
%setup -q -n %{name}-%{version}
Expand Down Expand Up @@ -86,8 +89,6 @@ rm -rf %{buildroot}

%files test
%defattr(-,root,root,-)
/opt/sdk/bin/testqml
/opt/sdk/share/applications/testqml.desktop
/opt/sdk/share/testqml/*
%{_prefix}/opt/tests/libqofono/*
# >> files test
# << files test
14 changes: 8 additions & 6 deletions rpm/connectionagent-qt5.yaml
@@ -1,6 +1,6 @@
Name: connectionagent-qt5
Summary: User Agent daemon
Version: 0.6.8
Version: 0.6.9
Release: 0
Group: "Communications/Connectivity Adaptation"
License: LGPLv2
Expand All @@ -18,6 +18,9 @@ PkgConfigBR:
- Qt5Core
- Qt5DBus
- connman-qt5
- Qt5Network
- Qt5Test
- Qt5Quick

Configure: none
Builder: qmake5
Expand All @@ -36,14 +39,13 @@ SubPackages:
- "%{_libdir}/qt5/imports/com/jolla/connection/*"

- Name: test
Summary: Declarative test for connection agent.
Summary: auto test for connection agent.
Group: Development/Tools
Description: This package contains the declarative plugin for connection agent.
Description: This package contains the auto tests for connection agent.
Requires:
- "%{name} = %{version}"
Files:
- "/opt/sdk/bin/testqml"
- "/opt/sdk/share/applications/testqml.desktop"
- "/opt/sdk/share/testqml/*"
- "%{_prefix}/opt/tests/libqofono/*"



8 changes: 5 additions & 3 deletions rpm/connectionagent.spec
Expand Up @@ -9,7 +9,7 @@ Name: connectionagent
# << macros

Summary: User Agent daemon
Version: 0.6.8
Version: 0.6.9
Release: 0
Group: Communications/Connectivity Adaptation
License: LGPLv2
Expand All @@ -20,6 +20,7 @@ Requires: connman-qt-declarative
BuildRequires: pkgconfig(QtCore)
BuildRequires: pkgconfig(QtDBus)
BuildRequires: pkgconfig(connman-qt4)
BuildRequires: pkgconfig(QtNetwork)

%description
Connection Agent provides multi user access to connman's User Agent.
Expand All @@ -36,13 +37,13 @@ Requires: %{name} = %{version}
This package contains the declarative plugin for connection agent.

%package test
Summary: Declarative test for connection agent.
Summary: Tests for connection agent.
Group: Development/Tools
Requires: %{name} = %{version}-%{release}
Requires: %{name} = %{version}

%description test
This package contains the declarative plugin for connection agent.
This package contains the tests for connection agent.

%prep
%setup -q -n %{name}-%{version}
Expand Down Expand Up @@ -89,5 +90,6 @@ rm -rf %{buildroot}
/opt/sdk/bin/testqml
/opt/sdk/share/applications/testqml.desktop
/opt/sdk/share/testqml/*
%{_prefix}/opt/tests/libqofono/*
# >> files test
# << files test
12 changes: 6 additions & 6 deletions rpm/connectionagent.yaml
@@ -1,6 +1,6 @@
Name: connectionagent
Summary: User Agent daemon
Version: 0.6.8
Version: 0.6.9
Release: 0
Group: "Communications/Connectivity Adaptation"
License: LGPLv2
Expand All @@ -17,8 +17,8 @@ Requires:
PkgConfigBR:
- QtCore
- QtDBus
- connman-qt

- connman-qt4
- QtNetwork
Configure: none
Builder: qmake
Files:
Expand All @@ -36,14 +36,14 @@ SubPackages:
- "%{_libdir}/qt4/imports/com/jolla/connection/*"

- Name: test
Summary: Declarative test for connection agent.
Summary: Tests for connection agent.
Group: Development/Tools
Description: This package contains the declarative plugin for connection agent.
Description: This package contains the tests for connection agent.
Requires:
- "%{name} = %{version}"
Files:
- "/opt/sdk/bin/testqml"
- "/opt/sdk/share/applications/testqml.desktop"
- "/opt/sdk/share/testqml/*"

- "%{_prefix}/opt/tests/libqofono/*"

6 changes: 6 additions & 0 deletions test/auto/auto.pro
@@ -0,0 +1,6 @@
TEMPLATE = subdirs

TEMPLATE += ordered

SUBDIRS += tst_connectionagent_plugin

@@ -0,0 +1,43 @@
#-------------------------------------------------
#
# Project created by QtCreator 2013-05-28T05:39:06
#
#-------------------------------------------------

QT += testlib dbus network

QT -= gui

TARGET = tst_connectionagent_plugintest
CONFIG += console
CONFIG -= app_bundle

TEMPLATE = app


SOURCES += tst_connectionagent_plugintest.cpp \
../../../connectionagentplugin/connectionagentplugin.cpp \
../../../connectionagentplugin/connectionamanagerinterface.cpp

HEADERS += \
../../../connectionagentplugin/connectionagentplugin.h \
../../../connectionagentplugin/connectionamanagerinterface.h

DEFINES += SRCDIR=\\\"$$PWD/\\\"

INCLUDEPATH += ../../../connectiongentplugin

equals(QT_MAJOR_VERSION, 4): {
PKGCONFIG += connman-qt4
LIBS += -lconnman-qt4
INCLUDEPATH += /usr/include/connman-qt
}

equals(QT_MAJOR_VERSION, 5): {
PKGCONFIG += connman-qt5
LIBS += -lconnman-qt5
INCLUDEPATH += /usr/include/connman-qt5
}

target.path = $$[QT_INSTALL_PREFIX]/opt/tests/libqofono/
INSTALLS += target

0 comments on commit 074e848

Please sign in to comment.