on xenial help sign in
Fix up session test a bit, which also lets it pass
979cee6Michael Terry
qml/Greeter/WideView.qml+5−4
@@ -130,12 +130,13 @@ FocusScope {
130
130
131 model: root.userModel
131 model: root.userModel
132 onResponded: root.responded(response)
132 onResponded: root.responded(response)
133− onSelected: {
134− root.selected(index)
133+ onSelected: root.selected(index)
135− currentSession = LightDMService.users.data(index, LightDMService.userRoles.SessionRole);
136− }
137 onSessionChooserButtonClicked: parent.state = "SessionsList"
134 onSessionChooserButtonClicked: parent.state = "SessionsList"
138
135
136+ onCurrentIndexChanged: {
137+ currentSession = LightDMService.users.data(currentIndex, LightDMService.userRoles.SessionRole);
138+ }
139+
139 Keys.forwardTo: [sessionChooserLoader.item]
140 Keys.forwardTo: [sessionChooserLoader.item]
140 }
141 }
141
142
tests/mocks/liblightdm/MockController.cpp−24
@@ -152,30 +152,6 @@ void MockController::setUserMode(const QString &userMode)
152 }
152 }
153}
153}
154
154
155−QString MockController::sessionName() const
156−{
157− return QString("INVALID - Please read directly from the UserModel");
158−}
159−
160−void MockController::setSessionName(const QString &sessionName)
161−{
162− // Let the user model deal with this
163− Q_EMIT sessionNameChanged(sessionName, m_currentUsername);
164−}
165−
166−QString MockController::currentUsername() const
167−{
168− return m_currentUsername;
169−}
170−
171−void MockController::setCurrentUsername(const QString &username)
172−{
173− if (m_currentUsername != username) {
174− m_currentUsername = username;
175− Q_EMIT currentUsernameChanged();
176− }
177−}
178−
179QString MockController::sessionMode() const
155QString MockController::sessionMode() const
180{
156{
181 return m_sessionMode;
157 return m_sessionMode;
tests/mocks/liblightdm/MockController.h−15
@@ -38,11 +38,6 @@ class Q_DECL_EXPORT MockController : public QObject
38 // single, none, full
38 // single, none, full
39 Q_PROPERTY(QString sessionMode READ sessionMode WRITE setSessionMode NOTIFY sessionModeChanged)
39 Q_PROPERTY(QString sessionMode READ sessionMode WRITE setSessionMode NOTIFY sessionModeChanged)
40
40
41− // This would be best as a Q_INVOKABLE, but using a property allows for
42− // keeping the mock cleaner
43− Q_PROPERTY(QString sessionName READ sessionName WRITE setSessionName NOTIFY sessionNameChanged)
44− Q_PROPERTY(QString currentUsername READ currentUsername WRITE setCurrentUsername NOTIFY currentUsernameChanged)
45−
46 Q_PROPERTY(int numAvailableSessions READ numFullSessions CONSTANT)
41 Q_PROPERTY(int numAvailableSessions READ numFullSessions CONSTANT)
47 Q_PROPERTY(int numSessions READ numSessions WRITE setNumSessions NOTIFY numSessionsChanged)
42 Q_PROPERTY(int numSessions READ numSessions WRITE setNumSessions NOTIFY numSessionsChanged)
48
43
@@ -73,12 +68,6 @@ public:
73 QString sessionMode() const;
68 QString sessionMode() const;
74 void setSessionMode(const QString &sessionMode);
69 void setSessionMode(const QString &sessionMode);
75
70
76− QString sessionName() const;
77− void setSessionName(const QString &userIndex);
78−
79− QString currentUsername() const;
80− void setCurrentUsername(const QString &username);
81−
82 class SessionItem
71 class SessionItem
83 {
72 {
84 public:
73 public:
@@ -92,7 +81,6 @@ public:
92 void setNumSessions(int numSessions);
81 void setNumSessions(int numSessions);
93
82
94Q_SIGNALS:
83Q_SIGNALS:
95− void currentUsernameChanged();
96 void selectUserHintChanged();
84 void selectUserHintChanged();
97 void selectGuestHintChanged();
85 void selectGuestHintChanged();
98 void hasGuestAccountHintChanged();
86 void hasGuestAccountHintChanged();
@@ -101,13 +89,10 @@ Q_SIGNALS:
101 void userModeChanged();
89 void userModeChanged();
102 void sessionModeChanged();
90 void sessionModeChanged();
103 void numSessionsChanged();
91 void numSessionsChanged();
104− void sessionNameChanged(const QString &sessionName, const QString &username);
105
92
106private:
93private:
107 explicit MockController(QObject* parent=0);
94 explicit MockController(QObject* parent=0);
108
95
109− QString m_currentUsername;
110− QString m_sessionName;
111 QString m_selectUserHint;
96 QString m_selectUserHint;
112 bool m_selectGuestHint;
97 bool m_selectGuestHint;
113 bool m_hasGuestAccountHint;
98 bool m_hasGuestAccountHint;
tests/mocks/liblightdm/MockUsersModel.cpp+1−2
@@ -73,8 +73,6 @@ UsersModel::UsersModel(QObject *parent)
73 this, &UsersModel::resetEntries);
73 this, &UsersModel::resetEntries);
74 connect(MockController::instance(), &MockController::userModeChanged,
74 connect(MockController::instance(), &MockController::userModeChanged,
75 this, &UsersModel::resetEntries);
75 this, &UsersModel::resetEntries);
76− connect(MockController::instance(), &MockController::sessionNameChanged,
77− this, &UsersModel::setCurrentSessionName);
78 resetEntries();
76 resetEntries();
79}
77}
80
78
@@ -180,6 +178,7 @@ void UsersModel::resetEntries()
180 { "info-after-login", "Info After Login", 0, 0, false, false, "ubuntu", 0 },
178 { "info-after-login", "Info After Login", 0, 0, false, false, "ubuntu", 0 },
181 { "info-prompt", "Info Prompt", 0, 0, false, false, "ubuntu", 0 },
179 { "info-prompt", "Info Prompt", 0, 0, false, false, "ubuntu", 0 },
182 { "wacky-prompts", "Interspersed Prompts", 0, 0, false, false, "ubuntu", 0 },
180 { "wacky-prompts", "Interspersed Prompts", 0, 0, false, false, "ubuntu", 0 },
181+ { "invalid-session", "Invalid Session", 0, 0, false, false, "invalid", 0 },
183 { "locked", "Locked", 0, 0, false, false, "ubuntu", 0 },
182 { "locked", "Locked", 0, 0, false, false, "ubuntu", 0 },
184 { "long-info-prompt", "Long Info Prompt", 0, 0, false, false, "ubuntu", 0 },
183 { "long-info-prompt", "Long Info Prompt", 0, 0, false, false, "ubuntu", 0 },
185 { "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 },
184 { "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 },
tests/qmltests/Greeter/tst_WideView.qml+7−31
@@ -336,7 +336,7 @@ StyledItem {
336 respondedSpy.clear();
336 respondedSpy.clear();
337 teaseSpy.clear();
337 teaseSpy.clear();
338 emergencySpy.clear();
338 emergencySpy.clear();
339− LightDMController.sessionMode = "full";
339+ LightDMController.reset();
340 LightDM.Sessions.iconSearchDirectories = [testIconDirectory];
340 LightDM.Sessions.iconSearchDirectories = [testIconDirectory];
341 }
341 }
342
342
@@ -394,34 +394,16 @@ StyledItem {
394 }
394 }
395
395
396 function test_changingSessionSticksToUser() {
396 function test_changingSessionSticksToUser() {
397− LightDMController.sessionMode = "full";
398−
399 var loginList = findChild(view, "loginList");
397 var loginList = findChild(view, "loginList");
400− var fakeSession1 = "ASessionWillNeverBeCalledThis";
401− var fakeSession2 = "ASessionWillAlsoNeverBeCalledThis";
402−
403− // For this test to work, a user has to be selected and the
404− // mock must be made aware of that user
405− selectUser("has-password")
406− LightDMController.currentUsername = "has-password"
407− compare(LightDM.Sessions.count > 1, true);
408− compare(loginList.currentSession != fakeSession1, true);
409− LightDMController.sessionName = fakeSession1;
410−
411− selectUser("has-pin")
412− LightDMController.currentUsername = "has-pin"
413− compare(loginList.currentSession != fakeSession2, true);
414− LightDMController.sessionName = fakeSession2;
415
398
416− selectUser("has-password")
399+ selectUser("invalid-session");
417− tryCompare(loginList, "currentSession", fakeSession1);
400+ tryCompare(loginList, "currentSession", "invalid");
418
401
419− selectUser("has-pin")
402+ selectUser("has-password");
420− tryCompare(loginList, "currentSession", fakeSession2);
403+ tryCompare(loginList, "currentSession", "ubuntu");
421
404
422− // Force a model reset
405+ selectUser("invalid-session")
423− LightDMController.userMode = "single";
406+ tryCompare(loginList, "currentSession", "invalid");
424− LightDMController.userMode = "full";
425 }
407 }
426
408
427 function test_tease_data() {
409 function test_tease_data() {
@@ -494,9 +476,6 @@ StyledItem {
494 }
476 }
495
477
496 function test_sessionIconNotShownWithActiveUser() {
478 function test_sessionIconNotShownWithActiveUser() {
497− LightDMController.sessionMode = "full";
498− compare(LightDM.Sessions.count > 1, true);
499−
500 selectUser("active");
479 selectUser("active");
501
480
502 var sessionChooserButton = findChild(view, "sessionChooserButton");
481 var sessionChooserButton = findChild(view, "sessionChooserButton");
@@ -504,9 +483,6 @@ StyledItem {
504 }
483 }
505
484
506 function test_sessionIconShownWithMultipleSessions() {
485 function test_sessionIconShownWithMultipleSessions() {
507− LightDMController.sessionMode = "full";
508− compare(LightDM.Sessions.count > 1, true);
509−
510 selectUser("has-password");
486 selectUser("has-password");
511
487
512 var sessionChooserButton = findChild(view, "sessionChooserButton");
488 var sessionChooserButton = findChild(view, "sessionChooserButton");