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.
cb1ecc1Michael Terry
cmake/modules/QmlTest.cmake+3
@@ -153,7 +153,9 @@ endmacro(add_qml_test_internal)
153
153
154macro(add_binary_qml_test CLASS_NAME LD_PATH DEPS ENVVAR)
154macro(add_binary_qml_test CLASS_NAME LD_PATH DEPS ENVVAR)
155 set(testCommand
155 set(testCommand
156+ ${ENVVAR}
156 LD_LIBRARY_PATH=${LD_PATH}
157 LD_LIBRARY_PATH=${LD_PATH}
158+ dbus-launch
157 ${CMAKE_CURRENT_BINARY_DIR}/${CLASS_NAME}TestExec
159 ${CMAKE_CURRENT_BINARY_DIR}/${CLASS_NAME}TestExec
158 -o ${CMAKE_BINARY_DIR}/test${CLASS_NAME}.xml,xunitxml
160 -o ${CMAKE_BINARY_DIR}/test${CLASS_NAME}.xml,xunitxml
159 -o -,txt)
161 -o -,txt)
@@ -171,6 +173,7 @@ macro(add_binary_qml_test CLASS_NAME LD_PATH DEPS ENVVAR)
171 ${ENVVAR}
173 ${ENVVAR}
172 LD_LIBRARY_PATH=${LD_PATH}
174 LD_LIBRARY_PATH=${LD_PATH}
173 xvfb-run --server-args "-screen 0 1024x768x24" --auto-servernum
175 xvfb-run --server-args "-screen 0 1024x768x24" --auto-servernum
176+ dbus-launch
174 ${CMAKE_CURRENT_BINARY_DIR}/${CLASS_NAME}TestExec
177 ${CMAKE_CURRENT_BINARY_DIR}/${CLASS_NAME}TestExec
175 -o ${CMAKE_BINARY_DIR}/test${CLASS_NAME}.xml,xunitxml
178 -o ${CMAKE_BINARY_DIR}/test${CLASS_NAME}.xml,xunitxml
176 -o -,txt)
179 -o -,txt)
tests/plugins/LightDM/CMakeLists.txt+4−8
@@ -1,8 +1,8 @@
1−add_executable(test-lightdm-dbus
1+add_executable(GreeterDBusTestExec
2 dbus.cpp
2 dbus.cpp
3 ${CMAKE_SOURCE_DIR}/plugins/LightDM/Greeter.cpp
3 ${CMAKE_SOURCE_DIR}/plugins/LightDM/Greeter.cpp
4 )
4 )
5−qt5_use_modules(test-lightdm-dbus Core DBus Quick Test)
5+qt5_use_modules(GreeterDBusTestExec Core DBus Quick Test)
6
6
7include_directories(
7include_directories(
8 ${CMAKE_CURRENT_BINARY_DIR}
8 ${CMAKE_CURRENT_BINARY_DIR}
@@ -11,15 +11,11 @@ include_directories(
11 ${LIBLIGHTDM_INCLUDE_DIRS}
11 ${LIBLIGHTDM_INCLUDE_DIRS}
12 )
12 )
13
13
14−add_dependencies(test-lightdm-dbus MockLightDM-full)
15−target_link_libraries(test-lightdm-dbus
14+target_link_libraries(GreeterDBusTestExec
16 -L${CMAKE_BINARY_DIR}/tests/mocks/LightDM/full
15 -L${CMAKE_BINARY_DIR}/tests/mocks/LightDM/full
17 -llightdm-qt5-2
16 -llightdm-qt5-2
18 )
17 )
19
18
20add_definitions(-DCURRENT_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}")
19add_definitions(-DCURRENT_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}")
21
20
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)
21+add_binary_qml_test(GreeterDBus "${CMAKE_BINARY_DIR}/tests/mocks/LightDM/full" MockLightDM-full "QML2_IMPORT_PATH=${CMAKE_BINARY_DIR}/tests/mocks")
23−add_dependencies(testLightDMDBus test-lightdm-dbus)
24−
25−add_dependencies(qmluitests testLightDMDBus)
tests/plugins/LightDM/dbus.cpp+7−1
@@ -159,9 +159,15 @@ private Q_SLOTS:
159 {
159 {
160 QSignalSpy spy(this, SIGNAL(PropertiesChangedRelay(QString, QVariantMap, QStringList)));
160 QSignalSpy spy(this, SIGNAL(PropertiesChangedRelay(QString, QVariantMap, QStringList)));
161 greeter->authenticate("no-password");
161 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.
162 spy.wait();
165 spy.wait();
166+ if (spy.count() < 2) {
167+ spy.wait();
168+ }
169+ QCOMPARE(spy.count(), 2);
163
170
164− QCOMPARE(spy.count(), 2); // once for locked, once for user; first will be locked mode
165 QList<QVariant> arguments = spy.takeFirst();
171 QList<QVariant> arguments = spy.takeFirst();
166 QVERIFY(arguments.at(0).toString() == "com.canonical.UnityGreeter.List");
172 QVERIFY(arguments.at(0).toString() == "com.canonical.UnityGreeter.List");
167 QVERIFY(arguments.at(1).toMap().contains("EntryIsLocked"));
173 QVERIFY(arguments.at(1).toMap().contains("EntryIsLocked"));