on xenial help sign in
Unify the name of the Greeter DBus test, make it use our standard binary test macro (which also nicely exports xml results), and make the test a little more robust against timing issues.

Approved by: PS Jenkins bot, Albert Astals Cid

commitcb1ecc1c3962b8ca9ab5f447a40766242d542f07 authorMichael Terry <michael.terry@canonical.com> dateFri 9 Jan 2015, 10:42 (12 years ago) parent61879c53bec098
3 files changed+14−9
cmake/modules/QmlTest.cmake+3 tests/plugins/LightDM/CMakeLists.txt+4−8 tests/plugins/LightDM/dbus.cpp+7−1
cmake/modules/QmlTest.cmake+3
@@ -153,7 +153,9 @@ endmacro(add_qml_test_internal)
153153
154154macro(add_binary_qml_test CLASS_NAME LD_PATH DEPS ENVVAR)
155155 set(testCommand
156+ ${ENVVAR}
156157 LD_LIBRARY_PATH=${LD_PATH}
158+ dbus-launch
157159 ${CMAKE_CURRENT_BINARY_DIR}/${CLASS_NAME}TestExec
158160 -o ${CMAKE_BINARY_DIR}/test${CLASS_NAME}.xml,xunitxml
159161 -o -,txt)
@@ -171,6 +173,7 @@ macro(add_binary_qml_test CLASS_NAME LD_PATH DEPS ENVVAR)
171173 ${ENVVAR}
172174 LD_LIBRARY_PATH=${LD_PATH}
173175 xvfb-run --server-args "-screen 0 1024x768x24" --auto-servernum
176+ dbus-launch
174177 ${CMAKE_CURRENT_BINARY_DIR}/${CLASS_NAME}TestExec
175178 -o ${CMAKE_BINARY_DIR}/test${CLASS_NAME}.xml,xunitxml
176179 -o -,txt)
tests/plugins/LightDM/CMakeLists.txt+4−8
@@ -1,8 +1,8 @@
1−add_executable(test-lightdm-dbus
1+add_executable(GreeterDBusTestExec
22 dbus.cpp
33 ${CMAKE_SOURCE_DIR}/plugins/LightDM/Greeter.cpp
44 )
5−qt5_use_modules(test-lightdm-dbus Core DBus Quick Test)
5+qt5_use_modules(GreeterDBusTestExec Core DBus Quick Test)
66
77include_directories(
88 ${CMAKE_CURRENT_BINARY_DIR}
@@ -11,15 +11,11 @@ include_directories(
1111 ${LIBLIGHTDM_INCLUDE_DIRS}
1212 )
1313
14−add_dependencies(test-lightdm-dbus MockLightDM-full)
15−target_link_libraries(test-lightdm-dbus
14+target_link_libraries(GreeterDBusTestExec
1615 -L${CMAKE_BINARY_DIR}/tests/mocks/LightDM/full
1716 -llightdm-qt5-2
1817 )
1918
2019add_definitions(-DCURRENT_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}")
2120
22−add_custom_target(testLightDMDBus xvfb-run --server-args "-screen 0 1024x768x24" --auto-servernum dbus-launch env QML2_IMPORT_PATH=${CMAKE_BINARY_DIR}/tests/mocks LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/LightDM/full ${CMAKE_CURRENT_BINARY_DIR}/test-lightdm-dbus)
23−add_dependencies(testLightDMDBus test-lightdm-dbus)
24−
25−add_dependencies(qmluitests testLightDMDBus)
21+add_binary_qml_test(GreeterDBus "${CMAKE_BINARY_DIR}/tests/mocks/LightDM/full" MockLightDM-full "QML2_IMPORT_PATH=${CMAKE_BINARY_DIR}/tests/mocks")
tests/plugins/LightDM/dbus.cpp+7−1
@@ -159,9 +159,15 @@ private Q_SLOTS:
159159 {
160160 QSignalSpy spy(this, SIGNAL(PropertiesChangedRelay(QString, QVariantMap, QStringList)));
161161 greeter->authenticate("no-password");
162+
163+ // Two property changed signals will be emitted, one for the IsLocked
164+ // property, one for the ActiveEntry; the first will be IsLocked.
162165 spy.wait();
166+ if (spy.count() < 2) {
167+ spy.wait();
168+ }
169+ QCOMPARE(spy.count(), 2);
163170
164− QCOMPARE(spy.count(), 2); // once for locked, once for user; first will be locked mode
165171 QList<QVariant> arguments = spy.takeFirst();
166172 QVERIFY(arguments.at(0).toString() == "com.canonical.UnityGreeter.List");
167173 QVERIFY(arguments.at(1).toMap().contains("EntryIsLocked"));