summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-06-23 15:42:15 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-06-23 15:42:15 (GMT)
commit4b13e519f09c12a74c0bc522fd97e5009bd8bc2f (patch)
tree37c1501969bd3760568cc45c6441a2bea4316bda /tests
parentf6835920b5497f228e2aa3ba397437af30a0bfe9 (diff)
parent944c753e15df02605ca415f4463dec3e25b8711b (diff)
downloadQt-4b13e519f09c12a74c0bc522fd97e5009bd8bc2f.zip
Qt-4b13e519f09c12a74c0bc522fd97e5009bd8bc2f.tar.gz
Qt-4b13e519f09c12a74c0bc522fd97e5009bd8bc2f.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: Use Pen with Qt::MiterJoin when drawing Rectangles with gradients Update screenshot Fix and better test Text / TextEdit alignments. Ensure the view is correctly positioned at component complete. Support for non-literal plural arguments to qsTr() in lupdate (QML). References to undefined variables throws a ReferenceError
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/eval.qml6
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/function.qml6
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.qml2
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp13
-rw-r--r--tests/auto/declarative/qdeclarativegridview/data/gridview-initCurrent.qml2
-rw-r--r--tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp57
-rw-r--r--tests/auto/declarative/qdeclarativelistview/data/listview-initCurrent.qml2
-rw-r--r--tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp32
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments.qml42
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments_cb.pngbin0 -> 1184 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments_cc.pngbin0 -> 1293 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments_ct.pngbin0 -> 1237 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments_lb.pngbin0 -> 1208 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments_lc.pngbin0 -> 1303 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments_lt.pngbin0 -> 1241 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments_rb.pngbin0 -> 1178 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments_rc.pngbin0 -> 1274 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments_rt.pngbin0 -> 1221 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp66
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/alignments.qml42
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/alignments_cb.pngbin0 -> 1411 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/alignments_cc.pngbin0 -> 1501 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/alignments_ct.pngbin0 -> 1457 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/alignments_lb.pngbin0 -> 1420 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/alignments_lc.pngbin0 -> 1508 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/alignments_lt.pngbin0 -> 1447 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/alignments_rb.pngbin0 -> 1421 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/alignments_rc.pngbin0 -> 1485 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/alignments_rt.pngbin0 -> 1439 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp54
30 files changed, 272 insertions, 52 deletions
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/eval.qml b/tests/auto/declarative/qdeclarativeecmascript/data/eval.qml
index bc2df98..aab39be 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/eval.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/eval.qml
@@ -16,7 +16,11 @@ QtObject {
test1 = (eval("a") == 7);
test2 = (eval("b") == 9);
- test3 = (eval("c") == undefined);
+ try {
+ eval("c");
+ } catch(e) {
+ test3 = true;
+ }
test4 = (eval("console") == console);
test5 = (eval("Qt") == Qt);
}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/function.qml b/tests/auto/declarative/qdeclarativeecmascript/data/function.qml
index b435f58..80d6ef4 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/function.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/function.qml
@@ -14,6 +14,10 @@ QtObject {
test1 = (func1(4) == 11);
test2 = (func2("Hello World!") == Qt.atob("Hello World!"));
- test3 = (func3() == undefined);
+ try {
+ func3();
+ } catch(e) {
+ test3 = true;
+ }
}
}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.qml
index e8f7b62..f601f49 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.qml
@@ -4,7 +4,7 @@ import "scriptErrors.js" as Script
MyQmlObject {
property int t: a.value
property int w: Script.getValue();
- property int x: undefinedObject
+ property int x: undefined
property int y: (a.value, undefinedObject)
onBasicSignal: { console.log(a.value); }
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
index 16e7ec5..50da55d 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
@@ -1002,10 +1002,10 @@ void tst_qdeclarativeecmascript::scriptErrors()
QString url = component.url().toString();
QString warning1 = url.left(url.length() - 3) + "js:2: Error: Invalid write to global property \"a\"";
- QString warning2 = url + ":5: TypeError: Result of expression 'a' [undefined] is not an object.";
+ QString warning2 = url + ":5: ReferenceError: Can't find variable: a";
QString warning3 = url.left(url.length() - 3) + "js:4: Error: Invalid write to global property \"a\"";
- QString warning4 = url + ":10: TypeError: Result of expression 'a' [undefined] is not an object.";
- QString warning5 = url + ":8: TypeError: Result of expression 'a' [undefined] is not an object.";
+ QString warning4 = url + ":10: ReferenceError: Can't find variable: a";
+ QString warning5 = url + ":8: ReferenceError: Can't find variable: a";
QString warning6 = url + ":7: Unable to assign [undefined] to int x";
QString warning7 = url + ":12: Error: Cannot assign to read-only property \"trueProperty\"";
QString warning8 = url + ":13: Error: Cannot assign to non-existent property \"fakeProperty\"";
@@ -1322,7 +1322,12 @@ void tst_qdeclarativeecmascript::callQtInvokables()
QDeclarativeEngine qmlengine;
QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(&qmlengine);
QScriptEngine *engine = &ep->scriptEngine;
- ep->globalClass->explicitSetProperty("object", ep->objectClass->newQObject(&o));
+
+ QStringList names; QList<QScriptValue> values;
+ names << QLatin1String("object"); values << ep->objectClass->newQObject(&o);
+ names << QLatin1String("undefined"); values << engine->undefinedValue();
+
+ ep->globalClass->explicitSetProperty(names, values);
// Non-existent methods
o.reset();
diff --git a/tests/auto/declarative/qdeclarativegridview/data/gridview-initCurrent.qml b/tests/auto/declarative/qdeclarativegridview/data/gridview-initCurrent.qml
index 9331243..a5d651d 100644
--- a/tests/auto/declarative/qdeclarativegridview/data/gridview-initCurrent.qml
+++ b/tests/auto/declarative/qdeclarativegridview/data/gridview-initCurrent.qml
@@ -43,7 +43,7 @@ Rectangle {
focus: true
width: 240
height: 320
- currentIndex: 5
+ currentIndex: 35
cellWidth: 80
cellHeight: 60
delegate: myDelegate
diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
index 4e35bc0..deff1f8 100644
--- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
+++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
@@ -557,7 +557,7 @@ void tst_QDeclarativeGridView::moved()
void tst_QDeclarativeGridView::currentIndex()
{
TestModel model;
- for (int i = 0; i < 30; i++)
+ for (int i = 0; i < 60; i++)
model.addItem("Item" + QString::number(i), QString::number(i));
QDeclarativeView *canvas = new QDeclarativeView(0);
@@ -572,57 +572,58 @@ void tst_QDeclarativeGridView::currentIndex()
qApp->processEvents();
QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
+ QVERIFY(gridview != 0);
QDeclarativeItem *viewport = gridview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QVERIFY(viewport != 0);
// current item should be third item
- QTRY_COMPARE(gridview->currentIndex(), 5);
- QTRY_COMPARE(gridview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 5));
- QTRY_COMPARE(gridview->currentItem()->y(), gridview->highlightItem()->y());
+ QCOMPARE(gridview->currentIndex(), 35);
+ QCOMPARE(gridview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 35));
+ QCOMPARE(gridview->currentItem()->y(), gridview->highlightItem()->y());
+ QCOMPARE(gridview->contentY(), 399.0);
gridview->moveCurrentIndexRight();
- QTRY_COMPARE(gridview->currentIndex(), 6);
+ QCOMPARE(gridview->currentIndex(), 36);
gridview->moveCurrentIndexDown();
- QTRY_COMPARE(gridview->currentIndex(), 9);
+ QCOMPARE(gridview->currentIndex(), 39);
gridview->moveCurrentIndexUp();
- QTRY_COMPARE(gridview->currentIndex(), 6);
+ QCOMPARE(gridview->currentIndex(), 36);
gridview->moveCurrentIndexLeft();
- QTRY_COMPARE(gridview->currentIndex(), 5);
+ QCOMPARE(gridview->currentIndex(), 35);
// no wrap
gridview->setCurrentIndex(0);
- QTRY_COMPARE(gridview->currentIndex(), 0);
+ QCOMPARE(gridview->currentIndex(), 0);
gridview->moveCurrentIndexUp();
- QTRY_COMPARE(gridview->currentIndex(), 0);
+ QCOMPARE(gridview->currentIndex(), 0);
gridview->moveCurrentIndexLeft();
- QTRY_COMPARE(gridview->currentIndex(), 0);
+ QCOMPARE(gridview->currentIndex(), 0);
gridview->setCurrentIndex(model.count()-1);
- QTRY_COMPARE(gridview->currentIndex(), model.count()-1);
+ QCOMPARE(gridview->currentIndex(), model.count()-1);
gridview->moveCurrentIndexRight();
- QTRY_COMPARE(gridview->currentIndex(), model.count()-1);
+ QCOMPARE(gridview->currentIndex(), model.count()-1);
gridview->moveCurrentIndexDown();
- QTRY_COMPARE(gridview->currentIndex(), model.count()-1);
+ QCOMPARE(gridview->currentIndex(), model.count()-1);
// with wrap
gridview->setWrapEnabled(true);
gridview->setCurrentIndex(0);
- QTRY_COMPARE(gridview->currentIndex(), 0);
+ QCOMPARE(gridview->currentIndex(), 0);
gridview->moveCurrentIndexLeft();
- QTRY_COMPARE(gridview->currentIndex(), model.count()-1);
+ QCOMPARE(gridview->currentIndex(), model.count()-1);
- QTRY_COMPARE(gridview->contentY(), 279.0);
+ QTRY_COMPARE(gridview->contentY(), 879.0);
gridview->moveCurrentIndexRight();
- QTRY_COMPARE(gridview->currentIndex(), 0);
+ QCOMPARE(gridview->currentIndex(), 0);
QTRY_COMPARE(gridview->contentY(), 0.0);
@@ -638,30 +639,30 @@ void tst_QDeclarativeGridView::currentIndex()
qApp->processEvents();
QTest::keyClick(canvas, Qt::Key_Down);
- QTRY_COMPARE(gridview->currentIndex(), 3);
+ QCOMPARE(gridview->currentIndex(), 3);
QTest::keyClick(canvas, Qt::Key_Up);
- QTRY_COMPARE(gridview->currentIndex(), 0);
+ QCOMPARE(gridview->currentIndex(), 0);
gridview->setFlow(QDeclarativeGridView::TopToBottom);
QTest::keyClick(canvas, Qt::Key_Right);
- QTRY_COMPARE(gridview->currentIndex(), 5);
+ QCOMPARE(gridview->currentIndex(), 5);
QTest::keyClick(canvas, Qt::Key_Left);
- QTRY_COMPARE(gridview->currentIndex(), 0);
+ QCOMPARE(gridview->currentIndex(), 0);
QTest::keyClick(canvas, Qt::Key_Down);
- QTRY_COMPARE(gridview->currentIndex(), 1);
+ QCOMPARE(gridview->currentIndex(), 1);
QTest::keyClick(canvas, Qt::Key_Up);
- QTRY_COMPARE(gridview->currentIndex(), 0);
+ QCOMPARE(gridview->currentIndex(), 0);
// turn off auto highlight
gridview->setHighlightFollowsCurrentItem(false);
- QTRY_VERIFY(gridview->highlightFollowsCurrentItem() == false);
- QTRY_VERIFY(gridview->highlightItem());
+ QVERIFY(gridview->highlightFollowsCurrentItem() == false);
+ QVERIFY(gridview->highlightItem());
qreal hlPosX = gridview->highlightItem()->x();
qreal hlPosY = gridview->highlightItem()->y();
diff --git a/tests/auto/declarative/qdeclarativelistview/data/listview-initCurrent.qml b/tests/auto/declarative/qdeclarativelistview/data/listview-initCurrent.qml
index 0599ddd..f3c2910 100644
--- a/tests/auto/declarative/qdeclarativelistview/data/listview-initCurrent.qml
+++ b/tests/auto/declarative/qdeclarativelistview/data/listview-initCurrent.qml
@@ -40,7 +40,7 @@ Rectangle {
id: list
objectName: "list"
focus: true
- currentIndex: 3
+ currentIndex: 20
width: 240
height: 320
keyNavigationWraps: testWrap
diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
index cd42b63..8ff6e56 100644
--- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
+++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
@@ -973,34 +973,36 @@ void tst_QDeclarativeListView::currentIndex()
QDeclarativeItem *viewport = listview->viewport();
QTRY_VERIFY(viewport != 0);
- // current item should be third item
- QTRY_COMPARE(listview->currentIndex(), 3);
- QTRY_COMPARE(listview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 3));
- QTRY_COMPARE(listview->highlightItem()->y(), listview->currentItem()->y());
+ // current item should be 20th item at startup
+ // and current item should be in view
+ QCOMPARE(listview->currentIndex(), 20);
+ QCOMPARE(listview->contentY(), 99.0);
+ QCOMPARE(listview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 20));
+ QCOMPARE(listview->highlightItem()->y(), listview->currentItem()->y());
// no wrap
listview->setCurrentIndex(0);
- QTRY_COMPARE(listview->currentIndex(), 0);
+ QCOMPARE(listview->currentIndex(), 0);
listview->incrementCurrentIndex();
- QTRY_COMPARE(listview->currentIndex(), 1);
+ QCOMPARE(listview->currentIndex(), 1);
listview->decrementCurrentIndex();
- QTRY_COMPARE(listview->currentIndex(), 0);
+ QCOMPARE(listview->currentIndex(), 0);
listview->decrementCurrentIndex();
- QTRY_COMPARE(listview->currentIndex(), 0);
+ QCOMPARE(listview->currentIndex(), 0);
// with wrap
ctxt->setContextProperty("testWrap", QVariant(true));
- QTRY_VERIFY(listview->isWrapEnabled());
+ QVERIFY(listview->isWrapEnabled());
listview->decrementCurrentIndex();
- QTRY_COMPARE(listview->currentIndex(), model.count()-1);
+ QCOMPARE(listview->currentIndex(), model.count()-1);
QTRY_COMPARE(listview->contentY(), 279.0);
listview->incrementCurrentIndex();
- QTRY_COMPARE(listview->currentIndex(), 0);
+ QCOMPARE(listview->currentIndex(), 0);
QTRY_COMPARE(listview->contentY(), 0.0);
@@ -1016,16 +1018,16 @@ void tst_QDeclarativeListView::currentIndex()
qApp->processEvents();
QTest::keyClick(canvas, Qt::Key_Down);
- QTRY_COMPARE(listview->currentIndex(), 1);
+ QCOMPARE(listview->currentIndex(), 1);
QTest::keyClick(canvas, Qt::Key_Up);
- QTRY_COMPARE(listview->currentIndex(), 0);
+ QCOMPARE(listview->currentIndex(), 0);
// turn off auto highlight
listview->setHighlightFollowsCurrentItem(false);
- QTRY_VERIFY(listview->highlightFollowsCurrentItem() == false);
+ QVERIFY(listview->highlightFollowsCurrentItem() == false);
- QTRY_VERIFY(listview->highlightItem());
+ QVERIFY(listview->highlightItem());
qreal hlPos = listview->highlightItem()->y();
listview->setCurrentIndex(4);
diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments.qml b/tests/auto/declarative/qdeclarativetext/data/alignments.qml
new file mode 100644
index 0000000..6a98a4d
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetext/data/alignments.qml
@@ -0,0 +1,42 @@
+import Qt 4.7
+
+Rectangle {
+ id: top
+ width: 70; height: 70;
+
+ property alias horizontalAlignment: t.horizontalAlignment
+ property alias verticalAlignment: t.verticalAlignment
+ property alias wrapMode: t.wrapMode
+ property alias running: timer.running
+ property string txt: "Test"
+
+ Rectangle {
+ anchors.centerIn: parent
+ width: 40
+ height: 40
+ color: "green"
+
+ Text {
+ id: t
+
+ anchors.fill: parent
+ font.pixelSize: 8
+ horizontalAlignment: TextEdit.AlignRight
+ verticalAlignment: TextEdit.AlignBottom
+ wrapMode: TextEdit.WordWrap
+ text: top.txt
+ }
+ Timer {
+ id: timer
+
+ interval: 1
+ running: true
+ repeat: true
+ onTriggered: {
+ top.txt = top.txt + "<br>more " + top.txt.length;
+ if (top.txt.length > 50)
+ running = false
+ }
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_cb.png b/tests/auto/declarative/qdeclarativetext/data/alignments_cb.png
new file mode 100644
index 0000000..5cdb1e5
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetext/data/alignments_cb.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_cc.png b/tests/auto/declarative/qdeclarativetext/data/alignments_cc.png
new file mode 100644
index 0000000..6b6862c
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetext/data/alignments_cc.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_ct.png b/tests/auto/declarative/qdeclarativetext/data/alignments_ct.png
new file mode 100644
index 0000000..7bfd281
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetext/data/alignments_ct.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_lb.png b/tests/auto/declarative/qdeclarativetext/data/alignments_lb.png
new file mode 100644
index 0000000..a8c16a0
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetext/data/alignments_lb.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_lc.png b/tests/auto/declarative/qdeclarativetext/data/alignments_lc.png
new file mode 100644
index 0000000..1f6e28d
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetext/data/alignments_lc.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_lt.png b/tests/auto/declarative/qdeclarativetext/data/alignments_lt.png
new file mode 100644
index 0000000..e529880
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetext/data/alignments_lt.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_rb.png b/tests/auto/declarative/qdeclarativetext/data/alignments_rb.png
new file mode 100644
index 0000000..c1ce274
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetext/data/alignments_rb.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_rc.png b/tests/auto/declarative/qdeclarativetext/data/alignments_rc.png
new file mode 100644
index 0000000..4f8a4a7
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetext/data/alignments_rc.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_rt.png b/tests/auto/declarative/qdeclarativetext/data/alignments_rt.png
new file mode 100644
index 0000000..643bd18
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetext/data/alignments_rt.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp
index 01120b1..91b3ca0 100644
--- a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp
+++ b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp
@@ -47,6 +47,7 @@
#include <QFontMetrics>
#include <QGraphicsSceneMouseEvent>
#include <qmath.h>
+#include <QDeclarativeView>
#include "../../../shared/util.h"
#include "testhttpserver.h"
@@ -70,6 +71,9 @@ private slots:
void elide();
void textFormat();
+ void alignments_data();
+ void alignments();
+
void embeddedImages_data();
void embeddedImages();
@@ -108,6 +112,8 @@ private:
QStringList colorStrings;
QDeclarativeEngine engine;
+
+ QDeclarativeView *createView(const QString &filename);
};
tst_qdeclarativetext::tst_qdeclarativetext()
@@ -163,6 +169,14 @@ tst_qdeclarativetext::tst_qdeclarativetext()
//
}
+QDeclarativeView *tst_qdeclarativetext::createView(const QString &filename)
+{
+ QDeclarativeView *canvas = new QDeclarativeView(0);
+
+ canvas->setSource(QUrl::fromLocalFile(filename));
+ return canvas;
+}
+
void tst_qdeclarativetext::text()
{
{
@@ -383,6 +397,58 @@ void tst_qdeclarativetext::textFormat()
}
}
+
+void tst_qdeclarativetext::alignments_data()
+{
+ QTest::addColumn<int>("hAlign");
+ QTest::addColumn<int>("vAlign");
+ QTest::addColumn<QString>("expectfile");
+
+ QTest::newRow("LT") << int(Qt::AlignLeft) << int(Qt::AlignTop) << SRCDIR "/data/alignments_lt.png";
+ QTest::newRow("RT") << int(Qt::AlignRight) << int(Qt::AlignTop) << SRCDIR "/data/alignments_rt.png";
+ QTest::newRow("CT") << int(Qt::AlignHCenter) << int(Qt::AlignTop) << SRCDIR "/data/alignments_ct.png";
+
+ QTest::newRow("LB") << int(Qt::AlignLeft) << int(Qt::AlignBottom) << SRCDIR "/data/alignments_lb.png";
+ QTest::newRow("RB") << int(Qt::AlignRight) << int(Qt::AlignBottom) << SRCDIR "/data/alignments_rb.png";
+ QTest::newRow("CB") << int(Qt::AlignHCenter) << int(Qt::AlignBottom) << SRCDIR "/data/alignments_cb.png";
+
+ QTest::newRow("LC") << int(Qt::AlignLeft) << int(Qt::AlignVCenter) << SRCDIR "/data/alignments_lc.png";
+ QTest::newRow("RC") << int(Qt::AlignRight) << int(Qt::AlignVCenter) << SRCDIR "/data/alignments_rc.png";
+ QTest::newRow("CC") << int(Qt::AlignHCenter) << int(Qt::AlignVCenter) << SRCDIR "/data/alignments_cc.png";
+}
+
+
+void tst_qdeclarativetext::alignments()
+{
+ QFETCH(int, hAlign);
+ QFETCH(int, vAlign);
+ QFETCH(QString, expectfile);
+
+ QDeclarativeView *canvas = createView(SRCDIR "/data/alignments.qml");
+
+ canvas->show();
+ QApplication::setActiveWindow(canvas);
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas));
+
+ QObject *ob = canvas->rootObject();
+ QVERIFY(ob != 0);
+ ob->setProperty("horizontalAlignment",hAlign);
+ ob->setProperty("verticalAlignment",vAlign);
+ QTRY_COMPARE(ob->property("running").toBool(),false);
+ QImage actual(canvas->width(), canvas->height(), QImage::Format_RGB32);
+ actual.fill(qRgb(255,255,255));
+ QPainter p(&actual);
+ canvas->render(&p);
+
+ QImage expect(expectfile);
+
+#ifdef Q_OS_LINUX
+ // Font-specific, but not likely platform-specific, so only test on one platform
+ QCOMPARE(actual,expect);
+#endif
+}
+
//the alignment tests may be trivial o.oa
void tst_qdeclarativetext::horizontalAlignment()
{
diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments.qml b/tests/auto/declarative/qdeclarativetextedit/data/alignments.qml
new file mode 100644
index 0000000..6a98a4d
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments.qml
@@ -0,0 +1,42 @@
+import Qt 4.7
+
+Rectangle {
+ id: top
+ width: 70; height: 70;
+
+ property alias horizontalAlignment: t.horizontalAlignment
+ property alias verticalAlignment: t.verticalAlignment
+ property alias wrapMode: t.wrapMode
+ property alias running: timer.running
+ property string txt: "Test"
+
+ Rectangle {
+ anchors.centerIn: parent
+ width: 40
+ height: 40
+ color: "green"
+
+ Text {
+ id: t
+
+ anchors.fill: parent
+ font.pixelSize: 8
+ horizontalAlignment: TextEdit.AlignRight
+ verticalAlignment: TextEdit.AlignBottom
+ wrapMode: TextEdit.WordWrap
+ text: top.txt
+ }
+ Timer {
+ id: timer
+
+ interval: 1
+ running: true
+ repeat: true
+ onTriggered: {
+ top.txt = top.txt + "<br>more " + top.txt.length;
+ if (top.txt.length > 50)
+ running = false
+ }
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_cb.png b/tests/auto/declarative/qdeclarativetextedit/data/alignments_cb.png
new file mode 100644
index 0000000..0e40444
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_cb.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_cc.png b/tests/auto/declarative/qdeclarativetextedit/data/alignments_cc.png
new file mode 100644
index 0000000..a5c83a8
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_cc.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_ct.png b/tests/auto/declarative/qdeclarativetextedit/data/alignments_ct.png
new file mode 100644
index 0000000..8177c20
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_ct.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_lb.png b/tests/auto/declarative/qdeclarativetextedit/data/alignments_lb.png
new file mode 100644
index 0000000..c0e1774
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_lb.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_lc.png b/tests/auto/declarative/qdeclarativetextedit/data/alignments_lc.png
new file mode 100644
index 0000000..d61aaf2
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_lc.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_lt.png b/tests/auto/declarative/qdeclarativetextedit/data/alignments_lt.png
new file mode 100644
index 0000000..599f4c6
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_lt.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_rb.png b/tests/auto/declarative/qdeclarativetextedit/data/alignments_rb.png
new file mode 100644
index 0000000..83ec990
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_rb.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_rc.png b/tests/auto/declarative/qdeclarativetextedit/data/alignments_rc.png
new file mode 100644
index 0000000..53e30b7
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_rc.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_rt.png b/tests/auto/declarative/qdeclarativetextedit/data/alignments_rt.png
new file mode 100644
index 0000000..61a112f
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_rt.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
index f7ba7a1..009d354 100644
--- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
+++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
@@ -73,6 +73,8 @@ private slots:
void width();
void wrap();
void textFormat();
+ void alignments();
+ void alignments_data();
// ### these tests may be trivial
void hAlign();
@@ -297,6 +299,58 @@ void tst_qdeclarativetextedit::textFormat()
}
}
+void tst_qdeclarativetextedit::alignments_data()
+{
+ QTest::addColumn<int>("hAlign");
+ QTest::addColumn<int>("vAlign");
+ QTest::addColumn<QString>("expectfile");
+
+ QTest::newRow("LT") << int(Qt::AlignLeft) << int(Qt::AlignTop) << SRCDIR "/data/alignments_lt.png";
+ QTest::newRow("RT") << int(Qt::AlignRight) << int(Qt::AlignTop) << SRCDIR "/data/alignments_rt.png";
+ QTest::newRow("CT") << int(Qt::AlignHCenter) << int(Qt::AlignTop) << SRCDIR "/data/alignments_ct.png";
+
+ QTest::newRow("LB") << int(Qt::AlignLeft) << int(Qt::AlignBottom) << SRCDIR "/data/alignments_lb.png";
+ QTest::newRow("RB") << int(Qt::AlignRight) << int(Qt::AlignBottom) << SRCDIR "/data/alignments_rb.png";
+ QTest::newRow("CB") << int(Qt::AlignHCenter) << int(Qt::AlignBottom) << SRCDIR "/data/alignments_cb.png";
+
+ QTest::newRow("LC") << int(Qt::AlignLeft) << int(Qt::AlignVCenter) << SRCDIR "/data/alignments_lc.png";
+ QTest::newRow("RC") << int(Qt::AlignRight) << int(Qt::AlignVCenter) << SRCDIR "/data/alignments_rc.png";
+ QTest::newRow("CC") << int(Qt::AlignHCenter) << int(Qt::AlignVCenter) << SRCDIR "/data/alignments_cc.png";
+}
+
+
+void tst_qdeclarativetextedit::alignments()
+{
+ QFETCH(int, hAlign);
+ QFETCH(int, vAlign);
+ QFETCH(QString, expectfile);
+
+ QDeclarativeView *canvas = createView(SRCDIR "/data/alignments.qml");
+
+ canvas->show();
+ QApplication::setActiveWindow(canvas);
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas));
+
+ QObject *ob = canvas->rootObject();
+ QVERIFY(ob != 0);
+ ob->setProperty("horizontalAlignment",hAlign);
+ ob->setProperty("verticalAlignment",vAlign);
+ QTRY_COMPARE(ob->property("running").toBool(),false);
+ QImage actual(canvas->width(), canvas->height(), QImage::Format_RGB32);
+ actual.fill(qRgb(255,255,255));
+ QPainter p(&actual);
+ canvas->render(&p);
+
+ QImage expect(expectfile);
+
+#ifdef Q_OS_LINUX
+ // Font-specific, but not likely platform-specific, so only test on one platform
+ QCOMPARE(actual,expect);
+#endif
+}
+
+
//the alignment tests may be trivial o.oa
void tst_qdeclarativetextedit::hAlign()
{