diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-06-07 06:32:59 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-06-07 06:32:59 (GMT) |
commit | d660ea1a68d282763e8f574f066d2ef958cd3c1b (patch) | |
tree | 84816e188811554b26278314ca8f07eb7a60965e /tests | |
parent | f6eeb554631faa542cb14388a46f05a0822b8033 (diff) | |
parent | a4f4fff60d20e509cb57bd0dab30533e1e299aee (diff) | |
download | Qt-d660ea1a68d282763e8f574f066d2ef958cd3c1b.zip Qt-d660ea1a68d282763e8f574f066d2ef958cd3c1b.tar.gz Qt-d660ea1a68d282763e8f574f066d2ef958cd3c1b.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'tests')
3 files changed, 96 insertions, 53 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() diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp index 370ecfb..c9de0aa 100644 --- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp +++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp @@ -833,6 +833,7 @@ void tst_qdeclarativetextinput::openInputPanelOnFocus() QDeclarativeTextInputPrivate *inputPrivate = static_cast<QDeclarativeTextInputPrivate*>(pri); inputPrivate->showInputPanelOnFocus = true; + // test default values QVERIFY(input.focusOnPress()); QCOMPARE(ic.openInputPanelReceived, false); QCOMPARE(ic.closeInputPanelReceived, false); @@ -842,75 +843,94 @@ void tst_qdeclarativetextinput::openInputPanelOnFocus() QApplication::processEvents(); QVERIFY(input.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(input.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(input.hasFocus()); QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos())); QApplication::processEvents(); QCOMPARE(ic.openInputPanelReceived, true); - QCOMPARE(ic.closeInputPanelReceived, false); ic.openInputPanelReceived = false; - // input panel closed on focus lost - input.setFocus(false); + // input method should stay enabled if focus + // is lost to an item that also accepts inputs + QDeclarativeTextInput anotherInput; + scene.addItem(&anotherInput); + anotherInput.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 + input.setFocusOnPress(false); + QCOMPARE(focusOnPressSpy.count(),1); input.setFocusOnPress(false); QCOMPARE(focusOnPressSpy.count(),1); - QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos())); - QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos())); input.setFocus(false); input.setFocus(true); + QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos())); + QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos())); + QApplication::processEvents(); QCOMPARE(ic.openInputPanelReceived, false); QCOMPARE(ic.closeInputPanelReceived, false); - input.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 input.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 input.closeSoftwareInputPanel(); QCOMPARE(ic.openInputPanelReceived, false); QCOMPARE(ic.closeInputPanelReceived, true); - ic.openInputPanelReceived = false; + ic.closeInputPanelReceived = false; // set focusOnPress back to true input.setFocusOnPress(true); QCOMPARE(focusOnPressSpy.count(),2); + input.setFocusOnPress(true); + QCOMPARE(focusOnPressSpy.count(),2); input.setFocus(false); + QApplication::processEvents(); QCOMPARE(ic.openInputPanelReceived, false); - QCOMPARE(ic.closeInputPanelReceived, true); + QCOMPARE(ic.closeInputPanelReceived, false); ic.closeInputPanelReceived = false; - input.setFocusOnPress(true); - QCOMPARE(focusOnPressSpy.count(),2); - + // input panel should not re-open + // if focus has already been set input.setFocus(true); QCOMPARE(ic.openInputPanelReceived, true); - QCOMPARE(ic.closeInputPanelReceived, false); ic.openInputPanelReceived = false; - - // input panel should not open if focus has already been set input.setFocus(true); QCOMPARE(ic.openInputPanelReceived, false); - QCOMPARE(ic.closeInputPanelReceived, false); + + // input method should be disabled + // if TextEdit loses focus + input.setFocus(false); + QApplication::processEvents(); + QVERIFY(view.inputContext() == 0); + QVERIFY(!view.testAttribute(Qt::WA_InputMethodEnabled)); } class MyTextInput : public QDeclarativeTextInput diff --git a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp index 53fd68c..5e46fab 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp +++ b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp @@ -46,6 +46,8 @@ #include <private/qdeclarativevaluetype_p.h> #include "testtypes.h" +extern int qt_defaultDpi(); + class tst_qdeclarativevaluetypes : public QObject { Q_OBJECT @@ -464,7 +466,7 @@ void tst_qdeclarativevaluetypes::font() QCOMPARE(object->property("f_overline").toBool(), object->font().overline()); QCOMPARE(object->property("f_strikeout").toBool(), object->font().strikeOut()); QCOMPARE(object->property("f_pointSize").toDouble(), object->font().pointSizeF()); - QCOMPARE(object->property("f_pixelSize").toInt(), object->font().pixelSize()); + QCOMPARE(object->property("f_pixelSize").toInt(), int((object->font().pointSizeF() * qt_defaultDpi()) / qreal(72.))); QCOMPARE(object->property("f_capitalization").toInt(), (int)object->font().capitalization()); QCOMPARE(object->property("f_letterSpacing").toDouble(), object->font().letterSpacing()); QCOMPARE(object->property("f_wordSpacing").toDouble(), object->font().wordSpacing()); |