on xenial help sign in
Add a touch more testing
commit9901e754dd56d0e897b35c0d0e786ba77a866e25 authorMichael Terry <mike@mterry.name> dateWed 11 Jan 2017, 09:32 (10 years ago) parentf01ede6
2 files changed+37−7
tests/plugins/LightDM/IntegratedLightDM/CMakeLists.txt+1−3 tests/plugins/LightDM/IntegratedLightDM/usersmodel.cpp+36−4
tests/plugins/LightDM/IntegratedLightDM/CMakeLists.txt+1−3
@@ -20,7 +20,6 @@ target_link_libraries(GreeterDBusTestExec
2020 )
2121target_include_directories(GreeterDBusTestExec PUBLIC
2222 ${CMAKE_SOURCE_DIR}/plugins/LightDM
23− ${CMAKE_SOURCE_DIR}/tests/mocks/LightDM/IntegratedLightDM
2423 )
2524add_unity8_uitest(GreeterDBus dbus-test-runner
2625 ARG_PREFIX "--parameter"
@@ -57,7 +56,6 @@ target_link_libraries(GreeterSessionsModelTestExec
5756target_include_directories(GreeterSessionsModelTestExec PUBLIC
5857 ${CMAKE_SOURCE_DIR}/plugins/LightDM
5958 ${CMAKE_SOURCE_DIR}/plugins/Utils
60− ${CMAKE_SOURCE_DIR}/tests/mocks/LightDM/IntegratedLightDM
6159 ${CMAKE_SOURCE_DIR}/tests/mocks/liblightdm/
6260 )
6361add_unity8_uitest(GreeterSessions GreeterSessionsModelTestExec
@@ -81,7 +79,7 @@ target_link_libraries(GreeterUsersModelTestExec
8179target_include_directories(GreeterUsersModelTestExec PUBLIC
8280 ${CMAKE_SOURCE_DIR}/plugins/LightDM
8381 ${CMAKE_SOURCE_DIR}/plugins/Utils
84− ${CMAKE_SOURCE_DIR}/tests/mocks/LightDM/IntegratedLightDM
82+ ${CMAKE_SOURCE_DIR}/tests/mocks/liblightdm
8583 )
8684add_unity8_uitest(GreeterUsers GreeterUsersModelTestExec
8785 DEPENDS MockLightDM
tests/plugins/LightDM/IntegratedLightDM/usersmodel.cpp+36−4
@@ -14,6 +14,8 @@
1414 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1515 */
1616
17+#include "Greeter.h"
18+#include "MockController.h"
1719#include "UsersModel.h"
1820
1921#include <QLightDM/UsersModel>
@@ -40,17 +42,25 @@ private:
4042 return model->data(model->index(i, 0), role).toString();
4143 }
4244
45+ void recreateModel()
46+ {
47+ if (model) {
48+ delete model;
49+ }
50+ model = new UsersModel();
51+ QVERIFY(model);
52+ }
53+
4354private Q_SLOTS:
4455
4556 void init()
4657 {
47− model = new UsersModel();
48− QVERIFY(model);
58+ recreateModel();
4959 }
5060
5161 void cleanup()
5262 {
53− delete model;
63+ QLightDM::MockController::instance()->reset();
5464 }
5565
5666 void testMangleColor()
@@ -65,8 +75,30 @@ private Q_SLOTS:
6575 QVERIFY(name == "empty-name");
6676 }
6777
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+
68100private:
69− UsersModel *model;
101+ UsersModel *model = nullptr;
70102};
71103
72104QTEST_MAIN(GreeterUsersModelTest)