on xenial help sign in
Add basic count tests
commit600971b042bc9ced1855a1cff01ad8434df2c0c2 authorJosh Arenson <joshua.arenson@canonical.com> dateThu 19 Nov 2015, 10:48 (11 years ago) parent2755f7f
2 files changed+53−9
tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.cpp+29−8 tests/qmltests/Greeter/tst_Greeter.qml+24−1
tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.cpp+29−8
@@ -16,7 +16,7 @@
1616
1717#include "SessionsModel.h"
1818#include "SessionsModelPrivate.h"
19−
19+#include <QDebug>
2020namespace QLightDM
2121{
2222
@@ -32,14 +32,35 @@ void SessionsModelPrivate::resetEntries()
3232 Q_Q(SessionsModel);
3333
3434 q->beginResetModel();
35− sessionItems =
36− {
37− {"", "", "Ubuntu", ""},
38− {"", "", "GNOME", ""},
39− {"", "", "Plasma", ""},
40− {"", "", "Unknown?", ""}
41− };
35+ if (testScenario == "multipleSessions") {
36+ resetEntries_multipleSessions();
37+ } else if (testScenario == "noSessions") {
38+ resetEntries_noSessions();
39+ } else {
40+ resetEntries_singleSession();
41+ }
4242 q->endResetModel();
4343}
4444
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+
4566} // namespace QLightDM
tests/qmltests/Greeter/tst_Greeter.qml+24−1
@@ -34,7 +34,6 @@ Item {
3434 // set the mock mode before loading
3535 LightDM.Greeter.mockMode = "full";
3636 LightDM.Users.mockMode = "full";
37− console.log("TEST SAYS testScenario is: " + LightDM.Sessions.testScenario);
3837 loader.active = true;
3938 }
4039
@@ -201,6 +200,30 @@ Item {
201200 compare(greeter.shown, false);
202201 }
203202
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+
204227 function test_unlockPass() {
205228 selectUser("has-password");
206229 tryCompare(viewShowPromptSpy, "count", 1);