Merge lp:~dandrader/unity8/unifyLightDMMocks into lp:unity8

Proposed by Daniel d'Andrada
Status: Merged
Approved by: Michael Terry
Approved revision: 1568
Merged at revision: 1586
Proposed branch: lp:~dandrader/unity8/unifyLightDMMocks
Merge into: lp:unity8
Diff against target: 3381 lines (+1695/-953)
64 files modified
plugins/LightDM/CMakeLists.txt (+3/-3)
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)
plugins/Lights/CMakeLists.txt (+0/-2)
plugins/Powerd/CMakeLists.txt (+0/-2)
plugins/Unity/Launcher/CMakeLists.txt (+0/-1)
plugins/Unity/Session/CMakeLists.txt (+0/-2)
plugins/Utils/CMakeLists.txt (+0/-3)
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 (+11/-0)
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/unifyLightDMMocks
Reviewer Review Type Date Requested Status
Michael Terry Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
Review via email: mp+244593@code.launchpad.net

Commit message

Unify all liblightdm mocks

Benefits:
- Cleaner tests/qmltests/CMakeLists.txt
- Ability change LightDM fake behavior at runtime, which
  makes it possible to merge several tests, reducing code duplication,
  such as tst_Shell, tst_TabletShell and tst_ShellWithPin.
- Ability to make building of tests optional, as the demo version
  of lightdm mock has been moved into plugins/LightDM, removing
  the dependency between producition code and test code

Description of the change

* 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.

To post a comment you must log in.
Revision history for this message
Michael Terry (mterry) wrote :

Seems mostly good, thanks man!

The demo plugin shares a lot of code with the liblightdm mock. Any chance they could actually share the file? Like have the mock version subclass the demo version or something?

Also, we've been meaning to rename the demo plugin because we are actually using it in producton now. Maybe something that sounds a little more robust than demo? (though it does still hold some demo code)

1503. By Launchpad Translations on behalf of unity-team

Launchpad automatic translations update.

1504. By Launchpad Translations on behalf of unity-team

Launchpad automatic translations update.

1505. By Launchpad Translations on behalf of unity-team

Launchpad automatic translations update.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

> The demo plugin shares a lot of code with the liblightdm mock. Any chance
> they could actually share the file? Like have the mock version subclass the
> demo version or something?

I spent two miserable days trying to do it. It creates a horrible entanglement. Could we please avoid this?

1506. By Albert Astals Cid

Rework how we set the ranges so we get some more asynchronousity from item views Fixes: #1384374
Approved by: Andrea Cimitan

1507. By Daniel d'Andrada

Refactor Dialogs.qml to use proper in-scene dialogs

Proper in-scene dialogs keep its Loader as parent and
therefore carry on all its transformations, following its
rotation, etc.

It needs Dialog from ubuntu-ui-toolkit to comply with the
reparentToRootItem property.
Approved by: Michał Sawicz, Ying-Chun Liu

1508. By Daniel d'Andrada

Make Greeter nicely handle being resized

- Introduced support for bidirectional DragHandles
- Refactored greeter to use a bidirectional DragHandle
- Added code to ensure Greeter retains its relative positioning when Shell is resized
Approved by: Michael Terry

1509. By Albert Astals Cid

clickscope is back to being unfavoritable Fixes: #1400762
Approved by: Michał Sawicz

1510. By Albert Astals Cid

Fix clicking on the manage dash list after having moved the current scope

Comes with a test for that and for a other manage dash scope move situation
And removes unused code from the test
Approved by: Michael Zanetti

1511. By Albert Astals Cid

ScopesList: Use the default scope style for the header

1512. By Albert Astals Cid

Make the drag range be a multiple of the drag "rate" value. Workarounds https://bugs.launchpad.net/mir/+bug/1399690

Also small fixlet to make _get_scope_loader faster
Approved by: Michał Sawicz

1513. By Gerry Boland

MockAppMan: emit SIGSTOP so AP test apps are run Fixes: #1394208

1514. By CI Train Bot Account

Releasing 8.02+15.04.20141215.3-0ubuntu1

1515. By Launchpad Translations on behalf of unity-team

Launchpad automatic translations update.

1516. By Albert Astals Cid

Need to wait until loaded is true to use the count property
Approved by: Michael Zanetti

1517. By Albert Astals Cid

Manage Dash: Ellide properly

Approved by: Pawel Stolowski

1518. By CI Train Bot Account

Releasing 8.02+15.04.20141216.1-0ubuntu1

Revision history for this message
Michael Terry (mterry) wrote :

> I spent two miserable days trying to do it. It creates a horrible entanglement. Could we please avoid this?

OK, but can you at least add giant warnings at the top of the file that if you change one, you ought to change the other?

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

