summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-06-01 03:09:17 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-06-01 03:09:17 (GMT)
commit33a65a1def8e6d40819ead6e7548cb7345f3b922 (patch)
treef00cf93cb202d8d54ebacd3dedc01ff31d23a9a4 /tests
parent91cb226780d05f0f7d8fd1875121427ade52c1a8 (diff)
parent5f6b50f99a6457c208c7f186db45a2dba690bace (diff)
downloadQt-33a65a1def8e6d40819ead6e7548cb7345f3b922.zip
Qt-33a65a1def8e6d40819ead6e7548cb7345f3b922.tar.gz
Qt-33a65a1def8e6d40819ead6e7548cb7345f3b922.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp43
-rw-r--r--tests/auto/qtextlayout/tst_qtextlayout.cpp25
2 files changed, 68 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
index 54bb9c1..c943c89 100644
--- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
+++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
@@ -63,6 +63,8 @@ private slots:
void color();
void selection();
+ void positionAt();
+
void maxLength();
void masks();
void validators();
@@ -361,6 +363,47 @@ void tst_qdeclarativetextinput::selection()
delete textinputObject;
}
+void tst_qdeclarativetextinput::positionAt()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/positionAt.qml");
+ QVERIFY(canvas->rootObject() != 0);
+ canvas->show();
+ canvas->setFocus();
+ QApplication::setActiveWindow(canvas);
+ QTest::qWaitForWindowShown(canvas);
+
+ QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput *>(canvas->rootObject());
+ QVERIFY(textinputObject != 0);
+
+ // Check autoscrolled...
+ QFontMetrics fm(textinputObject->font());
+
+ int pos = textinputObject->positionAt(textinputObject->width()/2);
+ int diff = abs(fm.width(textinputObject->text()) - (fm.width(textinputObject->text().left(pos))+textinputObject->width()/2));
+
+ // some tollerance for different fonts.
+#ifdef Q_OS_LINUX
+ QVERIFY(diff < 2);
+#else
+ QVERIFY(diff < 5);
+#endif
+
+ // Check without autoscroll...
+ QEXPECT_FAIL("", "QTBUG-11127", Abort);
+ textinputObject->setAutoScroll(false);
+ pos = textinputObject->positionAt(textinputObject->width()/2);
+ diff = abs(fm.width(textinputObject->text().left(pos))-textinputObject->width()/2);
+
+ // some tollerance for different fonts.
+#ifdef Q_OS_LINUX
+ QVERIFY(diff < 2);
+#else
+ QVERIFY(diff < 5);
+#endif
+
+ delete canvas;
+}
+
void tst_qdeclarativetextinput::maxLength()
{
//QString componentStr = "import Qt 4.7\nTextInput { maximumLength: 10; }";
diff --git a/tests/auto/qtextlayout/tst_qtextlayout.cpp b/tests/auto/qtextlayout/tst_qtextlayout.cpp
index caf9bd3..1a5f493 100644
--- a/tests/auto/qtextlayout/tst_qtextlayout.cpp
+++ b/tests/auto/qtextlayout/tst_qtextlayout.cpp
@@ -110,6 +110,8 @@ private slots:
void longText();
void widthOfTabs();
void columnWrapWithTabs();
+ void boundingRectForUnsetLineWidth();
+ void boundingRectForSetLineWidth();
// QTextLine stuff
void setNumColumnsWrapAtWordBoundaryOrAnywhere();
@@ -1307,6 +1309,29 @@ void tst_QTextLayout::columnWrapWithTabs()
}
+void tst_QTextLayout::boundingRectForUnsetLineWidth()
+{
+ QTextLayout layout("FOOBAR");
+
+ layout.beginLayout();
+ QTextLine line = layout.createLine();
+ layout.endLayout();
+
+ QCOMPARE(layout.boundingRect().width(), line.naturalTextWidth());
+}
+
+void tst_QTextLayout::boundingRectForSetLineWidth()
+{
+ QTextLayout layout("FOOBAR");
+
+ layout.beginLayout();
+ QTextLine line = layout.createLine();
+ line.setLineWidth(QFIXED_MAX - 1);
+ layout.endLayout();
+
+ QCOMPARE(layout.boundingRect().width(), qreal(QFIXED_MAX - 1));
+}
+
void tst_QTextLayout::lineWidthFromBOM()
{
const QString string(QChar(0xfeff)); // BYTE ORDER MARK