on xenial help sign in
Add a mock AccountsService that always returns false, to avoid confusing autopilot tests
commit68f514d6cc9e101713da6207f4f33d7bf78114d2 authorMichael Terry <michael.terry@canonical.com> dateTue 30 Jul 2013, 19:22 (13 years ago) parent46cee69
8 files changed+168−1
plugins/AccountsService/CMakeLists.txt+1 tests/mocks/AccountsService/AccountsService.cpp+33 tests/mocks/AccountsService/AccountsService.h+39 tests/mocks/AccountsService/CMakeLists.txt+19 tests/mocks/AccountsService/plugin.cpp+36 tests/mocks/AccountsService/plugin.h+35 tests/mocks/AccountsService/qmldir+3 tests/mocks/CMakeLists.txt+2−1
plugins/AccountsService/CMakeLists.txt+1
@@ -9,6 +9,7 @@ add_library(AccountsService-qml MODULE
99
1010qt5_use_modules(AccountsService-qml DBus Qml)
1111
12+export_qmlfiles(AccountsService AccountsService)
1213export_qmlplugin(AccountsService 0.1 AccountsService TARGETS AccountsService-qml)
1314
1415set(POLICYKIT_DIR "${CMAKE_INSTALL_PREFIX}/share/polkit-1")
tests/mocks/AccountsService/AccountsService.cppnew file+33
@@ -0,0 +1,33 @@
1+/*
2+ * Copyright (C) 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 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 General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ *
16+ * Author: Michael Terry <michael.terry@canonical.com>
17+ */
18+
19+#include "AccountsService.h"
20+
21+AccountsService::AccountsService(QObject* parent)
22+ : QObject(parent)
23+{
24+}
25+
26+QVariant AccountsService::getUserProperty(const QString &user, const QString &property)
27+{
28+ return QVariant(false);
29+}
30+
31+void AccountsService::setUserProperty(const QString &user, const QString &property, const QVariant &value)
32+{
33+}
tests/mocks/AccountsService/AccountsService.hnew file+39
@@ -0,0 +1,39 @@
1+/*
2+ * Copyright (C) 2012,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 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 General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ *
16+ * Authors: Gerry Boland <gerry.boland@canonical.com>
17+ * Michael Terry <michael.terry@canonical.com>
18+ */
19+
20+#ifndef UNITY_MOCK_ACCOUNTSSERVICE_H
21+#define UNITY_MOCK_ACCOUNTSSERVICE_H
22+
23+#include <QtCore/QObject>
24+#include <QtCore/QString>
25+#include <QtCore/QVariant>
26+
27+class AccountsService: public QObject
28+{
29+ Q_OBJECT
30+
31+public:
32+ explicit AccountsService(QObject *parent = 0);
33+
34+public Q_SLOTS:
35+ QVariant getUserProperty(const QString &user, const QString &property);
36+ void setUserProperty(const QString &user, const QString &property, const QVariant &value);
37+};
38+
39+#endif
tests/mocks/AccountsService/CMakeLists.txtnew file+19
@@ -0,0 +1,19 @@
1+add_library(MockAccountsService-qml MODULE
2+ AccountsService.cpp
3+ plugin.cpp
4+ )
5+
6+qt5_use_modules(MockAccountsService-qml DBus Qml)
7+
8+# copy files into build directory for shadow builds
9+file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/qmldir"
10+ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
11+ )
12+
13+install(TARGETS MockAccountsService-qml
14+ DESTINATION ${SHELL_PRIVATE_LIBDIR}/qml/mocks/AccountsService
15+ )
16+
17+install(FILES qmldir
18+ DESTINATION ${SHELL_PRIVATE_LIBDIR}/qml/mocks/AccountsService
19+ )
tests/mocks/AccountsService/plugin.cppnew file+36
@@ -0,0 +1,36 @@
1+/*
2+ * Copyright (C) 2012,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 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 General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ *
16+ * Authors: Gerry Boland <gerry.boland@canonical.com>
17+ * Michael Terry <michael.terry@canonical.com>
18+ */
19+
20+#include "plugin.h"
21+#include "AccountsService.h"
22+
23+#include <QtQml/QtQml>
24+
25+static QObject *service_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
26+{
27+ Q_UNUSED(engine)
28+ Q_UNUSED(scriptEngine)
29+ return new AccountsService();
30+}
31+
32+void AccountsServicePlugin::registerTypes(const char *uri)
33+{
34+ Q_ASSERT(uri == QLatin1String("AccountsService"));
35+ qmlRegisterSingletonType<AccountsService>(uri, 0, 1, "AccountsService", service_provider);
36+}
tests/mocks/AccountsService/plugin.hnew file+35
@@ -0,0 +1,35 @@
1+/*
2+ * Copyright (C) 2012,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 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 General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ *
16+ * Authors: Gerry Boland <gerry.boland@canonical.com>
17+ * Michael Terry <michael.terry@canonical.com>
18+ */
19+
20+#ifndef MOCK_ACCOUNTSSERVICE_PLUGIN_H
21+#define MOCK_ACCOUNTSSERVICE_PLUGIN_H
22+
23+#include <QtQml/QQmlEngine>
24+#include <QtQml/QQmlExtensionPlugin>
25+
26+class AccountsServicePlugin : public QQmlExtensionPlugin
27+{
28+ Q_OBJECT
29+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
30+
31+public:
32+ void registerTypes(const char *uri);
33+};
34+
35+#endif
tests/mocks/AccountsService/qmldirnew file+3
@@ -0,0 +1,3 @@
1+module AccountsService
2+plugin MockAccountsService-qml
3+typeinfo plugin.qmltypes
tests/mocks/CMakeLists.txt+2−1
@@ -1,6 +1,7 @@
1+add_subdirectory(AccountsService)
2+add_subdirectory(HudClient)
13add_subdirectory(libusermetrics)
24add_subdirectory(LightDM)
35add_subdirectory(QMenuModel)
46add_subdirectory(Ubuntu)
57add_subdirectory(Unity)
6−add_subdirectory(HudClient)