On 16/12/14 12:18, Michael Terry wrote:
>> I spent two miserable days trying to do it. It creates a horrible entanglement. Could we please avoid this?
> OK, but can you at least add giant warnings at the top of the file that if you change one, you ought to change the other?

Sure. done.

Revision history for this message
Michael Terry (mterry) wrote :

Running ./run.sh -f gives:

file:///home/mike/Work/code/unity8/unifyLightDMMocks/qml/Shell.qml:30:1: plugin cannot be loaded for module "LightDM": Cannot load library /home/mike/Work/code/unity8/unifyLightDMMocks/builddir/tests/mocks/LightDM/libMockLightDM-qml.so: (liblightdm-qt5-2.so: cannot open shared object file: No such file or directory)
     import LightDM 0.1 as LightDM
     ^

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1519. By Launchpad Translations on behalf of unity-team

Launchpad automatic translations update.

1520. By Launchpad Translations on behalf of unity-team

Launchpad automatic translations update.

1521. By Launchpad Translations on behalf of unity-team

Launchpad automatic translations update.

1522. By Launchpad Translations on behalf of unity-team

Launchpad automatic translations update.

1523. By Launchpad Translations on behalf of unity-team

Launchpad automatic translations update.

1524. By Launchpad Translations on behalf of unity-team

Launchpad automatic translations update.

1525. By Albert Astals Cid

Fix going to scopes when the Manage Dash is open Fixes: #1403464
Approved by: Michael Zanetti, PS Jenkins bot

1526. By Albert Astals Cid

QSortFilterProxyModelQML -> UnitySortFilterProxyModelQML

Someone copied the class to the sdk (but with less features...) so we better rename, class and qml name collisions are not cool Fixes: #1403758
Approved by: Michael Zanetti, PS Jenkins bot

1527. By Albert Astals Cid

Clip the Scopes List header

Now that we have a background since we use a default ScopeStyle we need to clip the "upper/search" part of the header Fixes: #1407620
Approved by: Andrea Cimitan, PS Jenkins bot

1528. By Albert Astals Cid

Fix ScopesList not being under finger

Do not take into the account the initial distance that took the movement to be accepted to calculate the position Fixes: #1403045
Approved by: Andrea Cimitan, PS Jenkins bot

1529. By Martin Pitt

tests: Fix Notify.Notification.add_action invocation to work also with unpatched libnotify API. Fixes: #1223401
Approved by: Michał Sawicz, PS Jenkins bot

1530. By Albert Astals Cid

Make waitForRendering with no item fail instead of crash
Approved by: Michał Sawicz, PS Jenkins bot

1531. By Albert Astals Cid

Disable Dash horizontal scroll while Navigation InverseMouseArea is pressed Fixes: #1403048
Approved by: Andrea Cimitan

1532. By Michał Sawicz

We don't need the SIGSTOP in main() any more.
Approved by: Michael Zanetti

1533. By dobey

Depend on :native version of g++ to allow cross-compiling to work. Fixes: #1353855
Approved by: Michał Sawicz, PS Jenkins bot

1534. By Nick Dedekind

Unhook Lights interface from indicator widgets Fixes: #1385331
Approved by: Albert Astals Cid

1535. By Michael Terry

Don't block handling power events on loading the greeter's qml and the background image.

During power button press, we call greeter.showNow(), which was taking so long to return that we couldn't handle the power button release for a few seconds. Which meant that the shutdown dialog thought it would be a good time to appear.

The easiest fix is to delay calling showNow until after we finish handling the event. Fixes: #1383277
Approved by: Daniel d'Andrada, PS Jenkins bot

1536. By Michael Terry

Show OSK above the wizard. Fixes: #1401213
Approved by: Andrea Cimitan, PS Jenkins bot

1537. By Leo Arias

Added an autopilot test for the edges demo.
Approved by: PS Jenkins bot, Albert Astals Cid

1538. By Michael Terry

Unify the name of the Greeter DBus test, make it use our standard binary test macro (which also nicely exports xml results), and make the test a little more robust against timing issues.
Approved by: PS Jenkins bot, Albert Astals Cid

1539. By Michael Terry

Add a test to make sure the shell always starts disabled until it is enabled by a complete PAM interaction.
Approved by: Michał Sawicz

1540. By Albert Astals Cid

Test: Make sure the mouse area is enabled before clicking into it

Despite the name swipeToCloseEnabled controls the enabled property of the whole mouse area
of the spread delegate so it needs to be true (animations & movement finished) before we can click on it

Approved by: Michał Sawicz

1541. By Albert Astals Cid

Test: We actually need to click on the customBackButton and not on backButton

Approved by: Michał Sawicz

