Merge lp:~mterry/unity8/simple-lightdm-mock into lp:unity8

Proposed by Michael Terry
Status: Merged
Approved by: Albert Astals Cid
Approved revision: 2751
Merged at revision: 2775
Proposed branch: lp:~mterry/unity8/simple-lightdm-mock
Merge into: lp:unity8
Diff against target: 3068 lines (+646/-1333)
63 files modified
debian/rules (+1/-1)
plugins/LightDM/CMakeLists.txt (+0/-1)
plugins/LightDM/Greeter.cpp (+1/-1)
plugins/LightDM/Greeter.h (+2/-5)
plugins/LightDM/SessionsModel.cpp (+1/-2)
plugins/LightDM/SessionsModel.h (+4/-5)
plugins/LightDM/UsersModel.cpp (+1/-1)
plugins/LightDM/UsersModel.h (+2/-7)
qml/Greeter/LightDMService.qml (+3/-4)
tests/CMakeLists.txt (+1/-1)
tests/autopilot/unity8/fixture_setup.py (+1/-1)
tests/autopilot/unity8/shell/tests/__init__.py (+1/-1)
tests/mocks/AccountsService/AccountsService.cpp (+2/-3)
tests/mocks/AccountsService/AccountsService.h (+3/-6)
tests/mocks/AccountsService/CMakeLists.txt (+1/-2)
tests/mocks/CMakeLists.txt (+2/-1)
tests/mocks/LightDM/CMakeLists.txt (+0/-1)
tests/mocks/LightDM/IntegratedLightDM/CMakeLists.txt (+0/-50)
tests/mocks/LightDM/IntegratedLightDM/MockGreeter.cpp (+0/-51)
tests/mocks/LightDM/IntegratedLightDM/MockGreeter.h (+0/-42)
tests/mocks/LightDM/IntegratedLightDM/MockSessionsModel.cpp (+0/-66)
tests/mocks/LightDM/IntegratedLightDM/MockSessionsModel.h (+0/-44)
tests/mocks/LightDM/IntegratedLightDM/MockUsersModel.cpp (+0/-44)
tests/mocks/LightDM/IntegratedLightDM/MockUsersModel.h (+0/-39)
tests/mocks/LightDM/IntegratedLightDM/QLightDM/Greeter (+0/-17)
tests/mocks/LightDM/IntegratedLightDM/QLightDM/SessionsModel (+0/-17)
tests/mocks/LightDM/IntegratedLightDM/QLightDM/UsersModel (+0/-17)
tests/mocks/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.cpp (+0/-132)
tests/mocks/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.h (+0/-54)
tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.cpp (+0/-83)
tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.h (+0/-63)
tests/mocks/LightDM/IntegratedLightDM/liblightdm/UsersModelPrivate.cpp (+0/-124)
tests/mocks/LightDM/IntegratedLightDM/liblightdm/UsersModelPrivate.h (+0/-64)
tests/mocks/LightDM/IntegratedLightDM/plugin.cpp (+0/-79)
tests/mocks/LightDM/IntegratedLightDM/plugin.h (+0/-32)
tests/mocks/LightDM/IntegratedLightDM/qmldir (+0/-2)
tests/mocks/LightDMController/CMakeLists.txt (+15/-0)
tests/mocks/LightDMController/plugin.cpp (+35/-0)
tests/mocks/LightDMController/plugin.h (+29/-0)
tests/mocks/LightDMController/qmldir (+2/-0)
tests/mocks/liblightdm/CMakeLists.txt (+8/-11)
tests/mocks/liblightdm/MockController.cpp (+124/-0)
tests/mocks/liblightdm/MockController.h (+80/-0)
tests/mocks/liblightdm/MockGreeter.cpp (+85/-35)
tests/mocks/liblightdm/MockGreeter.h (+9/-22)
tests/mocks/liblightdm/MockSessionsModel.cpp (+47/-49)
tests/mocks/liblightdm/MockSessionsModel.h (+9/-17)
tests/mocks/liblightdm/MockUsersModel.cpp (+85/-20)
tests/mocks/liblightdm/MockUsersModel.h (+6/-16)
tests/plugins/LightDM/IntegratedLightDM/CMakeLists.txt (+3/-3)
tests/plugins/LightDM/IntegratedLightDM/greeter.qml (+2/-7)
tests/plugins/LightDM/IntegratedLightDM/sessionsmodel.cpp (+15/-13)
tests/plugins/LightDM/IntegratedLightDM/usersmodel.cpp (+2/-12)
tests/qmltests/Dash/tst_DashShell.qml (+8/-0)
tests/qmltests/Greeter/TestView.qml (+1/-0)
tests/qmltests/Greeter/tst_Greeter.qml (+6/-8)
tests/qmltests/Greeter/tst_Infographics.qml (+1/-11)
tests/qmltests/Greeter/tst_NarrowView.qml (+9/-2)
tests/qmltests/Greeter/tst_WideView.qml (+20/-30)
tests/qmltests/Tutorial/tst_Tutorial.qml (+3/-3)
tests/qmltests/tst_OrientedShell.qml (+8/-1)
tests/qmltests/tst_Shell.qml (+5/-7)
tests/qmltests/tst_ShellWithPin.qml (+3/-3)
To merge this branch: bzr merge lp:~mterry/unity8/simple-lightdm-mock
Reviewer Review Type Date Requested Status
Unity8 CI Bot continuous-integration Approve
Albert Astals Cid (community) Approve
Review via email: mp+313478@code.launchpad.net

Commit message

Simplify the lightdm mock to make future greeter improvements easier to test.

I simplified the mock liblightdm to avoid separate files for the Private classes. That can all go into the main files. The separation isn't worth wading through the files to find what you want.

