diff options
| author | Sebastian Englbrecht <[email protected]> | 2026-05-25 13:30:09 +0200 |
|---|---|---|
| committer | Méven Car <[email protected]> | 2026-05-28 11:16:06 +0000 |
| commit | 980d4f71a978e7e437bbe9d0100c095d84a0b4fa (patch) | |
| tree | 1f13c38c7785306b9195aab3b8096e277e46950b | |
| parent | 2a397b64523611974946f68b103efd7a370a0c45 (diff) | |
dolphinmainwindowtest: ensure consistent starting state for places panel tests
In a fresh test environment there is no saved session, so the places panel may
not be visible. Explicitly show it before testing.
Additionally, focus-related assertions require the window to be the active
window — setFocus() on dock widget contents has no effect on an inactive window.
Replace the weak QTRY_VERIFY_WITH_TIMEOUT(activeWindow() != nullptr, 100) with
requestActivate() + qWaitForWindowActive() to enforce this precondition.
| -rw-r--r-- | src/tests/dolphinmainwindowtest.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/tests/dolphinmainwindowtest.cpp b/src/tests/dolphinmainwindowtest.cpp index 24d2025b7..84271786c 100644 --- a/src/tests/dolphinmainwindowtest.cpp +++ b/src/tests/dolphinmainwindowtest.cpp @@ -524,9 +524,16 @@ void DolphinMainWindowTest::testFocusPlacesPanel() m_mainWindow->show(); QVERIFY(QTest::qWaitForWindowExposed(m_mainWindow.data())); QVERIFY(m_mainWindow->isVisible()); - QTRY_VERIFY_WITH_TIMEOUT(QApplication::activeWindow() != nullptr, 100); + m_mainWindow->windowHandle()->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(m_mainWindow.data())); QWidget *placesPanel = reinterpret_cast<QWidget *>(m_mainWindow->m_placesPanel); + QAction *showPlacesPanelAction = m_mainWindow->actionCollection()->action(QStringLiteral("show_places_panel")); + if (!showPlacesPanelAction->isChecked()) { + showPlacesPanelAction->trigger(); + // trigger() moves focus to the panel; restore it so the test starts from a defined state. + m_mainWindow->activeViewContainer()->view()->setFocus(); + } QVERIFY2(QTest::qWaitFor( [&]() { return placesPanel && placesPanel->isVisible() && placesPanel->width() > 0 && placesPanel->height() > 0; @@ -535,7 +542,6 @@ void DolphinMainWindowTest::testFocusPlacesPanel() "The test couldn't be initialised properly. The places panel should be visible."); QAction *focusPlacesPanelAction = m_mainWindow->actionCollection()->action(QStringLiteral("focus_places_panel")); - QAction *showPlacesPanelAction = m_mainWindow->actionCollection()->action(QStringLiteral("show_places_panel")); focusPlacesPanelAction->trigger(); QVERIFY(placesPanel->hasFocus()); @@ -582,6 +588,13 @@ void DolphinMainWindowTest::testPlacesPanelWidthResistance() QVERIFY(m_mainWindow->isVisible()); QWidget *placesPanel = reinterpret_cast<QWidget *>(m_mainWindow->m_placesPanel); + // ensure panel is visible even in a fresh env without a saved session. + { + QAction *showPlacesPanelAction = m_mainWindow->actionCollection()->action(QStringLiteral("show_places_panel")); + if (!showPlacesPanelAction->isChecked()) { + showPlacesPanelAction->trigger(); + } + } QVERIFY2(QTest::qWaitFor( [&]() { return placesPanel && placesPanel->isVisible() && placesPanel->width() > 0; |