1542. By Albert Astals Cid

Test: By default mouseX act on the middle

Saves us lots of typing, tests are easier to read and workarounds problems that sometimes happen if we end up with 0, 0 as mouse coordinates because the precission of some geometry goes crazy and since we're clicking on 0x0 after lots transformations of pos into pos into pos we end up clicking outside the item by a very small number

Approved by: Michał Sawicz

1543. By CI Train Bot Account

Releasing 8.02+15.04.20150109.2-0ubuntu1

1544. By Launchpad Translations on behalf of unity-team

Launchpad automatic translations update.

Revision history for this message
Albert Astals Cid (aacid) wrote :

Text conflict in tests/mocks/LightDM/CMakeLists.txt
Text conflict in tests/plugins/LightDM/CMakeLists.txt
2 conflicts encountered.

1545. By Leo Arias

Added an autopilot test for the edges demo.
Approved by: PS Jenkins bot, Albert Astals Cid

1546. By Gerry Boland

DashCommunicator: replace QDBusInterface with a non-blocking simplification which does not introspect the service on creation Fixes: #1403508
Approved by: Michael Zanetti

1547. By Albert Astals Cid

Don't show the manage dash pull up arrow on temp scopes Fixes: #1401869
Approved by: Michael Zanetti

1548. By Albert Astals Cid

Remove hack, newer Qt already support keyClick(char)

Approved by: Michael Zanetti, PS Jenkins bot

1549. By Albert Astals Cid

Tests: Add Qt 5.5 removal TODOs

Approved by: Michał Sawicz

1550. By Michael Zanetti

patch debian/control file before using it to make it work with mk-build-deps
Approved by: Michał Sawicz

1551. By Albert Astals Cid

Make sure we use fPIC when compiling files for the static library too

Fixes compilation in ARM + Qt 5.4 Fixes: #1409235
Approved by: Michał Sawicz, Dmitry Shachnev

1552. By Albert Astals Cid

Make sure changing a scope doesn't trigger creation/destruction of delegates until it's finished
 Fixes: #1410122
Approved by: Michał Sawicz

1553. By Andrea Cimitan

support background on horizontal cards with summary Fixes: #1393008
Approved by: Michał Sawicz

1554. By CI Train Bot Account

Releasing 8.02+15.04.20150113.1-0ubuntu1

1555. By CI Train Bot Account

Resync trunk

1556. By Launchpad Translations on behalf of unity-team

Launchpad automatic translations update.

1557. By Launchpad Translations on behalf of unity-team

Launchpad automatic translations update.

1558. By Launchpad Translations on behalf of unity-team

Launchpad automatic translations update.

1559. By Launchpad Translations on behalf of unity-team

Launchpad automatic translations update.

1560. By Launchpad Translations on behalf of unity-team

Launchpad automatic translations update.

1561. By Daniel d'Andrada

Unify all liblightdm mocks

Benefits:
- Cleaner tests/qmltests/CMakeLists.txt
- Ability change LightDM fake behavior at runtime, which
  makes it possible to merge several tests, reducing code duplication,
  such as tst_Shell, tst_TabletShell and tst_ShellWithPin.
- Ability to make building of tests optional, as the demo version
  of lightdm mock has been moved into plugins/LightDM, removing
  the dependency between producition code and test code

1562. By Daniel d'Andrada

Update run.sh

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

> Running ./run.sh -f gives:
>
> file:///home/mike/Work/code/unity8/unifyLightDMMocks/qml/Shell.qml:30:1:
> plugin cannot be loaded for module "LightDM": Cannot load library
> /home/mike/Work/code/unity8/unifyLightDMMocks/builddir/tests/mocks/LightDM
> /libMockLightDM-qml.so: (liblightdm-qt5-2.so: cannot open shared object file:
> No such file or directory)
> import LightDM 0.1 as LightDM
> ^

Fixed.

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

> Text conflict in tests/mocks/LightDM/CMakeLists.txt
> Text conflict in tests/plugins/LightDM/CMakeLists.txt
> 2 conflicts encountered.

Fixed.

1563. By Daniel d'Andrada

Further clean up of run.sh

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1564. By Daniel d'Andrada

Init mockMode

Revision history for this message
Michael Terry (mterry) wrote :

OK, seems good now, assuming Jenkins approves. Thanks man!

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michael Terry (mterry) wrote :

A lot of autopilot tests are failing with errors like:

RuntimeError: LightDM mock 'single-pin' does not exist at path '/usr/lib/arm-linux-gnueabihf/unity8/qml/mocks/LightDM/single-pin'.

RuntimeError: LightDM mock 'single' does not exist at path '/usr/lib/arm-linux-gnueabihf/unity8/qml/mocks/LightDM/single'.

