Merge lp:~josharenson/unity8/fix-session-icon into lp:unity8

Proposed by Josh Arenson
Status: Merged
Merged at revision: 2776
Proposed branch: lp:~josharenson/unity8/fix-session-icon
Merge into: lp:unity8
Prerequisite: lp:~mterry/unity8/session-lightdm
Diff against target: 266 lines (+118/-17)
7 files modified
qml/Greeter/LoginList.qml (+1/-1)
qml/Greeter/WideView.qml (+22/-2)
tests/mocks/liblightdm/MockController.cpp (+24/-0)
tests/mocks/liblightdm/MockController.h (+15/-0)
tests/mocks/liblightdm/MockUsersModel.cpp (+37/-14)
tests/mocks/liblightdm/MockUsersModel.h (+2/-0)
tests/qmltests/Greeter/tst_WideView.qml (+17/-0)
To merge this branch: bzr merge lp:~josharenson/unity8/fix-session-icon
Reviewer Review Type Date Requested Status
Unity8 CI Bot continuous-integration Needs Fixing
Michael Terry Pending
Albert Astals Cid Pending
Review via email: mp+310381@code.launchpad.net

This proposal supersedes a proposal from 2016-10-20.

Commit message

Enable the greeter to remember which session the user last logged into

This also fixes a small issue with how the default session was handled.

Description of the change

* Are there any related MPs required for this MP to build/function as expected? Please list.
No

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

* If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
N/A

* If you changed the UI, has there been a design review?
N/A

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

PASSED: Continuous integration, rev:2659
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/2419/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/3173
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=vivid+overlay,testname=qmluitests.sh/1810
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=qmluitests.sh/1810
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=yakkety,testname=qmluitests.sh/1810
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/3201
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/3057
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/3057/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/3057
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/3057/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=yakkety/3057
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=yakkety/3057/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/3057
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/3057/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/3057
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/3057/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=yakkety/3057
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=yakkety/3057/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/3057
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/3057/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/3057
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/3057/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=yakkety/3057
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=yakkety/3057/artifact/output/*zip*/output.zip

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

