on xenial help sign in
Unify all liblightdm mocks
127c1c7Daniel d'Andrada
plugins/LightDM/CMakeLists.txt+3−1
@@ -4,6 +4,8 @@ pkg_check_modules(LIBUSERMETRICSOUTPUT REQUIRED libusermetricsoutput-1)
4# TODO: Once we split out a separate greeter process, uncomment these lines
4# TODO: Once we split out a separate greeter process, uncomment these lines
5#pkg_check_modules(LIBLIGHTDM REQUIRED liblightdm-qt5-2)
5#pkg_check_modules(LIBLIGHTDM REQUIRED liblightdm-qt5-2)
6
6
7+add_subdirectory(liblightdm)
8+
7include_directories(
9include_directories(
8 ${CMAKE_CURRENT_SOURCE_DIR}
10 ${CMAKE_CURRENT_SOURCE_DIR}
9 ${CMAKE_CURRENT_BINARY_DIR}
11 ${CMAKE_CURRENT_BINARY_DIR}
@@ -28,7 +30,7 @@ add_library(LightDM-qml MODULE
28 )
30 )
29
31
30target_link_libraries(LightDM-qml
32target_link_libraries(LightDM-qml
31− MockLightDM-demo
33+ integratedLightDM
32 unity8-private
34 unity8-private
33# TODO: Once we split out a separate greeter process, uncomment these lines
35# TODO: Once we split out a separate greeter process, uncomment these lines
34# ${LIBLIGHTDM_LDFLAGS}
36# ${LIBLIGHTDM_LDFLAGS}
plugins/LightDM/Greeter.cpp+1−19
@@ -17,26 +17,8 @@
17 */
17 */
18
18
19#include "Greeter.h"
19#include "Greeter.h"
20+#include "GreeterPrivate.h"
20#include <libintl.h>
21#include <libintl.h>
21−#include <QLightDM/Greeter>
22−
23−class GreeterPrivate
24−{
25−public:
26− explicit GreeterPrivate(Greeter *parent);
27−
28− QLightDM::Greeter *m_greeter;
29− bool m_active;
30− bool wasPrompted;
31− bool promptless;
32−
33−protected:
34− Greeter * const q_ptr;
35−
36−private:
37− Q_DECLARE_PUBLIC(Greeter)
38−};
39−
40
22
41GreeterPrivate::GreeterPrivate(Greeter* parent)
23GreeterPrivate::GreeterPrivate(Greeter* parent)
42 : m_greeter(new QLightDM::Greeter(parent)),
24 : m_greeter(new QLightDM::Greeter(parent)),
plugins/LightDM/Greeter.h+1−1
@@ -68,7 +68,7 @@ Q_SIGNALS:
68 // should switch to this user if possible.
68 // should switch to this user if possible.
69 void requestAuthenticationUser(const QString &user);
69 void requestAuthenticationUser(const QString &user);
70
70
71−private:
71+protected:
72 GreeterPrivate * const d_ptr;
72 GreeterPrivate * const d_ptr;
73
73
74 Q_DECLARE_PRIVATE(Greeter)
74 Q_DECLARE_PRIVATE(Greeter)
tests/mocks/LightDM/single-pin/UsersModelPrivate.cpp → plugins/LightDM/GreeterPrivate.hrenamed+20−14
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2013 Canonical, Ltd.
2+ * Copyright (C) 2014 Canonical, Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
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
5 * it under the terms of the GNU General Public License as published by
@@ -12,22 +12,28 @@
12 *
12 *
13 * You should have received a copy of the GNU General Public License
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/>.
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− *
16− * Author: Michael Terry <michael.terry@canonical.com>
17 */
15 */
18
16
19−#include "../UsersModelPrivate.h"
17+#ifndef UNITY_GREETER_PRIVATE_H
18+#define UNITY_GREETER_PRIVATE_H
20
19
21−namespace QLightDM
20+#include <QLightDM/Greeter>
22−{
23
21
24−UsersModelPrivate::UsersModelPrivate(UsersModel* parent)
22+class GreeterPrivate
25− : q_ptr(parent)
26{
23{
27− entries =
24+public:
28− {
25+ explicit GreeterPrivate(Greeter *parent);
29− { "has-pin", "Has PIN", 0, 0, false, false, 0, 0 },
26+
30− };
27+ QLightDM::Greeter *m_greeter;
28+ bool m_active;
29+ bool wasPrompted;
30+ bool promptless;
31+
32+protected:
33+ Greeter * const q_ptr;
34+
35+private:
36+ Q_DECLARE_PUBLIC(Greeter)
31−}
37+};
32
38
33−}
39+#endif // UNITY_GREETER_PRIVATE_H
tests/mocks/LightDM/demo/CMakeLists.txt → plugins/LightDM/liblightdm/CMakeLists.txtrenamed+6−6
@@ -1,14 +1,14 @@
1pkg_check_modules(LIBUSERMETRICSOUTPUT REQUIRED libusermetricsoutput-1)
1pkg_check_modules(LIBUSERMETRICSOUTPUT REQUIRED libusermetricsoutput-1)
2
2
3set(LibLightDM_SOURCES
3set(LibLightDM_SOURCES
4− ../Greeter.cpp
4+ Greeter.cpp
5− ../UsersModel.cpp
5+ UsersModel.cpp
6 GreeterPrivate.cpp
6 GreeterPrivate.cpp
7 UsersModelPrivate.cpp
7 UsersModelPrivate.cpp
8 ${CMAKE_SOURCE_DIR}/plugins/Utils/qvariantlistmodel.cpp
8 ${CMAKE_SOURCE_DIR}/plugins/Utils/qvariantlistmodel.cpp
9 )
9 )
10
10
11−add_library(MockLightDM-demo STATIC ${LibLightDM_SOURCES})
11+add_library(integratedLightDM STATIC ${LibLightDM_SOURCES})
12add_library(MockLightDM-demo-shared SHARED ${LibLightDM_SOURCES})
12add_library(MockLightDM-demo-shared SHARED ${LibLightDM_SOURCES})
13
13
14include_directories(
14include_directories(
@@ -16,7 +16,7 @@ include_directories(
16 ${LIBUSERMETRICSOUTPUT_INCLUDE_DIRS}
16 ${LIBUSERMETRICSOUTPUT_INCLUDE_DIRS}
17)
17)
18
18
19−target_link_libraries(MockLightDM-demo
19+target_link_libraries(integratedLightDM
20 ${LIBUSERMETRICSOUTPUT_LDFLAGS}
20 ${LIBUSERMETRICSOUTPUT_LDFLAGS}
21 -lpam
21 -lpam
22)
22)
@@ -25,10 +25,10 @@ target_link_libraries(MockLightDM-demo-shared
25 -lpam
25 -lpam
26)
26)
27
27
28−qt5_use_modules(MockLightDM-demo Concurrent Gui)
28+qt5_use_modules(integratedLightDM Concurrent Gui)
29qt5_use_modules(MockLightDM-demo-shared Concurrent Gui)
29qt5_use_modules(MockLightDM-demo-shared Concurrent Gui)
30
30
31−set_target_properties(MockLightDM-demo PROPERTIES COMPILE_FLAGS -fPIC)
31+set_target_properties(integratedLightDM PROPERTIES COMPILE_FLAGS -fPIC)
32set_target_properties(MockLightDM-demo-shared PROPERTIES
32set_target_properties(MockLightDM-demo-shared PROPERTIES
33 OUTPUT_NAME lightdm-qt5-2)
33 OUTPUT_NAME lightdm-qt5-2)
34
34
tests/mocks/LightDM/Greeter.cpp → plugins/LightDM/liblightdm/Greeter.cpprenamed+7−7
@@ -16,6 +16,13 @@
16 * Author: Michael Terry <michael.terry@canonical.com>
16 * Author: Michael Terry <michael.terry@canonical.com>
17 */
17 */
18
18
19+
20+/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
21+ * CHANGES MADE HERE MUST BE REFLECTED ON THE MOCK LIB
22+ * COUNTERPART IN tests/mocks/Lightdm/liblightdm
23+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
24+
25+
19#include "Greeter.h"
26#include "Greeter.h"
20#include "GreeterPrivate.h"
27#include "GreeterPrivate.h"
21#include <QtCore/QCoreApplication>
28#include <QtCore/QCoreApplication>
@@ -128,13 +135,6 @@ void Greeter::authenticate(const QString &username)
128
135
129 d->authenticated = false;
136 d->authenticated = false;
130 d->authenticationUser = username;
137 d->authenticationUser = username;
131− d->twoFactorDone = false;
132− QTimer::singleShot(0, this, SLOT(delayedAuthentication()));
133−}
134−
135−void Greeter::delayedAuthentication()
136−{
137− Q_D(Greeter);
138 d->handleAuthenticate();
138 d->handleAuthenticate();
139}
139}
140
140
tests/mocks/LightDM/Greeter.h → plugins/LightDM/liblightdm/Greeter.hrenamed+4−3
@@ -24,6 +24,10 @@
24#include <QtCore/QObject>
24#include <QtCore/QObject>
25#include <QtCore/QVariant>
25#include <QtCore/QVariant>
26
26
27+/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
28+ * CHANGES MADE HERE MUST BE REFLECTED ON THE MOCK LIB
29+ * COUNTERPART IN tests/mocks/Lightdm/liblightdm
30+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
27
31
28namespace QLightDM
32namespace QLightDM
29{
33{
@@ -99,9 +103,6 @@ Q_SIGNALS:
99protected:
103protected:
100 void sendAuthenticationComplete();
104 void sendAuthenticationComplete();
101
105
102−private Q_SLOTS:
103− void delayedAuthentication();
104−
105private:
106private:
106 GreeterPrivate *d_ptr;
107 GreeterPrivate *d_ptr;
107 Q_DECLARE_PRIVATE(Greeter)
108 Q_DECLARE_PRIVATE(Greeter)
tests/mocks/LightDM/demo/GreeterPrivate.cpp → plugins/LightDM/liblightdm/GreeterPrivate.cpprenamed+2−2
@@ -16,8 +16,8 @@
16 * Author: Michael Terry <michael.terry@canonical.com>
16 * Author: Michael Terry <michael.terry@canonical.com>
17 */
17 */
18
18
19−#include "../Greeter.h"
19+#include "Greeter.h"
20−#include "../GreeterPrivate.h"
20+#include "GreeterPrivate.h"
21#include <QFuture>
21#include <QFuture>
22#include <QFutureInterface>
22#include <QFutureInterface>
23#include <QFutureWatcher>
23#include <QFutureWatcher>
tests/mocks/LightDM/GreeterPrivate.h → plugins/LightDM/liblightdm/GreeterPrivate.hrenamed−1
@@ -35,7 +35,6 @@ public:
35 // These variables may not be used by all subclasses, that's no problem
35 // These variables may not be used by all subclasses, that's no problem
36 bool authenticated;
36 bool authenticated;
37 QString authenticationUser;
37 QString authenticationUser;
38− bool twoFactorDone;
39
38
40 void handleAuthenticate();
39 void handleAuthenticate();
41 void handleRespond(const QString &response);
40 void handleRespond(const QString &response);
tests/mocks/LightDM/UsersModel.cpp → plugins/LightDM/liblightdm/UsersModel.cpprenamed+6
@@ -16,6 +16,12 @@
16 * Author: Michael Terry <michael.terry@canonical.com>
16 * Author: Michael Terry <michael.terry@canonical.com>
17 */
17 */
18
18
19+
20+/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
21+ * CHANGES MADE HERE MUST BE REFLECTED ON THE MOCK LIB
22+ * COUNTERPART IN tests/mocks/Lightdm/liblightdm
23+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
24+
19// LightDM currently is Qt4 compatible, and so doesn't define setRoleNames.
25// LightDM currently is Qt4 compatible, and so doesn't define setRoleNames.
20// To use the same method of setting role name that it does, we
26// To use the same method of setting role name that it does, we
21// set our compatibility to Qt4 here too.
27// set our compatibility to Qt4 here too.
tests/mocks/LightDM/UsersModel.h → plugins/LightDM/liblightdm/UsersModel.hrenamed+4
@@ -24,6 +24,10 @@
24#include <QtCore/QSharedDataPointer>
24#include <QtCore/QSharedDataPointer>
25#include <QAbstractListModel>
25#include <QAbstractListModel>
26
26
27+/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
28+ * CHANGES MADE HERE MUST BE REFLECTED ON THE MOCK LIB
29+ * COUNTERPART IN tests/mocks/Lightdm/liblightdm
30+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
27
31
28namespace QLightDM
32namespace QLightDM
29{
33{
tests/mocks/LightDM/demo/UsersModelPrivate.cpp → plugins/LightDM/liblightdm/UsersModelPrivate.cpprenamed+1−1
@@ -16,7 +16,7 @@
16 * Author: Michael Terry <michael.terry@canonical.com>
16 * Author: Michael Terry <michael.terry@canonical.com>
17 */
17 */
18
18
19−#include "../UsersModelPrivate.h"
19+#include "UsersModelPrivate.h"
20
20
21#include <QDir>
21#include <QDir>
22#include <QSettings>
22#include <QSettings>
tests/mocks/LightDM/UsersModelPrivate.h → plugins/LightDM/liblightdm/UsersModelPrivate.hrenamed

The content is the same.

tests/mocks/LightDM/CMakeLists.txt+8−9
@@ -4,16 +4,13 @@
4# actually using the system liblightdm in the normal plugin, this version can
4# actually using the system liblightdm in the normal plugin, this version can
5# be deleted.
5# be deleted.
6
6
7−add_subdirectory(demo)
7+add_subdirectory(liblightdm)
8−add_subdirectory(full)
9−add_subdirectory(single)
10−add_subdirectory(single-pin)
11−add_subdirectory(single-passphrase)
12
8
13include_directories(
9include_directories(
14 ${CMAKE_CURRENT_SOURCE_DIR}
10 ${CMAKE_CURRENT_SOURCE_DIR}
15 ${CMAKE_CURRENT_BINARY_DIR}
11 ${CMAKE_CURRENT_BINARY_DIR}
16 ${CMAKE_SOURCE_DIR}/plugins/Utils
12 ${CMAKE_SOURCE_DIR}/plugins/Utils
13+ ${CMAKE_SOURCE_DIR}/plugins/LightDM
17 ${CMAKE_SOURCE_DIR}/tests/mocks/libusermetrics
14 ${CMAKE_SOURCE_DIR}/tests/mocks/libusermetrics
18 ${libunity8-private_SOURCE_DIR}
15 ${libunity8-private_SOURCE_DIR}
19)
16)
@@ -22,9 +19,11 @@ set(QMLPLUGIN_SRC
22 ${CMAKE_SOURCE_DIR}/plugins/LightDM/DBusGreeter.cpp
19 ${CMAKE_SOURCE_DIR}/plugins/LightDM/DBusGreeter.cpp
23 ${CMAKE_SOURCE_DIR}/plugins/LightDM/DBusGreeterList.cpp
20 ${CMAKE_SOURCE_DIR}/plugins/LightDM/DBusGreeterList.cpp
24 ${CMAKE_SOURCE_DIR}/plugins/LightDM/Greeter.cpp
21 ${CMAKE_SOURCE_DIR}/plugins/LightDM/Greeter.cpp
25− ${CMAKE_SOURCE_DIR}/plugins/LightDM/plugin.cpp
26 ${CMAKE_SOURCE_DIR}/plugins/LightDM/UsersModel.cpp
22 ${CMAKE_SOURCE_DIR}/plugins/LightDM/UsersModel.cpp
27 ${CMAKE_SOURCE_DIR}/plugins/Utils/unitysortfilterproxymodelqml.cpp
23 ${CMAKE_SOURCE_DIR}/plugins/Utils/unitysortfilterproxymodelqml.cpp
24+ MockGreeter.cpp
25+ MockUsersModel.cpp
26+ plugin.cpp
28 )
27 )
29
28
30add_library(MockLightDM-qml MODULE
29add_library(MockLightDM-qml MODULE
@@ -35,9 +34,9 @@ add_library(MockLightDM-qml MODULE
35# installed on the system. So we make sure we link to our full fake version
34# installed on the system. So we make sure we link to our full fake version
36# At run time, we can point to whichever version we happen to be using via
35# At run time, we can point to whichever version we happen to be using via
37# LD_LIBRARY_PATH.
36# LD_LIBRARY_PATH.
38−add_dependencies(MockLightDM-qml MockLightDM-full MockUserMetrics)
37+add_dependencies(MockLightDM-qml MockLightDM MockUserMetrics)
39target_link_libraries(MockLightDM-qml
38target_link_libraries(MockLightDM-qml
40− -L${CMAKE_CURRENT_BINARY_DIR}/full
39+ -L${CMAKE_CURRENT_BINARY_DIR}/liblightdm
41 -llightdm-qt5-2
40 -llightdm-qt5-2
42 -L${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics
41 -L${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics
43 -lusermetricsoutput
42 -lusermetricsoutput
@@ -49,5 +48,5 @@ qt5_use_modules(MockLightDM-qml DBus Gui Qml)
49add_unity8_mock(LightDM 0.1 LightDM
48add_unity8_mock(LightDM 0.1 LightDM
50 PREFIX mocks
49 PREFIX mocks
51 TARGETS MockLightDM-qml
50 TARGETS MockLightDM-qml
52− ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_CURRENT_BINARY_DIR}/full"
51+ ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_CURRENT_BINARY_DIR}/liblightdm"
53)
52)
tests/mocks/LightDM/single/UsersModelPrivate.cpp → tests/mocks/LightDM/MockGreeter.cpprenamed+13−11
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2013 Canonical, Ltd.
2+ * Copyright (C) 2014 Canonical, Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
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
5 * it under the terms of the GNU General Public License as published by
@@ -13,21 +13,23 @@
13 * You should have received a copy of the GNU General Public License
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/>.
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
15 *
16− * Author: Michael Terry <michael.terry@canonical.com>
17 */
16 */
18
17
19−#include "../UsersModelPrivate.h"
18+#include "MockGreeter.h"
19+#include <GreeterPrivate.h>
20
20
21−namespace QLightDM
21+QString MockGreeter::mockMode() const
22{
22{
23+ Q_D(const Greeter);
24+ return d->m_greeter->mockMode();
25+}
23
26
24−UsersModelPrivate::UsersModelPrivate(UsersModel* parent)
27+void MockGreeter::setMockMode(QString mockMode)
25− : q_ptr(parent)
26{
28{
27− entries =
29+ Q_D(Greeter);
28− {
29− { "single", "Single User", 0, 0, false, false, 0, 0 },
30− };
31−}
32
30
31+ if (d->m_greeter->mockMode() != mockMode) {
32+ d->m_greeter->setMockMode(mockMode);
33+ Q_EMIT mockModeChanged(mockMode);
34+ }
33}
35}
tests/mocks/LightDM/MockGreeter.hnew file+37
@@ -0,0 +1,37 @@
1+/*
2+ * Copyright (C) 2014 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+ */
17+
18+// The real, production, Greeter
19+#include <Greeter.h>
20+
21+#ifndef MOCK_UNITY_GREETER_H
22+#define MOCK_UNITY_GREETER_H
23+
24+class MockGreeter : public Greeter {
25+ Q_OBJECT
26+
27+ Q_PROPERTY(QString mockMode READ mockMode WRITE setMockMode NOTIFY mockModeChanged)
28+
29+public:
30+ QString mockMode() const;
31+ void setMockMode(QString mockMode);
32+
33+Q_SIGNALS:
34+ void mockModeChanged(QString mode);
35+};
36+
37+#endif // MOCK_UNITY_GREETER_H
tests/mocks/LightDM/MockUsersModel.cppnew file+39
@@ -0,0 +1,39 @@
1+/*
2+ * Copyright (C) 2014 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+ */
17+
18+#include "MockUsersModel.h"
19+#include <QLightDM/UsersModel>
20+#include <QSortFilterProxyModel>
21+
22+QString MockUsersModel::mockMode() const
23+{
24+ QLightDM::UsersModel* qUsersModel =
25+ static_cast<QLightDM::UsersModel*>(static_cast<QSortFilterProxyModel*>(sourceModel())->sourceModel());
26+
27+ return qUsersModel->mockMode();
28+}
29+
30+void MockUsersModel::setMockMode(QString mockMode)
31+{
32+ QLightDM::UsersModel* qUsersModel =
33+ static_cast<QLightDM::UsersModel*>(static_cast<QSortFilterProxyModel*>(sourceModel())->sourceModel());
34+
35+ if (qUsersModel->mockMode() != mockMode) {
36+ qUsersModel->setMockMode(mockMode);
37+ Q_EMIT mockModeChanged(mockMode);
38+ }
39+}
tests/mocks/LightDM/single/GreeterPrivate.cpp → tests/mocks/LightDM/MockUsersModel.hrenamed+14−23
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2013 Canonical, Ltd.
2+ * Copyright (C) 2014 Canonical, Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
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
5 * it under the terms of the GNU General Public License as published by
@@ -13,34 +13,25 @@
13 * You should have received a copy of the GNU General Public License
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/>.
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
15 *
16− * Author: Michael Terry <michael.terry@canonical.com>
17 */
16 */
18
17
19−#include "../Greeter.h"
18+#ifndef MOCK_UNITY_USERSMODEL_H
20−#include "../GreeterPrivate.h"
19+#define MOCK_UNITY_USERSMODEL_H
21
20
22−namespace QLightDM
21+#include <UsersModel.h>
23−{
24
22
25−GreeterPrivate::GreeterPrivate(Greeter* parent)
23+class MockUsersModel : public UsersModel
26− : authenticated(false),
27− authenticationUser(),
28− twoFactorDone(false),
29− q_ptr(parent)
30{
24{
31−}
25+ Q_OBJECT
32
26
33−void GreeterPrivate::handleAuthenticate()
27+ Q_PROPERTY(QString mockMode READ mockMode WRITE setMockMode NOTIFY mockModeChanged)
34−{
35− Q_Q(Greeter);
36
28
37− authenticated = true;
29+public:
38− Q_EMIT q->authenticationComplete();
30+ QString mockMode() const;
39−}
31+ void setMockMode(QString mockMode);
40
32
41−void GreeterPrivate::handleRespond(QString const &response)
33+Q_SIGNALS:
42−{
34+ void mockModeChanged(QString mode);
43− Q_UNUSED(response)
44−}
35+};
45
36
46−}
37+#endif // MOCK_UNITY_USERSMODEL_H
tests/mocks/LightDM/QLightDM/Greetermode 120000 → 100644+17−1
@@ -1 +0,0 @@
1−../Greeter.h
@@ -0,0 +1,17 @@
1+/*
2+ * Copyright (C) 2014 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+
17+#include "../liblightdm/Greeter.h"
tests/mocks/LightDM/QLightDM/InfographicModeldeleted−1
@@ -1 +0,0 @@
1−../InfographicModel.h
tests/mocks/LightDM/QLightDM/UsersModelmode 120000 → 100644+17−1
@@ -1 +0,0 @@
1−../UsersModel.h
@@ -0,0 +1,17 @@
1+/*
2+ * Copyright (C) 2014 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+
17+#include "../liblightdm/UsersModel.h"
tests/mocks/LightDM/full/CMakeLists.txtdeleted−18
@@ -1,18 +0,0 @@
1−set(LibLightDM_SOURCES
2− ../Greeter.cpp
3− ../UsersModel.cpp
4− GreeterPrivate.cpp
5− UsersModelPrivate.cpp
6− ${CMAKE_SOURCE_DIR}/plugins/Utils/qvariantlistmodel.cpp
7− )
8−
9−add_library(MockLightDM-full SHARED ${LibLightDM_SOURCES})
10−
11−qt5_use_modules(MockLightDM-full Gui)
12−
13−set_target_properties(MockLightDM-full PROPERTIES
14− OUTPUT_NAME lightdm-qt5-2)
15−
16−install(TARGETS MockLightDM-full
17− DESTINATION ${SHELL_INSTALL_QML}/mocks/LightDM/full
18− )
tests/mocks/LightDM/liblightdm/CMakeLists.txtnew file+18
@@ -0,0 +1,18 @@
1+set(LibLightDM_SOURCES
2+ Greeter.cpp
3+ UsersModel.cpp
4+ GreeterPrivate.cpp
5+ UsersModelPrivate.cpp
6+ ${CMAKE_SOURCE_DIR}/plugins/Utils/qvariantlistmodel.cpp
7+ )
8+
9+add_library(MockLightDM SHARED ${LibLightDM_SOURCES})
10+
11+qt5_use_modules(MockLightDM Gui)
12+
13+set_target_properties(MockLightDM PROPERTIES
14+ OUTPUT_NAME lightdm-qt5-2)
15+
16+install(TARGETS MockLightDM
17+ DESTINATION ${SHELL_INSTALL_QML}/mocks/LightDM/liblightdm
18+ )
tests/mocks/LightDM/liblightdm/Greeter.cppnew file+199
@@ -0,0 +1,199 @@
1+/*
2+ * Copyright (C) 2014 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+
17+#include "Greeter.h"
18+#include "GreeterPrivate.h"
19+#include <QtCore/QCoreApplication>
20+#include <QTimer>
21+
22+namespace QLightDM
23+{
24+
25+Greeter::Greeter(QObject *parent)
26+ : QObject(parent),
27+ d_ptr(new GreeterPrivate(this))
28+{
29+}
30+
31+Greeter::~Greeter()
32+{
33+}
34+
35+QString Greeter::authenticationUser() const
36+{
37+ Q_D(const Greeter);
38+ return d->authenticationUser;
39+}
40+
41+bool Greeter::hasGuestAccountHint() const
42+{
43+ return true;
44+}
45+
46+QString Greeter::getHint(const QString &name) const
47+{
48+ Q_UNUSED(name)
49+ return "";
50+}
51+
52+QString Greeter::defaultSessionHint() const
53+{
54+ return "ubuntu";
55+}
56+
57+bool Greeter::hideUsersHint() const
58+{
59+ return false;
60+}
61+
62+bool Greeter::showManualLoginHint() const
63+{
64+ return true;
65+}
66+
67+bool Greeter::showRemoteLoginHint() const
68+{
69+ return true;
70+}
71+
72+bool Greeter::lockHint () const
73+{
74+ return false;
75+}
76+
77+QString Greeter::selectUserHint() const
78+{
79+ return "";
80+}
81+
82+bool Greeter::selectGuestHint() const
83+{
84+ return false;
85+}
86+
87+QString Greeter::autologinUserHint() const
88+{
89+ return "";
90+}
91+
92+bool Greeter::autologinGuestHint() const
93+{
94+ return false;
95+}
96+
97+int Greeter::autologinTimeoutHint() const
98+{
99+ return 0;
100+}
101+
102+bool Greeter::inAuthentication() const
103+{
104+ return false;
105+}
106+
107+QString Greeter::hostname() const
108+{
109+ return "hostname1";
110+}
111+
112+bool Greeter::isAuthenticated() const
113+{
114+ Q_D(const Greeter);
115+ return d->authenticated;
116+}
117+
118+bool Greeter::connectSync()
119+{
120+ return true;
121+}
122+
123+void Greeter::authenticate(const QString &username)
124+{
125+ Q_D(Greeter);
126+
127+ d->authenticated = false;
128+ d->authenticationUser = username;
129+ d->twoFactorDone = false;
130+ QTimer::singleShot(0, this, SLOT(delayedAuthentication()));
131+}
132+
133+void Greeter::delayedAuthentication()
134+{
135+ Q_D(Greeter);
136+ d->handleAuthenticate();
137+}
138+
139+void Greeter::authenticateAsGuest()
140+{}
141+
142+void Greeter::authenticateAutologin()
143+{}
144+
145+void Greeter::authenticateRemote(const QString &session, const QString &username)
146+{
147+ Q_UNUSED(session)
148+ Q_UNUSED(username)
149+}
150+
151+void Greeter::cancelAuthentication()
152+{}
153+
154+void Greeter::setLanguage (const QString &language)
155+{
156+ Q_UNUSED(language)
157+}
158+
159+bool Greeter::startSessionSync(const QString &session)
160+{
161+ Q_UNUSED(session)
162+ return true;
163+}
164+
165+void Greeter::respond(const QString &response)
166+{
167+ Q_D(Greeter);
168+
169+ d->handleRespond(response);
170+}
171+
172+void Greeter::sendAuthenticationComplete()
173+{
174+ if (qgetenv("UNITY_TESTING").isEmpty()) {
175+ // simulate PAM's delay
176+ QTimer::singleShot(1000, this, SIGNAL(authenticationComplete()));
177+ } else {
178+ Q_EMIT authenticationComplete();
179+ }
180+}
181+
182+QString Greeter::mockMode() const
183+{
184+ Q_D(const Greeter);
185+ return d->mockMode;
186+}
187+
188+
189+void Greeter::setMockMode(QString mockMode)
190+{
191+ Q_D(Greeter);
192+
193+ if (d->mockMode != mockMode) {
194+ d->mockMode = mockMode;
195+ Q_EMIT mockModeChanged(mockMode);
196+ }
197+}
198+
199+}
tests/mocks/LightDM/liblightdm/Greeter.hnew file+118
@@ -0,0 +1,118 @@
1+/*
2+ * Copyright (C) 2013 Canonical, Ltd.
3+ * Copyright (C) 2010-2011 David Edmundson.
4+ * Copyright (C) 2010-2011 Robert Ancell
5+ *
6+ * This program is free software; you can redistribute it and/or modify
7+ * it under the terms of the GNU General Public License as published by
8+ * the Free Software Foundation; version 3.
9+ *
10+ * This program is distributed in the hope that it will be useful,
11+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+ * GNU General Public License for more details.
14+ *
15+ * You should have received a copy of the GNU General Public License
16+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
17+ *
18+ * Author: David Edmundson <kde@davidedmundson.co.uk>
19+ */
20+
21+#ifndef UNITY_MOCK_GREETER_H
22+#define UNITY_MOCK_GREETER_H
23+
24+#include <QtCore/QObject>
25+#include <QtCore/QVariant>
26+
27+
28+namespace QLightDM
29+{
30+ class GreeterPrivate;
31+
32+class Q_DECL_EXPORT Greeter : public QObject
33+{
34+ Q_OBJECT
35+
36+ Q_PROPERTY(bool authenticated READ isAuthenticated ) //NOTFIY authenticationComplete
37+ Q_PROPERTY(QString authenticationUser READ authenticationUser )
38+ Q_PROPERTY(QString defaultSession READ defaultSessionHint CONSTANT)
39+ Q_PROPERTY(QString selectUser READ selectUserHint CONSTANT)
40+ Q_PROPERTY(bool selectGuest READ selectGuestHint CONSTANT)
41+
42+ Q_PROPERTY(QString hostname READ hostname CONSTANT)
43+ Q_PROPERTY(bool hasGuestAccount READ hasGuestAccountHint CONSTANT)
44+ Q_PROPERTY(bool locked READ lockHint CONSTANT)
45+
46+ Q_PROPERTY(QString hostname READ hostname CONSTANT)
47+
48+ Q_ENUMS(PromptType MessageType)
49+
50+ //Mock-only API for testing purposes
51+ Q_PROPERTY(QString mockMode READ mockMode WRITE setMockMode NOTIFY mockModeChanged)
52+
53+public:
54+ enum PromptType {
55+ PromptTypeQuestion,
56+ PromptTypeSecret
57+ };
58+
59+ enum MessageType {
60+ MessageTypeInfo,
61+ MessageTypeError
62+ };
63+
64+ explicit Greeter(QObject* parent=0);
65+ virtual ~Greeter();
66+
67+ QString getHint(const QString &name) const;
68+ QString defaultSessionHint() const;
69+ bool hideUsersHint() const;
70+ bool showManualLoginHint() const;
71+ bool showRemoteLoginHint() const;
72+ bool lockHint () const;
73+ bool hasGuestAccountHint() const;
74+ QString selectUserHint() const;
75+ bool selectGuestHint() const;
76+ QString autologinUserHint() const;
77+ bool autologinGuestHint() const;
78+ int autologinTimeoutHint() const;
79+
80+ bool inAuthentication() const;
81+ bool isAuthenticated() const;
82+ QString authenticationUser() const;
83+ QString hostname() const;
84+
85+ QString mockMode() const;
86+ void setMockMode(QString mockMode);
87+
88+public Q_SLOTS:
89+ bool connectSync();
90+ void authenticate(const QString &username=QString());
91+ void authenticateAsGuest();
92+ void authenticateAutologin();
93+ void authenticateRemote(const QString &session=QString(), const QString &username=QString());
94+ void respond(const QString &response);
95+ void cancelAuthentication();
96+ void setLanguage (const QString &language);
97+ bool startSessionSync(const QString &session=QString());
98+
99+Q_SIGNALS:
100+ void showMessage(QString text, QLightDM::Greeter::MessageType type);
101+ void showPrompt(QString text, QLightDM::Greeter::PromptType type);
102+ void authenticationComplete();
103+ void autologinTimerExpired();
104+ void mockModeChanged(QString mode);
105+
106+protected:
107+ void sendAuthenticationComplete();
108+
109+private Q_SLOTS:
110+ void delayedAuthentication();
111+
112+private:
113+ GreeterPrivate *d_ptr;
114+ Q_DECLARE_PRIVATE(Greeter)
115+};
116+}
117+
118+#endif // UNITY_MOCK_GREETER_H
tests/mocks/LightDM/full/GreeterPrivate.cpp → tests/mocks/LightDM/liblightdm/GreeterPrivate.cpprenamed+35−6
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2013 Canonical, Ltd.
2+ * Copyright (C) 2014 Canonical, Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
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
5 * it under the terms of the GNU General Public License as published by
@@ -12,12 +12,10 @@
12 *
12 *
13 * You should have received a copy of the GNU General Public License
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/>.
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− *
16− * Author: Michael Terry <michael.terry@canonical.com>
17 */
15 */
18
16
19−#include "../Greeter.h"
17+#include "Greeter.h"
20−#include "../GreeterPrivate.h"
18+#include "GreeterPrivate.h"
21
19
22namespace QLightDM
20namespace QLightDM
23{
21{
@@ -34,6 +32,20 @@ void GreeterPrivate::handleAuthenticate()
34{
32{
35 Q_Q(Greeter);
33 Q_Q(Greeter);
36
34
35+ if (mockMode == "single") {
36+ authenticated = true;
37+ Q_EMIT q->authenticationComplete();
38+ } else if (mockMode == "single-passphrase" || mockMode == "single-pin") {
39+ Q_EMIT q->showPrompt("Password: ", Greeter::PromptTypeSecret);
40+ } else if (mockMode == "full") {
41+ handleAuthenticate_full();
42+ }
43+}
44+
45+void GreeterPrivate::handleAuthenticate_full()
46+{
47+ Q_Q(Greeter);
48+
37 // Send out any messages we need to
49 // Send out any messages we need to
38 if (authenticationUser == "info-prompt")
50 if (authenticationUser == "info-prompt")
39 Q_EMIT q->showMessage("Welcome to Unity Greeter", Greeter::MessageTypeInfo);
51 Q_EMIT q->showMessage("Welcome to Unity Greeter", Greeter::MessageTypeInfo);
@@ -65,7 +77,24 @@ void GreeterPrivate::handleAuthenticate()
65 }
77 }
66}
78}
67
79
68−void GreeterPrivate::handleRespond(const QString &response)
80+void GreeterPrivate::handleRespond(QString const &response)
81+{
82+ Q_Q(Greeter);
83+
84+ if (mockMode == "single") {
85+ // NOOP
86+ } else if (mockMode == "single-passphrase") {
87+ authenticated = (response == "password");
88+ q->sendAuthenticationComplete();
89+ } else if (mockMode == "single-pin") {
90+ authenticated = (response == "1234");
91+ q->sendAuthenticationComplete();
92+ } else if (mockMode == "full") {
93+ handleRespond_full(response);
94+ }
95+}
96+
97+void GreeterPrivate::handleRespond_full(const QString &response)
69{
98{
70 Q_Q(Greeter);
99 Q_Q(Greeter);
71
100
tests/mocks/LightDM/liblightdm/GreeterPrivate.hnew file+54
@@ -0,0 +1,54 @@
1+/*
2+ * Copyright (C) 2014 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+
17+#ifndef UNITY_MOCK_GREETER_PRIVATE_H
18+#define UNITY_MOCK_GREETER_PRIVATE_H
19+
20+#include <QtCore/QObject>
21+
22+namespace QLightDM
23+{
24+class Greeter;
25+class GreeterImpl;
26+
27+class GreeterPrivate
28+{
29+public:
30+ explicit GreeterPrivate(Greeter* parent=0);
31+ virtual ~GreeterPrivate() = default;
32+
33+ // These variables may not be used by all subclasses, that's no problem
34+ bool authenticated;
35+ QString authenticationUser;
36+ bool twoFactorDone;
37+
38+ QString mockMode;
39+
40+ void handleAuthenticate();
41+ void handleRespond(const QString &response);
42+
43+protected:
44+ GreeterImpl *m_impl; // if the backend needs more private data
45+ Greeter * const q_ptr;
46+
47+private:
48+ void handleAuthenticate_full();
49+ void handleRespond_full(const QString &response);
50+ Q_DECLARE_PUBLIC(Greeter)
51+};
52+}
53+
54+#endif // UNITY_MOCK_GREETER_PRIVATE_H
tests/mocks/LightDM/liblightdm/UsersModel.cppnew file+134
@@ -0,0 +1,134 @@
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+// LightDM currently is Qt4 compatible, and so doesn't define setRoleNames.
20+// To use the same method of setting role name that it does, we
21+// set our compatibility to Qt4 here too.
22+#define QT_DISABLE_DEPRECATED_BEFORE QT_VERSION_CHECK(4, 0, 0)
23+
24+#include "UsersModel.h"
25+#include "UsersModelPrivate.h"
26+#include <QtCore/QDir>
27+#include <QtCore/QString>
28+#include <QtGui/QIcon>
29+
30+namespace QLightDM
31+{
32+
33+UsersModel::UsersModel(QObject *parent) :
34+ QAbstractListModel(parent),
35+ d_ptr(new UsersModelPrivate(this))
36+{
37+ Q_D(UsersModel);
38+
39+ // Extend roleNames (we want to keep the "display" role)
40+ QHash<int, QByteArray> roles = roleNames();
41+ roles[NameRole] = "name";
42+ roles[RealNameRole] = "realName";
43+ roles[LoggedInRole] = "loggedIn";
44+ roles[BackgroundRole] = "background";
45+ roles[BackgroundPathRole] = "backgroundPath";
46+ roles[SessionRole] = "session";
47+ roles[HasMessagesRole] = "hasMessages";
48+ roles[ImagePathRole] = "imagePath";
49+ setRoleNames(roles);
50+
51+ // Now modify our mock user backgrounds
52+ QDir bgdir = QDir("/usr/share/demo-assets/shell/backgrounds/");
53+ QStringList backgrounds = bgdir.entryList(QDir::Files | QDir::NoDotAndDotDot);
54+
55+ for (int i = 0, j = 0; i < d->entries.size(); i++) {
56+ Entry &entry = d->entries[i];
57+ if (entry.background.isNull() && !backgrounds.isEmpty()) {
58+ entry.background = bgdir.filePath(backgrounds[j++]);
59+ if (j >= backgrounds.length()) {
60+ j = 0;
61+ }
62+ }
63+ }
64+}
65+
66+UsersModel::~UsersModel()
67+{
68+ delete d_ptr;
69+}
70+
71+int UsersModel::rowCount(const QModelIndex &parent) const
72+{
73+ Q_D(const UsersModel);
74+
75+ if (parent.isValid()) {
76+ return 0;
77+ } else { // parent is root
78+ return d->entries.size();
79+ }
80+}
81+
82+QVariant UsersModel::data(const QModelIndex &index, int role) const
83+{
84+ Q_D(const UsersModel);
85+
86+ if (!index.isValid()) {
87+ return QVariant();
88+ }
89+
90+ int row = index.row();
91+ switch (role) {
92+ case Qt::DisplayRole:
93+ return d->entries[row].real_name;
94+ case Qt::DecorationRole:
95+ return QIcon();
96+ case UsersModel::NameRole:
97+ return d->entries[row].username;
98+ case UsersModel::RealNameRole:
99+ return d->entries[row].real_name;
100+ case UsersModel::SessionRole:
101+ return d->entries[row].session;
102+ case UsersModel::LoggedInRole:
103+ return d->entries[row].is_active;
104+ case UsersModel::BackgroundRole:
105+ return QPixmap(d->entries[row].background);
106+ case UsersModel::BackgroundPathRole:
107+ return d->entries[row].background;
108+ case UsersModel::HasMessagesRole:
109+ return d->entries[row].has_messages;
110+ case UsersModel::ImagePathRole:
111+ return "";
112+ default:
113+ return QVariant();
114+ }
115+}
116+
117+QString UsersModel::mockMode() const
118+{
119+ Q_D(const UsersModel);
120+ return d->mockMode;
121+}
122+
123+void UsersModel::setMockMode(QString mockMode)
124+{
125+ Q_D(UsersModel);
126+
127+ if (d->mockMode != mockMode) {
128+ d->mockMode = mockMode;
129+ Q_EMIT mockModeChanged(mockMode);
130+ d->resetEntries();
131+ }
132+}
133+
134+}
tests/mocks/LightDM/liblightdm/UsersModel.hnew file+69
@@ -0,0 +1,69 @@
1+/*
2+ * Copyright (C) 2013-2014 Canonical, Ltd.
3+ * Copyright (C) 2010-2011 David Edmundson.
4+ *
5+ * This program is free software; you can redistribute it and/or modify
6+ * it under the terms of the GNU General Public License as published by
7+ * the Free Software Foundation; version 3.
8+ *
9+ * This program is distributed in the hope that it will be useful,
10+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+ * GNU General Public License for more details.
13+ *
14+ * You should have received a copy of the GNU General Public License
15+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
16+ */
17+
18+#ifndef UNITY_MOCK_USERSMODEL_H
19+#define UNITY_MOCK_USERSMODEL_H
20+
21+#include <QtCore/QString>
22+#include <QtCore/QSharedDataPointer>
23+#include <QAbstractListModel>
24+
25+
26+namespace QLightDM
27+{
28+class UsersModelPrivate;
29+
30+class Q_DECL_EXPORT UsersModel : public QAbstractListModel
31+{
32+ Q_OBJECT
33+
34+ Q_ENUMS(UserModelRoles)
35+
36+ //Mock-only API for testing purposes
37+ Q_PROPERTY(QString mockMode READ mockMode WRITE setMockMode NOTIFY mockModeChanged)
38+
39+Q_SIGNALS:
40+ void mockModeChanged(QString mode);
41+
42+public:
43+ explicit UsersModel(QObject *parent = 0);
44+ virtual ~UsersModel();
45+
46+ enum UserModelRoles {NameRole = Qt::UserRole,
47+ RealNameRole,
48+ LoggedInRole,
49+ BackgroundRole,
50+ SessionRole,
51+ HasMessagesRole,
52+ ImagePathRole,
53+ BackgroundPathRole
54+ };
55+
56+ int rowCount(const QModelIndex &parent) const;
57+ QVariant data(const QModelIndex &index, int role) const;
58+
59+ QString mockMode() const;
60+ void setMockMode(QString mockMode);
61+
62+private:
63+ UsersModelPrivate * const d_ptr;
64+ Q_DECLARE_PRIVATE(UsersModel)
65+};
66+
67+}
68+
69+#endif // UNITY_MOCK_USERSMODEL_H
tests/mocks/LightDM/full/UsersModelPrivate.cpp → tests/mocks/LightDM/liblightdm/UsersModelPrivate.cpprenamed+54−6
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2013 Canonical, Ltd.
2+ * Copyright (C) 2014 Canonical, Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
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
5 * it under the terms of the GNU General Public License as published by
@@ -12,17 +12,65 @@
12 *
12 *
13 * You should have received a copy of the GNU General Public License
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/>.
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− *
16− * Author: Michael Terry <michael.terry@canonical.com>
17 */
15 */
18
16
19−#include "../UsersModelPrivate.h"
17+#include "UsersModelPrivate.h"
18+#include "UsersModel.h"
20
19
21namespace QLightDM
20namespace QLightDM
22{
21{
23
22
24UsersModelPrivate::UsersModelPrivate(UsersModel* parent)
23UsersModelPrivate::UsersModelPrivate(UsersModel* parent)
24+ : mockMode("single")
25− : q_ptr(parent)
25+ , q_ptr(parent)
26+{
27+ resetEntries_single();
28+}
29+
30+void UsersModelPrivate::resetEntries()
31+{
32+ Q_Q(UsersModel);
33+
34+ q->beginResetModel();
35+
36+ if (mockMode == "single") {
37+ resetEntries_single();
38+ } else if (mockMode == "single-passphrase") {
39+ resetEntries_singlePassphrase();
40+ } else if (mockMode == "single-pin") {
41+ resetEntries_singlePin();
42+ } else if (mockMode == "full") {
43+ resetEntries_full();
44+ }
45+
46+ q->endResetModel();
47+}
48+
49+void UsersModelPrivate::resetEntries_single()
50+{
51+ entries =
52+ {
53+ { "single", "Single User", 0, 0, false, false, 0, 0 },
54+ };
55+}
56+
57+void UsersModelPrivate::resetEntries_singlePassphrase()
58+{
59+ entries =
60+ {
61+ { "single", "Single User", 0, 0, false, false, 0, 0 },
62+ };
63+}
64+
65+void UsersModelPrivate::resetEntries_singlePin()
66+{
67+ entries =
68+ {
69+ { "has-pin", "Has PIN", 0, 0, false, false, 0, 0 },
70+ };
71+}
72+
73+void UsersModelPrivate::resetEntries_full()
26{
74{
27 entries =
75 entries =
28 {
76 {
@@ -49,4 +97,4 @@ UsersModelPrivate::UsersModelPrivate(UsersModel* parent)
49 };
97 };
50}
98}
51
99
52−}
100+} // namespace QLightDM
tests/mocks/LightDM/liblightdm/UsersModelPrivate.hnew file+63
@@ -0,0 +1,63 @@
1+/*
2+ * Copyright (C) 2014 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+
17+#ifndef UNITY_MOCK_USERSMODEL_PRIVATE_H
18+#define UNITY_MOCK_USERSMODEL_PRIVATE_H
19+
20+#include <QtCore/QList>
21+#include <QtCore/QString>
22+
23+namespace QLightDM
24+{
25+class UsersModel;
26+
27+class Entry
28+{
29+public:
30+ QString username;
31+ QString real_name;
32+ QString background;
33+ QString layouts;
34+ bool is_active;
35+ bool has_messages;
36+ QString session;
37+ QString infographic;
38+};
39+
40+class UsersModelPrivate
41+{
42+public:
43+ explicit UsersModelPrivate(UsersModel *parent = 0);
44+ virtual ~UsersModelPrivate() = default;
45+
46+ QList<Entry> entries;
47+ QString mockMode;
48+
49+ void resetEntries();
50+protected:
51+ UsersModel * const q_ptr;
52+
53+private:
54+ void resetEntries_single();
55+ void resetEntries_singlePassphrase();
56+ void resetEntries_singlePin();
57+ void resetEntries_full();
58+ Q_DECLARE_PUBLIC(UsersModel)
59+};
60+
61+}
62+
63+#endif // UNITY_MOCK_USERSMODEL_PRIVATE_H
tests/mocks/LightDM/plugin.cppnew file+68
@@ -0,0 +1,68 @@
1+/*
2+ * Copyright (C) 2014 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+
17+#include "plugin.h"
18+#include <DBusGreeter.h>
19+#include <DBusGreeterList.h>
20+#include "MockGreeter.h"
21+#include "MockUsersModel.h"
22+#include <libusermetricsoutput/ColorTheme.h>
23+#include <libusermetricsoutput/UserMetrics.h>
24+#include <QLightDM/UsersModel>
25+
26+#include <QAbstractItemModel>
27+#include <QDBusConnection>
28+#include <QtQml/qqml.h>
29+
30+static QObject *greeter_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
31+{
32+ Q_UNUSED(engine)
33+ Q_UNUSED(scriptEngine)
34+
35+ MockGreeter *greeter = new MockGreeter;
36+ new DBusGreeter(greeter, "/");
37+ new DBusGreeterList(greeter, "/list");
38+
39+ return greeter;
40+}
41+
42+static QObject *users_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
43+{
44+ Q_UNUSED(engine)
45+ Q_UNUSED(scriptEngine)
46+ return new MockUsersModel;
47+}
48+
49+static QObject *infographic_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
50+{
51+ Q_UNUSED(engine)
52+ Q_UNUSED(scriptEngine)
53+ return UserMetricsOutput::UserMetrics::getInstance();
54+}
55+
56+void LightDMPlugin::registerTypes(const char *uri)
57+{
58+ qmlRegisterType<QAbstractItemModel>();
59+ qmlRegisterType<UserMetricsOutput::ColorTheme>();
60+
61+ Q_ASSERT(uri == QLatin1String("LightDM"));
62+ qRegisterMetaType<QLightDM::Greeter::MessageType>("QLightDM::Greeter::MessageType");
63+ qRegisterMetaType<QLightDM::Greeter::PromptType>("QLightDM::Greeter::PromptType");
64+ qmlRegisterSingletonType<MockGreeter>(uri, 0, 1, "Greeter", greeter_provider);
65+ qmlRegisterSingletonType<MockUsersModel>(uri, 0, 1, "Users", users_provider);
66+ qmlRegisterUncreatableType<QLightDM::UsersModel>(uri, 0, 1, "UserRoles", "Type is not instantiable");
67+ qmlRegisterSingletonType<UserMetricsOutput::UserMetrics>(uri, 0, 1, "Infographic", infographic_provider);
68+}
tests/mocks/LightDM/single-passphrase/UsersModelPrivate.cpp → tests/mocks/LightDM/plugin.hrenamed+13−14
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2013 Canonical, Ltd.
2+ * Copyright (C) 2014 Canonical, Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
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
5 * it under the terms of the GNU General Public License as published by
@@ -12,22 +12,21 @@
12 *
12 *
13 * You should have received a copy of the GNU General Public License
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/>.
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− *
16− * Author: Michael Terry <michael.terry@canonical.com>
17 */
15 */
18
16
19−#include "../UsersModelPrivate.h"
17+#ifndef MOCK_LIGHTDM_PLUGIN_H
18+#define MOCK_LIGHTDM_PLUGIN_H
20
19
21−namespace QLightDM
20+#include <QtQml/QQmlEngine>
22−{
21+#include <QtQml/QQmlExtensionPlugin>
23
22
24−UsersModelPrivate::UsersModelPrivate(UsersModel* parent)
23+class LightDMPlugin : public QQmlExtensionPlugin
25− : q_ptr(parent)
26{
24{
27− entries =
25+ Q_OBJECT
28− {
26+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
29− { "single", "Has Passphrase", 0, 0, false, false, 0, 0 },
27+
28+public:
29+ void registerTypes(const char *uri);
30− };
30+};
31−}
32
31
33−}
32+#endif
tests/mocks/LightDM/single-passphrase/CMakeLists.txtdeleted−19
@@ -1,19 +0,0 @@
1−set(LibLightDM_SOURCES
2− ../Greeter.cpp
3− ../UsersModel.cpp
4− GreeterPrivate.cpp
5− UsersModelPrivate.cpp
6− ${CMAKE_SOURCE_DIR}/plugins/Utils/qvariantlistmodel.cpp
7− )
8−
9−
10−add_library(MockLightDM-single-passphrase SHARED ${LibLightDM_SOURCES})
11−
12−qt5_use_modules(MockLightDM-single-passphrase Gui)
13−
14−set_target_properties(MockLightDM-single-passphrase PROPERTIES
15− OUTPUT_NAME lightdm-qt5-2)
16−
17−install(TARGETS MockLightDM-single-passphrase
18− DESTINATION ${SHELL_INSTALL_QML}/mocks/LightDM/single-passphrase
19− )
tests/mocks/LightDM/single-passphrase/GreeterPrivate.cppdeleted−46
@@ -1,46 +0,0 @@
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 "../Greeter.h"
20−#include "../GreeterPrivate.h"
21−
22−namespace QLightDM
23−{
24−
25−GreeterPrivate::GreeterPrivate(Greeter* parent)
26− : authenticated(false),
27− authenticationUser(),
28− q_ptr(parent)
29−{
30−}
31−
32−void GreeterPrivate::handleAuthenticate()
33−{
34− Q_Q(Greeter);
35− Q_EMIT q->showPrompt("Password: ", Greeter::PromptTypeSecret);
36−}
37−
38−void GreeterPrivate::handleRespond(const QString &response)
39−{
40− Q_Q(Greeter);
41−
42− authenticated = (response == "password");
43− q->sendAuthenticationComplete();
44−}
45−
46−}
tests/mocks/LightDM/single-pin/CMakeLists.txtdeleted−19
@@ -1,19 +0,0 @@
1−set(LibLightDM_SOURCES
2− ../Greeter.cpp
3− ../UsersModel.cpp
4− GreeterPrivate.cpp
5− UsersModelPrivate.cpp
6− ${CMAKE_SOURCE_DIR}/plugins/Utils/qvariantlistmodel.cpp
7− )
8−
9−
10−add_library(MockLightDM-single-pin SHARED ${LibLightDM_SOURCES})
11−
12−qt5_use_modules(MockLightDM-single-pin Gui)
13−
14−set_target_properties(MockLightDM-single-pin PROPERTIES
15− OUTPUT_NAME lightdm-qt5-2)
16−
17−install(TARGETS MockLightDM-single-pin
18− DESTINATION ${SHELL_INSTALL_QML}/mocks/LightDM/single-pin
19− )
tests/mocks/LightDM/single-pin/GreeterPrivate.cppdeleted−46
@@ -1,46 +0,0 @@
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 "../Greeter.h"
20−#include "../GreeterPrivate.h"
21−
22−namespace QLightDM
23−{
24−
25−GreeterPrivate::GreeterPrivate(Greeter* parent)
26− : authenticated(false),
27− authenticationUser(),
28− q_ptr(parent)
29−{
30−}
31−
32−void GreeterPrivate::handleAuthenticate()
33−{
34− Q_Q(Greeter);
35− Q_EMIT q->showPrompt("Password: ", Greeter::PromptTypeSecret);
36−}
37−
38−void GreeterPrivate::handleRespond(const QString &response)
39−{
40− Q_Q(Greeter);
41−
42− authenticated = (response == "1234");
43− q->sendAuthenticationComplete();
44−}
45−
46−}
tests/mocks/LightDM/single/CMakeLists.txtdeleted−18
@@ -1,18 +0,0 @@
1−set(LibLightDM_SOURCES
2− ../Greeter.cpp
3− ../UsersModel.cpp
4− GreeterPrivate.cpp
5− UsersModelPrivate.cpp
6− ${CMAKE_SOURCE_DIR}/plugins/Utils/qvariantlistmodel.cpp
7− )
8−
9−add_library(MockLightDM-single SHARED ${LibLightDM_SOURCES})
10−
11−qt5_use_modules(MockLightDM-single Gui)
12−
13−set_target_properties(MockLightDM-single PROPERTIES
14− OUTPUT_NAME lightdm-qt5-2)
15−
16−install(TARGETS MockLightDM-single
17− DESTINATION ${SHELL_INSTALL_QML}/mocks/LightDM/single
18− )
tests/plugins/LightDM/CMakeLists.txt+2−2
@@ -12,10 +12,10 @@ include_directories(
12 )
12 )
13
13
14target_link_libraries(GreeterDBusTestExec
14target_link_libraries(GreeterDBusTestExec
15− -L${CMAKE_BINARY_DIR}/tests/mocks/LightDM/full
15+ -L${CMAKE_BINARY_DIR}/tests/mocks/LightDM/liblightdm
16 -llightdm-qt5-2
16 -llightdm-qt5-2
17 )
17 )
18
18
19add_definitions(-DCURRENT_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}")
19add_definitions(-DCURRENT_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}")
20
20
21−add_binary_qml_test(GreeterDBus "${CMAKE_BINARY_DIR}/tests/mocks/LightDM/full" MockLightDM-full "QML2_IMPORT_PATH=${CMAKE_BINARY_DIR}/tests/mocks")
21+add_binary_qml_test(GreeterDBus "${CMAKE_BINARY_DIR}/tests/mocks/LightDM/liblightdm" MockLightDM "QML2_IMPORT_PATH=${CMAKE_BINARY_DIR}/tests/mocks")
tests/plugins/LightDM/greeter.qml+5
@@ -19,4 +19,9 @@ import LightDM 0.1 as LightDM
19
19
20Item {
20Item {
21 property var greeter: LightDM.Greeter
21 property var greeter: LightDM.Greeter
22+ Binding {
23+ target: LightDM.Greeter
24+ property: "mockMode"
25+ value: "full"
26+ }
22}
27}
tests/qmltests/CMakeLists.txt+19−19
@@ -16,11 +16,11 @@ add_qml_test(utils/Unity/Test UnityTest)
16
16
17set(qmltest_DEFAULT_TARGETS qmluitests)
17set(qmltest_DEFAULT_TARGETS qmluitests)
18set(qmltest_DEFAULT_NO_ADD_TEST TRUE)
18set(qmltest_DEFAULT_NO_ADD_TEST TRUE)
19−set(qmltest_DEFAULT_PROPERTIES ENVIRONMENT "LC_ALL=C")
19+set(qmltest_DEFAULT_PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/liblightdm:${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
20
20
21−add_qml_test(. Shell ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single:${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
21+add_qml_test(. Shell)
22−add_qml_test(. ShellWithPin ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single-pin:${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
22+add_qml_test(. ShellWithPin)
23−add_qml_test(. TabletShell ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/LightDM/full:${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
23+add_qml_test(. TabletShell)
24add_qml_test(Components Background)
24add_qml_test(Components Background)
25add_qml_test(Components Carousel)
25add_qml_test(Components Carousel)
26add_qml_test(Components Dialogs)
26add_qml_test(Components Dialogs)
@@ -61,10 +61,10 @@ add_qml_test(Dash/ScopeSettings ScopeSettingList)
61add_qml_test(Dash/ScopeSettings ScopeSettingNumber)
61add_qml_test(Dash/ScopeSettings ScopeSettingNumber)
62add_qml_test(Dash/ScopeSettings ScopeSettingString)
62add_qml_test(Dash/ScopeSettings ScopeSettingString)
63add_qml_test(Dash/ScopeSettings ScopeSettingsWidgetFactory)
63add_qml_test(Dash/ScopeSettings ScopeSettingsWidgetFactory)
64−add_qml_test(Greeter MultiGreeter ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/full")
64+add_qml_test(Greeter MultiGreeter)
65−add_qml_test(Greeter SingleGreeter ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single")
65+add_qml_test(Greeter SingleGreeter)
66−add_qml_test(Greeter Infographics ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/full")
66+add_qml_test(Greeter Infographics)
67−add_qml_test(Greeter Clock ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
67+add_qml_test(Greeter Clock)
68add_qml_test(Launcher Launcher)
68add_qml_test(Launcher Launcher)
69add_qml_test(Notifications Notifications)
69add_qml_test(Notifications Notifications)
70add_qml_test(Notifications VisualSnapDecisionsQueue)
70add_qml_test(Notifications VisualSnapDecisionsQueue)
@@ -72,21 +72,21 @@ add_qml_test(Notifications OptionToggle)
72add_qml_test(Notifications SwipeToAct)
72add_qml_test(Notifications SwipeToAct)
73add_qml_test(Panel ActiveCallHint)
73add_qml_test(Panel ActiveCallHint)
74add_qml_test(Panel IndicatorItem)
74add_qml_test(Panel IndicatorItem)
75−add_qml_test(Panel IndicatorItemRow ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
75+add_qml_test(Panel IndicatorItemRow)
76−add_qml_test(Panel IndicatorPage ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
76+add_qml_test(Panel IndicatorPage)
77−add_qml_test(Panel IndicatorsBar ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
77+add_qml_test(Panel IndicatorsBar)
78−add_qml_test(Panel IndicatorsMenu ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
78+add_qml_test(Panel IndicatorsMenu)
79−add_qml_test(Panel MenuContent ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
79+add_qml_test(Panel MenuContent)
80−add_qml_test(Panel Panel ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
80+add_qml_test(Panel Panel)
81add_qml_test(Panel SearchIndicator)
81add_qml_test(Panel SearchIndicator)
82add_qml_test(Panel/Indicators IndicatorsLight ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
82add_qml_test(Panel/Indicators IndicatorsLight ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
83# These MenuItemFactory tests need the test/mocks/ to come before plugins/
83# These MenuItemFactory tests need the test/mocks/ to come before plugins/
84add_qml_test(Panel/Indicators MenuItemFactory IMPORT_PATHS ${CMAKE_BINARY_DIR}/tests/mocks ${qmltest_DEFAULT_IMPORT_PATHS})
84add_qml_test(Panel/Indicators MenuItemFactory IMPORT_PATHS ${CMAKE_BINARY_DIR}/tests/mocks ${qmltest_DEFAULT_IMPORT_PATHS})
85add_qml_test(Panel/Indicators MessageMenuItemFactory IMPORT_PATHS ${CMAKE_BINARY_DIR}/tests/mocks ${qmltest_DEFAULT_IMPORT_PATHS})
85add_qml_test(Panel/Indicators MessageMenuItemFactory IMPORT_PATHS ${CMAKE_BINARY_DIR}/tests/mocks ${qmltest_DEFAULT_IMPORT_PATHS})
86−add_qml_test(Stages ApplicationWindow ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single")
86+add_qml_test(Stages ApplicationWindow)
87−add_qml_test(Stages PhoneStage ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single")
87+add_qml_test(Stages PhoneStage ENVIRONMENT)
88−add_qml_test(Stages SpreadDelegate ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single")
88+add_qml_test(Stages SpreadDelegate ENVIRONMENT)
89−add_qml_test(Stages SurfaceContainer ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single")
89+add_qml_test(Stages SurfaceContainer ENVIRONMENT)
90−add_qml_test(Stages SessionContainer ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single")
90+add_qml_test(Stages SessionContainer ENVIRONMENT)
91add_qml_test(Stages Splash)
91add_qml_test(Stages Splash)
92add_qml_test(Wizard Wizard)
92add_qml_test(Wizard Wizard)
tests/qmltests/Greeter/tst_Infographics.qml+10
@@ -23,6 +23,16 @@ import Unity.Test 0.1 as UT
23import LightDM 0.1 as LightDM
23import LightDM 0.1 as LightDM
24
24
25Item {
25Item {
26+ Binding {
27+ target: LightDM.Greeter
28+ property: "mockMode"
29+ value: "full"
30+ }
31+ Binding {
32+ target: LightDM.Users
33+ property: "mockMode"
34+ value: "full"
35+ }
26 property variant infographicModel: LightDM.Infographic
36 property variant infographicModel: LightDM.Infographic
27
37
28 width: units.gu(120)
38 width: units.gu(120)
tests/qmltests/Greeter/tst_MultiGreeter.qml+11
@@ -26,6 +26,17 @@ Item {
26 width: units.gu(120)
26 width: units.gu(120)
27 height: units.gu(80)
27 height: units.gu(80)
28
28
29+ Binding {
30+ target: LightDM.Greeter
31+ property: "mockMode"
32+ value: "full"
33+ }
34+ Binding {
35+ target: LightDM.Users
36+ property: "mockMode"
37+ value: "full"
38+ }
39+
29 Greeter {
40 Greeter {
30 id: greeter
41 id: greeter
31 anchors.fill: parent
42 anchors.fill: parent
tests/qmltests/tst_Shell.qml+8−1
@@ -36,6 +36,13 @@ Item {
36 width: units.gu(60)
36 width: units.gu(60)
37 height: units.gu(71)
37 height: units.gu(71)
38
38
39+ Component.onCompleted: {
40+ // must set the mock mode before loading the Shell
41+ LightDM.Greeter.mockMode = "single";
42+ LightDM.Users.mockMode = "single";
43+ shellLoader.active = true;
44+ }
45+
39 QtObject {
46 QtObject {
40 id: applicationArguments
47 id: applicationArguments
41
48
@@ -56,7 +63,7 @@ Item {
56 anchors.fill: parent
63 anchors.fill: parent
57 Loader {
64 Loader {
58 id: shellLoader
65 id: shellLoader
59−
66+ active: false
60 property bool itemDestroyed: false
67 property bool itemDestroyed: false
61 sourceComponent: Component {
68 sourceComponent: Component {
62 Shell {
69 Shell {
tests/qmltests/tst_ShellWithPin.qml+8
@@ -33,6 +33,13 @@ Item {
33 width: contentRow.width
33 width: contentRow.width
34 height: contentRow.height
34 height: contentRow.height
35
35
36+ Component.onCompleted: {
37+ // must set the mock mode before loading the Shell
38+ LightDM.Greeter.mockMode = "single-pin";
39+ LightDM.Users.mockMode = "single-pin";
40+ shellLoader.active = true;
41+ }
42+
36 QtObject {
43 QtObject {
37 id: applicationArguments
44 id: applicationArguments
38
45
@@ -54,6 +61,7 @@ Item {
54
61
55 Loader {
62 Loader {
56 id: shellLoader
63 id: shellLoader
64+ active: false
57
65
58 width: units.gu(40)
66 width: units.gu(40)
59 height: units.gu(71)
67 height: units.gu(71)
tests/qmltests/tst_TabletShell.qml+8
@@ -32,6 +32,13 @@ Row {
32 id: root
32 id: root
33 spacing: 0
33 spacing: 0
34
34
35+ Component.onCompleted: {
36+ // must set the mock mode before loading the Shell
37+ LightDM.Greeter.mockMode = "full";
38+ LightDM.Users.mockMode = "full";
39+ shellLoader.active = true;
40+ }
41+
35 QtObject {
42 QtObject {
36 id: applicationArguments
43 id: applicationArguments
37
44
@@ -51,6 +58,7 @@ Row {
51 Loader {
58 Loader {
52 id: shellLoader
59 id: shellLoader
53
60
61+ active: false
54 width: units.gu(100)
62 width: units.gu(100)
55 height: units.gu(80)
63 height: units.gu(80)
56
64