diff options
Diffstat (limited to 'tests')
4 files changed, 74 insertions, 1 deletions
diff --git a/tests/auto/declarative/qdeclarativetext/data/elideimplicitwidth.qml b/tests/auto/declarative/qdeclarativetext/data/elideimplicitwidth.qml new file mode 100644 index 0000000..60ae15c --- /dev/null +++ b/tests/auto/declarative/qdeclarativetext/data/elideimplicitwidth.qml @@ -0,0 +1,7 @@ +import QtQuick 1.1 + +Text { + text: "Hello World" + elide: Text.ElideRight + width: 30 +} diff --git a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp index ca6e87a..82b6f73 100644 --- a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp +++ b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp @@ -390,6 +390,13 @@ void tst_qdeclarativetext::elide() QCOMPARE(textObject->width(), 100.); } } + + // QTBUG-18627 + QUrl qmlfile = QUrl::fromLocalFile(SRCDIR "/data/elideimplicitwidth.qml"); + QDeclarativeComponent textComponent(&engine, qmlfile); + QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(textComponent.create()); + QVERIFY(item != 0); + QVERIFY(item->implicitWidth() > item->width()); } void tst_qdeclarativetext::textFormat() diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index 574d2d5..26a6fd8 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -788,6 +788,14 @@ void tst_qdeclarativetextedit::selection() QCOMPARE(textEditObject->selectionEnd(), i); QVERIFY(textEditObject->selectedText().isNull()); } + //Test cursor follows selection + for(int i=0; i<= testStr.size(); i++) { + textEditObject->select(i,i); + QCOMPARE(textEditObject->cursorPosition(), i); + QCOMPARE(textEditObject->selectionStart(), i); + QCOMPARE(textEditObject->selectionEnd(), i); + } + textEditObject->setCursorPosition(0); QVERIFY(textEditObject->cursorPosition() == 0); @@ -812,10 +820,12 @@ void tst_qdeclarativetextedit::selection() for(int i=0; i<= testStr.size(); i++) { textEditObject->select(0,i); QCOMPARE(testStr.mid(0,i), textEditObject->selectedText()); + QCOMPARE(textEditObject->cursorPosition(), i); } for(int i=0; i<= testStr.size(); i++) { textEditObject->select(i,testStr.size()); QCOMPARE(testStr.mid(i,testStr.size()-i), textEditObject->selectedText()); + QCOMPARE(textEditObject->cursorPosition(), testStr.size()); } textEditObject->setCursorPosition(0); diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp index 943b1fa..baaf862 100644 --- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp +++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp @@ -375,6 +375,13 @@ void tst_qdeclarativetextinput::selection() QCOMPARE(textinputObject->selectionEnd(), i); QVERIFY(textinputObject->selectedText().isNull()); } + //Test cursor follows selection + for(int i=0; i<= testStr.size(); i++) { + textinputObject->select(i,i); + QCOMPARE(textinputObject->cursorPosition(), i); + QCOMPARE(textinputObject->selectionStart(), i); + QCOMPARE(textinputObject->selectionEnd(), i); + } textinputObject->setCursorPosition(0); QVERIFY(textinputObject->cursorPosition() == 0); @@ -399,10 +406,12 @@ void tst_qdeclarativetextinput::selection() for(int i=0; i<= testStr.size(); i++) { textinputObject->select(0,i); QCOMPARE(testStr.mid(0,i), textinputObject->selectedText()); + QCOMPARE(textinputObject->cursorPosition(), i); } for(int i=0; i<= testStr.size(); i++) { textinputObject->select(i,testStr.size()); QCOMPARE(testStr.mid(i,testStr.size()-i), textinputObject->selectedText()); + QCOMPARE(textinputObject->cursorPosition(), testStr.size()); } textinputObject->setCursorPosition(0); @@ -1364,8 +1373,10 @@ void tst_qdeclarativetextinput::inputMethods() QVERIFY(canvas->rootObject() != 0); QDeclarativeTextInput *input = qobject_cast<QDeclarativeTextInput *>(canvas->rootObject()); QVERIFY(input != 0); + QVERIFY(input->imHints() & Qt::ImhNoPredictiveText); QVERIFY(input->inputMethodHints() & Qt::ImhNoPredictiveText); - input->setInputMethodHints(Qt::ImhUppercaseOnly); + input->setIMHints(Qt::ImhUppercaseOnly); + QVERIFY(input->imHints() & Qt::ImhUppercaseOnly); QVERIFY(input->inputMethodHints() & Qt::ImhUppercaseOnly); QVERIFY(canvas->rootObject() != 0); @@ -1805,6 +1816,7 @@ void tst_qdeclarativetextinput::echoMode() ref &= ~Qt::ImhHiddenText; ref &= ~(Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText); QCOMPARE(input->inputMethodHints(), ref); + QCOMPARE(input->imHints(), Qt::ImhNone); input->setEchoMode(QDeclarativeTextInput::NoEcho); QCOMPARE(input->text(), initial); QCOMPARE(input->displayText(), QLatin1String("")); @@ -1813,6 +1825,7 @@ void tst_qdeclarativetextinput::echoMode() ref |= Qt::ImhHiddenText; ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText); QCOMPARE(input->inputMethodHints(), ref); + QCOMPARE(input->imHints(), Qt::ImhNone); input->setEchoMode(QDeclarativeTextInput::Password); //Password ref |= Qt::ImhHiddenText; @@ -1820,6 +1833,7 @@ void tst_qdeclarativetextinput::echoMode() QCOMPARE(input->text(), initial); QCOMPARE(input->displayText(), QLatin1String("********")); QCOMPARE(input->inputMethodHints(), ref); + QCOMPARE(input->imHints(), Qt::ImhNone); input->setPasswordCharacter(QChar('Q')); QCOMPARE(input->passwordCharacter(), QLatin1String("Q")); QCOMPARE(input->text(), initial); @@ -1829,6 +1843,7 @@ void tst_qdeclarativetextinput::echoMode() ref &= ~Qt::ImhHiddenText; ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText); QCOMPARE(input->inputMethodHints(), ref); + QCOMPARE(input->imHints(), Qt::ImhNone); QCOMPARE(input->text(), initial); QCOMPARE(input->displayText(), QLatin1String("QQQQQQQQ")); QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), QLatin1String("QQQQQQQQ")); @@ -1849,6 +1864,40 @@ void tst_qdeclarativetextinput::echoMode() QCOMPARE(input->displayText(), initial); QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), initial); + // Test echo mode doesn't override imHints. + input->setIMHints(Qt::ImhHiddenText | Qt::ImhDialableCharactersOnly); + ref |= Qt::ImhDialableCharactersOnly; + //Normal + input->setEchoMode(QDeclarativeTextInput::Normal); + ref |= Qt::ImhHiddenText; + ref &= ~(Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText); + QCOMPARE(input->inputMethodHints(), ref); + QCOMPARE(input->imHints(), Qt::ImhHiddenText | Qt::ImhDialableCharactersOnly); + //NoEcho + input->setEchoMode(QDeclarativeTextInput::NoEcho); + ref |= Qt::ImhHiddenText; + ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText); + QCOMPARE(input->inputMethodHints(), ref); + QCOMPARE(input->imHints(), Qt::ImhHiddenText | Qt::ImhDialableCharactersOnly); + //Password + input->setEchoMode(QDeclarativeTextInput::Password); + ref |= Qt::ImhHiddenText; + ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText); + QCOMPARE(input->inputMethodHints(), ref); + QCOMPARE(input->imHints(), Qt::ImhHiddenText | Qt::ImhDialableCharactersOnly); + //PasswordEchoOnEdit + input->setEchoMode(QDeclarativeTextInput::PasswordEchoOnEdit); + ref &= ~Qt::ImhHiddenText; + ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText); + QCOMPARE(input->inputMethodHints(), ref); + QCOMPARE(input->imHints(), Qt::ImhHiddenText | Qt::ImhDialableCharactersOnly); + //Normal + input->setEchoMode(QDeclarativeTextInput::Normal); + ref |= Qt::ImhHiddenText; + ref &= ~(Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText); + QCOMPARE(input->inputMethodHints(), ref); + QCOMPARE(input->imHints(), Qt::ImhHiddenText | Qt::ImhDialableCharactersOnly); + delete canvas; } |