on xenial help sign in
Add basic count tests
600971bJosh Arenson
tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.cpp+29−8
@@ -16,7 +16,7 @@
16
16
17#include "SessionsModel.h"
17#include "SessionsModel.h"
18#include "SessionsModelPrivate.h"
18#include "SessionsModelPrivate.h"
19−
19+#include <QDebug>
20namespace QLightDM
20namespace QLightDM
21{
21{
22
22
@@ -32,14 +32,35 @@ void SessionsModelPrivate::resetEntries()
32 Q_Q(SessionsModel);
32 Q_Q(SessionsModel);
33
33
34 q->beginResetModel();
34 q->beginResetModel();
35− sessionItems =
35+ if (testScenario == "multipleSessions") {
36− {
36+ resetEntries_multipleSessions();
37− {"", "", "Ubuntu", ""},
37+ } else if (testScenario == "noSessions") {
38− {"", "", "GNOME", ""},
38+ resetEntries_noSessions();
39− {"", "", "Plasma", ""},
39+ } else {
40− {"", "", "Unknown?", ""}
40+ resetEntries_singleSession();
41− };
41+ }
42 q->endResetModel();
42 q->endResetModel();
43}
43}
44
44
45+void SessionsModelPrivate::resetEntries_multipleSessions()
46+{
47+ sessionItems =
48+ {
49+ {"", "", "Ubuntu", ""},
50+ {"", "", "GNOME", ""},
51+ {"", "", "Plasma", ""},
52+ {"", "", "Unknown?", ""}
53+ };
54+}
55+
56+void SessionsModelPrivate::resetEntries_noSessions()
57+{
58+ sessionItems = {};
59+}
60+
61+void SessionsModelPrivate::resetEntries_singleSession()
62+{
63+ sessionItems = {{"", "", "Ubuntu", ""}};
64+}
65+
45} // namespace QLightDM
66} // namespace QLightDM
tests/qmltests/Greeter/tst_Greeter.qml+24−1
@@ -34,7 +34,6 @@ Item {
34 // set the mock mode before loading
34 // set the mock mode before loading
35 LightDM.Greeter.mockMode = "full";
35 LightDM.Greeter.mockMode = "full";
36 LightDM.Users.mockMode = "full";
36 LightDM.Users.mockMode = "full";
37− console.log("TEST SAYS testScenario is: " + LightDM.Sessions.testScenario);
38 loader.active = true;
37 loader.active = true;
39 }
38 }
40
39
@@ -201,6 +200,30 @@ Item {
201 compare(greeter.shown, false);
200 compare(greeter.shown, false);
202 }
201 }
203
202
203+ function test_multipleSessionsReportsValidCount() {
204+ LightDM.Sessions.testScenario = "multipleSessions"
205+ var sessionsCount = LightDM.Sessions.count
206+ compare(sessionsCount > 1, true,
207+ "Sessions count was reported incorrectly. It was reported as: " +
208+ sessionsCount);
209+ }
210+
211+ function test_noSessionsReportsValidCount() {
212+ LightDM.Sessions.testScenario = "noSessions"
213+ var sessionsCount = LightDM.Sessions.count
214+ compare(sessionsCount == 0, true,
215+ "Sessions count was reported incorrectly. It was reported as: " +
216+ sessionsCount);
217+ }
218+
219+ function test_singleSessionReportsValidCount() {
220+ LightDM.Sessions.testScenario = "singleSession"
221+ var sessionsCount = LightDM.Sessions.count
222+ compare(sessionsCount == 1, true,
223+ "Sessions count was reported incorrectly. It was reported as: " +
224+ sessionsCount);
225+ }
226+
204 function test_unlockPass() {
227 function test_unlockPass() {
205 selectUser("has-password");
228 selectUser("has-password");
206 tryCompare(viewShowPromptSpy, "count", 1);
229 tryCompare(viewShowPromptSpy, "count", 1);