summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den-exter@nokia.com>2011-09-06 10:28:38 +1000
committerAndrew den Exter <andrew.den-exter@nokia.com>2011-09-06 12:56:30 +1000
commit95ba429db0652e8a8d2e1ef4eccdbde3925b195f (patch)
tree70aada94c5ff371bb574bdfcc88a8aff5168e8a7 /tests
parent8570c509f505a4b238905122645a80faa768adb5 (diff)
downloadqt4-tools-95ba429db0652e8a8d2e1ef4eccdbde3925b195f.tar.gz
Fix implicit height not growing when pre-edit text wraps.
QTextDocument::isEmpty() doesn't account for pre-edit text so use the return value of size() to determine if implicitHeight should fall back to the font height instead. Change-Id: I028552a7646372b22894c45946a57ec4951b044a Task-number: QTBUG-21288 Reviewed-by: Martin Jones
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
index fde0588338..33f74a9adf 100644
--- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
+++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
@@ -147,6 +147,8 @@ private slots:
void pastingRichText_QTBUG_14003();
void implicitSize_data();
void implicitSize();
+ void implicitSizePreedit_data();
+ void implicitSizePreedit();
void testQtQuick11Attributes();
void testQtQuick11Attributes_data();
@@ -2368,6 +2370,48 @@ void tst_qdeclarativetextedit::implicitSize()
QVERIFY(textObject->height() == textObject->implicitHeight());
}
+void tst_qdeclarativetextedit::implicitSizePreedit_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<QString>("wrap");
+ QTest::addColumn<bool>("wrapped");
+ QTest::newRow("plain") << "The quick red fox jumped over the lazy brown dog" << "TextEdit.NoWrap" << false;
+ QTest::newRow("plain_wrap") << "The quick red fox jumped over the lazy brown dog" << "TextEdit.Wrap" << true;
+
+}
+
+void tst_qdeclarativetextedit::implicitSizePreedit()
+{
+ QFETCH(QString, text);
+ QFETCH(QString, wrap);
+ QFETCH(bool, wrapped);
+
+ QString componentStr = "import QtQuick 1.1\nTextEdit { focus: true; width: 50; wrapMode: " + wrap + " }";
+ QDeclarativeComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QDeclarativeTextEdit *textObject = qobject_cast<QDeclarativeTextEdit*>(textComponent.create());
+
+ QGraphicsScene scene;
+ QGraphicsView view(&scene);
+ scene.addItem(textObject);
+ view.show();
+ QApplication::setActiveWindow(&view);
+ QTest::qWaitForWindowShown(&view);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
+
+ QInputMethodEvent event(text, QList<QInputMethodEvent::Attribute>());
+ QCoreApplication::sendEvent(&view, &event);
+
+ QVERIFY(textObject->width() < textObject->implicitWidth());
+ QVERIFY(textObject->height() == textObject->implicitHeight());
+ qreal wrappedHeight = textObject->height();
+
+ textObject->resetWidth();
+ QVERIFY(textObject->width() == textObject->implicitWidth());
+ QVERIFY(textObject->height() == textObject->implicitHeight());
+ QCOMPARE(textObject->height() < wrappedHeight, wrapped);
+}
+
void tst_qdeclarativetextedit::testQtQuick11Attributes()
{
QFETCH(QString, code);