summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativetextedit
diff options
context:
space:
mode:
authorJoona Petrell <joona.t.petrell@nokia.com>2010-06-07 04:52:20 (GMT)
committerJoona Petrell <joona.t.petrell@nokia.com>2010-06-07 05:31:10 (GMT)
commitf410fb06c584fa0e893ab6066ea8b03a5323fe07 (patch)
tree6c73d8229e20abce37b8b796f2b5eb1ca2b361d9 /tests/auto/declarative/qdeclarativetextedit
parent0619c12bfee40826034dbc31f9d398182a3aa49f (diff)
downloadQt-f410fb06c584fa0e893ab6066ea8b03a5323fe07.zip
Qt-f410fb06c584fa0e893ab6066ea8b03a5323fe07.tar.gz
Qt-f410fb06c584fa0e893ab6066ea8b03a5323fe07.tar.bz2
Remove unnecessary CloseSoftwareInputPanel events after TextEdit or TextInput has lost focus
Task-number: Reviewed-by: Warwick Allison
Diffstat (limited to 'tests/auto/declarative/qdeclarativetextedit')
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp73
1 files changed, 47 insertions, 26 deletions
diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
index 9e5285f..053c9ef 100644
--- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
+++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
@@ -862,6 +862,7 @@ void tst_qdeclarativetextedit::openInputPanelOnClick()
edit.setFocus(false);
edit.setFocus(true);
edit.setFocus(false);
+ QApplication::processEvents();
QCOMPARE(ic.openInputPanelReceived, false);
QCOMPARE(ic.closeInputPanelReceived, false);
}
@@ -887,6 +888,7 @@ void tst_qdeclarativetextedit::openInputPanelOnFocus()
QDeclarativeTextEditPrivate *editPrivate = static_cast<QDeclarativeTextEditPrivate*>(pri);
editPrivate->showInputPanelOnFocus = true;
+ // test default values
QVERIFY(edit.focusOnPress());
QCOMPARE(ic.openInputPanelReceived, false);
QCOMPARE(ic.closeInputPanelReceived, false);
@@ -896,75 +898,94 @@ void tst_qdeclarativetextedit::openInputPanelOnFocus()
QApplication::processEvents();
QVERIFY(edit.hasFocus());
QCOMPARE(ic.openInputPanelReceived, true);
- QCOMPARE(ic.closeInputPanelReceived, false);
ic.openInputPanelReceived = false;
// no events on release
QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos()));
QCOMPARE(ic.openInputPanelReceived, false);
- QCOMPARE(ic.closeInputPanelReceived, false);
ic.openInputPanelReceived = false;
- // Even with focus already gained, user needs
- // to be able to open panel by pressing on the editor
+ // if already focused, input panel can be opened on press
+ QVERIFY(edit.hasFocus());
QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos()));
QApplication::processEvents();
QCOMPARE(ic.openInputPanelReceived, true);
- QCOMPARE(ic.closeInputPanelReceived, false);
ic.openInputPanelReceived = false;
- // input panel closed on focus lost
- edit.setFocus(false);
+ // input method should stay enabled if focus
+ // is lost to an item that also accepts inputs
+ QDeclarativeTextEdit anotherEdit;
+ scene.addItem(&anotherEdit);
+ anotherEdit.setFocus(true);
+ QApplication::processEvents();
+ QCOMPARE(ic.openInputPanelReceived, true);
+ ic.openInputPanelReceived = false;
+ QCOMPARE(view.inputContext(), &ic);
+ QVERIFY(view.testAttribute(Qt::WA_InputMethodEnabled));
+
+ // input method should be disabled if focus
+ // is lost to an item that doesn't accept inputs
+ QDeclarativeItem item;
+ scene.addItem(&item);
+ item.setFocus(true);
QApplication::processEvents();
QCOMPARE(ic.openInputPanelReceived, false);
- QCOMPARE(ic.closeInputPanelReceived, true);
- ic.closeInputPanelReceived = false;
+ QVERIFY(view.inputContext() == 0);
+ QVERIFY(!view.testAttribute(Qt::WA_InputMethodEnabled));
- // no automatic input panel events if focusOnPress is false
+ // no automatic input panel events should
+ // be sent if focusOnPress is false
+ edit.setFocusOnPress(false);
+ QCOMPARE(focusOnPressSpy.count(),1);
edit.setFocusOnPress(false);
QCOMPARE(focusOnPressSpy.count(),1);
- QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos()));
- QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos()));
edit.setFocus(false);
edit.setFocus(true);
+ QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos()));
+ QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos()));
+ QApplication::processEvents();
QCOMPARE(ic.openInputPanelReceived, false);
QCOMPARE(ic.closeInputPanelReceived, false);
- edit.setFocusOnPress(false);
- QCOMPARE(focusOnPressSpy.count(),1);
-
- // one show input panel event when openSoftwareInputPanel is called
+ // one show input panel event should
+ // be set when openSoftwareInputPanel is called
edit.openSoftwareInputPanel();
QCOMPARE(ic.openInputPanelReceived, true);
QCOMPARE(ic.closeInputPanelReceived, false);
ic.openInputPanelReceived = false;
- // one close input panel event when closeSoftwareInputPanel is called
+ // one close input panel event should
+ // be sent when closeSoftwareInputPanel is called
edit.closeSoftwareInputPanel();
QCOMPARE(ic.openInputPanelReceived, false);
QCOMPARE(ic.closeInputPanelReceived, true);
- ic.openInputPanelReceived = false;
+ ic.closeInputPanelReceived = false;
// set focusOnPress back to true
edit.setFocusOnPress(true);
QCOMPARE(focusOnPressSpy.count(),2);
+ edit.setFocusOnPress(true);
+ QCOMPARE(focusOnPressSpy.count(),2);
edit.setFocus(false);
+ QApplication::processEvents();
QCOMPARE(ic.openInputPanelReceived, false);
- QCOMPARE(ic.closeInputPanelReceived, true);
+ QCOMPARE(ic.closeInputPanelReceived, false);
ic.closeInputPanelReceived = false;
- edit.setFocusOnPress(true);
- QCOMPARE(focusOnPressSpy.count(),2);
-
+ // input panel should not re-open
+ // if focus has already been set
edit.setFocus(true);
QCOMPARE(ic.openInputPanelReceived, true);
- QCOMPARE(ic.closeInputPanelReceived, false);
ic.openInputPanelReceived = false;
-
- // input panel should not open if focus has already been set
edit.setFocus(true);
QCOMPARE(ic.openInputPanelReceived, false);
- QCOMPARE(ic.closeInputPanelReceived, false);
+
+ // input method should be disabled
+ // if TextEdit loses focus
+ edit.setFocus(false);
+ QApplication::processEvents();
+ QVERIFY(view.inputContext() == 0);
+ QVERIFY(!view.testAttribute(Qt::WA_InputMethodEnabled));
}
void tst_qdeclarativetextedit::geometrySignals()