diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2010-04-12 07:38:46 (GMT) |
---|---|---|
committer | Alan Alpert <alan.alpert@nokia.com> | 2010-04-12 07:38:46 (GMT) |
commit | ee958684bd1273a5140e1f6d1264bf8bb7d62ef1 (patch) | |
tree | c3b95bb906483b14dd9a58098b18b82b9d9010c2 /tests/auto/declarative/qdeclarativetextinput | |
parent | efc80209fb5e6ac9d0343b3c9f6d5a1548cf5556 (diff) | |
parent | 9753f6098e0e5b3d80ac748559aecc2e66dcfc7a (diff) | |
download | Qt-ee958684bd1273a5140e1f6d1264bf8bb7d62ef1.zip Qt-ee958684bd1273a5140e1f6d1264bf8bb7d62ef1.tar.gz Qt-ee958684bd1273a5140e1f6d1264bf8bb7d62ef1.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Conflicts:
src/declarative/graphicsitems/qdeclarativetextinput.cpp
src/declarative/graphicsitems/qdeclarativetextinput_p.h
Diffstat (limited to 'tests/auto/declarative/qdeclarativetextinput')
4 files changed, 71 insertions, 5 deletions
diff --git a/tests/auto/declarative/qdeclarativetextinput/data/navigation.qml b/tests/auto/declarative/qdeclarativetextinput/data/navigation.qml index 493db5b..04f06da 100644 --- a/tests/auto/declarative/qdeclarativetextinput/data/navigation.qml +++ b/tests/auto/declarative/qdeclarativetextinput/data/navigation.qml @@ -1,7 +1,7 @@ import Qt 4.6 Rectangle { - property var myInput: input + property variant myInput: input width: 800; height: 600; color: "blue" diff --git a/tests/auto/declarative/qdeclarativetextinput/data/readOnly.qml b/tests/auto/declarative/qdeclarativetextinput/data/readOnly.qml index c47371a..41e8b59 100644 --- a/tests/auto/declarative/qdeclarativetextinput/data/readOnly.qml +++ b/tests/auto/declarative/qdeclarativetextinput/data/readOnly.qml @@ -1,7 +1,7 @@ import Qt 4.6 Rectangle { - property var myInput: input + property variant myInput: input width: 800; height: 600; color: "blue" diff --git a/tests/auto/declarative/qdeclarativetextinput/data/validators.qml b/tests/auto/declarative/qdeclarativetextinput/data/validators.qml index 531a232..4b1ba27 100644 --- a/tests/auto/declarative/qdeclarativetextinput/data/validators.qml +++ b/tests/auto/declarative/qdeclarativetextinput/data/validators.qml @@ -1,9 +1,9 @@ import Qt 4.7 Item { - property var intInput: intInput - property var dblInput: dblInput - property var strInput: strInput + property variant intInput: intInput + property variant dblInput: dblInput + property variant strInput: strInput width: 800; height: 600; diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp index 26d4cb1..9a66a36 100644 --- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp +++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp @@ -73,6 +73,7 @@ private slots: void sendRequestSoftwareInputPanelEvent(); void setHAlignClearCache(); + void focusOutClearSelection(); void echoMode(); private: @@ -113,6 +114,8 @@ void tst_qdeclarativetextinput::text() QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->text(), QString("")); + + delete textinputObject; } for (int i = 0; i < standard.size(); i++) @@ -124,6 +127,8 @@ void tst_qdeclarativetextinput::text() QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->text(), standard.at(i)); + + delete textinputObject; } } @@ -138,6 +143,8 @@ void tst_qdeclarativetextinput::width() QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->width(), 1.);//1 for the cursor + + delete textinputObject; } for (int i = 0; i < standard.size(); i++) @@ -153,6 +160,8 @@ void tst_qdeclarativetextinput::width() QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->width(), qreal(metricWidth) + 1.);//1 for the cursor + + delete textinputObject; } } @@ -169,6 +178,8 @@ void tst_qdeclarativetextinput::font() QCOMPARE(textinputObject->font().pointSize(), 40); QCOMPARE(textinputObject->font().bold(), false); QCOMPARE(textinputObject->font().italic(), false); + + delete textinputObject; } { @@ -180,6 +191,8 @@ void tst_qdeclarativetextinput::font() QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->font().bold(), true); QCOMPARE(textinputObject->font().italic(), false); + + delete textinputObject; } { @@ -191,6 +204,8 @@ void tst_qdeclarativetextinput::font() QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->font().italic(), true); QCOMPARE(textinputObject->font().bold(), false); + + delete textinputObject; } { @@ -203,6 +218,8 @@ void tst_qdeclarativetextinput::font() QCOMPARE(textinputObject->font().family(), QString("Helvetica")); QCOMPARE(textinputObject->font().bold(), false); QCOMPARE(textinputObject->font().italic(), false); + + delete textinputObject; } { @@ -213,6 +230,8 @@ void tst_qdeclarativetextinput::font() QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->font().family(), QString("")); + + delete textinputObject; } } @@ -227,6 +246,8 @@ void tst_qdeclarativetextinput::color() QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput*>(textinputComponent.create()); QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->color(), QColor(colorStrings.at(i))); + + delete textinputObject; } //test selection color @@ -238,6 +259,8 @@ void tst_qdeclarativetextinput::color() QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput*>(textinputComponent.create()); QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->selectionColor(), QColor(colorStrings.at(i))); + + delete textinputObject; } //test selected text color @@ -249,6 +272,8 @@ void tst_qdeclarativetextinput::color() QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput*>(textinputComponent.create()); QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->selectedTextColor(), QColor(colorStrings.at(i))); + + delete textinputObject; } { @@ -263,6 +288,8 @@ void tst_qdeclarativetextinput::color() QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->color(), testColor); + + delete textinputObject; } } @@ -345,6 +372,8 @@ void tst_qdeclarativetextinput::selection() QVERIFY(textinputObject->selectedText().size() == 10); textinputObject->setSelectionEnd(100); QVERIFY(textinputObject->selectedText().size() == 10); + + delete textinputObject; } void tst_qdeclarativetextinput::maxLength() @@ -372,6 +401,8 @@ void tst_qdeclarativetextinput::maxLength() QTest::keyPress(canvas, Qt::Key_A); QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10); } + + delete canvas; } void tst_qdeclarativetextinput::masks() @@ -394,6 +425,8 @@ void tst_qdeclarativetextinput::masks() QTest::keyPress(canvas, Qt::Key_A); QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10); } + + delete canvas; } void tst_qdeclarativetextinput::validators() @@ -486,6 +519,8 @@ void tst_qdeclarativetextinput::validators() QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10); QCOMPARE(strInput->text(), QLatin1String("aaaa")); QCOMPARE(strInput->hasAcceptableInput(), true); + + delete canvas; } void tst_qdeclarativetextinput::inputMethodHints() @@ -500,6 +535,8 @@ void tst_qdeclarativetextinput::inputMethodHints() QVERIFY(textinputObject->inputMethodHints() & Qt::ImhNoPredictiveText); textinputObject->setInputMethodHints(Qt::ImhUppercaseOnly); QVERIFY(textinputObject->inputMethodHints() & Qt::ImhUppercaseOnly); + + delete canvas; } /* @@ -537,6 +574,8 @@ void tst_qdeclarativetextinput::navigation() QVERIFY(input->hasFocus() == false); simulateKey(canvas, Qt::Key_Left); QVERIFY(input->hasFocus() == true); + + delete canvas; } void tst_qdeclarativetextinput::cursorDelegate() @@ -564,6 +603,8 @@ void tst_qdeclarativetextinput::cursorDelegate() //Test Delegate gets deleted textInputObject->setCursorDelegate(0); QVERIFY(!textInputObject->findChild<QDeclarativeItem*>("cursorInstance")); + + delete view; } void tst_qdeclarativetextinput::readOnly() @@ -586,6 +627,8 @@ void tst_qdeclarativetextinput::readOnly() simulateKey(canvas, Qt::Key_Space); simulateKey(canvas, Qt::Key_Escape); QCOMPARE(input->text(), initial); + + delete canvas; } void tst_qdeclarativetextinput::echoMode() @@ -722,6 +765,29 @@ void tst_qdeclarativetextinput::setHAlignClearCache() QCOMPARE(input.nbPaint, 2); } +void tst_qdeclarativetextinput::focusOutClearSelection() +{ + QGraphicsScene scene; + QGraphicsView view(&scene); + QDeclarativeTextInput input; + QDeclarativeTextInput input2; + input.setText(QLatin1String("Hello world")); + input.setFocus(true); + scene.addItem(&input2); + scene.addItem(&input); + view.show(); + QApplication::setActiveWindow(&view); + QTest::qWaitForWindowShown(&view); + input.setSelectionStart(2); + input.setSelectionEnd(5); + //The selection should work + QTRY_COMPARE(input.selectedText(), QLatin1String("llo")); + input2.setFocus(true); + QApplication::processEvents(); + //The input lost the focus selection should be cleared + QTRY_COMPARE(input.selectedText(), QLatin1String("")); +} + QTEST_MAIN(tst_qdeclarativetextinput) #include "tst_qdeclarativetextinput.moc" |