Merge lp:~dandrader/unity8/keepGreeterPwdUncovered into lp:unity8
- keepGreeterPwdUncovered
- Merge into trunk
| Status: | Superseded |
|---|---|
| Proposed branch: | lp:~dandrader/unity8/keepGreeterPwdUncovered |
| Merge into: | lp:unity8 |
| Diff against target: |
3495 lines (+1789/-945) 61 files modified
plugins/LightDM/CMakeLists.txt (+3/-1) plugins/LightDM/Greeter.cpp (+1/-19) plugins/LightDM/Greeter.h (+1/-1) plugins/LightDM/GreeterPrivate.h (+39/-0) plugins/LightDM/liblightdm/CMakeLists.txt (+37/-0) plugins/LightDM/liblightdm/Greeter.cpp (+184/-0) plugins/LightDM/liblightdm/Greeter.h (+112/-0) plugins/LightDM/liblightdm/GreeterPrivate.cpp (+281/-0) plugins/LightDM/liblightdm/GreeterPrivate.h (+51/-0) plugins/LightDM/liblightdm/UsersModel.cpp (+123/-0) plugins/LightDM/liblightdm/UsersModel.h (+66/-0) plugins/LightDM/liblightdm/UsersModelPrivate.cpp (+41/-0) plugins/LightDM/liblightdm/UsersModelPrivate.h (+59/-0) qml/Greeter/Greeter.qml (+8/-0) qml/Greeter/GreeterContent.qml (+6/-2) run.sh (+3/-26) tests/autopilot/unity8/shell/__init__.py (+0/-13) tests/autopilot/unity8/shell/tests/__init__.py (+8/-11) tests/autopilot/unity8/shell/tests/test_edges_demo.py (+0/-1) tests/autopilot/unity8/shell/tests/test_lock_screen.py (+6/-5) tests/mocks/LightDM/CMakeLists.txt (+8/-9) tests/mocks/LightDM/MockGreeter.cpp (+35/-0) tests/mocks/LightDM/MockGreeter.h (+37/-0) tests/mocks/LightDM/MockUsersModel.cpp (+39/-0) tests/mocks/LightDM/MockUsersModel.h (+37/-0) tests/mocks/LightDM/QLightDM/Greeter (+17/-0) tests/mocks/LightDM/QLightDM/UsersModel (+17/-0) tests/mocks/LightDM/demo/CMakeLists.txt (+0/-37) tests/mocks/LightDM/demo/GreeterPrivate.cpp (+0/-281) tests/mocks/LightDM/demo/UsersModelPrivate.cpp (+0/-41) tests/mocks/LightDM/full/CMakeLists.txt (+0/-18) tests/mocks/LightDM/full/GreeterPrivate.cpp (+0/-98) tests/mocks/LightDM/full/UsersModelPrivate.cpp (+0/-52) tests/mocks/LightDM/liblightdm/CMakeLists.txt (+18/-0) tests/mocks/LightDM/liblightdm/Greeter.cpp (+18/-3) tests/mocks/LightDM/liblightdm/Greeter.h (+7/-0) tests/mocks/LightDM/liblightdm/GreeterPrivate.cpp (+132/-0) tests/mocks/LightDM/liblightdm/GreeterPrivate.h (+5/-3) tests/mocks/LightDM/liblightdm/UsersModel.cpp (+17/-0) tests/mocks/LightDM/liblightdm/UsersModel.h (+10/-3) tests/mocks/LightDM/liblightdm/UsersModelPrivate.cpp (+104/-0) tests/mocks/LightDM/liblightdm/UsersModelPrivate.h (+7/-3) tests/mocks/LightDM/plugin.cpp (+68/-0) tests/mocks/LightDM/plugin.h (+32/-0) tests/mocks/LightDM/single-passphrase/CMakeLists.txt (+0/-19) tests/mocks/LightDM/single-passphrase/GreeterPrivate.cpp (+0/-46) tests/mocks/LightDM/single-passphrase/UsersModelPrivate.cpp (+0/-33) tests/mocks/LightDM/single-pin/CMakeLists.txt (+0/-19) tests/mocks/LightDM/single-pin/GreeterPrivate.cpp (+0/-46) tests/mocks/LightDM/single-pin/UsersModelPrivate.cpp (+0/-33) tests/mocks/LightDM/single/CMakeLists.txt (+0/-18) tests/mocks/LightDM/single/GreeterPrivate.cpp (+0/-46) tests/mocks/LightDM/single/UsersModelPrivate.cpp (+0/-33) tests/plugins/LightDM/CMakeLists.txt (+3/-3) tests/plugins/LightDM/greeter.qml (+5/-0) tests/qmltests/CMakeLists.txt (+19/-19) tests/qmltests/Greeter/tst_Infographics.qml (+10/-0) tests/qmltests/Greeter/tst_MultiGreeter.qml (+91/-2) tests/qmltests/tst_Shell.qml (+8/-1) tests/qmltests/tst_ShellWithPin.qml (+8/-0) tests/qmltests/tst_TabletShell.qml (+8/-0) |
| To merge this branch: | bzr merge lp:~dandrader/unity8/keepGreeterPwdUncovered |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| PS Jenkins bot | continuous-integration | Needs Fixing on 2015-01-28 | |
| Albert Astals Cid (community) | 2015-01-23 | Approve on 2015-01-28 | |
|
Review via email:
|
|||
This proposal has been superseded by a proposal from 2015-02-02.
Commit Message
Ensure the greeter password field is not covered by the keyboard
Description of the Change
This happens in tablet mode.
* Are there any related MPs required for this MP to build/function as expected? Please list.
No
* Did you perform an exploratory manual test run of your code change and any related functionality?
Yes
* Did you make sure that your branch does not contain spurious tags?
Yes
* If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
Not applicable
* If you changed the UI, has there been a design review?
Not applicable
- 1571. By Daniel d'Andrada on 2015-01-28
-
Remove debug left overs
| Albert Astals Cid (aacid) wrote : | # |
Personally i think a bit faster animation may be a better idea, but that's just my personal taste and i'm not the best person for these kind of UI decissions so just ignore :D
* 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.
No, but only on unrelated known broken tests
* Did you make sure that the branch does not contain spurious tags?
Yes
| PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1571
http://
Executed test runs:
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 1572. By Daniel d'Andrada on 2015-02-02
Unmerged revisions
Preview Diff
| 1 | === modified file 'plugins/LightDM/CMakeLists.txt' |
| 2 | --- plugins/LightDM/CMakeLists.txt 2014-12-19 14:51:35 +0000 |
| 3 | +++ plugins/LightDM/CMakeLists.txt 2015-02-02 14:28:47 +0000 |
| 4 | @@ -4,6 +4,8 @@ |
| 5 | # TODO: Once we split out a separate greeter process, uncomment these lines |
| 6 | #pkg_check_modules(LIBLIGHTDM REQUIRED liblightdm-qt5-2) |
| 7 | |
| 8 | +add_subdirectory(liblightdm) |
| 9 | + |
| 10 | include_directories( |
| 11 | ${CMAKE_CURRENT_SOURCE_DIR} |
| 12 | ${CMAKE_CURRENT_BINARY_DIR} |
| 13 | @@ -28,7 +30,7 @@ |
| 14 | ) |
| 15 | |
| 16 | target_link_libraries(LightDM-qml |
| 17 | - MockLightDM-demo |
| 18 | + integratedLightDM |
| 19 | unity8-private |
| 20 | # TODO: Once we split out a separate greeter process, uncomment these lines |
| 21 | # ${LIBLIGHTDM_LDFLAGS} |
| 22 | |
| 23 | === modified file 'plugins/LightDM/Greeter.cpp' |
| 24 | --- plugins/LightDM/Greeter.cpp 2014-10-09 14:53:00 +0000 |
| 25 | +++ plugins/LightDM/Greeter.cpp 2015-02-02 14:28:47 +0000 |
| 26 | @@ -17,26 +17,8 @@ |
| 27 | */ |
| 28 | |
| 29 | #include "Greeter.h" |
| 30 | +#include "GreeterPrivate.h" |
| 31 | #include <libintl.h> |
| 32 | -#include <QLightDM/Greeter> |
| 33 | - |
| 34 | -class GreeterPrivate |
| 35 | -{ |
| 36 | -public: |
| 37 | - explicit GreeterPrivate(Greeter *parent); |
| 38 | - |
| 39 | - QLightDM::Greeter *m_greeter; |
| 40 | - bool m_active; |
| 41 | - bool wasPrompted; |
| 42 | - bool promptless; |
| 43 | - |
| 44 | -protected: |
| 45 | - Greeter * const q_ptr; |
| 46 | - |
| 47 | -private: |
| 48 | - Q_DECLARE_PUBLIC(Greeter) |
| 49 | -}; |
| 50 | - |
| 51 | |
| 52 | GreeterPrivate::GreeterPrivate(Greeter* parent) |
| 53 | : m_greeter(new QLightDM::Greeter(parent)), |
| 54 | |
| 55 | === modified file 'plugins/LightDM/Greeter.h' |
| 56 | --- plugins/LightDM/Greeter.h 2014-10-09 14:53:00 +0000 |
| 57 | +++ plugins/LightDM/Greeter.h 2015-02-02 14:28:47 +0000 |
| 58 | @@ -68,7 +68,7 @@ |
| 59 | // should switch to this user if possible. |
| 60 | void requestAuthenticationUser(const QString &user); |
| 61 | |
| 62 | -private: |
| 63 | +protected: |
| 64 | GreeterPrivate * const d_ptr; |
| 65 | |
| 66 | Q_DECLARE_PRIVATE(Greeter) |
| 67 | |
| 68 | === added file 'plugins/LightDM/GreeterPrivate.h' |
| 69 | --- plugins/LightDM/GreeterPrivate.h 1970-01-01 00:00:00 +0000 |
| 70 | +++ plugins/LightDM/GreeterPrivate.h 2015-02-02 14:28:47 +0000 |
| 71 | @@ -0,0 +1,39 @@ |
| 72 | +/* |
| 73 | + * Copyright (C) 2014 Canonical, Ltd. |
| 74 | + * |
| 75 | + * This program is free software; you can redistribute it and/or modify |
| 76 | + * it under the terms of the GNU General Public License as published by |
| 77 | + * the Free Software Foundation; version 3. |
| 78 | + * |
| 79 | + * This program is distributed in the hope that it will be useful, |
| 80 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 81 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 82 | + * GNU General Public License for more details. |
| 83 | + * |
| 84 | + * You should have received a copy of the GNU General Public License |
| 85 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 86 | + */ |
| 87 | + |
| 88 | +#ifndef UNITY_GREETER_PRIVATE_H |
| 89 | +#define UNITY_GREETER_PRIVATE_H |
| 90 | + |
| 91 | +#include <QLightDM/Greeter> |
| 92 | + |
| 93 | +class GreeterPrivate |
| 94 | +{ |
| 95 | +public: |
| 96 | + explicit GreeterPrivate(Greeter *parent); |
| 97 | + |
| 98 | + QLightDM::Greeter *m_greeter; |
| 99 | + bool m_active; |
| 100 | + bool wasPrompted; |
| 101 | + bool promptless; |
| 102 | + |
| 103 | +protected: |
| 104 | + Greeter * const q_ptr; |
| 105 | + |
| 106 | +private: |
| 107 | + Q_DECLARE_PUBLIC(Greeter) |
| 108 | +}; |
| 109 | + |
| 110 | +#endif // UNITY_GREETER_PRIVATE_H |
| 111 | |
| 112 | === added directory 'plugins/LightDM/liblightdm' |
| 113 | === added file 'plugins/LightDM/liblightdm/CMakeLists.txt' |
| 114 | --- plugins/LightDM/liblightdm/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
| 115 | +++ plugins/LightDM/liblightdm/CMakeLists.txt 2015-02-02 14:28:47 +0000 |
| 116 | @@ -0,0 +1,37 @@ |
| 117 | +pkg_check_modules(LIBUSERMETRICSOUTPUT REQUIRED libusermetricsoutput-1) |
| 118 | + |
| 119 | +set(LibLightDM_SOURCES |
| 120 | + Greeter.cpp |
| 121 | + UsersModel.cpp |
| 122 | + GreeterPrivate.cpp |
| 123 | + UsersModelPrivate.cpp |
| 124 | + ${CMAKE_SOURCE_DIR}/plugins/Utils/qvariantlistmodel.cpp |
| 125 | + ) |
| 126 | + |
| 127 | +add_library(integratedLightDM STATIC ${LibLightDM_SOURCES}) |
| 128 | +add_library(MockLightDM-demo-shared SHARED ${LibLightDM_SOURCES}) |
| 129 | + |
| 130 | +include_directories( |
| 131 | + ${CMAKE_CURRENT_BINARY_DIR} |
| 132 | + ${LIBUSERMETRICSOUTPUT_INCLUDE_DIRS} |
| 133 | +) |
| 134 | + |
| 135 | +target_link_libraries(integratedLightDM |
| 136 | + ${LIBUSERMETRICSOUTPUT_LDFLAGS} |
| 137 | + -lpam |
| 138 | +) |
| 139 | +target_link_libraries(MockLightDM-demo-shared |
| 140 | + ${LIBUSERMETRICSOUTPUT_LDFLAGS} |
| 141 | + -lpam |
| 142 | +) |
| 143 | + |
| 144 | +qt5_use_modules(integratedLightDM Concurrent Gui) |
| 145 | +qt5_use_modules(MockLightDM-demo-shared Concurrent Gui) |
| 146 | + |
| 147 | +set_target_properties(integratedLightDM PROPERTIES COMPILE_FLAGS -fPIC) |
| 148 | +set_target_properties(MockLightDM-demo-shared PROPERTIES |
| 149 | + OUTPUT_NAME lightdm-qt5-2) |
| 150 | + |
| 151 | +install(TARGETS MockLightDM-demo-shared |
| 152 | + DESTINATION ${SHELL_INSTALL_QML}/mocks/LightDM/demo |
| 153 | + ) |
| 154 | |
| 155 | === added file 'plugins/LightDM/liblightdm/Greeter.cpp' |
| 156 | --- plugins/LightDM/liblightdm/Greeter.cpp 1970-01-01 00:00:00 +0000 |
| 157 | +++ plugins/LightDM/liblightdm/Greeter.cpp 2015-02-02 14:28:47 +0000 |
| 158 | @@ -0,0 +1,184 @@ |
| 159 | +/* |
| 160 | + * Copyright (C) 2013 Canonical, Ltd. |
| 161 | + * |
| 162 | + * This program is free software; you can redistribute it and/or modify |
| 163 | + * it under the terms of the GNU General Public License as published by |
| 164 | + * the Free Software Foundation; version 3. |
| 165 | + * |
| 166 | + * This program is distributed in the hope that it will be useful, |
| 167 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 168 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 169 | + * GNU General Public License for more details. |
| 170 | + * |
| 171 | + * You should have received a copy of the GNU General Public License |
| 172 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 173 | + * |
| 174 | + * Author: Michael Terry <michael.terry@canonical.com> |
| 175 | + */ |
| 176 | + |
| 177 | + |
| 178 | +/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 179 | + * CHANGES MADE HERE MUST BE REFLECTED ON THE MOCK LIB |
| 180 | + * COUNTERPART IN tests/mocks/Lightdm/liblightdm |
| 181 | + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ |
| 182 | + |
| 183 | + |
| 184 | +#include "Greeter.h" |
| 185 | +#include "GreeterPrivate.h" |
| 186 | +#include <QtCore/QCoreApplication> |
| 187 | +#include <QTimer> |
| 188 | + |
| 189 | +namespace QLightDM |
| 190 | +{ |
| 191 | + |
| 192 | +Greeter::Greeter(QObject *parent) |
| 193 | + : QObject(parent), |
| 194 | + d_ptr(new GreeterPrivate(this)) |
| 195 | +{ |
| 196 | +} |
| 197 | + |
| 198 | +Greeter::~Greeter() |
| 199 | +{ |
| 200 | +} |
| 201 | + |
| 202 | +QString Greeter::authenticationUser() const |
| 203 | +{ |
| 204 | + Q_D(const Greeter); |
| 205 | + return d->authenticationUser; |
| 206 | +} |
| 207 | + |
| 208 | +bool Greeter::hasGuestAccountHint() const |
| 209 | +{ |
| 210 | + return true; |
| 211 | +} |
| 212 | + |
| 213 | +QString Greeter::getHint(const QString &name) const |
| 214 | +{ |
| 215 | + Q_UNUSED(name) |
| 216 | + return ""; |
| 217 | +} |
| 218 | + |
| 219 | +QString Greeter::defaultSessionHint() const |
| 220 | +{ |
| 221 | + return "ubuntu"; |
| 222 | +} |
| 223 | + |
| 224 | +bool Greeter::hideUsersHint() const |
| 225 | +{ |
| 226 | + return false; |
| 227 | +} |
| 228 | + |
| 229 | +bool Greeter::showManualLoginHint() const |
| 230 | +{ |
| 231 | + return true; |
| 232 | +} |
| 233 | + |
| 234 | +bool Greeter::showRemoteLoginHint() const |
| 235 | +{ |
| 236 | + return true; |
| 237 | +} |
| 238 | + |
| 239 | +bool Greeter::lockHint () const |
| 240 | +{ |
| 241 | + return false; |
| 242 | +} |
| 243 | + |
| 244 | +QString Greeter::selectUserHint() const |
| 245 | +{ |
| 246 | + return ""; |
| 247 | +} |
| 248 | + |
| 249 | +bool Greeter::selectGuestHint() const |
| 250 | +{ |
| 251 | + return false; |
| 252 | +} |
| 253 | + |
| 254 | +QString Greeter::autologinUserHint() const |
| 255 | +{ |
| 256 | + return ""; |
| 257 | +} |
| 258 | + |
| 259 | +bool Greeter::autologinGuestHint() const |
| 260 | +{ |
| 261 | + return false; |
| 262 | +} |
| 263 | + |
| 264 | +int Greeter::autologinTimeoutHint() const |
| 265 | +{ |
| 266 | + return 0; |
| 267 | +} |
| 268 | + |
| 269 | +bool Greeter::inAuthentication() const |
| 270 | +{ |
| 271 | + return false; |
| 272 | +} |
| 273 | + |
| 274 | +QString Greeter::hostname() const |
| 275 | +{ |
| 276 | + return "hostname1"; |
| 277 | +} |
| 278 | + |
| 279 | +bool Greeter::isAuthenticated() const |
| 280 | +{ |
| 281 | + Q_D(const Greeter); |
| 282 | + return d->authenticated; |
| 283 | +} |
| 284 | + |
| 285 | +bool Greeter::connectSync() |
| 286 | +{ |
| 287 | + return true; |
| 288 | +} |
| 289 | + |
| 290 | +void Greeter::authenticate(const QString &username) |
| 291 | +{ |
| 292 | + Q_D(Greeter); |
| 293 | + |
| 294 | + d->authenticated = false; |
| 295 | + d->authenticationUser = username; |
| 296 | + d->handleAuthenticate(); |
| 297 | +} |
| 298 | + |
| 299 | +void Greeter::authenticateAsGuest() |
| 300 | +{} |
| 301 | + |
| 302 | +void Greeter::authenticateAutologin() |
| 303 | +{} |
| 304 | + |
| 305 | +void Greeter::authenticateRemote(const QString &session, const QString &username) |
| 306 | +{ |
| 307 | + Q_UNUSED(session) |
| 308 | + Q_UNUSED(username) |
| 309 | +} |
| 310 | + |
| 311 | +void Greeter::cancelAuthentication() |
| 312 | +{} |
| 313 | + |
| 314 | +void Greeter::setLanguage (const QString &language) |
| 315 | +{ |
| 316 | + Q_UNUSED(language) |
| 317 | +} |
| 318 | + |
| 319 | +bool Greeter::startSessionSync(const QString &session) |
| 320 | +{ |
| 321 | + Q_UNUSED(session) |
| 322 | + return true; |
| 323 | +} |
| 324 | + |
| 325 | +void Greeter::respond(const QString &response) |
| 326 | +{ |
| 327 | + Q_D(Greeter); |
| 328 | + |
| 329 | + d->handleRespond(response); |
| 330 | +} |
| 331 | + |
| 332 | +void Greeter::sendAuthenticationComplete() |
| 333 | +{ |
| 334 | + if (qgetenv("UNITY_TESTING").isEmpty()) { |
| 335 | + // simulate PAM's delay |
| 336 | + QTimer::singleShot(1000, this, SIGNAL(authenticationComplete())); |
| 337 | + } else { |
| 338 | + Q_EMIT authenticationComplete(); |
| 339 | + } |
| 340 | +} |
| 341 | + |
| 342 | +} |
| 343 | |
| 344 | === added file 'plugins/LightDM/liblightdm/Greeter.h' |
| 345 | --- plugins/LightDM/liblightdm/Greeter.h 1970-01-01 00:00:00 +0000 |
| 346 | +++ plugins/LightDM/liblightdm/Greeter.h 2015-02-02 14:28:47 +0000 |
| 347 | @@ -0,0 +1,112 @@ |
| 348 | +/* |
| 349 | + * Copyright (C) 2013 Canonical, Ltd. |
| 350 | + * Copyright (C) 2010-2011 David Edmundson. |
| 351 | + * Copyright (C) 2010-2011 Robert Ancell |
| 352 | + * |
| 353 | + * This program is free software; you can redistribute it and/or modify |
| 354 | + * it under the terms of the GNU General Public License as published by |
| 355 | + * the Free Software Foundation; version 3. |
| 356 | + * |
| 357 | + * This program is distributed in the hope that it will be useful, |
| 358 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 359 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 360 | + * GNU General Public License for more details. |
| 361 | + * |
| 362 | + * You should have received a copy of the GNU General Public License |
| 363 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 364 | + * |
| 365 | + * Author: David Edmundson <kde@davidedmundson.co.uk> |
| 366 | + */ |
| 367 | + |
| 368 | +#ifndef UNITY_MOCK_GREETER_H |
| 369 | +#define UNITY_MOCK_GREETER_H |
| 370 | + |
| 371 | +#include <QtCore/QObject> |
| 372 | +#include <QtCore/QVariant> |
| 373 | + |
| 374 | +/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 375 | + * CHANGES MADE HERE MUST BE REFLECTED ON THE MOCK LIB |
| 376 | + * COUNTERPART IN tests/mocks/Lightdm/liblightdm |
| 377 | + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ |
| 378 | + |
| 379 | +namespace QLightDM |
| 380 | +{ |
| 381 | + class GreeterPrivate; |
| 382 | + |
| 383 | +class Q_DECL_EXPORT Greeter : public QObject |
| 384 | +{ |
| 385 | + Q_OBJECT |
| 386 | + |
| 387 | + Q_PROPERTY(bool authenticated READ isAuthenticated ) //NOTFIY authenticationComplete |
| 388 | + Q_PROPERTY(QString authenticationUser READ authenticationUser ) |
| 389 | + Q_PROPERTY(QString defaultSession READ defaultSessionHint CONSTANT) |
| 390 | + Q_PROPERTY(QString selectUser READ selectUserHint CONSTANT) |
| 391 | + Q_PROPERTY(bool selectGuest READ selectGuestHint CONSTANT) |
| 392 | + |
| 393 | + Q_PROPERTY(QString hostname READ hostname CONSTANT) |
| 394 | + Q_PROPERTY(bool hasGuestAccount READ hasGuestAccountHint CONSTANT) |
| 395 | + Q_PROPERTY(bool locked READ lockHint CONSTANT) |
| 396 | + |
| 397 | + Q_PROPERTY(QString hostname READ hostname CONSTANT) |
| 398 | + |
| 399 | + Q_ENUMS(PromptType MessageType) |
| 400 | + |
| 401 | +public: |
| 402 | + enum PromptType { |
| 403 | + PromptTypeQuestion, |
| 404 | + PromptTypeSecret |
| 405 | + }; |
| 406 | + |
| 407 | + enum MessageType { |
| 408 | + MessageTypeInfo, |
| 409 | + MessageTypeError |
| 410 | + }; |
| 411 | + |
| 412 | + explicit Greeter(QObject* parent=0); |
| 413 | + virtual ~Greeter(); |
| 414 | + |
| 415 | + QString getHint(const QString &name) const; |
| 416 | + QString defaultSessionHint() const; |
| 417 | + bool hideUsersHint() const; |
| 418 | + bool showManualLoginHint() const; |
| 419 | + bool showRemoteLoginHint() const; |
| 420 | + bool lockHint () const; |
| 421 | + bool hasGuestAccountHint() const; |
| 422 | + QString selectUserHint() const; |
| 423 | + bool selectGuestHint() const; |
| 424 | + QString autologinUserHint() const; |
| 425 | + bool autologinGuestHint() const; |
| 426 | + int autologinTimeoutHint() const; |
| 427 | + |
| 428 | + bool inAuthentication() const; |
| 429 | + bool isAuthenticated() const; |
| 430 | + QString authenticationUser() const; |
| 431 | + QString hostname() const; |
| 432 | + |
| 433 | +public Q_SLOTS: |
| 434 | + bool connectSync(); |
| 435 | + void authenticate(const QString &username=QString()); |
| 436 | + void authenticateAsGuest(); |
| 437 | + void authenticateAutologin(); |
| 438 | + void authenticateRemote(const QString &session=QString(), const QString &username=QString()); |
| 439 | + void respond(const QString &response); |
| 440 | + void cancelAuthentication(); |
| 441 | + void setLanguage (const QString &language); |
| 442 | + bool startSessionSync(const QString &session=QString()); |
| 443 | + |
| 444 | +Q_SIGNALS: |
| 445 | + void showMessage(QString text, QLightDM::Greeter::MessageType type); |
| 446 | + void showPrompt(QString text, QLightDM::Greeter::PromptType type); |
| 447 | + void authenticationComplete(); |
| 448 | + void autologinTimerExpired(); |
| 449 | + |
| 450 | +protected: |
| 451 | + void sendAuthenticationComplete(); |
| 452 | + |
| 453 | +private: |
| 454 | + GreeterPrivate *d_ptr; |
| 455 | + Q_DECLARE_PRIVATE(Greeter) |
| 456 | +}; |
| 457 | +} |
| 458 | + |
| 459 | +#endif // UNITY_MOCK_GREETER_H |
| 460 | |
| 461 | === added file 'plugins/LightDM/liblightdm/GreeterPrivate.cpp' |
| 462 | --- plugins/LightDM/liblightdm/GreeterPrivate.cpp 1970-01-01 00:00:00 +0000 |
| 463 | +++ plugins/LightDM/liblightdm/GreeterPrivate.cpp 2015-02-02 14:28:47 +0000 |
| 464 | @@ -0,0 +1,281 @@ |
| 465 | +/* |
| 466 | + * Copyright (C) 2013 Canonical, Ltd. |
| 467 | + * |
| 468 | + * This program is free software; you can redistribute it and/or modify |
| 469 | + * it under the terms of the GNU General Public License as published by |
| 470 | + * the Free Software Foundation; version 3. |
| 471 | + * |
| 472 | + * This program is distributed in the hope that it will be useful, |
| 473 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 474 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 475 | + * GNU General Public License for more details. |
| 476 | + * |
| 477 | + * You should have received a copy of the GNU General Public License |
| 478 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 479 | + * |
| 480 | + * Author: Michael Terry <michael.terry@canonical.com> |
| 481 | + */ |
| 482 | + |
| 483 | +#include "Greeter.h" |
| 484 | +#include "GreeterPrivate.h" |
| 485 | +#include <QFuture> |
| 486 | +#include <QFutureInterface> |
| 487 | +#include <QFutureWatcher> |
| 488 | +#include <QQueue> |
| 489 | +#include <QtConcurrent> |
| 490 | +#include <QVector> |
| 491 | +#include <security/pam_appl.h> |
| 492 | + |
| 493 | +namespace QLightDM |
| 494 | +{ |
| 495 | + |
| 496 | +class GreeterImpl : public QObject |
| 497 | +{ |
| 498 | + Q_OBJECT |
| 499 | + |
| 500 | + struct AppData |
| 501 | + { |
| 502 | + GreeterImpl *impl; |
| 503 | + pam_handle *handle; |
| 504 | + }; |
| 505 | + |
| 506 | + typedef QFutureInterface<QString> ResponseFuture; |
| 507 | + |
| 508 | +public: |
| 509 | + explicit GreeterImpl(Greeter *parent, GreeterPrivate *greeterPrivate) |
| 510 | + : QObject(parent), |
| 511 | + greeter(parent), |
| 512 | + greeterPrivate(greeterPrivate), |
| 513 | + pamHandle(nullptr) |
| 514 | + { |
| 515 | + qRegisterMetaType<QLightDM::GreeterImpl::ResponseFuture>("QLightDM::GreeterImpl::ResponseFuture"); |
| 516 | + |
| 517 | + connect(&futureWatcher, SIGNAL(finished()), |
| 518 | + this, SLOT(finishPam())); |
| 519 | + connect(this, SIGNAL(showMessage(pam_handle *, QString, QLightDM::Greeter::MessageType)), |
| 520 | + this, SLOT(handleMessage(pam_handle *, QString, QLightDM::Greeter::MessageType))); |
| 521 | + // This next connect is how we pass ResponseFutures between threads |
| 522 | + connect(this, SIGNAL(showPrompt(pam_handle *, QString, QLightDM::Greeter::PromptType, QLightDM::GreeterImpl::ResponseFuture)), |
| 523 | + this, SLOT(handlePrompt(pam_handle *, QString, QLightDM::Greeter::PromptType, QLightDM::GreeterImpl::ResponseFuture))); |
| 524 | + } |
| 525 | + |
| 526 | + ~GreeterImpl() |
| 527 | + { |
| 528 | + cancelPam(); |
| 529 | + } |
| 530 | + |
| 531 | + void start(QString username) |
| 532 | + { |
| 533 | + // Clear out any existing PAM interactions first |
| 534 | + cancelPam(); |
| 535 | + |
| 536 | + AppData *appData = new AppData(); |
| 537 | + appData->impl = this; |
| 538 | + |
| 539 | + // Now actually start a new conversation with PAM |
| 540 | + pam_conv conversation; |
| 541 | + conversation.conv = converseWithPam; |
| 542 | + conversation.appdata_ptr = static_cast<void*>(appData); |
| 543 | + |
| 544 | + if (pam_start("lightdm", username.toUtf8(), &conversation, &pamHandle) == PAM_SUCCESS) { |
| 545 | + appData->handle = pamHandle; |
| 546 | + futureWatcher.setFuture(QtConcurrent::run(authenticateWithPam, pamHandle)); |
| 547 | + } else { |
| 548 | + delete appData; |
| 549 | + greeterPrivate->authenticated = false; |
| 550 | + Q_EMIT greeter->showMessage("Internal error: could not start PAM authentication", QLightDM::Greeter::MessageTypeError); |
| 551 | + Q_EMIT greeter->authenticationComplete(); |
| 552 | + } |
| 553 | + } |
| 554 | + |
| 555 | + static int authenticateWithPam(pam_handle* pamHandle) |
| 556 | + { |
| 557 | + int pamStatus = pam_authenticate(pamHandle, 0); |
| 558 | + if (pamStatus == PAM_SUCCESS) { |
| 559 | + pamStatus = pam_acct_mgmt(pamHandle, 0); |
| 560 | + } |
| 561 | + if (pamStatus == PAM_NEW_AUTHTOK_REQD) { |
| 562 | + pamStatus = pam_chauthtok(pamHandle, PAM_CHANGE_EXPIRED_AUTHTOK); |
| 563 | + } |
| 564 | + if (pamStatus == PAM_SUCCESS) { |
| 565 | + pam_setcred(pamHandle, PAM_REINITIALIZE_CRED); |
| 566 | + } |
| 567 | + return pamStatus; |
| 568 | + } |
| 569 | + |
| 570 | + static int converseWithPam(int num_msg, const pam_message** msg, |
| 571 | + pam_response** resp, void* appdata_ptr) |
| 572 | + { |
| 573 | + if (num_msg <= 0) |
| 574 | + return PAM_CONV_ERR; |
| 575 | + |
| 576 | + auto* tmp_response = static_cast<pam_response*>(calloc(num_msg, sizeof(pam_response))); |
| 577 | + if (!tmp_response) |
| 578 | + return PAM_CONV_ERR; |
| 579 | + |
| 580 | + AppData *appData = static_cast<AppData*>(appdata_ptr); |
| 581 | + GreeterImpl *impl = appData->impl; |
| 582 | + pam_handle *handle = appData->handle; |
| 583 | + |
| 584 | + int count; |
| 585 | + QVector<ResponseFuture> responses; |
| 586 | + |
| 587 | + for (count = 0; count < num_msg; ++count) |
| 588 | + { |
| 589 | + switch (msg[count]->msg_style) |
| 590 | + { |
| 591 | + case PAM_PROMPT_ECHO_ON: |
| 592 | + { |
| 593 | + QString message(msg[count]->msg); |
| 594 | + responses.append(ResponseFuture()); |
| 595 | + responses.last().reportStarted(); |
| 596 | + Q_EMIT impl->showPrompt(handle, message, Greeter::PromptTypeQuestion, responses.last()); |
| 597 | + break; |
| 598 | + } |
| 599 | + case PAM_PROMPT_ECHO_OFF: |
| 600 | + { |
| 601 | + QString message(msg[count]->msg); |
| 602 | + responses.append(ResponseFuture()); |
| 603 | + responses.last().reportStarted(); |
| 604 | + Q_EMIT impl->showPrompt(handle, message, Greeter::PromptTypeSecret, responses.last()); |
| 605 | + break; |
| 606 | + } |
| 607 | + case PAM_TEXT_INFO: |
| 608 | + { |
| 609 | + QString message(msg[count]->msg); |
| 610 | + Q_EMIT impl->showMessage(handle, message, Greeter::MessageTypeInfo); |
| 611 | + break; |
| 612 | + } |
| 613 | + default: |
| 614 | + { |
| 615 | + QString message(msg[count]->msg); |
| 616 | + Q_EMIT impl->showMessage(handle, message, Greeter::MessageTypeError); |
| 617 | + break; |
| 618 | + } |
| 619 | + } |
| 620 | + } |
| 621 | + |
| 622 | + int i = 0; |
| 623 | + bool raise_error = false; |
| 624 | + |
| 625 | + for (auto &response : responses) |
| 626 | + { |
| 627 | + pam_response* resp_item = &tmp_response[i++]; |
| 628 | + resp_item->resp_retcode = 0; |
| 629 | + resp_item->resp = strdup(response.future().result().toUtf8()); |
| 630 | + |
| 631 | + if (!resp_item->resp) |
| 632 | + { |
| 633 | + raise_error = true; |
| 634 | + break; |
| 635 | + } |
| 636 | + } |
| 637 | + |
| 638 | + delete appData; |
| 639 | + |
| 640 | + if (raise_error) |
| 641 | + { |
| 642 | + for (int i = 0; i < count; ++i) |
| 643 | + free(tmp_response[i].resp); |
| 644 | + |
| 645 | + free(tmp_response); |
| 646 | + return PAM_CONV_ERR; |
| 647 | + } |
| 648 | + else |
| 649 | + { |
| 650 | + *resp = tmp_response; |
| 651 | + return PAM_SUCCESS; |
| 652 | + } |
| 653 | + } |
| 654 | + |
| 655 | +public Q_SLOTS: |
| 656 | + bool respond(QString response) |
| 657 | + { |
| 658 | + if (!futures.isEmpty()) { |
| 659 | + futures.dequeue().reportFinished(&response); |
| 660 | + return true; |
| 661 | + } else { |
| 662 | + return false; |
| 663 | + } |
| 664 | + } |
| 665 | + |
| 666 | +Q_SIGNALS: |
| 667 | + void showMessage(pam_handle *handle, QString text, QLightDM::Greeter::MessageType type); |
| 668 | + void showPrompt(pam_handle *handle, QString text, QLightDM::Greeter::PromptType type, QLightDM::GreeterImpl::ResponseFuture response); |
| 669 | + |
| 670 | +private Q_SLOTS: |
| 671 | + void finishPam() |
| 672 | + { |
| 673 | + if (pamHandle == nullptr) { |
| 674 | + return; |
| 675 | + } |
| 676 | + |
| 677 | + int pamStatus = futureWatcher.result(); |
| 678 | + |
| 679 | + pam_end(pamHandle, pamStatus); |
| 680 | + pamHandle = nullptr; |
| 681 | + |
| 682 | + greeterPrivate->authenticated = (pamStatus == PAM_SUCCESS); |
| 683 | + Q_EMIT greeter->authenticationComplete(); |
| 684 | + } |
| 685 | + |
| 686 | + void handleMessage(pam_handle *handle, QString text, QLightDM::Greeter::MessageType type) |
| 687 | + { |
| 688 | + if (handle != pamHandle) |
| 689 | + return; |
| 690 | + |
| 691 | + Q_EMIT greeter->showMessage(text, type); |
| 692 | + } |
| 693 | + |
| 694 | + void handlePrompt(pam_handle *handle, QString text, QLightDM::Greeter::PromptType type, QLightDM::GreeterImpl::ResponseFuture future) |
| 695 | + { |
| 696 | + if (handle != pamHandle) { |
| 697 | + future.reportResult(QString()); |
| 698 | + future.reportFinished(); |
| 699 | + return; |
| 700 | + } |
| 701 | + |
| 702 | + futures.enqueue(future); |
| 703 | + Q_EMIT greeter->showPrompt(text, type); |
| 704 | + } |
| 705 | + |
| 706 | +private: |
| 707 | + void cancelPam() |
| 708 | + { |
| 709 | + // Unfortunately we can't simply cancel our QFuture because QtConcurrent::run doesn't support cancel |
| 710 | + if (pamHandle != nullptr) { |
| 711 | + pam_handle *handle = pamHandle; |
| 712 | + pamHandle = nullptr; // to disable normal finishPam() handling |
| 713 | + while (respond(QString())); // clear our local queue of QFutures |
| 714 | + pam_end(handle, PAM_CONV_ERR); |
| 715 | + } |
| 716 | + } |
| 717 | + |
| 718 | + Greeter *greeter; |
| 719 | + GreeterPrivate *greeterPrivate; |
| 720 | + pam_handle* pamHandle; |
| 721 | + QFutureWatcher<int> futureWatcher; |
| 722 | + QQueue<ResponseFuture> futures; |
| 723 | +}; |
| 724 | + |
| 725 | +GreeterPrivate::GreeterPrivate(Greeter* parent) |
| 726 | + : authenticated(false), |
| 727 | + authenticationUser(), |
| 728 | + m_impl(new GreeterImpl(parent, this)), |
| 729 | + q_ptr(parent) |
| 730 | +{ |
| 731 | +} |
| 732 | + |
| 733 | +void GreeterPrivate::handleAuthenticate() |
| 734 | +{ |
| 735 | + m_impl->start(authenticationUser); |
| 736 | +} |
| 737 | + |
| 738 | +void GreeterPrivate::handleRespond(const QString &response) |
| 739 | +{ |
| 740 | + m_impl->respond(response); |
| 741 | +} |
| 742 | + |
| 743 | +} |
| 744 | + |
| 745 | +#include "GreeterPrivate.moc" |
| 746 | |
| 747 | === added file 'plugins/LightDM/liblightdm/GreeterPrivate.h' |
| 748 | --- plugins/LightDM/liblightdm/GreeterPrivate.h 1970-01-01 00:00:00 +0000 |
| 749 | +++ plugins/LightDM/liblightdm/GreeterPrivate.h 2015-02-02 14:28:47 +0000 |
| 750 | @@ -0,0 +1,51 @@ |
| 751 | +/* |
| 752 | + * Copyright (C) 2013 Canonical, Ltd. |
| 753 | + * |
| 754 | + * This program is free software; you can redistribute it and/or modify |
| 755 | + * it under the terms of the GNU General Public License as published by |
| 756 | + * the Free Software Foundation; version 3. |
| 757 | + * |
| 758 | + * This program is distributed in the hope that it will be useful, |
| 759 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 760 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 761 | + * GNU General Public License for more details. |
| 762 | + * |
| 763 | + * You should have received a copy of the GNU General Public License |
| 764 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 765 | + * |
| 766 | + * Author: Michael Terry <michael.terry@canonical.com> |
| 767 | + */ |
| 768 | + |
| 769 | +#ifndef UNITY_MOCK_GREETER_PRIVATE_H |
| 770 | +#define UNITY_MOCK_GREETER_PRIVATE_H |
| 771 | + |
| 772 | +#include <QtCore/QObject> |
| 773 | + |
| 774 | +namespace QLightDM |
| 775 | +{ |
| 776 | +class Greeter; |
| 777 | +class GreeterImpl; |
| 778 | + |
| 779 | +class GreeterPrivate |
| 780 | +{ |
| 781 | +public: |
| 782 | + explicit GreeterPrivate(Greeter* parent=0); |
| 783 | + virtual ~GreeterPrivate() = default; |
| 784 | + |
| 785 | + // These variables may not be used by all subclasses, that's no problem |
| 786 | + bool authenticated; |
| 787 | + QString authenticationUser; |
| 788 | + |
| 789 | + void handleAuthenticate(); |
| 790 | + void handleRespond(const QString &response); |
| 791 | + |
| 792 | +protected: |
| 793 | + GreeterImpl *m_impl; // if the backend needs more private data |
| 794 | + Greeter * const q_ptr; |
| 795 | + |
| 796 | +private: |
| 797 | + Q_DECLARE_PUBLIC(Greeter) |
| 798 | +}; |
| 799 | +} |
| 800 | + |
| 801 | +#endif // UNITY_MOCK_GREETER_PRIVATE_H |
| 802 | |
| 803 | === added file 'plugins/LightDM/liblightdm/UsersModel.cpp' |
| 804 | --- plugins/LightDM/liblightdm/UsersModel.cpp 1970-01-01 00:00:00 +0000 |
| 805 | +++ plugins/LightDM/liblightdm/UsersModel.cpp 2015-02-02 14:28:47 +0000 |
| 806 | @@ -0,0 +1,123 @@ |
| 807 | +/* |
| 808 | + * Copyright (C) 2013 Canonical, Ltd. |
| 809 | + * |
| 810 | + * This program is free software; you can redistribute it and/or modify |
| 811 | + * it under the terms of the GNU General Public License as published by |
| 812 | + * the Free Software Foundation; version 3. |
| 813 | + * |
| 814 | + * This program is distributed in the hope that it will be useful, |
| 815 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 816 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 817 | + * GNU General Public License for more details. |
| 818 | + * |
| 819 | + * You should have received a copy of the GNU General Public License |
| 820 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 821 | + * |
| 822 | + * Author: Michael Terry <michael.terry@canonical.com> |
| 823 | + */ |
| 824 | + |
| 825 | + |
| 826 | +/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 827 | + * CHANGES MADE HERE MUST BE REFLECTED ON THE MOCK LIB |
| 828 | + * COUNTERPART IN tests/mocks/Lightdm/liblightdm |
| 829 | + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ |
| 830 | + |
| 831 | +// LightDM currently is Qt4 compatible, and so doesn't define setRoleNames. |
| 832 | +// To use the same method of setting role name that it does, we |
| 833 | +// set our compatibility to Qt4 here too. |
| 834 | +#define QT_DISABLE_DEPRECATED_BEFORE QT_VERSION_CHECK(4, 0, 0) |
| 835 | + |
| 836 | +#include "UsersModel.h" |
| 837 | +#include "UsersModelPrivate.h" |
| 838 | +#include <QtCore/QDir> |
| 839 | +#include <QtCore/QString> |
| 840 | +#include <QtGui/QIcon> |
| 841 | + |
| 842 | +namespace QLightDM |
| 843 | +{ |
| 844 | + |
| 845 | +UsersModel::UsersModel(QObject *parent) : |
| 846 | + QAbstractListModel(parent), |
| 847 | + d_ptr(new UsersModelPrivate(this)) |
| 848 | +{ |
| 849 | + Q_D(UsersModel); |
| 850 | + |
| 851 | + // Extend roleNames (we want to keep the "display" role) |
| 852 | + QHash<int, QByteArray> roles = roleNames(); |
| 853 | + roles[NameRole] = "name"; |
| 854 | + roles[RealNameRole] = "realName"; |
| 855 | + roles[LoggedInRole] = "loggedIn"; |
| 856 | + roles[BackgroundRole] = "background"; |
| 857 | + roles[BackgroundPathRole] = "backgroundPath"; |
| 858 | + roles[SessionRole] = "session"; |
| 859 | + roles[HasMessagesRole] = "hasMessages"; |
| 860 | + roles[ImagePathRole] = "imagePath"; |
| 861 | + setRoleNames(roles); |
| 862 | + |
| 863 | + // Now modify our mock user backgrounds |
| 864 | + QDir bgdir = QDir("/usr/share/demo-assets/shell/backgrounds/"); |
| 865 | + QStringList backgrounds = bgdir.entryList(QDir::Files | QDir::NoDotAndDotDot); |
| 866 | + |
| 867 | + for (int i = 0, j = 0; i < d->entries.size(); i++) { |
| 868 | + Entry &entry = d->entries[i]; |
| 869 | + if (entry.background.isNull() && !backgrounds.isEmpty()) { |
| 870 | + entry.background = bgdir.filePath(backgrounds[j++]); |
| 871 | + if (j >= backgrounds.length()) { |
| 872 | + j = 0; |
| 873 | + } |
| 874 | + } |
| 875 | + } |
| 876 | +} |
| 877 | + |
| 878 | +UsersModel::~UsersModel() |
| 879 | +{ |
| 880 | + delete d_ptr; |
| 881 | +} |
| 882 | + |
| 883 | +int UsersModel::rowCount(const QModelIndex &parent) const |
| 884 | +{ |
| 885 | + Q_D(const UsersModel); |
| 886 | + |
| 887 | + if (parent.isValid()) { |
| 888 | + return 0; |
| 889 | + } else { // parent is root |
| 890 | + return d->entries.size(); |
| 891 | + } |
| 892 | +} |
| 893 | + |
| 894 | +QVariant UsersModel::data(const QModelIndex &index, int role) const |
| 895 | +{ |
| 896 | + Q_D(const UsersModel); |
| 897 | + |
| 898 | + if (!index.isValid()) { |
| 899 | + return QVariant(); |
| 900 | + } |
| 901 | + |
| 902 | + int row = index.row(); |
| 903 | + switch (role) { |
| 904 | + case Qt::DisplayRole: |
| 905 | + return d->entries[row].real_name; |
| 906 | + case Qt::DecorationRole: |
| 907 | + return QIcon(); |
| 908 | + case UsersModel::NameRole: |
| 909 | + return d->entries[row].username; |
| 910 | + case UsersModel::RealNameRole: |
| 911 | + return d->entries[row].real_name; |
| 912 | + case UsersModel::SessionRole: |
| 913 | + return d->entries[row].session; |
| 914 | + case UsersModel::LoggedInRole: |
| 915 | + return d->entries[row].is_active; |
| 916 | + case UsersModel::BackgroundRole: |
| 917 | + return QPixmap(d->entries[row].background); |
| 918 | + case UsersModel::BackgroundPathRole: |
| 919 | + return d->entries[row].background; |
| 920 | + case UsersModel::HasMessagesRole: |
| 921 | + return d->entries[row].has_messages; |
| 922 | + case UsersModel::ImagePathRole: |
| 923 | + return ""; |
| 924 | + default: |
| 925 | + return QVariant(); |
| 926 | + } |
| 927 | +} |
| 928 | + |
| 929 | +} |
| 930 | |
| 931 | === added file 'plugins/LightDM/liblightdm/UsersModel.h' |
| 932 | --- plugins/LightDM/liblightdm/UsersModel.h 1970-01-01 00:00:00 +0000 |
| 933 | +++ plugins/LightDM/liblightdm/UsersModel.h 2015-02-02 14:28:47 +0000 |
| 934 | @@ -0,0 +1,66 @@ |
| 935 | +/* |
| 936 | + * Copyright (C) 2013 Canonical, Ltd. |
| 937 | + * Copyright (C) 2010-2011 David Edmundson. |
| 938 | + * |
| 939 | + * This program is free software; you can redistribute it and/or modify |
| 940 | + * it under the terms of the GNU General Public License as published by |
| 941 | + * the Free Software Foundation; version 3. |
| 942 | + * |
| 943 | + * This program is distributed in the hope that it will be useful, |
| 944 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 945 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 946 | + * GNU General Public License for more details. |
| 947 | + * |
| 948 | + * You should have received a copy of the GNU General Public License |
| 949 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 950 | + * |
| 951 | + * Author: David Edmundson <kde@davidedmundson.co.uk> |
| 952 | + */ |
| 953 | + |
| 954 | +#ifndef UNITY_MOCK_USERSMODEL_H |
| 955 | +#define UNITY_MOCK_USERSMODEL_H |
| 956 | + |
| 957 | +#include <QtCore/QString> |
| 958 | +#include <QtCore/QSharedDataPointer> |
| 959 | +#include <QAbstractListModel> |
| 960 | + |
| 961 | +/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 962 | + * CHANGES MADE HERE MUST BE REFLECTED ON THE MOCK LIB |
| 963 | + * COUNTERPART IN tests/mocks/Lightdm/liblightdm |
| 964 | + * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ |
| 965 | + |
| 966 | +namespace QLightDM |
| 967 | +{ |
| 968 | +class UsersModelPrivate; |
| 969 | + |
| 970 | +class Q_DECL_EXPORT UsersModel : public QAbstractListModel |
| 971 | +{ |
| 972 | + Q_OBJECT |
| 973 | + |
| 974 | + Q_ENUMS(UserModelRoles) |
| 975 | + |
| 976 | +public: |
| 977 | + explicit UsersModel(QObject *parent = 0); |
| 978 | + virtual ~UsersModel(); |
| 979 | + |
| 980 | + enum UserModelRoles {NameRole = Qt::UserRole, |
| 981 | + RealNameRole, |
| 982 | + LoggedInRole, |
| 983 | + BackgroundRole, |
| 984 | + SessionRole, |
| 985 | + HasMessagesRole, |
| 986 | + ImagePathRole, |
| 987 | + BackgroundPathRole |
| 988 | + }; |
| 989 | + |
| 990 | + int rowCount(const QModelIndex &parent) const; |
| 991 | + QVariant data(const QModelIndex &index, int role) const; |
| 992 | + |
| 993 | +private: |
| 994 | + UsersModelPrivate * const d_ptr; |
| 995 | + Q_DECLARE_PRIVATE(UsersModel) |
| 996 | +}; |
| 997 | + |
| 998 | +} |
| 999 | + |
| 1000 | +#endif // UNITY_MOCK_USERSMODEL_H |
| 1001 | |
| 1002 | === added file 'plugins/LightDM/liblightdm/UsersModelPrivate.cpp' |
| 1003 | --- plugins/LightDM/liblightdm/UsersModelPrivate.cpp 1970-01-01 00:00:00 +0000 |
| 1004 | +++ plugins/LightDM/liblightdm/UsersModelPrivate.cpp 2015-02-02 14:28:47 +0000 |
| 1005 | @@ -0,0 +1,41 @@ |
| 1006 | +/* |
| 1007 | + * Copyright (C) 2013 Canonical, Ltd. |
| 1008 | + * |
| 1009 | + * This program is free software; you can redistribute it and/or modify |
| 1010 | + * it under the terms of the GNU General Public License as published by |
| 1011 | + * the Free Software Foundation; version 3. |
| 1012 | + * |
| 1013 | + * This program is distributed in the hope that it will be useful, |
| 1014 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 1015 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 1016 | + * GNU General Public License for more details. |
| 1017 | + * |
| 1018 | + * You should have received a copy of the GNU General Public License |
| 1019 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 1020 | + * |
| 1021 | + * Author: Michael Terry <michael.terry@canonical.com> |
| 1022 | + */ |
| 1023 | + |
| 1024 | +#include "UsersModelPrivate.h" |
| 1025 | + |
| 1026 | +#include <QDir> |
| 1027 | +#include <QSettings> |
| 1028 | +#include <QStringList> |
| 1029 | + |
| 1030 | +namespace QLightDM |
| 1031 | +{ |
| 1032 | + |
| 1033 | +UsersModelPrivate::UsersModelPrivate(UsersModel* parent) |
| 1034 | + : q_ptr(parent) |
| 1035 | +{ |
| 1036 | + QSettings settings(QDir::homePath() + "/.unity8-greeter-demo", QSettings::NativeFormat); |
| 1037 | + QStringList users = settings.value("users", QStringList() << qgetenv("USER")).toStringList(); |
| 1038 | + |
| 1039 | + Q_FOREACH(const QString &user, users) |
| 1040 | + { |
| 1041 | + QString name = settings.value(user + "/name", user[0].toUpper() + user.mid(1)).toString(); |
| 1042 | + entries.append({user, name, 0, 0, false, false, 0, 0}); |
| 1043 | + } |
| 1044 | +} |
| 1045 | + |
| 1046 | +} |
| 1047 | |
| 1048 | === added file 'plugins/LightDM/liblightdm/UsersModelPrivate.h' |
| 1049 | --- plugins/LightDM/liblightdm/UsersModelPrivate.h 1970-01-01 00:00:00 +0000 |
| 1050 | +++ plugins/LightDM/liblightdm/UsersModelPrivate.h 2015-02-02 14:28:47 +0000 |
| 1051 | @@ -0,0 +1,59 @@ |
| 1052 | +/* |
| 1053 | + * Copyright (C) 2013 Canonical, Ltd. |
| 1054 | + * |
| 1055 | + * This program is free software; you can redistribute it and/or modify |
| 1056 | + * it under the terms of the GNU General Public License as published by |
| 1057 | + * the Free Software Foundation; version 3. |
| 1058 | + * |
| 1059 | + * This program is distributed in the hope that it will be useful, |
| 1060 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 1061 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 1062 | + * GNU General Public License for more details. |
| 1063 | + * |
| 1064 | + * You should have received a copy of the GNU General Public License |
| 1065 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 1066 | + * |
| 1067 | + * Author: Michael Terry <michael.terry@canonical.com> |
| 1068 | + */ |
| 1069 | + |
| 1070 | +#ifndef UNITY_MOCK_USERSMODEL_PRIVATE_H |
| 1071 | +#define UNITY_MOCK_USERSMODEL_PRIVATE_H |
| 1072 | + |
| 1073 | +#include <QtCore/QList> |
| 1074 | +#include <QtCore/QString> |
| 1075 | + |
| 1076 | +namespace QLightDM |
| 1077 | +{ |
| 1078 | +class UsersModel; |
| 1079 | + |
| 1080 | +class Entry |
| 1081 | +{ |
| 1082 | +public: |
| 1083 | + QString username; |
| 1084 | + QString real_name; |
| 1085 | + QString background; |
| 1086 | + QString layouts; |
| 1087 | + bool is_active; |
| 1088 | + bool has_messages; |
| 1089 | + QString session; |
| 1090 | + QString infographic; |
| 1091 | +}; |
| 1092 | + |
| 1093 | +class UsersModelPrivate |
| 1094 | +{ |
| 1095 | +public: |
| 1096 | + explicit UsersModelPrivate(UsersModel *parent = 0); |
| 1097 | + virtual ~UsersModelPrivate() = default; |
| 1098 | + |
| 1099 | + QList<Entry> entries; |
| 1100 | + |
| 1101 | +protected: |
| 1102 | + UsersModel * const q_ptr; |
| 1103 | + |
| 1104 | +private: |
| 1105 | + Q_DECLARE_PUBLIC(UsersModel) |
| 1106 | +}; |
| 1107 | + |
| 1108 | +} |
| 1109 | + |
| 1110 | +#endif // UNITY_MOCK_USERSMODEL_PRIVATE_H |
| 1111 | |
| 1112 | === modified file 'qml/Greeter/Greeter.qml' |
| 1113 | --- qml/Greeter/Greeter.qml 2015-01-09 10:41:28 +0000 |
| 1114 | +++ qml/Greeter/Greeter.qml 2015-02-02 14:28:47 +0000 |
| 1115 | @@ -30,6 +30,9 @@ |
| 1116 | |
| 1117 | property url background |
| 1118 | |
| 1119 | + // so that it can be replaced in tests with a mock object |
| 1120 | + property var inputMethod: Qt.inputMethod |
| 1121 | + |
| 1122 | prepareToHide: function () { |
| 1123 | hideTranslation.to = greeter.x > 0 || d.forceRightOnNextHideAnimation ? greeter.width : -greeter.width; |
| 1124 | d.forceRightOnNextHideAnimation = false; |
| 1125 | @@ -102,6 +105,11 @@ |
| 1126 | } |
| 1127 | onUnlocked: greeter.unlocked(uid); |
| 1128 | } |
| 1129 | + Binding { |
| 1130 | + target: greeterContentLoader.item |
| 1131 | + property: "inputMethod" |
| 1132 | + value: greeter.inputMethod |
| 1133 | + } |
| 1134 | } |
| 1135 | |
| 1136 | DragHandle { |
| 1137 | |
| 1138 | === modified file 'qml/Greeter/GreeterContent.qml' |
| 1139 | --- qml/Greeter/GreeterContent.qml 2014-12-11 17:32:14 +0000 |
| 1140 | +++ qml/Greeter/GreeterContent.qml 2015-02-02 14:28:47 +0000 |
| 1141 | @@ -24,6 +24,8 @@ |
| 1142 | id: root |
| 1143 | anchors.fill: parent |
| 1144 | |
| 1145 | + property var inputMethod |
| 1146 | + |
| 1147 | property bool ready: background.source == "" || background.status == Image.Ready || background.status == Image.Error |
| 1148 | |
| 1149 | signal selected(int uid) |
| 1150 | @@ -74,10 +76,12 @@ |
| 1151 | anchors { |
| 1152 | left: parent.left |
| 1153 | leftMargin: Math.min(parent.width * 0.16, units.gu(20)) |
| 1154 | - verticalCenter: parent.verticalCenter |
| 1155 | + top: parent.top |
| 1156 | } |
| 1157 | width: units.gu(29) |
| 1158 | - height: parent.height |
| 1159 | + height: inputMethod && inputMethod.visible ? parent.height - inputMethod.keyboardRectangle.height |
| 1160 | + : parent.height |
| 1161 | + Behavior on height { UbuntuNumberAnimation {} } |
| 1162 | |
| 1163 | // TODO: Once we have a system API for determining which mode we are |
| 1164 | // in, tablet/phone/desktop, that should be used instead of narrowMode. |
| 1165 | |
| 1166 | === modified file 'run.sh' |
| 1167 | --- run.sh 2015-01-20 16:21:07 +0000 |
| 1168 | +++ run.sh 2015-02-02 14:28:47 +0000 |
| 1169 | @@ -6,8 +6,6 @@ |
| 1170 | QML_PHONE_SHELL_PATH=./builddir/src/unity8 |
| 1171 | GDB=false |
| 1172 | FAKE=false |
| 1173 | -PINLOCK=false |
| 1174 | -KEYLOCK=false |
| 1175 | USE_MOCKS=false |
| 1176 | MOUSE_TOUCH=true |
| 1177 | |
| 1178 | @@ -16,9 +14,6 @@ |
| 1179 | echo "Script to run the shell.\n" >&2 |
| 1180 | echo "OPTIONS:" >&2 |
| 1181 | echo " -f, --fake Force use of fake Qml modules." >&2 |
| 1182 | - echo " -p, --pinlock Use a pin protected user." >&2 |
| 1183 | - echo " -k, --keylock Use a passphrase protected user." >&2 |
| 1184 | - echo " -l, --lightdm Use the specified lightdm mock." >&2 |
| 1185 | echo " -g, --gdb Run through gdb." >&2 |
| 1186 | echo " -h, --help Show this help." >&2 |
| 1187 | echo " -m, --nomousetouch Run without -mousetouch argument." >&2 |
| 1188 | @@ -26,7 +21,7 @@ |
| 1189 | exit 1 |
| 1190 | } |
| 1191 | |
| 1192 | -ARGS=`getopt -n$0 -u -a --longoptions="fake,pinlock,keylock,gdb,help,lightdm:,nomousetouch" -o "fpkl:ghm" -- "$@"` |
| 1193 | +ARGS=`getopt -n$0 -u -a --longoptions="fake,gdb,help:,nomousetouch" -o "fghm" -- "$@"` |
| 1194 | [ $? -ne 0 ] && usage |
| 1195 | eval set -- "$ARGS" |
| 1196 | |
| 1197 | @@ -34,12 +29,6 @@ |
| 1198 | do |
| 1199 | case "$1" in |
| 1200 | -f|--fake) USE_MOCKS=true;; |
| 1201 | - -p|--pinlock) USE_MOCKS=true; LIGHTDM_MOCK=single-pin;; |
| 1202 | - -k|--keylock) USE_MOCKS=true; LIGHTDM_MOCK=single-passphrase;; |
| 1203 | - -l|--lightdm) LIGHTDM_MOCK=$2; shift; |
| 1204 | - if [ -z "$LIGHTDM_MOCK" ]; then |
| 1205 | - echo "Please specify an argument to --lightdm" |
| 1206 | - fi;; |
| 1207 | -g|--gdb) GDB=true;; |
| 1208 | -h|--help) usage;; |
| 1209 | -m|--nomousetouch) MOUSE_TOUCH=false;; |
| 1210 | @@ -48,23 +37,11 @@ |
| 1211 | shift |
| 1212 | done |
| 1213 | |
| 1214 | -if [ -z "$LIGHTDM_MOCK" ]; then |
| 1215 | - LIGHTDM_MOCK=single |
| 1216 | -fi |
| 1217 | - |
| 1218 | -# Even without USE_MOCKS set, we want to fake our lightdm backend, because it's |
| 1219 | -# annoying to be prompted for your password when testing. To get the same |
| 1220 | -# backend used in production, pass '--lightdm=demo'. |
| 1221 | -export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/builddir/tests/mocks/LightDM/$LIGHTDM_MOCK |
| 1222 | - |
| 1223 | if $USE_MOCKS; then |
| 1224 | - rm -f $PWD/builddir/nonmirplugins/LightDM # undo symlink (from below) for cleanliness |
| 1225 | export QML2_IMPORT_PATH=$QML2_IMPORT_PATH:$PWD/builddir/tests/mocks:$PWD/builddir/plugins:$PWD/builddir/modules |
| 1226 | - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/builddir/tests/mocks/libusermetrics:$PWD/builddir/tests/mocks/QMenuModel |
| 1227 | + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/builddir/tests/mocks/LightDM/liblightdm:$PWD/builddir/tests/mocks/libusermetrics:$PWD/builddir/tests/mocks/QMenuModel |
| 1228 | else |
| 1229 | - # Just link our LightDM mock into the nonmirplugins folder. We don't want |
| 1230 | - # the rest of our plugins to be used. |
| 1231 | - ln -sf $PWD/builddir/tests/mocks/LightDM $PWD/builddir/nonmirplugins/ |
| 1232 | + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/builddir/plugins/LightDM/liblightdm |
| 1233 | fi |
| 1234 | |
| 1235 | QML_PHONE_SHELL_ARGS="" |
| 1236 | |
| 1237 | === modified file 'tests/autopilot/unity8/shell/__init__.py' |
| 1238 | --- tests/autopilot/unity8/shell/__init__.py 2014-05-01 14:25:18 +0000 |
| 1239 | +++ tests/autopilot/unity8/shell/__init__.py 2015-02-02 14:28:47 +0000 |
| 1240 | @@ -27,19 +27,6 @@ |
| 1241 | |
| 1242 | logger = logging.getLogger(__name__) |
| 1243 | |
| 1244 | - |
| 1245 | -def with_lightdm_mock(mock_type): |
| 1246 | - """A simple decorator that sets up the LightDM mock for a single test.""" |
| 1247 | - def with_lightdm_mock_internal(fn): |
| 1248 | - @wraps(fn) |
| 1249 | - def wrapper(*args, **kwargs): |
| 1250 | - tests_self = args[0] |
| 1251 | - tests_self.patch_lightdm_mock(mock_type) |
| 1252 | - return fn(*args, **kwargs) |
| 1253 | - return wrapper |
| 1254 | - return with_lightdm_mock_internal |
| 1255 | - |
| 1256 | - |
| 1257 | def disable_qml_mocking(fn): |
| 1258 | """Simple decorator that disables the QML mocks from being loaded.""" |
| 1259 | @wraps(fn) |
| 1260 | |
| 1261 | === modified file 'tests/autopilot/unity8/shell/tests/__init__.py' |
| 1262 | --- tests/autopilot/unity8/shell/tests/__init__.py 2014-10-31 08:37:28 +0000 |
| 1263 | +++ tests/autopilot/unity8/shell/tests/__init__.py 2015-02-02 14:28:47 +0000 |
| 1264 | @@ -153,7 +153,6 @@ |
| 1265 | self.useFixture(toolkit_fixtures.HideUnity7Launcher()) |
| 1266 | |
| 1267 | self._proxy = None |
| 1268 | - self._lightdm_mock_type = None |
| 1269 | self._qml_mock_enabled = True |
| 1270 | self._data_dirs_mock_enabled = True |
| 1271 | self._environment = {} |
| 1272 | @@ -265,8 +264,7 @@ |
| 1273 | binary_path |
| 1274 | ) |
| 1275 | |
| 1276 | - if self._lightdm_mock_type is None: |
| 1277 | - self.patch_lightdm_mock() |
| 1278 | + self.patch_lightdm_mock() |
| 1279 | |
| 1280 | if self._qml_mock_enabled: |
| 1281 | self._environment['QML2_IMPORT_PATH'] = ( |
| 1282 | @@ -338,12 +336,11 @@ |
| 1283 | if data_dirs is not None: |
| 1284 | self._environment['XDG_DATA_DIRS'] = data_dirs |
| 1285 | |
| 1286 | - def patch_lightdm_mock(self, mock_type='single'): |
| 1287 | - self._lightdm_mock_type = mock_type |
| 1288 | - logger.info("Setting up LightDM mock type '%s'", mock_type) |
| 1289 | + def patch_lightdm_mock(self): |
| 1290 | + logger.info("Setting up LightDM mock lib") |
| 1291 | new_ld_library_path = [ |
| 1292 | get_default_extra_mock_libraries(), |
| 1293 | - self._get_lightdm_mock_path(mock_type) |
| 1294 | + self._get_lightdm_mock_path() |
| 1295 | ] |
| 1296 | if os.getenv('LD_LIBRARY_PATH') is not None: |
| 1297 | new_ld_library_path.append(os.getenv('LD_LIBRARY_PATH')) |
| 1298 | @@ -353,16 +350,16 @@ |
| 1299 | |
| 1300 | self._environment['LD_LIBRARY_PATH'] = new_ld_library_path |
| 1301 | |
| 1302 | - def _get_lightdm_mock_path(self, mock_type): |
| 1303 | + def _get_lightdm_mock_path(self): |
| 1304 | lib_path = get_mocks_library_path() |
| 1305 | lightdm_mock_path = os.path.abspath( |
| 1306 | - os.path.join(lib_path, "LightDM", mock_type) |
| 1307 | + os.path.join(lib_path, "LightDM", "liblightdm") |
| 1308 | ) |
| 1309 | |
| 1310 | if not os.path.exists(lightdm_mock_path): |
| 1311 | raise RuntimeError( |
| 1312 | - "LightDM mock '%s' does not exist at path '%s'." |
| 1313 | - % (mock_type, lightdm_mock_path) |
| 1314 | + "LightDM mock does not exist at path '%s'." |
| 1315 | + % (lightdm_mock_path) |
| 1316 | ) |
| 1317 | return lightdm_mock_path |
| 1318 | |
| 1319 | |
| 1320 | === modified file 'tests/autopilot/unity8/shell/tests/test_edges_demo.py' |
| 1321 | --- tests/autopilot/unity8/shell/tests/test_edges_demo.py 2015-01-09 16:59:07 +0000 |
| 1322 | +++ tests/autopilot/unity8/shell/tests/test_edges_demo.py 2015-02-02 14:28:47 +0000 |
| 1323 | @@ -34,7 +34,6 @@ |
| 1324 | super(EdgesDemoTestCase, self).setUp() |
| 1325 | self._qml_mock_enabled = False |
| 1326 | self._data_dirs_mock_enabled = False |
| 1327 | - self._lightdm_mock_type = False |
| 1328 | |
| 1329 | self.useFixture(fixture_setup.EdgesDemo(True)) |
| 1330 | self.unity = self.launch_unity() |
| 1331 | |
| 1332 | === modified file 'tests/autopilot/unity8/shell/tests/test_lock_screen.py' |
| 1333 | --- tests/autopilot/unity8/shell/tests/test_lock_screen.py 2014-09-29 19:54:33 +0000 |
| 1334 | +++ tests/autopilot/unity8/shell/tests/test_lock_screen.py 2015-02-02 14:28:47 +0000 |
| 1335 | @@ -20,7 +20,6 @@ |
| 1336 | |
| 1337 | from __future__ import absolute_import |
| 1338 | |
| 1339 | -from unity8.shell import with_lightdm_mock |
| 1340 | from unity8.shell.tests import UnityTestCase, _get_device_emulation_scenarios |
| 1341 | |
| 1342 | from autopilot.matchers import Eventually |
| 1343 | @@ -41,9 +40,10 @@ |
| 1344 | |
| 1345 | scenarios = _get_device_emulation_scenarios() |
| 1346 | |
| 1347 | - @with_lightdm_mock("single-pin") |
| 1348 | def test_can_unlock_pin_screen(self): |
| 1349 | """Must be able to unlock the PIN entry lock screen.""" |
| 1350 | + |
| 1351 | + self._environment['LIBLIGHTDM_MOCK_MODE'] = "single-pin" |
| 1352 | self.launch_unity() |
| 1353 | greeter = self.main_window.get_greeter() |
| 1354 | |
| 1355 | @@ -56,9 +56,10 @@ |
| 1356 | self._enter_prompt_passphrase("1234\n") |
| 1357 | self.assertThat(greeter.shown, Eventually(Equals(False))) |
| 1358 | |
| 1359 | - @with_lightdm_mock("single-passphrase") |
| 1360 | def test_can_unlock_passphrase_screen(self): |
| 1361 | """Must be able to unlock the passphrase entry screen.""" |
| 1362 | + |
| 1363 | + self._environment['LIBLIGHTDM_MOCK_MODE'] = "single-passphrase" |
| 1364 | self.launch_unity() |
| 1365 | greeter = self.main_window.get_greeter() |
| 1366 | |
| 1367 | @@ -71,9 +72,9 @@ |
| 1368 | self._enter_prompt_passphrase("password") |
| 1369 | self.assertThat(greeter.shown, Eventually(Equals(False))) |
| 1370 | |
| 1371 | - @with_lightdm_mock("single-pin") |
| 1372 | def test_pin_screen_wrong_code(self): |
| 1373 | """Entering the wrong pin code must not dismiss the lock screen.""" |
| 1374 | + self._environment['LIBLIGHTDM_MOCK_MODE'] = "single-pin" |
| 1375 | self.launch_unity() |
| 1376 | greeter = self.main_window.get_greeter() |
| 1377 | |
| 1378 | @@ -90,9 +91,9 @@ |
| 1379 | self.assertThat(prompt.text, Eventually(Equals(""))) |
| 1380 | self.assertThat(greeter.shown, Eventually(Equals(True))) |
| 1381 | |
| 1382 | - @with_lightdm_mock("single-passphrase") |
| 1383 | def test_passphrase_screen_wrong_password(self): |
| 1384 | """Entering the wrong password must not dismiss the lock screen.""" |
| 1385 | + self._environment['LIBLIGHTDM_MOCK_MODE'] = "single-passphrase" |
| 1386 | self.launch_unity() |
| 1387 | greeter = self.main_window.get_greeter() |
| 1388 | |
| 1389 | |
| 1390 | === modified file 'tests/mocks/LightDM/CMakeLists.txt' |
| 1391 | --- tests/mocks/LightDM/CMakeLists.txt 2015-01-22 16:41:18 +0000 |
| 1392 | +++ tests/mocks/LightDM/CMakeLists.txt 2015-02-02 14:28:47 +0000 |
| 1393 | @@ -4,16 +4,13 @@ |
| 1394 | # actually using the system liblightdm in the normal plugin, this version can |
| 1395 | # be deleted. |
| 1396 | |
| 1397 | -add_subdirectory(demo) |
| 1398 | -add_subdirectory(full) |
| 1399 | -add_subdirectory(single) |
| 1400 | -add_subdirectory(single-pin) |
| 1401 | -add_subdirectory(single-passphrase) |
| 1402 | +add_subdirectory(liblightdm) |
| 1403 | |
| 1404 | include_directories( |
| 1405 | ${CMAKE_CURRENT_SOURCE_DIR} |
| 1406 | ${CMAKE_CURRENT_BINARY_DIR} |
| 1407 | ${CMAKE_SOURCE_DIR}/plugins/Utils |
| 1408 | + ${CMAKE_SOURCE_DIR}/plugins/LightDM |
| 1409 | ${CMAKE_SOURCE_DIR}/tests/mocks/libusermetrics |
| 1410 | ${libunity8-private_SOURCE_DIR} |
| 1411 | ) |
| 1412 | @@ -22,9 +19,11 @@ |
| 1413 | ${CMAKE_SOURCE_DIR}/plugins/LightDM/DBusGreeter.cpp |
| 1414 | ${CMAKE_SOURCE_DIR}/plugins/LightDM/DBusGreeterList.cpp |
| 1415 | ${CMAKE_SOURCE_DIR}/plugins/LightDM/Greeter.cpp |
| 1416 | - ${CMAKE_SOURCE_DIR}/plugins/LightDM/plugin.cpp |
| 1417 | ${CMAKE_SOURCE_DIR}/plugins/LightDM/UsersModel.cpp |
| 1418 | ${CMAKE_SOURCE_DIR}/plugins/Utils/unitysortfilterproxymodelqml.cpp |
| 1419 | + MockGreeter.cpp |
| 1420 | + MockUsersModel.cpp |
| 1421 | + plugin.cpp |
| 1422 | ) |
| 1423 | |
| 1424 | add_library(MockLightDM-qml MODULE |
| 1425 | @@ -35,9 +34,9 @@ |
| 1426 | # installed on the system. So we make sure we link to our full fake version |
| 1427 | # At run time, we can point to whichever version we happen to be using via |
| 1428 | # LD_LIBRARY_PATH. |
| 1429 | -add_dependencies(MockLightDM-qml MockLightDM-full MockUserMetrics) |
| 1430 | +add_dependencies(MockLightDM-qml MockLightDM MockUserMetrics) |
| 1431 | target_link_libraries(MockLightDM-qml |
| 1432 | - -L${CMAKE_CURRENT_BINARY_DIR}/full |
| 1433 | + -L${CMAKE_CURRENT_BINARY_DIR}/liblightdm |
| 1434 | -llightdm-qt5-2 |
| 1435 | -L${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics |
| 1436 | -lusermetricsoutput |
| 1437 | @@ -49,5 +48,5 @@ |
| 1438 | add_unity8_mock(LightDM 0.1 LightDM |
| 1439 | PREFIX mocks |
| 1440 | TARGETS MockLightDM-qml |
| 1441 | - ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_CURRENT_BINARY_DIR}/full" |
| 1442 | + ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_CURRENT_BINARY_DIR}/liblightdm" |
| 1443 | ) |
| 1444 | |
| 1445 | === added file 'tests/mocks/LightDM/MockGreeter.cpp' |
| 1446 | --- tests/mocks/LightDM/MockGreeter.cpp 1970-01-01 00:00:00 +0000 |
| 1447 | +++ tests/mocks/LightDM/MockGreeter.cpp 2015-02-02 14:28:47 +0000 |
| 1448 | @@ -0,0 +1,35 @@ |
| 1449 | +/* |
| 1450 | + * Copyright (C) 2014 Canonical, Ltd. |
| 1451 | + * |
| 1452 | + * This program is free software; you can redistribute it and/or modify |
| 1453 | + * it under the terms of the GNU General Public License as published by |
| 1454 | + * the Free Software Foundation; version 3. |
| 1455 | + * |
| 1456 | + * This program is distributed in the hope that it will be useful, |
| 1457 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 1458 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 1459 | + * GNU General Public License for more details. |
| 1460 | + * |
| 1461 | + * You should have received a copy of the GNU General Public License |
| 1462 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 1463 | + * |
| 1464 | + */ |
| 1465 | + |
| 1466 | +#include "MockGreeter.h" |
| 1467 | +#include <GreeterPrivate.h> |
| 1468 | + |
| 1469 | +QString MockGreeter::mockMode() const |
| 1470 | +{ |
| 1471 | + Q_D(const Greeter); |
| 1472 | + return d->m_greeter->mockMode(); |
| 1473 | +} |
| 1474 | + |
| 1475 | +void MockGreeter::setMockMode(QString mockMode) |
| 1476 | +{ |
| 1477 | + Q_D(Greeter); |
| 1478 | + |
| 1479 | + if (d->m_greeter->mockMode() != mockMode) { |
| 1480 | + d->m_greeter->setMockMode(mockMode); |
| 1481 | + Q_EMIT mockModeChanged(mockMode); |
| 1482 | + } |
| 1483 | +} |
| 1484 | |
| 1485 | === added file 'tests/mocks/LightDM/MockGreeter.h' |
| 1486 | --- tests/mocks/LightDM/MockGreeter.h 1970-01-01 00:00:00 +0000 |
| 1487 | +++ tests/mocks/LightDM/MockGreeter.h 2015-02-02 14:28:47 +0000 |
| 1488 | @@ -0,0 +1,37 @@ |
| 1489 | +/* |
| 1490 | + * Copyright (C) 2014 Canonical, Ltd. |
| 1491 | + * |
| 1492 | + * This program is free software; you can redistribute it and/or modify |
| 1493 | + * it under the terms of the GNU General Public License as published by |
| 1494 | + * the Free Software Foundation; version 3. |
| 1495 | + * |
| 1496 | + * This program is distributed in the hope that it will be useful, |
| 1497 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 1498 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 1499 | + * GNU General Public License for more details. |
| 1500 | + * |
| 1501 | + * You should have received a copy of the GNU General Public License |
| 1502 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 1503 | + * |
| 1504 | + */ |
| 1505 | + |
| 1506 | +// The real, production, Greeter |
| 1507 | +#include <Greeter.h> |
| 1508 | + |
| 1509 | +#ifndef MOCK_UNITY_GREETER_H |
| 1510 | +#define MOCK_UNITY_GREETER_H |
| 1511 | + |
| 1512 | +class MockGreeter : public Greeter { |
| 1513 | + Q_OBJECT |
| 1514 | + |
| 1515 | + Q_PROPERTY(QString mockMode READ mockMode WRITE setMockMode NOTIFY mockModeChanged) |
| 1516 | + |
| 1517 | +public: |
| 1518 | + QString mockMode() const; |
| 1519 | + void setMockMode(QString mockMode); |
| 1520 | + |
| 1521 | +Q_SIGNALS: |
| 1522 | + void mockModeChanged(QString mode); |
| 1523 | +}; |
| 1524 | + |
| 1525 | +#endif // MOCK_UNITY_GREETER_H |
| 1526 | |
| 1527 | === added file 'tests/mocks/LightDM/MockUsersModel.cpp' |
| 1528 | --- tests/mocks/LightDM/MockUsersModel.cpp 1970-01-01 00:00:00 +0000 |
| 1529 | +++ tests/mocks/LightDM/MockUsersModel.cpp 2015-02-02 14:28:47 +0000 |
| 1530 | @@ -0,0 +1,39 @@ |
| 1531 | +/* |
| 1532 | + * Copyright (C) 2014 Canonical, Ltd. |
| 1533 | + * |
| 1534 | + * This program is free software; you can redistribute it and/or modify |
| 1535 | + * it under the terms of the GNU General Public License as published by |
| 1536 | + * the Free Software Foundation; version 3. |
| 1537 | + * |
| 1538 | + * This program is distributed in the hope that it will be useful, |
| 1539 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 1540 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 1541 | + * GNU General Public License for more details. |
| 1542 | + * |
| 1543 | + * You should have received a copy of the GNU General Public License |
| 1544 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 1545 | + * |
| 1546 | + */ |
| 1547 | + |
| 1548 | +#include "MockUsersModel.h" |
| 1549 | +#include <QLightDM/UsersModel> |
| 1550 | +#include <QSortFilterProxyModel> |
| 1551 | + |
| 1552 | +QString MockUsersModel::mockMode() const |
| 1553 | +{ |
| 1554 | + QLightDM::UsersModel* qUsersModel = |
| 1555 | + static_cast<QLightDM::UsersModel*>(static_cast<QSortFilterProxyModel*>(sourceModel())->sourceModel()); |
| 1556 | + |
| 1557 | + return qUsersModel->mockMode(); |
| 1558 | +} |
| 1559 | + |
| 1560 | +void MockUsersModel::setMockMode(QString mockMode) |
| 1561 | +{ |
| 1562 | + QLightDM::UsersModel* qUsersModel = |
| 1563 | + static_cast<QLightDM::UsersModel*>(static_cast<QSortFilterProxyModel*>(sourceModel())->sourceModel()); |
| 1564 | + |
| 1565 | + if (qUsersModel->mockMode() != mockMode) { |
| 1566 | + qUsersModel->setMockMode(mockMode); |
| 1567 | + Q_EMIT mockModeChanged(mockMode); |
| 1568 | + } |
| 1569 | +} |
| 1570 | |
| 1571 | === added file 'tests/mocks/LightDM/MockUsersModel.h' |
| 1572 | --- tests/mocks/LightDM/MockUsersModel.h 1970-01-01 00:00:00 +0000 |
| 1573 | +++ tests/mocks/LightDM/MockUsersModel.h 2015-02-02 14:28:47 +0000 |
| 1574 | @@ -0,0 +1,37 @@ |
| 1575 | +/* |
| 1576 | + * Copyright (C) 2014 Canonical, Ltd. |
| 1577 | + * |
| 1578 | + * This program is free software; you can redistribute it and/or modify |
| 1579 | + * it under the terms of the GNU General Public License as published by |
| 1580 | + * the Free Software Foundation; version 3. |
| 1581 | + * |
| 1582 | + * This program is distributed in the hope that it will be useful, |
| 1583 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 1584 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 1585 | + * GNU General Public License for more details. |
| 1586 | + * |
| 1587 | + * You should have received a copy of the GNU General Public License |
| 1588 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 1589 | + * |
| 1590 | + */ |
| 1591 | + |
| 1592 | +#ifndef MOCK_UNITY_USERSMODEL_H |
| 1593 | +#define MOCK_UNITY_USERSMODEL_H |
| 1594 | + |
| 1595 | +#include <UsersModel.h> |
| 1596 | + |
| 1597 | +class MockUsersModel : public UsersModel |
| 1598 | +{ |
| 1599 | + Q_OBJECT |
| 1600 | + |
| 1601 | + Q_PROPERTY(QString mockMode READ mockMode WRITE setMockMode NOTIFY mockModeChanged) |
| 1602 | + |
| 1603 | +public: |
| 1604 | + QString mockMode() const; |
| 1605 | + void setMockMode(QString mockMode); |
| 1606 | + |
| 1607 | +Q_SIGNALS: |
| 1608 | + void mockModeChanged(QString mode); |
| 1609 | +}; |
| 1610 | + |
| 1611 | +#endif // MOCK_UNITY_USERSMODEL_H |
| 1612 | |
| 1613 | === added file 'tests/mocks/LightDM/QLightDM/Greeter' |
| 1614 | --- tests/mocks/LightDM/QLightDM/Greeter 1970-01-01 00:00:00 +0000 |
| 1615 | +++ tests/mocks/LightDM/QLightDM/Greeter 2015-02-02 14:28:47 +0000 |
| 1616 | @@ -0,0 +1,17 @@ |
| 1617 | +/* |
| 1618 | + * Copyright (C) 2014 Canonical, Ltd. |
| 1619 | + * |
| 1620 | + * This program is free software; you can redistribute it and/or modify |
| 1621 | + * it under the terms of the GNU General Public License as published by |
| 1622 | + * the Free Software Foundation; version 3. |
| 1623 | + * |
| 1624 | + * This program is distributed in the hope that it will be useful, |
| 1625 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 1626 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 1627 | + * GNU General Public License for more details. |
| 1628 | + * |
| 1629 | + * You should have received a copy of the GNU General Public License |
| 1630 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 1631 | + */ |
| 1632 | + |
| 1633 | +#include "../liblightdm/Greeter.h" |
| 1634 | |
| 1635 | === removed symlink 'tests/mocks/LightDM/QLightDM/Greeter' |
| 1636 | === target was u'../Greeter.h' |
| 1637 | === removed symlink 'tests/mocks/LightDM/QLightDM/InfographicModel' |
| 1638 | === target was u'../InfographicModel.h' |
| 1639 | === added file 'tests/mocks/LightDM/QLightDM/UsersModel' |
| 1640 | --- tests/mocks/LightDM/QLightDM/UsersModel 1970-01-01 00:00:00 +0000 |
| 1641 | +++ tests/mocks/LightDM/QLightDM/UsersModel 2015-02-02 14:28:47 +0000 |
| 1642 | @@ -0,0 +1,17 @@ |
| 1643 | +/* |
| 1644 | + * Copyright (C) 2014 Canonical, Ltd. |
| 1645 | + * |
| 1646 | + * This program is free software; you can redistribute it and/or modify |
| 1647 | + * it under the terms of the GNU General Public License as published by |
| 1648 | + * the Free Software Foundation; version 3. |
| 1649 | + * |
| 1650 | + * This program is distributed in the hope that it will be useful, |
| 1651 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 1652 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 1653 | + * GNU General Public License for more details. |
| 1654 | + * |
| 1655 | + * You should have received a copy of the GNU General Public License |
| 1656 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 1657 | + */ |
| 1658 | + |
| 1659 | +#include "../liblightdm/UsersModel.h" |
| 1660 | |
| 1661 | === removed symlink 'tests/mocks/LightDM/QLightDM/UsersModel' |
| 1662 | === target was u'../UsersModel.h' |
| 1663 | === removed directory 'tests/mocks/LightDM/demo' |
| 1664 | === removed file 'tests/mocks/LightDM/demo/CMakeLists.txt' |
| 1665 | --- tests/mocks/LightDM/demo/CMakeLists.txt 2015-01-12 10:40:46 +0000 |
| 1666 | +++ tests/mocks/LightDM/demo/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
| 1667 | @@ -1,37 +0,0 @@ |
| 1668 | -pkg_check_modules(LIBUSERMETRICSOUTPUT REQUIRED libusermetricsoutput-1) |
| 1669 | - |
| 1670 | -set(LibLightDM_SOURCES |
| 1671 | - ../Greeter.cpp |
| 1672 | - ../UsersModel.cpp |
| 1673 | - GreeterPrivate.cpp |
| 1674 | - UsersModelPrivate.cpp |
| 1675 | - ${CMAKE_SOURCE_DIR}/plugins/Utils/qvariantlistmodel.cpp |
| 1676 | - ) |
| 1677 | - |
| 1678 | -add_library(MockLightDM-demo STATIC ${LibLightDM_SOURCES}) |
| 1679 | -add_library(MockLightDM-demo-shared SHARED ${LibLightDM_SOURCES}) |
| 1680 | - |
| 1681 | -include_directories( |
| 1682 | - ${CMAKE_CURRENT_BINARY_DIR} |
| 1683 | - ${LIBUSERMETRICSOUTPUT_INCLUDE_DIRS} |
| 1684 | -) |
| 1685 | - |
| 1686 | -target_link_libraries(MockLightDM-demo |
| 1687 | - ${LIBUSERMETRICSOUTPUT_LDFLAGS} |
| 1688 | - -lpam |
| 1689 | -) |
| 1690 | -target_link_libraries(MockLightDM-demo-shared |
| 1691 | - ${LIBUSERMETRICSOUTPUT_LDFLAGS} |
| 1692 | - -lpam |
| 1693 | -) |
| 1694 | - |
| 1695 | -qt5_use_modules(MockLightDM-demo Concurrent Gui) |
| 1696 | -qt5_use_modules(MockLightDM-demo-shared Concurrent Gui) |
| 1697 | - |
| 1698 | -set_target_properties(MockLightDM-demo PROPERTIES COMPILE_FLAGS -fPIC) |
| 1699 | -set_target_properties(MockLightDM-demo-shared PROPERTIES |
| 1700 | - OUTPUT_NAME lightdm-qt5-2) |
| 1701 | - |
| 1702 | -install(TARGETS MockLightDM-demo-shared |
| 1703 | - DESTINATION ${SHELL_INSTALL_QML}/mocks/LightDM/demo |
| 1704 | - ) |
| 1705 | |
| 1706 | === removed file 'tests/mocks/LightDM/demo/GreeterPrivate.cpp' |
| 1707 | --- tests/mocks/LightDM/demo/GreeterPrivate.cpp 2014-08-26 08:14:44 +0000 |
| 1708 | +++ tests/mocks/LightDM/demo/GreeterPrivate.cpp 1970-01-01 00:00:00 +0000 |
| 1709 | @@ -1,281 +0,0 @@ |
| 1710 | -/* |
| 1711 | - * Copyright (C) 2013 Canonical, Ltd. |
| 1712 | - * |
| 1713 | - * This program is free software; you can redistribute it and/or modify |
| 1714 | - * it under the terms of the GNU General Public License as published by |
| 1715 | - * the Free Software Foundation; version 3. |
| 1716 | - * |
| 1717 | - * This program is distributed in the hope that it will be useful, |
| 1718 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 1719 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 1720 | - * GNU General Public License for more details. |
| 1721 | - * |
| 1722 | - * You should have received a copy of the GNU General Public License |
| 1723 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 1724 | - * |
| 1725 | - * Author: Michael Terry <michael.terry@canonical.com> |
| 1726 | - */ |
| 1727 | - |
| 1728 | -#include "../Greeter.h" |
| 1729 | -#include "../GreeterPrivate.h" |
| 1730 | -#include <QFuture> |
| 1731 | -#include <QFutureInterface> |
| 1732 | -#include <QFutureWatcher> |
| 1733 | -#include <QQueue> |
| 1734 | -#include <QtConcurrent> |
| 1735 | -#include <QVector> |
| 1736 | -#include <security/pam_appl.h> |
| 1737 | - |
| 1738 | -namespace QLightDM |
| 1739 | -{ |
| 1740 | - |
| 1741 | -class GreeterImpl : public QObject |
| 1742 | -{ |
| 1743 | - Q_OBJECT |
| 1744 | - |
| 1745 | - struct AppData |
| 1746 | - { |
| 1747 | - GreeterImpl *impl; |
| 1748 | - pam_handle *handle; |
| 1749 | - }; |
| 1750 | - |
| 1751 | - typedef QFutureInterface<QString> ResponseFuture; |
| 1752 | - |
| 1753 | -public: |
| 1754 | - explicit GreeterImpl(Greeter *parent, GreeterPrivate *greeterPrivate) |
| 1755 | - : QObject(parent), |
| 1756 | - greeter(parent), |
| 1757 | - greeterPrivate(greeterPrivate), |
| 1758 | - pamHandle(nullptr) |
| 1759 | - { |
| 1760 | - qRegisterMetaType<QLightDM::GreeterImpl::ResponseFuture>("QLightDM::GreeterImpl::ResponseFuture"); |
| 1761 | - |
| 1762 | - connect(&futureWatcher, SIGNAL(finished()), |
| 1763 | - this, SLOT(finishPam())); |
| 1764 | - connect(this, SIGNAL(showMessage(pam_handle *, QString, QLightDM::Greeter::MessageType)), |
| 1765 | - this, SLOT(handleMessage(pam_handle *, QString, QLightDM::Greeter::MessageType))); |
| 1766 | - // This next connect is how we pass ResponseFutures between threads |
| 1767 | - connect(this, SIGNAL(showPrompt(pam_handle *, QString, QLightDM::Greeter::PromptType, QLightDM::GreeterImpl::ResponseFuture)), |
| 1768 | - this, SLOT(handlePrompt(pam_handle *, QString, QLightDM::Greeter::PromptType, QLightDM::GreeterImpl::ResponseFuture))); |
| 1769 | - } |
| 1770 | - |
| 1771 | - ~GreeterImpl() |
| 1772 | - { |
| 1773 | - cancelPam(); |
| 1774 | - } |
| 1775 | - |
| 1776 | - void start(QString username) |
| 1777 | - { |
| 1778 | - // Clear out any existing PAM interactions first |
| 1779 | - cancelPam(); |
| 1780 | - |
| 1781 | - AppData *appData = new AppData(); |
| 1782 | - appData->impl = this; |
| 1783 | - |
| 1784 | - // Now actually start a new conversation with PAM |
| 1785 | - pam_conv conversation; |
| 1786 | - conversation.conv = converseWithPam; |
| 1787 | - conversation.appdata_ptr = static_cast<void*>(appData); |
| 1788 | - |
| 1789 | - if (pam_start("lightdm", username.toUtf8(), &conversation, &pamHandle) == PAM_SUCCESS) { |
| 1790 | - appData->handle = pamHandle; |
| 1791 | - futureWatcher.setFuture(QtConcurrent::run(authenticateWithPam, pamHandle)); |
| 1792 | - } else { |
| 1793 | - delete appData; |
| 1794 | - greeterPrivate->authenticated = false; |
| 1795 | - Q_EMIT greeter->showMessage("Internal error: could not start PAM authentication", QLightDM::Greeter::MessageTypeError); |
| 1796 | - Q_EMIT greeter->authenticationComplete(); |
| 1797 | - } |
| 1798 | - } |
| 1799 | - |
| 1800 | - static int authenticateWithPam(pam_handle* pamHandle) |
| 1801 | - { |
| 1802 | - int pamStatus = pam_authenticate(pamHandle, 0); |
| 1803 | - if (pamStatus == PAM_SUCCESS) { |
| 1804 | - pamStatus = pam_acct_mgmt(pamHandle, 0); |
| 1805 | - } |
| 1806 | - if (pamStatus == PAM_NEW_AUTHTOK_REQD) { |
| 1807 | - pamStatus = pam_chauthtok(pamHandle, PAM_CHANGE_EXPIRED_AUTHTOK); |
| 1808 | - } |
| 1809 | - if (pamStatus == PAM_SUCCESS) { |
| 1810 | - pam_setcred(pamHandle, PAM_REINITIALIZE_CRED); |
| 1811 | - } |
| 1812 | - return pamStatus; |
| 1813 | - } |
| 1814 | - |
| 1815 | - static int converseWithPam(int num_msg, const pam_message** msg, |
| 1816 | - pam_response** resp, void* appdata_ptr) |
| 1817 | - { |
| 1818 | - if (num_msg <= 0) |
| 1819 | - return PAM_CONV_ERR; |
| 1820 | - |
| 1821 | - auto* tmp_response = static_cast<pam_response*>(calloc(num_msg, sizeof(pam_response))); |
| 1822 | - if (!tmp_response) |
| 1823 | - return PAM_CONV_ERR; |
| 1824 | - |
| 1825 | - AppData *appData = static_cast<AppData*>(appdata_ptr); |
| 1826 | - GreeterImpl *impl = appData->impl; |
| 1827 | - pam_handle *handle = appData->handle; |
| 1828 | - |
| 1829 | - int count; |
| 1830 | - QVector<ResponseFuture> responses; |
| 1831 | - |
| 1832 | - for (count = 0; count < num_msg; ++count) |
| 1833 | - { |
| 1834 | - switch (msg[count]->msg_style) |
| 1835 | - { |
| 1836 | - case PAM_PROMPT_ECHO_ON: |
| 1837 | - { |
| 1838 | - QString message(msg[count]->msg); |
| 1839 | - responses.append(ResponseFuture()); |
| 1840 | - responses.last().reportStarted(); |
| 1841 | - Q_EMIT impl->showPrompt(handle, message, Greeter::PromptTypeQuestion, responses.last()); |
| 1842 | - break; |
| 1843 | - } |
| 1844 | - case PAM_PROMPT_ECHO_OFF: |
| 1845 | - { |
| 1846 | - QString message(msg[count]->msg); |
| 1847 | - responses.append(ResponseFuture()); |
| 1848 | - responses.last().reportStarted(); |
| 1849 | - Q_EMIT impl->showPrompt(handle, message, Greeter::PromptTypeSecret, responses.last()); |
| 1850 | - break; |
| 1851 | - } |
| 1852 | - case PAM_TEXT_INFO: |
| 1853 | - { |
| 1854 | - QString message(msg[count]->msg); |
| 1855 | - Q_EMIT impl->showMessage(handle, message, Greeter::MessageTypeInfo); |
| 1856 | - break; |
| 1857 | - } |
| 1858 | - default: |
| 1859 | - { |
| 1860 | - QString message(msg[count]->msg); |
| 1861 | - Q_EMIT impl->showMessage(handle, message, Greeter::MessageTypeError); |
| 1862 | - break; |
| 1863 | - } |
| 1864 | - } |
| 1865 | - } |
| 1866 | - |
| 1867 | - int i = 0; |
| 1868 | - bool raise_error = false; |
| 1869 | - |
| 1870 | - for (auto &response : responses) |
| 1871 | - { |
| 1872 | - pam_response* resp_item = &tmp_response[i++]; |
| 1873 | - resp_item->resp_retcode = 0; |
| 1874 | - resp_item->resp = strdup(response.future().result().toUtf8()); |
| 1875 | - |
| 1876 | - if (!resp_item->resp) |
| 1877 | - { |
| 1878 | - raise_error = true; |
| 1879 | - break; |
| 1880 | - } |
| 1881 | - } |
| 1882 | - |
| 1883 | - delete appData; |
| 1884 | - |
| 1885 | - if (raise_error) |
| 1886 | - { |
| 1887 | - for (int i = 0; i < count; ++i) |
| 1888 | - free(tmp_response[i].resp); |
| 1889 | - |
| 1890 | - free(tmp_response); |
| 1891 | - return PAM_CONV_ERR; |
| 1892 | - } |
| 1893 | - else |
| 1894 | - { |
| 1895 | - *resp = tmp_response; |
| 1896 | - return PAM_SUCCESS; |
| 1897 | - } |
| 1898 | - } |
| 1899 | - |
| 1900 | -public Q_SLOTS: |
| 1901 | - bool respond(QString response) |
| 1902 | - { |
| 1903 | - if (!futures.isEmpty()) { |
| 1904 | - futures.dequeue().reportFinished(&response); |
| 1905 | - return true; |
| 1906 | - } else { |
| 1907 | - return false; |
| 1908 | - } |
| 1909 | - } |
| 1910 | - |
| 1911 | -Q_SIGNALS: |
| 1912 | - void showMessage(pam_handle *handle, QString text, QLightDM::Greeter::MessageType type); |
| 1913 | - void showPrompt(pam_handle *handle, QString text, QLightDM::Greeter::PromptType type, QLightDM::GreeterImpl::ResponseFuture response); |
| 1914 | - |
| 1915 | -private Q_SLOTS: |
| 1916 | - void finishPam() |
| 1917 | - { |
| 1918 | - if (pamHandle == nullptr) { |
| 1919 | - return; |
| 1920 | - } |
| 1921 | - |
| 1922 | - int pamStatus = futureWatcher.result(); |
| 1923 | - |
| 1924 | - pam_end(pamHandle, pamStatus); |
| 1925 | - pamHandle = nullptr; |
| 1926 | - |
| 1927 | - greeterPrivate->authenticated = (pamStatus == PAM_SUCCESS); |
| 1928 | - Q_EMIT greeter->authenticationComplete(); |
| 1929 | - } |
| 1930 | - |
| 1931 | - void handleMessage(pam_handle *handle, QString text, QLightDM::Greeter::MessageType type) |
| 1932 | - { |
| 1933 | - if (handle != pamHandle) |
| 1934 | - return; |
| 1935 | - |
| 1936 | - Q_EMIT greeter->showMessage(text, type); |
| 1937 | - } |
| 1938 | - |
| 1939 | - void handlePrompt(pam_handle *handle, QString text, QLightDM::Greeter::PromptType type, QLightDM::GreeterImpl::ResponseFuture future) |
| 1940 | - { |
| 1941 | - if (handle != pamHandle) { |
| 1942 | - future.reportResult(QString()); |
| 1943 | - future.reportFinished(); |
| 1944 | - return; |
| 1945 | - } |
| 1946 | - |
| 1947 | - futures.enqueue(future); |
| 1948 | - Q_EMIT greeter->showPrompt(text, type); |
| 1949 | - } |
| 1950 | - |
| 1951 | -private: |
| 1952 | - void cancelPam() |
| 1953 | - { |
| 1954 | - // Unfortunately we can't simply cancel our QFuture because QtConcurrent::run doesn't support cancel |
| 1955 | - if (pamHandle != nullptr) { |
| 1956 | - pam_handle *handle = pamHandle; |
| 1957 | - pamHandle = nullptr; // to disable normal finishPam() handling |
| 1958 | - while (respond(QString())); // clear our local queue of QFutures |
| 1959 | - pam_end(handle, PAM_CONV_ERR); |
| 1960 | - } |
| 1961 | - } |
| 1962 | - |
| 1963 | - Greeter *greeter; |
| 1964 | - GreeterPrivate *greeterPrivate; |
| 1965 | - pam_handle* pamHandle; |
| 1966 | - QFutureWatcher<int> futureWatcher; |
| 1967 | - QQueue<ResponseFuture> futures; |
| 1968 | -}; |
| 1969 | - |
| 1970 | -GreeterPrivate::GreeterPrivate(Greeter* parent) |
| 1971 | - : authenticated(false), |
| 1972 | - authenticationUser(), |
| 1973 | - m_impl(new GreeterImpl(parent, this)), |
| 1974 | - q_ptr(parent) |
| 1975 | -{ |
| 1976 | -} |
| 1977 | - |
| 1978 | -void GreeterPrivate::handleAuthenticate() |
| 1979 | -{ |
| 1980 | - m_impl->start(authenticationUser); |
| 1981 | -} |
| 1982 | - |
| 1983 | -void GreeterPrivate::handleRespond(const QString &response) |
| 1984 | -{ |
| 1985 | - m_impl->respond(response); |
| 1986 | -} |
| 1987 | - |
| 1988 | -} |
| 1989 | - |
| 1990 | -#include "GreeterPrivate.moc" |
| 1991 | |
| 1992 | === removed file 'tests/mocks/LightDM/demo/UsersModelPrivate.cpp' |
| 1993 | --- tests/mocks/LightDM/demo/UsersModelPrivate.cpp 2014-07-15 16:38:02 +0000 |
| 1994 | +++ tests/mocks/LightDM/demo/UsersModelPrivate.cpp 1970-01-01 00:00:00 +0000 |
| 1995 | @@ -1,41 +0,0 @@ |
| 1996 | -/* |
| 1997 | - * Copyright (C) 2013 Canonical, Ltd. |
| 1998 | - * |
| 1999 | - * This program is free software; you can redistribute it and/or modify |
| 2000 | - * it under the terms of the GNU General Public License as published by |
| 2001 | - * the Free Software Foundation; version 3. |
| 2002 | - * |
| 2003 | - * This program is distributed in the hope that it will be useful, |
| 2004 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 2005 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 2006 | - * GNU General Public License for more details. |
| 2007 | - * |
| 2008 | - * You should have received a copy of the GNU General Public License |
| 2009 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 2010 | - * |
| 2011 | - * Author: Michael Terry <michael.terry@canonical.com> |
| 2012 | - */ |
| 2013 | - |
| 2014 | -#include "../UsersModelPrivate.h" |
| 2015 | - |
| 2016 | -#include <QDir> |
| 2017 | -#include <QSettings> |
| 2018 | -#include <QStringList> |
| 2019 | - |
| 2020 | -namespace QLightDM |
| 2021 | -{ |
| 2022 | - |
| 2023 | -UsersModelPrivate::UsersModelPrivate(UsersModel* parent) |
| 2024 | - : q_ptr(parent) |
| 2025 | -{ |
| 2026 | - QSettings settings(QDir::homePath() + "/.unity8-greeter-demo", QSettings::NativeFormat); |
| 2027 | - QStringList users = settings.value("users", QStringList() << qgetenv("USER")).toStringList(); |
| 2028 | - |
| 2029 | - Q_FOREACH(const QString &user, users) |
| 2030 | - { |
| 2031 | - QString name = settings.value(user + "/name", user[0].toUpper() + user.mid(1)).toString(); |
| 2032 | - entries.append({user, name, 0, 0, false, false, 0, 0}); |
| 2033 | - } |
| 2034 | -} |
| 2035 | - |
| 2036 | -} |
| 2037 | |
| 2038 | === removed directory 'tests/mocks/LightDM/full' |
| 2039 | === removed file 'tests/mocks/LightDM/full/CMakeLists.txt' |
| 2040 | --- tests/mocks/LightDM/full/CMakeLists.txt 2014-06-11 15:36:51 +0000 |
| 2041 | +++ tests/mocks/LightDM/full/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
| 2042 | @@ -1,18 +0,0 @@ |
| 2043 | -set(LibLightDM_SOURCES |
| 2044 | - ../Greeter.cpp |
| 2045 | - ../UsersModel.cpp |
| 2046 | - GreeterPrivate.cpp |
| 2047 | - UsersModelPrivate.cpp |
| 2048 | - ${CMAKE_SOURCE_DIR}/plugins/Utils/qvariantlistmodel.cpp |
| 2049 | - ) |
| 2050 | - |
| 2051 | -add_library(MockLightDM-full SHARED ${LibLightDM_SOURCES}) |
| 2052 | - |
| 2053 | -qt5_use_modules(MockLightDM-full Gui) |
| 2054 | - |
| 2055 | -set_target_properties(MockLightDM-full PROPERTIES |
| 2056 | - OUTPUT_NAME lightdm-qt5-2) |
| 2057 | - |
| 2058 | -install(TARGETS MockLightDM-full |
| 2059 | - DESTINATION ${SHELL_INSTALL_QML}/mocks/LightDM/full |
| 2060 | - ) |
| 2061 | |
| 2062 | === removed file 'tests/mocks/LightDM/full/GreeterPrivate.cpp' |
| 2063 | --- tests/mocks/LightDM/full/GreeterPrivate.cpp 2014-08-06 15:27:57 +0000 |
| 2064 | +++ tests/mocks/LightDM/full/GreeterPrivate.cpp 1970-01-01 00:00:00 +0000 |
| 2065 | @@ -1,98 +0,0 @@ |
| 2066 | -/* |
| 2067 | - * Copyright (C) 2013 Canonical, Ltd. |
| 2068 | - * |
| 2069 | - * This program is free software; you can redistribute it and/or modify |
| 2070 | - * it under the terms of the GNU General Public License as published by |
| 2071 | - * the Free Software Foundation; version 3. |
| 2072 | - * |
| 2073 | - * This program is distributed in the hope that it will be useful, |
| 2074 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 2075 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 2076 | - * GNU General Public License for more details. |
| 2077 | - * |
| 2078 | - * You should have received a copy of the GNU General Public License |
| 2079 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 2080 | - * |
| 2081 | - * Author: Michael Terry <michael.terry@canonical.com> |
| 2082 | - */ |
| 2083 | - |
| 2084 | -#include "../Greeter.h" |
| 2085 | -#include "../GreeterPrivate.h" |
| 2086 | - |
| 2087 | -namespace QLightDM |
| 2088 | -{ |
| 2089 | - |
| 2090 | -GreeterPrivate::GreeterPrivate(Greeter* parent) |
| 2091 | - : authenticated(false), |
| 2092 | - authenticationUser(), |
| 2093 | - twoFactorDone(false), |
| 2094 | - q_ptr(parent) |
| 2095 | -{ |
| 2096 | -} |
| 2097 | - |
| 2098 | -void GreeterPrivate::handleAuthenticate() |
| 2099 | -{ |
| 2100 | - Q_Q(Greeter); |
| 2101 | - |
| 2102 | - // Send out any messages we need to |
| 2103 | - if (authenticationUser == "info-prompt") |
| 2104 | - Q_EMIT q->showMessage("Welcome to Unity Greeter", Greeter::MessageTypeInfo); |
| 2105 | - else if (authenticationUser == "wide-info-prompt") |
| 2106 | - Q_EMIT q->showMessage("Welcome to Unity Greeter, the greeteriest greeter that ever did appear in these fine lands", Greeter::MessageTypeInfo); |
| 2107 | - else if (authenticationUser == "html-info-prompt") |
| 2108 | - Q_EMIT q->showMessage("<b>&</b>", Greeter::MessageTypeInfo); |
| 2109 | - else if (authenticationUser == "long-info-prompt") |
| 2110 | - 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); |
| 2111 | - else if (authenticationUser == "multi-info-prompt") { |
| 2112 | - Q_EMIT q->showMessage("Welcome to Unity Greeter", Greeter::MessageTypeInfo); |
| 2113 | - Q_EMIT q->showMessage("This is an error", Greeter::MessageTypeError); |
| 2114 | - Q_EMIT q->showMessage("You should have seen three messages", Greeter::MessageTypeInfo); |
| 2115 | - } |
| 2116 | - |
| 2117 | - // OK, now actually do the prompt |
| 2118 | - if (authenticationUser == "no-password") { |
| 2119 | - authenticated = true; |
| 2120 | - Q_EMIT q->authenticationComplete(); |
| 2121 | - } else if (authenticationUser == "has-pin"){ |
| 2122 | - Q_EMIT q->showPrompt("Password: ", Greeter::PromptTypeSecret); |
| 2123 | - } else if (authenticationUser == "auth-error") { |
| 2124 | - authenticated = false; |
| 2125 | - Q_EMIT q->authenticationComplete(); |
| 2126 | - } else if (authenticationUser == "different-prompt") { |
| 2127 | - Q_EMIT q->showPrompt("Secret word: ", Greeter::PromptTypeSecret); |
| 2128 | - } else { |
| 2129 | - Q_EMIT q->showPrompt("Password: ", Greeter::PromptTypeSecret); |
| 2130 | - } |
| 2131 | -} |
| 2132 | - |
| 2133 | -void GreeterPrivate::handleRespond(const QString &response) |
| 2134 | -{ |
| 2135 | - Q_Q(Greeter); |
| 2136 | - |
| 2137 | - if (authenticationUser == "no-response") |
| 2138 | - return; |
| 2139 | - else if (authenticationUser == "two-factor") { |
| 2140 | - if (!twoFactorDone) { |
| 2141 | - if (response == "password") { |
| 2142 | - twoFactorDone = true; |
| 2143 | - Q_EMIT q->showPrompt("otp", Greeter::PromptTypeQuestion); |
| 2144 | - } else { |
| 2145 | - authenticated = false; |
| 2146 | - q->sendAuthenticationComplete(); |
| 2147 | - } |
| 2148 | - } else { |
| 2149 | - authenticated = (response == "otp"); |
| 2150 | - q->sendAuthenticationComplete(); |
| 2151 | - } |
| 2152 | - return; |
| 2153 | - } |
| 2154 | - |
| 2155 | - if (authenticationUser == "has-pin") { |
| 2156 | - authenticated = (response == "1234"); |
| 2157 | - } else { |
| 2158 | - authenticated = (response == "password"); |
| 2159 | - } |
| 2160 | - q->sendAuthenticationComplete(); |
| 2161 | -} |
| 2162 | - |
| 2163 | -} |
| 2164 | |
| 2165 | === removed file 'tests/mocks/LightDM/full/UsersModelPrivate.cpp' |
| 2166 | --- tests/mocks/LightDM/full/UsersModelPrivate.cpp 2013-06-11 10:30:07 +0000 |
| 2167 | +++ tests/mocks/LightDM/full/UsersModelPrivate.cpp 1970-01-01 00:00:00 +0000 |
| 2168 | @@ -1,52 +0,0 @@ |
| 2169 | -/* |
| 2170 | - * Copyright (C) 2013 Canonical, Ltd. |
| 2171 | - * |
| 2172 | - * This program is free software; you can redistribute it and/or modify |
| 2173 | - * it under the terms of the GNU General Public License as published by |
| 2174 | - * the Free Software Foundation; version 3. |
| 2175 | - * |
| 2176 | - * This program is distributed in the hope that it will be useful, |
| 2177 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 2178 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 2179 | - * GNU General Public License for more details. |
| 2180 | - * |
| 2181 | - * You should have received a copy of the GNU General Public License |
| 2182 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 2183 | - * |
| 2184 | - * Author: Michael Terry <michael.terry@canonical.com> |
| 2185 | - */ |
| 2186 | - |
| 2187 | -#include "../UsersModelPrivate.h" |
| 2188 | - |
| 2189 | -namespace QLightDM |
| 2190 | -{ |
| 2191 | - |
| 2192 | -UsersModelPrivate::UsersModelPrivate(UsersModel* parent) |
| 2193 | - : q_ptr(parent) |
| 2194 | -{ |
| 2195 | - entries = |
| 2196 | - { |
| 2197 | - { "has-password", "Has Password", 0, 0, false, false, 0, 0 }, |
| 2198 | - { "has-pin", "Has PIN", 0, 0, false, false, 0, 0 }, |
| 2199 | - { "different-prompt", "Different Prompt", 0, 0, false, false, 0, 0 }, |
| 2200 | - { "no-password", "No Password", 0, 0, false, false, 0, 0 }, |
| 2201 | - { "auth-error", "Auth Error", 0, 0, false, false, 0, 0 }, |
| 2202 | - { "two-factor", "Two Factor", 0, 0, false, false, 0, 0 }, |
| 2203 | - { "info-prompt", "Info Prompt", 0, 0, false, false, 0, 0 }, |
| 2204 | - { "html-info-prompt", "HTML Info Prompt", 0, 0, false, false, 0, 0 }, |
| 2205 | - { "long-info-prompt", "Long Info Prompt", 0, 0, false, false, 0, 0 }, |
| 2206 | - { "wide-info-prompt", "Wide Info Prompt", 0, 0, false, false, 0, 0 }, |
| 2207 | - { "multi-info-prompt", "Multi Info Prompt", 0, 0, false, false, 0, 0 }, |
| 2208 | - { "long-name", "Long name (far far too long to fit)", 0, 0, false, false, 0, 0 }, |
| 2209 | - { "color-background", "Color Background", "#dd4814", 0, false, false, 0, 0 }, |
| 2210 | - // white and black are a bit redundant, but useful for manually testing if UI is still readable |
| 2211 | - { "white-background", "White Background", "#ffffff", 0, false, false, 0, 0 }, |
| 2212 | - { "black-background", "Black Background", "#000000", 0, false, false, 0, 0 }, |
| 2213 | - { "no-background", "No Background", "", 0, false, false, 0, 0 }, |
| 2214 | - { "unicode", "가나다라마", 0, 0, false, false, 0, 0 }, |
| 2215 | - { "no-response", "No Response", 0, 0, false, false, 0, 0 }, |
| 2216 | - { "empty-name", "", 0, 0, false, false, 0, 0 }, |
| 2217 | - }; |
| 2218 | -} |
| 2219 | - |
| 2220 | -} |
| 2221 | |
| 2222 | === added directory 'tests/mocks/LightDM/liblightdm' |
| 2223 | === added file 'tests/mocks/LightDM/liblightdm/CMakeLists.txt' |
| 2224 | --- tests/mocks/LightDM/liblightdm/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
| 2225 | +++ tests/mocks/LightDM/liblightdm/CMakeLists.txt 2015-02-02 14:28:47 +0000 |
| 2226 | @@ -0,0 +1,18 @@ |
| 2227 | +set(LibLightDM_SOURCES |
| 2228 | + Greeter.cpp |
| 2229 | + UsersModel.cpp |
| 2230 | + GreeterPrivate.cpp |
| 2231 | + UsersModelPrivate.cpp |
| 2232 | + ${CMAKE_SOURCE_DIR}/plugins/Utils/qvariantlistmodel.cpp |
| 2233 | + ) |
| 2234 | + |
| 2235 | +add_library(MockLightDM SHARED ${LibLightDM_SOURCES}) |
| 2236 | + |
| 2237 | +qt5_use_modules(MockLightDM Gui) |
| 2238 | + |
| 2239 | +set_target_properties(MockLightDM PROPERTIES |
| 2240 | + OUTPUT_NAME lightdm-qt5-2) |
| 2241 | + |
| 2242 | +install(TARGETS MockLightDM |
| 2243 | + DESTINATION ${SHELL_INSTALL_QML}/mocks/LightDM/liblightdm |
| 2244 | + ) |
| 2245 | |
| 2246 | === renamed file 'tests/mocks/LightDM/Greeter.cpp' => 'tests/mocks/LightDM/liblightdm/Greeter.cpp' |
| 2247 | --- tests/mocks/LightDM/Greeter.cpp 2014-12-09 17:14:35 +0000 |
| 2248 | +++ tests/mocks/LightDM/liblightdm/Greeter.cpp 2015-02-02 14:28:47 +0000 |
| 2249 | @@ -1,5 +1,5 @@ |
| 2250 | /* |
| 2251 | - * Copyright (C) 2013 Canonical, Ltd. |
| 2252 | + * Copyright (C) 2014 Canonical, Ltd. |
| 2253 | * |
| 2254 | * This program is free software; you can redistribute it and/or modify |
| 2255 | * it under the terms of the GNU General Public License as published by |
| 2256 | @@ -12,8 +12,6 @@ |
| 2257 | * |
| 2258 | * You should have received a copy of the GNU General Public License |
| 2259 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 2260 | - * |
| 2261 | - * Author: Michael Terry <michael.terry@canonical.com> |
| 2262 | */ |
| 2263 | |
| 2264 | #include "Greeter.h" |
| 2265 | @@ -181,4 +179,21 @@ |
| 2266 | } |
| 2267 | } |
| 2268 | |
| 2269 | +QString Greeter::mockMode() const |
| 2270 | +{ |
| 2271 | + Q_D(const Greeter); |
| 2272 | + return d->mockMode; |
| 2273 | +} |
| 2274 | + |
| 2275 | + |
| 2276 | +void Greeter::setMockMode(QString mockMode) |
| 2277 | +{ |
| 2278 | + Q_D(Greeter); |
| 2279 | + |
| 2280 | + if (d->mockMode != mockMode) { |
| 2281 | + d->mockMode = mockMode; |
| 2282 | + Q_EMIT mockModeChanged(mockMode); |
| 2283 | + } |
| 2284 | +} |
| 2285 | + |
| 2286 | } |
| 2287 | |
| 2288 | === renamed file 'tests/mocks/LightDM/Greeter.h' => 'tests/mocks/LightDM/liblightdm/Greeter.h' |
| 2289 | --- tests/mocks/LightDM/Greeter.h 2014-12-09 17:14:35 +0000 |
| 2290 | +++ tests/mocks/LightDM/liblightdm/Greeter.h 2015-02-02 14:28:47 +0000 |
| 2291 | @@ -47,6 +47,9 @@ |
| 2292 | |
| 2293 | Q_ENUMS(PromptType MessageType) |
| 2294 | |
| 2295 | + //Mock-only API for testing purposes |
| 2296 | + Q_PROPERTY(QString mockMode READ mockMode WRITE setMockMode NOTIFY mockModeChanged) |
| 2297 | + |
| 2298 | public: |
| 2299 | enum PromptType { |
| 2300 | PromptTypeQuestion, |
| 2301 | @@ -79,6 +82,9 @@ |
| 2302 | QString authenticationUser() const; |
| 2303 | QString hostname() const; |
| 2304 | |
| 2305 | + QString mockMode() const; |
| 2306 | + void setMockMode(QString mockMode); |
| 2307 | + |
| 2308 | public Q_SLOTS: |
| 2309 | bool connectSync(); |
| 2310 | void authenticate(const QString &username=QString()); |
| 2311 | @@ -95,6 +101,7 @@ |
| 2312 | void showPrompt(QString text, QLightDM::Greeter::PromptType type); |
| 2313 | void authenticationComplete(); |
| 2314 | void autologinTimerExpired(); |
| 2315 | + void mockModeChanged(QString mode); |
| 2316 | |
| 2317 | protected: |
| 2318 | void sendAuthenticationComplete(); |
| 2319 | |
| 2320 | === added file 'tests/mocks/LightDM/liblightdm/GreeterPrivate.cpp' |
| 2321 | --- tests/mocks/LightDM/liblightdm/GreeterPrivate.cpp 1970-01-01 00:00:00 +0000 |
| 2322 | +++ tests/mocks/LightDM/liblightdm/GreeterPrivate.cpp 2015-02-02 14:28:47 +0000 |
| 2323 | @@ -0,0 +1,132 @@ |
| 2324 | +/* |
| 2325 | + * Copyright (C) 2014 Canonical, Ltd. |
| 2326 | + * |
| 2327 | + * This program is free software; you can redistribute it and/or modify |
| 2328 | + * it under the terms of the GNU General Public License as published by |
| 2329 | + * the Free Software Foundation; version 3. |
| 2330 | + * |
| 2331 | + * This program is distributed in the hope that it will be useful, |
| 2332 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 2333 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 2334 | + * GNU General Public License for more details. |
| 2335 | + * |
| 2336 | + * You should have received a copy of the GNU General Public License |
| 2337 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 2338 | + */ |
| 2339 | + |
| 2340 | +#include "Greeter.h" |
| 2341 | +#include "GreeterPrivate.h" |
| 2342 | + |
| 2343 | +namespace QLightDM |
| 2344 | +{ |
| 2345 | + |
| 2346 | +GreeterPrivate::GreeterPrivate(Greeter* parent) |
| 2347 | + : authenticated(false), |
| 2348 | + authenticationUser(), |
| 2349 | + twoFactorDone(false), |
| 2350 | + mockMode("single"), |
| 2351 | + q_ptr(parent) |
| 2352 | +{ |
| 2353 | + char *envMockMode = getenv("LIBLIGHTDM_MOCK_MODE"); |
| 2354 | + if (envMockMode) { |
| 2355 | + mockMode = envMockMode; |
| 2356 | + } |
| 2357 | +} |
| 2358 | + |
| 2359 | +void GreeterPrivate::handleAuthenticate() |
| 2360 | +{ |
| 2361 | + Q_Q(Greeter); |
| 2362 | + |
| 2363 | + if (mockMode == "single") { |
| 2364 | + authenticated = true; |
| 2365 | + Q_EMIT q->authenticationComplete(); |
| 2366 | + } else if (mockMode == "single-passphrase" || mockMode == "single-pin") { |
| 2367 | + Q_EMIT q->showPrompt("Password: ", Greeter::PromptTypeSecret); |
| 2368 | + } else if (mockMode == "full") { |
| 2369 | + handleAuthenticate_full(); |
| 2370 | + } |
| 2371 | +} |
| 2372 | + |
| 2373 | +void GreeterPrivate::handleAuthenticate_full() |
| 2374 | +{ |
| 2375 | + Q_Q(Greeter); |
| 2376 | + |
| 2377 | + // Send out any messages we need to |
| 2378 | + if (authenticationUser == "info-prompt") |
| 2379 | + Q_EMIT q->showMessage("Welcome to Unity Greeter", Greeter::MessageTypeInfo); |
| 2380 | + else if (authenticationUser == "wide-info-prompt") |
| 2381 | + Q_EMIT q->showMessage("Welcome to Unity Greeter, the greeteriest greeter that ever did appear in these fine lands", Greeter::MessageTypeInfo); |
| 2382 | + else if (authenticationUser == "html-info-prompt") |
| 2383 | + Q_EMIT q->showMessage("<b>&</b>", Greeter::MessageTypeInfo); |
| 2384 | + else if (authenticationUser == "long-info-prompt") |
| 2385 | + 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); |
| 2386 | + else if (authenticationUser == "multi-info-prompt") { |
| 2387 | + Q_EMIT q->showMessage("Welcome to Unity Greeter", Greeter::MessageTypeInfo); |
| 2388 | + Q_EMIT q->showMessage("This is an error", Greeter::MessageTypeError); |
| 2389 | + Q_EMIT q->showMessage("You should have seen three messages", Greeter::MessageTypeInfo); |
| 2390 | + } |
| 2391 | + |
| 2392 | + // OK, now actually do the prompt |
| 2393 | + if (authenticationUser == "no-password") { |
| 2394 | + authenticated = true; |
| 2395 | + Q_EMIT q->authenticationComplete(); |
| 2396 | + } else if (authenticationUser == "has-pin"){ |
| 2397 | + Q_EMIT q->showPrompt("Password: ", Greeter::PromptTypeSecret); |
| 2398 | + } else if (authenticationUser == "auth-error") { |
| 2399 | + authenticated = false; |
| 2400 | + Q_EMIT q->authenticationComplete(); |
| 2401 | + } else if (authenticationUser == "different-prompt") { |
| 2402 | + Q_EMIT q->showPrompt("Secret word: ", Greeter::PromptTypeSecret); |
| 2403 | + } else { |
| 2404 | + Q_EMIT q->showPrompt("Password: ", Greeter::PromptTypeSecret); |
| 2405 | + } |
| 2406 | +} |
| 2407 | + |
| 2408 | +void GreeterPrivate::handleRespond(QString const &response) |
| 2409 | +{ |
| 2410 | + Q_Q(Greeter); |
| 2411 | + |
| 2412 | + if (mockMode == "single") { |
| 2413 | + // NOOP |
| 2414 | + } else if (mockMode == "single-passphrase") { |
| 2415 | + authenticated = (response == "password"); |
| 2416 | + q->sendAuthenticationComplete(); |
| 2417 | + } else if (mockMode == "single-pin") { |
| 2418 | + authenticated = (response == "1234"); |
| 2419 | + q->sendAuthenticationComplete(); |
| 2420 | + } else if (mockMode == "full") { |
| 2421 | + handleRespond_full(response); |
| 2422 | + } |
| 2423 | +} |
| 2424 | + |
| 2425 | +void GreeterPrivate::handleRespond_full(const QString &response) |
| 2426 | +{ |
| 2427 | + Q_Q(Greeter); |
| 2428 | + |
| 2429 | + if (authenticationUser == "no-response") |
| 2430 | + return; |
| 2431 | + else if (authenticationUser == "two-factor") { |
| 2432 | + if (!twoFactorDone) { |
| 2433 | + if (response == "password") { |
| 2434 | + twoFactorDone = true; |
| 2435 | + Q_EMIT q->showPrompt("otp", Greeter::PromptTypeQuestion); |
| 2436 | + } else { |
| 2437 | + authenticated = false; |
| 2438 | + q->sendAuthenticationComplete(); |
| 2439 | + } |
| 2440 | + } else { |
| 2441 | + authenticated = (response == "otp"); |
| 2442 | + q->sendAuthenticationComplete(); |
| 2443 | + } |
| 2444 | + return; |
| 2445 | + } |
| 2446 | + |
| 2447 | + if (authenticationUser == "has-pin") { |
| 2448 | + authenticated = (response == "1234"); |
| 2449 | + } else { |
| 2450 | + authenticated = (response == "password"); |
| 2451 | + } |
| 2452 | + q->sendAuthenticationComplete(); |
| 2453 | +} |
| 2454 | + |
| 2455 | +} |
| 2456 | |
| 2457 | === renamed file 'tests/mocks/LightDM/GreeterPrivate.h' => 'tests/mocks/LightDM/liblightdm/GreeterPrivate.h' |
| 2458 | --- tests/mocks/LightDM/GreeterPrivate.h 2014-07-01 20:21:23 +0000 |
| 2459 | +++ tests/mocks/LightDM/liblightdm/GreeterPrivate.h 2015-02-02 14:28:47 +0000 |
| 2460 | @@ -1,5 +1,5 @@ |
| 2461 | /* |
| 2462 | - * Copyright (C) 2013 Canonical, Ltd. |
| 2463 | + * Copyright (C) 2014 Canonical, Ltd. |
| 2464 | * |
| 2465 | * This program is free software; you can redistribute it and/or modify |
| 2466 | * it under the terms of the GNU General Public License as published by |
| 2467 | @@ -12,8 +12,6 @@ |
| 2468 | * |
| 2469 | * You should have received a copy of the GNU General Public License |
| 2470 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 2471 | - * |
| 2472 | - * Author: Michael Terry <michael.terry@canonical.com> |
| 2473 | */ |
| 2474 | |
| 2475 | #ifndef UNITY_MOCK_GREETER_PRIVATE_H |
| 2476 | @@ -37,6 +35,8 @@ |
| 2477 | QString authenticationUser; |
| 2478 | bool twoFactorDone; |
| 2479 | |
| 2480 | + QString mockMode; |
| 2481 | + |
| 2482 | void handleAuthenticate(); |
| 2483 | void handleRespond(const QString &response); |
| 2484 | |
| 2485 | @@ -45,6 +45,8 @@ |
| 2486 | Greeter * const q_ptr; |
| 2487 | |
| 2488 | private: |
| 2489 | + void handleAuthenticate_full(); |
| 2490 | + void handleRespond_full(const QString &response); |
| 2491 | Q_DECLARE_PUBLIC(Greeter) |
| 2492 | }; |
| 2493 | } |
| 2494 | |
| 2495 | === renamed file 'tests/mocks/LightDM/UsersModel.cpp' => 'tests/mocks/LightDM/liblightdm/UsersModel.cpp' |
| 2496 | --- tests/mocks/LightDM/UsersModel.cpp 2013-06-05 22:03:08 +0000 |
| 2497 | +++ tests/mocks/LightDM/liblightdm/UsersModel.cpp 2015-02-02 14:28:47 +0000 |
| 2498 | @@ -114,4 +114,21 @@ |
| 2499 | } |
| 2500 | } |
| 2501 | |
| 2502 | +QString UsersModel::mockMode() const |
| 2503 | +{ |
| 2504 | + Q_D(const UsersModel); |
| 2505 | + return d->mockMode; |
| 2506 | +} |
| 2507 | + |
| 2508 | +void UsersModel::setMockMode(QString mockMode) |
| 2509 | +{ |
| 2510 | + Q_D(UsersModel); |
| 2511 | + |
| 2512 | + if (d->mockMode != mockMode) { |
| 2513 | + d->mockMode = mockMode; |
| 2514 | + Q_EMIT mockModeChanged(mockMode); |
| 2515 | + d->resetEntries(); |
| 2516 | + } |
| 2517 | +} |
| 2518 | + |
| 2519 | } |
| 2520 | |
| 2521 | === renamed file 'tests/mocks/LightDM/UsersModel.h' => 'tests/mocks/LightDM/liblightdm/UsersModel.h' |
| 2522 | --- tests/mocks/LightDM/UsersModel.h 2013-06-05 22:03:08 +0000 |
| 2523 | +++ tests/mocks/LightDM/liblightdm/UsersModel.h 2015-02-02 14:28:47 +0000 |
| 2524 | @@ -1,5 +1,5 @@ |
| 2525 | /* |
| 2526 | - * Copyright (C) 2013 Canonical, Ltd. |
| 2527 | + * Copyright (C) 2013-2014 Canonical, Ltd. |
| 2528 | * Copyright (C) 2010-2011 David Edmundson. |
| 2529 | * |
| 2530 | * This program is free software; you can redistribute it and/or modify |
| 2531 | @@ -13,8 +13,6 @@ |
| 2532 | * |
| 2533 | * You should have received a copy of the GNU General Public License |
| 2534 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 2535 | - * |
| 2536 | - * Author: David Edmundson <kde@davidedmundson.co.uk> |
| 2537 | */ |
| 2538 | |
| 2539 | #ifndef UNITY_MOCK_USERSMODEL_H |
| 2540 | @@ -35,6 +33,12 @@ |
| 2541 | |
| 2542 | Q_ENUMS(UserModelRoles) |
| 2543 | |
| 2544 | + //Mock-only API for testing purposes |
| 2545 | + Q_PROPERTY(QString mockMode READ mockMode WRITE setMockMode NOTIFY mockModeChanged) |
| 2546 | + |
| 2547 | +Q_SIGNALS: |
| 2548 | + void mockModeChanged(QString mode); |
| 2549 | + |
| 2550 | public: |
| 2551 | explicit UsersModel(QObject *parent = 0); |
| 2552 | virtual ~UsersModel(); |
| 2553 | @@ -52,6 +56,9 @@ |
| 2554 | int rowCount(const QModelIndex &parent) const; |
| 2555 | QVariant data(const QModelIndex &index, int role) const; |
| 2556 | |
| 2557 | + QString mockMode() const; |
| 2558 | + void setMockMode(QString mockMode); |
| 2559 | + |
| 2560 | private: |
| 2561 | UsersModelPrivate * const d_ptr; |
| 2562 | Q_DECLARE_PRIVATE(UsersModel) |
| 2563 | |
| 2564 | === added file 'tests/mocks/LightDM/liblightdm/UsersModelPrivate.cpp' |
| 2565 | --- tests/mocks/LightDM/liblightdm/UsersModelPrivate.cpp 1970-01-01 00:00:00 +0000 |
| 2566 | +++ tests/mocks/LightDM/liblightdm/UsersModelPrivate.cpp 2015-02-02 14:28:47 +0000 |
| 2567 | @@ -0,0 +1,104 @@ |
| 2568 | +/* |
| 2569 | + * Copyright (C) 2014 Canonical, Ltd. |
| 2570 | + * |
| 2571 | + * This program is free software; you can redistribute it and/or modify |
| 2572 | + * it under the terms of the GNU General Public License as published by |
| 2573 | + * the Free Software Foundation; version 3. |
| 2574 | + * |
| 2575 | + * This program is distributed in the hope that it will be useful, |
| 2576 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 2577 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 2578 | + * GNU General Public License for more details. |
| 2579 | + * |
| 2580 | + * You should have received a copy of the GNU General Public License |
| 2581 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 2582 | + */ |
| 2583 | + |
| 2584 | +#include "UsersModelPrivate.h" |
| 2585 | +#include "UsersModel.h" |
| 2586 | + |
| 2587 | +namespace QLightDM |
| 2588 | +{ |
| 2589 | + |
| 2590 | +UsersModelPrivate::UsersModelPrivate(UsersModel* parent) |
| 2591 | + : mockMode("single") |
| 2592 | + , q_ptr(parent) |
| 2593 | +{ |
| 2594 | + char *envMockMode = getenv("LIBLIGHTDM_MOCK_MODE"); |
| 2595 | + if (envMockMode) { |
| 2596 | + mockMode = envMockMode; |
| 2597 | + } |
| 2598 | + resetEntries(); |
| 2599 | +} |
| 2600 | + |
| 2601 | +void UsersModelPrivate::resetEntries() |
| 2602 | +{ |
| 2603 | + Q_Q(UsersModel); |
| 2604 | + |
| 2605 | + q->beginResetModel(); |
| 2606 | + |
| 2607 | + if (mockMode == "single") { |
| 2608 | + resetEntries_single(); |
| 2609 | + } else if (mockMode == "single-passphrase") { |
| 2610 | + resetEntries_singlePassphrase(); |
| 2611 | + } else if (mockMode == "single-pin") { |
| 2612 | + resetEntries_singlePin(); |
| 2613 | + } else if (mockMode == "full") { |
| 2614 | + resetEntries_full(); |
| 2615 | + } |
| 2616 | + |
| 2617 | + q->endResetModel(); |
| 2618 | +} |
| 2619 | + |
| 2620 | +void UsersModelPrivate::resetEntries_single() |
| 2621 | +{ |
| 2622 | + entries = |
| 2623 | + { |
| 2624 | + { "single", "Single User", 0, 0, false, false, 0, 0 }, |
| 2625 | + }; |
| 2626 | +} |
| 2627 | + |
| 2628 | +void UsersModelPrivate::resetEntries_singlePassphrase() |
| 2629 | +{ |
| 2630 | + entries = |
| 2631 | + { |
| 2632 | + { "single", "Single User", 0, 0, false, false, 0, 0 }, |
| 2633 | + }; |
| 2634 | +} |
| 2635 | + |
| 2636 | +void UsersModelPrivate::resetEntries_singlePin() |
| 2637 | +{ |
| 2638 | + entries = |
| 2639 | + { |
| 2640 | + { "has-pin", "Has PIN", 0, 0, false, false, 0, 0 }, |
| 2641 | + }; |
| 2642 | +} |
| 2643 | + |
| 2644 | +void UsersModelPrivate::resetEntries_full() |
| 2645 | +{ |
| 2646 | + entries = |
| 2647 | + { |
| 2648 | + { "has-password", "Has Password", 0, 0, false, false, 0, 0 }, |
| 2649 | + { "has-pin", "Has PIN", 0, 0, false, false, 0, 0 }, |
| 2650 | + { "different-prompt", "Different Prompt", 0, 0, false, false, 0, 0 }, |
| 2651 | + { "no-password", "No Password", 0, 0, false, false, 0, 0 }, |
| 2652 | + { "auth-error", "Auth Error", 0, 0, false, false, 0, 0 }, |
| 2653 | + { "two-factor", "Two Factor", 0, 0, false, false, 0, 0 }, |
| 2654 | + { "info-prompt", "Info Prompt", 0, 0, false, false, 0, 0 }, |
| 2655 | + { "html-info-prompt", "HTML Info Prompt", 0, 0, false, false, 0, 0 }, |
| 2656 | + { "long-info-prompt", "Long Info Prompt", 0, 0, false, false, 0, 0 }, |
| 2657 | + { "wide-info-prompt", "Wide Info Prompt", 0, 0, false, false, 0, 0 }, |
| 2658 | + { "multi-info-prompt", "Multi Info Prompt", 0, 0, false, false, 0, 0 }, |
| 2659 | + { "long-name", "Long name (far far too long to fit)", 0, 0, false, false, 0, 0 }, |
| 2660 | + { "color-background", "Color Background", "#dd4814", 0, false, false, 0, 0 }, |
| 2661 | + // white and black are a bit redundant, but useful for manually testing if UI is still readable |
| 2662 | + { "white-background", "White Background", "#ffffff", 0, false, false, 0, 0 }, |
| 2663 | + { "black-background", "Black Background", "#000000", 0, false, false, 0, 0 }, |
| 2664 | + { "no-background", "No Background", "", 0, false, false, 0, 0 }, |
| 2665 | + { "unicode", "가나다라마", 0, 0, false, false, 0, 0 }, |
| 2666 | + { "no-response", "No Response", 0, 0, false, false, 0, 0 }, |
| 2667 | + { "empty-name", "", 0, 0, false, false, 0, 0 }, |
| 2668 | + }; |
| 2669 | +} |
| 2670 | + |
| 2671 | +} // namespace QLightDM |
| 2672 | |
| 2673 | === renamed file 'tests/mocks/LightDM/UsersModelPrivate.h' => 'tests/mocks/LightDM/liblightdm/UsersModelPrivate.h' |
| 2674 | --- tests/mocks/LightDM/UsersModelPrivate.h 2013-06-05 22:03:08 +0000 |
| 2675 | +++ tests/mocks/LightDM/liblightdm/UsersModelPrivate.h 2015-02-02 14:28:47 +0000 |
| 2676 | @@ -1,5 +1,5 @@ |
| 2677 | /* |
| 2678 | - * Copyright (C) 2013 Canonical, Ltd. |
| 2679 | + * Copyright (C) 2014 Canonical, Ltd. |
| 2680 | * |
| 2681 | * This program is free software; you can redistribute it and/or modify |
| 2682 | * it under the terms of the GNU General Public License as published by |
| 2683 | @@ -12,8 +12,6 @@ |
| 2684 | * |
| 2685 | * You should have received a copy of the GNU General Public License |
| 2686 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 2687 | - * |
| 2688 | - * Author: Michael Terry <michael.terry@canonical.com> |
| 2689 | */ |
| 2690 | |
| 2691 | #ifndef UNITY_MOCK_USERSMODEL_PRIVATE_H |
| 2692 | @@ -46,11 +44,17 @@ |
| 2693 | virtual ~UsersModelPrivate() = default; |
| 2694 | |
| 2695 | QList<Entry> entries; |
| 2696 | + QString mockMode; |
| 2697 | |
| 2698 | + void resetEntries(); |
| 2699 | protected: |
| 2700 | UsersModel * const q_ptr; |
| 2701 | |
| 2702 | private: |
| 2703 | + void resetEntries_single(); |
| 2704 | + void resetEntries_singlePassphrase(); |
| 2705 | + void resetEntries_singlePin(); |
| 2706 | + void resetEntries_full(); |
| 2707 | Q_DECLARE_PUBLIC(UsersModel) |
| 2708 | }; |
| 2709 | |
| 2710 | |
| 2711 | === added file 'tests/mocks/LightDM/plugin.cpp' |
| 2712 | --- tests/mocks/LightDM/plugin.cpp 1970-01-01 00:00:00 +0000 |
| 2713 | +++ tests/mocks/LightDM/plugin.cpp 2015-02-02 14:28:47 +0000 |
| 2714 | @@ -0,0 +1,68 @@ |
| 2715 | +/* |
| 2716 | + * Copyright (C) 2014 Canonical, Ltd. |
| 2717 | + * |
| 2718 | + * This program is free software; you can redistribute it and/or modify |
| 2719 | + * it under the terms of the GNU General Public License as published by |
| 2720 | + * the Free Software Foundation; version 3. |
| 2721 | + * |
| 2722 | + * This program is distributed in the hope that it will be useful, |
| 2723 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 2724 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 2725 | + * GNU General Public License for more details. |
| 2726 | + * |
| 2727 | + * You should have received a copy of the GNU General Public License |
| 2728 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 2729 | + */ |
| 2730 | + |
| 2731 | +#include "plugin.h" |
| 2732 | +#include <DBusGreeter.h> |
| 2733 | +#include <DBusGreeterList.h> |
| 2734 | +#include "MockGreeter.h" |
| 2735 | +#include "MockUsersModel.h" |
| 2736 | +#include <libusermetricsoutput/ColorTheme.h> |
| 2737 | +#include <libusermetricsoutput/UserMetrics.h> |
| 2738 | +#include <QLightDM/UsersModel> |
| 2739 | + |
| 2740 | +#include <QAbstractItemModel> |
| 2741 | +#include <QDBusConnection> |
| 2742 | +#include <QtQml/qqml.h> |
| 2743 | + |
| 2744 | +static QObject *greeter_provider(QQmlEngine *engine, QJSEngine *scriptEngine) |
| 2745 | +{ |
| 2746 | + Q_UNUSED(engine) |
| 2747 | + Q_UNUSED(scriptEngine) |
| 2748 | + |
| 2749 | + MockGreeter *greeter = new MockGreeter; |
| 2750 | + new DBusGreeter(greeter, "/"); |
| 2751 | + new DBusGreeterList(greeter, "/list"); |
| 2752 | + |
| 2753 | + return greeter; |
| 2754 | +} |
| 2755 | + |
| 2756 | +static QObject *users_provider(QQmlEngine *engine, QJSEngine *scriptEngine) |
| 2757 | +{ |
| 2758 | + Q_UNUSED(engine) |
| 2759 | + Q_UNUSED(scriptEngine) |
| 2760 | + return new MockUsersModel; |
| 2761 | +} |
| 2762 | + |
| 2763 | +static QObject *infographic_provider(QQmlEngine *engine, QJSEngine *scriptEngine) |
| 2764 | +{ |
| 2765 | + Q_UNUSED(engine) |
| 2766 | + Q_UNUSED(scriptEngine) |
| 2767 | + return UserMetricsOutput::UserMetrics::getInstance(); |
| 2768 | +} |
| 2769 | + |
| 2770 | +void LightDMPlugin::registerTypes(const char *uri) |
| 2771 | +{ |
| 2772 | + qmlRegisterType<QAbstractItemModel>(); |
| 2773 | + qmlRegisterType<UserMetricsOutput::ColorTheme>(); |
| 2774 | + |
| 2775 | + Q_ASSERT(uri == QLatin1String("LightDM")); |
| 2776 | + qRegisterMetaType<QLightDM::Greeter::MessageType>("QLightDM::Greeter::MessageType"); |
| 2777 | + qRegisterMetaType<QLightDM::Greeter::PromptType>("QLightDM::Greeter::PromptType"); |
| 2778 | + qmlRegisterSingletonType<MockGreeter>(uri, 0, 1, "Greeter", greeter_provider); |
| 2779 | + qmlRegisterSingletonType<MockUsersModel>(uri, 0, 1, "Users", users_provider); |
| 2780 | + qmlRegisterUncreatableType<QLightDM::UsersModel>(uri, 0, 1, "UserRoles", "Type is not instantiable"); |
| 2781 | + qmlRegisterSingletonType<UserMetricsOutput::UserMetrics>(uri, 0, 1, "Infographic", infographic_provider); |
| 2782 | +} |
| 2783 | |
| 2784 | === added file 'tests/mocks/LightDM/plugin.h' |
| 2785 | --- tests/mocks/LightDM/plugin.h 1970-01-01 00:00:00 +0000 |
| 2786 | +++ tests/mocks/LightDM/plugin.h 2015-02-02 14:28:47 +0000 |
| 2787 | @@ -0,0 +1,32 @@ |
| 2788 | +/* |
| 2789 | + * Copyright (C) 2014 Canonical, Ltd. |
| 2790 | + * |
| 2791 | + * This program is free software; you can redistribute it and/or modify |
| 2792 | + * it under the terms of the GNU General Public License as published by |
| 2793 | + * the Free Software Foundation; version 3. |
| 2794 | + * |
| 2795 | + * This program is distributed in the hope that it will be useful, |
| 2796 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 2797 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 2798 | + * GNU General Public License for more details. |
| 2799 | + * |
| 2800 | + * You should have received a copy of the GNU General Public License |
| 2801 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 2802 | + */ |
| 2803 | + |
| 2804 | +#ifndef MOCK_LIGHTDM_PLUGIN_H |
| 2805 | +#define MOCK_LIGHTDM_PLUGIN_H |
| 2806 | + |
| 2807 | +#include <QtQml/QQmlEngine> |
| 2808 | +#include <QtQml/QQmlExtensionPlugin> |
| 2809 | + |
| 2810 | +class LightDMPlugin : public QQmlExtensionPlugin |
| 2811 | +{ |
| 2812 | + Q_OBJECT |
| 2813 | + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") |
| 2814 | + |
| 2815 | +public: |
| 2816 | + void registerTypes(const char *uri); |
| 2817 | +}; |
| 2818 | + |
| 2819 | +#endif |
| 2820 | |
| 2821 | === removed directory 'tests/mocks/LightDM/single' |
| 2822 | === removed directory 'tests/mocks/LightDM/single-passphrase' |
| 2823 | === removed file 'tests/mocks/LightDM/single-passphrase/CMakeLists.txt' |
| 2824 | --- tests/mocks/LightDM/single-passphrase/CMakeLists.txt 2014-06-11 15:36:51 +0000 |
| 2825 | +++ tests/mocks/LightDM/single-passphrase/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
| 2826 | @@ -1,19 +0,0 @@ |
| 2827 | -set(LibLightDM_SOURCES |
| 2828 | - ../Greeter.cpp |
| 2829 | - ../UsersModel.cpp |
| 2830 | - GreeterPrivate.cpp |
| 2831 | - UsersModelPrivate.cpp |
| 2832 | - ${CMAKE_SOURCE_DIR}/plugins/Utils/qvariantlistmodel.cpp |
| 2833 | - ) |
| 2834 | - |
| 2835 | - |
| 2836 | -add_library(MockLightDM-single-passphrase SHARED ${LibLightDM_SOURCES}) |
| 2837 | - |
| 2838 | -qt5_use_modules(MockLightDM-single-passphrase Gui) |
| 2839 | - |
| 2840 | -set_target_properties(MockLightDM-single-passphrase PROPERTIES |
| 2841 | - OUTPUT_NAME lightdm-qt5-2) |
| 2842 | - |
| 2843 | -install(TARGETS MockLightDM-single-passphrase |
| 2844 | - DESTINATION ${SHELL_INSTALL_QML}/mocks/LightDM/single-passphrase |
| 2845 | - ) |
| 2846 | |
| 2847 | === removed file 'tests/mocks/LightDM/single-passphrase/GreeterPrivate.cpp' |
| 2848 | --- tests/mocks/LightDM/single-passphrase/GreeterPrivate.cpp 2014-08-06 15:27:57 +0000 |
| 2849 | +++ tests/mocks/LightDM/single-passphrase/GreeterPrivate.cpp 1970-01-01 00:00:00 +0000 |
| 2850 | @@ -1,46 +0,0 @@ |
| 2851 | -/* |
| 2852 | - * Copyright (C) 2013 Canonical, Ltd. |
| 2853 | - * |
| 2854 | - * This program is free software; you can redistribute it and/or modify |
| 2855 | - * it under the terms of the GNU General Public License as published by |
| 2856 | - * the Free Software Foundation; version 3. |
| 2857 | - * |
| 2858 | - * This program is distributed in the hope that it will be useful, |
| 2859 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 2860 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 2861 | - * GNU General Public License for more details. |
| 2862 | - * |
| 2863 | - * You should have received a copy of the GNU General Public License |
| 2864 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 2865 | - * |
| 2866 | - * Author: Michael Terry <michael.terry@canonical.com> |
| 2867 | - */ |
| 2868 | - |
| 2869 | -#include "../Greeter.h" |
| 2870 | -#include "../GreeterPrivate.h" |
| 2871 | - |
| 2872 | -namespace QLightDM |
| 2873 | -{ |
| 2874 | - |
| 2875 | -GreeterPrivate::GreeterPrivate(Greeter* parent) |
| 2876 | - : authenticated(false), |
| 2877 | - authenticationUser(), |
| 2878 | - q_ptr(parent) |
| 2879 | -{ |
| 2880 | -} |
| 2881 | - |
| 2882 | -void GreeterPrivate::handleAuthenticate() |
| 2883 | -{ |
| 2884 | - Q_Q(Greeter); |
| 2885 | - Q_EMIT q->showPrompt("Password: ", Greeter::PromptTypeSecret); |
| 2886 | -} |
| 2887 | - |
| 2888 | -void GreeterPrivate::handleRespond(const QString &response) |
| 2889 | -{ |
| 2890 | - Q_Q(Greeter); |
| 2891 | - |
| 2892 | - authenticated = (response == "password"); |
| 2893 | - q->sendAuthenticationComplete(); |
| 2894 | -} |
| 2895 | - |
| 2896 | -} |
| 2897 | |
| 2898 | === removed file 'tests/mocks/LightDM/single-passphrase/UsersModelPrivate.cpp' |
| 2899 | --- tests/mocks/LightDM/single-passphrase/UsersModelPrivate.cpp 2013-06-14 19:35:25 +0000 |
| 2900 | +++ tests/mocks/LightDM/single-passphrase/UsersModelPrivate.cpp 1970-01-01 00:00:00 +0000 |
| 2901 | @@ -1,33 +0,0 @@ |
| 2902 | -/* |
| 2903 | - * Copyright (C) 2013 Canonical, Ltd. |
| 2904 | - * |
| 2905 | - * This program is free software; you can redistribute it and/or modify |
| 2906 | - * it under the terms of the GNU General Public License as published by |
| 2907 | - * the Free Software Foundation; version 3. |
| 2908 | - * |
| 2909 | - * This program is distributed in the hope that it will be useful, |
| 2910 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 2911 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 2912 | - * GNU General Public License for more details. |
| 2913 | - * |
| 2914 | - * You should have received a copy of the GNU General Public License |
| 2915 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 2916 | - * |
| 2917 | - * Author: Michael Terry <michael.terry@canonical.com> |
| 2918 | - */ |
| 2919 | - |
| 2920 | -#include "../UsersModelPrivate.h" |
| 2921 | - |
| 2922 | -namespace QLightDM |
| 2923 | -{ |
| 2924 | - |
| 2925 | -UsersModelPrivate::UsersModelPrivate(UsersModel* parent) |
| 2926 | - : q_ptr(parent) |
| 2927 | -{ |
| 2928 | - entries = |
| 2929 | - { |
| 2930 | - { "single", "Has Passphrase", 0, 0, false, false, 0, 0 }, |
| 2931 | - }; |
| 2932 | -} |
| 2933 | - |
| 2934 | -} |
| 2935 | |
| 2936 | === removed directory 'tests/mocks/LightDM/single-pin' |
| 2937 | === removed file 'tests/mocks/LightDM/single-pin/CMakeLists.txt' |
| 2938 | --- tests/mocks/LightDM/single-pin/CMakeLists.txt 2014-06-11 15:36:51 +0000 |
| 2939 | +++ tests/mocks/LightDM/single-pin/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
| 2940 | @@ -1,19 +0,0 @@ |
| 2941 | -set(LibLightDM_SOURCES |
| 2942 | - ../Greeter.cpp |
| 2943 | - ../UsersModel.cpp |
| 2944 | - GreeterPrivate.cpp |
| 2945 | - UsersModelPrivate.cpp |
| 2946 | - ${CMAKE_SOURCE_DIR}/plugins/Utils/qvariantlistmodel.cpp |
| 2947 | - ) |
| 2948 | - |
| 2949 | - |
| 2950 | -add_library(MockLightDM-single-pin SHARED ${LibLightDM_SOURCES}) |
| 2951 | - |
| 2952 | -qt5_use_modules(MockLightDM-single-pin Gui) |
| 2953 | - |
| 2954 | -set_target_properties(MockLightDM-single-pin PROPERTIES |
| 2955 | - OUTPUT_NAME lightdm-qt5-2) |
| 2956 | - |
| 2957 | -install(TARGETS MockLightDM-single-pin |
| 2958 | - DESTINATION ${SHELL_INSTALL_QML}/mocks/LightDM/single-pin |
| 2959 | - ) |
| 2960 | |
| 2961 | === removed file 'tests/mocks/LightDM/single-pin/GreeterPrivate.cpp' |
| 2962 | --- tests/mocks/LightDM/single-pin/GreeterPrivate.cpp 2014-08-06 15:27:57 +0000 |
| 2963 | +++ tests/mocks/LightDM/single-pin/GreeterPrivate.cpp 1970-01-01 00:00:00 +0000 |
| 2964 | @@ -1,46 +0,0 @@ |
| 2965 | -/* |
| 2966 | - * Copyright (C) 2013 Canonical, Ltd. |
| 2967 | - * |
| 2968 | - * This program is free software; you can redistribute it and/or modify |
| 2969 | - * it under the terms of the GNU General Public License as published by |
| 2970 | - * the Free Software Foundation; version 3. |
| 2971 | - * |
| 2972 | - * This program is distributed in the hope that it will be useful, |
| 2973 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 2974 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 2975 | - * GNU General Public License for more details. |
| 2976 | - * |
| 2977 | - * You should have received a copy of the GNU General Public License |
| 2978 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 2979 | - * |
| 2980 | - * Author: Michael Terry <michael.terry@canonical.com> |
| 2981 | - */ |
| 2982 | - |
| 2983 | -#include "../Greeter.h" |
| 2984 | -#include "../GreeterPrivate.h" |
| 2985 | - |
| 2986 | -namespace QLightDM |
| 2987 | -{ |
| 2988 | - |
| 2989 | -GreeterPrivate::GreeterPrivate(Greeter* parent) |
| 2990 | - : authenticated(false), |
| 2991 | - authenticationUser(), |
| 2992 | - q_ptr(parent) |
| 2993 | -{ |
| 2994 | -} |
| 2995 | - |
| 2996 | -void GreeterPrivate::handleAuthenticate() |
| 2997 | -{ |
| 2998 | - Q_Q(Greeter); |
| 2999 | - Q_EMIT q->showPrompt("Password: ", Greeter::PromptTypeSecret); |
| 3000 | -} |
| 3001 | - |
| 3002 | -void GreeterPrivate::handleRespond(const QString &response) |
| 3003 | -{ |
| 3004 | - Q_Q(Greeter); |
| 3005 | - |
| 3006 | - authenticated = (response == "1234"); |
| 3007 | - q->sendAuthenticationComplete(); |
| 3008 | -} |
| 3009 | - |
| 3010 | -} |
| 3011 | |
| 3012 | === removed file 'tests/mocks/LightDM/single-pin/UsersModelPrivate.cpp' |
| 3013 | --- tests/mocks/LightDM/single-pin/UsersModelPrivate.cpp 2014-07-02 16:17:14 +0000 |
| 3014 | +++ tests/mocks/LightDM/single-pin/UsersModelPrivate.cpp 1970-01-01 00:00:00 +0000 |
| 3015 | @@ -1,33 +0,0 @@ |
| 3016 | -/* |
| 3017 | - * Copyright (C) 2013 Canonical, Ltd. |
| 3018 | - * |
| 3019 | - * This program is free software; you can redistribute it and/or modify |
| 3020 | - * it under the terms of the GNU General Public License as published by |
| 3021 | - * the Free Software Foundation; version 3. |
| 3022 | - * |
| 3023 | - * This program is distributed in the hope that it will be useful, |
| 3024 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 3025 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 3026 | - * GNU General Public License for more details. |
| 3027 | - * |
| 3028 | - * You should have received a copy of the GNU General Public License |
| 3029 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 3030 | - * |
| 3031 | - * Author: Michael Terry <michael.terry@canonical.com> |
| 3032 | - */ |
| 3033 | - |
| 3034 | -#include "../UsersModelPrivate.h" |
| 3035 | - |
| 3036 | -namespace QLightDM |
| 3037 | -{ |
| 3038 | - |
| 3039 | -UsersModelPrivate::UsersModelPrivate(UsersModel* parent) |
| 3040 | - : q_ptr(parent) |
| 3041 | -{ |
| 3042 | - entries = |
| 3043 | - { |
| 3044 | - { "has-pin", "Has PIN", 0, 0, false, false, 0, 0 }, |
| 3045 | - }; |
| 3046 | -} |
| 3047 | - |
| 3048 | -} |
| 3049 | |
| 3050 | === removed file 'tests/mocks/LightDM/single/CMakeLists.txt' |
| 3051 | --- tests/mocks/LightDM/single/CMakeLists.txt 2014-06-11 15:36:51 +0000 |
| 3052 | +++ tests/mocks/LightDM/single/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
| 3053 | @@ -1,18 +0,0 @@ |
| 3054 | -set(LibLightDM_SOURCES |
| 3055 | - ../Greeter.cpp |
| 3056 | - ../UsersModel.cpp |
| 3057 | - GreeterPrivate.cpp |
| 3058 | - UsersModelPrivate.cpp |
| 3059 | - ${CMAKE_SOURCE_DIR}/plugins/Utils/qvariantlistmodel.cpp |
| 3060 | - ) |
| 3061 | - |
| 3062 | -add_library(MockLightDM-single SHARED ${LibLightDM_SOURCES}) |
| 3063 | - |
| 3064 | -qt5_use_modules(MockLightDM-single Gui) |
| 3065 | - |
| 3066 | -set_target_properties(MockLightDM-single PROPERTIES |
| 3067 | - OUTPUT_NAME lightdm-qt5-2) |
| 3068 | - |
| 3069 | -install(TARGETS MockLightDM-single |
| 3070 | - DESTINATION ${SHELL_INSTALL_QML}/mocks/LightDM/single |
| 3071 | - ) |
| 3072 | |
| 3073 | === removed file 'tests/mocks/LightDM/single/GreeterPrivate.cpp' |
| 3074 | --- tests/mocks/LightDM/single/GreeterPrivate.cpp 2013-07-29 22:16:04 +0000 |
| 3075 | +++ tests/mocks/LightDM/single/GreeterPrivate.cpp 1970-01-01 00:00:00 +0000 |
| 3076 | @@ -1,46 +0,0 @@ |
| 3077 | -/* |
| 3078 | - * Copyright (C) 2013 Canonical, Ltd. |
| 3079 | - * |
| 3080 | - * This program is free software; you can redistribute it and/or modify |
| 3081 | - * it under the terms of the GNU General Public License as published by |
| 3082 | - * the Free Software Foundation; version 3. |
| 3083 | - * |
| 3084 | - * This program is distributed in the hope that it will be useful, |
| 3085 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 3086 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 3087 | - * GNU General Public License for more details. |
| 3088 | - * |
| 3089 | - * You should have received a copy of the GNU General Public License |
| 3090 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 3091 | - * |
| 3092 | - * Author: Michael Terry <michael.terry@canonical.com> |
| 3093 | - */ |
| 3094 | - |
| 3095 | -#include "../Greeter.h" |
| 3096 | -#include "../GreeterPrivate.h" |
| 3097 | - |
| 3098 | -namespace QLightDM |
| 3099 | -{ |
| 3100 | - |
| 3101 | -GreeterPrivate::GreeterPrivate(Greeter* parent) |
| 3102 | - : authenticated(false), |
| 3103 | - authenticationUser(), |
| 3104 | - twoFactorDone(false), |
| 3105 | - q_ptr(parent) |
| 3106 | -{ |
| 3107 | -} |
| 3108 | - |
| 3109 | -void GreeterPrivate::handleAuthenticate() |
| 3110 | -{ |
| 3111 | - Q_Q(Greeter); |
| 3112 | - |
| 3113 | - authenticated = true; |
| 3114 | - Q_EMIT q->authenticationComplete(); |
| 3115 | -} |
| 3116 | - |
| 3117 | -void GreeterPrivate::handleRespond(QString const &response) |
| 3118 | -{ |
| 3119 | - Q_UNUSED(response) |
| 3120 | -} |
| 3121 | - |
| 3122 | -} |
| 3123 | |
| 3124 | === removed file 'tests/mocks/LightDM/single/UsersModelPrivate.cpp' |
| 3125 | --- tests/mocks/LightDM/single/UsersModelPrivate.cpp 2013-06-14 19:35:25 +0000 |
| 3126 | +++ tests/mocks/LightDM/single/UsersModelPrivate.cpp 1970-01-01 00:00:00 +0000 |
| 3127 | @@ -1,33 +0,0 @@ |
| 3128 | -/* |
| 3129 | - * Copyright (C) 2013 Canonical, Ltd. |
| 3130 | - * |
| 3131 | - * This program is free software; you can redistribute it and/or modify |
| 3132 | - * it under the terms of the GNU General Public License as published by |
| 3133 | - * the Free Software Foundation; version 3. |
| 3134 | - * |
| 3135 | - * This program is distributed in the hope that it will be useful, |
| 3136 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 3137 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 3138 | - * GNU General Public License for more details. |
| 3139 | - * |
| 3140 | - * You should have received a copy of the GNU General Public License |
| 3141 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 3142 | - * |
| 3143 | - * Author: Michael Terry <michael.terry@canonical.com> |
| 3144 | - */ |
| 3145 | - |
| 3146 | -#include "../UsersModelPrivate.h" |
| 3147 | - |
| 3148 | -namespace QLightDM |
| 3149 | -{ |
| 3150 | - |
| 3151 | -UsersModelPrivate::UsersModelPrivate(UsersModel* parent) |
| 3152 | - : q_ptr(parent) |
| 3153 | -{ |
| 3154 | - entries = |
| 3155 | - { |
| 3156 | - { "single", "Single User", 0, 0, false, false, 0, 0 }, |
| 3157 | - }; |
| 3158 | -} |
| 3159 | - |
| 3160 | -} |
| 3161 | |
| 3162 | === modified file 'tests/plugins/LightDM/CMakeLists.txt' |
| 3163 | --- tests/plugins/LightDM/CMakeLists.txt 2015-01-22 16:41:18 +0000 |
| 3164 | +++ tests/plugins/LightDM/CMakeLists.txt 2015-02-02 14:28:47 +0000 |
| 3165 | @@ -11,10 +11,10 @@ |
| 3166 | ${LIBLIGHTDM_INCLUDE_DIRS} |
| 3167 | ) |
| 3168 | |
| 3169 | -add_dependencies(GreeterDBusTestExec MockLightDM-full) |
| 3170 | -target_link_libraries(GreeterDBusTestExec -L${CMAKE_BINARY_DIR}/tests/mocks/LightDM/full |
| 3171 | +add_dependencies(GreeterDBusTestExec MockLightDM) |
| 3172 | +target_link_libraries(GreeterDBusTestExec -L${CMAKE_BINARY_DIR}/tests/mocks/LightDM/liblightdm |
| 3173 | -llightdm-qt5-2) |
| 3174 | |
| 3175 | add_definitions(-DCURRENT_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}") |
| 3176 | |
| 3177 | -add_binary_qml_test(GreeterDBus "${CMAKE_BINARY_DIR}/tests/mocks/LightDM/full" MockLightDM-full "QML2_IMPORT_PATH=${CMAKE_BINARY_DIR}/tests/mocks") |
| 3178 | +add_binary_qml_test(GreeterDBus "${CMAKE_BINARY_DIR}/tests/mocks/LightDM/liblightdm" MockLightDM "QML2_IMPORT_PATH=${CMAKE_BINARY_DIR}/tests/mocks") |
| 3179 | |
| 3180 | === modified file 'tests/plugins/LightDM/greeter.qml' |
| 3181 | --- tests/plugins/LightDM/greeter.qml 2013-12-03 11:43:15 +0000 |
| 3182 | +++ tests/plugins/LightDM/greeter.qml 2015-02-02 14:28:47 +0000 |
| 3183 | @@ -19,4 +19,9 @@ |
| 3184 | |
| 3185 | Item { |
| 3186 | property var greeter: LightDM.Greeter |
| 3187 | + Binding { |
| 3188 | + target: LightDM.Greeter |
| 3189 | + property: "mockMode" |
| 3190 | + value: "full" |
| 3191 | + } |
| 3192 | } |
| 3193 | |
| 3194 | === modified file 'tests/qmltests/CMakeLists.txt' |
| 3195 | --- tests/qmltests/CMakeLists.txt 2015-01-21 18:32:48 +0000 |
| 3196 | +++ tests/qmltests/CMakeLists.txt 2015-02-02 14:28:47 +0000 |
| 3197 | @@ -16,11 +16,11 @@ |
| 3198 | |
| 3199 | set(qmltest_DEFAULT_TARGETS qmluitests) |
| 3200 | set(qmltest_DEFAULT_NO_ADD_TEST TRUE) |
| 3201 | -set(qmltest_DEFAULT_PROPERTIES ENVIRONMENT "LC_ALL=C") |
| 3202 | +set(qmltest_DEFAULT_PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/liblightdm:${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel") |
| 3203 | |
| 3204 | -add_qml_test(. Shell ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single:${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel") |
| 3205 | -add_qml_test(. ShellWithPin ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single-pin:${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel") |
| 3206 | -add_qml_test(. TabletShell ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/LightDM/full:${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel") |
| 3207 | +add_qml_test(. Shell) |
| 3208 | +add_qml_test(. ShellWithPin) |
| 3209 | +add_qml_test(. TabletShell) |
| 3210 | add_qml_test(Components Background) |
| 3211 | add_qml_test(Components Carousel) |
| 3212 | add_qml_test(Components Dialogs) |
| 3213 | @@ -61,10 +61,10 @@ |
| 3214 | add_qml_test(Dash/ScopeSettings ScopeSettingNumber) |
| 3215 | add_qml_test(Dash/ScopeSettings ScopeSettingString) |
| 3216 | add_qml_test(Dash/ScopeSettings ScopeSettingsWidgetFactory) |
| 3217 | -add_qml_test(Greeter MultiGreeter ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/full") |
| 3218 | -add_qml_test(Greeter SingleGreeter ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single") |
| 3219 | -add_qml_test(Greeter Infographics ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/full") |
| 3220 | -add_qml_test(Greeter Clock ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel") |
| 3221 | +add_qml_test(Greeter MultiGreeter) |
| 3222 | +add_qml_test(Greeter SingleGreeter) |
| 3223 | +add_qml_test(Greeter Infographics) |
| 3224 | +add_qml_test(Greeter Clock) |
| 3225 | add_qml_test(Launcher Launcher) |
| 3226 | add_qml_test(Notifications Notifications) |
| 3227 | add_qml_test(Notifications VisualSnapDecisionsQueue) |
| 3228 | @@ -72,22 +72,22 @@ |
| 3229 | add_qml_test(Notifications SwipeToAct) |
| 3230 | add_qml_test(Panel ActiveCallHint) |
| 3231 | add_qml_test(Panel IndicatorItem) |
| 3232 | -add_qml_test(Panel IndicatorItemRow ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel") |
| 3233 | -add_qml_test(Panel IndicatorPage ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel") |
| 3234 | -add_qml_test(Panel IndicatorsBar ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel") |
| 3235 | -add_qml_test(Panel IndicatorsMenu ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel") |
| 3236 | -add_qml_test(Panel MenuContent ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel") |
| 3237 | -add_qml_test(Panel Panel ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel") |
| 3238 | +add_qml_test(Panel IndicatorItemRow) |
| 3239 | +add_qml_test(Panel IndicatorPage) |
| 3240 | +add_qml_test(Panel IndicatorsBar) |
| 3241 | +add_qml_test(Panel IndicatorsMenu) |
| 3242 | +add_qml_test(Panel MenuContent) |
| 3243 | +add_qml_test(Panel Panel) |
| 3244 | add_qml_test(Panel SearchIndicator) |
| 3245 | add_qml_test(Panel/Indicators IndicatorsLight ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel") |
| 3246 | # These MenuItemFactory tests need the test/mocks/ to come before plugins/ |
| 3247 | add_qml_test(Panel/Indicators MenuItemFactory IMPORT_PATHS ${CMAKE_BINARY_DIR}/tests/mocks ${qmltest_DEFAULT_IMPORT_PATHS}) |
| 3248 | add_qml_test(Panel/Indicators MessageMenuItemFactory IMPORT_PATHS ${CMAKE_BINARY_DIR}/tests/mocks ${qmltest_DEFAULT_IMPORT_PATHS}) |
| 3249 | -add_qml_test(Stages ApplicationWindow ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single") |
| 3250 | -add_qml_test(Stages PhoneStage ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single") |
| 3251 | -add_qml_test(Stages SpreadDelegate ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single") |
| 3252 | -add_qml_test(Stages SurfaceContainer ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single") |
| 3253 | -add_qml_test(Stages SessionContainer ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single") |
| 3254 | +add_qml_test(Stages ApplicationWindow) |
| 3255 | +add_qml_test(Stages PhoneStage ENVIRONMENT) |
| 3256 | +add_qml_test(Stages SpreadDelegate ENVIRONMENT) |
| 3257 | +add_qml_test(Stages SurfaceContainer ENVIRONMENT) |
| 3258 | +add_qml_test(Stages SessionContainer ENVIRONMENT) |
| 3259 | add_qml_test(Stages WindowMoveResizeArea) |
| 3260 | add_qml_test(Stages Splash) |
| 3261 | add_qml_test(Wizard Wizard) |
| 3262 | |
| 3263 | === modified file 'tests/qmltests/Greeter/tst_Infographics.qml' |
| 3264 | --- tests/qmltests/Greeter/tst_Infographics.qml 2013-12-17 16:04:47 +0000 |
| 3265 | +++ tests/qmltests/Greeter/tst_Infographics.qml 2015-02-02 14:28:47 +0000 |
| 3266 | @@ -23,6 +23,16 @@ |
| 3267 | import LightDM 0.1 as LightDM |
| 3268 | |
| 3269 | Item { |
| 3270 | + Binding { |
| 3271 | + target: LightDM.Greeter |
| 3272 | + property: "mockMode" |
| 3273 | + value: "full" |
| 3274 | + } |
| 3275 | + Binding { |
| 3276 | + target: LightDM.Users |
| 3277 | + property: "mockMode" |
| 3278 | + value: "full" |
| 3279 | + } |
| 3280 | property variant infographicModel: LightDM.Infographic |
| 3281 | |
| 3282 | width: units.gu(120) |
| 3283 | |
| 3284 | === modified file 'tests/qmltests/Greeter/tst_MultiGreeter.qml' |
| 3285 | --- tests/qmltests/Greeter/tst_MultiGreeter.qml 2014-12-09 14:50:59 +0000 |
| 3286 | +++ tests/qmltests/Greeter/tst_MultiGreeter.qml 2015-02-02 14:28:47 +0000 |
| 3287 | @@ -15,6 +15,7 @@ |
| 3288 | */ |
| 3289 | |
| 3290 | import QtQuick 2.0 |
| 3291 | +import QtQuick.Layouts 1.1 |
| 3292 | import QtTest 1.0 |
| 3293 | import ".." |
| 3294 | import "../../../qml/Greeter" |
| 3295 | @@ -23,12 +24,37 @@ |
| 3296 | import Unity.Test 0.1 as UT |
| 3297 | |
| 3298 | Item { |
| 3299 | - width: units.gu(120) |
| 3300 | + id: root |
| 3301 | + width: units.gu(140) |
| 3302 | height: units.gu(80) |
| 3303 | |
| 3304 | + QtObject { |
| 3305 | + id: fakeInputMethod |
| 3306 | + property bool visible: fakeKeyboard.visible |
| 3307 | + property var keyboardRectangle: QtObject { |
| 3308 | + property real x: fakeKeyboard.x |
| 3309 | + property real y: fakeKeyboard.y |
| 3310 | + property real width: fakeKeyboard.width |
| 3311 | + property real height: fakeKeyboard.height |
| 3312 | + } |
| 3313 | + } |
| 3314 | + |
| 3315 | + Binding { |
| 3316 | + target: LightDM.Greeter |
| 3317 | + property: "mockMode" |
| 3318 | + value: "full" |
| 3319 | + } |
| 3320 | + Binding { |
| 3321 | + target: LightDM.Users |
| 3322 | + property: "mockMode" |
| 3323 | + value: "full" |
| 3324 | + } |
| 3325 | + |
| 3326 | Greeter { |
| 3327 | id: greeter |
| 3328 | - anchors.fill: parent |
| 3329 | + width: units.gu(120) |
| 3330 | + height: root.height |
| 3331 | + inputMethod: fakeInputMethod |
| 3332 | locked: !LightDM.Greeter.authenticated |
| 3333 | } |
| 3334 | |
| 3335 | @@ -43,6 +69,44 @@ |
| 3336 | } |
| 3337 | } |
| 3338 | |
| 3339 | + Rectangle { |
| 3340 | + id: fakeKeyboard |
| 3341 | + color: "green" |
| 3342 | + opacity: 0.7 |
| 3343 | + anchors.bottom: root.bottom |
| 3344 | + width: greeter.width |
| 3345 | + height: greeter.height * 0.6 |
| 3346 | + visible: keyboardVisibleCheckbox.checked |
| 3347 | + Text { |
| 3348 | + text: "Keyboard Rectangle" |
| 3349 | + color: "yellow" |
| 3350 | + font.bold: true |
| 3351 | + fontSizeMode: Text.Fit |
| 3352 | + minimumPixelSize: 10; font.pixelSize: 200 |
| 3353 | + verticalAlignment: Text.AlignVCenter |
| 3354 | + x: (parent.width - width) / 2 |
| 3355 | + y: (parent.height - height) / 2 |
| 3356 | + width: parent.width |
| 3357 | + height: parent.height |
| 3358 | + } |
| 3359 | + } |
| 3360 | + |
| 3361 | + Item { |
| 3362 | + anchors { |
| 3363 | + top: root.top |
| 3364 | + bottom: root.bottom |
| 3365 | + left: greeter.right |
| 3366 | + right: root.right |
| 3367 | + } |
| 3368 | + RowLayout { |
| 3369 | + Layout.fillWidth: true |
| 3370 | + CheckBox { |
| 3371 | + id: keyboardVisibleCheckbox |
| 3372 | + } |
| 3373 | + Label { text: "Keyboard Visible"; anchors.verticalCenter: parent.verticalCenter } |
| 3374 | + } |
| 3375 | + } |
| 3376 | + |
| 3377 | SignalSpy { |
| 3378 | id: unlockSpy |
| 3379 | target: greeter |
| 3380 | @@ -65,6 +129,10 @@ |
| 3381 | name: "MultiGreeter" |
| 3382 | when: windowShown |
| 3383 | |
| 3384 | + function cleanup() { |
| 3385 | + keyboardVisibleCheckbox.checked = false; |
| 3386 | + } |
| 3387 | + |
| 3388 | function select_index(i) { |
| 3389 | // We could be anywhere in list; find target index to know which direction |
| 3390 | var userlist = findChild(greeter, "userList") |
| 3391 | @@ -382,5 +450,26 @@ |
| 3392 | tryCompare(spy, "count", 1) |
| 3393 | greeterObj.destroy() |
| 3394 | } |
| 3395 | + |
| 3396 | + function test_login_list_not_covered_by_keyboard() { |
| 3397 | + var loginList = findChild(greeter, "loginLoader").item; |
| 3398 | + compare(loginList.height, greeter.height); |
| 3399 | + |
| 3400 | + // when the vkb shows up, loginList is moved up to remain fully uncovered |
| 3401 | + |
| 3402 | + keyboardVisibleCheckbox.checked = true; |
| 3403 | + |
| 3404 | + tryCompare(loginList, "height", greeter.height - fakeInputMethod.keyboardRectangle.height); |
| 3405 | + tryCompareFunction( function() { |
| 3406 | + var loginListRect = loginList.mapToItem(greeter, 0, 0, loginList.width, loginList.height); |
| 3407 | + return loginListRect.y + loginListRect.height <= fakeInputMethod.keyboardRectangle.y; |
| 3408 | + }, true); |
| 3409 | + |
| 3410 | + // once the vkb goes away, loginList goes back to its full height |
| 3411 | + |
| 3412 | + keyboardVisibleCheckbox.checked = false; |
| 3413 | + |
| 3414 | + tryCompare(loginList, "height", greeter.height); |
| 3415 | + } |
| 3416 | } |
| 3417 | } |
| 3418 | |
| 3419 | === modified file 'tests/qmltests/tst_Shell.qml' |
| 3420 | --- tests/qmltests/tst_Shell.qml 2015-01-09 10:42:42 +0000 |
| 3421 | +++ tests/qmltests/tst_Shell.qml 2015-02-02 14:28:47 +0000 |
| 3422 | @@ -36,6 +36,13 @@ |
| 3423 | width: units.gu(60) |
| 3424 | height: units.gu(71) |
| 3425 | |
| 3426 | + Component.onCompleted: { |
| 3427 | + // must set the mock mode before loading the Shell |
| 3428 | + LightDM.Greeter.mockMode = "single"; |
| 3429 | + LightDM.Users.mockMode = "single"; |
| 3430 | + shellLoader.active = true; |
| 3431 | + } |
| 3432 | + |
| 3433 | QtObject { |
| 3434 | id: applicationArguments |
| 3435 | |
| 3436 | @@ -56,7 +63,7 @@ |
| 3437 | anchors.fill: parent |
| 3438 | Loader { |
| 3439 | id: shellLoader |
| 3440 | - |
| 3441 | + active: false |
| 3442 | property bool itemDestroyed: false |
| 3443 | sourceComponent: Component { |
| 3444 | Shell { |
| 3445 | |
| 3446 | === modified file 'tests/qmltests/tst_ShellWithPin.qml' |
| 3447 | --- tests/qmltests/tst_ShellWithPin.qml 2014-12-09 17:14:35 +0000 |
| 3448 | +++ tests/qmltests/tst_ShellWithPin.qml 2015-02-02 14:28:47 +0000 |
| 3449 | @@ -33,6 +33,13 @@ |
| 3450 | width: contentRow.width |
| 3451 | height: contentRow.height |
| 3452 | |
| 3453 | + Component.onCompleted: { |
| 3454 | + // must set the mock mode before loading the Shell |
| 3455 | + LightDM.Greeter.mockMode = "single-pin"; |
| 3456 | + LightDM.Users.mockMode = "single-pin"; |
| 3457 | + shellLoader.active = true; |
| 3458 | + } |
| 3459 | + |
| 3460 | QtObject { |
| 3461 | id: applicationArguments |
| 3462 | |
| 3463 | @@ -54,6 +61,7 @@ |
| 3464 | |
| 3465 | Loader { |
| 3466 | id: shellLoader |
| 3467 | + active: false |
| 3468 | |
| 3469 | width: units.gu(40) |
| 3470 | height: units.gu(71) |
| 3471 | |
| 3472 | === modified file 'tests/qmltests/tst_TabletShell.qml' |
| 3473 | --- tests/qmltests/tst_TabletShell.qml 2015-01-09 09:15:45 +0000 |
| 3474 | +++ tests/qmltests/tst_TabletShell.qml 2015-02-02 14:28:47 +0000 |
| 3475 | @@ -32,6 +32,13 @@ |
| 3476 | id: root |
| 3477 | spacing: 0 |
| 3478 | |
| 3479 | + Component.onCompleted: { |
| 3480 | + // must set the mock mode before loading the Shell |
| 3481 | + LightDM.Greeter.mockMode = "full"; |
| 3482 | + LightDM.Users.mockMode = "full"; |
| 3483 | + shellLoader.active = true; |
| 3484 | + } |
| 3485 | + |
| 3486 | QtObject { |
| 3487 | id: applicationArguments |
| 3488 | |
| 3489 | @@ -51,6 +58,7 @@ |
| 3490 | Loader { |
| 3491 | id: shellLoader |
| 3492 | |
| 3493 | + active: false |
| 3494 | width: units.gu(100) |
| 3495 | height: units.gu(80) |
| 3496 |

FAILED: Continuous integration, rev:1570 jenkins. qa.ubuntu. com/job/ unity8- ci/5185/ jenkins. qa.ubuntu. com/job/ generic- deb-autopilot- vivid-touch/ 966 jenkins. qa.ubuntu. com/job/ unity-phablet- qmluitests- vivid/349 jenkins. qa.ubuntu. com/job/ unity8- vivid-amd64- ci/350 jenkins. qa.ubuntu. com/job/ unity8- vivid-i386- ci/350 jenkins. qa.ubuntu. com/job/ generic- deb-autopilot- runner- vivid-mako/ 856 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- vivid-armhf/ 964 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- vivid-armhf/ 964/artifact/ work/output/ *zip*/output. zip s-jenkins. ubuntu- ci:8080/ job/touch- flash-device/ 17403
http://
Executed test runs:
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/unity8- ci/5185/ rebuild
http://