And I dropped the mock LightDM plugin entirely. (opting instead for a tiny "mock()" API call on the real plugin that returns an object that can be used to manipulate our mock liblightdm, if we're in testing mode)

Description of the change

Simplify the lightdm mock to make future greeter improvements easier to test.

I simplified the mock liblightdm to avoid separate files for the Private classes. That can all go into the main files. The separation isn't worth wading through the files to find what you want.

And I dropped the mock LightDM plugin entirely. (opting instead for a tiny "mock()" API call on the real plugin that returns an object that can be used to manipulate our mock liblightdm, if we're in testing mode)

To post a comment you must log in.
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

FAILED: Continuous integration, rev:2744
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/2731/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/3586
    UNSTABLE: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=qmluitests.sh/2050
    UNSTABLE: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=zesty,testname=qmluitests.sh/2050
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/3614
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/3460
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/3460/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/3460
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/3460/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/3460
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/3460/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/3460
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/3460/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/3460
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/3460/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/3460
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/3460/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/2731/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

WideView::test_choosingNewSessionChangesLoginListIcon seems to fail in both xenial and zesty

review: Needs Fixing
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

FAILED: Continuous integration, rev:2744
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/2749/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/3605
    UNSTABLE: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=qmluitests.sh/2061
    UNSTABLE: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=zesty,testname=qmluitests.sh/2061
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/3633
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/3479
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/3479/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/3479
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/3479/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/3479
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/3479/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/3479
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/3479/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/3479
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/3479/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/3479
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/3479/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/2749/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

I do appreciate that we have dropped quite a bit of code, but I'm not very happy with the mock() API addition, what about http://paste.ubuntu.com/23658647/ ?

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

The previous paste was missing the new plugin that exposes the MockController http://paste.ubuntu.com/23658654/

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

Albert thanks for that! I do like that better. Though I changed from QLightDMController to LightDMController, as a matter of aesthetic preference.

Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

FAILED: Continuous integration, rev:2747
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/2753/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/3609
    UNSTABLE: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=qmluitests.sh/2064
    UNSTABLE: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=zesty,testname=qmluitests.sh/2064
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/3637
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/3483
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/3483/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/3483
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/3483/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/3483
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/3483/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/3483
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/3483/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/3483
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/3483/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/3483
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/3483/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/2753/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

FAILED: Continuous integration, rev:2748
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/2755/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/3613
    UNSTABLE: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=qmluitests.sh/2066
    FAILURE: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=zesty,testname=qmluitests.sh/2066/console
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/3641
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/3487
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/3487/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/3487
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/3487/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/3487
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/3487/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/3487
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/3487/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/3487
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/3487/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/3487
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/3487/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/2755/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

FAILED: Continuous integration, rev:2748
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/2757/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/3615
    UNSTABLE: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=qmluitests.sh/2068
    FAILURE: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=zesty,testname=qmluitests.sh/2068/console
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/3643
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/3489
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/3489/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/3489
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/3489/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/3489
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/3489/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/3489
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/3489/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/3489
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/3489/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/3489
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/3489/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/2757/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

Though i can not reproduce it locally
    WideView::test_choosingNewSessionChangesLoginListIcon
seems to be quite persistent in failing in this branch in CI.

review: Needs Fixing
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

FAILED: Continuous integration, rev:2749
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/2833/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/3710
    UNSTABLE: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=qmluitests.sh/2133
    UNSTABLE: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=zesty,testname=qmluitests.sh/2133
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/3738
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/3582
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/3582/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/3582
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/3582/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/3582
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/3582/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/3582
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/3582/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/3582
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/3582/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/3582
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/3582/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/2833/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

PASSED: Continuous integration, rev:2750
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/2836/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/3714
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=qmluitests.sh/2137
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=zesty,testname=qmluitests.sh/2137
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/3742
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/3586
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/3586/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/3586
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/3586/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/3586
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/3586/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/3586
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/3586/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/3586
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/3586/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/3586
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/3586/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/2836/rebuild

review: Approve (continuous-integration)
Revision history for this message
Michael Terry (mterry) wrote :

OK tests pass again finally. Phew. Ready for re-review. :)

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

Mock code being removed \o/

 * Did you perform an exploratory manual test run of the code change and any related functionality?
Yes

 * Did CI run pass? If not, please explain why.
Yes

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

Looooooooooooots of conflicts

review: Needs Fixing
2751. By Michael Terry

Merge trunk

Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

PASSED: Continuous integration, rev:2751
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/2920/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/3811
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=qmluitests.sh/2207
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=zesty,testname=qmluitests.sh/2207
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/3839
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/3682
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/3682/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/3682
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/3682/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/3682
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/3682/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/3682
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/3682/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/3682
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/3682/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/3682
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/3682/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/2920/rebuild

review: Approve (continuous-integration)
Revision history for this message
Michael Terry (mterry) wrote :

Fixed the conflicts! Phew.

Revision history for this message
Albert Astals Cid (aacid) :
review: Approve
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

PASSED: Continuous integration, rev:2751
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/2941/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/3837
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=qmluitests.sh/2230
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=zesty,testname=qmluitests.sh/2230
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/3865
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/3708
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/3708/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/3708
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/3708/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/3708
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/3708/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/3708
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/3708/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/3708
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/3708/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/3708
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/3708/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/2941/rebuild

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/rules'
--- debian/rules 2017-01-03 14:02:23 +0000
+++ debian/rules 2017-01-17 15:40:09 +0000
@@ -40,4 +40,4 @@
40override_dh_shlibdeps:40override_dh_shlibdeps:
41 # Some mock libraries link against liblightdm-qt5-3.so which we want to41 # Some mock libraries link against liblightdm-qt5-3.so which we want to
42 # avoid, since we only really link against our mock one, not the system one.42 # avoid, since we only really link against our mock one, not the system one.
43 dh_shlibdeps -XlibMockLightDM-qml.so -XlibMockAccountsService-qml.so -Lunity8-private43 dh_shlibdeps -XlibMockAccountsService-qml.so -Lunity8-private
4444
=== modified file 'plugins/LightDM/CMakeLists.txt'
--- plugins/LightDM/CMakeLists.txt 2016-03-02 02:54:30 +0000
+++ plugins/LightDM/CMakeLists.txt 2017-01-17 15:40:09 +0000
@@ -7,7 +7,6 @@
7 ${CMAKE_CURRENT_SOURCE_DIR}7 ${CMAKE_CURRENT_SOURCE_DIR}
8 ${CMAKE_CURRENT_BINARY_DIR}8 ${CMAKE_CURRENT_BINARY_DIR}
9 ${CMAKE_SOURCE_DIR}/plugins/Utils9 ${CMAKE_SOURCE_DIR}/plugins/Utils
10 ${CMAKE_BINARY_DIR}/tests/mocks/LightDM/IntegratedLightDM
11 ${libunity8-private_SOURCE_DIR}10 ${libunity8-private_SOURCE_DIR}
12 ${LIBUSERMETRICSOUTPUT_INCLUDE_DIRS}11 ${LIBUSERMETRICSOUTPUT_INCLUDE_DIRS}
13)12)
1413
=== modified file 'plugins/LightDM/Greeter.cpp'
--- plugins/LightDM/Greeter.cpp 2016-07-28 15:34:29 +0000
+++ plugins/LightDM/Greeter.cpp 2017-01-17 15:40:09 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2013, 2015 Canonical, Ltd.2 * Copyright (C) 2013-2016 Canonical, Ltd.
3 *3 *
4 * This program is free software; you can redistribute it and/or modify4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by5 * it under the terms of the GNU General Public License as published by
66
=== modified file 'plugins/LightDM/Greeter.h'
--- plugins/LightDM/Greeter.h 2016-07-28 15:34:29 +0000
+++ plugins/LightDM/Greeter.h 2017-01-17 15:40:09 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2012,2013,2015 Canonical, Ltd.2 * Copyright (C) 2012-2016 Canonical, Ltd.
3 *3 *
4 * This program is free software; you can redistribute it and/or modify4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by5 * it under the terms of the GNU General Public License as published by
@@ -21,8 +21,7 @@
21 such edits in the future, and by inserting ourselves here, we have more21 such edits in the future, and by inserting ourselves here, we have more
22 control. */22 control. */
2323
24#ifndef UNITY_GREETER_H24#pragma once
25#define UNITY_GREETER_H
2625
27#include <QLightDM/Greeter>26#include <QLightDM/Greeter>
28#include <QtCore/QObject>27#include <QtCore/QObject>
@@ -81,5 +80,3 @@
81 void showPromptFilter(const QString &text, QLightDM::Greeter::PromptType type);80 void showPromptFilter(const QString &text, QLightDM::Greeter::PromptType type);
82 void authenticationCompleteFilter();81 void authenticationCompleteFilter();
83};82};
84
85#endif
8683
=== modified file 'plugins/LightDM/SessionsModel.cpp'
--- plugins/LightDM/SessionsModel.cpp 2016-10-07 17:24:55 +0000
+++ plugins/LightDM/SessionsModel.cpp 2017-01-17 15:40:09 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2015 Canonical, Ltd.2 * Copyright (C) 2015-2016 Canonical, Ltd.
3 *3 *
4 * This program is free software; you can redistribute it and/or modify4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by5 * it under the terms of the GNU General Public License as published by
@@ -128,7 +128,6 @@
128 }128 }
129129
130 setModel(m_model);130 setModel(m_model);
131 setSourceModel(m_model);
132 setSortCaseSensitivity(Qt::CaseInsensitive);131 setSortCaseSensitivity(Qt::CaseInsensitive);
133 setSortLocaleAware(true);132 setSortLocaleAware(true);
134 setSortRole(Qt::DisplayRole);133 setSortRole(Qt::DisplayRole);
135134
=== modified file 'plugins/LightDM/SessionsModel.h'
--- plugins/LightDM/SessionsModel.h 2016-12-23 11:04:53 +0000
+++ plugins/LightDM/SessionsModel.h 2017-01-17 15:40:09 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2015 Canonical, Ltd.2 * Copyright (C) 2015-2016 Canonical, Ltd.
3 *3 *
4 * This program is free software; you can redistribute it and/or modify4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by5 * it under the terms of the GNU General Public License as published by
@@ -15,8 +15,7 @@
15 *15 *
16 */16 */
1717
18#ifndef UNITY_SESSIONSMODEL_H18#pragma once
19#define UNITY_SESSIONSMODEL_H
2019
21#include <unitysortfilterproxymodelqml.h>20#include <unitysortfilterproxymodelqml.h>
22#include <QLightDM/SessionsModel>21#include <QLightDM/SessionsModel>
@@ -30,6 +29,7 @@
3029
31 Q_PROPERTY(QList<QUrl> iconSearchDirectories READ iconSearchDirectories30 Q_PROPERTY(QList<QUrl> iconSearchDirectories READ iconSearchDirectories
32 WRITE setIconSearchDirectories NOTIFY iconSearchDirectoriesChanged)31 WRITE setIconSearchDirectories NOTIFY iconSearchDirectoriesChanged)
32
33Q_SIGNALS:33Q_SIGNALS:
34 void iconSearchDirectoriesChanged();34 void iconSearchDirectoriesChanged();
3535
@@ -54,6 +54,7 @@
54 Q_INVOKABLE QUrl iconUrl(const QString sessionName) const;54 Q_INVOKABLE QUrl iconUrl(const QString sessionName) const;
5555
56 void setIconSearchDirectories(const QList<QUrl> searchDirectories);56 void setIconSearchDirectories(const QList<QUrl> searchDirectories);
57
57private:58private:
58 QLightDM::SessionsModel* m_model;59 QLightDM::SessionsModel* m_model;
59 QHash<int, QByteArray> m_roleNames;60 QHash<int, QByteArray> m_roleNames;
@@ -63,5 +64,3 @@
63 QUrl("/usr/share/unity-greeter/")};64 QUrl("/usr/share/unity-greeter/")};
6465
65};66};
66
67#endif // UNITY_SESSIONSMODEL_H
6867
=== modified file 'plugins/LightDM/UsersModel.cpp'
--- plugins/LightDM/UsersModel.cpp 2015-10-26 20:15:08 +0000
+++ plugins/LightDM/UsersModel.cpp 2017-01-17 15:40:09 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2013 Canonical, Ltd.2 * Copyright (C) 2013,2015-2016 Canonical, Ltd.
3 *3 *
4 * This program is free software; you can redistribute it and/or modify4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by5 * it under the terms of the GNU General Public License as published by
66
=== modified file 'plugins/LightDM/UsersModel.h'
--- plugins/LightDM/UsersModel.h 2015-09-11 13:38:45 +0000
+++ plugins/LightDM/UsersModel.h 2017-01-17 15:40:09 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2012,2013 Canonical, Ltd.2 * Copyright (C) 2012-2013,2015-2016 Canonical, Ltd.
3 *3 *
4 * This program is free software; you can redistribute it and/or modify4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by5 * it under the terms of the GNU General Public License as published by
@@ -12,16 +12,13 @@
12 *12 *
13 * You should have received a copy of the GNU General Public License13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors: Michael Terry <michael.terry@canonical.com>
17 */15 */
1816
19/* This class is a really tiny filter around QLightDM::UsersModel. There are17/* This class is a really tiny filter around QLightDM::UsersModel. There are
20 some operations that we want to edit a bit for the benefit of Qml.18 some operations that we want to edit a bit for the benefit of Qml.
21 Specifically, we want to sort users according to realName. */19 Specifically, we want to sort users according to realName. */
2220
23#ifndef UNITY_USERSMODEL_H21#pragma once
24#define UNITY_USERSMODEL_H
2522
26#include <unitysortfilterproxymodelqml.h>23#include <unitysortfilterproxymodelqml.h>
27#include <QtCore/QObject>24#include <QtCore/QObject>
@@ -33,5 +30,3 @@
33public:30public:
34 explicit UsersModel(QObject* parent=0);31 explicit UsersModel(QObject* parent=0);
35};32};
36
37#endif
3833
=== modified file 'qml/Greeter/LightDMService.qml'
--- qml/Greeter/LightDMService.qml 2015-11-19 21:47:32 +0000
+++ qml/Greeter/LightDMService.qml 2017-01-17 15:40:09 +0000
@@ -35,10 +35,9 @@
35 // This trickery handles cases where applicationArguments aren't provided35 // This trickery handles cases where applicationArguments aren't provided
36 // such as during testing36 // such as during testing
37 property var fullLightDM: {37 property var fullLightDM: {
38 if (typeof applicationArguments !== "undefined") {38 if (typeof applicationArguments === "undefined" ||
39 if (applicationArguments.mode === "greeter") {39 applicationArguments.mode === "greeter") {
40 return true;40 return true;
41 }
42 }41 }
43 return false;42 return false;
44 }43 }
4544
=== modified file 'tests/CMakeLists.txt'
--- tests/CMakeLists.txt 2016-12-06 20:16:56 +0000
+++ tests/CMakeLists.txt 2017-01-17 15:40:09 +0000
@@ -42,8 +42,8 @@
4242
43 set(ld_paths)43 set(ld_paths)
44 list(APPEND ld_paths44 list(APPEND ld_paths
45 ${UNITY_MOCKPATH}/liblightdm
45 ${UNITY_MOCKPATH}/libusermetrics46 ${UNITY_MOCKPATH}/libusermetrics
46 ${UNITY_MOCKPATH}/LightDM/IntegratedLightDM/liblightdm
47 )47 )
4848
49 string(REPLACE ";" ":" ld_library_path "${ld_paths}")49 string(REPLACE ";" ":" ld_library_path "${ld_paths}")
5050
=== modified file 'tests/autopilot/unity8/fixture_setup.py'
--- tests/autopilot/unity8/fixture_setup.py 2015-10-26 20:15:08 +0000
+++ tests/autopilot/unity8/fixture_setup.py 2017-01-17 15:40:09 +0000
@@ -74,7 +74,7 @@
74 def _get_lightdm_mock_path(self):74 def _get_lightdm_mock_path(self):
75 lib_path = get_mocks_library_path()75 lib_path = get_mocks_library_path()
76 lightdm_mock_path = os.path.abspath(76 lightdm_mock_path = os.path.abspath(
77 os.path.join(lib_path, "LightDM" ,"IntegratedLightDM", "liblightdm")77 os.path.join(lib_path, "liblightdm")
78 )78 )
7979
80 if not os.path.exists(lightdm_mock_path):80 if not os.path.exists(lightdm_mock_path):
8181
=== modified file 'tests/autopilot/unity8/shell/tests/__init__.py'
--- tests/autopilot/unity8/shell/tests/__init__.py 2016-10-25 13:11:19 +0000
+++ tests/autopilot/unity8/shell/tests/__init__.py 2017-01-17 15:40:09 +0000
@@ -264,7 +264,7 @@
264 def _get_lightdm_mock_path(self):264 def _get_lightdm_mock_path(self):
265 lib_path = get_mocks_library_path()265 lib_path = get_mocks_library_path()
266 lightdm_mock_path = os.path.abspath(266 lightdm_mock_path = os.path.abspath(
267 os.path.join(lib_path, "LightDM" ,"IntegratedLightDM", "liblightdm")267 os.path.join(lib_path, "liblightdm")
268 )268 )
269269
270 if not os.path.exists(lightdm_mock_path):270 if not os.path.exists(lightdm_mock_path):
271271
=== modified file 'tests/mocks/AccountsService/AccountsService.cpp'
--- tests/mocks/AccountsService/AccountsService.cpp 2016-08-04 14:05:54 +0000
+++ tests/mocks/AccountsService/AccountsService.cpp 2017-01-17 15:40:09 +0000
@@ -15,7 +15,7 @@
15 */15 */
1616
17#include "AccountsService.h"17#include "AccountsService.h"
18#include "MockUsersModel.h"18#include "UsersModel.h"
1919
20#include <QLightDM/UsersModel>20#include <QLightDM/UsersModel>
21#include <paths.h>21#include <paths.h>
@@ -33,9 +33,8 @@
33 m_demoEdgesCompleted(),33 m_demoEdgesCompleted(),
34 m_hereEnabled(false),34 m_hereEnabled(false),
35 m_hereLicensePath(""),35 m_hereLicensePath(""),
36 m_usersModel(new MockUsersModel(this))36 m_usersModel(new UsersModel(this))
37{37{
38 m_usersModel->setMockMode("full");
39}38}
4039
41QString AccountsService::user() const40QString AccountsService::user() const
4241
=== modified file 'tests/mocks/AccountsService/AccountsService.h'
--- tests/mocks/AccountsService/AccountsService.h 2016-12-23 11:04:53 +0000
+++ tests/mocks/AccountsService/AccountsService.h 2017-01-17 15:40:09 +0000
@@ -14,15 +14,14 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */15 */
1616
17#ifndef UNITY_MOCK_ACCOUNTSSERVICE_H17#pragma once
18#define UNITY_MOCK_ACCOUNTSSERVICE_H
1918
20#include <QObject>19#include <QObject>
21#include <QString>20#include <QString>
22#include <QStringList>21#include <QStringList>
23#include <QVariant>22#include <QVariant>
2423
25class MockUsersModel;24class UsersModel;
2625
27class AccountsService: public QObject26class AccountsService: public QObject
28{27{
@@ -165,7 +164,5 @@
165 QString m_realName;164 QString m_realName;
166 QStringList m_kbdMap;165 QStringList m_kbdMap;
167 QString m_email;166 QString m_email;
168 MockUsersModel *m_usersModel;167 UsersModel *m_usersModel;
169};168};
170
171#endif
172169
=== modified file 'tests/mocks/AccountsService/CMakeLists.txt'
--- tests/mocks/AccountsService/CMakeLists.txt 2016-12-06 20:16:56 +0000
+++ tests/mocks/AccountsService/CMakeLists.txt 2017-01-17 15:40:09 +0000
@@ -1,14 +1,13 @@
1include_directories(1include_directories(
2 ${CMAKE_CURRENT_BINARY_DIR}2 ${CMAKE_CURRENT_BINARY_DIR}
3 ${CMAKE_SOURCE_DIR}/plugins/LightDM3 ${CMAKE_SOURCE_DIR}/plugins/LightDM
4 ${CMAKE_SOURCE_DIR}/plugins/LightDM/IntegratedLightDM
4 ${CMAKE_SOURCE_DIR}/plugins/Utils5 ${CMAKE_SOURCE_DIR}/plugins/Utils
5 ${CMAKE_SOURCE_DIR}/tests/mocks/LightDM/IntegratedLightDM
6 )6 )
77
8add_library(MockAccountsService-qml MODULE8add_library(MockAccountsService-qml MODULE
9 ${CMAKE_SOURCE_DIR}/plugins/LightDM/UsersModel.cpp9 ${CMAKE_SOURCE_DIR}/plugins/LightDM/UsersModel.cpp
10 ${CMAKE_SOURCE_DIR}/plugins/Utils/unitysortfilterproxymodelqml.cpp10 ${CMAKE_SOURCE_DIR}/plugins/Utils/unitysortfilterproxymodelqml.cpp
11 ${CMAKE_SOURCE_DIR}/tests/mocks/LightDM/IntegratedLightDM/MockUsersModel.cpp
12 AccountsService.cpp11 AccountsService.cpp
13 plugin.cpp12 plugin.cpp
14 )13 )
1514
=== modified file 'tests/mocks/CMakeLists.txt'
--- tests/mocks/CMakeLists.txt 2016-12-06 20:16:56 +0000
+++ tests/mocks/CMakeLists.txt 2017-01-17 15:40:09 +0000
@@ -32,8 +32,9 @@
32add_subdirectory(Cursor)32add_subdirectory(Cursor)
33add_subdirectory(GSettings.1.0)33add_subdirectory(GSettings.1.0)
34add_subdirectory(indicator-service)34add_subdirectory(indicator-service)
35add_subdirectory(liblightdm)
35add_subdirectory(libusermetrics)36add_subdirectory(libusermetrics)
36add_subdirectory(LightDM)37add_subdirectory(LightDMController)
37add_subdirectory(Lights)38add_subdirectory(Lights)
38add_subdirectory(MeeGo)39add_subdirectory(MeeGo)
39add_subdirectory(Powerd)40add_subdirectory(Powerd)
4041
=== removed directory 'tests/mocks/LightDM'
=== removed file 'tests/mocks/LightDM/CMakeLists.txt'
--- tests/mocks/LightDM/CMakeLists.txt 2015-09-25 13:01:00 +0000
+++ tests/mocks/LightDM/CMakeLists.txt 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1add_subdirectory(IntegratedLightDM)
20
=== removed directory 'tests/mocks/LightDM/IntegratedLightDM'
=== removed file 'tests/mocks/LightDM/IntegratedLightDM/CMakeLists.txt'
--- tests/mocks/LightDM/IntegratedLightDM/CMakeLists.txt 2016-07-14 13:04:10 +0000
+++ tests/mocks/LightDM/IntegratedLightDM/CMakeLists.txt 1970-01-01 00:00:00 +0000
@@ -1,50 +0,0 @@
1# This is a copy of the normal LightDM plugin, but instead of statically
2# linking in the lightdm bits, this one uses shared libraries so we can swap
3# out different sets of users for different tests. When we finally switch to
4# actually using the system liblightdm in the normal plugin, this version can
5# be deleted.
6
7add_subdirectory(liblightdm)
8
9include_directories(
10 ${CMAKE_CURRENT_SOURCE_DIR}
11 ${CMAKE_CURRENT_BINARY_DIR}
12 ${CMAKE_SOURCE_DIR}/plugins/Utils
13 ${CMAKE_SOURCE_DIR}/plugins/LightDM
14 ${CMAKE_SOURCE_DIR}/tests/mocks/libusermetrics
15 ${libunity8-private_SOURCE_DIR}
16)
17
18set(QMLPLUGIN_SRC
19 ${CMAKE_SOURCE_DIR}/plugins/LightDM/DBusGreeter.cpp
20 ${CMAKE_SOURCE_DIR}/plugins/LightDM/DBusGreeterList.cpp
21 ${CMAKE_SOURCE_DIR}/plugins/LightDM/Greeter.cpp
22 ${CMAKE_SOURCE_DIR}/plugins/LightDM/SessionsModel.cpp
23 ${CMAKE_SOURCE_DIR}/plugins/LightDM/UsersModel.cpp
24 ${CMAKE_SOURCE_DIR}/plugins/Utils/unitysortfilterproxymodelqml.cpp
25 MockGreeter.cpp
26 MockSessionsModel.cpp
27 MockUsersModel.cpp
28 plugin.cpp
29 )
30
31add_library(MockLightDM-qml MODULE
32 ${QMLPLUGIN_SRC}
33 )
34
35# We want to link to liblightdm-qt5-3, but we don't want to depend on it being
36# installed on the system. So we make sure we link to our full fake version
37# At run time, we can point to whichever version we happen to be using via
38# LD_LIBRARY_PATH.
39target_link_libraries(MockLightDM-qml
40 MockLightDM
41 MockUserMetrics
42 unity8-private
43 )
44
45qt5_use_modules(MockLightDM-qml DBus Gui Qml)
46
47add_unity8_mock(LightDM.IntegratedLightDM 0.1 LightDM/IntegratedLightDM
48 TARGETS MockLightDM-qml
49 ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_CURRENT_BINARY_DIR}/liblightdm"
50)
510
=== removed file 'tests/mocks/LightDM/IntegratedLightDM/MockGreeter.cpp'
--- tests/mocks/LightDM/IntegratedLightDM/MockGreeter.cpp 2016-06-09 21:45:09 +0000
+++ tests/mocks/LightDM/IntegratedLightDM/MockGreeter.cpp 1970-01-01 00:00:00 +0000
@@ -1,51 +0,0 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17
18#include "MockGreeter.h"
19#include <GreeterPrivate.h>
20
21QString MockGreeter::mockMode() const
22{
23 Q_D(const Greeter);
24 return d->m_greeter->mockMode();
25}
26
27void MockGreeter::setMockMode(QString mockMode)
28{
29 Q_D(Greeter);
30
31 if (d->m_greeter->mockMode() != mockMode) {
32 d->m_greeter->setMockMode(mockMode);
33 Q_EMIT mockModeChanged(mockMode);
34 }
35}
36
37QString MockGreeter::selectUserHint() const
38{
39 Q_D(const Greeter);
40 return d->m_greeter->selectUserHint();
41}
42
43void MockGreeter::setSelectUserHint(const QString &selectUserHint)
44{
45 Q_D(Greeter);
46
47 if (d->m_greeter->selectUserHint() != selectUserHint) {
48 d->m_greeter->setSelectUserHint(selectUserHint);
49 Q_EMIT selectUserHintChanged();
50 }
51}
520
=== removed file 'tests/mocks/LightDM/IntegratedLightDM/MockGreeter.h'
--- tests/mocks/LightDM/IntegratedLightDM/MockGreeter.h 2016-06-09 21:45:09 +0000
+++ tests/mocks/LightDM/IntegratedLightDM/MockGreeter.h 1970-01-01 00:00:00 +0000
@@ -1,42 +0,0 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17
18// The real, production, Greeter
19#include <Greeter.h>
20
21#ifndef MOCK_UNITY_GREETER_H
22#define MOCK_UNITY_GREETER_H
23
24class MockGreeter : public Greeter {
25 Q_OBJECT
26
27 Q_PROPERTY(QString mockMode READ mockMode WRITE setMockMode NOTIFY mockModeChanged)
28 Q_PROPERTY(QString selectUser READ selectUserHint WRITE setSelectUserHint NOTIFY selectUserHintChanged)
29
30public:
31 QString mockMode() const;
32 void setMockMode(QString mockMode);
33
34 QString selectUserHint() const;
35 void setSelectUserHint(const QString &selectUserHint);
36
37Q_SIGNALS:
38 void mockModeChanged(QString mode);
39 void selectUserHintChanged();
40};
41
42#endif // MOCK_UNITY_GREETER_H
430
=== removed file 'tests/mocks/LightDM/IntegratedLightDM/MockSessionsModel.cpp'
--- tests/mocks/LightDM/IntegratedLightDM/MockSessionsModel.cpp 2016-07-13 20:24:24 +0000
+++ tests/mocks/LightDM/IntegratedLightDM/MockSessionsModel.cpp 1970-01-01 00:00:00 +0000
@@ -1,66 +0,0 @@
1/*
2 * Copyright (C) 2015 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17
18#include "MockSessionsModel.h"
19#include <QLightDM/SessionsModel>
20
21
22int MockSessionsModel::numSessions() const
23{
24 QLightDM::SessionsModel* qSessionsModel =
25 static_cast<QLightDM::SessionsModel*>(sourceModel());
26
27 return qSessionsModel->numSessions();
28}
29
30int MockSessionsModel::numAvailableSessions() const
31{
32 QLightDM::SessionsModel* qSessionsModel =
33 static_cast<QLightDM::SessionsModel*>(sourceModel());
34
35 return qSessionsModel->numAvailableSessions();
36}
37
38QString MockSessionsModel::testScenario() const
39{
40 QLightDM::SessionsModel* qSessionsModel =
41 static_cast<QLightDM::SessionsModel*>(sourceModel());
42
43 return qSessionsModel->testScenario();
44}
45
46void MockSessionsModel::setNumSessions(const int numSessions)
47{
48 QLightDM::SessionsModel* qSessionsModel =
49 static_cast<QLightDM::SessionsModel*>(sourceModel());
50
51 if (qSessionsModel->numSessions() != numSessions) {
52 qSessionsModel->setNumSessions(numSessions);
53 Q_EMIT numSessionsChanged();
54 }
55}
56
57void MockSessionsModel::setTestScenario(const QString testScenario)
58{
59 QLightDM::SessionsModel* qSessionsModel =
60 static_cast<QLightDM::SessionsModel*>(sourceModel());
61
62 if (qSessionsModel->testScenario() != testScenario) {
63 qSessionsModel->setTestScenario(testScenario);
64 Q_EMIT testScenarioChanged();
65 }
66}
670
=== removed file 'tests/mocks/LightDM/IntegratedLightDM/MockSessionsModel.h'
--- tests/mocks/LightDM/IntegratedLightDM/MockSessionsModel.h 2016-07-13 20:24:24 +0000
+++ tests/mocks/LightDM/IntegratedLightDM/MockSessionsModel.h 1970-01-01 00:00:00 +0000
@@ -1,44 +0,0 @@
1/*
2 * Copyright (C) 2015 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17
18#ifndef MOCK_UNITY_SESSIONSMODEL_H
19#define MOCK_UNITY_SESSIONSMODEL_H
20
21#include <SessionsModel.h>
22
23class MockSessionsModel : public SessionsModel
24{
25 Q_OBJECT
26
27 Q_PROPERTY(int numAvailableSessions READ numAvailableSessions CONSTANT)
28 Q_PROPERTY(int numSessions READ numSessions WRITE setNumSessions NOTIFY numSessionsChanged)
29 Q_PROPERTY(QString testScenario READ testScenario WRITE setTestScenario NOTIFY testScenarioChanged)
30
31public:
32 int numAvailableSessions() const;
33 int numSessions() const;
34 QString testScenario() const;
35 void setNumSessions(const int numSessions);
36 void setTestScenario(const QString testScenario);
37
38Q_SIGNALS:
39 void numSessionsChanged();
40 void testScenarioChanged();
41
42};
43
44#endif // MOCK_UNITY_SESSIONSMODEL_H
450
=== removed file 'tests/mocks/LightDM/IntegratedLightDM/MockUsersModel.cpp'
--- tests/mocks/LightDM/IntegratedLightDM/MockUsersModel.cpp 2016-08-04 14:05:54 +0000
+++ tests/mocks/LightDM/IntegratedLightDM/MockUsersModel.cpp 1970-01-01 00:00:00 +0000
@@ -1,44 +0,0 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17
18#include "MockUsersModel.h"
19#include <QLightDM/UsersModel>
20#include <QSortFilterProxyModel>
21
22MockUsersModel::MockUsersModel(QObject* parent)
23 : UsersModel(parent)
24{
25}
26
27QString MockUsersModel::mockMode() const
28{
29 QLightDM::UsersModel* qUsersModel =
30 static_cast<QLightDM::UsersModel*>(static_cast<QSortFilterProxyModel*>(sourceModel())->sourceModel());
31
32 return qUsersModel->mockMode();
33}
34
35void MockUsersModel::setMockMode(QString mockMode)
36{
37 QLightDM::UsersModel* qUsersModel =
38 static_cast<QLightDM::UsersModel*>(static_cast<QSortFilterProxyModel*>(sourceModel())->sourceModel());
39
40 if (qUsersModel->mockMode() != mockMode) {
41 qUsersModel->setMockMode(mockMode);
42 Q_EMIT mockModeChanged(mockMode);
43 }
44}
450
=== removed file 'tests/mocks/LightDM/IntegratedLightDM/MockUsersModel.h'
--- tests/mocks/LightDM/IntegratedLightDM/MockUsersModel.h 2016-08-04 14:05:54 +0000
+++ tests/mocks/LightDM/IntegratedLightDM/MockUsersModel.h 1970-01-01 00:00:00 +0000
@@ -1,39 +0,0 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17
18#ifndef MOCK_UNITY_USERSMODEL_H
19#define MOCK_UNITY_USERSMODEL_H
20
21#include <UsersModel.h>
22
23class MockUsersModel : public UsersModel
24{
25 Q_OBJECT
26
27 Q_PROPERTY(QString mockMode READ mockMode WRITE setMockMode NOTIFY mockModeChanged)
28
29public:
30 explicit MockUsersModel(QObject* parent=0);
31
32 QString mockMode() const;
33 void setMockMode(QString mockMode);
34
35Q_SIGNALS:
36 void mockModeChanged(QString mode);
37};
38
39#endif // MOCK_UNITY_USERSMODEL_H
400
=== removed directory 'tests/mocks/LightDM/IntegratedLightDM/QLightDM'
=== removed file 'tests/mocks/LightDM/IntegratedLightDM/QLightDM/Greeter'
--- tests/mocks/LightDM/IntegratedLightDM/QLightDM/Greeter 2015-01-20 11:50:19 +0000
+++ tests/mocks/LightDM/IntegratedLightDM/QLightDM/Greeter 1970-01-01 00:00:00 +0000
@@ -1,17 +0,0 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "../liblightdm/Greeter.h"
180
=== removed file 'tests/mocks/LightDM/IntegratedLightDM/QLightDM/SessionsModel'
--- tests/mocks/LightDM/IntegratedLightDM/QLightDM/SessionsModel 2015-11-18 03:52:01 +0000
+++ tests/mocks/LightDM/IntegratedLightDM/QLightDM/SessionsModel 1970-01-01 00:00:00 +0000
@@ -1,17 +0,0 @@
1/*
2 * Copyright (C) 2015 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "../liblightdm/SessionsModel.h"
180
=== removed file 'tests/mocks/LightDM/IntegratedLightDM/QLightDM/UsersModel'
--- tests/mocks/LightDM/IntegratedLightDM/QLightDM/UsersModel 2015-01-20 11:50:19 +0000
+++ tests/mocks/LightDM/IntegratedLightDM/QLightDM/UsersModel 1970-01-01 00:00:00 +0000
@@ -1,17 +0,0 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "../liblightdm/UsersModel.h"
180
=== removed file 'tests/mocks/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.cpp'
--- tests/mocks/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.cpp 2016-06-09 21:45:09 +0000
+++ tests/mocks/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.cpp 1970-01-01 00:00:00 +0000
@@ -1,132 +0,0 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "Greeter.h"
18#include "GreeterPrivate.h"
19
20namespace QLightDM
21{
22
23GreeterPrivate::GreeterPrivate(Greeter* parent)
24 : authenticated(false),
25 authenticationUser(),
26 twoFactorDone(false),
27 mockMode("single"),
28 q_ptr(parent)
29{
30 char *envMockMode = getenv("LIBLIGHTDM_MOCK_MODE");
31 if (envMockMode) {
32 mockMode = envMockMode;
33 }
34}
35
36void GreeterPrivate::handleAuthenticate()
37{
38 Q_Q(Greeter);
39
40 if (mockMode == "single") {
41 authenticated = true;
42 Q_EMIT q->authenticationComplete();
43 } else if (mockMode == "single-passphrase" || mockMode == "single-pin") {
44 Q_EMIT q->showPrompt("Password: ", Greeter::PromptTypeSecret);
45 } else if (mockMode == "full") {
46 handleAuthenticate_full();
47 }
48}
49
50void GreeterPrivate::handleAuthenticate_full()
51{
52 Q_Q(Greeter);
53
54 // Send out any messages we need to
55 if (authenticationUser == "info-prompt")
56 Q_EMIT q->showMessage("Welcome to Unity Greeter", Greeter::MessageTypeInfo);
57 else if (authenticationUser == "wide-info-prompt")
58 Q_EMIT q->showMessage("Welcome to Unity Greeter, the greeteriest greeter that ever did appear in these fine lands", Greeter::MessageTypeInfo);
59 else if (authenticationUser == "html-info-prompt")
60 Q_EMIT q->showMessage("<b>&</b>", Greeter::MessageTypeInfo);
61 else if (authenticationUser == "long-info-prompt")
62 Q_EMIT q->showMessage("Welcome to Unity Greeter\n\nWe like to annoy you with super ridiculously long messages.\nLike this one\n\nThis is the last line of a multiple line message.", Greeter::MessageTypeInfo);
63 else if (authenticationUser == "multi-info-prompt") {
64 Q_EMIT q->showMessage("Welcome to Unity Greeter", Greeter::MessageTypeInfo);
65 Q_EMIT q->showMessage("This is an error", Greeter::MessageTypeError);
66 Q_EMIT q->showMessage("You should have seen three messages", Greeter::MessageTypeInfo);
67 }
68
69 // OK, now actually do the prompt
70 if (authenticationUser == "no-password") {
71 authenticated = true;
72 Q_EMIT q->authenticationComplete();
73 } else if (authenticationUser == "has-pin"){
74 Q_EMIT q->showPrompt("Password: ", Greeter::PromptTypeSecret);
75 } else if (authenticationUser == "auth-error") {
76 authenticated = false;
77 Q_EMIT q->authenticationComplete();
78 } else if (authenticationUser == "different-prompt") {
79 Q_EMIT q->showPrompt("Secret word: ", Greeter::PromptTypeSecret);
80 } else {
81 Q_EMIT q->showPrompt("Password: ", Greeter::PromptTypeSecret);
82 }
83}
84
85void GreeterPrivate::handleRespond(QString const &response)
86{
87 Q_Q(Greeter);
88
89 if (mockMode == "single") {
90 // NOOP
91 } else if (mockMode == "single-passphrase") {
92 authenticated = (response == "password");
93 q->sendAuthenticationComplete();
94 } else if (mockMode == "single-pin") {
95 authenticated = (response == "1234");
96 q->sendAuthenticationComplete();
97 } else if (mockMode == "full") {
98 handleRespond_full(response);
99 }
100}
101
102void GreeterPrivate::handleRespond_full(const QString &response)
103{
104 Q_Q(Greeter);
105
106 if (authenticationUser == "no-response")
107 return;
108 else if (authenticationUser == "two-factor") {
109 if (!twoFactorDone) {
110 if (response == "password") {
111 twoFactorDone = true;
112 Q_EMIT q->showPrompt("otp", Greeter::PromptTypeQuestion);
113 } else {
114 authenticated = false;
115 q->sendAuthenticationComplete();
116 }
117 } else {
118 authenticated = (response == "otp");
119 q->sendAuthenticationComplete();
120 }
121 return;
122 }
123
124 if (authenticationUser == "has-pin") {
125 authenticated = (response == "1234");
126 } else {
127 authenticated = (response == "password");
128 }
129 q->sendAuthenticationComplete();
130}
131
132}
1330
=== removed file 'tests/mocks/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.h'
--- tests/mocks/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.h 2016-06-09 21:45:09 +0000
+++ tests/mocks/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.h 1970-01-01 00:00:00 +0000
@@ -1,54 +0,0 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef UNITY_MOCK_GREETER_PRIVATE_H
18#define UNITY_MOCK_GREETER_PRIVATE_H
19
20#include <QtCore/QObject>
21
22namespace QLightDM
23{
24class Greeter;
25class GreeterImpl;
26
27class GreeterPrivate
28{
29public:
30 explicit GreeterPrivate(Greeter* parent=0);
31 virtual ~GreeterPrivate() = default;
32
33 // These variables may not be used by all subclasses, that's no problem
34 bool authenticated;
35 QString authenticationUser;
36 bool twoFactorDone;
37 QString selectUserHint;
38
39 QString mockMode;
40
41 void handleAuthenticate();
42 void handleRespond(const QString &response);
43
44protected:
45 Greeter * const q_ptr;
46
47private:
48 void handleAuthenticate_full();
49 void handleRespond_full(const QString &response);
50 Q_DECLARE_PUBLIC(Greeter)
51};
52}
53
54#endif // UNITY_MOCK_GREETER_PRIVATE_H
550
=== removed file 'tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.cpp'
--- tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.cpp 2016-11-28 10:19:39 +0000
+++ tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.cpp 1970-01-01 00:00:00 +0000
@@ -1,83 +0,0 @@
1/*
2 * Copyright (C) 2015 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "SessionsModel.h"
18#include "SessionsModelPrivate.h"
19#include <QDebug>
20namespace QLightDM
21{
22
23SessionsModelPrivate::SessionsModelPrivate(SessionsModel* parent)
24 : testScenario("singleSession")
25 , q_ptr(parent)
26 , m_availableSessions(
27 {
28 {"ubuntu", "", "Ubuntu", ""},
29 {"ubuntu-2d", "", "Ubuntu 2D", ""},
30 {"gnome", "", "GNOME", ""},
31 {"gnome-classic", "", "GNOME Classic", ""},
32 {"gnome-flashback-compiz", "", "GNOME Flashback (Compiz)", ""},
33 {"gnome-flashback-metacity", "", "GNOME Flashback (Metacity)", ""},
34 {"gnome-wayland", "", "GNOME on Wayland", ""},
35 {"plasma", "", "Plasma", ""},
36 {"kde", "", "KDE" , ""},
37 {"xterm", "", "Recovery Console", ""},
38 {"", "", "Unknown?", ""}
39 })
40{
41 numSessions = numAvailableSessions();
42 resetEntries();
43}
44
45int SessionsModelPrivate::numAvailableSessions() const
46{
47 return m_availableSessions.length();
48}
49
50void SessionsModelPrivate::resetEntries()
51{
52 Q_Q(SessionsModel);
53
54 q->beginResetModel();
55 if (testScenario == "multipleSessions") {
56 resetEntries_multipleSessions(numSessions);
57 } else if (testScenario == "noSessions") {
58 resetEntries_noSessions();
59 } else {
60 resetEntries_singleSession();
61 }
62 q->endResetModel();
63}
64
65void SessionsModelPrivate::resetEntries_multipleSessions(int numSessions)
66{
67 sessionItems.clear();
68 for (int i = 0; i < numSessions; i++) {
69 sessionItems.append(m_availableSessions.value(i));
70 }
71}
72
73void SessionsModelPrivate::resetEntries_noSessions()
74{
75 sessionItems = {};
76}
77
78void SessionsModelPrivate::resetEntries_singleSession()
79{
80 sessionItems = {{"ubuntu", "", "Ubuntu", ""}};
81}
82
83} // namespace QLightDM
840
=== removed file 'tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.h'
--- tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.h 2016-07-13 20:24:24 +0000
+++ tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.h 1970-01-01 00:00:00 +0000
@@ -1,63 +0,0 @@
1/*
2 * Copyright (C) 2015 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17
18#ifndef UNITY_MOCK_SESSIONSMODEL_PRIVATE_H
19#define UNITY_MOCK_SESSIONSMODEL_PRIVATE_H
20
21#include <QtCore/QList>
22#include <QtCore/QString>
23
24namespace QLightDM
25{
26class SessionsModel;
27
28class SessionItem
29{
30public:
31 QString key;
32 QString type; // unused
33 QString name;
34 QString comment; // unused
35};
36
37class SessionsModelPrivate
38{
39public:
40 explicit SessionsModelPrivate(SessionsModel* parent=0);
41 virtual ~SessionsModelPrivate() = default;
42
43 int numAvailableSessions() const;
44
45 QList<SessionItem> sessionItems;
46 int numSessions;
47 QString testScenario;
48
49 void resetEntries();
50protected:
51 SessionsModel* const q_ptr;
52
53private:
54 const QList<SessionItem> m_availableSessions;
55 void resetEntries_multipleSessions(int numSessions);
56 void resetEntries_noSessions();
57 void resetEntries_singleSession();
58 Q_DECLARE_PUBLIC(SessionsModel)
59};
60
61} // namespace QLightDM
62
63#endif // UNITY_MOCK_SESSIONSMODEL_PRIVATE_H
640
=== removed file 'tests/mocks/LightDM/IntegratedLightDM/liblightdm/UsersModelPrivate.cpp'
--- tests/mocks/LightDM/IntegratedLightDM/liblightdm/UsersModelPrivate.cpp 2016-11-28 10:19:39 +0000
+++ tests/mocks/LightDM/IntegratedLightDM/liblightdm/UsersModelPrivate.cpp 1970-01-01 00:00:00 +0000
@@ -1,124 +0,0 @@
1/*
2 * Copyright (C) 2014-2016 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "UsersModelPrivate.h"
18#include "UsersModel.h"
19
20#include <QDir>
21
22namespace QLightDM
23{
24
25UsersModelPrivate::UsersModelPrivate(UsersModel* parent)
26 : mockMode("single")
27 , q_ptr(parent)
28{
29 char *envMockMode = getenv("LIBLIGHTDM_MOCK_MODE");
30 if (envMockMode) {
31 mockMode = envMockMode;
32 }
33 resetEntries();
34}
35
36void UsersModelPrivate::resetEntries()
37{
38 Q_Q(UsersModel);
39
40 q->beginResetModel();
41
42 if (mockMode == "single") {
43 resetEntries_single();
44 } else if (mockMode == "single-passphrase") {
45 resetEntries_singlePassphrase();
46 } else if (mockMode == "single-pin") {
47 resetEntries_singlePin();
48 } else if (mockMode == "full") {
49 resetEntries_full();
50 }
51
52 // Assign uids in a loop, just to avoid having to muck with them when
53 // adding or removing test users.
54 for (int i = 0; i < entries.size(); i++) {
55 entries[i].uid = i + 1;
56 }
57
58 // Assign backgrounds
59 QDir backgroundDir("/usr/share/backgrounds");
60 QStringList backgrounds = backgroundDir.entryList(QDir::Files);
61 if (!backgrounds.empty()) {
62 for (int i = 0; i < entries.size(); i++) {
63 if (entries[i].background.isNull()) {
64 entries[i].background = backgroundDir.filePath(backgrounds[i % backgrounds.size()]);
65 }
66 }
67 }
68
69 q->endResetModel();
70}
71
72void UsersModelPrivate::resetEntries_single()
73{
74 entries =
75 {
76 { "single", "Single User", 0, 0, false, false, "ubuntu", 0, 0 },
77 };
78}
79
80void UsersModelPrivate::resetEntries_singlePassphrase()
81{
82 entries =
83 {
84 { "single", "Single User", 0, 0, false, false, "ubuntu", 0, 0 },
85 };
86}
87
88void UsersModelPrivate::resetEntries_singlePin()
89{
90 entries =
91 {
92 { "has-pin", "Has PIN", 0, 0, false, false, "ubuntu", 0, 0 },
93 };
94}
95
96void UsersModelPrivate::resetEntries_full()
97{
98 entries =
99 {
100 { "has-password", "Has Password", 0, 0, false, false, "ubuntu", 0, 0 },
101 { "has-pin", "Has PIN", 0, 0, false, false, "ubuntu", 0, 0 },
102 { "different-prompt", "Different Prompt", 0, 0, false, false, "ubuntu", 0, 0 },
103 { "no-password", "No Password", 0, 0, false, false, "ubuntu", 0, 0 },
104 { "auth-error", "Auth Error", 0, 0, false, false, "ubuntu", 0, 0 },
105 { "two-factor", "Two Factor", 0, 0, false, false, "ubuntu", 0, 0 },
106 { "info-prompt", "Info Prompt", 0, 0, false, false, "ubuntu", 0, 0 },
107 { "html-info-prompt", "HTML Info Prompt", 0, 0, false, false, "ubuntu", 0, 0 },
108 { "long-info-prompt", "Long Info Prompt", 0, 0, false, false, "ubuntu", 0, 0 },
109 { "wide-info-prompt", "Wide Info Prompt", 0, 0, false, false, "ubuntu", 0, 0 },
110 { "multi-info-prompt", "Multi Info Prompt", 0, 0, false, false, "ubuntu", 0, 0 },
111 { "long-name", "Long name (far far too long to fit, seriously this would never fit on the screen, you will never see this part of the name)", 0, 0, false, false, "ubuntu", 0, 0 },
112 { "color-background", "Color Background", "#E95420", 0, false, false, "ubuntu", 0, 0 },
113 // white and black are a bit redundant, but useful for manually testing if UI is still readable
114 { "white-background", "White Background", "#ffffff", 0, false, false, "ubuntu", 0, 0 },
115 { "black-background", "Black Background", "#000000", 0, false, false, "ubuntu", 0, 0 },
116 { "no-background", "No Background", "", 0, false, false, "ubuntu", 0, 0 },
117 { "unicode", "가나다라마", 0, 0, false, false, "ubuntu", 0, 0 },
118 { "no-response", "No Response", 0, 0, false, false, "ubuntu", 0, 0 },
119 { "empty-name", "", 0, 0, false, false, "ubuntu", 0, 0 },
120 { "active", "Active Account", 0, 0, true, false, "ubuntu", 0, 0 },
121 };
122}
123
124} // namespace QLightDM
1250
=== removed file 'tests/mocks/LightDM/IntegratedLightDM/liblightdm/UsersModelPrivate.h'
--- tests/mocks/LightDM/IntegratedLightDM/liblightdm/UsersModelPrivate.h 2016-05-24 22:11:21 +0000
+++ tests/mocks/LightDM/IntegratedLightDM/liblightdm/UsersModelPrivate.h 1970-01-01 00:00:00 +0000
@@ -1,64 +0,0 @@
1/*
2 * Copyright (C) 2014-2016 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef UNITY_MOCK_USERSMODEL_PRIVATE_H
18#define UNITY_MOCK_USERSMODEL_PRIVATE_H
19
20#include <QtCore/QList>
21#include <QtCore/QString>
22
23namespace QLightDM
24{
25class UsersModel;
26
27class Entry
28{
29public:
30 QString username;
31 QString real_name;
32 QString background;
33 QString layouts;
34 bool is_active;
35 bool has_messages;
36 QString session;
37 QString infographic;
38 uid_t uid;
39};
40
41class UsersModelPrivate
42{
43public:
44 explicit UsersModelPrivate(UsersModel *parent = 0);
45 virtual ~UsersModelPrivate() = default;
46
47 QList<Entry> entries;
48 QString mockMode;
49
50 void resetEntries();
51protected:
52 UsersModel * const q_ptr;
53
54private:
55 void resetEntries_single();
56 void resetEntries_singlePassphrase();
57 void resetEntries_singlePin();
58 void resetEntries_full();
59 Q_DECLARE_PUBLIC(UsersModel)
60};
61
62}
63
64#endif // UNITY_MOCK_USERSMODEL_PRIVATE_H
650
=== removed file 'tests/mocks/LightDM/IntegratedLightDM/plugin.cpp'
--- tests/mocks/LightDM/IntegratedLightDM/plugin.cpp 2016-06-16 17:23:24 +0000
+++ tests/mocks/LightDM/IntegratedLightDM/plugin.cpp 1970-01-01 00:00:00 +0000
@@ -1,79 +0,0 @@
1/*
2 * Copyright (C) 2014, 2015 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "plugin.h"
18#include <DBusGreeter.h>
19#include <DBusGreeterList.h>
20#include "MockGreeter.h"
21#include "MockSessionsModel.h"
22#include "MockUsersModel.h"
23#include <QLightDM/SessionsModel>
24#include "ColorTheme.h"
25#include "UserMetrics.h"
26#include <QLightDM/UsersModel>
27
28#include <QAbstractItemModel>
29#include <QDBusConnection>
30#include <QtQml/qqml.h>
31
32static QObject *greeter_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
33{
34 Q_UNUSED(engine)
35 Q_UNUSED(scriptEngine)
36
37 MockGreeter *greeter = new MockGreeter;
38 new DBusGreeter(greeter, "/");
39 new DBusGreeterList(greeter, "/list");
40
41 return greeter;
42}
43
44static QObject *sessions_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
45{
46 Q_UNUSED(engine)
47 Q_UNUSED(scriptEngine)
48 return new MockSessionsModel;
49}
50
51static QObject *users_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
52{
53 Q_UNUSED(engine)
54 Q_UNUSED(scriptEngine)
55 return new MockUsersModel;
56}
57
58static QObject *infographic_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
59{
60 Q_UNUSED(engine)
61 Q_UNUSED(scriptEngine)
62 return UserMetricsOutput::UserMetrics::getInstance();
63}
64
65void LightDMPlugin::registerTypes(const char *uri)
66{
67 qmlRegisterType<QAbstractItemModel>();
68 qmlRegisterType<UserMetricsOutput::ColorTheme>();
69
70 Q_ASSERT(uri == QLatin1String("LightDM.IntegratedLightDM"));
71 qRegisterMetaType<QLightDM::Greeter::MessageType>("QLightDM::Greeter::MessageType");
72 qRegisterMetaType<QLightDM::Greeter::PromptType>("QLightDM::Greeter::PromptType");
73 qmlRegisterSingletonType<MockGreeter>(uri, 0, 1, "Greeter", greeter_provider);
74 qmlRegisterSingletonType<MockSessionsModel>(uri, 0, 1, "Sessions", sessions_provider);
75 qmlRegisterUncreatableType<QLightDM::SessionsModel>(uri, 0, 1, "SessionRoles", "Type is not instantiable");
76 qmlRegisterSingletonType<MockUsersModel>(uri, 0, 1, "Users", users_provider);
77 qmlRegisterUncreatableType<QLightDM::UsersModel>(uri, 0, 1, "UserRoles", "Type is not instantiable");
78 qmlRegisterSingletonType<UserMetricsOutput::UserMetrics>(uri, 0, 1, "Infographic", infographic_provider);
79}
800
=== removed file 'tests/mocks/LightDM/IntegratedLightDM/plugin.h'
--- tests/mocks/LightDM/IntegratedLightDM/plugin.h 2015-09-25 13:01:00 +0000
+++ tests/mocks/LightDM/IntegratedLightDM/plugin.h 1970-01-01 00:00:00 +0000
@@ -1,32 +0,0 @@
1/*
2 * Copyright (C) 2014, 2015 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef MOCK_LIGHTDM_PLUGIN_H
18#define MOCK_LIGHTDM_PLUGIN_H
19
20#include <QtQml/QQmlEngine>
21#include <QtQml/QQmlExtensionPlugin>
22
23class LightDMPlugin : public QQmlExtensionPlugin
24{
25 Q_OBJECT
26 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
27
28public:
29 void registerTypes(const char *uri) override;
30};
31
32#endif
330
=== removed file 'tests/mocks/LightDM/IntegratedLightDM/qmldir'
--- tests/mocks/LightDM/IntegratedLightDM/qmldir 2015-09-25 13:01:00 +0000
+++ tests/mocks/LightDM/IntegratedLightDM/qmldir 1970-01-01 00:00:00 +0000
@@ -1,2 +0,0 @@
1module LightDM.IntegratedLightDM
2plugin MockLightDM-qml
30
=== added directory 'tests/mocks/LightDMController'
=== added file 'tests/mocks/LightDMController/CMakeLists.txt'
--- tests/mocks/LightDMController/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ tests/mocks/LightDMController/CMakeLists.txt 2017-01-17 15:40:09 +0000
@@ -0,0 +1,15 @@
1add_library(LightDMController MODULE
2 plugin.cpp
3 )
4
5target_include_directories(LightDMController PUBLIC
6 ${CMAKE_SOURCE_DIR}/tests/mocks/liblightdm/
7 )
8
9target_link_libraries(LightDMController
10 MockLightDM
11 )
12
13qt5_use_modules(LightDMController Qml)
14
15add_unity8_mock(LightDMController 0.1 LightDMController TARGETS LightDMController)
016
=== added file 'tests/mocks/LightDMController/plugin.cpp'
--- tests/mocks/LightDMController/plugin.cpp 1970-01-01 00:00:00 +0000
+++ tests/mocks/LightDMController/plugin.cpp 2017-01-17 15:40:09 +0000
@@ -0,0 +1,35 @@
1/*
2 * Copyright (C) 2017 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "plugin.h"
18
19#include "MockController.h"
20
21#include <QtQml/qqml.h>
22
23static QObject *mock_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
24{
25 Q_UNUSED(scriptEngine)
26 auto controller = QLightDM::MockController::instance();
27 engine->setObjectOwnership(controller, QQmlEngine::CppOwnership);
28 return controller;
29}
30
31void LightDMControllerPlugin::registerTypes(const char *uri)
32{
33 Q_ASSERT(uri == QLatin1String("LightDMController"));
34 qmlRegisterSingletonType<QLightDM::MockController>(uri, 0, 1, "LightDMController", mock_provider);
35}
036
=== added file 'tests/mocks/LightDMController/plugin.h'
--- tests/mocks/LightDMController/plugin.h 1970-01-01 00:00:00 +0000
+++ tests/mocks/LightDMController/plugin.h 2017-01-17 15:40:09 +0000
@@ -0,0 +1,29 @@
1/*
2 * Copyright (C) 2016 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#pragma once
18
19#include <QQmlEngine>
20#include <QQmlExtensionPlugin>
21
22class LightDMControllerPlugin : public QQmlExtensionPlugin
23{
24 Q_OBJECT
25 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
26
27public:
28 void registerTypes(const char *uri) override;
29};
030
=== added file 'tests/mocks/LightDMController/qmldir'
--- tests/mocks/LightDMController/qmldir 1970-01-01 00:00:00 +0000
+++ tests/mocks/LightDMController/qmldir 2017-01-17 15:40:09 +0000
@@ -0,0 +1,2 @@
1module LightDMController
2plugin LightDMController
03
=== renamed directory 'tests/mocks/LightDM/IntegratedLightDM/liblightdm' => 'tests/mocks/liblightdm'
=== modified file 'tests/mocks/liblightdm/CMakeLists.txt'
--- tests/mocks/LightDM/IntegratedLightDM/liblightdm/CMakeLists.txt 2016-12-06 20:16:56 +0000
+++ tests/mocks/liblightdm/CMakeLists.txt 2017-01-17 15:40:09 +0000
@@ -1,21 +1,18 @@
1set(LibLightDM_SOURCES1set(MockLightDM_SOURCES
2 Greeter.cpp2 MockController.cpp
3 SessionsModel.cpp3 MockGreeter.cpp
4 UsersModel.cpp4 MockSessionsModel.cpp
5 GreeterPrivate.cpp5 MockUsersModel.cpp
6 SessionsModelPrivate.cpp
7 UsersModelPrivate.cpp
8 ${CMAKE_SOURCE_DIR}/plugins/Utils/qvariantlistmodel.cpp
9 )6 )
107
11add_library(MockLightDM SHARED ${LibLightDM_SOURCES})8add_library(MockLightDM SHARED ${MockLightDM_SOURCES})
129
13qt5_use_modules(MockLightDM Gui)10qt5_use_modules(MockLightDM DBus Gui)
1411
15set_target_properties(MockLightDM PROPERTIES12set_target_properties(MockLightDM PROPERTIES
16 OUTPUT_NAME lightdm-qt5-313 OUTPUT_NAME lightdm-qt5-3
17 SOVERSION 0)14 SOVERSION 0)
1815
19install(TARGETS MockLightDM16install(TARGETS MockLightDM
20 DESTINATION ${SHELL_INSTALL_QML}/mocks/LightDM/IntegratedLightDM/liblightdm17 DESTINATION ${SHELL_INSTALL_QML}/mocks/liblightdm
21 )18 )
2219
=== added file 'tests/mocks/liblightdm/MockController.cpp'
--- tests/mocks/liblightdm/MockController.cpp 1970-01-01 00:00:00 +0000
+++ tests/mocks/liblightdm/MockController.cpp 2017-01-17 15:40:09 +0000
@@ -0,0 +1,124 @@
1/*
2 * Copyright (C) 2016 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "MockController.h"
18
19static QLightDM::MockController *m_instance = nullptr;
20
21namespace QLightDM
22{
23
24MockController::MockController(QObject *parent)
25 : QObject(parent)
26 , m_fullSessions(
27 {
28 {"ubuntu", "Ubuntu"},
29 {"ubuntu-2d", "Ubuntu 2D"},
30 {"gnome", "GNOME"},
31 {"gnome-classic", "GNOME Classic"},
32 {"gnome-flashback-compiz", "GNOME Flashback (Compiz)"},
33 {"gnome-flashback-metacity", "GNOME Flashback (Metacity)"},
34 {"gnome-wayland", "GNOME on Wayland"},
35 {"plasma", "Plasma"},
36 {"kde", "KDE" },
37 {"xterm", "Recovery Console"},
38 {"", "Unknown?"}
39 })
40{
41 m_userMode = qgetenv("LIBLIGHTDM_MOCK_MODE");
42 if (m_userMode.isEmpty()) {
43 m_userMode = "full";
44 }
45 m_sessionMode = "full";
46 m_numSessions = numFullSessions();
47}
48
49MockController::~MockController()
50{
51 m_instance = nullptr;
52}
53
54MockController *MockController::instance()
55{
56 if (!m_instance) {
57 m_instance = new MockController;
58 }
59 return m_instance;
60}
61
62QString MockController::selectUserHint() const
63{
64 return m_selectUserHint;
65}
66
67void MockController::setSelectUserHint(const QString &selectUserHint)
68{
69 if (m_selectUserHint != selectUserHint) {
70 m_selectUserHint = selectUserHint;
71 Q_EMIT selectUserHintChanged();
72 }
73}
74
75QString MockController::userMode() const
76{
77 return m_userMode;
78}
79
80void MockController::setUserMode(const QString &userMode)
81{
82 if (m_userMode != userMode) {
83 m_userMode = userMode;
84 Q_EMIT userModeChanged();
85 }
86}
87
88QString MockController::sessionMode() const
89{
90 return m_sessionMode;
91}
92
93void MockController::setSessionMode(const QString &sessionMode)
94{
95 if (m_sessionMode != sessionMode) {
96 m_sessionMode = sessionMode;
97 Q_EMIT sessionModeChanged();
98 }
99}
100
101const QList<MockController::SessionItem> &MockController::fullSessionItems() const
102{
103 return m_fullSessions;
104}
105
106int MockController::numFullSessions() const
107{
108 return m_fullSessions.size();
109}
110
111int MockController::numSessions() const
112{
113 return m_numSessions;
114}
115
116void MockController::setNumSessions(int numSessions)
117{
118 if (m_numSessions != numSessions) {
119 m_numSessions = numSessions;
120 Q_EMIT numSessionsChanged();
121 }
122}
123
124}
0125
=== added file 'tests/mocks/liblightdm/MockController.h'
--- tests/mocks/liblightdm/MockController.h 1970-01-01 00:00:00 +0000
+++ tests/mocks/liblightdm/MockController.h 2017-01-17 15:40:09 +0000
@@ -0,0 +1,80 @@
1/*
2 * Copyright (C) 2016 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#pragma once
18
19#include <QObject>
20#include <QString>
21
22
23namespace QLightDM
24{
25class Q_DECL_EXPORT MockController : public QObject
26{
27 Q_OBJECT
28
29 Q_PROPERTY(QString selectUserHint READ selectUserHint WRITE setSelectUserHint NOTIFY selectUserHintChanged)
30
31 // single, single-pin, single-passphrase, full
32 Q_PROPERTY(QString userMode READ userMode WRITE setUserMode NOTIFY userModeChanged)
33
34 // single, none, full
35 Q_PROPERTY(QString sessionMode READ sessionMode WRITE setSessionMode NOTIFY sessionModeChanged)
36
37 Q_PROPERTY(int numAvailableSessions READ numFullSessions CONSTANT)
38 Q_PROPERTY(int numSessions READ numSessions WRITE setNumSessions NOTIFY numSessionsChanged)
39
40public:
41 static MockController *instance();
42 virtual ~MockController();
43
44 QString selectUserHint() const;
45 void setSelectUserHint(const QString &selectUserHint);
46
47 QString userMode() const;
48 void setUserMode(const QString &userMode);
49
50 QString sessionMode() const;
51 void setSessionMode(const QString &sessionMode);
52
53 class SessionItem
54 {
55 public:
56 QString key;
57 QString name;
58 };
59 int numFullSessions() const;
60 const QList<SessionItem> &fullSessionItems() const;
61
62 int numSessions() const;
63 void setNumSessions(int numSessions);
64
65Q_SIGNALS:
66 void selectUserHintChanged();
67 void userModeChanged();
68 void sessionModeChanged();
69 void numSessionsChanged();
70
71private:
72 explicit MockController(QObject* parent=0);
73
74 QString m_selectUserHint;
75 QString m_userMode;
76 QString m_sessionMode;
77 QList<SessionItem> m_fullSessions;
78 int m_numSessions;
79};
80}
081
=== renamed file 'tests/mocks/LightDM/IntegratedLightDM/liblightdm/Greeter.cpp' => 'tests/mocks/liblightdm/MockGreeter.cpp'
--- tests/mocks/LightDM/IntegratedLightDM/liblightdm/Greeter.cpp 2016-12-23 11:04:53 +0000
+++ tests/mocks/liblightdm/MockGreeter.cpp 2017-01-17 15:40:09 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2014 Canonical, Ltd.2 * Copyright (C) 2014-2016 Canonical, Ltd.
3 *3 *
4 * This program is free software; you can redistribute it and/or modify4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by5 * it under the terms of the GNU General Public License as published by
@@ -14,27 +14,38 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */15 */
1616
17#include "Greeter.h"17#include "MockController.h"
18#include "GreeterPrivate.h"18#include "MockGreeter.h"
19#include <QtCore/QCoreApplication>19#include <QDBusInterface>
20#include <QDBusPendingCall>
20#include <QTimer>21#include <QTimer>
2122
22namespace QLightDM23namespace QLightDM
23{24{
2425
26class GreeterPrivate
27{
28public:
29 bool authenticated = false;
30 QString authenticationUser;
31 bool twoFactorDone = false;
32};
33
25Greeter::Greeter(QObject *parent)34Greeter::Greeter(QObject *parent)
26 : QObject(parent),35 : QObject(parent)
27 d_ptr(new GreeterPrivate(this))36 , d_ptr(new GreeterPrivate)
28{37{
29}38}
3039
31Greeter::~Greeter()40Greeter::~Greeter()
32{41{
42 delete d_ptr;
33}43}
3444
35QString Greeter::authenticationUser() const45QString Greeter::authenticationUser() const
36{46{
37 Q_D(const Greeter);47 Q_D(const Greeter);
48
38 return d->authenticationUser;49 return d->authenticationUser;
39}50}
4051
@@ -71,14 +82,7 @@
7182
72QString Greeter::selectUserHint() const83QString Greeter::selectUserHint() const
73{84{
74 Q_D(const Greeter);85 return MockController::instance()->selectUserHint();
75 return d->selectUserHint;
76}
77
78void Greeter::setSelectUserHint(const QString &selectUserHint)
79{
80 Q_D(Greeter);
81 d->selectUserHint = selectUserHint;
82}86}
8387
84bool Greeter::selectGuestHint() const88bool Greeter::selectGuestHint() const
@@ -114,6 +118,7 @@
114bool Greeter::isAuthenticated() const118bool Greeter::isAuthenticated() const
115{119{
116 Q_D(const Greeter);120 Q_D(const Greeter);
121
117 return d->authenticated;122 return d->authenticated;
118}123}
119124
@@ -129,13 +134,42 @@
129 d->authenticated = false;134 d->authenticated = false;
130 d->authenticationUser = username;135 d->authenticationUser = username;
131 d->twoFactorDone = false;136 d->twoFactorDone = false;
132 QTimer::singleShot(0, this, &Greeter::delayedAuthentication);137 QTimer::singleShot(0, this, &Greeter::handleAuthenticate);
133}138}
134139
135void Greeter::delayedAuthentication()140void Greeter::handleAuthenticate()
136{141{
137 Q_D(Greeter);142 Q_D(Greeter);
138 d->handleAuthenticate();143
144 // Send out any messages we need to
145 if (d->authenticationUser == "info-prompt")
146 Q_EMIT showMessage("Welcome to Unity Greeter", Greeter::MessageTypeInfo);
147 else if (d->authenticationUser == "wide-info-prompt")
148 Q_EMIT showMessage("Welcome to Unity Greeter, the greeteriest greeter that ever did appear in these fine lands", Greeter::MessageTypeInfo);
149 else if (d->authenticationUser == "html-info-prompt")
150 Q_EMIT showMessage("<b>&</b>", Greeter::MessageTypeInfo);
151 else if (d->authenticationUser == "long-info-prompt")
152 Q_EMIT showMessage("Welcome to Unity Greeter\n\nWe like to annoy you with super ridiculously long messages.\nLike this one\n\nThis is the last line of a multiple line message.", Greeter::MessageTypeInfo);
153 else if (d->authenticationUser == "multi-info-prompt") {
154 Q_EMIT showMessage("Welcome to Unity Greeter", Greeter::MessageTypeInfo);
155 Q_EMIT showMessage("This is an error", Greeter::MessageTypeError);
156 Q_EMIT showMessage("You should have seen three messages", Greeter::MessageTypeInfo);
157 }
158
159 // OK, now actually do the prompt
160 if (d->authenticationUser == "no-password") {
161 d->authenticated = true;
162 Q_EMIT authenticationComplete();
163 } else if (d->authenticationUser == "has-pin"){
164 Q_EMIT showPrompt("Password: ", Greeter::PromptTypeSecret);
165 } else if (d->authenticationUser == "auth-error") {
166 d->authenticated = false;
167 Q_EMIT authenticationComplete();
168 } else if (d->authenticationUser == "different-prompt") {
169 Q_EMIT showPrompt("Secret word: ", Greeter::PromptTypeSecret);
170 } else {
171 Q_EMIT showPrompt("Password: ", Greeter::PromptTypeSecret);
172 }
139}173}
140174
141void Greeter::authenticateAsGuest()175void Greeter::authenticateAsGuest()
@@ -161,6 +195,16 @@
161bool Greeter::startSessionSync(const QString &session)195bool Greeter::startSessionSync(const QString &session)
162{196{
163 Q_UNUSED(session)197 Q_UNUSED(session)
198
199 // Send a request to hide the greeter. This is normally done by logind,
200 // but when testing, we don't want the bother of mocking that out. Instead,
201 // just send the request directly ourselves.
202 QDBusInterface iface("com.canonical.UnityGreeter",
203 "/",
204 "com.canonical.UnityGreeter",
205 QDBusConnection::sessionBus());
206 iface.asyncCall("HideGreeter");
207
164 return true;208 return true;
165}209}
166210
@@ -168,7 +212,30 @@
168{212{
169 Q_D(Greeter);213 Q_D(Greeter);
170214
171 d->handleRespond(response);215 if (d->authenticationUser == "no-response")
216 return;
217 else if (d->authenticationUser == "two-factor") {
218 if (!d->twoFactorDone) {
219 if (response == "password") {
220 d->twoFactorDone = true;
221 Q_EMIT showPrompt("otp", Greeter::PromptTypeQuestion);
222 } else {
223 d->authenticated = false;
224 sendAuthenticationComplete();
225 }
226 } else {
227 d->authenticated = (response == "otp");
228 sendAuthenticationComplete();
229 }
230 return;
231 }
232
233 if (d->authenticationUser == "has-pin") {
234 d->authenticated = (response == "1234");
235 } else {
236 d->authenticated = (response == "password");
237 }
238 sendAuthenticationComplete();
172}239}
173240
174void Greeter::sendAuthenticationComplete()241void Greeter::sendAuthenticationComplete()
@@ -181,21 +248,4 @@
181 }248 }
182}249}
183250
184QString Greeter::mockMode() const
185{
186 Q_D(const Greeter);
187 return d->mockMode;
188}
189
190
191void Greeter::setMockMode(QString mockMode)
192{
193 Q_D(Greeter);
194
195 if (d->mockMode != mockMode) {
196 d->mockMode = mockMode;
197 Q_EMIT mockModeChanged(mockMode);
198 }
199}
200
201}251}
202252
=== renamed file 'tests/mocks/LightDM/IntegratedLightDM/liblightdm/Greeter.h' => 'tests/mocks/liblightdm/MockGreeter.h'
--- tests/mocks/LightDM/IntegratedLightDM/liblightdm/Greeter.h 2016-12-23 11:04:53 +0000
+++ tests/mocks/liblightdm/MockGreeter.h 2017-01-17 15:40:09 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2013 Canonical, Ltd.2 * Copyright (C) 2013-2016 Canonical, Ltd.
3 * Copyright (C) 2010-2011 David Edmundson.3 * Copyright (C) 2010-2011 David Edmundson.
4 * Copyright (C) 2010-2011 Robert Ancell4 * Copyright (C) 2010-2011 Robert Ancell
5 *5 *
@@ -18,16 +18,14 @@
18 * Author: David Edmundson <kde@davidedmundson.co.uk>18 * Author: David Edmundson <kde@davidedmundson.co.uk>
19 */19 */
2020
21#ifndef UNITY_MOCK_GREETER_H21#pragma once
22#define UNITY_MOCK_GREETER_H22
2323#include <QObject>
24#include <QtCore/QObject>24#include <QVariant>
25#include <QtCore/QVariant>
26
2725
28namespace QLightDM26namespace QLightDM
29{27{
30 class GreeterPrivate;28class GreeterPrivate;
3129
32class Q_DECL_EXPORT Greeter : public QObject30class Q_DECL_EXPORT Greeter : public QObject
33{31{
@@ -42,9 +40,6 @@
42 Q_PROPERTY(QString hostname READ hostname CONSTANT)40 Q_PROPERTY(QString hostname READ hostname CONSTANT)
43 Q_PROPERTY(bool hasGuestAccount READ hasGuestAccountHint CONSTANT)41 Q_PROPERTY(bool hasGuestAccount READ hasGuestAccountHint CONSTANT)
4442
45 //Mock-only API for testing purposes
46 Q_PROPERTY(QString mockMode READ mockMode WRITE setMockMode NOTIFY mockModeChanged)
47
48public:43public:
49 enum PromptType {44 enum PromptType {
50 PromptTypeQuestion,45 PromptTypeQuestion,
@@ -68,7 +63,6 @@
68 bool showRemoteLoginHint() const;63 bool showRemoteLoginHint() const;
69 bool hasGuestAccountHint() const;64 bool hasGuestAccountHint() const;
70 QString selectUserHint() const;65 QString selectUserHint() const;
71 void setSelectUserHint(const QString &selectUserHint); // only in mock
72 bool selectGuestHint() const;66 bool selectGuestHint() const;
73 QString autologinUserHint() const;67 QString autologinUserHint() const;
74 bool autologinGuestHint() const;68 bool autologinGuestHint() const;
@@ -79,9 +73,6 @@
79 QString authenticationUser() const;73 QString authenticationUser() const;
80 QString hostname() const;74 QString hostname() const;
8175
82 QString mockMode() const;
83 void setMockMode(QString mockMode);
84
85public Q_SLOTS:76public Q_SLOTS:
86 bool connectSync();77 bool connectSync();
87 void authenticate(const QString &username=QString());78 void authenticate(const QString &username=QString());
@@ -98,18 +89,14 @@
98 void showPrompt(QString text, QLightDM::Greeter::PromptType type);89 void showPrompt(QString text, QLightDM::Greeter::PromptType type);
99 void authenticationComplete();90 void authenticationComplete();
100 void autologinTimerExpired();91 void autologinTimerExpired();
101 void mockModeChanged(QString mode);
102
103protected:
104 void sendAuthenticationComplete();
10592
106private Q_SLOTS:93private Q_SLOTS:
107 void delayedAuthentication();94 void handleAuthenticate();
10895
109private:96private:
97 void sendAuthenticationComplete();
98
110 GreeterPrivate *d_ptr;99 GreeterPrivate *d_ptr;
111 Q_DECLARE_PRIVATE(Greeter)100 Q_DECLARE_PRIVATE(Greeter)
112};101};
113}102}
114
115#endif // UNITY_MOCK_GREETER_H
116103
=== renamed file 'tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModel.cpp' => 'tests/mocks/liblightdm/MockSessionsModel.cpp'
--- tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModel.cpp 2016-12-23 11:04:53 +0000
+++ tests/mocks/liblightdm/MockSessionsModel.cpp 2017-01-17 15:40:09 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2015 Canonical, Ltd.2 * Copyright (C) 2015-2016 Canonical, Ltd.
3 *3 *
4 * This program is free software; you can redistribute it and/or modify4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by5 * it under the terms of the GNU General Public License as published by
@@ -21,21 +21,35 @@
21// set our compatibility to Qt4 here too.21// set our compatibility to Qt4 here too.
22#define QT_DISABLE_DEPRECATED_BEFORE QT_VERSION_CHECK(4, 0, 0)22#define QT_DISABLE_DEPRECATED_BEFORE QT_VERSION_CHECK(4, 0, 0)
2323
24#include "SessionsModel.h"24#include "MockController.h"
25#include "SessionsModelPrivate.h"25#include "MockSessionsModel.h"
26#include <QtCore/QDir>
27#include <QtCore/QString>
2826
29namespace QLightDM27namespace QLightDM
30{28{
3129
32SessionsModel::SessionsModel(QObject* parent) :30class SessionsModelPrivate
33 QAbstractListModel(parent),31{
34 d_ptr(new SessionsModelPrivate(this))32public:
35{33 QHash<int, QByteArray> roleNames;
36 m_roleNames = QAbstractListModel::roleNames();34 QList<MockController::SessionItem> sessionItems;
37 m_roleNames[KeyRole] = "key";35};
38 m_roleNames[TypeRole] = "type";36
37SessionsModel::SessionsModel(QObject* parent)
38 : QAbstractListModel(parent)
39 , d_ptr(new SessionsModelPrivate)
40{
41 Q_D(SessionsModel);
42
43 d->roleNames = QAbstractListModel::roleNames();
44 d->roleNames[KeyRole] = "key";
45 d->roleNames[TypeRole] = "type";
46 setRoleNames(d->roleNames);
47
48 connect(MockController::instance(), &MockController::sessionModeChanged,
49 this, &SessionsModel::resetEntries);
50 connect(MockController::instance(), &MockController::numSessionsChanged,
51 this, &SessionsModel::resetEntries);
52 resetEntries();
39}53}
4054
41SessionsModel::~SessionsModel()55SessionsModel::~SessionsModel()
@@ -65,7 +79,9 @@
6579
66QHash<int, QByteArray> SessionsModel::roleNames() const80QHash<int, QByteArray> SessionsModel::roleNames() const
67{81{
68 return m_roleNames;82 Q_D(const SessionsModel);
83
84 return d->roleNames;
69}85}
7086
71int SessionsModel::rowCount(const QModelIndex& parent) const87int SessionsModel::rowCount(const QModelIndex& parent) const
@@ -79,42 +95,24 @@
79 }95 }
80}96}
8197
82int SessionsModel::numSessions() const98void SessionsModel::resetEntries()
83{99{
84 Q_D(const SessionsModel);100 Q_D(SessionsModel);
85 return d->numSessions;101
86}102 beginResetModel();
87103
88int SessionsModel::numAvailableSessions() const104 QString sessionMode = MockController::instance()->sessionMode();
89{105
90 Q_D(const SessionsModel);106 if (sessionMode == "full") {
91 return d->numAvailableSessions();107 d->sessionItems = MockController::instance()->fullSessionItems();
92}108 d->sessionItems = d->sessionItems.mid(0, MockController::instance()->numSessions());
93109 } else if (sessionMode == "single") {
94QString SessionsModel::testScenario() const110 d->sessionItems = {MockController::instance()->fullSessionItems()[0]};
95{111 } else {
96 Q_D(const SessionsModel);112 d->sessionItems = {};
97 return d->testScenario;113 }
98}114
99115 endResetModel();
100void SessionsModel::setNumSessions(int numSessions)
101{
102 Q_D(SessionsModel);
103
104 if (d->numSessions != numSessions) {
105 d->numSessions = numSessions;
106 d->resetEntries();
107 }
108}
109
110void SessionsModel::setTestScenario(QString testScenario)
111{
112 Q_D(SessionsModel);
113
114 if (d->testScenario != testScenario) {
115 d->testScenario = testScenario;
116 d->resetEntries();
117 }
118}116}
119117
120} // namespace QLightDM118} // namespace QLightDM
121119
=== renamed file 'tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModel.h' => 'tests/mocks/liblightdm/MockSessionsModel.h'
--- tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModel.h 2016-12-23 11:04:53 +0000
+++ tests/mocks/liblightdm/MockSessionsModel.h 2017-01-17 15:40:09 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2015 Canonical, Ltd.2 * Copyright (C) 2015-2016 Canonical, Ltd.
3 *3 *
4 * This program is free software; you can redistribute it and/or modify4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by5 * it under the terms of the GNU General Public License as published by
@@ -15,11 +15,12 @@
15 *15 *
16 */16 */
1717
18#ifndef UNITY_MOCK_SESSIONSMODEL_H18#pragma once
19#define UNITY_MOCK_SESSIONSMODEL_H
2019
21#include <QtCore/QAbstractListModel>20#include <QAbstractListModel>
22#include <QtCore/QString>21#include <QByteArray>
22#include <QHash>
23#include <QString>
2324
24namespace QLightDM25namespace QLightDM
25{26{
@@ -30,7 +31,6 @@
30 Q_OBJECT31 Q_OBJECT
3132
32 public:33 public:
33
34 enum SessionModelRoles {34 enum SessionModelRoles {
35 //name is exposed as Qt::DisplayRole35 //name is exposed as Qt::DisplayRole
36 //comment is exposed as Qt::TooltipRole36 //comment is exposed as Qt::TooltipRole
@@ -54,19 +54,11 @@
54 int rowCount(const QModelIndex& parent) const override;54 int rowCount(const QModelIndex& parent) const override;
55 QVariant data(const QModelIndex& index, int role) const override;55 QVariant data(const QModelIndex& index, int role) const override;
5656
57 int numSessions() const;57 private Q_SLOTS:
58 int numAvailableSessions() const;58 void resetEntries();
59 QString testScenario() const;
60 void setNumSessions(int numSessions);
61 void setTestScenario(QString testScenario);
62
63 protected:
64 SessionsModelPrivate* const d_ptr;
6559
66 private:60 private:
67 QHash<int, QByteArray> m_roleNames;61 SessionsModelPrivate *d_ptr;
68 Q_DECLARE_PRIVATE(SessionsModel)62 Q_DECLARE_PRIVATE(SessionsModel)
69 };63 };
70}64}
71
72#endif // UNITY_MOCK_SESSIONSMODEL_H
7365
=== renamed file 'tests/mocks/LightDM/IntegratedLightDM/liblightdm/UsersModel.cpp' => 'tests/mocks/liblightdm/MockUsersModel.cpp'
--- tests/mocks/LightDM/IntegratedLightDM/liblightdm/UsersModel.cpp 2016-12-23 11:04:53 +0000
+++ tests/mocks/liblightdm/MockUsersModel.cpp 2017-01-17 15:40:09 +0000
@@ -21,18 +21,36 @@
21// set our compatibility to Qt4 here too.21// set our compatibility to Qt4 here too.
22#define QT_DISABLE_DEPRECATED_BEFORE QT_VERSION_CHECK(4, 0, 0)22#define QT_DISABLE_DEPRECATED_BEFORE QT_VERSION_CHECK(4, 0, 0)
2323
24#include "UsersModel.h"24#include "MockController.h"
25#include "UsersModelPrivate.h"25#include "MockUsersModel.h"
26#include <QtCore/QDir>26#include <QDir>
27#include <QtCore/QString>27#include <QIcon>
28#include <QtGui/QIcon>
2928
30namespace QLightDM29namespace QLightDM
31{30{
3231
33UsersModel::UsersModel(QObject *parent) :32class Entry
34 QAbstractListModel(parent),33{
35 d_ptr(new UsersModelPrivate(this))34public:
35 QString username;
36 QString real_name;
37 QString background;
38 QString layouts;
39 bool is_active;
40 bool has_messages;
41 QString session;
42 uid_t uid;
43};
44
45class UsersModelPrivate
46{
47public:
48 QList<Entry> entries;
49};
50
51UsersModel::UsersModel(QObject *parent)
52 : QAbstractListModel(parent)
53 , d_ptr(new UsersModelPrivate)
36{54{
37 // Extend roleNames (we want to keep the "display" role)55 // Extend roleNames (we want to keep the "display" role)
38 QHash<int, QByteArray> roles = roleNames();56 QHash<int, QByteArray> roles = roleNames();
@@ -46,6 +64,10 @@
46 roles[ImagePathRole] = "imagePath";64 roles[ImagePathRole] = "imagePath";
47 roles[UidRole] = "uid";65 roles[UidRole] = "uid";
48 setRoleNames(roles);66 setRoleNames(roles);
67
68 connect(MockController::instance(), &MockController::userModeChanged,
69 this, &UsersModel::resetEntries);
70 resetEntries();
49}71}
5072
51UsersModel::~UsersModel()73UsersModel::~UsersModel()
@@ -101,21 +123,64 @@
101 }123 }
102}124}
103125
104QString UsersModel::mockMode() const126void UsersModel::resetEntries()
105{
106 Q_D(const UsersModel);
107 return d->mockMode;
108}
109
110void UsersModel::setMockMode(QString mockMode)
111{127{
112 Q_D(UsersModel);128 Q_D(UsersModel);
113129
114 if (d->mockMode != mockMode) {130 beginResetModel();
115 d->mockMode = mockMode;131
116 Q_EMIT mockModeChanged(mockMode);132 QString userMode = MockController::instance()->userMode();
117 d->resetEntries();133
118 }134 if (userMode == "single") {
135 d->entries = {{"no-password", "No Password", "", 0, false, false, "ubuntu", 0}};
136 } else if (userMode == "single-passphrase") {
137 d->entries = {{"has-password", "Has Password", "", 0, false, false, "ubuntu", 0}};
138 } else if (userMode == "single-pin") {
139 d->entries = {{"has-pin", "Has PIN", "", 0, false, false, "ubuntu", 0}};
140 } else if (userMode == "full") {
141 d->entries = {
142 { "has-password", "Has Password", 0, 0, false, false, "ubuntu", 0 },
143 { "has-pin", "Has PIN", 0, 0, false, false, "ubuntu", 0 },
144 { "different-prompt", "Different Prompt", 0, 0, false, false, "ubuntu", 0 },
145 { "no-password", "No Password", 0, 0, false, false, "ubuntu", 0 },
146 { "auth-error", "Auth Error", 0, 0, false, false, "ubuntu", 0 },
147 { "two-factor", "Two Factor", 0, 0, false, false, "ubuntu", 0 },
148 { "info-prompt", "Info Prompt", 0, 0, false, false, "ubuntu", 0 },
149 { "html-info-prompt", "HTML Info Prompt", 0, 0, false, false, "ubuntu", 0 },
150 { "long-info-prompt", "Long Info Prompt", 0, 0, false, false, "ubuntu", 0 },
151 { "wide-info-prompt", "Wide Info Prompt", 0, 0, false, false, "ubuntu", 0 },
152 { "multi-info-prompt", "Multi Info Prompt", 0, 0, false, false, "ubuntu", 0 },
153 { "long-name", "Long name (far far too long to fit, seriously this would never fit on the screen, you will never see this part of the name)", 0, 0, false, false, "ubuntu", 0 },
154 { "color-background", "Color Background", "#E95420", 0, false, false, "ubuntu", 0 },
155 // white and black are a bit redundant, but useful for manually testing if UI is still readable
156 { "white-background", "White Background", "#ffffff", 0, false, false, "ubuntu", 0 },
157 { "black-background", "Black Background", "#000000", 0, false, false, "ubuntu", 0 },
158 { "no-background", "No Background", "", 0, false, false, "ubuntu", 0 },
159 { "unicode", "가나다라마", 0, 0, false, false, "ubuntu", 0 },
160 { "no-response", "No Response", 0, 0, false, false, "ubuntu", 0 },
161 { "empty-name", "", 0, 0, false, false, "ubuntu", 0 },
162 { "active", "Active Account", 0, 0, true, false, "ubuntu", 0 },
163 };
164 }
165
166 // Assign uids in a loop, just to avoid having to muck with them when
167 // adding or removing test users.
168 for (int i = 0; i < d->entries.size(); i++) {
169 d->entries[i].uid = i + 1;
170 }
171
172 // Assign backgrounds
173 QDir backgroundDir("/usr/share/backgrounds");
174 QStringList backgrounds = backgroundDir.entryList(QDir::Files);
175 if (!backgrounds.empty()) {
176 for (int i = 0; i < d->entries.size(); i++) {
177 if (d->entries[i].background.isNull()) {
178 d->entries[i].background = backgroundDir.filePath(backgrounds[i % backgrounds.size()]);
179 }
180 }
181 }
182
183 endResetModel();
119}184}
120185
121}186}
122187
=== renamed file 'tests/mocks/LightDM/IntegratedLightDM/liblightdm/UsersModel.h' => 'tests/mocks/liblightdm/MockUsersModel.h'
--- tests/mocks/LightDM/IntegratedLightDM/liblightdm/UsersModel.h 2016-12-23 11:04:53 +0000
+++ tests/mocks/liblightdm/MockUsersModel.h 2017-01-17 15:40:09 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2013-2014 Canonical, Ltd.2 * Copyright (C) 2013-2016 Canonical, Ltd.
3 * Copyright (C) 2010-2011 David Edmundson.3 * Copyright (C) 2010-2011 David Edmundson.
4 *4 *
5 * This program is free software; you can redistribute it and/or modify5 * This program is free software; you can redistribute it and/or modify
@@ -15,13 +15,11 @@
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */16 */
1717
18#ifndef UNITY_MOCK_USERSMODEL_H18#pragma once
19#define UNITY_MOCK_USERSMODEL_H
2019
21#include <QtCore/QString>
22#include <QtCore/QSharedDataPointer>
23#include <QAbstractListModel>20#include <QAbstractListModel>
2421#include <QList>
22#include <QString>
2523
26namespace QLightDM24namespace QLightDM
27{25{
@@ -31,12 +29,6 @@
31{29{
32 Q_OBJECT30 Q_OBJECT
3331
34 //Mock-only API for testing purposes
35 Q_PROPERTY(QString mockMode READ mockMode WRITE setMockMode NOTIFY mockModeChanged)
36
37Q_SIGNALS:
38 void mockModeChanged(QString mode);
39
40public:32public:
41 explicit UsersModel(QObject *parent = 0);33 explicit UsersModel(QObject *parent = 0);
42 virtual ~UsersModel();34 virtual ~UsersModel();
@@ -56,8 +48,8 @@
56 int rowCount(const QModelIndex &parent) const override;48 int rowCount(const QModelIndex &parent) const override;
57 QVariant data(const QModelIndex &index, int role) const override;49 QVariant data(const QModelIndex &index, int role) const override;
5850
59 QString mockMode() const;51private Q_SLOTS:
60 void setMockMode(QString mockMode);52 void resetEntries();
6153
62private:54private:
63 UsersModelPrivate * const d_ptr;55 UsersModelPrivate * const d_ptr;
@@ -65,5 +57,3 @@
65};57};
6658
67}59}
68
69#endif // UNITY_MOCK_USERSMODEL_H
7060
=== modified file 'tests/plugins/LightDM/IntegratedLightDM/CMakeLists.txt'
--- tests/plugins/LightDM/IntegratedLightDM/CMakeLists.txt 2016-12-08 20:33:21 +0000
+++ tests/plugins/LightDM/IntegratedLightDM/CMakeLists.txt 2017-01-17 15:40:09 +0000
@@ -1,6 +1,7 @@
1include_directories(1include_directories(
2 ${GLIB_INCLUDE_DIRS}2 ${GLIB_INCLUDE_DIRS}
3 ${CMAKE_CURRENT_BINARY_DIR}3 ${CMAKE_CURRENT_BINARY_DIR}
4 ${CMAKE_SOURCE_DIR}/plugins/LightDM/IntegratedLightDM
4 )5 )
56
6add_executable(GreeterDBusTestExec7add_executable(GreeterDBusTestExec
@@ -28,7 +29,7 @@
28add_unity8_uitest(GreeterDBus dbus-test-runner29add_unity8_uitest(GreeterDBus dbus-test-runner
29 ARG_PREFIX "--parameter"30 ARG_PREFIX "--parameter"
30 ARGS --task $<TARGET_FILE:GreeterDBusTestExec>31 ARGS --task $<TARGET_FILE:GreeterDBusTestExec>
31 DEPENDS MockLightDM MockLightDM-qml32 DEPENDS MockLightDM
32 )33 )
3334
34add_executable(GreeterPamTestExec35add_executable(GreeterPamTestExec
@@ -64,12 +65,12 @@
64 ${CMAKE_SOURCE_DIR}/plugins/LightDM65 ${CMAKE_SOURCE_DIR}/plugins/LightDM
65 ${CMAKE_SOURCE_DIR}/plugins/Utils66 ${CMAKE_SOURCE_DIR}/plugins/Utils
66 ${CMAKE_SOURCE_DIR}/tests/mocks/LightDM/IntegratedLightDM67 ${CMAKE_SOURCE_DIR}/tests/mocks/LightDM/IntegratedLightDM
68 ${CMAKE_SOURCE_DIR}/tests/mocks/liblightdm/
67 )69 )
68install(TARGETS GreeterSessionsModelTestExec70install(TARGETS GreeterSessionsModelTestExec
69 DESTINATION "${SHELL_PRIVATE_LIBDIR}/tests/plugins/LightDM/IntegratedLightDM"71 DESTINATION "${SHELL_PRIVATE_LIBDIR}/tests/plugins/LightDM/IntegratedLightDM"
70 )72 )
71add_unity8_uitest(GreeterSessions GreeterSessionsModelTestExec73add_unity8_uitest(GreeterSessions GreeterSessionsModelTestExec
72 ENVIRONMENT LIBLIGHTDM_MOCK_MODE=full
73 DEPENDS MockLightDM74 DEPENDS MockLightDM
74 )75 )
7576
@@ -96,7 +97,6 @@
96 DESTINATION "${SHELL_PRIVATE_LIBDIR}/tests/plugins/LightDM/IntegratedLightDM"97 DESTINATION "${SHELL_PRIVATE_LIBDIR}/tests/plugins/LightDM/IntegratedLightDM"
97 )98 )
98add_unity8_uitest(GreeterUsers GreeterUsersModelTestExec99add_unity8_uitest(GreeterUsers GreeterUsersModelTestExec
99 ENVIRONMENT LIBLIGHTDM_MOCK_MODE=full
100 DEPENDS MockLightDM100 DEPENDS MockLightDM
101 )101 )
102102
103103
=== modified file 'tests/plugins/LightDM/IntegratedLightDM/greeter.qml'
--- tests/plugins/LightDM/IntegratedLightDM/greeter.qml 2015-11-07 00:12:17 +0000
+++ tests/plugins/LightDM/IntegratedLightDM/greeter.qml 2017-01-17 15:40:09 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright 2013 Canonical Ltd.2 * Copyright 2013,2015-2016 Canonical Ltd.
3 *3 *
4 * This program is free software; you can redistribute it and/or modify4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by5 * it under the terms of the GNU General Public License as published by
@@ -15,13 +15,8 @@
15 */15 */
1616
17import QtQuick 2.417import QtQuick 2.4
18import LightDM.IntegratedLightDM 0.1 as LightDM18import LightDM.FullLightDM 0.1 as LightDM
1919
20Item {20Item {
21 property var greeter: LightDM.Greeter21 property var greeter: LightDM.Greeter
22 Binding {
23 target: LightDM.Greeter
24 property: "mockMode"
25 value: "full"
26 }
27}22}
2823
=== modified file 'tests/plugins/LightDM/IntegratedLightDM/sessionsmodel.cpp'
--- tests/plugins/LightDM/IntegratedLightDM/sessionsmodel.cpp 2016-06-15 17:11:22 +0000
+++ tests/plugins/LightDM/IntegratedLightDM/sessionsmodel.cpp 2017-01-17 15:40:09 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2015 Canonical, Ltd.2 * Copyright (C) 2015-2016 Canonical, Ltd.
3 *3 *
4 * This program is free software; you can redistribute it and/or modify4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by5 * it under the terms of the GNU General Public License as published by
@@ -16,6 +16,8 @@
1616
17#include "SessionsModel.h"17#include "SessionsModel.h"
1818
19#include "MockController.h"
20
19#include <QLightDM/SessionsModel>21#include <QLightDM/SessionsModel>
20#include <QtCore/QModelIndex>22#include <QtCore/QModelIndex>
21#include <QtTest>23#include <QtTest>
@@ -31,14 +33,14 @@
31 {33 {
32 model = new SessionsModel();34 model = new SessionsModel();
33 QVERIFY(model);35 QVERIFY(model);
34 sourceModel = new QLightDM::SessionsModel();36 mock = QLightDM::MockController::instance();
35 QVERIFY(sourceModel);37 QVERIFY(mock);
36 }38 }
3739
38 void cleanup()40 void cleanup()
39 {41 {
40 delete model;42 delete model;
41 delete sourceModel;43 // mock will be a singleton, doesn't need to be cleaned
42 }44 }
4345
44 static QModelIndex findByKey(QAbstractItemModel *model, const QString& key)46 static QModelIndex findByKey(QAbstractItemModel *model, const QString& key)
@@ -93,34 +95,34 @@
9395
94 void testMultipleSessionsCountIsCorrect()96 void testMultipleSessionsCountIsCorrect()
95 {97 {
96 sourceModel->setTestScenario("multipleSessions");98 mock->setProperty("sessionMode", "full");
97 QVERIFY(sourceModel->rowCount(QModelIndex()) > 1);99 QVERIFY(model->rowCount(QModelIndex()) > 1);
98 }100 }
99101
100 void testNoSessionsCountIsCorrect()102 void testNoSessionsCountIsCorrect()
101 {103 {
102 sourceModel->setTestScenario("noSessions");104 mock->setProperty("sessionMode", "none");
103 QVERIFY(sourceModel->rowCount(QModelIndex()) == 0);105 QVERIFY(model->rowCount(QModelIndex()) == 0);
104 }106 }
105107
106 void testSingleSessionCountIsCorrect()108 void testSingleSessionCountIsCorrect()
107 {109 {
108 sourceModel->setTestScenario("singleSession");110 mock->setProperty("sessionMode", "single");
109 QVERIFY(sourceModel->rowCount(QModelIndex()) == 1);111 QVERIFY(model->rowCount(QModelIndex()) == 1);
110 }112 }
111113
112 void testSessionNameIsCorrect()114 void testSessionNameIsCorrect()
113 {115 {
114 // This is testing the lookup, not the correctness of the strings,116 // This is testing the lookup, not the correctness of the strings,
115 // so one test should be sufficient117 // so one test should be sufficient
116 sourceModel->setTestScenario("multipleSessions");118 mock->setProperty("sessionMode", "full");
117 QVERIFY(model->data(findByKey(sourceModel, "ubuntu"),119 QVERIFY(model->data(findByKey(model, "ubuntu"),
118 Qt::DisplayRole).toString() == "Ubuntu");120 Qt::DisplayRole).toString() == "Ubuntu");
119 }121 }
120122
121private:123private:
122 SessionsModel *model;124 SessionsModel *model;
123 QLightDM::SessionsModel *sourceModel;125 QObject *mock;
124};126};
125127
126QTEST_MAIN(GreeterSessionsModelTest)128QTEST_MAIN(GreeterSessionsModelTest)
127129
=== modified file 'tests/plugins/LightDM/IntegratedLightDM/usersmodel.cpp'
--- tests/plugins/LightDM/IntegratedLightDM/usersmodel.cpp 2016-08-05 12:55:29 +0000
+++ tests/plugins/LightDM/IntegratedLightDM/usersmodel.cpp 2017-01-17 15:40:09 +0000
@@ -46,37 +46,27 @@
46 {46 {
47 model = new UsersModel();47 model = new UsersModel();
48 QVERIFY(model);48 QVERIFY(model);
49 sourceModel = new QLightDM::UsersModel();
50 QVERIFY(sourceModel);
51 }49 }
5250
53 void cleanup()51 void cleanup()
54 {52 {
55 delete model;53 delete model;
56 delete sourceModel;
57 }54 }
5855
59 void testMangleColor()56 void testMangleColor()
60 {57 {
61 QString background = getStringValue(sourceModel, "color-background", QLightDM::UsersModel::BackgroundPathRole);58 auto background = getStringValue(model, "color-background", QLightDM::UsersModel::BackgroundPathRole);
62 QVERIFY(background == "#E95420");
63
64 background = getStringValue(model, "color-background", QLightDM::UsersModel::BackgroundPathRole);
65 QVERIFY(background == "data:image/svg+xml,<svg><rect width='100%' height='100%' fill='#E95420'/></svg>");59 QVERIFY(background == "data:image/svg+xml,<svg><rect width='100%' height='100%' fill='#E95420'/></svg>");
66 }60 }
6761
68 void testMangleEmptyName()62 void testMangleEmptyName()
69 {63 {
70 QString name = getStringValue(sourceModel, "empty-name", QLightDM::UsersModel::RealNameRole);64 auto name = getStringValue(model, "empty-name", QLightDM::UsersModel::RealNameRole);
71 QVERIFY(name == "");
72
73 name = getStringValue(model, "empty-name", QLightDM::UsersModel::RealNameRole);
74 QVERIFY(name == "empty-name");65 QVERIFY(name == "empty-name");
75 }66 }
7667
77private:68private:
78 UsersModel *model;69 UsersModel *model;
79 QLightDM::UsersModel *sourceModel;
80};70};
8171
82QTEST_MAIN(GreeterUsersModelTest)72QTEST_MAIN(GreeterUsersModelTest)
8373
=== modified file 'tests/qmltests/Dash/tst_DashShell.qml'
--- tests/qmltests/Dash/tst_DashShell.qml 2016-12-14 17:43:23 +0000
+++ tests/qmltests/Dash/tst_DashShell.qml 2017-01-17 15:40:09 +0000
@@ -20,12 +20,20 @@
20import "../../../qml/"20import "../../../qml/"
21import Ubuntu.Components 1.321import Ubuntu.Components 1.3
22import Unity.Test 0.1 as UT22import Unity.Test 0.1 as UT
23import LightDMController 0.1
24import LightDM.FullLightDM 0.1 as LightDM
2325
24Item {26Item {
25 id: root27 id: root
26 width: units.gu(80)28 width: units.gu(80)
27 height: units.gu(80)29 height: units.gu(80)
2830
31 Binding {
32 target: LightDMController
33 property: "userMode"
34 value: "single"
35 }
36
29 Shell {37 Shell {
30 id: shell38 id: shell
31 width: parent.width / 239 width: parent.width / 2
3240
=== modified file 'tests/qmltests/Greeter/TestView.qml'
--- tests/qmltests/Greeter/TestView.qml 2016-08-30 14:06:47 +0000
+++ tests/qmltests/Greeter/TestView.qml 2017-01-17 15:40:09 +0000
@@ -32,6 +32,7 @@
32 property bool alphanumeric32 property bool alphanumeric
33 property var userModel33 property var userModel
34 property var infographicModel34 property var infographicModel
35 property bool waiting
35 readonly property bool fullyShown: _fullyShown36 readonly property bool fullyShown: _fullyShown
36 readonly property bool required: _required37 readonly property bool required: _required
37 readonly property bool animating: _animating38 readonly property bool animating: _animating
3839
=== modified file 'tests/qmltests/Greeter/tst_Greeter.qml'
--- tests/qmltests/Greeter/tst_Greeter.qml 2016-08-30 14:06:47 +0000
+++ tests/qmltests/Greeter/tst_Greeter.qml 2017-01-17 15:40:09 +0000
@@ -22,7 +22,8 @@
22import AccountsService 0.122import AccountsService 0.1
23import Biometryd 0.023import Biometryd 0.0
24import GSettings 1.024import GSettings 1.0
25import LightDM.IntegratedLightDM 0.1 as LightDM // This is the mock25import LightDMController 0.1
26import LightDM.FullLightDM 0.1 as LightDM
26import Unity.Test 0.1 as UT27import Unity.Test 0.1 as UT
2728
28Item {29Item {
@@ -32,9 +33,6 @@
32 property url defaultBackground: "/usr/share/backgrounds/warty-final-ubuntu.png"33 property url defaultBackground: "/usr/share/backgrounds/warty-final-ubuntu.png"
3334
34 Component.onCompleted: {35 Component.onCompleted: {
35 // set the mock mode before loading
36 LightDM.Greeter.mockMode = "full";
37 LightDM.Users.mockMode = "full";
38 loader.active = true;36 loader.active = true;
39 }37 }
4038
@@ -146,7 +144,7 @@
146144
147 function init() {145 function init() {
148 greeterSettings.lockedOutTime = 0;146 greeterSettings.lockedOutTime = 0;
149 LightDM.Greeter.selectUser = "";147 LightDMController.selectUserHint = "";
150 greeter.failedLoginsDelayAttempts = 7;148 greeter.failedLoginsDelayAttempts = 7;
151 greeter.failedLoginsDelayMinutes = 5;149 greeter.failedLoginsDelayMinutes = 5;
152 teaseSpy.clear();150 teaseSpy.clear();
@@ -570,20 +568,20 @@
570 }568 }
571569
572 function test_selectUserHint() {570 function test_selectUserHint() {
573 LightDM.Greeter.selectUser = "info-prompt";571 LightDMController.selectUserHint = "info-prompt";
574 resetLoader();572 resetLoader();
575 var i = verifySelected("info-prompt");573 var i = verifySelected("info-prompt");
576 verify(i != 0); // sanity-check that info-prompt isn't default 0 answer574 verify(i != 0); // sanity-check that info-prompt isn't default 0 answer
577 }575 }
578576
579 function test_selectUserHintUnset() {577 function test_selectUserHintUnset() {
580 LightDM.Greeter.selectUser = "";578 LightDMController.selectUserHint = "";
581 resetLoader();579 resetLoader();
582 verifySelected(LightDM.Users.data(0, LightDM.UserRoles.NameRole));580 verifySelected(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
583 }581 }
584582
585 function test_selectUserHintInvalid() {583 function test_selectUserHintInvalid() {
586 LightDM.Greeter.selectUser = "not-a-real-user";584 LightDMController.selectUserHint = "not-a-real-user";
587 resetLoader();585 resetLoader();
588 verifySelected(LightDM.Users.data(0, LightDM.UserRoles.NameRole));586 verifySelected(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
589 }587 }
590588
=== modified file 'tests/qmltests/Greeter/tst_Infographics.qml'
--- tests/qmltests/Greeter/tst_Infographics.qml 2016-10-25 08:14:40 +0000
+++ tests/qmltests/Greeter/tst_Infographics.qml 2017-01-17 15:40:09 +0000
@@ -20,19 +20,9 @@
20import "../../../qml/Greeter"20import "../../../qml/Greeter"
21import Ubuntu.Components 1.321import Ubuntu.Components 1.3
22import Unity.Test 0.1 as UT22import Unity.Test 0.1 as UT
23import LightDM.IntegratedLightDM 0.1 as LightDM23import LightDM.FullLightDM 0.1 as LightDM
2424
25Item {25Item {
26 Binding {
27 target: LightDM.Greeter
28 property: "mockMode"
29 value: "full"
30 }
31 Binding {
32 target: LightDM.Users
33 property: "mockMode"
34 value: "full"
35 }
36 property variant infographicModel: LightDM.Infographic26 property variant infographicModel: LightDM.Infographic
3727
38 width: units.gu(120)28 width: units.gu(120)
3929
=== modified file 'tests/qmltests/Greeter/tst_NarrowView.qml'
--- tests/qmltests/Greeter/tst_NarrowView.qml 2016-08-30 20:23:15 +0000
+++ tests/qmltests/Greeter/tst_NarrowView.qml 2017-01-17 15:40:09 +0000
@@ -18,7 +18,8 @@
18import QtTest 1.018import QtTest 1.0
19import ".."19import ".."
20import "../../../qml/Greeter"20import "../../../qml/Greeter"
21import LightDM.IntegratedLightDM 0.1 as LightDM21import LightDMController 0.1
22import LightDM.FullLightDM 0.1 as LightDM
22import Ubuntu.Components 1.323import Ubuntu.Components 1.3
23import Ubuntu.Telephony 0.1 as Telephony24import Ubuntu.Telephony 0.1 as Telephony
24import Unity.Test 0.1 as UT25import Unity.Test 0.1 as UT
@@ -30,6 +31,12 @@
3031
31 Component.onCompleted: theme.name = "Ubuntu.Components.Themes.SuruDark" // use the same theme as the real shell32 Component.onCompleted: theme.name = "Ubuntu.Components.Themes.SuruDark" // use the same theme as the real shell
3233
34 Binding {
35 target: LightDMController
36 property: "userMode"
37 value: "single"
38 }
39
33 Row {40 Row {
34 anchors.fill: parent41 anchors.fill: parent
35 Loader {42 Loader {
@@ -252,7 +259,7 @@
252 Binding {259 Binding {
253 target: LightDM.Infographic260 target: LightDM.Infographic
254 property: "username"261 property: "username"
255 value: "single"262 value: "has-password"
256 }263 }
257264
258 SignalSpy {265 SignalSpy {
259266
=== modified file 'tests/qmltests/Greeter/tst_WideView.qml'
--- tests/qmltests/Greeter/tst_WideView.qml 2016-08-30 14:06:47 +0000
+++ tests/qmltests/Greeter/tst_WideView.qml 2017-01-17 15:40:09 +0000
@@ -18,7 +18,8 @@
18import QtTest 1.018import QtTest 1.0
19import ".."19import ".."
20import "../../../qml/Greeter"20import "../../../qml/Greeter"
21import LightDM.IntegratedLightDM 0.1 as LightDM21import LightDMController 0.1
22import LightDM.FullLightDM 0.1 as LightDM
22import Ubuntu.Components 1.323import Ubuntu.Components 1.3
23import Unity.Test 0.1 as UT24import Unity.Test 0.1 as UT
2425
@@ -31,12 +32,6 @@
3132
32 theme.name: "Ubuntu.Components.Themes.SuruDark"33 theme.name: "Ubuntu.Components.Themes.SuruDark"
3334
34 Binding {
35 target: LightDM.Users
36 property: "mockMode"
37 value: "full"
38 }
39
40 Row {35 Row {
41 anchors.fill: parent36 anchors.fill: parent
42 Loader {37 Loader {
@@ -271,15 +266,15 @@
271 id: multipleSessionsCheckbox266 id: multipleSessionsCheckbox
272 onClicked: {267 onClicked: {
273 if (checked) {268 if (checked) {
274 LightDM.Sessions.testScenario = "multipleSessions"269 LightDMController.sessionMode = "full";
275 } else {270 } else {
276 LightDM.Sessions.testScenario = "singleSession"271 LightDMController.sessionMode = "single";
277 }272 }
278 }273 }
279 Connections {274 Connections {
280 target: LightDM.Sessions275 target: LightDMController
281 onTestScenarioChanged: {276 onSessionModeChanged: {
282 if (LightDM.Sessions.testScenario === "multipleSessions") {277 if (LightDMController.sessionMode === "full") {
283 multipleSessionsCheckbox.checked = true;278 multipleSessionsCheckbox.checked = true;
284 } else {279 } else {
285 multipleSessionsCheckbox.checked = false;280 multipleSessionsCheckbox.checked = false;
@@ -297,11 +292,11 @@
297292
298 width: units.gu(10)293 width: units.gu(10)
299 minimumValue: 0294 minimumValue: 0
300 maximumValue: LightDM.Sessions.numAvailableSessions295 maximumValue: LightDMController.numAvailableSessions
301 value: LightDM.Sessions.numSessions296 value: LightDMController.numSessions
302 visible: LightDM.Sessions.testScenario === "multipleSessions"297 visible: LightDMController.sessionMode === "full"
303 Binding {298 Binding {
304 target: LightDM.Sessions299 target: LightDMController
305 property: "numSessions"300 property: "numSessions"
306 value: numSessionsSlider.value301 value: numSessionsSlider.value
307 }302 }
@@ -368,7 +363,8 @@
368 respondedSpy.clear();363 respondedSpy.clear();
369 teaseSpy.clear();364 teaseSpy.clear();
370 emergencySpy.clear();365 emergencySpy.clear();
371 LightDM.Sessions.testScenario = "multipleSessions"366 LightDMController.sessionMode = "full";
367 LightDM.Sessions.iconSearchDirectories = [testIconDirectory];
372 }368 }
373369
374 function cleanup() {370 function cleanup() {
@@ -426,10 +422,6 @@
426 }422 }
427423
428 function test_sessionIconsAreValid() {424 function test_sessionIconsAreValid() {
429 LightDM.Sessions.testScenario = "multipleSessions"
430 var originalDirectories = LightDM.Sessions.iconSearchDirectories
431 LightDM.Sessions.iconSearchDirectories = [testIconDirectory]
432
433 selectUser("has-password");425 selectUser("has-password");
434426
435 // Test the login list icon is valid427 // Test the login list icon is valid
@@ -449,12 +441,10 @@
449441
450 function test_choosingNewSessionChangesLoginListIcon() {442 function test_choosingNewSessionChangesLoginListIcon() {
451 // Ensure the default session is selected (Ubuntu)443 // Ensure the default session is selected (Ubuntu)
452 loader.active = false;444 cleanup();
453 loader.active = true;
454445
455 selectUser("has-password");446 selectUser("has-password");
456447
457 LightDM.Sessions.testScenario = "multipleSessions";
458 var sessionChooserButton = findChild(view, "sessionChooserButton");448 var sessionChooserButton = findChild(view, "sessionChooserButton");
459 var icon = String(sessionChooserButton.icon);449 var icon = String(sessionChooserButton.icon);
460 compare(icon.indexOf("ubuntu") > -1, true);450 compare(icon.indexOf("ubuntu") > -1, true);
@@ -465,25 +455,25 @@
465 var currentDelegate = findChild(view, delegateName);455 var currentDelegate = findChild(view, delegateName);
466 var sessionKey = LightDM.Sessions.data(i,LightDM.SessionRoles.KeyRole);456 var sessionKey = LightDM.Sessions.data(i,LightDM.SessionRoles.KeyRole);
467 if (sessionKey === "gnome-classic") {457 if (sessionKey === "gnome-classic") {
458 waitForRendering(currentDelegate);
468 tap(currentDelegate);459 tap(currentDelegate);
469 var sessionChooserButton = findChild(view, "sessionChooserButton");
470 waitForRendering(sessionChooserButton);460 waitForRendering(sessionChooserButton);
471 var icon = String(sessionChooserButton.icon);
472 break;461 break;
473 }462 }
474 }463 }
475464
465 icon = String(sessionChooserButton.icon);
476 compare(icon.indexOf("gnome") > -1, true,466 compare(icon.indexOf("gnome") > -1, true,
477 "Expected icon to contain gnome but it was " + icon);467 "Expected icon to contain gnome but it was " + icon);
478 }468 }
479469
480 function test_noSessionsDoesntBreakView() {470 function test_noSessionsDoesntBreakView() {
481 LightDM.Sessions.testScenario = "noSessions"471 LightDMController.sessionMode = "none";
482 compare(LightDM.Sessions.count, 0)472 compare(LightDM.Sessions.count, 0)
483 }473 }
484474
485 function test_sessionIconNotShownWithOneSession() {475 function test_sessionIconNotShownWithOneSession() {
486 LightDM.Sessions.testScenario = "singleSession"476 LightDMController.sessionMode = "single";
487 compare(LightDM.Sessions.count, 1);477 compare(LightDM.Sessions.count, 1);
488478
489 var sessionChooserButton = findChild(view, "sessionChooserButton");479 var sessionChooserButton = findChild(view, "sessionChooserButton");
@@ -491,7 +481,7 @@
491 }481 }
492482
493 function test_sessionIconNotShownWithActiveUser() {483 function test_sessionIconNotShownWithActiveUser() {
494 LightDM.Sessions.testScenario = "multipleSessions";484 LightDMController.sessionMode = "full";
495 compare(LightDM.Sessions.count > 1, true);485 compare(LightDM.Sessions.count > 1, true);
496486
497 selectUser("active");487 selectUser("active");
@@ -501,7 +491,7 @@
501 }491 }
502492
503 function test_sessionIconShownWithMultipleSessions() {493 function test_sessionIconShownWithMultipleSessions() {
504 LightDM.Sessions.testScenario = "multipleSessions"494 LightDMController.sessionMode = "full";
505 compare(LightDM.Sessions.count > 1, true);495 compare(LightDM.Sessions.count > 1, true);
506496
507 selectUser("has-password");497 selectUser("has-password");
508498
=== modified file 'tests/qmltests/Tutorial/tst_Tutorial.qml'
--- tests/qmltests/Tutorial/tst_Tutorial.qml 2016-12-05 14:08:55 +0000
+++ tests/qmltests/Tutorial/tst_Tutorial.qml 2017-01-17 15:40:09 +0000
@@ -17,7 +17,8 @@
17import QtQuick 2.417import QtQuick 2.4
18import QtTest 1.018import QtTest 1.0
19import AccountsService 0.119import AccountsService 0.1
20import LightDM.IntegratedLightDM 0.1 as LightDM20import LightDMController 0.1
21import LightDM.FullLightDM 0.1 as LightDM
21import Ubuntu.Components 1.322import Ubuntu.Components 1.3
22import Ubuntu.Components.ListItems 1.323import Ubuntu.Components.ListItems 1.3
23import Ubuntu.Telephony 0.1 as Telephony24import Ubuntu.Telephony 0.1 as Telephony
@@ -85,8 +86,7 @@
8586
86 Component.onCompleted: {87 Component.onCompleted: {
87 // must set the mock mode before loading the Shell88 // must set the mock mode before loading the Shell
88 LightDM.Greeter.mockMode = "single-pin";89 LightDMController.userMode = "single-pin";
89 LightDM.Users.mockMode = "single-pin";
90 shellLoader.active = true;90 shellLoader.active = true;
91 }91 }
9292
9393
=== modified file 'tests/qmltests/tst_OrientedShell.qml'
--- tests/qmltests/tst_OrientedShell.qml 2016-12-12 16:45:09 +0000
+++ tests/qmltests/tst_OrientedShell.qml 2017-01-17 15:40:09 +0000
@@ -22,7 +22,8 @@
22import Ubuntu.Components.ListItems 1.3 as ListItem22import Ubuntu.Components.ListItems 1.3 as ListItem
23import Unity.Application 0.123import Unity.Application 0.1
24import Unity.Test 0.124import Unity.Test 0.1
25import LightDM.IntegratedLightDM 0.1 as LightDM25import LightDMController 0.1
26import LightDM.FullLightDM 0.1 as LightDM
26import Powerd 0.127import Powerd 0.1
27import Unity.InputInfo 0.128import Unity.InputInfo 0.1
28import Utils 0.129import Utils 0.1
@@ -38,6 +39,12 @@
38 width: units.gu(160) + controls.width39 width: units.gu(160) + controls.width
39 height: units.gu(100)40 height: units.gu(100)
4041
42 Binding {
43 target: LightDMController
44 property: "userMode"
45 value: "single"
46 }
47
41 QtObject {48 QtObject {
42 id: applicationArguments49 id: applicationArguments
43 property string deviceName: "mako"50 property string deviceName: "mako"
4451
=== modified file 'tests/qmltests/tst_Shell.qml'
--- tests/qmltests/tst_Shell.qml 2017-01-09 14:10:17 +0000
+++ tests/qmltests/tst_Shell.qml 2017-01-17 15:40:09 +0000
@@ -18,7 +18,8 @@
18import QtTest 1.018import QtTest 1.0
19import AccountsService 0.119import AccountsService 0.1
20import GSettings 1.020import GSettings 1.0
21import LightDM.IntegratedLightDM 0.1 as LightDM21import LightDMController 0.1
22import LightDM.FullLightDM 0.1 as LightDM
22import SessionBroadcast 0.123import SessionBroadcast 0.1
23import Ubuntu.Components 1.324import Ubuntu.Components 1.3
24import Ubuntu.Components.ListItems 1.3 as ListItem25import Ubuntu.Components.ListItems 1.3 as ListItem
@@ -48,8 +49,7 @@
4849
49 Component.onCompleted: {50 Component.onCompleted: {
50 // must set the mock mode before loading the Shell51 // must set the mock mode before loading the Shell
51 LightDM.Greeter.mockMode = "single";52 LightDMController.userMode = "single";
52 LightDM.Users.mockMode = "single";
53 shellLoader.active = true;53 shellLoader.active = true;
54 }54 }
5555
@@ -248,8 +248,7 @@
248 model: ["single", "single-passphrase", "single-pin", "full"]248 model: ["single", "single-passphrase", "single-pin", "full"]
249 onSelectedIndexChanged: {249 onSelectedIndexChanged: {
250 testCase.tearDown();250 testCase.tearDown();
251 LightDM.Greeter.mockMode = model[selectedIndex];251 LightDMController.userMode = model[selectedIndex];
252 LightDM.Users.mockMode = model[selectedIndex];
253 shellLoader.active = true;252 shellLoader.active = true;
254 }253 }
255 }254 }
@@ -881,8 +880,7 @@
881 }880 }
882881
883 function setLightDMMockMode(mode) {882 function setLightDMMockMode(mode) {
884 LightDM.Greeter.mockMode = mode;883 LightDMController.userMode = mode;
885 LightDM.Users.mockMode = mode;
886 }884 }
887885
888 function test_showInputMethod() {886 function test_showInputMethod() {
889887
=== modified file 'tests/qmltests/tst_ShellWithPin.qml'
--- tests/qmltests/tst_ShellWithPin.qml 2017-01-03 12:04:08 +0000
+++ tests/qmltests/tst_ShellWithPin.qml 2017-01-17 15:40:09 +0000
@@ -19,7 +19,8 @@
19import QtTest 1.019import QtTest 1.0
20import AccountsService 0.120import AccountsService 0.1
21import GSettings 1.021import GSettings 1.0
22import LightDM.IntegratedLightDM 0.1 as LightDM22import LightDMController 0.1
23import LightDM.FullLightDM 0.1 as LightDM
23import Ubuntu.SystemImage 0.124import Ubuntu.SystemImage 0.1
24import Ubuntu.Telephony 0.1 as Telephony25import Ubuntu.Telephony 0.1 as Telephony
25import Unity.Application 0.126import Unity.Application 0.1
@@ -35,8 +36,7 @@
3536
36 Component.onCompleted: {37 Component.onCompleted: {
37 // must set the mock mode before loading the Shell38 // must set the mock mode before loading the Shell
38 LightDM.Greeter.mockMode = "single-pin";39 LightDMController.userMode = "single-pin";
39 LightDM.Users.mockMode = "single-pin";
40 shellLoader.active = true;40 shellLoader.active = true;
41 }41 }
4242

Subscribers

People subscribed via source and target branches