summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/declarative')
-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.qml43
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments_cb.pngbin0 -> 528 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments_cc.pngbin0 -> 549 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments_ct.pngbin0 -> 564 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments_lb.pngbin0 -> 522 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments_lc.pngbin0 -> 541 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments_lt.pngbin0 -> 558 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments_rb.pngbin0 -> 530 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments_rc.pngbin0 -> 550 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments_rt.pngbin0 -> 564 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp66
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/alignments.qml43
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/alignments_cb.pngbin0 -> 528 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/alignments_cc.pngbin0 -> 549 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/alignments_ct.pngbin0 -> 564 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/alignments_lb.pngbin0 -> 522 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/alignments_lc.pngbin0 -> 541 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/alignments_lt.pngbin0 -> 558 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/alignments_rb.pngbin0 -> 530 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/alignments_rc.pngbin0 -> 550 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/alignments_rt.pngbin0 -> 564 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp54
-rw-r--r--tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp4
31 files changed, 276 insertions, 54 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..b10c335
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetext/data/alignments.qml
@@ -0,0 +1,43 @@
+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.family: "Misc Fixed"
+ 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..b0ad381
--- /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..98232ce
--- /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..b606ba5
--- /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..a8f095d
--- /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..c2a0679
--- /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..c019551
--- /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..08d581a
--- /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..d607955
--- /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..2acfb9e
--- /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..b10c335
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments.qml
@@ -0,0 +1,43 @@
+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.family: "Misc Fixed"
+ 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..b0ad381
--- /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..98232ce
--- /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..b606ba5
--- /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..a8f095d
--- /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..c2a0679
--- /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..c019551
--- /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..08d581a
--- /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..d607955
--- /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..2acfb9e
--- /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()
{
diff --git a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp
index f30f758..1ea2a95 100644
--- a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp
+++ b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp
@@ -261,7 +261,7 @@ void tst_QDeclarativeViewer::resizing()
QCOMPARE(rootItem->width(), 150.0);
QCOMPARE(rootItem->height(), 200.0);
- QCOMPARE(viewer->view()->size(), QSize(150, 200));
+ QTRY_COMPARE(viewer->view()->size(), QSize(150, 200));
QCOMPARE(viewer->view()->initialSize(), QSize(200, 300));
QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(150, 200));
QCOMPARE(viewer->size(), QSize(150, 200+viewer->menuBar()->height()));
@@ -279,7 +279,7 @@ void tst_QDeclarativeViewer::resizing()
QTRY_COMPARE(rootItem->width(), 250.0);
QTRY_COMPARE(rootItem->height(), 350.0-viewer->menuBar()->height());
- QCOMPARE(viewer->view()->size(), QSize(250, 350-viewer->menuBar()->height()));
+ QTRY_COMPARE(viewer->view()->size(), QSize(250, 350-viewer->menuBar()->height()));
QCOMPARE(viewer->view()->initialSize(), QSize(200, 300));
QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(250, 350-viewer->menuBar()->height()));
QCOMPARE(viewer->size(), QSize(250, 350));