Merge lp:~mterry/unity8/simple-lightdm-mock into lp:unity8
- simple-lightdm-mock
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Albert Astals Cid |
Approved revision: | 2751 |
Merged at revision: | 2775 |
Proposed branch: | lp:~mterry/unity8/simple-lightdm-mock |
Merge into: | lp:unity8 |
Diff against target: |
3068 lines (+646/-1333) 63 files modified
debian/rules (+1/-1) plugins/LightDM/CMakeLists.txt (+0/-1) plugins/LightDM/Greeter.cpp (+1/-1) plugins/LightDM/Greeter.h (+2/-5) plugins/LightDM/SessionsModel.cpp (+1/-2) plugins/LightDM/SessionsModel.h (+4/-5) plugins/LightDM/UsersModel.cpp (+1/-1) plugins/LightDM/UsersModel.h (+2/-7) qml/Greeter/LightDMService.qml (+3/-4) tests/CMakeLists.txt (+1/-1) tests/autopilot/unity8/fixture_setup.py (+1/-1) tests/autopilot/unity8/shell/tests/__init__.py (+1/-1) tests/mocks/AccountsService/AccountsService.cpp (+2/-3) tests/mocks/AccountsService/AccountsService.h (+3/-6) tests/mocks/AccountsService/CMakeLists.txt (+1/-2) tests/mocks/CMakeLists.txt (+2/-1) tests/mocks/LightDM/CMakeLists.txt (+0/-1) tests/mocks/LightDM/IntegratedLightDM/CMakeLists.txt (+0/-50) tests/mocks/LightDM/IntegratedLightDM/MockGreeter.cpp (+0/-51) tests/mocks/LightDM/IntegratedLightDM/MockGreeter.h (+0/-42) tests/mocks/LightDM/IntegratedLightDM/MockSessionsModel.cpp (+0/-66) tests/mocks/LightDM/IntegratedLightDM/MockSessionsModel.h (+0/-44) tests/mocks/LightDM/IntegratedLightDM/MockUsersModel.cpp (+0/-44) tests/mocks/LightDM/IntegratedLightDM/MockUsersModel.h (+0/-39) tests/mocks/LightDM/IntegratedLightDM/QLightDM/Greeter (+0/-17) tests/mocks/LightDM/IntegratedLightDM/QLightDM/SessionsModel (+0/-17) tests/mocks/LightDM/IntegratedLightDM/QLightDM/UsersModel (+0/-17) tests/mocks/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.cpp (+0/-132) tests/mocks/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.h (+0/-54) tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.cpp (+0/-83) tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.h (+0/-63) tests/mocks/LightDM/IntegratedLightDM/liblightdm/UsersModelPrivate.cpp (+0/-124) tests/mocks/LightDM/IntegratedLightDM/liblightdm/UsersModelPrivate.h (+0/-64) tests/mocks/LightDM/IntegratedLightDM/plugin.cpp (+0/-79) tests/mocks/LightDM/IntegratedLightDM/plugin.h (+0/-32) tests/mocks/LightDM/IntegratedLightDM/qmldir (+0/-2) tests/mocks/LightDMController/CMakeLists.txt (+15/-0) tests/mocks/LightDMController/plugin.cpp (+35/-0) tests/mocks/LightDMController/plugin.h (+29/-0) tests/mocks/LightDMController/qmldir (+2/-0) tests/mocks/liblightdm/CMakeLists.txt (+8/-11) tests/mocks/liblightdm/MockController.cpp (+124/-0) tests/mocks/liblightdm/MockController.h (+80/-0) tests/mocks/liblightdm/MockGreeter.cpp (+85/-35) tests/mocks/liblightdm/MockGreeter.h (+9/-22) tests/mocks/liblightdm/MockSessionsModel.cpp (+47/-49) tests/mocks/liblightdm/MockSessionsModel.h (+9/-17) tests/mocks/liblightdm/MockUsersModel.cpp (+85/-20) tests/mocks/liblightdm/MockUsersModel.h (+6/-16) tests/plugins/LightDM/IntegratedLightDM/CMakeLists.txt (+3/-3) tests/plugins/LightDM/IntegratedLightDM/greeter.qml (+2/-7) tests/plugins/LightDM/IntegratedLightDM/sessionsmodel.cpp (+15/-13) tests/plugins/LightDM/IntegratedLightDM/usersmodel.cpp (+2/-12) tests/qmltests/Dash/tst_DashShell.qml (+8/-0) tests/qmltests/Greeter/TestView.qml (+1/-0) tests/qmltests/Greeter/tst_Greeter.qml (+6/-8) tests/qmltests/Greeter/tst_Infographics.qml (+1/-11) tests/qmltests/Greeter/tst_NarrowView.qml (+9/-2) tests/qmltests/Greeter/tst_WideView.qml (+20/-30) tests/qmltests/Tutorial/tst_Tutorial.qml (+3/-3) tests/qmltests/tst_OrientedShell.qml (+8/-1) tests/qmltests/tst_Shell.qml (+5/-7) tests/qmltests/tst_ShellWithPin.qml (+3/-3) |
To merge this branch: | bzr merge lp:~mterry/unity8/simple-lightdm-mock |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Unity8 CI Bot | continuous-integration | Approve | |
Albert Astals Cid (community) | Approve | ||
Review via email: mp+313478@code.launchpad.net |
Commit message
Simplify the lightdm mock to make future greeter improvements easier to test.
I simplified the mock liblightdm to avoid separate files for the Private classes. That can all go into the main files. The separation isn't worth wading through the files to find what you want.
And I dropped the mock LightDM plugin entirely. (opting instead for a tiny "mock()" API call on the real plugin that returns an object that can be used to manipulate our mock liblightdm, if we're in testing mode)
Description of the change
Simplify the lightdm mock to make future greeter improvements easier to test.
I simplified the mock liblightdm to avoid separate files for the Private classes. That can all go into the main files. The separation isn't worth wading through the files to find what you want.
And I dropped the mock LightDM plugin entirely. (opting instead for a tiny "mock()" API call on the real plugin that returns an object that can be used to manipulate our mock liblightdm, if we're in testing mode)
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
Albert Astals Cid (aacid) wrote : | # |
WideView:
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:2744
https:/
Executed test runs:
SUCCESS: https:/
UNSTABLE: https:/
UNSTABLE: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Albert Astals Cid (aacid) wrote : | # |
I do appreciate that we have dropped quite a bit of code, but I'm not very happy with the mock() API addition, what about http://
Albert Astals Cid (aacid) wrote : | # |
The previous paste was missing the new plugin that exposes the MockController http://
Michael Terry (mterry) wrote : | # |
Albert thanks for that! I do like that better. Though I changed from QLightDMController to LightDMController, as a matter of aesthetic preference.
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:2746
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:2747
https:/
Executed test runs:
SUCCESS: https:/
UNSTABLE: https:/
UNSTABLE: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:2748
https:/
Executed test runs:
SUCCESS: https:/
UNSTABLE: https:/
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:2748
https:/
Executed test runs:
SUCCESS: https:/
UNSTABLE: https:/
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Albert Astals Cid (aacid) wrote : | # |
Though i can not reproduce it locally
WideView:
seems to be quite persistent in failing in this branch in CI.
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:2749
https:/
Executed test runs:
SUCCESS: https:/
UNSTABLE: https:/
UNSTABLE: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:2750
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Michael Terry (mterry) wrote : | # |
OK tests pass again finally. Phew. Ready for re-review. :)
Albert Astals Cid (aacid) wrote : | # |
Mock code being removed \o/
* Did you perform an exploratory manual test run of the code change and any related functionality?
Yes
* Did CI run pass? If not, please explain why.
Yes
Albert Astals Cid (aacid) wrote : | # |
Looooooooooooots of conflicts
- 2751. By Michael Terry
-
Merge trunk
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:2751
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Michael Terry (mterry) wrote : | # |
Fixed the conflicts! Phew.
Albert Astals Cid (aacid) : | # |
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:2751
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Preview Diff
1 | === modified file 'debian/rules' | |||
2 | --- debian/rules 2017-01-03 14:02:23 +0000 | |||
3 | +++ debian/rules 2017-01-17 15:40:09 +0000 | |||
4 | @@ -40,4 +40,4 @@ | |||
5 | 40 | override_dh_shlibdeps: | 40 | override_dh_shlibdeps: |
6 | 41 | # Some mock libraries link against liblightdm-qt5-3.so which we want to | 41 | # Some mock libraries link against liblightdm-qt5-3.so which we want to |
7 | 42 | # avoid, since we only really link against our mock one, not the system one. | 42 | # avoid, since we only really link against our mock one, not the system one. |
9 | 43 | dh_shlibdeps -XlibMockLightDM-qml.so -XlibMockAccountsService-qml.so -Lunity8-private | 43 | dh_shlibdeps -XlibMockAccountsService-qml.so -Lunity8-private |
10 | 44 | 44 | ||
11 | === modified file 'plugins/LightDM/CMakeLists.txt' | |||
12 | --- plugins/LightDM/CMakeLists.txt 2016-03-02 02:54:30 +0000 | |||
13 | +++ plugins/LightDM/CMakeLists.txt 2017-01-17 15:40:09 +0000 | |||
14 | @@ -7,7 +7,6 @@ | |||
15 | 7 | ${CMAKE_CURRENT_SOURCE_DIR} | 7 | ${CMAKE_CURRENT_SOURCE_DIR} |
16 | 8 | ${CMAKE_CURRENT_BINARY_DIR} | 8 | ${CMAKE_CURRENT_BINARY_DIR} |
17 | 9 | ${CMAKE_SOURCE_DIR}/plugins/Utils | 9 | ${CMAKE_SOURCE_DIR}/plugins/Utils |
18 | 10 | ${CMAKE_BINARY_DIR}/tests/mocks/LightDM/IntegratedLightDM | ||
19 | 11 | ${libunity8-private_SOURCE_DIR} | 10 | ${libunity8-private_SOURCE_DIR} |
20 | 12 | ${LIBUSERMETRICSOUTPUT_INCLUDE_DIRS} | 11 | ${LIBUSERMETRICSOUTPUT_INCLUDE_DIRS} |
21 | 13 | ) | 12 | ) |
22 | 14 | 13 | ||
23 | === modified file 'plugins/LightDM/Greeter.cpp' | |||
24 | --- plugins/LightDM/Greeter.cpp 2016-07-28 15:34:29 +0000 | |||
25 | +++ plugins/LightDM/Greeter.cpp 2017-01-17 15:40:09 +0000 | |||
26 | @@ -1,5 +1,5 @@ | |||
27 | 1 | /* | 1 | /* |
29 | 2 | * Copyright (C) 2013, 2015 Canonical, Ltd. | 2 | * Copyright (C) 2013-2016 Canonical, Ltd. |
30 | 3 | * | 3 | * |
31 | 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 |
32 | 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 |
33 | 6 | 6 | ||
34 | === modified file 'plugins/LightDM/Greeter.h' | |||
35 | --- plugins/LightDM/Greeter.h 2016-07-28 15:34:29 +0000 | |||
36 | +++ plugins/LightDM/Greeter.h 2017-01-17 15:40:09 +0000 | |||
37 | @@ -1,5 +1,5 @@ | |||
38 | 1 | /* | 1 | /* |
40 | 2 | * Copyright (C) 2012,2013,2015 Canonical, Ltd. | 2 | * Copyright (C) 2012-2016 Canonical, Ltd. |
41 | 3 | * | 3 | * |
42 | 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 |
43 | 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 |
44 | @@ -21,8 +21,7 @@ | |||
45 | 21 | such edits in the future, and by inserting ourselves here, we have more | 21 | such edits in the future, and by inserting ourselves here, we have more |
46 | 22 | control. */ | 22 | control. */ |
47 | 23 | 23 | ||
50 | 24 | #ifndef UNITY_GREETER_H | 24 | #pragma once |
49 | 25 | #define UNITY_GREETER_H | ||
51 | 26 | 25 | ||
52 | 27 | #include <QLightDM/Greeter> | 26 | #include <QLightDM/Greeter> |
53 | 28 | #include <QtCore/QObject> | 27 | #include <QtCore/QObject> |
54 | @@ -81,5 +80,3 @@ | |||
55 | 81 | void showPromptFilter(const QString &text, QLightDM::Greeter::PromptType type); | 80 | void showPromptFilter(const QString &text, QLightDM::Greeter::PromptType type); |
56 | 82 | void authenticationCompleteFilter(); | 81 | void authenticationCompleteFilter(); |
57 | 83 | }; | 82 | }; |
58 | 84 | |||
59 | 85 | #endif | ||
60 | 86 | 83 | ||
61 | === modified file 'plugins/LightDM/SessionsModel.cpp' | |||
62 | --- plugins/LightDM/SessionsModel.cpp 2016-10-07 17:24:55 +0000 | |||
63 | +++ plugins/LightDM/SessionsModel.cpp 2017-01-17 15:40:09 +0000 | |||
64 | @@ -1,5 +1,5 @@ | |||
65 | 1 | /* | 1 | /* |
67 | 2 | * Copyright (C) 2015 Canonical, Ltd. | 2 | * Copyright (C) 2015-2016 Canonical, Ltd. |
68 | 3 | * | 3 | * |
69 | 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 |
70 | 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 |
71 | @@ -128,7 +128,6 @@ | |||
72 | 128 | } | 128 | } |
73 | 129 | 129 | ||
74 | 130 | setModel(m_model); | 130 | setModel(m_model); |
75 | 131 | setSourceModel(m_model); | ||
76 | 132 | setSortCaseSensitivity(Qt::CaseInsensitive); | 131 | setSortCaseSensitivity(Qt::CaseInsensitive); |
77 | 133 | setSortLocaleAware(true); | 132 | setSortLocaleAware(true); |
78 | 134 | setSortRole(Qt::DisplayRole); | 133 | setSortRole(Qt::DisplayRole); |
79 | 135 | 134 | ||
80 | === modified file 'plugins/LightDM/SessionsModel.h' | |||
81 | --- plugins/LightDM/SessionsModel.h 2016-12-23 11:04:53 +0000 | |||
82 | +++ plugins/LightDM/SessionsModel.h 2017-01-17 15:40:09 +0000 | |||
83 | @@ -1,5 +1,5 @@ | |||
84 | 1 | /* | 1 | /* |
86 | 2 | * Copyright (C) 2015 Canonical, Ltd. | 2 | * Copyright (C) 2015-2016 Canonical, Ltd. |
87 | 3 | * | 3 | * |
88 | 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 |
89 | 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 |
90 | @@ -15,8 +15,7 @@ | |||
91 | 15 | * | 15 | * |
92 | 16 | */ | 16 | */ |
93 | 17 | 17 | ||
96 | 18 | #ifndef UNITY_SESSIONSMODEL_H | 18 | #pragma once |
95 | 19 | #define UNITY_SESSIONSMODEL_H | ||
97 | 20 | 19 | ||
98 | 21 | #include <unitysortfilterproxymodelqml.h> | 20 | #include <unitysortfilterproxymodelqml.h> |
99 | 22 | #include <QLightDM/SessionsModel> | 21 | #include <QLightDM/SessionsModel> |
100 | @@ -30,6 +29,7 @@ | |||
101 | 30 | 29 | ||
102 | 31 | Q_PROPERTY(QList<QUrl> iconSearchDirectories READ iconSearchDirectories | 30 | Q_PROPERTY(QList<QUrl> iconSearchDirectories READ iconSearchDirectories |
103 | 32 | WRITE setIconSearchDirectories NOTIFY iconSearchDirectoriesChanged) | 31 | WRITE setIconSearchDirectories NOTIFY iconSearchDirectoriesChanged) |
104 | 32 | |||
105 | 33 | Q_SIGNALS: | 33 | Q_SIGNALS: |
106 | 34 | void iconSearchDirectoriesChanged(); | 34 | void iconSearchDirectoriesChanged(); |
107 | 35 | 35 | ||
108 | @@ -54,6 +54,7 @@ | |||
109 | 54 | Q_INVOKABLE QUrl iconUrl(const QString sessionName) const; | 54 | Q_INVOKABLE QUrl iconUrl(const QString sessionName) const; |
110 | 55 | 55 | ||
111 | 56 | void setIconSearchDirectories(const QList<QUrl> searchDirectories); | 56 | void setIconSearchDirectories(const QList<QUrl> searchDirectories); |
112 | 57 | |||
113 | 57 | private: | 58 | private: |
114 | 58 | QLightDM::SessionsModel* m_model; | 59 | QLightDM::SessionsModel* m_model; |
115 | 59 | QHash<int, QByteArray> m_roleNames; | 60 | QHash<int, QByteArray> m_roleNames; |
116 | @@ -63,5 +64,3 @@ | |||
117 | 63 | QUrl("/usr/share/unity-greeter/")}; | 64 | QUrl("/usr/share/unity-greeter/")}; |
118 | 64 | 65 | ||
119 | 65 | }; | 66 | }; |
120 | 66 | |||
121 | 67 | #endif // UNITY_SESSIONSMODEL_H | ||
122 | 68 | 67 | ||
123 | === modified file 'plugins/LightDM/UsersModel.cpp' | |||
124 | --- plugins/LightDM/UsersModel.cpp 2015-10-26 20:15:08 +0000 | |||
125 | +++ plugins/LightDM/UsersModel.cpp 2017-01-17 15:40:09 +0000 | |||
126 | @@ -1,5 +1,5 @@ | |||
127 | 1 | /* | 1 | /* |
129 | 2 | * Copyright (C) 2013 Canonical, Ltd. | 2 | * Copyright (C) 2013,2015-2016 Canonical, Ltd. |
130 | 3 | * | 3 | * |
131 | 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 |
132 | 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 |
133 | 6 | 6 | ||
134 | === modified file 'plugins/LightDM/UsersModel.h' | |||
135 | --- plugins/LightDM/UsersModel.h 2015-09-11 13:38:45 +0000 | |||
136 | +++ plugins/LightDM/UsersModel.h 2017-01-17 15:40:09 +0000 | |||
137 | @@ -1,5 +1,5 @@ | |||
138 | 1 | /* | 1 | /* |
140 | 2 | * Copyright (C) 2012,2013 Canonical, Ltd. | 2 | * Copyright (C) 2012-2013,2015-2016 Canonical, Ltd. |
141 | 3 | * | 3 | * |
142 | 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 |
143 | 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 |
144 | @@ -12,16 +12,13 @@ | |||
145 | 12 | * | 12 | * |
146 | 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 |
147 | 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/>. |
148 | 15 | * | ||
149 | 16 | * Authors: Michael Terry <michael.terry@canonical.com> | ||
150 | 17 | */ | 15 | */ |
151 | 18 | 16 | ||
152 | 19 | /* This class is a really tiny filter around QLightDM::UsersModel. There are | 17 | /* This class is a really tiny filter around QLightDM::UsersModel. There are |
153 | 20 | some operations that we want to edit a bit for the benefit of Qml. | 18 | some operations that we want to edit a bit for the benefit of Qml. |
154 | 21 | Specifically, we want to sort users according to realName. */ | 19 | Specifically, we want to sort users according to realName. */ |
155 | 22 | 20 | ||
158 | 23 | #ifndef UNITY_USERSMODEL_H | 21 | #pragma once |
157 | 24 | #define UNITY_USERSMODEL_H | ||
159 | 25 | 22 | ||
160 | 26 | #include <unitysortfilterproxymodelqml.h> | 23 | #include <unitysortfilterproxymodelqml.h> |
161 | 27 | #include <QtCore/QObject> | 24 | #include <QtCore/QObject> |
162 | @@ -33,5 +30,3 @@ | |||
163 | 33 | public: | 30 | public: |
164 | 34 | explicit UsersModel(QObject* parent=0); | 31 | explicit UsersModel(QObject* parent=0); |
165 | 35 | }; | 32 | }; |
166 | 36 | |||
167 | 37 | #endif | ||
168 | 38 | 33 | ||
169 | === modified file 'qml/Greeter/LightDMService.qml' | |||
170 | --- qml/Greeter/LightDMService.qml 2015-11-19 21:47:32 +0000 | |||
171 | +++ qml/Greeter/LightDMService.qml 2017-01-17 15:40:09 +0000 | |||
172 | @@ -35,10 +35,9 @@ | |||
173 | 35 | // This trickery handles cases where applicationArguments aren't provided | 35 | // This trickery handles cases where applicationArguments aren't provided |
174 | 36 | // such as during testing | 36 | // such as during testing |
175 | 37 | property var fullLightDM: { | 37 | property var fullLightDM: { |
180 | 38 | if (typeof applicationArguments !== "undefined") { | 38 | if (typeof applicationArguments === "undefined" || |
181 | 39 | if (applicationArguments.mode === "greeter") { | 39 | applicationArguments.mode === "greeter") { |
182 | 40 | return true; | 40 | return true; |
179 | 41 | } | ||
183 | 42 | } | 41 | } |
184 | 43 | return false; | 42 | return false; |
185 | 44 | } | 43 | } |
186 | 45 | 44 | ||
187 | === modified file 'tests/CMakeLists.txt' | |||
188 | --- tests/CMakeLists.txt 2016-12-06 20:16:56 +0000 | |||
189 | +++ tests/CMakeLists.txt 2017-01-17 15:40:09 +0000 | |||
190 | @@ -42,8 +42,8 @@ | |||
191 | 42 | 42 | ||
192 | 43 | set(ld_paths) | 43 | set(ld_paths) |
193 | 44 | list(APPEND ld_paths | 44 | list(APPEND ld_paths |
194 | 45 | ${UNITY_MOCKPATH}/liblightdm | ||
195 | 45 | ${UNITY_MOCKPATH}/libusermetrics | 46 | ${UNITY_MOCKPATH}/libusermetrics |
196 | 46 | ${UNITY_MOCKPATH}/LightDM/IntegratedLightDM/liblightdm | ||
197 | 47 | ) | 47 | ) |
198 | 48 | 48 | ||
199 | 49 | string(REPLACE ";" ":" ld_library_path "${ld_paths}") | 49 | string(REPLACE ";" ":" ld_library_path "${ld_paths}") |
200 | 50 | 50 | ||
201 | === modified file 'tests/autopilot/unity8/fixture_setup.py' | |||
202 | --- tests/autopilot/unity8/fixture_setup.py 2015-10-26 20:15:08 +0000 | |||
203 | +++ tests/autopilot/unity8/fixture_setup.py 2017-01-17 15:40:09 +0000 | |||
204 | @@ -74,7 +74,7 @@ | |||
205 | 74 | def _get_lightdm_mock_path(self): | 74 | def _get_lightdm_mock_path(self): |
206 | 75 | lib_path = get_mocks_library_path() | 75 | lib_path = get_mocks_library_path() |
207 | 76 | lightdm_mock_path = os.path.abspath( | 76 | lightdm_mock_path = os.path.abspath( |
209 | 77 | os.path.join(lib_path, "LightDM" ,"IntegratedLightDM", "liblightdm") | 77 | os.path.join(lib_path, "liblightdm") |
210 | 78 | ) | 78 | ) |
211 | 79 | 79 | ||
212 | 80 | if not os.path.exists(lightdm_mock_path): | 80 | if not os.path.exists(lightdm_mock_path): |
213 | 81 | 81 | ||
214 | === modified file 'tests/autopilot/unity8/shell/tests/__init__.py' | |||
215 | --- tests/autopilot/unity8/shell/tests/__init__.py 2016-10-25 13:11:19 +0000 | |||
216 | +++ tests/autopilot/unity8/shell/tests/__init__.py 2017-01-17 15:40:09 +0000 | |||
217 | @@ -264,7 +264,7 @@ | |||
218 | 264 | def _get_lightdm_mock_path(self): | 264 | def _get_lightdm_mock_path(self): |
219 | 265 | lib_path = get_mocks_library_path() | 265 | lib_path = get_mocks_library_path() |
220 | 266 | lightdm_mock_path = os.path.abspath( | 266 | lightdm_mock_path = os.path.abspath( |
222 | 267 | os.path.join(lib_path, "LightDM" ,"IntegratedLightDM", "liblightdm") | 267 | os.path.join(lib_path, "liblightdm") |
223 | 268 | ) | 268 | ) |
224 | 269 | 269 | ||
225 | 270 | if not os.path.exists(lightdm_mock_path): | 270 | if not os.path.exists(lightdm_mock_path): |
226 | 271 | 271 | ||
227 | === modified file 'tests/mocks/AccountsService/AccountsService.cpp' | |||
228 | --- tests/mocks/AccountsService/AccountsService.cpp 2016-08-04 14:05:54 +0000 | |||
229 | +++ tests/mocks/AccountsService/AccountsService.cpp 2017-01-17 15:40:09 +0000 | |||
230 | @@ -15,7 +15,7 @@ | |||
231 | 15 | */ | 15 | */ |
232 | 16 | 16 | ||
233 | 17 | #include "AccountsService.h" | 17 | #include "AccountsService.h" |
235 | 18 | #include "MockUsersModel.h" | 18 | #include "UsersModel.h" |
236 | 19 | 19 | ||
237 | 20 | #include <QLightDM/UsersModel> | 20 | #include <QLightDM/UsersModel> |
238 | 21 | #include <paths.h> | 21 | #include <paths.h> |
239 | @@ -33,9 +33,8 @@ | |||
240 | 33 | m_demoEdgesCompleted(), | 33 | m_demoEdgesCompleted(), |
241 | 34 | m_hereEnabled(false), | 34 | m_hereEnabled(false), |
242 | 35 | m_hereLicensePath(""), | 35 | m_hereLicensePath(""), |
244 | 36 | m_usersModel(new MockUsersModel(this)) | 36 | m_usersModel(new UsersModel(this)) |
245 | 37 | { | 37 | { |
246 | 38 | m_usersModel->setMockMode("full"); | ||
247 | 39 | } | 38 | } |
248 | 40 | 39 | ||
249 | 41 | QString AccountsService::user() const | 40 | QString AccountsService::user() const |
250 | 42 | 41 | ||
251 | === modified file 'tests/mocks/AccountsService/AccountsService.h' | |||
252 | --- tests/mocks/AccountsService/AccountsService.h 2016-12-23 11:04:53 +0000 | |||
253 | +++ tests/mocks/AccountsService/AccountsService.h 2017-01-17 15:40:09 +0000 | |||
254 | @@ -14,15 +14,14 @@ | |||
255 | 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/>. |
256 | 15 | */ | 15 | */ |
257 | 16 | 16 | ||
260 | 17 | #ifndef UNITY_MOCK_ACCOUNTSSERVICE_H | 17 | #pragma once |
259 | 18 | #define UNITY_MOCK_ACCOUNTSSERVICE_H | ||
261 | 19 | 18 | ||
262 | 20 | #include <QObject> | 19 | #include <QObject> |
263 | 21 | #include <QString> | 20 | #include <QString> |
264 | 22 | #include <QStringList> | 21 | #include <QStringList> |
265 | 23 | #include <QVariant> | 22 | #include <QVariant> |
266 | 24 | 23 | ||
268 | 25 | class MockUsersModel; | 24 | class UsersModel; |
269 | 26 | 25 | ||
270 | 27 | class AccountsService: public QObject | 26 | class AccountsService: public QObject |
271 | 28 | { | 27 | { |
272 | @@ -165,7 +164,5 @@ | |||
273 | 165 | QString m_realName; | 164 | QString m_realName; |
274 | 166 | QStringList m_kbdMap; | 165 | QStringList m_kbdMap; |
275 | 167 | QString m_email; | 166 | QString m_email; |
277 | 168 | MockUsersModel *m_usersModel; | 167 | UsersModel *m_usersModel; |
278 | 169 | }; | 168 | }; |
279 | 170 | |||
280 | 171 | #endif | ||
281 | 172 | 169 | ||
282 | === modified file 'tests/mocks/AccountsService/CMakeLists.txt' | |||
283 | --- tests/mocks/AccountsService/CMakeLists.txt 2016-12-06 20:16:56 +0000 | |||
284 | +++ tests/mocks/AccountsService/CMakeLists.txt 2017-01-17 15:40:09 +0000 | |||
285 | @@ -1,14 +1,13 @@ | |||
286 | 1 | include_directories( | 1 | include_directories( |
287 | 2 | ${CMAKE_CURRENT_BINARY_DIR} | 2 | ${CMAKE_CURRENT_BINARY_DIR} |
288 | 3 | ${CMAKE_SOURCE_DIR}/plugins/LightDM | 3 | ${CMAKE_SOURCE_DIR}/plugins/LightDM |
289 | 4 | ${CMAKE_SOURCE_DIR}/plugins/LightDM/IntegratedLightDM | ||
290 | 4 | ${CMAKE_SOURCE_DIR}/plugins/Utils | 5 | ${CMAKE_SOURCE_DIR}/plugins/Utils |
291 | 5 | ${CMAKE_SOURCE_DIR}/tests/mocks/LightDM/IntegratedLightDM | ||
292 | 6 | ) | 6 | ) |
293 | 7 | 7 | ||
294 | 8 | add_library(MockAccountsService-qml MODULE | 8 | add_library(MockAccountsService-qml MODULE |
295 | 9 | ${CMAKE_SOURCE_DIR}/plugins/LightDM/UsersModel.cpp | 9 | ${CMAKE_SOURCE_DIR}/plugins/LightDM/UsersModel.cpp |
296 | 10 | ${CMAKE_SOURCE_DIR}/plugins/Utils/unitysortfilterproxymodelqml.cpp | 10 | ${CMAKE_SOURCE_DIR}/plugins/Utils/unitysortfilterproxymodelqml.cpp |
297 | 11 | ${CMAKE_SOURCE_DIR}/tests/mocks/LightDM/IntegratedLightDM/MockUsersModel.cpp | ||
298 | 12 | AccountsService.cpp | 11 | AccountsService.cpp |
299 | 13 | plugin.cpp | 12 | plugin.cpp |
300 | 14 | ) | 13 | ) |
301 | 15 | 14 | ||
302 | === modified file 'tests/mocks/CMakeLists.txt' | |||
303 | --- tests/mocks/CMakeLists.txt 2016-12-06 20:16:56 +0000 | |||
304 | +++ tests/mocks/CMakeLists.txt 2017-01-17 15:40:09 +0000 | |||
305 | @@ -32,8 +32,9 @@ | |||
306 | 32 | add_subdirectory(Cursor) | 32 | add_subdirectory(Cursor) |
307 | 33 | add_subdirectory(GSettings.1.0) | 33 | add_subdirectory(GSettings.1.0) |
308 | 34 | add_subdirectory(indicator-service) | 34 | add_subdirectory(indicator-service) |
309 | 35 | add_subdirectory(liblightdm) | ||
310 | 35 | add_subdirectory(libusermetrics) | 36 | add_subdirectory(libusermetrics) |
312 | 36 | add_subdirectory(LightDM) | 37 | add_subdirectory(LightDMController) |
313 | 37 | add_subdirectory(Lights) | 38 | add_subdirectory(Lights) |
314 | 38 | add_subdirectory(MeeGo) | 39 | add_subdirectory(MeeGo) |
315 | 39 | add_subdirectory(Powerd) | 40 | add_subdirectory(Powerd) |
316 | 40 | 41 | ||
317 | === removed directory 'tests/mocks/LightDM' | |||
318 | === removed file 'tests/mocks/LightDM/CMakeLists.txt' | |||
319 | --- tests/mocks/LightDM/CMakeLists.txt 2015-09-25 13:01:00 +0000 | |||
320 | +++ tests/mocks/LightDM/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
321 | @@ -1,1 +0,0 @@ | |||
322 | 1 | add_subdirectory(IntegratedLightDM) | ||
323 | 2 | 0 | ||
324 | === removed directory 'tests/mocks/LightDM/IntegratedLightDM' | |||
325 | === removed file 'tests/mocks/LightDM/IntegratedLightDM/CMakeLists.txt' | |||
326 | --- tests/mocks/LightDM/IntegratedLightDM/CMakeLists.txt 2016-07-14 13:04:10 +0000 | |||
327 | +++ tests/mocks/LightDM/IntegratedLightDM/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
328 | @@ -1,50 +0,0 @@ | |||
329 | 1 | # This is a copy of the normal LightDM plugin, but instead of statically | ||
330 | 2 | # linking in the lightdm bits, this one uses shared libraries so we can swap | ||
331 | 3 | # out different sets of users for different tests. When we finally switch to | ||
332 | 4 | # actually using the system liblightdm in the normal plugin, this version can | ||
333 | 5 | # be deleted. | ||
334 | 6 | |||
335 | 7 | add_subdirectory(liblightdm) | ||
336 | 8 | |||
337 | 9 | include_directories( | ||
338 | 10 | ${CMAKE_CURRENT_SOURCE_DIR} | ||
339 | 11 | ${CMAKE_CURRENT_BINARY_DIR} | ||
340 | 12 | ${CMAKE_SOURCE_DIR}/plugins/Utils | ||
341 | 13 | ${CMAKE_SOURCE_DIR}/plugins/LightDM | ||
342 | 14 | ${CMAKE_SOURCE_DIR}/tests/mocks/libusermetrics | ||
343 | 15 | ${libunity8-private_SOURCE_DIR} | ||
344 | 16 | ) | ||
345 | 17 | |||
346 | 18 | set(QMLPLUGIN_SRC | ||
347 | 19 | ${CMAKE_SOURCE_DIR}/plugins/LightDM/DBusGreeter.cpp | ||
348 | 20 | ${CMAKE_SOURCE_DIR}/plugins/LightDM/DBusGreeterList.cpp | ||
349 | 21 | ${CMAKE_SOURCE_DIR}/plugins/LightDM/Greeter.cpp | ||
350 | 22 | ${CMAKE_SOURCE_DIR}/plugins/LightDM/SessionsModel.cpp | ||
351 | 23 | ${CMAKE_SOURCE_DIR}/plugins/LightDM/UsersModel.cpp | ||
352 | 24 | ${CMAKE_SOURCE_DIR}/plugins/Utils/unitysortfilterproxymodelqml.cpp | ||
353 | 25 | MockGreeter.cpp | ||
354 | 26 | MockSessionsModel.cpp | ||
355 | 27 | MockUsersModel.cpp | ||
356 | 28 | plugin.cpp | ||
357 | 29 | ) | ||
358 | 30 | |||
359 | 31 | add_library(MockLightDM-qml MODULE | ||
360 | 32 | ${QMLPLUGIN_SRC} | ||
361 | 33 | ) | ||
362 | 34 | |||
363 | 35 | # We want to link to liblightdm-qt5-3, but we don't want to depend on it being | ||
364 | 36 | # installed on the system. So we make sure we link to our full fake version | ||
365 | 37 | # At run time, we can point to whichever version we happen to be using via | ||
366 | 38 | # LD_LIBRARY_PATH. | ||
367 | 39 | target_link_libraries(MockLightDM-qml | ||
368 | 40 | MockLightDM | ||
369 | 41 | MockUserMetrics | ||
370 | 42 | unity8-private | ||
371 | 43 | ) | ||
372 | 44 | |||
373 | 45 | qt5_use_modules(MockLightDM-qml DBus Gui Qml) | ||
374 | 46 | |||
375 | 47 | add_unity8_mock(LightDM.IntegratedLightDM 0.1 LightDM/IntegratedLightDM | ||
376 | 48 | TARGETS MockLightDM-qml | ||
377 | 49 | ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_CURRENT_BINARY_DIR}/liblightdm" | ||
378 | 50 | ) | ||
379 | 51 | 0 | ||
380 | === removed file 'tests/mocks/LightDM/IntegratedLightDM/MockGreeter.cpp' | |||
381 | --- tests/mocks/LightDM/IntegratedLightDM/MockGreeter.cpp 2016-06-09 21:45:09 +0000 | |||
382 | +++ tests/mocks/LightDM/IntegratedLightDM/MockGreeter.cpp 1970-01-01 00:00:00 +0000 | |||
383 | @@ -1,51 +0,0 @@ | |||
384 | 1 | /* | ||
385 | 2 | * Copyright (C) 2014 Canonical, Ltd. | ||
386 | 3 | * | ||
387 | 4 | * This program is free software; you can redistribute it and/or modify | ||
388 | 5 | * it under the terms of the GNU General Public License as published by | ||
389 | 6 | * the Free Software Foundation; version 3. | ||
390 | 7 | * | ||
391 | 8 | * This program is distributed in the hope that it will be useful, | ||
392 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
393 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
394 | 11 | * GNU General Public License for more details. | ||
395 | 12 | * | ||
396 | 13 | * You should have received a copy of the GNU General Public License | ||
397 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
398 | 15 | * | ||
399 | 16 | */ | ||
400 | 17 | |||
401 | 18 | #include "MockGreeter.h" | ||
402 | 19 | #include <GreeterPrivate.h> | ||
403 | 20 | |||
404 | 21 | QString MockGreeter::mockMode() const | ||
405 | 22 | { | ||
406 | 23 | Q_D(const Greeter); | ||
407 | 24 | return d->m_greeter->mockMode(); | ||
408 | 25 | } | ||
409 | 26 | |||
410 | 27 | void MockGreeter::setMockMode(QString mockMode) | ||
411 | 28 | { | ||
412 | 29 | Q_D(Greeter); | ||
413 | 30 | |||
414 | 31 | if (d->m_greeter->mockMode() != mockMode) { | ||
415 | 32 | d->m_greeter->setMockMode(mockMode); | ||
416 | 33 | Q_EMIT mockModeChanged(mockMode); | ||
417 | 34 | } | ||
418 | 35 | } | ||
419 | 36 | |||
420 | 37 | QString MockGreeter::selectUserHint() const | ||
421 | 38 | { | ||
422 | 39 | Q_D(const Greeter); | ||
423 | 40 | return d->m_greeter->selectUserHint(); | ||
424 | 41 | } | ||
425 | 42 | |||
426 | 43 | void MockGreeter::setSelectUserHint(const QString &selectUserHint) | ||
427 | 44 | { | ||
428 | 45 | Q_D(Greeter); | ||
429 | 46 | |||
430 | 47 | if (d->m_greeter->selectUserHint() != selectUserHint) { | ||
431 | 48 | d->m_greeter->setSelectUserHint(selectUserHint); | ||
432 | 49 | Q_EMIT selectUserHintChanged(); | ||
433 | 50 | } | ||
434 | 51 | } | ||
435 | 52 | 0 | ||
436 | === removed file 'tests/mocks/LightDM/IntegratedLightDM/MockGreeter.h' | |||
437 | --- tests/mocks/LightDM/IntegratedLightDM/MockGreeter.h 2016-06-09 21:45:09 +0000 | |||
438 | +++ tests/mocks/LightDM/IntegratedLightDM/MockGreeter.h 1970-01-01 00:00:00 +0000 | |||
439 | @@ -1,42 +0,0 @@ | |||
440 | 1 | /* | ||
441 | 2 | * Copyright (C) 2014 Canonical, Ltd. | ||
442 | 3 | * | ||
443 | 4 | * This program is free software; you can redistribute it and/or modify | ||
444 | 5 | * it under the terms of the GNU General Public License as published by | ||
445 | 6 | * the Free Software Foundation; version 3. | ||
446 | 7 | * | ||
447 | 8 | * This program is distributed in the hope that it will be useful, | ||
448 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
449 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
450 | 11 | * GNU General Public License for more details. | ||
451 | 12 | * | ||
452 | 13 | * You should have received a copy of the GNU General Public License | ||
453 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
454 | 15 | * | ||
455 | 16 | */ | ||
456 | 17 | |||
457 | 18 | // The real, production, Greeter | ||
458 | 19 | #include <Greeter.h> | ||
459 | 20 | |||
460 | 21 | #ifndef MOCK_UNITY_GREETER_H | ||
461 | 22 | #define MOCK_UNITY_GREETER_H | ||
462 | 23 | |||
463 | 24 | class MockGreeter : public Greeter { | ||
464 | 25 | Q_OBJECT | ||
465 | 26 | |||
466 | 27 | Q_PROPERTY(QString mockMode READ mockMode WRITE setMockMode NOTIFY mockModeChanged) | ||
467 | 28 | Q_PROPERTY(QString selectUser READ selectUserHint WRITE setSelectUserHint NOTIFY selectUserHintChanged) | ||
468 | 29 | |||
469 | 30 | public: | ||
470 | 31 | QString mockMode() const; | ||
471 | 32 | void setMockMode(QString mockMode); | ||
472 | 33 | |||
473 | 34 | QString selectUserHint() const; | ||
474 | 35 | void setSelectUserHint(const QString &selectUserHint); | ||
475 | 36 | |||
476 | 37 | Q_SIGNALS: | ||
477 | 38 | void mockModeChanged(QString mode); | ||
478 | 39 | void selectUserHintChanged(); | ||
479 | 40 | }; | ||
480 | 41 | |||
481 | 42 | #endif // MOCK_UNITY_GREETER_H | ||
482 | 43 | 0 | ||
483 | === removed file 'tests/mocks/LightDM/IntegratedLightDM/MockSessionsModel.cpp' | |||
484 | --- tests/mocks/LightDM/IntegratedLightDM/MockSessionsModel.cpp 2016-07-13 20:24:24 +0000 | |||
485 | +++ tests/mocks/LightDM/IntegratedLightDM/MockSessionsModel.cpp 1970-01-01 00:00:00 +0000 | |||
486 | @@ -1,66 +0,0 @@ | |||
487 | 1 | /* | ||
488 | 2 | * Copyright (C) 2015 Canonical, Ltd. | ||
489 | 3 | * | ||
490 | 4 | * This program is free software; you can redistribute it and/or modify | ||
491 | 5 | * it under the terms of the GNU General Public License as published by | ||
492 | 6 | * the Free Software Foundation; version 3. | ||
493 | 7 | * | ||
494 | 8 | * This program is distributed in the hope that it will be useful, | ||
495 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
496 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
497 | 11 | * GNU General Public License for more details. | ||
498 | 12 | * | ||
499 | 13 | * You should have received a copy of the GNU General Public License | ||
500 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
501 | 15 | * | ||
502 | 16 | */ | ||
503 | 17 | |||
504 | 18 | #include "MockSessionsModel.h" | ||
505 | 19 | #include <QLightDM/SessionsModel> | ||
506 | 20 | |||
507 | 21 | |||
508 | 22 | int MockSessionsModel::numSessions() const | ||
509 | 23 | { | ||
510 | 24 | QLightDM::SessionsModel* qSessionsModel = | ||
511 | 25 | static_cast<QLightDM::SessionsModel*>(sourceModel()); | ||
512 | 26 | |||
513 | 27 | return qSessionsModel->numSessions(); | ||
514 | 28 | } | ||
515 | 29 | |||
516 | 30 | int MockSessionsModel::numAvailableSessions() const | ||
517 | 31 | { | ||
518 | 32 | QLightDM::SessionsModel* qSessionsModel = | ||
519 | 33 | static_cast<QLightDM::SessionsModel*>(sourceModel()); | ||
520 | 34 | |||
521 | 35 | return qSessionsModel->numAvailableSessions(); | ||
522 | 36 | } | ||
523 | 37 | |||
524 | 38 | QString MockSessionsModel::testScenario() const | ||
525 | 39 | { | ||
526 | 40 | QLightDM::SessionsModel* qSessionsModel = | ||
527 | 41 | static_cast<QLightDM::SessionsModel*>(sourceModel()); | ||
528 | 42 | |||
529 | 43 | return qSessionsModel->testScenario(); | ||
530 | 44 | } | ||
531 | 45 | |||
532 | 46 | void MockSessionsModel::setNumSessions(const int numSessions) | ||
533 | 47 | { | ||
534 | 48 | QLightDM::SessionsModel* qSessionsModel = | ||
535 | 49 | static_cast<QLightDM::SessionsModel*>(sourceModel()); | ||
536 | 50 | |||
537 | 51 | if (qSessionsModel->numSessions() != numSessions) { | ||
538 | 52 | qSessionsModel->setNumSessions(numSessions); | ||
539 | 53 | Q_EMIT numSessionsChanged(); | ||
540 | 54 | } | ||
541 | 55 | } | ||
542 | 56 | |||
543 | 57 | void MockSessionsModel::setTestScenario(const QString testScenario) | ||
544 | 58 | { | ||
545 | 59 | QLightDM::SessionsModel* qSessionsModel = | ||
546 | 60 | static_cast<QLightDM::SessionsModel*>(sourceModel()); | ||
547 | 61 | |||
548 | 62 | if (qSessionsModel->testScenario() != testScenario) { | ||
549 | 63 | qSessionsModel->setTestScenario(testScenario); | ||
550 | 64 | Q_EMIT testScenarioChanged(); | ||
551 | 65 | } | ||
552 | 66 | } | ||
553 | 67 | 0 | ||
554 | === removed file 'tests/mocks/LightDM/IntegratedLightDM/MockSessionsModel.h' | |||
555 | --- tests/mocks/LightDM/IntegratedLightDM/MockSessionsModel.h 2016-07-13 20:24:24 +0000 | |||
556 | +++ tests/mocks/LightDM/IntegratedLightDM/MockSessionsModel.h 1970-01-01 00:00:00 +0000 | |||
557 | @@ -1,44 +0,0 @@ | |||
558 | 1 | /* | ||
559 | 2 | * Copyright (C) 2015 Canonical, Ltd. | ||
560 | 3 | * | ||
561 | 4 | * This program is free software; you can redistribute it and/or modify | ||
562 | 5 | * it under the terms of the GNU General Public License as published by | ||
563 | 6 | * the Free Software Foundation; version 3. | ||
564 | 7 | * | ||
565 | 8 | * This program is distributed in the hope that it will be useful, | ||
566 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
567 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
568 | 11 | * GNU General Public License for more details. | ||
569 | 12 | * | ||
570 | 13 | * You should have received a copy of the GNU General Public License | ||
571 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
572 | 15 | * | ||
573 | 16 | */ | ||
574 | 17 | |||
575 | 18 | #ifndef MOCK_UNITY_SESSIONSMODEL_H | ||
576 | 19 | #define MOCK_UNITY_SESSIONSMODEL_H | ||
577 | 20 | |||
578 | 21 | #include <SessionsModel.h> | ||
579 | 22 | |||
580 | 23 | class MockSessionsModel : public SessionsModel | ||
581 | 24 | { | ||
582 | 25 | Q_OBJECT | ||
583 | 26 | |||
584 | 27 | Q_PROPERTY(int numAvailableSessions READ numAvailableSessions CONSTANT) | ||
585 | 28 | Q_PROPERTY(int numSessions READ numSessions WRITE setNumSessions NOTIFY numSessionsChanged) | ||
586 | 29 | Q_PROPERTY(QString testScenario READ testScenario WRITE setTestScenario NOTIFY testScenarioChanged) | ||
587 | 30 | |||
588 | 31 | public: | ||
589 | 32 | int numAvailableSessions() const; | ||
590 | 33 | int numSessions() const; | ||
591 | 34 | QString testScenario() const; | ||
592 | 35 | void setNumSessions(const int numSessions); | ||
593 | 36 | void setTestScenario(const QString testScenario); | ||
594 | 37 | |||
595 | 38 | Q_SIGNALS: | ||
596 | 39 | void numSessionsChanged(); | ||
597 | 40 | void testScenarioChanged(); | ||
598 | 41 | |||
599 | 42 | }; | ||
600 | 43 | |||
601 | 44 | #endif // MOCK_UNITY_SESSIONSMODEL_H | ||
602 | 45 | 0 | ||
603 | === removed file 'tests/mocks/LightDM/IntegratedLightDM/MockUsersModel.cpp' | |||
604 | --- tests/mocks/LightDM/IntegratedLightDM/MockUsersModel.cpp 2016-08-04 14:05:54 +0000 | |||
605 | +++ tests/mocks/LightDM/IntegratedLightDM/MockUsersModel.cpp 1970-01-01 00:00:00 +0000 | |||
606 | @@ -1,44 +0,0 @@ | |||
607 | 1 | /* | ||
608 | 2 | * Copyright (C) 2014 Canonical, Ltd. | ||
609 | 3 | * | ||
610 | 4 | * This program is free software; you can redistribute it and/or modify | ||
611 | 5 | * it under the terms of the GNU General Public License as published by | ||
612 | 6 | * the Free Software Foundation; version 3. | ||
613 | 7 | * | ||
614 | 8 | * This program is distributed in the hope that it will be useful, | ||
615 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
616 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
617 | 11 | * GNU General Public License for more details. | ||
618 | 12 | * | ||
619 | 13 | * You should have received a copy of the GNU General Public License | ||
620 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
621 | 15 | * | ||
622 | 16 | */ | ||
623 | 17 | |||
624 | 18 | #include "MockUsersModel.h" | ||
625 | 19 | #include <QLightDM/UsersModel> | ||
626 | 20 | #include <QSortFilterProxyModel> | ||
627 | 21 | |||
628 | 22 | MockUsersModel::MockUsersModel(QObject* parent) | ||
629 | 23 | : UsersModel(parent) | ||
630 | 24 | { | ||
631 | 25 | } | ||
632 | 26 | |||
633 | 27 | QString MockUsersModel::mockMode() const | ||
634 | 28 | { | ||
635 | 29 | QLightDM::UsersModel* qUsersModel = | ||
636 | 30 | static_cast<QLightDM::UsersModel*>(static_cast<QSortFilterProxyModel*>(sourceModel())->sourceModel()); | ||
637 | 31 | |||
638 | 32 | return qUsersModel->mockMode(); | ||
639 | 33 | } | ||
640 | 34 | |||
641 | 35 | void MockUsersModel::setMockMode(QString mockMode) | ||
642 | 36 | { | ||
643 | 37 | QLightDM::UsersModel* qUsersModel = | ||
644 | 38 | static_cast<QLightDM::UsersModel*>(static_cast<QSortFilterProxyModel*>(sourceModel())->sourceModel()); | ||
645 | 39 | |||
646 | 40 | if (qUsersModel->mockMode() != mockMode) { | ||
647 | 41 | qUsersModel->setMockMode(mockMode); | ||
648 | 42 | Q_EMIT mockModeChanged(mockMode); | ||
649 | 43 | } | ||
650 | 44 | } | ||
651 | 45 | 0 | ||
652 | === removed file 'tests/mocks/LightDM/IntegratedLightDM/MockUsersModel.h' | |||
653 | --- tests/mocks/LightDM/IntegratedLightDM/MockUsersModel.h 2016-08-04 14:05:54 +0000 | |||
654 | +++ tests/mocks/LightDM/IntegratedLightDM/MockUsersModel.h 1970-01-01 00:00:00 +0000 | |||
655 | @@ -1,39 +0,0 @@ | |||
656 | 1 | /* | ||
657 | 2 | * Copyright (C) 2014 Canonical, Ltd. | ||
658 | 3 | * | ||
659 | 4 | * This program is free software; you can redistribute it and/or modify | ||
660 | 5 | * it under the terms of the GNU General Public License as published by | ||
661 | 6 | * the Free Software Foundation; version 3. | ||
662 | 7 | * | ||
663 | 8 | * This program is distributed in the hope that it will be useful, | ||
664 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
665 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
666 | 11 | * GNU General Public License for more details. | ||
667 | 12 | * | ||
668 | 13 | * You should have received a copy of the GNU General Public License | ||
669 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
670 | 15 | * | ||
671 | 16 | */ | ||
672 | 17 | |||
673 | 18 | #ifndef MOCK_UNITY_USERSMODEL_H | ||
674 | 19 | #define MOCK_UNITY_USERSMODEL_H | ||
675 | 20 | |||
676 | 21 | #include <UsersModel.h> | ||
677 | 22 | |||
678 | 23 | class MockUsersModel : public UsersModel | ||
679 | 24 | { | ||
680 | 25 | Q_OBJECT | ||
681 | 26 | |||
682 | 27 | Q_PROPERTY(QString mockMode READ mockMode WRITE setMockMode NOTIFY mockModeChanged) | ||
683 | 28 | |||
684 | 29 | public: | ||
685 | 30 | explicit MockUsersModel(QObject* parent=0); | ||
686 | 31 | |||
687 | 32 | QString mockMode() const; | ||
688 | 33 | void setMockMode(QString mockMode); | ||
689 | 34 | |||
690 | 35 | Q_SIGNALS: | ||
691 | 36 | void mockModeChanged(QString mode); | ||
692 | 37 | }; | ||
693 | 38 | |||
694 | 39 | #endif // MOCK_UNITY_USERSMODEL_H | ||
695 | 40 | 0 | ||
696 | === removed directory 'tests/mocks/LightDM/IntegratedLightDM/QLightDM' | |||
697 | === removed file 'tests/mocks/LightDM/IntegratedLightDM/QLightDM/Greeter' | |||
698 | --- tests/mocks/LightDM/IntegratedLightDM/QLightDM/Greeter 2015-01-20 11:50:19 +0000 | |||
699 | +++ tests/mocks/LightDM/IntegratedLightDM/QLightDM/Greeter 1970-01-01 00:00:00 +0000 | |||
700 | @@ -1,17 +0,0 @@ | |||
701 | 1 | /* | ||
702 | 2 | * Copyright (C) 2014 Canonical, Ltd. | ||
703 | 3 | * | ||
704 | 4 | * This program is free software; you can redistribute it and/or modify | ||
705 | 5 | * it under the terms of the GNU General Public License as published by | ||
706 | 6 | * the Free Software Foundation; version 3. | ||
707 | 7 | * | ||
708 | 8 | * This program is distributed in the hope that it will be useful, | ||
709 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
710 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
711 | 11 | * GNU General Public License for more details. | ||
712 | 12 | * | ||
713 | 13 | * You should have received a copy of the GNU General Public License | ||
714 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
715 | 15 | */ | ||
716 | 16 | |||
717 | 17 | #include "../liblightdm/Greeter.h" | ||
718 | 18 | 0 | ||
719 | === removed file 'tests/mocks/LightDM/IntegratedLightDM/QLightDM/SessionsModel' | |||
720 | --- tests/mocks/LightDM/IntegratedLightDM/QLightDM/SessionsModel 2015-11-18 03:52:01 +0000 | |||
721 | +++ tests/mocks/LightDM/IntegratedLightDM/QLightDM/SessionsModel 1970-01-01 00:00:00 +0000 | |||
722 | @@ -1,17 +0,0 @@ | |||
723 | 1 | /* | ||
724 | 2 | * Copyright (C) 2015 Canonical, Ltd. | ||
725 | 3 | * | ||
726 | 4 | * This program is free software; you can redistribute it and/or modify | ||
727 | 5 | * it under the terms of the GNU General Public License as published by | ||
728 | 6 | * the Free Software Foundation; version 3. | ||
729 | 7 | * | ||
730 | 8 | * This program is distributed in the hope that it will be useful, | ||
731 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
732 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
733 | 11 | * GNU General Public License for more details. | ||
734 | 12 | * | ||
735 | 13 | * You should have received a copy of the GNU General Public License | ||
736 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
737 | 15 | */ | ||
738 | 16 | |||
739 | 17 | #include "../liblightdm/SessionsModel.h" | ||
740 | 18 | 0 | ||
741 | === removed file 'tests/mocks/LightDM/IntegratedLightDM/QLightDM/UsersModel' | |||
742 | --- tests/mocks/LightDM/IntegratedLightDM/QLightDM/UsersModel 2015-01-20 11:50:19 +0000 | |||
743 | +++ tests/mocks/LightDM/IntegratedLightDM/QLightDM/UsersModel 1970-01-01 00:00:00 +0000 | |||
744 | @@ -1,17 +0,0 @@ | |||
745 | 1 | /* | ||
746 | 2 | * Copyright (C) 2014 Canonical, Ltd. | ||
747 | 3 | * | ||
748 | 4 | * This program is free software; you can redistribute it and/or modify | ||
749 | 5 | * it under the terms of the GNU General Public License as published by | ||
750 | 6 | * the Free Software Foundation; version 3. | ||
751 | 7 | * | ||
752 | 8 | * This program is distributed in the hope that it will be useful, | ||
753 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
754 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
755 | 11 | * GNU General Public License for more details. | ||
756 | 12 | * | ||
757 | 13 | * You should have received a copy of the GNU General Public License | ||
758 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
759 | 15 | */ | ||
760 | 16 | |||
761 | 17 | #include "../liblightdm/UsersModel.h" | ||
762 | 18 | 0 | ||
763 | === removed file 'tests/mocks/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.cpp' | |||
764 | --- tests/mocks/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.cpp 2016-06-09 21:45:09 +0000 | |||
765 | +++ tests/mocks/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.cpp 1970-01-01 00:00:00 +0000 | |||
766 | @@ -1,132 +0,0 @@ | |||
767 | 1 | /* | ||
768 | 2 | * Copyright (C) 2014 Canonical, Ltd. | ||
769 | 3 | * | ||
770 | 4 | * This program is free software; you can redistribute it and/or modify | ||
771 | 5 | * it under the terms of the GNU General Public License as published by | ||
772 | 6 | * the Free Software Foundation; version 3. | ||
773 | 7 | * | ||
774 | 8 | * This program is distributed in the hope that it will be useful, | ||
775 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
776 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
777 | 11 | * GNU General Public License for more details. | ||
778 | 12 | * | ||
779 | 13 | * You should have received a copy of the GNU General Public License | ||
780 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
781 | 15 | */ | ||
782 | 16 | |||
783 | 17 | #include "Greeter.h" | ||
784 | 18 | #include "GreeterPrivate.h" | ||
785 | 19 | |||
786 | 20 | namespace QLightDM | ||
787 | 21 | { | ||
788 | 22 | |||
789 | 23 | GreeterPrivate::GreeterPrivate(Greeter* parent) | ||
790 | 24 | : authenticated(false), | ||
791 | 25 | authenticationUser(), | ||
792 | 26 | twoFactorDone(false), | ||
793 | 27 | mockMode("single"), | ||
794 | 28 | q_ptr(parent) | ||
795 | 29 | { | ||
796 | 30 | char *envMockMode = getenv("LIBLIGHTDM_MOCK_MODE"); | ||
797 | 31 | if (envMockMode) { | ||
798 | 32 | mockMode = envMockMode; | ||
799 | 33 | } | ||
800 | 34 | } | ||
801 | 35 | |||
802 | 36 | void GreeterPrivate::handleAuthenticate() | ||
803 | 37 | { | ||
804 | 38 | Q_Q(Greeter); | ||
805 | 39 | |||
806 | 40 | if (mockMode == "single") { | ||
807 | 41 | authenticated = true; | ||
808 | 42 | Q_EMIT q->authenticationComplete(); | ||
809 | 43 | } else if (mockMode == "single-passphrase" || mockMode == "single-pin") { | ||
810 | 44 | Q_EMIT q->showPrompt("Password: ", Greeter::PromptTypeSecret); | ||
811 | 45 | } else if (mockMode == "full") { | ||
812 | 46 | handleAuthenticate_full(); | ||
813 | 47 | } | ||
814 | 48 | } | ||
815 | 49 | |||
816 | 50 | void GreeterPrivate::handleAuthenticate_full() | ||
817 | 51 | { | ||
818 | 52 | Q_Q(Greeter); | ||
819 | 53 | |||
820 | 54 | // Send out any messages we need to | ||
821 | 55 | if (authenticationUser == "info-prompt") | ||
822 | 56 | Q_EMIT q->showMessage("Welcome to Unity Greeter", Greeter::MessageTypeInfo); | ||
823 | 57 | else if (authenticationUser == "wide-info-prompt") | ||
824 | 58 | Q_EMIT q->showMessage("Welcome to Unity Greeter, the greeteriest greeter that ever did appear in these fine lands", Greeter::MessageTypeInfo); | ||
825 | 59 | else if (authenticationUser == "html-info-prompt") | ||
826 | 60 | Q_EMIT q->showMessage("<b>&</b>", Greeter::MessageTypeInfo); | ||
827 | 61 | else if (authenticationUser == "long-info-prompt") | ||
828 | 62 | Q_EMIT q->showMessage("Welcome to Unity Greeter\n\nWe like to annoy you with super ridiculously long messages.\nLike this one\n\nThis is the last line of a multiple line message.", Greeter::MessageTypeInfo); | ||
829 | 63 | else if (authenticationUser == "multi-info-prompt") { | ||
830 | 64 | Q_EMIT q->showMessage("Welcome to Unity Greeter", Greeter::MessageTypeInfo); | ||
831 | 65 | Q_EMIT q->showMessage("This is an error", Greeter::MessageTypeError); | ||
832 | 66 | Q_EMIT q->showMessage("You should have seen three messages", Greeter::MessageTypeInfo); | ||
833 | 67 | } | ||
834 | 68 | |||
835 | 69 | // OK, now actually do the prompt | ||
836 | 70 | if (authenticationUser == "no-password") { | ||
837 | 71 | authenticated = true; | ||
838 | 72 | Q_EMIT q->authenticationComplete(); | ||
839 | 73 | } else if (authenticationUser == "has-pin"){ | ||
840 | 74 | Q_EMIT q->showPrompt("Password: ", Greeter::PromptTypeSecret); | ||
841 | 75 | } else if (authenticationUser == "auth-error") { | ||
842 | 76 | authenticated = false; | ||
843 | 77 | Q_EMIT q->authenticationComplete(); | ||
844 | 78 | } else if (authenticationUser == "different-prompt") { | ||
845 | 79 | Q_EMIT q->showPrompt("Secret word: ", Greeter::PromptTypeSecret); | ||
846 | 80 | } else { | ||
847 | 81 | Q_EMIT q->showPrompt("Password: ", Greeter::PromptTypeSecret); | ||
848 | 82 | } | ||
849 | 83 | } | ||
850 | 84 | |||
851 | 85 | void GreeterPrivate::handleRespond(QString const &response) | ||
852 | 86 | { | ||
853 | 87 | Q_Q(Greeter); | ||
854 | 88 | |||
855 | 89 | if (mockMode == "single") { | ||
856 | 90 | // NOOP | ||
857 | 91 | } else if (mockMode == "single-passphrase") { | ||
858 | 92 | authenticated = (response == "password"); | ||
859 | 93 | q->sendAuthenticationComplete(); | ||
860 | 94 | } else if (mockMode == "single-pin") { | ||
861 | 95 | authenticated = (response == "1234"); | ||
862 | 96 | q->sendAuthenticationComplete(); | ||
863 | 97 | } else if (mockMode == "full") { | ||
864 | 98 | handleRespond_full(response); | ||
865 | 99 | } | ||
866 | 100 | } | ||
867 | 101 | |||
868 | 102 | void GreeterPrivate::handleRespond_full(const QString &response) | ||
869 | 103 | { | ||
870 | 104 | Q_Q(Greeter); | ||
871 | 105 | |||
872 | 106 | if (authenticationUser == "no-response") | ||
873 | 107 | return; | ||
874 | 108 | else if (authenticationUser == "two-factor") { | ||
875 | 109 | if (!twoFactorDone) { | ||
876 | 110 | if (response == "password") { | ||
877 | 111 | twoFactorDone = true; | ||
878 | 112 | Q_EMIT q->showPrompt("otp", Greeter::PromptTypeQuestion); | ||
879 | 113 | } else { | ||
880 | 114 | authenticated = false; | ||
881 | 115 | q->sendAuthenticationComplete(); | ||
882 | 116 | } | ||
883 | 117 | } else { | ||
884 | 118 | authenticated = (response == "otp"); | ||
885 | 119 | q->sendAuthenticationComplete(); | ||
886 | 120 | } | ||
887 | 121 | return; | ||
888 | 122 | } | ||
889 | 123 | |||
890 | 124 | if (authenticationUser == "has-pin") { | ||
891 | 125 | authenticated = (response == "1234"); | ||
892 | 126 | } else { | ||
893 | 127 | authenticated = (response == "password"); | ||
894 | 128 | } | ||
895 | 129 | q->sendAuthenticationComplete(); | ||
896 | 130 | } | ||
897 | 131 | |||
898 | 132 | } | ||
899 | 133 | 0 | ||
900 | === removed file 'tests/mocks/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.h' | |||
901 | --- tests/mocks/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.h 2016-06-09 21:45:09 +0000 | |||
902 | +++ tests/mocks/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.h 1970-01-01 00:00:00 +0000 | |||
903 | @@ -1,54 +0,0 @@ | |||
904 | 1 | /* | ||
905 | 2 | * Copyright (C) 2014 Canonical, Ltd. | ||
906 | 3 | * | ||
907 | 4 | * This program is free software; you can redistribute it and/or modify | ||
908 | 5 | * it under the terms of the GNU General Public License as published by | ||
909 | 6 | * the Free Software Foundation; version 3. | ||
910 | 7 | * | ||
911 | 8 | * This program is distributed in the hope that it will be useful, | ||
912 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
913 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
914 | 11 | * GNU General Public License for more details. | ||
915 | 12 | * | ||
916 | 13 | * You should have received a copy of the GNU General Public License | ||
917 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
918 | 15 | */ | ||
919 | 16 | |||
920 | 17 | #ifndef UNITY_MOCK_GREETER_PRIVATE_H | ||
921 | 18 | #define UNITY_MOCK_GREETER_PRIVATE_H | ||
922 | 19 | |||
923 | 20 | #include <QtCore/QObject> | ||
924 | 21 | |||
925 | 22 | namespace QLightDM | ||
926 | 23 | { | ||
927 | 24 | class Greeter; | ||
928 | 25 | class GreeterImpl; | ||
929 | 26 | |||
930 | 27 | class GreeterPrivate | ||
931 | 28 | { | ||
932 | 29 | public: | ||
933 | 30 | explicit GreeterPrivate(Greeter* parent=0); | ||
934 | 31 | virtual ~GreeterPrivate() = default; | ||
935 | 32 | |||
936 | 33 | // These variables may not be used by all subclasses, that's no problem | ||
937 | 34 | bool authenticated; | ||
938 | 35 | QString authenticationUser; | ||
939 | 36 | bool twoFactorDone; | ||
940 | 37 | QString selectUserHint; | ||
941 | 38 | |||
942 | 39 | QString mockMode; | ||
943 | 40 | |||
944 | 41 | void handleAuthenticate(); | ||
945 | 42 | void handleRespond(const QString &response); | ||
946 | 43 | |||
947 | 44 | protected: | ||
948 | 45 | Greeter * const q_ptr; | ||
949 | 46 | |||
950 | 47 | private: | ||
951 | 48 | void handleAuthenticate_full(); | ||
952 | 49 | void handleRespond_full(const QString &response); | ||
953 | 50 | Q_DECLARE_PUBLIC(Greeter) | ||
954 | 51 | }; | ||
955 | 52 | } | ||
956 | 53 | |||
957 | 54 | #endif // UNITY_MOCK_GREETER_PRIVATE_H | ||
958 | 55 | 0 | ||
959 | === removed file 'tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.cpp' | |||
960 | --- tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.cpp 2016-11-28 10:19:39 +0000 | |||
961 | +++ tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.cpp 1970-01-01 00:00:00 +0000 | |||
962 | @@ -1,83 +0,0 @@ | |||
963 | 1 | /* | ||
964 | 2 | * Copyright (C) 2015 Canonical, Ltd. | ||
965 | 3 | * | ||
966 | 4 | * This program is free software; you can redistribute it and/or modify | ||
967 | 5 | * it under the terms of the GNU General Public License as published by | ||
968 | 6 | * the Free Software Foundation; version 3. | ||
969 | 7 | * | ||
970 | 8 | * This program is distributed in the hope that it will be useful, | ||
971 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
972 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
973 | 11 | * GNU General Public License for more details. | ||
974 | 12 | * | ||
975 | 13 | * You should have received a copy of the GNU General Public License | ||
976 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
977 | 15 | */ | ||
978 | 16 | |||
979 | 17 | #include "SessionsModel.h" | ||
980 | 18 | #include "SessionsModelPrivate.h" | ||
981 | 19 | #include <QDebug> | ||
982 | 20 | namespace QLightDM | ||
983 | 21 | { | ||
984 | 22 | |||
985 | 23 | SessionsModelPrivate::SessionsModelPrivate(SessionsModel* parent) | ||
986 | 24 | : testScenario("singleSession") | ||
987 | 25 | , q_ptr(parent) | ||
988 | 26 | , m_availableSessions( | ||
989 | 27 | { | ||
990 | 28 | {"ubuntu", "", "Ubuntu", ""}, | ||
991 | 29 | {"ubuntu-2d", "", "Ubuntu 2D", ""}, | ||
992 | 30 | {"gnome", "", "GNOME", ""}, | ||
993 | 31 | {"gnome-classic", "", "GNOME Classic", ""}, | ||
994 | 32 | {"gnome-flashback-compiz", "", "GNOME Flashback (Compiz)", ""}, | ||
995 | 33 | {"gnome-flashback-metacity", "", "GNOME Flashback (Metacity)", ""}, | ||
996 | 34 | {"gnome-wayland", "", "GNOME on Wayland", ""}, | ||
997 | 35 | {"plasma", "", "Plasma", ""}, | ||
998 | 36 | {"kde", "", "KDE" , ""}, | ||
999 | 37 | {"xterm", "", "Recovery Console", ""}, | ||
1000 | 38 | {"", "", "Unknown?", ""} | ||
1001 | 39 | }) | ||
1002 | 40 | { | ||
1003 | 41 | numSessions = numAvailableSessions(); | ||
1004 | 42 | resetEntries(); | ||
1005 | 43 | } | ||
1006 | 44 | |||
1007 | 45 | int SessionsModelPrivate::numAvailableSessions() const | ||
1008 | 46 | { | ||
1009 | 47 | return m_availableSessions.length(); | ||
1010 | 48 | } | ||
1011 | 49 | |||
1012 | 50 | void SessionsModelPrivate::resetEntries() | ||
1013 | 51 | { | ||
1014 | 52 | Q_Q(SessionsModel); | ||
1015 | 53 | |||
1016 | 54 | q->beginResetModel(); | ||
1017 | 55 | if (testScenario == "multipleSessions") { | ||
1018 | 56 | resetEntries_multipleSessions(numSessions); | ||
1019 | 57 | } else if (testScenario == "noSessions") { | ||
1020 | 58 | resetEntries_noSessions(); | ||
1021 | 59 | } else { | ||
1022 | 60 | resetEntries_singleSession(); | ||
1023 | 61 | } | ||
1024 | 62 | q->endResetModel(); | ||
1025 | 63 | } | ||
1026 | 64 | |||
1027 | 65 | void SessionsModelPrivate::resetEntries_multipleSessions(int numSessions) | ||
1028 | 66 | { | ||
1029 | 67 | sessionItems.clear(); | ||
1030 | 68 | for (int i = 0; i < numSessions; i++) { | ||
1031 | 69 | sessionItems.append(m_availableSessions.value(i)); | ||
1032 | 70 | } | ||
1033 | 71 | } | ||
1034 | 72 | |||
1035 | 73 | void SessionsModelPrivate::resetEntries_noSessions() | ||
1036 | 74 | { | ||
1037 | 75 | sessionItems = {}; | ||
1038 | 76 | } | ||
1039 | 77 | |||
1040 | 78 | void SessionsModelPrivate::resetEntries_singleSession() | ||
1041 | 79 | { | ||
1042 | 80 | sessionItems = {{"ubuntu", "", "Ubuntu", ""}}; | ||
1043 | 81 | } | ||
1044 | 82 | |||
1045 | 83 | } // namespace QLightDM | ||
1046 | 84 | 0 | ||
1047 | === removed file 'tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.h' | |||
1048 | --- tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.h 2016-07-13 20:24:24 +0000 | |||
1049 | +++ tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.h 1970-01-01 00:00:00 +0000 | |||
1050 | @@ -1,63 +0,0 @@ | |||
1051 | 1 | /* | ||
1052 | 2 | * Copyright (C) 2015 Canonical, Ltd. | ||
1053 | 3 | * | ||
1054 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1055 | 5 | * it under the terms of the GNU General Public License as published by | ||
1056 | 6 | * the Free Software Foundation; version 3. | ||
1057 | 7 | * | ||
1058 | 8 | * This program is distributed in the hope that it will be useful, | ||
1059 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1060 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1061 | 11 | * GNU General Public License for more details. | ||
1062 | 12 | * | ||
1063 | 13 | * You should have received a copy of the GNU General Public License | ||
1064 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1065 | 15 | * | ||
1066 | 16 | */ | ||
1067 | 17 | |||
1068 | 18 | #ifndef UNITY_MOCK_SESSIONSMODEL_PRIVATE_H | ||
1069 | 19 | #define UNITY_MOCK_SESSIONSMODEL_PRIVATE_H | ||
1070 | 20 | |||
1071 | 21 | #include <QtCore/QList> | ||
1072 | 22 | #include <QtCore/QString> | ||
1073 | 23 | |||
1074 | 24 | namespace QLightDM | ||
1075 | 25 | { | ||
1076 | 26 | class SessionsModel; | ||
1077 | 27 | |||
1078 | 28 | class SessionItem | ||
1079 | 29 | { | ||
1080 | 30 | public: | ||
1081 | 31 | QString key; | ||
1082 | 32 | QString type; // unused | ||
1083 | 33 | QString name; | ||
1084 | 34 | QString comment; // unused | ||
1085 | 35 | }; | ||
1086 | 36 | |||
1087 | 37 | class SessionsModelPrivate | ||
1088 | 38 | { | ||
1089 | 39 | public: | ||
1090 | 40 | explicit SessionsModelPrivate(SessionsModel* parent=0); | ||
1091 | 41 | virtual ~SessionsModelPrivate() = default; | ||
1092 | 42 | |||
1093 | 43 | int numAvailableSessions() const; | ||
1094 | 44 | |||
1095 | 45 | QList<SessionItem> sessionItems; | ||
1096 | 46 | int numSessions; | ||
1097 | 47 | QString testScenario; | ||
1098 | 48 | |||
1099 | 49 | void resetEntries(); | ||
1100 | 50 | protected: | ||
1101 | 51 | SessionsModel* const q_ptr; | ||
1102 | 52 | |||
1103 | 53 | private: | ||
1104 | 54 | const QList<SessionItem> m_availableSessions; | ||
1105 | 55 | void resetEntries_multipleSessions(int numSessions); | ||
1106 | 56 | void resetEntries_noSessions(); | ||
1107 | 57 | void resetEntries_singleSession(); | ||
1108 | 58 | Q_DECLARE_PUBLIC(SessionsModel) | ||
1109 | 59 | }; | ||
1110 | 60 | |||
1111 | 61 | } // namespace QLightDM | ||
1112 | 62 | |||
1113 | 63 | #endif // UNITY_MOCK_SESSIONSMODEL_PRIVATE_H | ||
1114 | 64 | 0 | ||
1115 | === removed file 'tests/mocks/LightDM/IntegratedLightDM/liblightdm/UsersModelPrivate.cpp' | |||
1116 | --- tests/mocks/LightDM/IntegratedLightDM/liblightdm/UsersModelPrivate.cpp 2016-11-28 10:19:39 +0000 | |||
1117 | +++ tests/mocks/LightDM/IntegratedLightDM/liblightdm/UsersModelPrivate.cpp 1970-01-01 00:00:00 +0000 | |||
1118 | @@ -1,124 +0,0 @@ | |||
1119 | 1 | /* | ||
1120 | 2 | * Copyright (C) 2014-2016 Canonical, Ltd. | ||
1121 | 3 | * | ||
1122 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1123 | 5 | * it under the terms of the GNU General Public License as published by | ||
1124 | 6 | * the Free Software Foundation; version 3. | ||
1125 | 7 | * | ||
1126 | 8 | * This program is distributed in the hope that it will be useful, | ||
1127 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1128 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1129 | 11 | * GNU General Public License for more details. | ||
1130 | 12 | * | ||
1131 | 13 | * You should have received a copy of the GNU General Public License | ||
1132 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1133 | 15 | */ | ||
1134 | 16 | |||
1135 | 17 | #include "UsersModelPrivate.h" | ||
1136 | 18 | #include "UsersModel.h" | ||
1137 | 19 | |||
1138 | 20 | #include <QDir> | ||
1139 | 21 | |||
1140 | 22 | namespace QLightDM | ||
1141 | 23 | { | ||
1142 | 24 | |||
1143 | 25 | UsersModelPrivate::UsersModelPrivate(UsersModel* parent) | ||
1144 | 26 | : mockMode("single") | ||
1145 | 27 | , q_ptr(parent) | ||
1146 | 28 | { | ||
1147 | 29 | char *envMockMode = getenv("LIBLIGHTDM_MOCK_MODE"); | ||
1148 | 30 | if (envMockMode) { | ||
1149 | 31 | mockMode = envMockMode; | ||
1150 | 32 | } | ||
1151 | 33 | resetEntries(); | ||
1152 | 34 | } | ||
1153 | 35 | |||
1154 | 36 | void UsersModelPrivate::resetEntries() | ||
1155 | 37 | { | ||
1156 | 38 | Q_Q(UsersModel); | ||
1157 | 39 | |||
1158 | 40 | q->beginResetModel(); | ||
1159 | 41 | |||
1160 | 42 | if (mockMode == "single") { | ||
1161 | 43 | resetEntries_single(); | ||
1162 | 44 | } else if (mockMode == "single-passphrase") { | ||
1163 | 45 | resetEntries_singlePassphrase(); | ||
1164 | 46 | } else if (mockMode == "single-pin") { | ||
1165 | 47 | resetEntries_singlePin(); | ||
1166 | 48 | } else if (mockMode == "full") { | ||
1167 | 49 | resetEntries_full(); | ||
1168 | 50 | } | ||
1169 | 51 | |||
1170 | 52 | // Assign uids in a loop, just to avoid having to muck with them when | ||
1171 | 53 | // adding or removing test users. | ||
1172 | 54 | for (int i = 0; i < entries.size(); i++) { | ||
1173 | 55 | entries[i].uid = i + 1; | ||
1174 | 56 | } | ||
1175 | 57 | |||
1176 | 58 | // Assign backgrounds | ||
1177 | 59 | QDir backgroundDir("/usr/share/backgrounds"); | ||
1178 | 60 | QStringList backgrounds = backgroundDir.entryList(QDir::Files); | ||
1179 | 61 | if (!backgrounds.empty()) { | ||
1180 | 62 | for (int i = 0; i < entries.size(); i++) { | ||
1181 | 63 | if (entries[i].background.isNull()) { | ||
1182 | 64 | entries[i].background = backgroundDir.filePath(backgrounds[i % backgrounds.size()]); | ||
1183 | 65 | } | ||
1184 | 66 | } | ||
1185 | 67 | } | ||
1186 | 68 | |||
1187 | 69 | q->endResetModel(); | ||
1188 | 70 | } | ||
1189 | 71 | |||
1190 | 72 | void UsersModelPrivate::resetEntries_single() | ||
1191 | 73 | { | ||
1192 | 74 | entries = | ||
1193 | 75 | { | ||
1194 | 76 | { "single", "Single User", 0, 0, false, false, "ubuntu", 0, 0 }, | ||
1195 | 77 | }; | ||
1196 | 78 | } | ||
1197 | 79 | |||
1198 | 80 | void UsersModelPrivate::resetEntries_singlePassphrase() | ||
1199 | 81 | { | ||
1200 | 82 | entries = | ||
1201 | 83 | { | ||
1202 | 84 | { "single", "Single User", 0, 0, false, false, "ubuntu", 0, 0 }, | ||
1203 | 85 | }; | ||
1204 | 86 | } | ||
1205 | 87 | |||
1206 | 88 | void UsersModelPrivate::resetEntries_singlePin() | ||
1207 | 89 | { | ||
1208 | 90 | entries = | ||
1209 | 91 | { | ||
1210 | 92 | { "has-pin", "Has PIN", 0, 0, false, false, "ubuntu", 0, 0 }, | ||
1211 | 93 | }; | ||
1212 | 94 | } | ||
1213 | 95 | |||
1214 | 96 | void UsersModelPrivate::resetEntries_full() | ||
1215 | 97 | { | ||
1216 | 98 | entries = | ||
1217 | 99 | { | ||
1218 | 100 | { "has-password", "Has Password", 0, 0, false, false, "ubuntu", 0, 0 }, | ||
1219 | 101 | { "has-pin", "Has PIN", 0, 0, false, false, "ubuntu", 0, 0 }, | ||
1220 | 102 | { "different-prompt", "Different Prompt", 0, 0, false, false, "ubuntu", 0, 0 }, | ||
1221 | 103 | { "no-password", "No Password", 0, 0, false, false, "ubuntu", 0, 0 }, | ||
1222 | 104 | { "auth-error", "Auth Error", 0, 0, false, false, "ubuntu", 0, 0 }, | ||
1223 | 105 | { "two-factor", "Two Factor", 0, 0, false, false, "ubuntu", 0, 0 }, | ||
1224 | 106 | { "info-prompt", "Info Prompt", 0, 0, false, false, "ubuntu", 0, 0 }, | ||
1225 | 107 | { "html-info-prompt", "HTML Info Prompt", 0, 0, false, false, "ubuntu", 0, 0 }, | ||
1226 | 108 | { "long-info-prompt", "Long Info Prompt", 0, 0, false, false, "ubuntu", 0, 0 }, | ||
1227 | 109 | { "wide-info-prompt", "Wide Info Prompt", 0, 0, false, false, "ubuntu", 0, 0 }, | ||
1228 | 110 | { "multi-info-prompt", "Multi Info Prompt", 0, 0, false, false, "ubuntu", 0, 0 }, | ||
1229 | 111 | { "long-name", "Long name (far far too long to fit, seriously this would never fit on the screen, you will never see this part of the name)", 0, 0, false, false, "ubuntu", 0, 0 }, | ||
1230 | 112 | { "color-background", "Color Background", "#E95420", 0, false, false, "ubuntu", 0, 0 }, | ||
1231 | 113 | // white and black are a bit redundant, but useful for manually testing if UI is still readable | ||
1232 | 114 | { "white-background", "White Background", "#ffffff", 0, false, false, "ubuntu", 0, 0 }, | ||
1233 | 115 | { "black-background", "Black Background", "#000000", 0, false, false, "ubuntu", 0, 0 }, | ||
1234 | 116 | { "no-background", "No Background", "", 0, false, false, "ubuntu", 0, 0 }, | ||
1235 | 117 | { "unicode", "가나다라마", 0, 0, false, false, "ubuntu", 0, 0 }, | ||
1236 | 118 | { "no-response", "No Response", 0, 0, false, false, "ubuntu", 0, 0 }, | ||
1237 | 119 | { "empty-name", "", 0, 0, false, false, "ubuntu", 0, 0 }, | ||
1238 | 120 | { "active", "Active Account", 0, 0, true, false, "ubuntu", 0, 0 }, | ||
1239 | 121 | }; | ||
1240 | 122 | } | ||
1241 | 123 | |||
1242 | 124 | } // namespace QLightDM | ||
1243 | 125 | 0 | ||
1244 | === removed file 'tests/mocks/LightDM/IntegratedLightDM/liblightdm/UsersModelPrivate.h' | |||
1245 | --- tests/mocks/LightDM/IntegratedLightDM/liblightdm/UsersModelPrivate.h 2016-05-24 22:11:21 +0000 | |||
1246 | +++ tests/mocks/LightDM/IntegratedLightDM/liblightdm/UsersModelPrivate.h 1970-01-01 00:00:00 +0000 | |||
1247 | @@ -1,64 +0,0 @@ | |||
1248 | 1 | /* | ||
1249 | 2 | * Copyright (C) 2014-2016 Canonical, Ltd. | ||
1250 | 3 | * | ||
1251 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1252 | 5 | * it under the terms of the GNU General Public License as published by | ||
1253 | 6 | * the Free Software Foundation; version 3. | ||
1254 | 7 | * | ||
1255 | 8 | * This program is distributed in the hope that it will be useful, | ||
1256 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1257 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1258 | 11 | * GNU General Public License for more details. | ||
1259 | 12 | * | ||
1260 | 13 | * You should have received a copy of the GNU General Public License | ||
1261 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1262 | 15 | */ | ||
1263 | 16 | |||
1264 | 17 | #ifndef UNITY_MOCK_USERSMODEL_PRIVATE_H | ||
1265 | 18 | #define UNITY_MOCK_USERSMODEL_PRIVATE_H | ||
1266 | 19 | |||
1267 | 20 | #include <QtCore/QList> | ||
1268 | 21 | #include <QtCore/QString> | ||
1269 | 22 | |||
1270 | 23 | namespace QLightDM | ||
1271 | 24 | { | ||
1272 | 25 | class UsersModel; | ||
1273 | 26 | |||
1274 | 27 | class Entry | ||
1275 | 28 | { | ||
1276 | 29 | public: | ||
1277 | 30 | QString username; | ||
1278 | 31 | QString real_name; | ||
1279 | 32 | QString background; | ||
1280 | 33 | QString layouts; | ||
1281 | 34 | bool is_active; | ||
1282 | 35 | bool has_messages; | ||
1283 | 36 | QString session; | ||
1284 | 37 | QString infographic; | ||
1285 | 38 | uid_t uid; | ||
1286 | 39 | }; | ||
1287 | 40 | |||
1288 | 41 | class UsersModelPrivate | ||
1289 | 42 | { | ||
1290 | 43 | public: | ||
1291 | 44 | explicit UsersModelPrivate(UsersModel *parent = 0); | ||
1292 | 45 | virtual ~UsersModelPrivate() = default; | ||
1293 | 46 | |||
1294 | 47 | QList<Entry> entries; | ||
1295 | 48 | QString mockMode; | ||
1296 | 49 | |||
1297 | 50 | void resetEntries(); | ||
1298 | 51 | protected: | ||
1299 | 52 | UsersModel * const q_ptr; | ||
1300 | 53 | |||
1301 | 54 | private: | ||
1302 | 55 | void resetEntries_single(); | ||
1303 | 56 | void resetEntries_singlePassphrase(); | ||
1304 | 57 | void resetEntries_singlePin(); | ||
1305 | 58 | void resetEntries_full(); | ||
1306 | 59 | Q_DECLARE_PUBLIC(UsersModel) | ||
1307 | 60 | }; | ||
1308 | 61 | |||
1309 | 62 | } | ||
1310 | 63 | |||
1311 | 64 | #endif // UNITY_MOCK_USERSMODEL_PRIVATE_H | ||
1312 | 65 | 0 | ||
1313 | === removed file 'tests/mocks/LightDM/IntegratedLightDM/plugin.cpp' | |||
1314 | --- tests/mocks/LightDM/IntegratedLightDM/plugin.cpp 2016-06-16 17:23:24 +0000 | |||
1315 | +++ tests/mocks/LightDM/IntegratedLightDM/plugin.cpp 1970-01-01 00:00:00 +0000 | |||
1316 | @@ -1,79 +0,0 @@ | |||
1317 | 1 | /* | ||
1318 | 2 | * Copyright (C) 2014, 2015 Canonical, Ltd. | ||
1319 | 3 | * | ||
1320 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1321 | 5 | * it under the terms of the GNU General Public License as published by | ||
1322 | 6 | * the Free Software Foundation; version 3. | ||
1323 | 7 | * | ||
1324 | 8 | * This program is distributed in the hope that it will be useful, | ||
1325 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1326 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1327 | 11 | * GNU General Public License for more details. | ||
1328 | 12 | * | ||
1329 | 13 | * You should have received a copy of the GNU General Public License | ||
1330 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1331 | 15 | */ | ||
1332 | 16 | |||
1333 | 17 | #include "plugin.h" | ||
1334 | 18 | #include <DBusGreeter.h> | ||
1335 | 19 | #include <DBusGreeterList.h> | ||
1336 | 20 | #include "MockGreeter.h" | ||
1337 | 21 | #include "MockSessionsModel.h" | ||
1338 | 22 | #include "MockUsersModel.h" | ||
1339 | 23 | #include <QLightDM/SessionsModel> | ||
1340 | 24 | #include "ColorTheme.h" | ||
1341 | 25 | #include "UserMetrics.h" | ||
1342 | 26 | #include <QLightDM/UsersModel> | ||
1343 | 27 | |||
1344 | 28 | #include <QAbstractItemModel> | ||
1345 | 29 | #include <QDBusConnection> | ||
1346 | 30 | #include <QtQml/qqml.h> | ||
1347 | 31 | |||
1348 | 32 | static QObject *greeter_provider(QQmlEngine *engine, QJSEngine *scriptEngine) | ||
1349 | 33 | { | ||
1350 | 34 | Q_UNUSED(engine) | ||
1351 | 35 | Q_UNUSED(scriptEngine) | ||
1352 | 36 | |||
1353 | 37 | MockGreeter *greeter = new MockGreeter; | ||
1354 | 38 | new DBusGreeter(greeter, "/"); | ||
1355 | 39 | new DBusGreeterList(greeter, "/list"); | ||
1356 | 40 | |||
1357 | 41 | return greeter; | ||
1358 | 42 | } | ||
1359 | 43 | |||
1360 | 44 | static QObject *sessions_provider(QQmlEngine *engine, QJSEngine *scriptEngine) | ||
1361 | 45 | { | ||
1362 | 46 | Q_UNUSED(engine) | ||
1363 | 47 | Q_UNUSED(scriptEngine) | ||
1364 | 48 | return new MockSessionsModel; | ||
1365 | 49 | } | ||
1366 | 50 | |||
1367 | 51 | static QObject *users_provider(QQmlEngine *engine, QJSEngine *scriptEngine) | ||
1368 | 52 | { | ||
1369 | 53 | Q_UNUSED(engine) | ||
1370 | 54 | Q_UNUSED(scriptEngine) | ||
1371 | 55 | return new MockUsersModel; | ||
1372 | 56 | } | ||
1373 | 57 | |||
1374 | 58 | static QObject *infographic_provider(QQmlEngine *engine, QJSEngine *scriptEngine) | ||
1375 | 59 | { | ||
1376 | 60 | Q_UNUSED(engine) | ||
1377 | 61 | Q_UNUSED(scriptEngine) | ||
1378 | 62 | return UserMetricsOutput::UserMetrics::getInstance(); | ||
1379 | 63 | } | ||
1380 | 64 | |||
1381 | 65 | void LightDMPlugin::registerTypes(const char *uri) | ||
1382 | 66 | { | ||
1383 | 67 | qmlRegisterType<QAbstractItemModel>(); | ||
1384 | 68 | qmlRegisterType<UserMetricsOutput::ColorTheme>(); | ||
1385 | 69 | |||
1386 | 70 | Q_ASSERT(uri == QLatin1String("LightDM.IntegratedLightDM")); | ||
1387 | 71 | qRegisterMetaType<QLightDM::Greeter::MessageType>("QLightDM::Greeter::MessageType"); | ||
1388 | 72 | qRegisterMetaType<QLightDM::Greeter::PromptType>("QLightDM::Greeter::PromptType"); | ||
1389 | 73 | qmlRegisterSingletonType<MockGreeter>(uri, 0, 1, "Greeter", greeter_provider); | ||
1390 | 74 | qmlRegisterSingletonType<MockSessionsModel>(uri, 0, 1, "Sessions", sessions_provider); | ||
1391 | 75 | qmlRegisterUncreatableType<QLightDM::SessionsModel>(uri, 0, 1, "SessionRoles", "Type is not instantiable"); | ||
1392 | 76 | qmlRegisterSingletonType<MockUsersModel>(uri, 0, 1, "Users", users_provider); | ||
1393 | 77 | qmlRegisterUncreatableType<QLightDM::UsersModel>(uri, 0, 1, "UserRoles", "Type is not instantiable"); | ||
1394 | 78 | qmlRegisterSingletonType<UserMetricsOutput::UserMetrics>(uri, 0, 1, "Infographic", infographic_provider); | ||
1395 | 79 | } | ||
1396 | 80 | 0 | ||
1397 | === removed file 'tests/mocks/LightDM/IntegratedLightDM/plugin.h' | |||
1398 | --- tests/mocks/LightDM/IntegratedLightDM/plugin.h 2015-09-25 13:01:00 +0000 | |||
1399 | +++ tests/mocks/LightDM/IntegratedLightDM/plugin.h 1970-01-01 00:00:00 +0000 | |||
1400 | @@ -1,32 +0,0 @@ | |||
1401 | 1 | /* | ||
1402 | 2 | * Copyright (C) 2014, 2015 Canonical, Ltd. | ||
1403 | 3 | * | ||
1404 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1405 | 5 | * it under the terms of the GNU General Public License as published by | ||
1406 | 6 | * the Free Software Foundation; version 3. | ||
1407 | 7 | * | ||
1408 | 8 | * This program is distributed in the hope that it will be useful, | ||
1409 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1410 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1411 | 11 | * GNU General Public License for more details. | ||
1412 | 12 | * | ||
1413 | 13 | * You should have received a copy of the GNU General Public License | ||
1414 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1415 | 15 | */ | ||
1416 | 16 | |||
1417 | 17 | #ifndef MOCK_LIGHTDM_PLUGIN_H | ||
1418 | 18 | #define MOCK_LIGHTDM_PLUGIN_H | ||
1419 | 19 | |||
1420 | 20 | #include <QtQml/QQmlEngine> | ||
1421 | 21 | #include <QtQml/QQmlExtensionPlugin> | ||
1422 | 22 | |||
1423 | 23 | class LightDMPlugin : public QQmlExtensionPlugin | ||
1424 | 24 | { | ||
1425 | 25 | Q_OBJECT | ||
1426 | 26 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") | ||
1427 | 27 | |||
1428 | 28 | public: | ||
1429 | 29 | void registerTypes(const char *uri) override; | ||
1430 | 30 | }; | ||
1431 | 31 | |||
1432 | 32 | #endif | ||
1433 | 33 | 0 | ||
1434 | === removed file 'tests/mocks/LightDM/IntegratedLightDM/qmldir' | |||
1435 | --- tests/mocks/LightDM/IntegratedLightDM/qmldir 2015-09-25 13:01:00 +0000 | |||
1436 | +++ tests/mocks/LightDM/IntegratedLightDM/qmldir 1970-01-01 00:00:00 +0000 | |||
1437 | @@ -1,2 +0,0 @@ | |||
1438 | 1 | module LightDM.IntegratedLightDM | ||
1439 | 2 | plugin MockLightDM-qml | ||
1440 | 3 | 0 | ||
1441 | === added directory 'tests/mocks/LightDMController' | |||
1442 | === added file 'tests/mocks/LightDMController/CMakeLists.txt' | |||
1443 | --- tests/mocks/LightDMController/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
1444 | +++ tests/mocks/LightDMController/CMakeLists.txt 2017-01-17 15:40:09 +0000 | |||
1445 | @@ -0,0 +1,15 @@ | |||
1446 | 1 | add_library(LightDMController MODULE | ||
1447 | 2 | plugin.cpp | ||
1448 | 3 | ) | ||
1449 | 4 | |||
1450 | 5 | target_include_directories(LightDMController PUBLIC | ||
1451 | 6 | ${CMAKE_SOURCE_DIR}/tests/mocks/liblightdm/ | ||
1452 | 7 | ) | ||
1453 | 8 | |||
1454 | 9 | target_link_libraries(LightDMController | ||
1455 | 10 | MockLightDM | ||
1456 | 11 | ) | ||
1457 | 12 | |||
1458 | 13 | qt5_use_modules(LightDMController Qml) | ||
1459 | 14 | |||
1460 | 15 | add_unity8_mock(LightDMController 0.1 LightDMController TARGETS LightDMController) | ||
1461 | 0 | 16 | ||
1462 | === added file 'tests/mocks/LightDMController/plugin.cpp' | |||
1463 | --- tests/mocks/LightDMController/plugin.cpp 1970-01-01 00:00:00 +0000 | |||
1464 | +++ tests/mocks/LightDMController/plugin.cpp 2017-01-17 15:40:09 +0000 | |||
1465 | @@ -0,0 +1,35 @@ | |||
1466 | 1 | /* | ||
1467 | 2 | * Copyright (C) 2017 Canonical, Ltd. | ||
1468 | 3 | * | ||
1469 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1470 | 5 | * it under the terms of the GNU General Public License as published by | ||
1471 | 6 | * the Free Software Foundation; version 3. | ||
1472 | 7 | * | ||
1473 | 8 | * This program is distributed in the hope that it will be useful, | ||
1474 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1475 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1476 | 11 | * GNU General Public License for more details. | ||
1477 | 12 | * | ||
1478 | 13 | * You should have received a copy of the GNU General Public License | ||
1479 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1480 | 15 | */ | ||
1481 | 16 | |||
1482 | 17 | #include "plugin.h" | ||
1483 | 18 | |||
1484 | 19 | #include "MockController.h" | ||
1485 | 20 | |||
1486 | 21 | #include <QtQml/qqml.h> | ||
1487 | 22 | |||
1488 | 23 | static QObject *mock_provider(QQmlEngine *engine, QJSEngine *scriptEngine) | ||
1489 | 24 | { | ||
1490 | 25 | Q_UNUSED(scriptEngine) | ||
1491 | 26 | auto controller = QLightDM::MockController::instance(); | ||
1492 | 27 | engine->setObjectOwnership(controller, QQmlEngine::CppOwnership); | ||
1493 | 28 | return controller; | ||
1494 | 29 | } | ||
1495 | 30 | |||
1496 | 31 | void LightDMControllerPlugin::registerTypes(const char *uri) | ||
1497 | 32 | { | ||
1498 | 33 | Q_ASSERT(uri == QLatin1String("LightDMController")); | ||
1499 | 34 | qmlRegisterSingletonType<QLightDM::MockController>(uri, 0, 1, "LightDMController", mock_provider); | ||
1500 | 35 | } | ||
1501 | 0 | 36 | ||
1502 | === added file 'tests/mocks/LightDMController/plugin.h' | |||
1503 | --- tests/mocks/LightDMController/plugin.h 1970-01-01 00:00:00 +0000 | |||
1504 | +++ tests/mocks/LightDMController/plugin.h 2017-01-17 15:40:09 +0000 | |||
1505 | @@ -0,0 +1,29 @@ | |||
1506 | 1 | /* | ||
1507 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
1508 | 3 | * | ||
1509 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1510 | 5 | * it under the terms of the GNU General Public License as published by | ||
1511 | 6 | * the Free Software Foundation; version 3. | ||
1512 | 7 | * | ||
1513 | 8 | * This program is distributed in the hope that it will be useful, | ||
1514 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1515 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1516 | 11 | * GNU General Public License for more details. | ||
1517 | 12 | * | ||
1518 | 13 | * You should have received a copy of the GNU General Public License | ||
1519 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1520 | 15 | */ | ||
1521 | 16 | |||
1522 | 17 | #pragma once | ||
1523 | 18 | |||
1524 | 19 | #include <QQmlEngine> | ||
1525 | 20 | #include <QQmlExtensionPlugin> | ||
1526 | 21 | |||
1527 | 22 | class LightDMControllerPlugin : public QQmlExtensionPlugin | ||
1528 | 23 | { | ||
1529 | 24 | Q_OBJECT | ||
1530 | 25 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") | ||
1531 | 26 | |||
1532 | 27 | public: | ||
1533 | 28 | void registerTypes(const char *uri) override; | ||
1534 | 29 | }; | ||
1535 | 0 | 30 | ||
1536 | === added file 'tests/mocks/LightDMController/qmldir' | |||
1537 | --- tests/mocks/LightDMController/qmldir 1970-01-01 00:00:00 +0000 | |||
1538 | +++ tests/mocks/LightDMController/qmldir 2017-01-17 15:40:09 +0000 | |||
1539 | @@ -0,0 +1,2 @@ | |||
1540 | 1 | module LightDMController | ||
1541 | 2 | plugin LightDMController | ||
1542 | 0 | 3 | ||
1543 | === renamed directory 'tests/mocks/LightDM/IntegratedLightDM/liblightdm' => 'tests/mocks/liblightdm' | |||
1544 | === modified file 'tests/mocks/liblightdm/CMakeLists.txt' | |||
1545 | --- tests/mocks/LightDM/IntegratedLightDM/liblightdm/CMakeLists.txt 2016-12-06 20:16:56 +0000 | |||
1546 | +++ tests/mocks/liblightdm/CMakeLists.txt 2017-01-17 15:40:09 +0000 | |||
1547 | @@ -1,21 +1,18 @@ | |||
1556 | 1 | set(LibLightDM_SOURCES | 1 | set(MockLightDM_SOURCES |
1557 | 2 | Greeter.cpp | 2 | MockController.cpp |
1558 | 3 | SessionsModel.cpp | 3 | MockGreeter.cpp |
1559 | 4 | UsersModel.cpp | 4 | MockSessionsModel.cpp |
1560 | 5 | GreeterPrivate.cpp | 5 | MockUsersModel.cpp |
1553 | 6 | SessionsModelPrivate.cpp | ||
1554 | 7 | UsersModelPrivate.cpp | ||
1555 | 8 | ${CMAKE_SOURCE_DIR}/plugins/Utils/qvariantlistmodel.cpp | ||
1561 | 9 | ) | 6 | ) |
1562 | 10 | 7 | ||
1564 | 11 | add_library(MockLightDM SHARED ${LibLightDM_SOURCES}) | 8 | add_library(MockLightDM SHARED ${MockLightDM_SOURCES}) |
1565 | 12 | 9 | ||
1567 | 13 | qt5_use_modules(MockLightDM Gui) | 10 | qt5_use_modules(MockLightDM DBus Gui) |
1568 | 14 | 11 | ||
1569 | 15 | set_target_properties(MockLightDM PROPERTIES | 12 | set_target_properties(MockLightDM PROPERTIES |
1570 | 16 | OUTPUT_NAME lightdm-qt5-3 | 13 | OUTPUT_NAME lightdm-qt5-3 |
1571 | 17 | SOVERSION 0) | 14 | SOVERSION 0) |
1572 | 18 | 15 | ||
1573 | 19 | install(TARGETS MockLightDM | 16 | install(TARGETS MockLightDM |
1575 | 20 | DESTINATION ${SHELL_INSTALL_QML}/mocks/LightDM/IntegratedLightDM/liblightdm | 17 | DESTINATION ${SHELL_INSTALL_QML}/mocks/liblightdm |
1576 | 21 | ) | 18 | ) |
1577 | 22 | 19 | ||
1578 | === added file 'tests/mocks/liblightdm/MockController.cpp' | |||
1579 | --- tests/mocks/liblightdm/MockController.cpp 1970-01-01 00:00:00 +0000 | |||
1580 | +++ tests/mocks/liblightdm/MockController.cpp 2017-01-17 15:40:09 +0000 | |||
1581 | @@ -0,0 +1,124 @@ | |||
1582 | 1 | /* | ||
1583 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
1584 | 3 | * | ||
1585 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1586 | 5 | * it under the terms of the GNU General Public License as published by | ||
1587 | 6 | * the Free Software Foundation; version 3. | ||
1588 | 7 | * | ||
1589 | 8 | * This program is distributed in the hope that it will be useful, | ||
1590 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1591 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1592 | 11 | * GNU General Public License for more details. | ||
1593 | 12 | * | ||
1594 | 13 | * You should have received a copy of the GNU General Public License | ||
1595 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1596 | 15 | */ | ||
1597 | 16 | |||
1598 | 17 | #include "MockController.h" | ||
1599 | 18 | |||
1600 | 19 | static QLightDM::MockController *m_instance = nullptr; | ||
1601 | 20 | |||
1602 | 21 | namespace QLightDM | ||
1603 | 22 | { | ||
1604 | 23 | |||
1605 | 24 | MockController::MockController(QObject *parent) | ||
1606 | 25 | : QObject(parent) | ||
1607 | 26 | , m_fullSessions( | ||
1608 | 27 | { | ||
1609 | 28 | {"ubuntu", "Ubuntu"}, | ||
1610 | 29 | {"ubuntu-2d", "Ubuntu 2D"}, | ||
1611 | 30 | {"gnome", "GNOME"}, | ||
1612 | 31 | {"gnome-classic", "GNOME Classic"}, | ||
1613 | 32 | {"gnome-flashback-compiz", "GNOME Flashback (Compiz)"}, | ||
1614 | 33 | {"gnome-flashback-metacity", "GNOME Flashback (Metacity)"}, | ||
1615 | 34 | {"gnome-wayland", "GNOME on Wayland"}, | ||
1616 | 35 | {"plasma", "Plasma"}, | ||
1617 | 36 | {"kde", "KDE" }, | ||
1618 | 37 | {"xterm", "Recovery Console"}, | ||
1619 | 38 | {"", "Unknown?"} | ||
1620 | 39 | }) | ||
1621 | 40 | { | ||
1622 | 41 | m_userMode = qgetenv("LIBLIGHTDM_MOCK_MODE"); | ||
1623 | 42 | if (m_userMode.isEmpty()) { | ||
1624 | 43 | m_userMode = "full"; | ||
1625 | 44 | } | ||
1626 | 45 | m_sessionMode = "full"; | ||
1627 | 46 | m_numSessions = numFullSessions(); | ||
1628 | 47 | } | ||
1629 | 48 | |||
1630 | 49 | MockController::~MockController() | ||
1631 | 50 | { | ||
1632 | 51 | m_instance = nullptr; | ||
1633 | 52 | } | ||
1634 | 53 | |||
1635 | 54 | MockController *MockController::instance() | ||
1636 | 55 | { | ||
1637 | 56 | if (!m_instance) { | ||
1638 | 57 | m_instance = new MockController; | ||
1639 | 58 | } | ||
1640 | 59 | return m_instance; | ||
1641 | 60 | } | ||
1642 | 61 | |||
1643 | 62 | QString MockController::selectUserHint() const | ||
1644 | 63 | { | ||
1645 | 64 | return m_selectUserHint; | ||
1646 | 65 | } | ||
1647 | 66 | |||
1648 | 67 | void MockController::setSelectUserHint(const QString &selectUserHint) | ||
1649 | 68 | { | ||
1650 | 69 | if (m_selectUserHint != selectUserHint) { | ||
1651 | 70 | m_selectUserHint = selectUserHint; | ||
1652 | 71 | Q_EMIT selectUserHintChanged(); | ||
1653 | 72 | } | ||
1654 | 73 | } | ||
1655 | 74 | |||
1656 | 75 | QString MockController::userMode() const | ||
1657 | 76 | { | ||
1658 | 77 | return m_userMode; | ||
1659 | 78 | } | ||
1660 | 79 | |||
1661 | 80 | void MockController::setUserMode(const QString &userMode) | ||
1662 | 81 | { | ||
1663 | 82 | if (m_userMode != userMode) { | ||
1664 | 83 | m_userMode = userMode; | ||
1665 | 84 | Q_EMIT userModeChanged(); | ||
1666 | 85 | } | ||
1667 | 86 | } | ||
1668 | 87 | |||
1669 | 88 | QString MockController::sessionMode() const | ||
1670 | 89 | { | ||
1671 | 90 | return m_sessionMode; | ||
1672 | 91 | } | ||
1673 | 92 | |||
1674 | 93 | void MockController::setSessionMode(const QString &sessionMode) | ||
1675 | 94 | { | ||
1676 | 95 | if (m_sessionMode != sessionMode) { | ||
1677 | 96 | m_sessionMode = sessionMode; | ||
1678 | 97 | Q_EMIT sessionModeChanged(); | ||
1679 | 98 | } | ||
1680 | 99 | } | ||
1681 | 100 | |||
1682 | 101 | const QList<MockController::SessionItem> &MockController::fullSessionItems() const | ||
1683 | 102 | { | ||
1684 | 103 | return m_fullSessions; | ||
1685 | 104 | } | ||
1686 | 105 | |||
1687 | 106 | int MockController::numFullSessions() const | ||
1688 | 107 | { | ||
1689 | 108 | return m_fullSessions.size(); | ||
1690 | 109 | } | ||
1691 | 110 | |||
1692 | 111 | int MockController::numSessions() const | ||
1693 | 112 | { | ||
1694 | 113 | return m_numSessions; | ||
1695 | 114 | } | ||
1696 | 115 | |||
1697 | 116 | void MockController::setNumSessions(int numSessions) | ||
1698 | 117 | { | ||
1699 | 118 | if (m_numSessions != numSessions) { | ||
1700 | 119 | m_numSessions = numSessions; | ||
1701 | 120 | Q_EMIT numSessionsChanged(); | ||
1702 | 121 | } | ||
1703 | 122 | } | ||
1704 | 123 | |||
1705 | 124 | } | ||
1706 | 0 | 125 | ||
1707 | === added file 'tests/mocks/liblightdm/MockController.h' | |||
1708 | --- tests/mocks/liblightdm/MockController.h 1970-01-01 00:00:00 +0000 | |||
1709 | +++ tests/mocks/liblightdm/MockController.h 2017-01-17 15:40:09 +0000 | |||
1710 | @@ -0,0 +1,80 @@ | |||
1711 | 1 | /* | ||
1712 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
1713 | 3 | * | ||
1714 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1715 | 5 | * it under the terms of the GNU General Public License as published by | ||
1716 | 6 | * the Free Software Foundation; version 3. | ||
1717 | 7 | * | ||
1718 | 8 | * This program is distributed in the hope that it will be useful, | ||
1719 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1720 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1721 | 11 | * GNU General Public License for more details. | ||
1722 | 12 | * | ||
1723 | 13 | * You should have received a copy of the GNU General Public License | ||
1724 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1725 | 15 | */ | ||
1726 | 16 | |||
1727 | 17 | #pragma once | ||
1728 | 18 | |||
1729 | 19 | #include <QObject> | ||
1730 | 20 | #include <QString> | ||
1731 | 21 | |||
1732 | 22 | |||
1733 | 23 | namespace QLightDM | ||
1734 | 24 | { | ||
1735 | 25 | class Q_DECL_EXPORT MockController : public QObject | ||
1736 | 26 | { | ||
1737 | 27 | Q_OBJECT | ||
1738 | 28 | |||
1739 | 29 | Q_PROPERTY(QString selectUserHint READ selectUserHint WRITE setSelectUserHint NOTIFY selectUserHintChanged) | ||
1740 | 30 | |||
1741 | 31 | // single, single-pin, single-passphrase, full | ||
1742 | 32 | Q_PROPERTY(QString userMode READ userMode WRITE setUserMode NOTIFY userModeChanged) | ||
1743 | 33 | |||
1744 | 34 | // single, none, full | ||
1745 | 35 | Q_PROPERTY(QString sessionMode READ sessionMode WRITE setSessionMode NOTIFY sessionModeChanged) | ||
1746 | 36 | |||
1747 | 37 | Q_PROPERTY(int numAvailableSessions READ numFullSessions CONSTANT) | ||
1748 | 38 | Q_PROPERTY(int numSessions READ numSessions WRITE setNumSessions NOTIFY numSessionsChanged) | ||
1749 | 39 | |||
1750 | 40 | public: | ||
1751 | 41 | static MockController *instance(); | ||
1752 | 42 | virtual ~MockController(); | ||
1753 | 43 | |||
1754 | 44 | QString selectUserHint() const; | ||
1755 | 45 | void setSelectUserHint(const QString &selectUserHint); | ||
1756 | 46 | |||
1757 | 47 | QString userMode() const; | ||
1758 | 48 | void setUserMode(const QString &userMode); | ||
1759 | 49 | |||
1760 | 50 | QString sessionMode() const; | ||
1761 | 51 | void setSessionMode(const QString &sessionMode); | ||
1762 | 52 | |||
1763 | 53 | class SessionItem | ||
1764 | 54 | { | ||
1765 | 55 | public: | ||
1766 | 56 | QString key; | ||
1767 | 57 | QString name; | ||
1768 | 58 | }; | ||
1769 | 59 | int numFullSessions() const; | ||
1770 | 60 | const QList<SessionItem> &fullSessionItems() const; | ||
1771 | 61 | |||
1772 | 62 | int numSessions() const; | ||
1773 | 63 | void setNumSessions(int numSessions); | ||
1774 | 64 | |||
1775 | 65 | Q_SIGNALS: | ||
1776 | 66 | void selectUserHintChanged(); | ||
1777 | 67 | void userModeChanged(); | ||
1778 | 68 | void sessionModeChanged(); | ||
1779 | 69 | void numSessionsChanged(); | ||
1780 | 70 | |||
1781 | 71 | private: | ||
1782 | 72 | explicit MockController(QObject* parent=0); | ||
1783 | 73 | |||
1784 | 74 | QString m_selectUserHint; | ||
1785 | 75 | QString m_userMode; | ||
1786 | 76 | QString m_sessionMode; | ||
1787 | 77 | QList<SessionItem> m_fullSessions; | ||
1788 | 78 | int m_numSessions; | ||
1789 | 79 | }; | ||
1790 | 80 | } | ||
1791 | 0 | 81 | ||
1792 | === renamed file 'tests/mocks/LightDM/IntegratedLightDM/liblightdm/Greeter.cpp' => 'tests/mocks/liblightdm/MockGreeter.cpp' | |||
1793 | --- tests/mocks/LightDM/IntegratedLightDM/liblightdm/Greeter.cpp 2016-12-23 11:04:53 +0000 | |||
1794 | +++ tests/mocks/liblightdm/MockGreeter.cpp 2017-01-17 15:40:09 +0000 | |||
1795 | @@ -1,5 +1,5 @@ | |||
1796 | 1 | /* | 1 | /* |
1798 | 2 | * Copyright (C) 2014 Canonical, Ltd. | 2 | * Copyright (C) 2014-2016 Canonical, Ltd. |
1799 | 3 | * | 3 | * |
1800 | 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 |
1801 | 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 |
1802 | @@ -14,27 +14,38 @@ | |||
1803 | 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/>. |
1804 | 15 | */ | 15 | */ |
1805 | 16 | 16 | ||
1809 | 17 | #include "Greeter.h" | 17 | #include "MockController.h" |
1810 | 18 | #include "GreeterPrivate.h" | 18 | #include "MockGreeter.h" |
1811 | 19 | #include <QtCore/QCoreApplication> | 19 | #include <QDBusInterface> |
1812 | 20 | #include <QDBusPendingCall> | ||
1813 | 20 | #include <QTimer> | 21 | #include <QTimer> |
1814 | 21 | 22 | ||
1815 | 22 | namespace QLightDM | 23 | namespace QLightDM |
1816 | 23 | { | 24 | { |
1817 | 24 | 25 | ||
1818 | 26 | class GreeterPrivate | ||
1819 | 27 | { | ||
1820 | 28 | public: | ||
1821 | 29 | bool authenticated = false; | ||
1822 | 30 | QString authenticationUser; | ||
1823 | 31 | bool twoFactorDone = false; | ||
1824 | 32 | }; | ||
1825 | 33 | |||
1826 | 25 | Greeter::Greeter(QObject *parent) | 34 | Greeter::Greeter(QObject *parent) |
1829 | 26 | : QObject(parent), | 35 | : QObject(parent) |
1830 | 27 | d_ptr(new GreeterPrivate(this)) | 36 | , d_ptr(new GreeterPrivate) |
1831 | 28 | { | 37 | { |
1832 | 29 | } | 38 | } |
1833 | 30 | 39 | ||
1834 | 31 | Greeter::~Greeter() | 40 | Greeter::~Greeter() |
1835 | 32 | { | 41 | { |
1836 | 42 | delete d_ptr; | ||
1837 | 33 | } | 43 | } |
1838 | 34 | 44 | ||
1839 | 35 | QString Greeter::authenticationUser() const | 45 | QString Greeter::authenticationUser() const |
1840 | 36 | { | 46 | { |
1841 | 37 | Q_D(const Greeter); | 47 | Q_D(const Greeter); |
1842 | 48 | |||
1843 | 38 | return d->authenticationUser; | 49 | return d->authenticationUser; |
1844 | 39 | } | 50 | } |
1845 | 40 | 51 | ||
1846 | @@ -71,14 +82,7 @@ | |||
1847 | 71 | 82 | ||
1848 | 72 | QString Greeter::selectUserHint() const | 83 | QString Greeter::selectUserHint() const |
1849 | 73 | { | 84 | { |
1858 | 74 | Q_D(const Greeter); | 85 | return MockController::instance()->selectUserHint(); |
1851 | 75 | return d->selectUserHint; | ||
1852 | 76 | } | ||
1853 | 77 | |||
1854 | 78 | void Greeter::setSelectUserHint(const QString &selectUserHint) | ||
1855 | 79 | { | ||
1856 | 80 | Q_D(Greeter); | ||
1857 | 81 | d->selectUserHint = selectUserHint; | ||
1859 | 82 | } | 86 | } |
1860 | 83 | 87 | ||
1861 | 84 | bool Greeter::selectGuestHint() const | 88 | bool Greeter::selectGuestHint() const |
1862 | @@ -114,6 +118,7 @@ | |||
1863 | 114 | bool Greeter::isAuthenticated() const | 118 | bool Greeter::isAuthenticated() const |
1864 | 115 | { | 119 | { |
1865 | 116 | Q_D(const Greeter); | 120 | Q_D(const Greeter); |
1866 | 121 | |||
1867 | 117 | return d->authenticated; | 122 | return d->authenticated; |
1868 | 118 | } | 123 | } |
1869 | 119 | 124 | ||
1870 | @@ -129,13 +134,42 @@ | |||
1871 | 129 | d->authenticated = false; | 134 | d->authenticated = false; |
1872 | 130 | d->authenticationUser = username; | 135 | d->authenticationUser = username; |
1873 | 131 | d->twoFactorDone = false; | 136 | d->twoFactorDone = false; |
1875 | 132 | QTimer::singleShot(0, this, &Greeter::delayedAuthentication); | 137 | QTimer::singleShot(0, this, &Greeter::handleAuthenticate); |
1876 | 133 | } | 138 | } |
1877 | 134 | 139 | ||
1879 | 135 | void Greeter::delayedAuthentication() | 140 | void Greeter::handleAuthenticate() |
1880 | 136 | { | 141 | { |
1881 | 137 | Q_D(Greeter); | 142 | Q_D(Greeter); |
1883 | 138 | d->handleAuthenticate(); | 143 | |
1884 | 144 | // Send out any messages we need to | ||
1885 | 145 | if (d->authenticationUser == "info-prompt") | ||
1886 | 146 | Q_EMIT showMessage("Welcome to Unity Greeter", Greeter::MessageTypeInfo); | ||
1887 | 147 | else if (d->authenticationUser == "wide-info-prompt") | ||
1888 | 148 | Q_EMIT showMessage("Welcome to Unity Greeter, the greeteriest greeter that ever did appear in these fine lands", Greeter::MessageTypeInfo); | ||
1889 | 149 | else if (d->authenticationUser == "html-info-prompt") | ||
1890 | 150 | Q_EMIT showMessage("<b>&</b>", Greeter::MessageTypeInfo); | ||
1891 | 151 | else if (d->authenticationUser == "long-info-prompt") | ||
1892 | 152 | Q_EMIT showMessage("Welcome to Unity Greeter\n\nWe like to annoy you with super ridiculously long messages.\nLike this one\n\nThis is the last line of a multiple line message.", Greeter::MessageTypeInfo); | ||
1893 | 153 | else if (d->authenticationUser == "multi-info-prompt") { | ||
1894 | 154 | Q_EMIT showMessage("Welcome to Unity Greeter", Greeter::MessageTypeInfo); | ||
1895 | 155 | Q_EMIT showMessage("This is an error", Greeter::MessageTypeError); | ||
1896 | 156 | Q_EMIT showMessage("You should have seen three messages", Greeter::MessageTypeInfo); | ||
1897 | 157 | } | ||
1898 | 158 | |||
1899 | 159 | // OK, now actually do the prompt | ||
1900 | 160 | if (d->authenticationUser == "no-password") { | ||
1901 | 161 | d->authenticated = true; | ||
1902 | 162 | Q_EMIT authenticationComplete(); | ||
1903 | 163 | } else if (d->authenticationUser == "has-pin"){ | ||
1904 | 164 | Q_EMIT showPrompt("Password: ", Greeter::PromptTypeSecret); | ||
1905 | 165 | } else if (d->authenticationUser == "auth-error") { | ||
1906 | 166 | d->authenticated = false; | ||
1907 | 167 | Q_EMIT authenticationComplete(); | ||
1908 | 168 | } else if (d->authenticationUser == "different-prompt") { | ||
1909 | 169 | Q_EMIT showPrompt("Secret word: ", Greeter::PromptTypeSecret); | ||
1910 | 170 | } else { | ||
1911 | 171 | Q_EMIT showPrompt("Password: ", Greeter::PromptTypeSecret); | ||
1912 | 172 | } | ||
1913 | 139 | } | 173 | } |
1914 | 140 | 174 | ||
1915 | 141 | void Greeter::authenticateAsGuest() | 175 | void Greeter::authenticateAsGuest() |
1916 | @@ -161,6 +195,16 @@ | |||
1917 | 161 | bool Greeter::startSessionSync(const QString &session) | 195 | bool Greeter::startSessionSync(const QString &session) |
1918 | 162 | { | 196 | { |
1919 | 163 | Q_UNUSED(session) | 197 | Q_UNUSED(session) |
1920 | 198 | |||
1921 | 199 | // Send a request to hide the greeter. This is normally done by logind, | ||
1922 | 200 | // but when testing, we don't want the bother of mocking that out. Instead, | ||
1923 | 201 | // just send the request directly ourselves. | ||
1924 | 202 | QDBusInterface iface("com.canonical.UnityGreeter", | ||
1925 | 203 | "/", | ||
1926 | 204 | "com.canonical.UnityGreeter", | ||
1927 | 205 | QDBusConnection::sessionBus()); | ||
1928 | 206 | iface.asyncCall("HideGreeter"); | ||
1929 | 207 | |||
1930 | 164 | return true; | 208 | return true; |
1931 | 165 | } | 209 | } |
1932 | 166 | 210 | ||
1933 | @@ -168,7 +212,30 @@ | |||
1934 | 168 | { | 212 | { |
1935 | 169 | Q_D(Greeter); | 213 | Q_D(Greeter); |
1936 | 170 | 214 | ||
1938 | 171 | d->handleRespond(response); | 215 | if (d->authenticationUser == "no-response") |
1939 | 216 | return; | ||
1940 | 217 | else if (d->authenticationUser == "two-factor") { | ||
1941 | 218 | if (!d->twoFactorDone) { | ||
1942 | 219 | if (response == "password") { | ||
1943 | 220 | d->twoFactorDone = true; | ||
1944 | 221 | Q_EMIT showPrompt("otp", Greeter::PromptTypeQuestion); | ||
1945 | 222 | } else { | ||
1946 | 223 | d->authenticated = false; | ||
1947 | 224 | sendAuthenticationComplete(); | ||
1948 | 225 | } | ||
1949 | 226 | } else { | ||
1950 | 227 | d->authenticated = (response == "otp"); | ||
1951 | 228 | sendAuthenticationComplete(); | ||
1952 | 229 | } | ||
1953 | 230 | return; | ||
1954 | 231 | } | ||
1955 | 232 | |||
1956 | 233 | if (d->authenticationUser == "has-pin") { | ||
1957 | 234 | d->authenticated = (response == "1234"); | ||
1958 | 235 | } else { | ||
1959 | 236 | d->authenticated = (response == "password"); | ||
1960 | 237 | } | ||
1961 | 238 | sendAuthenticationComplete(); | ||
1962 | 172 | } | 239 | } |
1963 | 173 | 240 | ||
1964 | 174 | void Greeter::sendAuthenticationComplete() | 241 | void Greeter::sendAuthenticationComplete() |
1965 | @@ -181,21 +248,4 @@ | |||
1966 | 181 | } | 248 | } |
1967 | 182 | } | 249 | } |
1968 | 183 | 250 | ||
1969 | 184 | QString Greeter::mockMode() const | ||
1970 | 185 | { | ||
1971 | 186 | Q_D(const Greeter); | ||
1972 | 187 | return d->mockMode; | ||
1973 | 188 | } | ||
1974 | 189 | |||
1975 | 190 | |||
1976 | 191 | void Greeter::setMockMode(QString mockMode) | ||
1977 | 192 | { | ||
1978 | 193 | Q_D(Greeter); | ||
1979 | 194 | |||
1980 | 195 | if (d->mockMode != mockMode) { | ||
1981 | 196 | d->mockMode = mockMode; | ||
1982 | 197 | Q_EMIT mockModeChanged(mockMode); | ||
1983 | 198 | } | ||
1984 | 199 | } | ||
1985 | 200 | |||
1986 | 201 | } | 251 | } |
1987 | 202 | 252 | ||
1988 | === renamed file 'tests/mocks/LightDM/IntegratedLightDM/liblightdm/Greeter.h' => 'tests/mocks/liblightdm/MockGreeter.h' | |||
1989 | --- tests/mocks/LightDM/IntegratedLightDM/liblightdm/Greeter.h 2016-12-23 11:04:53 +0000 | |||
1990 | +++ tests/mocks/liblightdm/MockGreeter.h 2017-01-17 15:40:09 +0000 | |||
1991 | @@ -1,5 +1,5 @@ | |||
1992 | 1 | /* | 1 | /* |
1994 | 2 | * Copyright (C) 2013 Canonical, Ltd. | 2 | * Copyright (C) 2013-2016 Canonical, Ltd. |
1995 | 3 | * Copyright (C) 2010-2011 David Edmundson. | 3 | * Copyright (C) 2010-2011 David Edmundson. |
1996 | 4 | * Copyright (C) 2010-2011 Robert Ancell | 4 | * Copyright (C) 2010-2011 Robert Ancell |
1997 | 5 | * | 5 | * |
1998 | @@ -18,16 +18,14 @@ | |||
1999 | 18 | * Author: David Edmundson <kde@davidedmundson.co.uk> | 18 | * Author: David Edmundson <kde@davidedmundson.co.uk> |
2000 | 19 | */ | 19 | */ |
2001 | 20 | 20 | ||
2008 | 21 | #ifndef UNITY_MOCK_GREETER_H | 21 | #pragma once |
2009 | 22 | #define UNITY_MOCK_GREETER_H | 22 | |
2010 | 23 | 23 | #include <QObject> | |
2011 | 24 | #include <QtCore/QObject> | 24 | #include <QVariant> |
2006 | 25 | #include <QtCore/QVariant> | ||
2007 | 26 | |||
2012 | 27 | 25 | ||
2013 | 28 | namespace QLightDM | 26 | namespace QLightDM |
2014 | 29 | { | 27 | { |
2016 | 30 | class GreeterPrivate; | 28 | class GreeterPrivate; |
2017 | 31 | 29 | ||
2018 | 32 | class Q_DECL_EXPORT Greeter : public QObject | 30 | class Q_DECL_EXPORT Greeter : public QObject |
2019 | 33 | { | 31 | { |
2020 | @@ -42,9 +40,6 @@ | |||
2021 | 42 | Q_PROPERTY(QString hostname READ hostname CONSTANT) | 40 | Q_PROPERTY(QString hostname READ hostname CONSTANT) |
2022 | 43 | Q_PROPERTY(bool hasGuestAccount READ hasGuestAccountHint CONSTANT) | 41 | Q_PROPERTY(bool hasGuestAccount READ hasGuestAccountHint CONSTANT) |
2023 | 44 | 42 | ||
2024 | 45 | //Mock-only API for testing purposes | ||
2025 | 46 | Q_PROPERTY(QString mockMode READ mockMode WRITE setMockMode NOTIFY mockModeChanged) | ||
2026 | 47 | |||
2027 | 48 | public: | 43 | public: |
2028 | 49 | enum PromptType { | 44 | enum PromptType { |
2029 | 50 | PromptTypeQuestion, | 45 | PromptTypeQuestion, |
2030 | @@ -68,7 +63,6 @@ | |||
2031 | 68 | bool showRemoteLoginHint() const; | 63 | bool showRemoteLoginHint() const; |
2032 | 69 | bool hasGuestAccountHint() const; | 64 | bool hasGuestAccountHint() const; |
2033 | 70 | QString selectUserHint() const; | 65 | QString selectUserHint() const; |
2034 | 71 | void setSelectUserHint(const QString &selectUserHint); // only in mock | ||
2035 | 72 | bool selectGuestHint() const; | 66 | bool selectGuestHint() const; |
2036 | 73 | QString autologinUserHint() const; | 67 | QString autologinUserHint() const; |
2037 | 74 | bool autologinGuestHint() const; | 68 | bool autologinGuestHint() const; |
2038 | @@ -79,9 +73,6 @@ | |||
2039 | 79 | QString authenticationUser() const; | 73 | QString authenticationUser() const; |
2040 | 80 | QString hostname() const; | 74 | QString hostname() const; |
2041 | 81 | 75 | ||
2042 | 82 | QString mockMode() const; | ||
2043 | 83 | void setMockMode(QString mockMode); | ||
2044 | 84 | |||
2045 | 85 | public Q_SLOTS: | 76 | public Q_SLOTS: |
2046 | 86 | bool connectSync(); | 77 | bool connectSync(); |
2047 | 87 | void authenticate(const QString &username=QString()); | 78 | void authenticate(const QString &username=QString()); |
2048 | @@ -98,18 +89,14 @@ | |||
2049 | 98 | void showPrompt(QString text, QLightDM::Greeter::PromptType type); | 89 | void showPrompt(QString text, QLightDM::Greeter::PromptType type); |
2050 | 99 | void authenticationComplete(); | 90 | void authenticationComplete(); |
2051 | 100 | void autologinTimerExpired(); | 91 | void autologinTimerExpired(); |
2052 | 101 | void mockModeChanged(QString mode); | ||
2053 | 102 | |||
2054 | 103 | protected: | ||
2055 | 104 | void sendAuthenticationComplete(); | ||
2056 | 105 | 92 | ||
2057 | 106 | private Q_SLOTS: | 93 | private Q_SLOTS: |
2059 | 107 | void delayedAuthentication(); | 94 | void handleAuthenticate(); |
2060 | 108 | 95 | ||
2061 | 109 | private: | 96 | private: |
2062 | 97 | void sendAuthenticationComplete(); | ||
2063 | 98 | |||
2064 | 110 | GreeterPrivate *d_ptr; | 99 | GreeterPrivate *d_ptr; |
2065 | 111 | Q_DECLARE_PRIVATE(Greeter) | 100 | Q_DECLARE_PRIVATE(Greeter) |
2066 | 112 | }; | 101 | }; |
2067 | 113 | } | 102 | } |
2068 | 114 | |||
2069 | 115 | #endif // UNITY_MOCK_GREETER_H | ||
2070 | 116 | 103 | ||
2071 | === renamed file 'tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModel.cpp' => 'tests/mocks/liblightdm/MockSessionsModel.cpp' | |||
2072 | --- tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModel.cpp 2016-12-23 11:04:53 +0000 | |||
2073 | +++ tests/mocks/liblightdm/MockSessionsModel.cpp 2017-01-17 15:40:09 +0000 | |||
2074 | @@ -1,5 +1,5 @@ | |||
2075 | 1 | /* | 1 | /* |
2077 | 2 | * Copyright (C) 2015 Canonical, Ltd. | 2 | * Copyright (C) 2015-2016 Canonical, Ltd. |
2078 | 3 | * | 3 | * |
2079 | 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 |
2080 | 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 |
2081 | @@ -21,21 +21,35 @@ | |||
2082 | 21 | // set our compatibility to Qt4 here too. | 21 | // set our compatibility to Qt4 here too. |
2083 | 22 | #define QT_DISABLE_DEPRECATED_BEFORE QT_VERSION_CHECK(4, 0, 0) | 22 | #define QT_DISABLE_DEPRECATED_BEFORE QT_VERSION_CHECK(4, 0, 0) |
2084 | 23 | 23 | ||
2089 | 24 | #include "SessionsModel.h" | 24 | #include "MockController.h" |
2090 | 25 | #include "SessionsModelPrivate.h" | 25 | #include "MockSessionsModel.h" |
2087 | 26 | #include <QtCore/QDir> | ||
2088 | 27 | #include <QtCore/QString> | ||
2091 | 28 | 26 | ||
2092 | 29 | namespace QLightDM | 27 | namespace QLightDM |
2093 | 30 | { | 28 | { |
2094 | 31 | 29 | ||
2102 | 32 | SessionsModel::SessionsModel(QObject* parent) : | 30 | class SessionsModelPrivate |
2103 | 33 | QAbstractListModel(parent), | 31 | { |
2104 | 34 | d_ptr(new SessionsModelPrivate(this)) | 32 | public: |
2105 | 35 | { | 33 | QHash<int, QByteArray> roleNames; |
2106 | 36 | m_roleNames = QAbstractListModel::roleNames(); | 34 | QList<MockController::SessionItem> sessionItems; |
2107 | 37 | m_roleNames[KeyRole] = "key"; | 35 | }; |
2108 | 38 | m_roleNames[TypeRole] = "type"; | 36 | |
2109 | 37 | SessionsModel::SessionsModel(QObject* parent) | ||
2110 | 38 | : QAbstractListModel(parent) | ||
2111 | 39 | , d_ptr(new SessionsModelPrivate) | ||
2112 | 40 | { | ||
2113 | 41 | Q_D(SessionsModel); | ||
2114 | 42 | |||
2115 | 43 | d->roleNames = QAbstractListModel::roleNames(); | ||
2116 | 44 | d->roleNames[KeyRole] = "key"; | ||
2117 | 45 | d->roleNames[TypeRole] = "type"; | ||
2118 | 46 | setRoleNames(d->roleNames); | ||
2119 | 47 | |||
2120 | 48 | connect(MockController::instance(), &MockController::sessionModeChanged, | ||
2121 | 49 | this, &SessionsModel::resetEntries); | ||
2122 | 50 | connect(MockController::instance(), &MockController::numSessionsChanged, | ||
2123 | 51 | this, &SessionsModel::resetEntries); | ||
2124 | 52 | resetEntries(); | ||
2125 | 39 | } | 53 | } |
2126 | 40 | 54 | ||
2127 | 41 | SessionsModel::~SessionsModel() | 55 | SessionsModel::~SessionsModel() |
2128 | @@ -65,7 +79,9 @@ | |||
2129 | 65 | 79 | ||
2130 | 66 | QHash<int, QByteArray> SessionsModel::roleNames() const | 80 | QHash<int, QByteArray> SessionsModel::roleNames() const |
2131 | 67 | { | 81 | { |
2133 | 68 | return m_roleNames; | 82 | Q_D(const SessionsModel); |
2134 | 83 | |||
2135 | 84 | return d->roleNames; | ||
2136 | 69 | } | 85 | } |
2137 | 70 | 86 | ||
2138 | 71 | int SessionsModel::rowCount(const QModelIndex& parent) const | 87 | int SessionsModel::rowCount(const QModelIndex& parent) const |
2139 | @@ -79,42 +95,24 @@ | |||
2140 | 79 | } | 95 | } |
2141 | 80 | } | 96 | } |
2142 | 81 | 97 | ||
2179 | 82 | int SessionsModel::numSessions() const | 98 | void SessionsModel::resetEntries() |
2180 | 83 | { | 99 | { |
2181 | 84 | Q_D(const SessionsModel); | 100 | Q_D(SessionsModel); |
2182 | 85 | return d->numSessions; | 101 | |
2183 | 86 | } | 102 | beginResetModel(); |
2184 | 87 | 103 | ||
2185 | 88 | int SessionsModel::numAvailableSessions() const | 104 | QString sessionMode = MockController::instance()->sessionMode(); |
2186 | 89 | { | 105 | |
2187 | 90 | Q_D(const SessionsModel); | 106 | if (sessionMode == "full") { |
2188 | 91 | return d->numAvailableSessions(); | 107 | d->sessionItems = MockController::instance()->fullSessionItems(); |
2189 | 92 | } | 108 | d->sessionItems = d->sessionItems.mid(0, MockController::instance()->numSessions()); |
2190 | 93 | 109 | } else if (sessionMode == "single") { | |
2191 | 94 | QString SessionsModel::testScenario() const | 110 | d->sessionItems = {MockController::instance()->fullSessionItems()[0]}; |
2192 | 95 | { | 111 | } else { |
2193 | 96 | Q_D(const SessionsModel); | 112 | d->sessionItems = {}; |
2194 | 97 | return d->testScenario; | 113 | } |
2195 | 98 | } | 114 | |
2196 | 99 | 115 | endResetModel(); | |
2161 | 100 | void SessionsModel::setNumSessions(int numSessions) | ||
2162 | 101 | { | ||
2163 | 102 | Q_D(SessionsModel); | ||
2164 | 103 | |||
2165 | 104 | if (d->numSessions != numSessions) { | ||
2166 | 105 | d->numSessions = numSessions; | ||
2167 | 106 | d->resetEntries(); | ||
2168 | 107 | } | ||
2169 | 108 | } | ||
2170 | 109 | |||
2171 | 110 | void SessionsModel::setTestScenario(QString testScenario) | ||
2172 | 111 | { | ||
2173 | 112 | Q_D(SessionsModel); | ||
2174 | 113 | |||
2175 | 114 | if (d->testScenario != testScenario) { | ||
2176 | 115 | d->testScenario = testScenario; | ||
2177 | 116 | d->resetEntries(); | ||
2178 | 117 | } | ||
2197 | 118 | } | 116 | } |
2198 | 119 | 117 | ||
2199 | 120 | } // namespace QLightDM | 118 | } // namespace QLightDM |
2200 | 121 | 119 | ||
2201 | === renamed file 'tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModel.h' => 'tests/mocks/liblightdm/MockSessionsModel.h' | |||
2202 | --- tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModel.h 2016-12-23 11:04:53 +0000 | |||
2203 | +++ tests/mocks/liblightdm/MockSessionsModel.h 2017-01-17 15:40:09 +0000 | |||
2204 | @@ -1,5 +1,5 @@ | |||
2205 | 1 | /* | 1 | /* |
2207 | 2 | * Copyright (C) 2015 Canonical, Ltd. | 2 | * Copyright (C) 2015-2016 Canonical, Ltd. |
2208 | 3 | * | 3 | * |
2209 | 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 |
2210 | 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 |
2211 | @@ -15,11 +15,12 @@ | |||
2212 | 15 | * | 15 | * |
2213 | 16 | */ | 16 | */ |
2214 | 17 | 17 | ||
2217 | 18 | #ifndef UNITY_MOCK_SESSIONSMODEL_H | 18 | #pragma once |
2216 | 19 | #define UNITY_MOCK_SESSIONSMODEL_H | ||
2218 | 20 | 19 | ||
2221 | 21 | #include <QtCore/QAbstractListModel> | 20 | #include <QAbstractListModel> |
2222 | 22 | #include <QtCore/QString> | 21 | #include <QByteArray> |
2223 | 22 | #include <QHash> | ||
2224 | 23 | #include <QString> | ||
2225 | 23 | 24 | ||
2226 | 24 | namespace QLightDM | 25 | namespace QLightDM |
2227 | 25 | { | 26 | { |
2228 | @@ -30,7 +31,6 @@ | |||
2229 | 30 | Q_OBJECT | 31 | Q_OBJECT |
2230 | 31 | 32 | ||
2231 | 32 | public: | 33 | public: |
2232 | 33 | |||
2233 | 34 | enum SessionModelRoles { | 34 | enum SessionModelRoles { |
2234 | 35 | //name is exposed as Qt::DisplayRole | 35 | //name is exposed as Qt::DisplayRole |
2235 | 36 | //comment is exposed as Qt::TooltipRole | 36 | //comment is exposed as Qt::TooltipRole |
2236 | @@ -54,19 +54,11 @@ | |||
2237 | 54 | int rowCount(const QModelIndex& parent) const override; | 54 | int rowCount(const QModelIndex& parent) const override; |
2238 | 55 | QVariant data(const QModelIndex& index, int role) const override; | 55 | QVariant data(const QModelIndex& index, int role) const override; |
2239 | 56 | 56 | ||
2248 | 57 | int numSessions() const; | 57 | private Q_SLOTS: |
2249 | 58 | int numAvailableSessions() const; | 58 | void resetEntries(); |
2242 | 59 | QString testScenario() const; | ||
2243 | 60 | void setNumSessions(int numSessions); | ||
2244 | 61 | void setTestScenario(QString testScenario); | ||
2245 | 62 | |||
2246 | 63 | protected: | ||
2247 | 64 | SessionsModelPrivate* const d_ptr; | ||
2250 | 65 | 59 | ||
2251 | 66 | private: | 60 | private: |
2253 | 67 | QHash<int, QByteArray> m_roleNames; | 61 | SessionsModelPrivate *d_ptr; |
2254 | 68 | Q_DECLARE_PRIVATE(SessionsModel) | 62 | Q_DECLARE_PRIVATE(SessionsModel) |
2255 | 69 | }; | 63 | }; |
2256 | 70 | } | 64 | } |
2257 | 71 | |||
2258 | 72 | #endif // UNITY_MOCK_SESSIONSMODEL_H | ||
2259 | 73 | 65 | ||
2260 | === renamed file 'tests/mocks/LightDM/IntegratedLightDM/liblightdm/UsersModel.cpp' => 'tests/mocks/liblightdm/MockUsersModel.cpp' | |||
2261 | --- tests/mocks/LightDM/IntegratedLightDM/liblightdm/UsersModel.cpp 2016-12-23 11:04:53 +0000 | |||
2262 | +++ tests/mocks/liblightdm/MockUsersModel.cpp 2017-01-17 15:40:09 +0000 | |||
2263 | @@ -21,18 +21,36 @@ | |||
2264 | 21 | // set our compatibility to Qt4 here too. | 21 | // set our compatibility to Qt4 here too. |
2265 | 22 | #define QT_DISABLE_DEPRECATED_BEFORE QT_VERSION_CHECK(4, 0, 0) | 22 | #define QT_DISABLE_DEPRECATED_BEFORE QT_VERSION_CHECK(4, 0, 0) |
2266 | 23 | 23 | ||
2272 | 24 | #include "UsersModel.h" | 24 | #include "MockController.h" |
2273 | 25 | #include "UsersModelPrivate.h" | 25 | #include "MockUsersModel.h" |
2274 | 26 | #include <QtCore/QDir> | 26 | #include <QDir> |
2275 | 27 | #include <QtCore/QString> | 27 | #include <QIcon> |
2271 | 28 | #include <QtGui/QIcon> | ||
2276 | 29 | 28 | ||
2277 | 30 | namespace QLightDM | 29 | namespace QLightDM |
2278 | 31 | { | 30 | { |
2279 | 32 | 31 | ||
2283 | 33 | UsersModel::UsersModel(QObject *parent) : | 32 | class Entry |
2284 | 34 | QAbstractListModel(parent), | 33 | { |
2285 | 35 | d_ptr(new UsersModelPrivate(this)) | 34 | public: |
2286 | 35 | QString username; | ||
2287 | 36 | QString real_name; | ||
2288 | 37 | QString background; | ||
2289 | 38 | QString layouts; | ||
2290 | 39 | bool is_active; | ||
2291 | 40 | bool has_messages; | ||
2292 | 41 | QString session; | ||
2293 | 42 | uid_t uid; | ||
2294 | 43 | }; | ||
2295 | 44 | |||
2296 | 45 | class UsersModelPrivate | ||
2297 | 46 | { | ||
2298 | 47 | public: | ||
2299 | 48 | QList<Entry> entries; | ||
2300 | 49 | }; | ||
2301 | 50 | |||
2302 | 51 | UsersModel::UsersModel(QObject *parent) | ||
2303 | 52 | : QAbstractListModel(parent) | ||
2304 | 53 | , d_ptr(new UsersModelPrivate) | ||
2305 | 36 | { | 54 | { |
2306 | 37 | // Extend roleNames (we want to keep the "display" role) | 55 | // Extend roleNames (we want to keep the "display" role) |
2307 | 38 | QHash<int, QByteArray> roles = roleNames(); | 56 | QHash<int, QByteArray> roles = roleNames(); |
2308 | @@ -46,6 +64,10 @@ | |||
2309 | 46 | roles[ImagePathRole] = "imagePath"; | 64 | roles[ImagePathRole] = "imagePath"; |
2310 | 47 | roles[UidRole] = "uid"; | 65 | roles[UidRole] = "uid"; |
2311 | 48 | setRoleNames(roles); | 66 | setRoleNames(roles); |
2312 | 67 | |||
2313 | 68 | connect(MockController::instance(), &MockController::userModeChanged, | ||
2314 | 69 | this, &UsersModel::resetEntries); | ||
2315 | 70 | resetEntries(); | ||
2316 | 49 | } | 71 | } |
2317 | 50 | 72 | ||
2318 | 51 | UsersModel::~UsersModel() | 73 | UsersModel::~UsersModel() |
2319 | @@ -101,21 +123,64 @@ | |||
2320 | 101 | } | 123 | } |
2321 | 102 | } | 124 | } |
2322 | 103 | 125 | ||
2330 | 104 | QString UsersModel::mockMode() const | 126 | void UsersModel::resetEntries() |
2324 | 105 | { | ||
2325 | 106 | Q_D(const UsersModel); | ||
2326 | 107 | return d->mockMode; | ||
2327 | 108 | } | ||
2328 | 109 | |||
2329 | 110 | void UsersModel::setMockMode(QString mockMode) | ||
2331 | 111 | { | 127 | { |
2332 | 112 | Q_D(UsersModel); | 128 | Q_D(UsersModel); |
2333 | 113 | 129 | ||
2339 | 114 | if (d->mockMode != mockMode) { | 130 | beginResetModel(); |
2340 | 115 | d->mockMode = mockMode; | 131 | |
2341 | 116 | Q_EMIT mockModeChanged(mockMode); | 132 | QString userMode = MockController::instance()->userMode(); |
2342 | 117 | d->resetEntries(); | 133 | |
2343 | 118 | } | 134 | if (userMode == "single") { |
2344 | 135 | d->entries = {{"no-password", "No Password", "", 0, false, false, "ubuntu", 0}}; | ||
2345 | 136 | } else if (userMode == "single-passphrase") { | ||
2346 | 137 | d->entries = {{"has-password", "Has Password", "", 0, false, false, "ubuntu", 0}}; | ||
2347 | 138 | } else if (userMode == "single-pin") { | ||
2348 | 139 | d->entries = {{"has-pin", "Has PIN", "", 0, false, false, "ubuntu", 0}}; | ||
2349 | 140 | } else if (userMode == "full") { | ||
2350 | 141 | d->entries = { | ||
2351 | 142 | { "has-password", "Has Password", 0, 0, false, false, "ubuntu", 0 }, | ||
2352 | 143 | { "has-pin", "Has PIN", 0, 0, false, false, "ubuntu", 0 }, | ||
2353 | 144 | { "different-prompt", "Different Prompt", 0, 0, false, false, "ubuntu", 0 }, | ||
2354 | 145 | { "no-password", "No Password", 0, 0, false, false, "ubuntu", 0 }, | ||
2355 | 146 | { "auth-error", "Auth Error", 0, 0, false, false, "ubuntu", 0 }, | ||
2356 | 147 | { "two-factor", "Two Factor", 0, 0, false, false, "ubuntu", 0 }, | ||
2357 | 148 | { "info-prompt", "Info Prompt", 0, 0, false, false, "ubuntu", 0 }, | ||
2358 | 149 | { "html-info-prompt", "HTML Info Prompt", 0, 0, false, false, "ubuntu", 0 }, | ||
2359 | 150 | { "long-info-prompt", "Long Info Prompt", 0, 0, false, false, "ubuntu", 0 }, | ||
2360 | 151 | { "wide-info-prompt", "Wide Info Prompt", 0, 0, false, false, "ubuntu", 0 }, | ||
2361 | 152 | { "multi-info-prompt", "Multi Info Prompt", 0, 0, false, false, "ubuntu", 0 }, | ||
2362 | 153 | { "long-name", "Long name (far far too long to fit, seriously this would never fit on the screen, you will never see this part of the name)", 0, 0, false, false, "ubuntu", 0 }, | ||
2363 | 154 | { "color-background", "Color Background", "#E95420", 0, false, false, "ubuntu", 0 }, | ||
2364 | 155 | // white and black are a bit redundant, but useful for manually testing if UI is still readable | ||
2365 | 156 | { "white-background", "White Background", "#ffffff", 0, false, false, "ubuntu", 0 }, | ||
2366 | 157 | { "black-background", "Black Background", "#000000", 0, false, false, "ubuntu", 0 }, | ||
2367 | 158 | { "no-background", "No Background", "", 0, false, false, "ubuntu", 0 }, | ||
2368 | 159 | { "unicode", "가나다라마", 0, 0, false, false, "ubuntu", 0 }, | ||
2369 | 160 | { "no-response", "No Response", 0, 0, false, false, "ubuntu", 0 }, | ||
2370 | 161 | { "empty-name", "", 0, 0, false, false, "ubuntu", 0 }, | ||
2371 | 162 | { "active", "Active Account", 0, 0, true, false, "ubuntu", 0 }, | ||
2372 | 163 | }; | ||
2373 | 164 | } | ||
2374 | 165 | |||
2375 | 166 | // Assign uids in a loop, just to avoid having to muck with them when | ||
2376 | 167 | // adding or removing test users. | ||
2377 | 168 | for (int i = 0; i < d->entries.size(); i++) { | ||
2378 | 169 | d->entries[i].uid = i + 1; | ||
2379 | 170 | } | ||
2380 | 171 | |||
2381 | 172 | // Assign backgrounds | ||
2382 | 173 | QDir backgroundDir("/usr/share/backgrounds"); | ||
2383 | 174 | QStringList backgrounds = backgroundDir.entryList(QDir::Files); | ||
2384 | 175 | if (!backgrounds.empty()) { | ||
2385 | 176 | for (int i = 0; i < d->entries.size(); i++) { | ||
2386 | 177 | if (d->entries[i].background.isNull()) { | ||
2387 | 178 | d->entries[i].background = backgroundDir.filePath(backgrounds[i % backgrounds.size()]); | ||
2388 | 179 | } | ||
2389 | 180 | } | ||
2390 | 181 | } | ||
2391 | 182 | |||
2392 | 183 | endResetModel(); | ||
2393 | 119 | } | 184 | } |
2394 | 120 | 185 | ||
2395 | 121 | } | 186 | } |
2396 | 122 | 187 | ||
2397 | === renamed file 'tests/mocks/LightDM/IntegratedLightDM/liblightdm/UsersModel.h' => 'tests/mocks/liblightdm/MockUsersModel.h' | |||
2398 | --- tests/mocks/LightDM/IntegratedLightDM/liblightdm/UsersModel.h 2016-12-23 11:04:53 +0000 | |||
2399 | +++ tests/mocks/liblightdm/MockUsersModel.h 2017-01-17 15:40:09 +0000 | |||
2400 | @@ -1,5 +1,5 @@ | |||
2401 | 1 | /* | 1 | /* |
2403 | 2 | * Copyright (C) 2013-2014 Canonical, Ltd. | 2 | * Copyright (C) 2013-2016 Canonical, Ltd. |
2404 | 3 | * Copyright (C) 2010-2011 David Edmundson. | 3 | * Copyright (C) 2010-2011 David Edmundson. |
2405 | 4 | * | 4 | * |
2406 | 5 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
2407 | @@ -15,13 +15,11 @@ | |||
2408 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2409 | 16 | */ | 16 | */ |
2410 | 17 | 17 | ||
2413 | 18 | #ifndef UNITY_MOCK_USERSMODEL_H | 18 | #pragma once |
2412 | 19 | #define UNITY_MOCK_USERSMODEL_H | ||
2414 | 20 | 19 | ||
2415 | 21 | #include <QtCore/QString> | ||
2416 | 22 | #include <QtCore/QSharedDataPointer> | ||
2417 | 23 | #include <QAbstractListModel> | 20 | #include <QAbstractListModel> |
2419 | 24 | 21 | #include <QList> | |
2420 | 22 | #include <QString> | ||
2421 | 25 | 23 | ||
2422 | 26 | namespace QLightDM | 24 | namespace QLightDM |
2423 | 27 | { | 25 | { |
2424 | @@ -31,12 +29,6 @@ | |||
2425 | 31 | { | 29 | { |
2426 | 32 | Q_OBJECT | 30 | Q_OBJECT |
2427 | 33 | 31 | ||
2428 | 34 | //Mock-only API for testing purposes | ||
2429 | 35 | Q_PROPERTY(QString mockMode READ mockMode WRITE setMockMode NOTIFY mockModeChanged) | ||
2430 | 36 | |||
2431 | 37 | Q_SIGNALS: | ||
2432 | 38 | void mockModeChanged(QString mode); | ||
2433 | 39 | |||
2434 | 40 | public: | 32 | public: |
2435 | 41 | explicit UsersModel(QObject *parent = 0); | 33 | explicit UsersModel(QObject *parent = 0); |
2436 | 42 | virtual ~UsersModel(); | 34 | virtual ~UsersModel(); |
2437 | @@ -56,8 +48,8 @@ | |||
2438 | 56 | int rowCount(const QModelIndex &parent) const override; | 48 | int rowCount(const QModelIndex &parent) const override; |
2439 | 57 | QVariant data(const QModelIndex &index, int role) const override; | 49 | QVariant data(const QModelIndex &index, int role) const override; |
2440 | 58 | 50 | ||
2443 | 59 | QString mockMode() const; | 51 | private Q_SLOTS: |
2444 | 60 | void setMockMode(QString mockMode); | 52 | void resetEntries(); |
2445 | 61 | 53 | ||
2446 | 62 | private: | 54 | private: |
2447 | 63 | UsersModelPrivate * const d_ptr; | 55 | UsersModelPrivate * const d_ptr; |
2448 | @@ -65,5 +57,3 @@ | |||
2449 | 65 | }; | 57 | }; |
2450 | 66 | 58 | ||
2451 | 67 | } | 59 | } |
2452 | 68 | |||
2453 | 69 | #endif // UNITY_MOCK_USERSMODEL_H | ||
2454 | 70 | 60 | ||
2455 | === modified file 'tests/plugins/LightDM/IntegratedLightDM/CMakeLists.txt' | |||
2456 | --- tests/plugins/LightDM/IntegratedLightDM/CMakeLists.txt 2016-12-08 20:33:21 +0000 | |||
2457 | +++ tests/plugins/LightDM/IntegratedLightDM/CMakeLists.txt 2017-01-17 15:40:09 +0000 | |||
2458 | @@ -1,6 +1,7 @@ | |||
2459 | 1 | include_directories( | 1 | include_directories( |
2460 | 2 | ${GLIB_INCLUDE_DIRS} | 2 | ${GLIB_INCLUDE_DIRS} |
2461 | 3 | ${CMAKE_CURRENT_BINARY_DIR} | 3 | ${CMAKE_CURRENT_BINARY_DIR} |
2462 | 4 | ${CMAKE_SOURCE_DIR}/plugins/LightDM/IntegratedLightDM | ||
2463 | 4 | ) | 5 | ) |
2464 | 5 | 6 | ||
2465 | 6 | add_executable(GreeterDBusTestExec | 7 | add_executable(GreeterDBusTestExec |
2466 | @@ -28,7 +29,7 @@ | |||
2467 | 28 | add_unity8_uitest(GreeterDBus dbus-test-runner | 29 | add_unity8_uitest(GreeterDBus dbus-test-runner |
2468 | 29 | ARG_PREFIX "--parameter" | 30 | ARG_PREFIX "--parameter" |
2469 | 30 | ARGS --task $<TARGET_FILE:GreeterDBusTestExec> | 31 | ARGS --task $<TARGET_FILE:GreeterDBusTestExec> |
2471 | 31 | DEPENDS MockLightDM MockLightDM-qml | 32 | DEPENDS MockLightDM |
2472 | 32 | ) | 33 | ) |
2473 | 33 | 34 | ||
2474 | 34 | add_executable(GreeterPamTestExec | 35 | add_executable(GreeterPamTestExec |
2475 | @@ -64,12 +65,12 @@ | |||
2476 | 64 | ${CMAKE_SOURCE_DIR}/plugins/LightDM | 65 | ${CMAKE_SOURCE_DIR}/plugins/LightDM |
2477 | 65 | ${CMAKE_SOURCE_DIR}/plugins/Utils | 66 | ${CMAKE_SOURCE_DIR}/plugins/Utils |
2478 | 66 | ${CMAKE_SOURCE_DIR}/tests/mocks/LightDM/IntegratedLightDM | 67 | ${CMAKE_SOURCE_DIR}/tests/mocks/LightDM/IntegratedLightDM |
2479 | 68 | ${CMAKE_SOURCE_DIR}/tests/mocks/liblightdm/ | ||
2480 | 67 | ) | 69 | ) |
2481 | 68 | install(TARGETS GreeterSessionsModelTestExec | 70 | install(TARGETS GreeterSessionsModelTestExec |
2482 | 69 | DESTINATION "${SHELL_PRIVATE_LIBDIR}/tests/plugins/LightDM/IntegratedLightDM" | 71 | DESTINATION "${SHELL_PRIVATE_LIBDIR}/tests/plugins/LightDM/IntegratedLightDM" |
2483 | 70 | ) | 72 | ) |
2484 | 71 | add_unity8_uitest(GreeterSessions GreeterSessionsModelTestExec | 73 | add_unity8_uitest(GreeterSessions GreeterSessionsModelTestExec |
2485 | 72 | ENVIRONMENT LIBLIGHTDM_MOCK_MODE=full | ||
2486 | 73 | DEPENDS MockLightDM | 74 | DEPENDS MockLightDM |
2487 | 74 | ) | 75 | ) |
2488 | 75 | 76 | ||
2489 | @@ -96,7 +97,6 @@ | |||
2490 | 96 | DESTINATION "${SHELL_PRIVATE_LIBDIR}/tests/plugins/LightDM/IntegratedLightDM" | 97 | DESTINATION "${SHELL_PRIVATE_LIBDIR}/tests/plugins/LightDM/IntegratedLightDM" |
2491 | 97 | ) | 98 | ) |
2492 | 98 | add_unity8_uitest(GreeterUsers GreeterUsersModelTestExec | 99 | add_unity8_uitest(GreeterUsers GreeterUsersModelTestExec |
2493 | 99 | ENVIRONMENT LIBLIGHTDM_MOCK_MODE=full | ||
2494 | 100 | DEPENDS MockLightDM | 100 | DEPENDS MockLightDM |
2495 | 101 | ) | 101 | ) |
2496 | 102 | 102 | ||
2497 | 103 | 103 | ||
2498 | === modified file 'tests/plugins/LightDM/IntegratedLightDM/greeter.qml' | |||
2499 | --- tests/plugins/LightDM/IntegratedLightDM/greeter.qml 2015-11-07 00:12:17 +0000 | |||
2500 | +++ tests/plugins/LightDM/IntegratedLightDM/greeter.qml 2017-01-17 15:40:09 +0000 | |||
2501 | @@ -1,5 +1,5 @@ | |||
2502 | 1 | /* | 1 | /* |
2504 | 2 | * Copyright 2013 Canonical Ltd. | 2 | * Copyright 2013,2015-2016 Canonical Ltd. |
2505 | 3 | * | 3 | * |
2506 | 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 |
2507 | 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 |
2508 | @@ -15,13 +15,8 @@ | |||
2509 | 15 | */ | 15 | */ |
2510 | 16 | 16 | ||
2511 | 17 | import QtQuick 2.4 | 17 | import QtQuick 2.4 |
2513 | 18 | import LightDM.IntegratedLightDM 0.1 as LightDM | 18 | import LightDM.FullLightDM 0.1 as LightDM |
2514 | 19 | 19 | ||
2515 | 20 | Item { | 20 | Item { |
2516 | 21 | property var greeter: LightDM.Greeter | 21 | property var greeter: LightDM.Greeter |
2517 | 22 | Binding { | ||
2518 | 23 | target: LightDM.Greeter | ||
2519 | 24 | property: "mockMode" | ||
2520 | 25 | value: "full" | ||
2521 | 26 | } | ||
2522 | 27 | } | 22 | } |
2523 | 28 | 23 | ||
2524 | === modified file 'tests/plugins/LightDM/IntegratedLightDM/sessionsmodel.cpp' | |||
2525 | --- tests/plugins/LightDM/IntegratedLightDM/sessionsmodel.cpp 2016-06-15 17:11:22 +0000 | |||
2526 | +++ tests/plugins/LightDM/IntegratedLightDM/sessionsmodel.cpp 2017-01-17 15:40:09 +0000 | |||
2527 | @@ -1,5 +1,5 @@ | |||
2528 | 1 | /* | 1 | /* |
2530 | 2 | * Copyright (C) 2015 Canonical, Ltd. | 2 | * Copyright (C) 2015-2016 Canonical, Ltd. |
2531 | 3 | * | 3 | * |
2532 | 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 |
2533 | 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 |
2534 | @@ -16,6 +16,8 @@ | |||
2535 | 16 | 16 | ||
2536 | 17 | #include "SessionsModel.h" | 17 | #include "SessionsModel.h" |
2537 | 18 | 18 | ||
2538 | 19 | #include "MockController.h" | ||
2539 | 20 | |||
2540 | 19 | #include <QLightDM/SessionsModel> | 21 | #include <QLightDM/SessionsModel> |
2541 | 20 | #include <QtCore/QModelIndex> | 22 | #include <QtCore/QModelIndex> |
2542 | 21 | #include <QtTest> | 23 | #include <QtTest> |
2543 | @@ -31,14 +33,14 @@ | |||
2544 | 31 | { | 33 | { |
2545 | 32 | model = new SessionsModel(); | 34 | model = new SessionsModel(); |
2546 | 33 | QVERIFY(model); | 35 | QVERIFY(model); |
2549 | 34 | sourceModel = new QLightDM::SessionsModel(); | 36 | mock = QLightDM::MockController::instance(); |
2550 | 35 | QVERIFY(sourceModel); | 37 | QVERIFY(mock); |
2551 | 36 | } | 38 | } |
2552 | 37 | 39 | ||
2553 | 38 | void cleanup() | 40 | void cleanup() |
2554 | 39 | { | 41 | { |
2555 | 40 | delete model; | 42 | delete model; |
2557 | 41 | delete sourceModel; | 43 | // mock will be a singleton, doesn't need to be cleaned |
2558 | 42 | } | 44 | } |
2559 | 43 | 45 | ||
2560 | 44 | static QModelIndex findByKey(QAbstractItemModel *model, const QString& key) | 46 | static QModelIndex findByKey(QAbstractItemModel *model, const QString& key) |
2561 | @@ -93,34 +95,34 @@ | |||
2562 | 93 | 95 | ||
2563 | 94 | void testMultipleSessionsCountIsCorrect() | 96 | void testMultipleSessionsCountIsCorrect() |
2564 | 95 | { | 97 | { |
2567 | 96 | sourceModel->setTestScenario("multipleSessions"); | 98 | mock->setProperty("sessionMode", "full"); |
2568 | 97 | QVERIFY(sourceModel->rowCount(QModelIndex()) > 1); | 99 | QVERIFY(model->rowCount(QModelIndex()) > 1); |
2569 | 98 | } | 100 | } |
2570 | 99 | 101 | ||
2571 | 100 | void testNoSessionsCountIsCorrect() | 102 | void testNoSessionsCountIsCorrect() |
2572 | 101 | { | 103 | { |
2575 | 102 | sourceModel->setTestScenario("noSessions"); | 104 | mock->setProperty("sessionMode", "none"); |
2576 | 103 | QVERIFY(sourceModel->rowCount(QModelIndex()) == 0); | 105 | QVERIFY(model->rowCount(QModelIndex()) == 0); |
2577 | 104 | } | 106 | } |
2578 | 105 | 107 | ||
2579 | 106 | void testSingleSessionCountIsCorrect() | 108 | void testSingleSessionCountIsCorrect() |
2580 | 107 | { | 109 | { |
2583 | 108 | sourceModel->setTestScenario("singleSession"); | 110 | mock->setProperty("sessionMode", "single"); |
2584 | 109 | QVERIFY(sourceModel->rowCount(QModelIndex()) == 1); | 111 | QVERIFY(model->rowCount(QModelIndex()) == 1); |
2585 | 110 | } | 112 | } |
2586 | 111 | 113 | ||
2587 | 112 | void testSessionNameIsCorrect() | 114 | void testSessionNameIsCorrect() |
2588 | 113 | { | 115 | { |
2589 | 114 | // This is testing the lookup, not the correctness of the strings, | 116 | // This is testing the lookup, not the correctness of the strings, |
2590 | 115 | // so one test should be sufficient | 117 | // so one test should be sufficient |
2593 | 116 | sourceModel->setTestScenario("multipleSessions"); | 118 | mock->setProperty("sessionMode", "full"); |
2594 | 117 | QVERIFY(model->data(findByKey(sourceModel, "ubuntu"), | 119 | QVERIFY(model->data(findByKey(model, "ubuntu"), |
2595 | 118 | Qt::DisplayRole).toString() == "Ubuntu"); | 120 | Qt::DisplayRole).toString() == "Ubuntu"); |
2596 | 119 | } | 121 | } |
2597 | 120 | 122 | ||
2598 | 121 | private: | 123 | private: |
2599 | 122 | SessionsModel *model; | 124 | SessionsModel *model; |
2601 | 123 | QLightDM::SessionsModel *sourceModel; | 125 | QObject *mock; |
2602 | 124 | }; | 126 | }; |
2603 | 125 | 127 | ||
2604 | 126 | QTEST_MAIN(GreeterSessionsModelTest) | 128 | QTEST_MAIN(GreeterSessionsModelTest) |
2605 | 127 | 129 | ||
2606 | === modified file 'tests/plugins/LightDM/IntegratedLightDM/usersmodel.cpp' | |||
2607 | --- tests/plugins/LightDM/IntegratedLightDM/usersmodel.cpp 2016-08-05 12:55:29 +0000 | |||
2608 | +++ tests/plugins/LightDM/IntegratedLightDM/usersmodel.cpp 2017-01-17 15:40:09 +0000 | |||
2609 | @@ -46,37 +46,27 @@ | |||
2610 | 46 | { | 46 | { |
2611 | 47 | model = new UsersModel(); | 47 | model = new UsersModel(); |
2612 | 48 | QVERIFY(model); | 48 | QVERIFY(model); |
2613 | 49 | sourceModel = new QLightDM::UsersModel(); | ||
2614 | 50 | QVERIFY(sourceModel); | ||
2615 | 51 | } | 49 | } |
2616 | 52 | 50 | ||
2617 | 53 | void cleanup() | 51 | void cleanup() |
2618 | 54 | { | 52 | { |
2619 | 55 | delete model; | 53 | delete model; |
2620 | 56 | delete sourceModel; | ||
2621 | 57 | } | 54 | } |
2622 | 58 | 55 | ||
2623 | 59 | void testMangleColor() | 56 | void testMangleColor() |
2624 | 60 | { | 57 | { |
2629 | 61 | QString background = getStringValue(sourceModel, "color-background", QLightDM::UsersModel::BackgroundPathRole); | 58 | auto background = getStringValue(model, "color-background", QLightDM::UsersModel::BackgroundPathRole); |
2626 | 62 | QVERIFY(background == "#E95420"); | ||
2627 | 63 | |||
2628 | 64 | background = getStringValue(model, "color-background", QLightDM::UsersModel::BackgroundPathRole); | ||
2630 | 65 | QVERIFY(background == "data:image/svg+xml,<svg><rect width='100%' height='100%' fill='#E95420'/></svg>"); | 59 | QVERIFY(background == "data:image/svg+xml,<svg><rect width='100%' height='100%' fill='#E95420'/></svg>"); |
2631 | 66 | } | 60 | } |
2632 | 67 | 61 | ||
2633 | 68 | void testMangleEmptyName() | 62 | void testMangleEmptyName() |
2634 | 69 | { | 63 | { |
2639 | 70 | QString name = getStringValue(sourceModel, "empty-name", QLightDM::UsersModel::RealNameRole); | 64 | auto name = getStringValue(model, "empty-name", QLightDM::UsersModel::RealNameRole); |
2636 | 71 | QVERIFY(name == ""); | ||
2637 | 72 | |||
2638 | 73 | name = getStringValue(model, "empty-name", QLightDM::UsersModel::RealNameRole); | ||
2640 | 74 | QVERIFY(name == "empty-name"); | 65 | QVERIFY(name == "empty-name"); |
2641 | 75 | } | 66 | } |
2642 | 76 | 67 | ||
2643 | 77 | private: | 68 | private: |
2644 | 78 | UsersModel *model; | 69 | UsersModel *model; |
2645 | 79 | QLightDM::UsersModel *sourceModel; | ||
2646 | 80 | }; | 70 | }; |
2647 | 81 | 71 | ||
2648 | 82 | QTEST_MAIN(GreeterUsersModelTest) | 72 | QTEST_MAIN(GreeterUsersModelTest) |
2649 | 83 | 73 | ||
2650 | === modified file 'tests/qmltests/Dash/tst_DashShell.qml' | |||
2651 | --- tests/qmltests/Dash/tst_DashShell.qml 2016-12-14 17:43:23 +0000 | |||
2652 | +++ tests/qmltests/Dash/tst_DashShell.qml 2017-01-17 15:40:09 +0000 | |||
2653 | @@ -20,12 +20,20 @@ | |||
2654 | 20 | import "../../../qml/" | 20 | import "../../../qml/" |
2655 | 21 | import Ubuntu.Components 1.3 | 21 | import Ubuntu.Components 1.3 |
2656 | 22 | import Unity.Test 0.1 as UT | 22 | import Unity.Test 0.1 as UT |
2657 | 23 | import LightDMController 0.1 | ||
2658 | 24 | import LightDM.FullLightDM 0.1 as LightDM | ||
2659 | 23 | 25 | ||
2660 | 24 | Item { | 26 | Item { |
2661 | 25 | id: root | 27 | id: root |
2662 | 26 | width: units.gu(80) | 28 | width: units.gu(80) |
2663 | 27 | height: units.gu(80) | 29 | height: units.gu(80) |
2664 | 28 | 30 | ||
2665 | 31 | Binding { | ||
2666 | 32 | target: LightDMController | ||
2667 | 33 | property: "userMode" | ||
2668 | 34 | value: "single" | ||
2669 | 35 | } | ||
2670 | 36 | |||
2671 | 29 | Shell { | 37 | Shell { |
2672 | 30 | id: shell | 38 | id: shell |
2673 | 31 | width: parent.width / 2 | 39 | width: parent.width / 2 |
2674 | 32 | 40 | ||
2675 | === modified file 'tests/qmltests/Greeter/TestView.qml' | |||
2676 | --- tests/qmltests/Greeter/TestView.qml 2016-08-30 14:06:47 +0000 | |||
2677 | +++ tests/qmltests/Greeter/TestView.qml 2017-01-17 15:40:09 +0000 | |||
2678 | @@ -32,6 +32,7 @@ | |||
2679 | 32 | property bool alphanumeric | 32 | property bool alphanumeric |
2680 | 33 | property var userModel | 33 | property var userModel |
2681 | 34 | property var infographicModel | 34 | property var infographicModel |
2682 | 35 | property bool waiting | ||
2683 | 35 | readonly property bool fullyShown: _fullyShown | 36 | readonly property bool fullyShown: _fullyShown |
2684 | 36 | readonly property bool required: _required | 37 | readonly property bool required: _required |
2685 | 37 | readonly property bool animating: _animating | 38 | readonly property bool animating: _animating |
2686 | 38 | 39 | ||
2687 | === modified file 'tests/qmltests/Greeter/tst_Greeter.qml' | |||
2688 | --- tests/qmltests/Greeter/tst_Greeter.qml 2016-08-30 14:06:47 +0000 | |||
2689 | +++ tests/qmltests/Greeter/tst_Greeter.qml 2017-01-17 15:40:09 +0000 | |||
2690 | @@ -22,7 +22,8 @@ | |||
2691 | 22 | import AccountsService 0.1 | 22 | import AccountsService 0.1 |
2692 | 23 | import Biometryd 0.0 | 23 | import Biometryd 0.0 |
2693 | 24 | import GSettings 1.0 | 24 | import GSettings 1.0 |
2695 | 25 | import LightDM.IntegratedLightDM 0.1 as LightDM // This is the mock | 25 | import LightDMController 0.1 |
2696 | 26 | import LightDM.FullLightDM 0.1 as LightDM | ||
2697 | 26 | import Unity.Test 0.1 as UT | 27 | import Unity.Test 0.1 as UT |
2698 | 27 | 28 | ||
2699 | 28 | Item { | 29 | Item { |
2700 | @@ -32,9 +33,6 @@ | |||
2701 | 32 | property url defaultBackground: "/usr/share/backgrounds/warty-final-ubuntu.png" | 33 | property url defaultBackground: "/usr/share/backgrounds/warty-final-ubuntu.png" |
2702 | 33 | 34 | ||
2703 | 34 | Component.onCompleted: { | 35 | Component.onCompleted: { |
2704 | 35 | // set the mock mode before loading | ||
2705 | 36 | LightDM.Greeter.mockMode = "full"; | ||
2706 | 37 | LightDM.Users.mockMode = "full"; | ||
2707 | 38 | loader.active = true; | 36 | loader.active = true; |
2708 | 39 | } | 37 | } |
2709 | 40 | 38 | ||
2710 | @@ -146,7 +144,7 @@ | |||
2711 | 146 | 144 | ||
2712 | 147 | function init() { | 145 | function init() { |
2713 | 148 | greeterSettings.lockedOutTime = 0; | 146 | greeterSettings.lockedOutTime = 0; |
2715 | 149 | LightDM.Greeter.selectUser = ""; | 147 | LightDMController.selectUserHint = ""; |
2716 | 150 | greeter.failedLoginsDelayAttempts = 7; | 148 | greeter.failedLoginsDelayAttempts = 7; |
2717 | 151 | greeter.failedLoginsDelayMinutes = 5; | 149 | greeter.failedLoginsDelayMinutes = 5; |
2718 | 152 | teaseSpy.clear(); | 150 | teaseSpy.clear(); |
2719 | @@ -570,20 +568,20 @@ | |||
2720 | 570 | } | 568 | } |
2721 | 571 | 569 | ||
2722 | 572 | function test_selectUserHint() { | 570 | function test_selectUserHint() { |
2724 | 573 | LightDM.Greeter.selectUser = "info-prompt"; | 571 | LightDMController.selectUserHint = "info-prompt"; |
2725 | 574 | resetLoader(); | 572 | resetLoader(); |
2726 | 575 | var i = verifySelected("info-prompt"); | 573 | var i = verifySelected("info-prompt"); |
2727 | 576 | verify(i != 0); // sanity-check that info-prompt isn't default 0 answer | 574 | verify(i != 0); // sanity-check that info-prompt isn't default 0 answer |
2728 | 577 | } | 575 | } |
2729 | 578 | 576 | ||
2730 | 579 | function test_selectUserHintUnset() { | 577 | function test_selectUserHintUnset() { |
2732 | 580 | LightDM.Greeter.selectUser = ""; | 578 | LightDMController.selectUserHint = ""; |
2733 | 581 | resetLoader(); | 579 | resetLoader(); |
2734 | 582 | verifySelected(LightDM.Users.data(0, LightDM.UserRoles.NameRole)); | 580 | verifySelected(LightDM.Users.data(0, LightDM.UserRoles.NameRole)); |
2735 | 583 | } | 581 | } |
2736 | 584 | 582 | ||
2737 | 585 | function test_selectUserHintInvalid() { | 583 | function test_selectUserHintInvalid() { |
2739 | 586 | LightDM.Greeter.selectUser = "not-a-real-user"; | 584 | LightDMController.selectUserHint = "not-a-real-user"; |
2740 | 587 | resetLoader(); | 585 | resetLoader(); |
2741 | 588 | verifySelected(LightDM.Users.data(0, LightDM.UserRoles.NameRole)); | 586 | verifySelected(LightDM.Users.data(0, LightDM.UserRoles.NameRole)); |
2742 | 589 | } | 587 | } |
2743 | 590 | 588 | ||
2744 | === modified file 'tests/qmltests/Greeter/tst_Infographics.qml' | |||
2745 | --- tests/qmltests/Greeter/tst_Infographics.qml 2016-10-25 08:14:40 +0000 | |||
2746 | +++ tests/qmltests/Greeter/tst_Infographics.qml 2017-01-17 15:40:09 +0000 | |||
2747 | @@ -20,19 +20,9 @@ | |||
2748 | 20 | import "../../../qml/Greeter" | 20 | import "../../../qml/Greeter" |
2749 | 21 | import Ubuntu.Components 1.3 | 21 | import Ubuntu.Components 1.3 |
2750 | 22 | import Unity.Test 0.1 as UT | 22 | import Unity.Test 0.1 as UT |
2752 | 23 | import LightDM.IntegratedLightDM 0.1 as LightDM | 23 | import LightDM.FullLightDM 0.1 as LightDM |
2753 | 24 | 24 | ||
2754 | 25 | Item { | 25 | Item { |
2755 | 26 | Binding { | ||
2756 | 27 | target: LightDM.Greeter | ||
2757 | 28 | property: "mockMode" | ||
2758 | 29 | value: "full" | ||
2759 | 30 | } | ||
2760 | 31 | Binding { | ||
2761 | 32 | target: LightDM.Users | ||
2762 | 33 | property: "mockMode" | ||
2763 | 34 | value: "full" | ||
2764 | 35 | } | ||
2765 | 36 | property variant infographicModel: LightDM.Infographic | 26 | property variant infographicModel: LightDM.Infographic |
2766 | 37 | 27 | ||
2767 | 38 | width: units.gu(120) | 28 | width: units.gu(120) |
2768 | 39 | 29 | ||
2769 | === modified file 'tests/qmltests/Greeter/tst_NarrowView.qml' | |||
2770 | --- tests/qmltests/Greeter/tst_NarrowView.qml 2016-08-30 20:23:15 +0000 | |||
2771 | +++ tests/qmltests/Greeter/tst_NarrowView.qml 2017-01-17 15:40:09 +0000 | |||
2772 | @@ -18,7 +18,8 @@ | |||
2773 | 18 | import QtTest 1.0 | 18 | import QtTest 1.0 |
2774 | 19 | import ".." | 19 | import ".." |
2775 | 20 | import "../../../qml/Greeter" | 20 | import "../../../qml/Greeter" |
2777 | 21 | import LightDM.IntegratedLightDM 0.1 as LightDM | 21 | import LightDMController 0.1 |
2778 | 22 | import LightDM.FullLightDM 0.1 as LightDM | ||
2779 | 22 | import Ubuntu.Components 1.3 | 23 | import Ubuntu.Components 1.3 |
2780 | 23 | import Ubuntu.Telephony 0.1 as Telephony | 24 | import Ubuntu.Telephony 0.1 as Telephony |
2781 | 24 | import Unity.Test 0.1 as UT | 25 | import Unity.Test 0.1 as UT |
2782 | @@ -30,6 +31,12 @@ | |||
2783 | 30 | 31 | ||
2784 | 31 | Component.onCompleted: theme.name = "Ubuntu.Components.Themes.SuruDark" // use the same theme as the real shell | 32 | Component.onCompleted: theme.name = "Ubuntu.Components.Themes.SuruDark" // use the same theme as the real shell |
2785 | 32 | 33 | ||
2786 | 34 | Binding { | ||
2787 | 35 | target: LightDMController | ||
2788 | 36 | property: "userMode" | ||
2789 | 37 | value: "single" | ||
2790 | 38 | } | ||
2791 | 39 | |||
2792 | 33 | Row { | 40 | Row { |
2793 | 34 | anchors.fill: parent | 41 | anchors.fill: parent |
2794 | 35 | Loader { | 42 | Loader { |
2795 | @@ -252,7 +259,7 @@ | |||
2796 | 252 | Binding { | 259 | Binding { |
2797 | 253 | target: LightDM.Infographic | 260 | target: LightDM.Infographic |
2798 | 254 | property: "username" | 261 | property: "username" |
2800 | 255 | value: "single" | 262 | value: "has-password" |
2801 | 256 | } | 263 | } |
2802 | 257 | 264 | ||
2803 | 258 | SignalSpy { | 265 | SignalSpy { |
2804 | 259 | 266 | ||
2805 | === modified file 'tests/qmltests/Greeter/tst_WideView.qml' | |||
2806 | --- tests/qmltests/Greeter/tst_WideView.qml 2016-08-30 14:06:47 +0000 | |||
2807 | +++ tests/qmltests/Greeter/tst_WideView.qml 2017-01-17 15:40:09 +0000 | |||
2808 | @@ -18,7 +18,8 @@ | |||
2809 | 18 | import QtTest 1.0 | 18 | import QtTest 1.0 |
2810 | 19 | import ".." | 19 | import ".." |
2811 | 20 | import "../../../qml/Greeter" | 20 | import "../../../qml/Greeter" |
2813 | 21 | import LightDM.IntegratedLightDM 0.1 as LightDM | 21 | import LightDMController 0.1 |
2814 | 22 | import LightDM.FullLightDM 0.1 as LightDM | ||
2815 | 22 | import Ubuntu.Components 1.3 | 23 | import Ubuntu.Components 1.3 |
2816 | 23 | import Unity.Test 0.1 as UT | 24 | import Unity.Test 0.1 as UT |
2817 | 24 | 25 | ||
2818 | @@ -31,12 +32,6 @@ | |||
2819 | 31 | 32 | ||
2820 | 32 | theme.name: "Ubuntu.Components.Themes.SuruDark" | 33 | theme.name: "Ubuntu.Components.Themes.SuruDark" |
2821 | 33 | 34 | ||
2822 | 34 | Binding { | ||
2823 | 35 | target: LightDM.Users | ||
2824 | 36 | property: "mockMode" | ||
2825 | 37 | value: "full" | ||
2826 | 38 | } | ||
2827 | 39 | |||
2828 | 40 | Row { | 35 | Row { |
2829 | 41 | anchors.fill: parent | 36 | anchors.fill: parent |
2830 | 42 | Loader { | 37 | Loader { |
2831 | @@ -271,15 +266,15 @@ | |||
2832 | 271 | id: multipleSessionsCheckbox | 266 | id: multipleSessionsCheckbox |
2833 | 272 | onClicked: { | 267 | onClicked: { |
2834 | 273 | if (checked) { | 268 | if (checked) { |
2836 | 274 | LightDM.Sessions.testScenario = "multipleSessions" | 269 | LightDMController.sessionMode = "full"; |
2837 | 275 | } else { | 270 | } else { |
2839 | 276 | LightDM.Sessions.testScenario = "singleSession" | 271 | LightDMController.sessionMode = "single"; |
2840 | 277 | } | 272 | } |
2841 | 278 | } | 273 | } |
2842 | 279 | Connections { | 274 | Connections { |
2846 | 280 | target: LightDM.Sessions | 275 | target: LightDMController |
2847 | 281 | onTestScenarioChanged: { | 276 | onSessionModeChanged: { |
2848 | 282 | if (LightDM.Sessions.testScenario === "multipleSessions") { | 277 | if (LightDMController.sessionMode === "full") { |
2849 | 283 | multipleSessionsCheckbox.checked = true; | 278 | multipleSessionsCheckbox.checked = true; |
2850 | 284 | } else { | 279 | } else { |
2851 | 285 | multipleSessionsCheckbox.checked = false; | 280 | multipleSessionsCheckbox.checked = false; |
2852 | @@ -297,11 +292,11 @@ | |||
2853 | 297 | 292 | ||
2854 | 298 | width: units.gu(10) | 293 | width: units.gu(10) |
2855 | 299 | minimumValue: 0 | 294 | minimumValue: 0 |
2859 | 300 | maximumValue: LightDM.Sessions.numAvailableSessions | 295 | maximumValue: LightDMController.numAvailableSessions |
2860 | 301 | value: LightDM.Sessions.numSessions | 296 | value: LightDMController.numSessions |
2861 | 302 | visible: LightDM.Sessions.testScenario === "multipleSessions" | 297 | visible: LightDMController.sessionMode === "full" |
2862 | 303 | Binding { | 298 | Binding { |
2864 | 304 | target: LightDM.Sessions | 299 | target: LightDMController |
2865 | 305 | property: "numSessions" | 300 | property: "numSessions" |
2866 | 306 | value: numSessionsSlider.value | 301 | value: numSessionsSlider.value |
2867 | 307 | } | 302 | } |
2868 | @@ -368,7 +363,8 @@ | |||
2869 | 368 | respondedSpy.clear(); | 363 | respondedSpy.clear(); |
2870 | 369 | teaseSpy.clear(); | 364 | teaseSpy.clear(); |
2871 | 370 | emergencySpy.clear(); | 365 | emergencySpy.clear(); |
2873 | 371 | LightDM.Sessions.testScenario = "multipleSessions" | 366 | LightDMController.sessionMode = "full"; |
2874 | 367 | LightDM.Sessions.iconSearchDirectories = [testIconDirectory]; | ||
2875 | 372 | } | 368 | } |
2876 | 373 | 369 | ||
2877 | 374 | function cleanup() { | 370 | function cleanup() { |
2878 | @@ -426,10 +422,6 @@ | |||
2879 | 426 | } | 422 | } |
2880 | 427 | 423 | ||
2881 | 428 | function test_sessionIconsAreValid() { | 424 | function test_sessionIconsAreValid() { |
2882 | 429 | LightDM.Sessions.testScenario = "multipleSessions" | ||
2883 | 430 | var originalDirectories = LightDM.Sessions.iconSearchDirectories | ||
2884 | 431 | LightDM.Sessions.iconSearchDirectories = [testIconDirectory] | ||
2885 | 432 | |||
2886 | 433 | selectUser("has-password"); | 425 | selectUser("has-password"); |
2887 | 434 | 426 | ||
2888 | 435 | // Test the login list icon is valid | 427 | // Test the login list icon is valid |
2889 | @@ -449,12 +441,10 @@ | |||
2890 | 449 | 441 | ||
2891 | 450 | function test_choosingNewSessionChangesLoginListIcon() { | 442 | function test_choosingNewSessionChangesLoginListIcon() { |
2892 | 451 | // Ensure the default session is selected (Ubuntu) | 443 | // Ensure the default session is selected (Ubuntu) |
2895 | 452 | loader.active = false; | 444 | cleanup(); |
2894 | 453 | loader.active = true; | ||
2896 | 454 | 445 | ||
2897 | 455 | selectUser("has-password"); | 446 | selectUser("has-password"); |
2898 | 456 | 447 | ||
2899 | 457 | LightDM.Sessions.testScenario = "multipleSessions"; | ||
2900 | 458 | var sessionChooserButton = findChild(view, "sessionChooserButton"); | 448 | var sessionChooserButton = findChild(view, "sessionChooserButton"); |
2901 | 459 | var icon = String(sessionChooserButton.icon); | 449 | var icon = String(sessionChooserButton.icon); |
2902 | 460 | compare(icon.indexOf("ubuntu") > -1, true); | 450 | compare(icon.indexOf("ubuntu") > -1, true); |
2903 | @@ -465,25 +455,25 @@ | |||
2904 | 465 | var currentDelegate = findChild(view, delegateName); | 455 | var currentDelegate = findChild(view, delegateName); |
2905 | 466 | var sessionKey = LightDM.Sessions.data(i,LightDM.SessionRoles.KeyRole); | 456 | var sessionKey = LightDM.Sessions.data(i,LightDM.SessionRoles.KeyRole); |
2906 | 467 | if (sessionKey === "gnome-classic") { | 457 | if (sessionKey === "gnome-classic") { |
2907 | 458 | waitForRendering(currentDelegate); | ||
2908 | 468 | tap(currentDelegate); | 459 | tap(currentDelegate); |
2909 | 469 | var sessionChooserButton = findChild(view, "sessionChooserButton"); | ||
2910 | 470 | waitForRendering(sessionChooserButton); | 460 | waitForRendering(sessionChooserButton); |
2911 | 471 | var icon = String(sessionChooserButton.icon); | ||
2912 | 472 | break; | 461 | break; |
2913 | 473 | } | 462 | } |
2914 | 474 | } | 463 | } |
2915 | 475 | 464 | ||
2916 | 465 | icon = String(sessionChooserButton.icon); | ||
2917 | 476 | compare(icon.indexOf("gnome") > -1, true, | 466 | compare(icon.indexOf("gnome") > -1, true, |
2918 | 477 | "Expected icon to contain gnome but it was " + icon); | 467 | "Expected icon to contain gnome but it was " + icon); |
2919 | 478 | } | 468 | } |
2920 | 479 | 469 | ||
2921 | 480 | function test_noSessionsDoesntBreakView() { | 470 | function test_noSessionsDoesntBreakView() { |
2923 | 481 | LightDM.Sessions.testScenario = "noSessions" | 471 | LightDMController.sessionMode = "none"; |
2924 | 482 | compare(LightDM.Sessions.count, 0) | 472 | compare(LightDM.Sessions.count, 0) |
2925 | 483 | } | 473 | } |
2926 | 484 | 474 | ||
2927 | 485 | function test_sessionIconNotShownWithOneSession() { | 475 | function test_sessionIconNotShownWithOneSession() { |
2929 | 486 | LightDM.Sessions.testScenario = "singleSession" | 476 | LightDMController.sessionMode = "single"; |
2930 | 487 | compare(LightDM.Sessions.count, 1); | 477 | compare(LightDM.Sessions.count, 1); |
2931 | 488 | 478 | ||
2932 | 489 | var sessionChooserButton = findChild(view, "sessionChooserButton"); | 479 | var sessionChooserButton = findChild(view, "sessionChooserButton"); |
2933 | @@ -491,7 +481,7 @@ | |||
2934 | 491 | } | 481 | } |
2935 | 492 | 482 | ||
2936 | 493 | function test_sessionIconNotShownWithActiveUser() { | 483 | function test_sessionIconNotShownWithActiveUser() { |
2938 | 494 | LightDM.Sessions.testScenario = "multipleSessions"; | 484 | LightDMController.sessionMode = "full"; |
2939 | 495 | compare(LightDM.Sessions.count > 1, true); | 485 | compare(LightDM.Sessions.count > 1, true); |
2940 | 496 | 486 | ||
2941 | 497 | selectUser("active"); | 487 | selectUser("active"); |
2942 | @@ -501,7 +491,7 @@ | |||
2943 | 501 | } | 491 | } |
2944 | 502 | 492 | ||
2945 | 503 | function test_sessionIconShownWithMultipleSessions() { | 493 | function test_sessionIconShownWithMultipleSessions() { |
2947 | 504 | LightDM.Sessions.testScenario = "multipleSessions" | 494 | LightDMController.sessionMode = "full"; |
2948 | 505 | compare(LightDM.Sessions.count > 1, true); | 495 | compare(LightDM.Sessions.count > 1, true); |
2949 | 506 | 496 | ||
2950 | 507 | selectUser("has-password"); | 497 | selectUser("has-password"); |
2951 | 508 | 498 | ||
2952 | === modified file 'tests/qmltests/Tutorial/tst_Tutorial.qml' | |||
2953 | --- tests/qmltests/Tutorial/tst_Tutorial.qml 2016-12-05 14:08:55 +0000 | |||
2954 | +++ tests/qmltests/Tutorial/tst_Tutorial.qml 2017-01-17 15:40:09 +0000 | |||
2955 | @@ -17,7 +17,8 @@ | |||
2956 | 17 | import QtQuick 2.4 | 17 | import QtQuick 2.4 |
2957 | 18 | import QtTest 1.0 | 18 | import QtTest 1.0 |
2958 | 19 | import AccountsService 0.1 | 19 | import AccountsService 0.1 |
2960 | 20 | import LightDM.IntegratedLightDM 0.1 as LightDM | 20 | import LightDMController 0.1 |
2961 | 21 | import LightDM.FullLightDM 0.1 as LightDM | ||
2962 | 21 | import Ubuntu.Components 1.3 | 22 | import Ubuntu.Components 1.3 |
2963 | 22 | import Ubuntu.Components.ListItems 1.3 | 23 | import Ubuntu.Components.ListItems 1.3 |
2964 | 23 | import Ubuntu.Telephony 0.1 as Telephony | 24 | import Ubuntu.Telephony 0.1 as Telephony |
2965 | @@ -85,8 +86,7 @@ | |||
2966 | 85 | 86 | ||
2967 | 86 | Component.onCompleted: { | 87 | Component.onCompleted: { |
2968 | 87 | // must set the mock mode before loading the Shell | 88 | // must set the mock mode before loading the Shell |
2971 | 88 | LightDM.Greeter.mockMode = "single-pin"; | 89 | LightDMController.userMode = "single-pin"; |
2970 | 89 | LightDM.Users.mockMode = "single-pin"; | ||
2972 | 90 | shellLoader.active = true; | 90 | shellLoader.active = true; |
2973 | 91 | } | 91 | } |
2974 | 92 | 92 | ||
2975 | 93 | 93 | ||
2976 | === modified file 'tests/qmltests/tst_OrientedShell.qml' | |||
2977 | --- tests/qmltests/tst_OrientedShell.qml 2016-12-12 16:45:09 +0000 | |||
2978 | +++ tests/qmltests/tst_OrientedShell.qml 2017-01-17 15:40:09 +0000 | |||
2979 | @@ -22,7 +22,8 @@ | |||
2980 | 22 | import Ubuntu.Components.ListItems 1.3 as ListItem | 22 | import Ubuntu.Components.ListItems 1.3 as ListItem |
2981 | 23 | import Unity.Application 0.1 | 23 | import Unity.Application 0.1 |
2982 | 24 | import Unity.Test 0.1 | 24 | import Unity.Test 0.1 |
2984 | 25 | import LightDM.IntegratedLightDM 0.1 as LightDM | 25 | import LightDMController 0.1 |
2985 | 26 | import LightDM.FullLightDM 0.1 as LightDM | ||
2986 | 26 | import Powerd 0.1 | 27 | import Powerd 0.1 |
2987 | 27 | import Unity.InputInfo 0.1 | 28 | import Unity.InputInfo 0.1 |
2988 | 28 | import Utils 0.1 | 29 | import Utils 0.1 |
2989 | @@ -38,6 +39,12 @@ | |||
2990 | 38 | width: units.gu(160) + controls.width | 39 | width: units.gu(160) + controls.width |
2991 | 39 | height: units.gu(100) | 40 | height: units.gu(100) |
2992 | 40 | 41 | ||
2993 | 42 | Binding { | ||
2994 | 43 | target: LightDMController | ||
2995 | 44 | property: "userMode" | ||
2996 | 45 | value: "single" | ||
2997 | 46 | } | ||
2998 | 47 | |||
2999 | 41 | QtObject { | 48 | QtObject { |
3000 | 42 | id: applicationArguments | 49 | id: applicationArguments |
3001 | 43 | property string deviceName: "mako" | 50 | property string deviceName: "mako" |
3002 | 44 | 51 | ||
3003 | === modified file 'tests/qmltests/tst_Shell.qml' | |||
3004 | --- tests/qmltests/tst_Shell.qml 2017-01-09 14:10:17 +0000 | |||
3005 | +++ tests/qmltests/tst_Shell.qml 2017-01-17 15:40:09 +0000 | |||
3006 | @@ -18,7 +18,8 @@ | |||
3007 | 18 | import QtTest 1.0 | 18 | import QtTest 1.0 |
3008 | 19 | import AccountsService 0.1 | 19 | import AccountsService 0.1 |
3009 | 20 | import GSettings 1.0 | 20 | import GSettings 1.0 |
3011 | 21 | import LightDM.IntegratedLightDM 0.1 as LightDM | 21 | import LightDMController 0.1 |
3012 | 22 | import LightDM.FullLightDM 0.1 as LightDM | ||
3013 | 22 | import SessionBroadcast 0.1 | 23 | import SessionBroadcast 0.1 |
3014 | 23 | import Ubuntu.Components 1.3 | 24 | import Ubuntu.Components 1.3 |
3015 | 24 | import Ubuntu.Components.ListItems 1.3 as ListItem | 25 | import Ubuntu.Components.ListItems 1.3 as ListItem |
3016 | @@ -48,8 +49,7 @@ | |||
3017 | 48 | 49 | ||
3018 | 49 | Component.onCompleted: { | 50 | Component.onCompleted: { |
3019 | 50 | // must set the mock mode before loading the Shell | 51 | // must set the mock mode before loading the Shell |
3022 | 51 | LightDM.Greeter.mockMode = "single"; | 52 | LightDMController.userMode = "single"; |
3021 | 52 | LightDM.Users.mockMode = "single"; | ||
3023 | 53 | shellLoader.active = true; | 53 | shellLoader.active = true; |
3024 | 54 | } | 54 | } |
3025 | 55 | 55 | ||
3026 | @@ -248,8 +248,7 @@ | |||
3027 | 248 | model: ["single", "single-passphrase", "single-pin", "full"] | 248 | model: ["single", "single-passphrase", "single-pin", "full"] |
3028 | 249 | onSelectedIndexChanged: { | 249 | onSelectedIndexChanged: { |
3029 | 250 | testCase.tearDown(); | 250 | testCase.tearDown(); |
3032 | 251 | LightDM.Greeter.mockMode = model[selectedIndex]; | 251 | LightDMController.userMode = model[selectedIndex]; |
3031 | 252 | LightDM.Users.mockMode = model[selectedIndex]; | ||
3033 | 253 | shellLoader.active = true; | 252 | shellLoader.active = true; |
3034 | 254 | } | 253 | } |
3035 | 255 | } | 254 | } |
3036 | @@ -881,8 +880,7 @@ | |||
3037 | 881 | } | 880 | } |
3038 | 882 | 881 | ||
3039 | 883 | function setLightDMMockMode(mode) { | 882 | function setLightDMMockMode(mode) { |
3042 | 884 | LightDM.Greeter.mockMode = mode; | 883 | LightDMController.userMode = mode; |
3041 | 885 | LightDM.Users.mockMode = mode; | ||
3043 | 886 | } | 884 | } |
3044 | 887 | 885 | ||
3045 | 888 | function test_showInputMethod() { | 886 | function test_showInputMethod() { |
3046 | 889 | 887 | ||
3047 | === modified file 'tests/qmltests/tst_ShellWithPin.qml' | |||
3048 | --- tests/qmltests/tst_ShellWithPin.qml 2017-01-03 12:04:08 +0000 | |||
3049 | +++ tests/qmltests/tst_ShellWithPin.qml 2017-01-17 15:40:09 +0000 | |||
3050 | @@ -19,7 +19,8 @@ | |||
3051 | 19 | import QtTest 1.0 | 19 | import QtTest 1.0 |
3052 | 20 | import AccountsService 0.1 | 20 | import AccountsService 0.1 |
3053 | 21 | import GSettings 1.0 | 21 | import GSettings 1.0 |
3055 | 22 | import LightDM.IntegratedLightDM 0.1 as LightDM | 22 | import LightDMController 0.1 |
3056 | 23 | import LightDM.FullLightDM 0.1 as LightDM | ||
3057 | 23 | import Ubuntu.SystemImage 0.1 | 24 | import Ubuntu.SystemImage 0.1 |
3058 | 24 | import Ubuntu.Telephony 0.1 as Telephony | 25 | import Ubuntu.Telephony 0.1 as Telephony |
3059 | 25 | import Unity.Application 0.1 | 26 | import Unity.Application 0.1 |
3060 | @@ -35,8 +36,7 @@ | |||
3061 | 35 | 36 | ||
3062 | 36 | Component.onCompleted: { | 37 | Component.onCompleted: { |
3063 | 37 | // must set the mock mode before loading the Shell | 38 | // must set the mock mode before loading the Shell |
3066 | 38 | LightDM.Greeter.mockMode = "single-pin"; | 39 | LightDMController.userMode = "single-pin"; |
3065 | 39 | LightDM.Users.mockMode = "single-pin"; | ||
3067 | 40 | shellLoader.active = true; | 40 | shellLoader.active = true; |
3068 | 41 | } | 41 | } |
3069 | 42 | 42 |
FAILED: Continuous integration, rev:2744 /unity8- jenkins. ubuntu. com/job/ lp-unity8- ci/2731/ /unity8- jenkins. ubuntu. com/job/ build/3586 /unity8- jenkins. ubuntu. com/job/ test-0- autopkgtest/ label=amd64, release= xenial+ overlay, testname= qmluitests. sh/2050 /unity8- jenkins. ubuntu. com/job/ test-0- autopkgtest/ label=amd64, release= zesty,testname= qmluitests. sh/2050 /unity8- jenkins. ubuntu. com/job/ build-0- fetch/3614 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=amd64, release= xenial+ overlay/ 3460 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=amd64, release= xenial+ overlay/ 3460/artifact/ output/ *zip*/output. zip /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=amd64, release= zesty/3460 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=amd64, release= zesty/3460/ artifact/ output/ *zip*/output. zip /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=armhf, release= xenial+ overlay/ 3460 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=armhf, release= xenial+ overlay/ 3460/artifact/ output/ *zip*/output. zip /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=armhf, release= zesty/3460 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=armhf, release= zesty/3460/ artifact/ output/ *zip*/output. zip /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=i386, release= xenial+ overlay/ 3460 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=i386, release= xenial+ overlay/ 3460/artifact/ output/ *zip*/output. zip /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=i386, release= zesty/3460 /unity8- jenkins. ubuntu. com/job/ build-2- binpkg/ arch=i386, release= zesty/3460/ artifact/ output/ *zip*/output. zip
https:/
Executed test runs:
SUCCESS: https:/
UNSTABLE: https:/
UNSTABLE: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild: /unity8- jenkins. ubuntu. com/job/ lp-unity8- ci/2731/ rebuild
https:/