on xenial help sign in
Add a touch more testing
9901e75Michael Terry
tests/plugins/LightDM/IntegratedLightDM/CMakeLists.txt+1−3
@@ -20,7 +20,6 @@ target_link_libraries(GreeterDBusTestExec
20 )
20 )
21target_include_directories(GreeterDBusTestExec PUBLIC
21target_include_directories(GreeterDBusTestExec PUBLIC
22 ${CMAKE_SOURCE_DIR}/plugins/LightDM
22 ${CMAKE_SOURCE_DIR}/plugins/LightDM
23− ${CMAKE_SOURCE_DIR}/tests/mocks/LightDM/IntegratedLightDM
24 )
23 )
25add_unity8_uitest(GreeterDBus dbus-test-runner
24add_unity8_uitest(GreeterDBus dbus-test-runner
26 ARG_PREFIX "--parameter"
25 ARG_PREFIX "--parameter"
@@ -57,7 +56,6 @@ target_link_libraries(GreeterSessionsModelTestExec
57target_include_directories(GreeterSessionsModelTestExec PUBLIC
56target_include_directories(GreeterSessionsModelTestExec PUBLIC
58 ${CMAKE_SOURCE_DIR}/plugins/LightDM
57 ${CMAKE_SOURCE_DIR}/plugins/LightDM
59 ${CMAKE_SOURCE_DIR}/plugins/Utils
58 ${CMAKE_SOURCE_DIR}/plugins/Utils
60− ${CMAKE_SOURCE_DIR}/tests/mocks/LightDM/IntegratedLightDM
61 ${CMAKE_SOURCE_DIR}/tests/mocks/liblightdm/
59 ${CMAKE_SOURCE_DIR}/tests/mocks/liblightdm/
62 )
60 )
63add_unity8_uitest(GreeterSessions GreeterSessionsModelTestExec
61add_unity8_uitest(GreeterSessions GreeterSessionsModelTestExec
@@ -81,7 +79,7 @@ target_link_libraries(GreeterUsersModelTestExec
81target_include_directories(GreeterUsersModelTestExec PUBLIC
79target_include_directories(GreeterUsersModelTestExec PUBLIC
82 ${CMAKE_SOURCE_DIR}/plugins/LightDM
80 ${CMAKE_SOURCE_DIR}/plugins/LightDM
83 ${CMAKE_SOURCE_DIR}/plugins/Utils
81 ${CMAKE_SOURCE_DIR}/plugins/Utils
84− ${CMAKE_SOURCE_DIR}/tests/mocks/LightDM/IntegratedLightDM
82+ ${CMAKE_SOURCE_DIR}/tests/mocks/liblightdm
85 )
83 )
86add_unity8_uitest(GreeterUsers GreeterUsersModelTestExec
84add_unity8_uitest(GreeterUsers GreeterUsersModelTestExec
87 DEPENDS MockLightDM
85 DEPENDS MockLightDM
tests/plugins/LightDM/IntegratedLightDM/usersmodel.cpp+36−4
@@ -14,6 +14,8 @@
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 */
16
16
17+#include "Greeter.h"
18+#include "MockController.h"
17#include "UsersModel.h"
19#include "UsersModel.h"
18
20
19#include <QLightDM/UsersModel>
21#include <QLightDM/UsersModel>
@@ -40,17 +42,25 @@ private:
40 return model->data(model->index(i, 0), role).toString();
42 return model->data(model->index(i, 0), role).toString();
41 }
43 }
42
44
45+ void recreateModel()
46+ {
47+ if (model) {
48+ delete model;
49+ }
50+ model = new UsersModel();
51+ QVERIFY(model);
52+ }
53+
43private Q_SLOTS:
54private Q_SLOTS:
44
55
45 void init()
56 void init()
46 {
57 {
47− model = new UsersModel();
58+ recreateModel();
48− QVERIFY(model);
49 }
59 }
50
60
51 void cleanup()
61 void cleanup()
52 {
62 {
53− delete model;
63+ QLightDM::MockController::instance()->reset();
54 }
64 }
55
65
56 void testMangleColor()
66 void testMangleColor()
@@ -65,8 +75,30 @@ private Q_SLOTS:
65 QVERIFY(name == "empty-name");
75 QVERIFY(name == "empty-name");
66 }
76 }
67
77
78+ void testHasGuest()
79+ {
80+ // sanity check that it doesn't start already present
81+ QCOMPARE(findName(model, QStringLiteral("*guest")), -1);
82+
83+ QLightDM::MockController::instance()->setHasGuestAccountHint(true);
84+ recreateModel();
85+
86+ int i = findName(model, QStringLiteral("*guest"));
87+ QVERIFY(i >= 0);
88+ QCOMPARE(i, model->count() - 1);
89+
90+ auto realName = model->data(i, QLightDM::UsersModel::RealNameRole).toString();
91+ QCOMPARE(realName, QStringLiteral("Guest Session"));
92+
93+ auto loggedIn = model->data(i, QLightDM::UsersModel::LoggedInRole).toBool();
94+ QVERIFY(!loggedIn);
95+
96+ auto session = model->data(i, QLightDM::UsersModel::SessionRole).toString();
97+ QCOMPARE(session, Greeter::instance()->defaultSessionHint());
98+ }
99+
68private:
100private:
69− UsersModel *model;
101+ UsersModel *model = nullptr;
70};
102};
71
103
72QTEST_MAIN(GreeterUsersModelTest)
104QTEST_MAIN(GreeterUsersModelTest)