Revision: 338
http://ktutorial.svn.sourceforge.net/ktutorial/?rev=338&view=rev
Author: danxuliu
Date: 2011-10-13 09:13:34 +0000 (Thu, 13 Oct 2011)
Log Message:
-----------
Fix TutorialManagerDialogTest. It seems that, in Qt 4.7, the tutorial list needs to get the focus before receiving the click events or they will have no effect.
Modified Paths:
--------------
trunk/ktutorial/ktutorial-library/tests/view/TutorialManagerDialogTest.cpp
Modified: trunk/ktutorial/ktutorial-library/tests/view/TutorialManagerDialogTest.cpp
===================================================================
--- trunk/ktutorial/ktutorial-library/tests/view/TutorialManagerDialogTest.cpp 2011-09-23 13:02:59 UTC (rev 337)
+++ trunk/ktutorial/ktutorial-library/tests/view/TutorialManagerDialogTest.cpp 2011-10-13 09:13:34 UTC (rev 338)
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2009-2010 by Daniel Calviño Sánchez *
+ * Copyright (C) 2009-2011 by Daniel Calviño Sánchez *
* dan...@gm... *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -173,6 +173,8 @@
mTutorialManagerDialog->show();
+ tutorialList(mTutorialManagerDialog)->setFocus();
+
QTest::keyClick(tutorialList(mTutorialManagerDialog), Qt::Key_Space,
Qt::NoModifier, 500);
@@ -211,6 +213,8 @@
mTutorialManagerDialog->show();
+ tutorialList(mTutorialManagerDialog)->setFocus();
+
QTest::keyClick(tutorialList(mTutorialManagerDialog), Qt::Key_Space,
Qt::NoModifier, 500);
@@ -274,6 +278,26 @@
mTutorialManagerDialog->show();
+ //When the dialog is shown, the focus is given to the Close button. The
+ //Start button (User1) is the default one, but as it is disabled, the Close
+ //button becomes the default dialog button. The Start button will become the
+ //default button again when the Close button receives a FocusOut event.
+ //However, the dialog must be the active window for the Close button to
+ //receive the FocusOut event. If the focus is set to the tutorial list but
+ //the dialog is not the active window no FocusOut event will be sent (as
+ //QWidget::setFocus calls QApplicationPrivate::setFocusWidget only when the
+ //widget is in the active window). Even if the dialog became the active
+ //window later once the focus was set to the tutorial list, no FocusOut
+ //event would be sent to the Close button.
+ //Thus, the dialog must have been truly shown before setting the focus to
+ //the tutorial list. Note that if the dialog is shown but it is not the
+ //active window (which can happen, for example, when debugging step by step)
+ //the FocusOut event will not be sent either, but in normal test running
+ //showing the dialog will make it the active window.
+ QTest::qWaitForWindowShown(mTutorialManagerDialog);
+
+ tutorialList(mTutorialManagerDialog)->setFocus();
+
QItemSelectionModel* selectionModel =
tutorialList(mTutorialManagerDialog)->selectionModel();
selectionModel->select(selectionModel->model()->index(1, 0),
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|