on xenial help sign in
Added indicators client + autopilot test suite basics.
4c4b83eNick Dedekind
plugins/IndicatorsClient/CMakeLists.txt+1
@@ -16,6 +16,7 @@ endif()
16
16
17
17
18add_subdirectory(indicators)
18add_subdirectory(indicators)
19+add_subdirectory(client)
19
20
20if(NETWORK_PLUGIN_ENABLED)
21if(NETWORK_PLUGIN_ENABLED)
21 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNETWORK_PLUGIN_ENABLED" )
22 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNETWORK_PLUGIN_ENABLED" )
plugins/IndicatorsClient/client/CMakeLists.txtnew file+30
@@ -0,0 +1,30 @@
1+project(indicators_client)
2+set(INDICATORS_CLIENT_APP indicators-client)
3+
4+set(INDICATORS_CLIENT_SRC
5+ main.cpp
6+ indicatorsclient.cpp
7+)
8+
9+set(INDICATORS_CLIENT_HEADERS
10+ indicatorsclient.h
11+)
12+
13+qt5_add_resources(INDICATORS_CLIENT_RESOURCES_RCC
14+ indicatorsclient.qrc)
15+
16+add_executable(${INDICATORS_CLIENT_APP}
17+ ${INDICATORS_CLIENT_SRC}
18+ ${INDICATORS_CLIENT_RESOURCES_RCC}
19+ ${INDICATORS_CLIENT_HEADERS}
20+)
21+
22+include_directories(
23+ ${CMAKE_BINARY_DIR}
24+)
25+
26+qt5_use_modules(${INDICATORS_CLIENT_APP} Core Widgets Quick)
27+set_target_properties(${INDICATORS_CLIENT_APP} PROPERTIES COMPILE_FLAGS -fPIC)
28+
29+install(TARGETS ${INDICATORS_CLIENT_APP}
30+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
plugins/IndicatorsClient/client/indicatorsclient.cppnew file+60
@@ -0,0 +1,60 @@
1+/*
2+ * Copyright 2013 Canonical Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU Lesser General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU Lesser General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU Lesser General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ *
16+ * Authors:
17+ * Renato Araujo Oliveira Filho <renato@canonical.com>
18+ * Nick Dedekind <nick.dedekind@canonical.com>
19+ */
20+
21+#include "indicatorsclient.h"
22+
23+#include <QQuickView>
24+#include <QQmlContext>
25+#include <QQmlEngine>
26+#include <QDebug>
27+
28+IndicatorsClient::IndicatorsClient(int &argc, char **argv)
29+ : QObject(0),
30+ m_view(0)
31+{
32+ m_application = new QApplication(argc, argv);
33+}
34+
35+IndicatorsClient::~IndicatorsClient()
36+{
37+ if (m_view != 0) {
38+ delete m_view;
39+ }
40+
41+ delete m_application;
42+}
43+
44+void IndicatorsClient::setupUI()
45+{
46+ m_view = new QQuickView;
47+
48+ m_view->setSource(QUrl("qrc:qml/indicatorsclient.qml"));
49+ m_view->setResizeMode(QQuickView::SizeRootObjectToView);
50+
51+ //Usable size on desktop
52+ m_view->setMinimumSize(QSize(480, 720));
53+}
54+
55+int IndicatorsClient::run()
56+{
57+ setupUI();
58+ m_view->showMaximized();
59+ return m_application->exec();
60+}
plugins/IndicatorsClient/client/indicatorsclient.hnew file+46
@@ -0,0 +1,46 @@
1+/*
2+ * Copyright 2013 Canonical Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU Lesser General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU Lesser General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU Lesser General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ *
16+ * Authors:
17+ * Renato Araujo Oliveira Filho <renato@canonical.com>
18+ * Nick Dedekind <nick.dedekind@canonical.com>
19+ */
20+
21+#ifndef INDICATORS_CLIENT_H
22+#define INDICATORS_CLIENT_H
23+
24+#include <QApplication>
25+#include <QQuickView>
26+
27+class PluginManager;
28+class WidgetsMap;
29+
30+class IndicatorsClient : public QObject
31+{
32+ Q_OBJECT
33+public:
34+ IndicatorsClient(int &argc, char **argv);
35+ ~IndicatorsClient();
36+
37+ int run();
38+
39+private:
40+ QApplication *m_application;
41+ QQuickView *m_view;
42+
43+ void setupUI();
44+};
45+
46+#endif
plugins/IndicatorsClient/client/indicatorsclient.qrcnew file+7
@@ -0,0 +1,7 @@
1+<RCC>
2+ <qresource prefix="/">
3+ <file>qml/indicatorsclient.qml</file>
4+ <file>qml/indicatorslist.qml</file>
5+ <file>qml/indicatorspage.qml</file>
6+ </qresource>
7+</RCC>
plugins/IndicatorsClient/client/main.cppnew file+26
@@ -0,0 +1,26 @@
1+/*
2+ * Copyright 2013 Canonical Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU Lesser General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU Lesser General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU Lesser General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ *
16+ * Authors:
17+ * Renato Araujo Oliveira Filho <renato@canonical.com>
18+ */
19+
20+#include "indicatorsclient.h"
21+
22+int main(int argc, char** argv)
23+{
24+ IndicatorsClient client(argc, argv);
25+ return client.run();
26+}
plugins/IndicatorsClient/client/qml/indicatorsclient.qmlnew file+32
@@ -0,0 +1,32 @@
1+/*
2+ * Copyright 2013 Canonical Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU Lesser General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU Lesser General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU Lesser General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ *
16+ * Authors:
17+ * Renato Araujo Oliveira Filho <renato@canonical.com>
18+ */
19+
20+import QtQuick 2.0
21+import Ubuntu.Components 0.1
22+import Ubuntu.Components.ListItems 0.1 as ListItem
23+
24+Rectangle {
25+ color: "black"
26+ PageStack {
27+ id: pages
28+
29+ anchors.fill: parent
30+ Component.onCompleted: push(Qt.createComponent("indicatorslist.qml"))
31+ }
32+}
plugins/IndicatorsClient/client/qml/indicatorslist.qmlnew file+78
@@ -0,0 +1,78 @@
1+/*
2+ * Copyright 2013 Canonical Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU Lesser General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU Lesser General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU Lesser General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ *
16+ * Authors:
17+ * Renato Araujo Oliveira Filho <renato@canonical.com>
18+ */
19+
20+import QtQuick 2.0
21+import Ubuntu.Components 0.1
22+import Ubuntu.Components.ListItems 0.1 as ListItem
23+import IndicatorsClient 0.1 as IndicatorsClient
24+
25+Page {
26+ id: page
27+ anchors.fill: parent
28+ title: "Plugin list"
29+
30+ IndicatorsClient.IndicatorsModel {
31+ id: indicators
32+
33+ Component.onCompleted: indicators.load()
34+ }
35+
36+ ListView {
37+ id: mainMenu
38+ anchors.fill: parent
39+ model: indicators
40+
41+ delegate: IndicatorsClient.Menu {
42+ anchors.left: parent.left
43+ anchors.right: parent.right
44+ height: implicitHeight
45+ progression: isValid
46+ objectName: title
47+
48+ // Used basic components instead of 'ListItem.Standard' properties because it does not support image resize
49+ Image {
50+ id: itemIcon
51+ anchors.left: parent.left
52+ anchors.verticalCenter: parent.verticalCenter
53+ source: iconSource
54+ smooth: true
55+ width: units.gu(5)
56+ height: units.gu(5)
57+ }
58+
59+ Label {
60+ anchors.left: itemIcon.right
61+ anchors.leftMargin: units.gu(0.5)
62+ anchors.verticalCenter: parent.verticalCenter
63+ text: (label != "") ? (title + " (" + label + ")") : title
64+ }
65+
66+ onClicked: {
67+ if (progression) {
68+ var props = model.initialProperties
69+ props["widgetsMap"] = indicators.widgetsMap
70+
71+ var page = Qt.createComponent("indicatorspage.qml")
72+ pages.push(page, {"initialProperties" : props, "component" : model.component})
73+ }
74+ }
75+ }
76+ }
77+}
78+
plugins/IndicatorsClient/client/qml/indicatorspage.qmlnew file+48
@@ -0,0 +1,48 @@
1+/*
2+ * Copyright 2013 Canonical Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU Lesser General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU Lesser General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU Lesser General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ *
16+ * Authors:
17+ * Renato Araujo Oliveira Filho <renato@canonical.com>
18+ */
19+
20+import QtQuick 2.0
21+import Ubuntu.Components 0.1
22+
23+Page {
24+ id: _page
25+
26+ title: initialProperties && initialProperties.title ? initialProperties.title : ""
27+ property variant initialProperties
28+ property alias component : _loader.sourceComponent
29+
30+ anchors.fill: parent
31+
32+ Loader {
33+ id: _loader
34+
35+ anchors.fill: parent
36+
37+ onStatusChanged: {
38+ if (status == Loader.Ready) {
39+ for(var pName in initialProperties) {
40+ if (item.hasOwnProperty(pName)) {
41+ item[pName] = initialProperties[pName]
42+ }
43+ }
44+ item.start()
45+ }
46+ }
47+ }
48+}
plugins/IndicatorsClient/indicatorsfactory.cpp+1−1
@@ -32,7 +32,7 @@ IndicatorsFactory::IndicatorsFactory()
32 registerItem<IndicatorClientDateTime>("indicator-datetime");
32 registerItem<IndicatorClientDateTime>("indicator-datetime");
33 registerItem<IndicatorClientMessaging>("indicator-messaging");
33 registerItem<IndicatorClientMessaging>("indicator-messaging");
34 registerItem<IndicatorClientNetwork>("indicator-network");
34 registerItem<IndicatorClientNetwork>("indicator-network");
35− registerItem<IndicatorClientPower>("indicator-battery");
35+ registerItem<IndicatorClientPower>("indicator-power");
36 registerItem<IndicatorClientSound>("indicator-sound");
36 registerItem<IndicatorClientSound>("indicator-sound");
37}
37}
38
38
tests/autopilot/indicators_client/__init__.pynew file+8
@@ -0,0 +1,8 @@
1+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2+# Copyright 2013 Canonical
3+#
4+# This program is free software: you can redistribute it and/or modify it
5+# under the terms of the GNU General Public License version 3, as published
6+# by the Free Software Foundation.
7+
8+"""indicators-client autopilot tests and emulators - top level package."""
tests/autopilot/indicators_client/emulators/__init__.pynew file+6
@@ -0,0 +1,6 @@
1+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2+# Copyright 2013 Canonical
3+#
4+# This program is free software: you can redistribute it and/or modify it
5+# under the terms of the GNU General Public License version 3, as published
6+# by the Free Software Foundation.
tests/autopilot/indicators_client/emulators/main_window.pynew file+18
@@ -0,0 +1,18 @@
1+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2+# Copyright 2013 Canonical
3+#
4+# This program is free software: you can redistribute it and/or modify it
5+# under the terms of the GNU General Public License version 3, as published
6+# by the Free Software Foundation.
7+
8+class MainWindow(object):
9+ """An emulator class that makes it easy to interact with the shell"""
10+
11+ def __init__(self, app):
12+ self.app = app
13+
14+ def get_panel(self):
15+ return self.app.select_single("Panel")
16+
17+ def get_indicator(self):
18+ return self.app.select_single("Indicator")
tests/autopilot/indicators_client/tests/__init__.pynew file+54
@@ -0,0 +1,54 @@
1+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2+# Copyright 2013 Canonical
3+#
4+# This program is free software: you can redistribute it and/or modify it
5+# under the terms of the GNU General Public License version 3, as published
6+# by the Free Software Foundation.
7+
8+"""qml-phone-shell autopilot tests."""
9+
10+import os.path
11+
12+from autopilot.testcase import AutopilotTestCase
13+from autopilot.matchers import Eventually
14+from autopilot.platform import model
15+from testtools.matchers import Equals
16+
17+from indicators_client.emulators.main_window import MainWindow
18+
19+class FormFactors(object):
20+ Phone, Tablet, Desktop = range(3)
21+
22+class IndicatorsTestCase(AutopilotTestCase):
23+
24+ """A common test case class that provides several useful methods for shell tests."""
25+
26+ def setUp(self, geometry, grid_size):
27+ super(ShellTestCase, self).setUp()
28+ self.launch_test_local(geometry)
29+
30+ def launch_test_local(self, geometry):
31+ os.environ['LD_LIBRARY_PATH'] = "../../../unity_build/build/lib"
32+ os.environ['QML2_IMPORT_PATH'] = "../../builddir/plugins:../../builddir/tests/mocks"
33+ self.app = self.launch_test_application(
34+ "../../builddir/plugins/IndicatorsClient/client/indicators-client")
35+
36+ def skipWrapper(*args, **kwargs):
37+ pass
38+
39+ def form_factor(self):
40+ return FormFactors.Desktop
41+
42+ def __getattribute__(self, attr_name):
43+ attr = object.__getattribute__(self, attr_name);
44+ if attr_name.startswith("test_"):
45+ try:
46+ if self.form_factor() in attr.blacklist:
47+ return self.skipWrapper
48+ except:
49+ pass
50+ return attr
51+
52+ @property
53+ def main_window(self):
54+ return MainWindow(self.app)