Some other autopilot tests are failing for presumably other reasons (indicators). The qmluitests failures are in DashContent and also seem unrelated.

review: Needs Fixing
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

> A lot of autopilot tests are failing with errors like:
>
> RuntimeError: LightDM mock 'single-pin' does not exist at path '/usr/lib/arm-
> linux-gnueabihf/unity8/qml/mocks/LightDM/single-pin'.
>
> RuntimeError: LightDM mock 'single' does not exist at path '/usr/lib/arm-
> linux-gnueabihf/unity8/qml/mocks/LightDM/single'.

Oh, thanks for pointing that out. I forgot to check if the autopilot tests were using those libs.

> The qmluitests failures are in DashContent and also seem
> unrelated.

Yes, Dash has some known unstable tests at the moment. tsdgeos has a branch to make them more reliable.

1565. By Daniel d'Andrada

Enable specifying liblightdm mock mode via env var

1566. By Daniel d'Andrada

Update autopilot tests

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

Text conflict in tests/mocks/LightDM/CMakeLists.txt
Text conflict in tests/plugins/LightDM/CMakeLists.txt
Text conflict in tests/qmltests/CMakeLists.txt
3 conflicts encountered.

1567. By Daniel d'Andrada

Merge trunk

[ Michael Terry ]
* Don't show any power dialogs while the screen is off. This is a
  band-aid to avoid the symptom, while we still investigate the source
  of why the screen doesn't turn on (and why we seem to not handle the
  power-button-release event). (LP: #1409003, #1410830)
* Don't refocus the dialer-app when a call is started by the user.
  Because of how qtmir works, this would cause the dialer-app to
  unfocus momentarily, causing interface oddities for the user. (LP:
  #1413065)
[ CI Train Bot ]
* Resync trunk
[ Albert Astals Cid ]
* Build with ninja
* Fixes for Table Preview Widget (LP: #1410420)
[ Michael Zanetti ]
* Add support for earpiece media buttons (LP: #1398427)
* Add a WindowMoveResizeArea and tests for it

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

On 22/01/15 06:39, Albert Astals Cid wrote:
> Text conflict in tests/mocks/LightDM/CMakeLists.txt
> Text conflict in tests/plugins/LightDM/CMakeLists.txt
> Text conflict in tests/qmltests/CMakeLists.txt
> 3 conflicts encountered.
Fixed

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michael Terry (mterry) wrote :

unity8.application_lifecycle.tests.test_application_lifecycle.ApplicationLifecycleTests.test_greeter_hides_on_app_focus is failing, but doesn't on trunk for me. Might be due to these changes.

1568. By Daniel d'Andrada

Just to trigger a new build in Jenkins

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

> unity8.application_lifecycle.tests.test_application_lifecycle.ApplicationLifec
> ycleTests.test_greeter_hides_on_app_focus is failing, but doesn't on trunk for
> me. Might be due to these changes.

That test no longer fails in the latest Jenkins run. I just triggered a rebuild. No code changes. So this is an unstable test.

/me does the happy dance.

Revision history for this message
Michael Terry (mterry) wrote :

Just because it's an unstable test doesn't mean it's not your fault. :) But I agree that your changes would be more likely to reliably break a test than cause it to be flaky.

OK, I'll approve the branch.

review: Approve
Revision history for this message
Albert Astals Cid (aacid) wrote :

Text conflict in run.sh
Text conflict in tests/mocks/LightDM/CMakeLists.txt
Text conflict in tests/plugins/LightDM/CMakeLists.txt
3 conflicts encountered.

1569. By Daniel d'Andrada

Merge trunk

[ Sebastien Bacher ]
* Set text hint property for the messaging menus inline reply widget
  (LP: #1389234)
[ Ying-Chun Liu ]
* Added an initial set of autopilot tests for the display indicator.
[ Nick Dedekind ]
* Removed filtering the indicator model by visibility.
[ Michael Zanetti ]
* fixes left edge drag when in spread
[ Albert Astals Cid ]
* Fix ninja build in a different way The previous one was adding rpath
  to some .so that broke our tests that use LD_LIBRARY_PATH to change
  which one is picked up
[ Leo Arias ]
* Added an initial set of autopilot tests for the display indicator.

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

> Text conflict in run.sh
> Text conflict in tests/mocks/LightDM/CMakeLists.txt
> Text conflict in tests/plugins/LightDM/CMakeLists.txt
> 3 conflicts encountered.

Solved.

1570. By Daniel d'Andrada

include(FindPkgConfig) only once, in the root CMakeLists.txt

In order to fix cross compilation

Patch by Saviq

Preview Diff

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

Subscribers

People subscribed via source and target branches