diff options
Diffstat (limited to 'tests')
4 files changed, 151 insertions, 36 deletions
diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index 47c5b63..fbab30e 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -50,6 +50,7 @@ #include <QtDeclarative/qdeclarativeexpression.h> #include <QtDeclarative/qdeclarativecomponent.h> #include <private/qdeclarativetextedit_p.h> +#include <private/qdeclarativetextedit_p_p.h> #include <QFontMetrics> #include <QDeclarativeView> #include <QStyle> @@ -86,7 +87,8 @@ private slots: void delegateLoading(); void navigation(); void readOnly(); - void sendRequestSoftwareInputPanelEvent(); + void openInputPanelOnClick(); + void openInputPanelOnFocus(); void geometrySignals(); private: void simulateKey(QDeclarativeView *, int key); @@ -817,14 +819,14 @@ public: bool closeInputPanelReceived; }; -void tst_qdeclarativetextedit::sendRequestSoftwareInputPanelEvent() +void tst_qdeclarativetextedit::openInputPanelOnClick() { QGraphicsScene scene; QGraphicsView view(&scene); MyInputContext ic; view.setInputContext(&ic); QDeclarativeTextEdit edit; - QSignalSpy inputPanelonFocusSpy(&edit, SIGNAL(showInputPanelOnFocusChanged(bool))); + QSignalSpy focusOnPressSpy(&edit, SIGNAL(focusOnPressChanged(bool))); edit.setText("Hello world"); edit.setPos(0, 0); scene.addItem(&edit); @@ -834,7 +836,58 @@ void tst_qdeclarativetextedit::sendRequestSoftwareInputPanelEvent() QTest::qWaitForWindowShown(&view); QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view)); - QVERIFY(edit.showInputPanelOnFocus()); + QDeclarativeItemPrivate* pri = QDeclarativeItemPrivate::get(&edit); + QDeclarativeTextEditPrivate *editPrivate = static_cast<QDeclarativeTextEditPrivate*>(pri); + + // input panel on click + editPrivate->showInputPanelOnFocus = false; + + QStyle::RequestSoftwareInputPanel behavior = QStyle::RequestSoftwareInputPanel( + view.style()->styleHint(QStyle::SH_RequestSoftwareInputPanel)); + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos())); + QApplication::processEvents(); + if (behavior == QStyle::RSIP_OnMouseClickAndAlreadyFocused) { + QCOMPARE(ic.openInputPanelReceived, false); + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos())); + QApplication::processEvents(); + QCOMPARE(ic.openInputPanelReceived, true); + } else if (behavior == QStyle::RSIP_OnMouseClick) { + QCOMPARE(ic.openInputPanelReceived, true); + } + ic.openInputPanelReceived = false; + + // focus should not cause input panels to open or close + edit.setFocus(false); + edit.setFocus(true); + edit.setFocus(false); + edit.setFocus(true); + edit.setFocus(false); + QCOMPARE(ic.openInputPanelReceived, false); + QCOMPARE(ic.closeInputPanelReceived, false); +} + +void tst_qdeclarativetextedit::openInputPanelOnFocus() +{ + QGraphicsScene scene; + QGraphicsView view(&scene); + MyInputContext ic; + view.setInputContext(&ic); + QDeclarativeTextEdit edit; + QSignalSpy focusOnPressSpy(&edit, SIGNAL(focusOnPressChanged(bool))); + edit.setText("Hello world"); + edit.setPos(0, 0); + scene.addItem(&edit); + view.show(); + qApp->setAutoSipEnabled(true); + QApplication::setActiveWindow(&view); + QTest::qWaitForWindowShown(&view); + QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view)); + + QDeclarativeItemPrivate* pri = QDeclarativeItemPrivate::get(&edit); + QDeclarativeTextEditPrivate *editPrivate = static_cast<QDeclarativeTextEditPrivate*>(pri); + editPrivate->showInputPanelOnFocus = true; + + QVERIFY(edit.focusOnPress()); QCOMPARE(ic.openInputPanelReceived, false); QCOMPARE(ic.closeInputPanelReceived, false); @@ -867,9 +920,9 @@ void tst_qdeclarativetextedit::sendRequestSoftwareInputPanelEvent() QCOMPARE(ic.closeInputPanelReceived, true); ic.closeInputPanelReceived = false; - // no input panel events if showInputPanelOnFocus is false - edit.setShowInputPanelOnFocus(false); - QCOMPARE(inputPanelonFocusSpy.count(),1); + // no automatic input panel events if focusOnPress is false + 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); @@ -877,8 +930,8 @@ void tst_qdeclarativetextedit::sendRequestSoftwareInputPanelEvent() QCOMPARE(ic.openInputPanelReceived, false); QCOMPARE(ic.closeInputPanelReceived, false); - edit.setShowInputPanelOnFocus(false); - QCOMPARE(inputPanelonFocusSpy.count(),1); + edit.setFocusOnPress(false); + QCOMPARE(focusOnPressSpy.count(),1); // one show input panel event when openSoftwareInputPanel is called edit.openSoftwareInputPanel(); @@ -892,14 +945,17 @@ void tst_qdeclarativetextedit::sendRequestSoftwareInputPanelEvent() QCOMPARE(ic.closeInputPanelReceived, true); ic.openInputPanelReceived = false; - // set showInputPanelOnFocus back to true - edit.setShowInputPanelOnFocus(true); - QCOMPARE(inputPanelonFocusSpy.count(),2); + // set focusOnPress back to true + edit.setFocusOnPress(true); + QCOMPARE(focusOnPressSpy.count(),2); edit.setFocus(false); QCOMPARE(ic.openInputPanelReceived, false); QCOMPARE(ic.closeInputPanelReceived, true); ic.closeInputPanelReceived = false; + edit.setFocusOnPress(true); + QCOMPARE(focusOnPressSpy.count(),2); + // active window focus reason should not cause input panel to open QGraphicsObject * editObject = qobject_cast<QGraphicsObject*>(&edit); editObject->setFocus(Qt::ActiveWindowFocusReason); @@ -910,9 +966,6 @@ void tst_qdeclarativetextedit::sendRequestSoftwareInputPanelEvent() edit.setFocus(true); QCOMPARE(ic.openInputPanelReceived, false); QCOMPARE(ic.closeInputPanelReceived, false); - - edit.setShowInputPanelOnFocus(true); - QCOMPARE(inputPanelonFocusSpy.count(),2); } void tst_qdeclarativetextedit::geometrySignals() diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp index c943c89..3cb4da0 100644 --- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp +++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp @@ -45,6 +45,7 @@ #include <QFile> #include <QtDeclarative/qdeclarativeview.h> #include <private/qdeclarativetextinput_p.h> +#include <private/qdeclarativetextinput_p_p.h> #include <QDebug> #include <QStyle> #include <QInputContext> @@ -74,7 +75,8 @@ private slots: void navigation(); void readOnly(); - void sendRequestSoftwareInputPanelEvent(); + void openInputPanelOnClick(); + void openInputPanelOnFocus(); void setHAlignClearCache(); void focusOutClearSelection(); @@ -763,14 +765,14 @@ public: bool closeInputPanelReceived; }; -void tst_qdeclarativetextinput::sendRequestSoftwareInputPanelEvent() +void tst_qdeclarativetextinput::openInputPanelOnClick() { QGraphicsScene scene; QGraphicsView view(&scene); MyInputContext ic; view.setInputContext(&ic); QDeclarativeTextInput input; - QSignalSpy inputPanelonFocusSpy(&input, SIGNAL(showInputPanelOnFocusChanged(bool))); + QSignalSpy focusOnPressSpy(&input, SIGNAL(focusOnPressChanged(bool))); input.setText("Hello world"); input.setPos(0, 0); scene.addItem(&input); @@ -780,7 +782,58 @@ void tst_qdeclarativetextinput::sendRequestSoftwareInputPanelEvent() QTest::qWaitForWindowShown(&view); QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view)); - QVERIFY(input.showInputPanelOnFocus()); + QDeclarativeItemPrivate* pri = QDeclarativeItemPrivate::get(&input); + QDeclarativeTextInputPrivate *inputPrivate = static_cast<QDeclarativeTextInputPrivate*>(pri); + + // input panel on click + inputPrivate->showInputPanelOnFocus = false; + + QStyle::RequestSoftwareInputPanel behavior = QStyle::RequestSoftwareInputPanel( + view.style()->styleHint(QStyle::SH_RequestSoftwareInputPanel)); + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos())); + QApplication::processEvents(); + if (behavior == QStyle::RSIP_OnMouseClickAndAlreadyFocused) { + QCOMPARE(ic.openInputPanelReceived, false); + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos())); + QApplication::processEvents(); + QCOMPARE(ic.openInputPanelReceived, true); + } else if (behavior == QStyle::RSIP_OnMouseClick) { + QCOMPARE(ic.openInputPanelReceived, true); + } + ic.openInputPanelReceived = false; + + // focus should not cause input panels to open or close + input.setFocus(false); + input.setFocus(true); + input.setFocus(false); + input.setFocus(true); + input.setFocus(false); + QCOMPARE(ic.openInputPanelReceived, false); + QCOMPARE(ic.closeInputPanelReceived, false); +} + +void tst_qdeclarativetextinput::openInputPanelOnFocus() +{ + QGraphicsScene scene; + QGraphicsView view(&scene); + MyInputContext ic; + view.setInputContext(&ic); + QDeclarativeTextInput input; + QSignalSpy focusOnPressSpy(&input, SIGNAL(focusOnPressChanged(bool))); + input.setText("Hello world"); + input.setPos(0, 0); + scene.addItem(&input); + view.show(); + qApp->setAutoSipEnabled(true); + QApplication::setActiveWindow(&view); + QTest::qWaitForWindowShown(&view); + QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view)); + + QDeclarativeItemPrivate* pri = QDeclarativeItemPrivate::get(&input); + QDeclarativeTextInputPrivate *inputPrivate = static_cast<QDeclarativeTextInputPrivate*>(pri); + inputPrivate->showInputPanelOnFocus = true; + + QVERIFY(input.focusOnPress()); QCOMPARE(ic.openInputPanelReceived, false); QCOMPARE(ic.closeInputPanelReceived, false); @@ -813,9 +866,9 @@ void tst_qdeclarativetextinput::sendRequestSoftwareInputPanelEvent() QCOMPARE(ic.closeInputPanelReceived, true); ic.closeInputPanelReceived = false; - // no input panel events if showInputPanelOnFocus is false - input.setShowInputPanelOnFocus(false); - QCOMPARE(inputPanelonFocusSpy.count(),1); + // no automatic input panel events if focusOnPress is false + 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); @@ -823,8 +876,8 @@ void tst_qdeclarativetextinput::sendRequestSoftwareInputPanelEvent() QCOMPARE(ic.openInputPanelReceived, false); QCOMPARE(ic.closeInputPanelReceived, false); - input.setShowInputPanelOnFocus(false); - QCOMPARE(inputPanelonFocusSpy.count(),1); + input.setFocusOnPress(false); + QCOMPARE(focusOnPressSpy.count(),1); // one show input panel event when openSoftwareInputPanel is called input.openSoftwareInputPanel(); @@ -838,14 +891,17 @@ void tst_qdeclarativetextinput::sendRequestSoftwareInputPanelEvent() QCOMPARE(ic.closeInputPanelReceived, true); ic.openInputPanelReceived = false; - // set showInputPanelOnFocus back to true - input.setShowInputPanelOnFocus(true); - QCOMPARE(inputPanelonFocusSpy.count(),2); + // set focusOnPress back to true + input.setFocusOnPress(true); + QCOMPARE(focusOnPressSpy.count(),2); input.setFocus(false); QCOMPARE(ic.openInputPanelReceived, false); QCOMPARE(ic.closeInputPanelReceived, true); ic.closeInputPanelReceived = false; + input.setFocusOnPress(true); + QCOMPARE(focusOnPressSpy.count(),2); + // active window focus reason should not cause input panel to open QGraphicsObject * inputObject = qobject_cast<QGraphicsObject*>(&input); inputObject->setFocus(Qt::ActiveWindowFocusReason); @@ -856,9 +912,6 @@ void tst_qdeclarativetextinput::sendRequestSoftwareInputPanelEvent() input.setFocus(true); QCOMPARE(ic.openInputPanelReceived, false); QCOMPARE(ic.closeInputPanelReceived, false); - - input.setShowInputPanelOnFocus(true); - QCOMPARE(inputPanelonFocusSpy.count(),2); } class MyTextInput : public QDeclarativeTextInput diff --git a/tests/auto/declarative/qdeclarativeviewer/data/orientation.qml b/tests/auto/declarative/qdeclarativeviewer/data/orientation.qml index 687fac6..be911a3 100644 --- a/tests/auto/declarative/qdeclarativeviewer/data/orientation.qml +++ b/tests/auto/declarative/qdeclarativeviewer/data/orientation.qml @@ -1,10 +1,19 @@ import Qt 4.7 Rectangle { color: "black" - width: (runtime.orientation == Orientation.Landscape) ? 300 : 200 - height: (runtime.orientation == Orientation.Landscape) ? 200 : 300 + width: (runtime.orientation == Orientation.RightUp || runtime.orientation == Orientation.LeftUp) ? 300 : 200 + height: (runtime.orientation == Orientation.RightUp || runtime.orientation == Orientation.LeftUp) ? 200 : 300 Text { - text: runtime.orientation == Orientation.Landscape ? "Landscape" : "Portrait" + text: { + if (runtime.orientation == Orientation.TopUp) + return "TopUp" + if (runtime.orientation == Orientation.TopDown) + return "TopDown" + if (runtime.orientation == Orientation.LeftUp) + return "LeftUp" + if (runtime.orientation == Orientation.RightUp) + return "RightUp" + } color: "white" } -}
\ No newline at end of file +} diff --git a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp index 9429dc9..f296d9e 100644 --- a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp +++ b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp @@ -82,7 +82,7 @@ void tst_QDeclarativeViewer::orientation() QCOMPARE(viewer->size(), QSize(200, 300+viewer->menuBar()->height())); QCOMPARE(viewer->size(), viewer->sizeHint()); - viewer->toggleOrientation(); + viewer->rotateOrientation(); qApp->processEvents(); QCOMPARE(rootItem->width(), 300.0); @@ -92,7 +92,7 @@ void tst_QDeclarativeViewer::orientation() QCOMPARE(viewer->size(), QSize(300, 200+viewer->menuBar()->height())); QCOMPARE(viewer->size(), viewer->sizeHint()); - viewer->toggleOrientation(); + viewer->rotateOrientation(); qApp->processEvents(); QCOMPARE(rootItem->width(), 200.0); |