aboutsummaryrefslogtreecommitdiffstats
path: root/tests/CMakeLists.txt
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-08-07 18:02:51 +0200
committerDanilo M. <danix@danix.xyz>2026-08-07 18:02:51 +0200
commitd62a9eb9694beee1674f9c63f9a77029a81627ee (patch)
treebac56e4f15a64acde7195fd971895afb9552a91e /tests/CMakeLists.txt
parent5f77cb8374b983b17268dfd571afa65e2678147b (diff)
downloadqtmaildir-d62a9eb9694beee1674f9c63f9a77029a81627ee.tar.gz
qtmaildir-d62a9eb9694beee1674f9c63f9a77029a81627ee.zip
test: pin the offscreen platform, and let the popup test check its own geometry
ctest sets no QT_QPA_PLATFORM, so the suite's verdict depended on how it was invoked: green for anyone exporting `offscreen` by hand, red under ctest in the same tree. That cost a wrong diagnosis before the cause was found, an unrelated change blamed for a failure that reproduces on a clean checkout. The Wayland warning blames a missing transientParent, which is misleading. Instrumenting the test showed the popup viewport arriving as 1278x0. The zero height is why the grab returned a null pixmap, but the width is the worse half: this test sizes a line edit to 550px and exists to prove a description survives a popup that size, so a working grab would have measured a popup twice that wide and passed while proving nothing. Offscreen gives 548x40, the geometry the test means. Pinning the platform is therefore the correct fix rather than an opt-out. It is set in add_qtmaildir_test so it covers every test, including the two others that create widgets, and anything added later. The test now also asserts its own geometry, since CMake only governs ctest and the binary is often run directly. A bare !shot.isNull() said nothing useful; it now reports "popup viewport has no height (1278x0)" or names a popup too wide to be the case under test. Both guards were verified by mutation.
Diffstat (limited to 'tests/CMakeLists.txt')
-rw-r--r--tests/CMakeLists.txt21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index c09ef78..a7bb670 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -5,10 +5,31 @@
# a global initialiser the linker then drops. Library code reads :/fonts/ when
# it builds the placeholder pane, so a test that never links the qrc would
# exercise only the missing-resource fallback and pass against a broken build.
+#
+# Every test runs under the OFFSCREEN platform, set here rather than left to
+# whatever the invoking session happens to use. This is not tidiness: a test
+# that renders needs deterministic geometry, and a real windowing system does
+# not provide it.
+#
+# The case that forced it (item 52). theDescriptionSurvivesAModestPopupWidth
+# sizes a line edit to 550px and asserts a description survives the popup that
+# results. Under Wayland the compositor gave the popup a viewport of 1278x0: the
+# zero height made the grab return a null pixmap, which is what failed, but the
+# 1278 width is the worse half. Had the grab succeeded, the test would have
+# measured a popup more than twice the width it claims to be testing and passed
+# while proving nothing about the 550px case.
+#
+# So the platform is pinned for correctness, not to dodge a red result. `ctest`
+# sets no QT_QPA_PLATFORM of its own, so without this the suite's verdict
+# depends on how it was invoked: it passed for a developer exporting `offscreen`
+# by hand and failed under `ctest` in the same tree, which cost one wrong
+# diagnosis before the cause was found.
function(add_qtmaildir_test name)
add_executable(test_${name} test_${name}.cpp ${CMAKE_SOURCE_DIR}/src/resources.qrc)
target_link_libraries(test_${name} PRIVATE qtmaildir_lib Qt6::Test)
add_test(NAME ${name} COMMAND test_${name})
+ set_tests_properties(${name} PROPERTIES
+ ENVIRONMENT "QT_QPA_PLATFORM=offscreen")
endfunction()
add_qtmaildir_test(keymap)