review: Approve (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote : Posted in a previous version of this proposal

Tested, seems to work well.

Is this something that we can autotest?

review: Needs Information
Revision history for this message
Josh Arenson (josharenson) wrote : Posted in a previous version of this proposal

> Tested, seems to work well.
>
> Is this something that we can autotest?

There are some existing tests for the session icons. I think the level of effort to test this small issue would be very high, if even possible. The information for this field is delivered from AccountService via LightDM and thus, would likely require substantial updates to the mocks. Perhaps I'm overthinking this...

 It may be a good candidate for an autopilot test, however. If you disagree, lets discuss in person.

Revision history for this message
Albert Astals Cid (aacid) wrote : Posted in a previous version of this proposal

talked in person, agreed that Josh will evaluate how hard is to add an autotest for the Greeter in which we have two users, set the last used session of user2 to be X (non default) and then while moving to user2 we check that the selected session is the one we set.

Revision history for this message
Josh Arenson (josharenson) wrote :

Kind of gross, but I added a test.

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

FAILED: Continuous integration, rev:2583
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/2480/
Executed test runs:
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build/3269/console
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/3297
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/3151
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/3151/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/3151
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/3151/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/3151
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/3151/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/3151
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/3151/artifact/output/*zip*/output.zip
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/3151/console
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/3151
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/3151/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/3151
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/3151/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/3151
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/3151/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/3151
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/3151/artifact/output/*zip*/output.zip

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

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

Fix whitespace

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

FAILED: Continuous integration, rev:2585
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/2496/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/3289
    UNSTABLE: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=vivid+overlay,testname=qmluitests.sh/1882
    UNSTABLE: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=qmluitests.sh/1882
    UNSTABLE: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=zesty,testname=qmluitests.sh/1882
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/3317
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/3170
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/3170/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/3170
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/3170/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/3170
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/3170/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/3170
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/3170/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/3170
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/3170/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/3170
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/3170/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/3170
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/3170/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/3170
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/3170/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/3170
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/3170/artifact/output/*zip*/output.zip

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

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

FAILED: Continuous integration, rev:2585
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/2501/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/3294
    UNSTABLE: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=vivid+overlay,testname=qmluitests.sh/1887
    UNSTABLE: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=qmluitests.sh/1887
    UNSTABLE: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=zesty,testname=qmluitests.sh/1887
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/3322
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/3175
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/3175/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/3175
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/3175/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/3175
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/3175/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/3175
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/3175/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/3175
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/3175/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/3175
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/3175/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/3175
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/3175/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/3175
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/3175/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/3175
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/3175/artifact/output/*zip*/output.zip

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

review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'qml/Greeter/LoginList.qml'
--- qml/Greeter/LoginList.qml 2016-11-16 02:13:48 +0000
+++ qml/Greeter/LoginList.qml 2016-11-16 02:13:50 +0000
@@ -165,7 +165,7 @@
165 }165 }
166166
167 delegate: Item {167 delegate: Item {
168 width: parent.width168 width: userList.width
169 height: root.cellHeight169 height: root.cellHeight
170170
171 readonly property bool belowHighlight: (userList.currentIndex < 0 && index > 0) || (userList.currentIndex >= 0 && index > userList.currentIndex)171 readonly property bool belowHighlight: (userList.currentIndex < 0 && index > 0) || (userList.currentIndex >= 0 && index > userList.currentIndex)
172172
=== modified file 'qml/Greeter/WideView.qml'
--- qml/Greeter/WideView.qml 2016-11-16 02:13:48 +0000
+++ qml/Greeter/WideView.qml 2016-11-16 02:13:50 +0000
@@ -125,6 +125,8 @@
125 id: loginList125 id: loginList
126 objectName: "loginList"126 objectName: "loginList"
127127
128 property int selectedUserIndex: 0
129
128 width: units.gu(40)130 width: units.gu(40)
129 anchors {131 anchors {
130 left: parent.left132 left: parent.left
@@ -139,12 +141,30 @@
139 Behavior on boxVerticalOffset { UbuntuNumberAnimation {} }141 Behavior on boxVerticalOffset { UbuntuNumberAnimation {} }
140142
141 model: root.userModel143 model: root.userModel
142 currentSession: LightDM.Greeter.defaultSession144 currentSession: LightDM.Users.data(selectedUserIndex,
145 LightDM.UserRoles.SessionRole);
143 onResponded: root.responded(response)146 onResponded: root.responded(response)
144 onSelected: root.selected(index)147 onSelected: {
148 if (LightDM.Users.mock) {
149 LightDM.Users.mock.currentUsername = currentUser;
150 }
151
152 loginList.selectedUserIndex = index;
153 root.selected(index)
154 }
145 onSessionChooserButtonClicked: parent.state = "SessionsList"155 onSessionChooserButtonClicked: parent.state = "SessionsList"
146156
147 Keys.forwardTo: [sessionChooserLoader.item]157 Keys.forwardTo: [sessionChooserLoader.item]
158
159 // This is only for testing
160 Connections {
161 // TODO when Qt 5.7
162 //enabled: LightDM.Users.mock
163 target: LightDM.Users
164 onModelReset: {
165 loginList.currentSession = LightDM.Users.data(loginList.selectedUserIndex, LightDM.UserRoles.SessionRole);
166 }
167 }
148 }168 }
149169
150 Loader {170 Loader {
151171
=== modified file 'tests/mocks/liblightdm/MockController.cpp'
--- tests/mocks/liblightdm/MockController.cpp 2016-11-16 02:13:48 +0000
+++ tests/mocks/liblightdm/MockController.cpp 2016-11-16 02:13:50 +0000
@@ -98,6 +98,30 @@
98 }98 }
99}99}
100100
101QString MockController::sessionName() const
102{
103 return QString("INVALID - Please read directly from the UserModel");
104}
105
106void MockController::setSessionName(const QString &sessionName)
107{
108 // Let the user model deal with this
109 Q_EMIT sessionNameChanged(sessionName, m_currentUsername);
110}
111
112QString MockController::currentUsername() const
113{
114 return m_currentUsername;
115}
116
117void MockController::setCurrentUsername(const QString &username)
118{
119 if (m_currentUsername != username) {
120 m_currentUsername = username;
121 Q_EMIT currentUsernameChanged();
122 }
123}
124
101const QList<MockController::SessionItem> &MockController::fullSessionItems() const125const QList<MockController::SessionItem> &MockController::fullSessionItems() const
102{126{
103 return m_fullSessions;127 return m_fullSessions;
104128
=== modified file 'tests/mocks/liblightdm/MockController.h'
--- tests/mocks/liblightdm/MockController.h 2016-11-16 02:13:48 +0000
+++ tests/mocks/liblightdm/MockController.h 2016-11-16 02:13:50 +0000
@@ -35,6 +35,11 @@
35 // single, none, full35 // single, none, full
36 Q_PROPERTY(QString sessionMode READ sessionMode WRITE setSessionMode NOTIFY sessionModeChanged)36 Q_PROPERTY(QString sessionMode READ sessionMode WRITE setSessionMode NOTIFY sessionModeChanged)
3737
38 // This would be best as a Q_INVOKABLE, but using a property allows for
39 // keeping the mock cleaner
40 Q_PROPERTY(QString sessionName READ sessionName WRITE setSessionName NOTIFY sessionNameChanged)
41 Q_PROPERTY(QString currentUsername READ currentUsername WRITE setCurrentUsername NOTIFY currentUsernameChanged)
42
38 Q_PROPERTY(int numAvailableSessions READ numFullSessions CONSTANT)43 Q_PROPERTY(int numAvailableSessions READ numFullSessions CONSTANT)
39 Q_PROPERTY(int numSessions READ numSessions WRITE setNumSessions NOTIFY numSessionsChanged)44 Q_PROPERTY(int numSessions READ numSessions WRITE setNumSessions NOTIFY numSessionsChanged)
4045
@@ -51,6 +56,12 @@
51 QString sessionMode() const;56 QString sessionMode() const;
52 void setSessionMode(const QString &sessionMode);57 void setSessionMode(const QString &sessionMode);
5358
59 QString sessionName() const;
60 void setSessionName(const QString &sessionName);
61
62 QString currentUsername() const;
63 void setCurrentUsername(const QString &userIndex);
64
54 class SessionItem65 class SessionItem
55 {66 {
56 public:67 public:
@@ -64,14 +75,18 @@
64 void setNumSessions(int numSessions);75 void setNumSessions(int numSessions);
6576
66Q_SIGNALS:77Q_SIGNALS:
78 void currentUsernameChanged();
67 void selectUserHintChanged();79 void selectUserHintChanged();
68 void userModeChanged();80 void userModeChanged();
69 void sessionModeChanged();81 void sessionModeChanged();
82 void sessionNameChanged(const QString &sessionName, const QString &username);
70 void numSessionsChanged();83 void numSessionsChanged();
7184
72private:85private:
73 explicit MockController(QObject* parent=0);86 explicit MockController(QObject* parent=0);
7487
88 QString m_currentUsername;
89 QString m_sessionName;
75 QString m_selectUserHint;90 QString m_selectUserHint;
76 QString m_userMode;91 QString m_userMode;
77 QString m_sessionMode;92 QString m_sessionMode;
7893
=== modified file 'tests/mocks/liblightdm/MockUsersModel.cpp'
--- tests/mocks/liblightdm/MockUsersModel.cpp 2016-11-16 02:13:48 +0000
+++ tests/mocks/liblightdm/MockUsersModel.cpp 2016-11-16 02:13:50 +0000
@@ -67,6 +67,8 @@
6767
68 connect(MockController::instance(), &MockController::userModeChanged,68 connect(MockController::instance(), &MockController::userModeChanged,
69 this, &UsersModel::resetEntries);69 this, &UsersModel::resetEntries);
70 connect(MockController::instance(), &MockController::sessionNameChanged,
71 this, &UsersModel::setCurrentSessionName);
70 resetEntries();72 resetEntries();
71}73}
7274
@@ -75,6 +77,22 @@
75 delete d_ptr;77 delete d_ptr;
76}78}
7779
80void UsersModel::setCurrentSessionName(const QString &sessionName, const QString &username)
81{
82 Q_D(UsersModel);
83
84 beginResetModel();
85
86 for (auto &entry : d->entries) {
87 if (username == entry.username) {
88 entry.session = sessionName;
89 break;
90 }
91 }
92
93 endResetModel();
94}
95
78int UsersModel::rowCount(const QModelIndex &parent) const96int UsersModel::rowCount(const QModelIndex &parent) const
79{97{
80 Q_D(const UsersModel);98 Q_D(const UsersModel);
@@ -138,28 +156,33 @@
138 } else if (userMode == "single-pin") {156 } else if (userMode == "single-pin") {
139 d->entries = {{"has-pin", "Has PIN", "", 0, false, false, "ubuntu", 0}};157 d->entries = {{"has-pin", "Has PIN", "", 0, false, false, "ubuntu", 0}};
140 } else if (userMode == "full") {158 } else if (userMode == "full") {
159 /*
160 * Since the real model sorts these entries alphabetically, the model indices
161 * don't line up correctly. The easiest way to fix this is to ensure that this
162 * list of entries REMAINS IN ALPHABETICAL ORDER at all times.
163 */
141 d->entries = {164 d->entries = {
165 { "active", "Active Account", 0, 0, true, false, "ubuntu", 0 },
166 { "auth-error", "Auth Error", 0, 0, false, false, "ubuntu", 0 },
167 { "black-background", "Black Background", "#000000", 0, false, false, "ubuntu", 0 },
168 { "color-background", "Color Background", "#E95420", 0, false, false, "ubuntu", 0 },
169 { "different-prompt", "Different Prompt", 0, 0, false, false, "ubuntu", 0 },
170 { "empty-name", "", 0, 0, false, false, "ubuntu", 0 },
142 { "has-password", "Has Password", 0, 0, false, false, "ubuntu", 0 },171 { "has-password", "Has Password", 0, 0, false, false, "ubuntu", 0 },
143 { "has-pin", "Has PIN", 0, 0, false, false, "ubuntu", 0 },172 { "has-pin", "Has PIN", 0, 0, false, false, "ubuntu", 0 },
144 { "different-prompt", "Different Prompt", 0, 0, false, false, "ubuntu", 0 },173 { "html-info-prompt", "HTML Info 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 },174 { "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 },175 { "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 },176 { "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 },
152 { "multi-info-prompt", "Multi Info Prompt", 0, 0, false, false, "ubuntu", 0 },177 { "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 },178 { "no-background", "No Background", "", 0, false, false, "ubuntu", 0 },
154 { "color-background", "Color Background", "#E95420", 0, false, false, "ubuntu", 0 },179 { "no-password", "No Password", 0, 0, false, false, "ubuntu", 0 },
180 { "no-response", "No Response", 0, 0, false, false, "ubuntu", 0 },
181 { "two-factor", "Two Factor", 0, 0, false, false, "ubuntu", 0 },
182 { "unicode", "가나다라마", 0, 0, false, false, "ubuntu", 0 },
155 // white and black are a bit redundant, but useful for manually testing if UI is still readable183 // 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 },184 { "white-background", "White Background", "#ffffff", 0, false, false, "ubuntu", 0 },
157 { "black-background", "Black Background", "#000000", 0, false, false, "ubuntu", 0 },185 { "wide-info-prompt", "Wide Info Prompt", 0, 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 };186 };
164 }187 }
165188
166189
=== modified file 'tests/mocks/liblightdm/MockUsersModel.h'
--- tests/mocks/liblightdm/MockUsersModel.h 2016-11-16 02:13:48 +0000
+++ tests/mocks/liblightdm/MockUsersModel.h 2016-11-16 02:13:50 +0000
@@ -52,6 +52,8 @@
52 int rowCount(const QModelIndex &parent) const override;52 int rowCount(const QModelIndex &parent) const override;
53 QVariant data(const QModelIndex &index, int role) const override;53 QVariant data(const QModelIndex &index, int role) const override;
5454
55 void setCurrentSessionName(const QString &sessionName, const QString &username);
56
55 QObject *mock();57 QObject *mock();
5658
57private Q_SLOTS:59private Q_SLOTS:
5860
=== modified file 'tests/qmltests/Greeter/tst_WideView.qml'
--- tests/qmltests/Greeter/tst_WideView.qml 2016-11-16 02:13:48 +0000
+++ tests/qmltests/Greeter/tst_WideView.qml 2016-11-16 02:13:50 +0000
@@ -409,6 +409,23 @@
409 waitForRendering(view);409 waitForRendering(view);
410 }410 }
411411
412 function test_changingSessionSticksToUser() {
413 LightDM.Sessions.mock.sessionMode = "full";
414 var loginList = findChild(view, "loginList");
415 var fakeSessionName = "ASessionWillNeverBeCalledThis"
416
417 compare(LightDM.Sessions.count > 1, true);
418 compare(loginList.currentSession != fakeSessionName, true);
419
420 LightDM.Users.mock.sessionName = fakeSessionName;
421 tryCompare(loginList, "currentSession", fakeSessionName);
422
423 // Force a model reset
424 LightDM.Users.mock.userMode = "single";
425 LightDM.Users.mock.userMode = "full";
426
427 }
428
412 function test_tease_data() {429 function test_tease_data() {
413 return [430 return [
414 {tag: "locked", x: 0, offset: 0, count: 0, locked: true},431 {tag: "locked", x: 0, offset: 0, count: 0, locked: true},

Subscribers

People subscribed via source and target branches