]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/tests/dolphinviewtest_allviewmodes.cpp
Improve DolphinViewTest_AllViewModes::testKeyboardFocus().
[dolphin.git] / src / tests / dolphinviewtest_allviewmodes.cpp
index 3eb78c0d256430146644f269454d063c7585ac91..36285a95964b919f6900d642311ba0d6eb6c30e6 100644 (file)
@@ -217,14 +217,25 @@ void DolphinViewTest_AllViewModes::testViewPropertySettings()
  * testKeyboardFocus() checks whether a view grabs the keyboard focus.
  *
  * A view may never grab the keyboard focus itself and must respect the focus-state
- * when switching the view mode.
+ * when switching the view mode, see
+ *
+ * https://bugs.kde.org/show_bug.cgi?id=261147
  */
 
 void DolphinViewTest_AllViewModes::testKeyboardFocus()
 {
     const DolphinView::Mode mode = m_view->mode();
 
+    // Move keyboard focus to another widget. To see that this is needed, run only this test,
+    // i.e., pass 'testKeyboardFocus' as a parameter on the command line.
+    QWidget widget;
+    widget.show();
+    QTest::qWaitForWindowShown(&widget);
+    widget.setFocus();
+
     QVERIFY(!m_view->hasFocus());
+
+    // Switch view modes and verify that the view does not get the focus back
     for (int i = 0; i <= DolphinView::MaxModeEnum; ++i) {
         m_view->setMode(static_cast<DolphinView::Mode>(i));
         QVERIFY(!m_view->hasFocus());