summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/declarative')
-rw-r--r--tests/auto/declarative/datetimeformatter/tst_datetimeformatter.cpp14
-rw-r--r--tests/auto/declarative/layouts/data/grid-spacing.qml20
-rw-r--r--tests/auto/declarative/layouts/data/grid.qml20
-rw-r--r--tests/auto/declarative/layouts/data/horizontal-spacing.qml12
-rw-r--r--tests/auto/declarative/layouts/data/horizontal.qml12
-rw-r--r--tests/auto/declarative/layouts/data/vertical-spacing.qml12
-rw-r--r--tests/auto/declarative/layouts/data/vertical.qml12
-rw-r--r--tests/auto/declarative/layouts/tst_layouts.cpp76
-rw-r--r--tests/auto/declarative/listview/data/listview.qml4
-rw-r--r--tests/auto/declarative/listview/tst_listview.cpp28
-rw-r--r--tests/auto/declarative/numberformatter/tst_numberformatter.cpp15
-rw-r--r--tests/auto/declarative/pathview/data/pathview.qml10
-rw-r--r--tests/auto/declarative/pathview/tst_pathview.cpp8
-rw-r--r--tests/auto/declarative/qbindablemap/tst_qbindablemap.cpp4
-rw-r--r--tests/auto/declarative/qfxloader/NoResize.qml7
-rw-r--r--tests/auto/declarative/qfxloader/Rect120x60.qml6
-rw-r--r--tests/auto/declarative/qfxloader/SetSourceComponent.qml6
-rw-r--r--tests/auto/declarative/qfxloader/SizeToItem.qml6
-rw-r--r--tests/auto/declarative/qfxloader/SizeToLoader.qml7
-rw-r--r--tests/auto/declarative/qfxloader/qfxloader.pro5
-rw-r--r--tests/auto/declarative/qfxloader/tst_qfxloader.cpp103
-rw-r--r--tests/auto/declarative/qfxtext/tst_qfxtext.cpp160
-rw-r--r--tests/auto/declarative/qfxtextedit/data/cursorTest.qml6
-rw-r--r--tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp64
-rw-r--r--tests/auto/declarative/qfxtextinput/data/navigation.qml4
-rw-r--r--tests/auto/declarative/qfxtextinput/tst_qfxtextinput.cpp291
-rw-r--r--tests/auto/declarative/qmlparser/Alias.qml8
-rw-r--r--tests/auto/declarative/qmlparser/alias.1.qml8
-rw-r--r--tests/auto/declarative/qmlparser/alias.2.qml8
-rw-r--r--tests/auto/declarative/qmlparser/alias.3.qml10
-rw-r--r--tests/auto/declarative/qmlparser/customParserIdNotAllowed.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/customParserIdNotAllowed.qml5
-rw-r--r--tests/auto/declarative/qmlparser/listItemDeleteSelf.qml38
-rw-r--r--tests/auto/declarative/qmlparser/testtypes.h8
-rw-r--r--tests/auto/declarative/qmlparser/tst_qmlparser.cpp75
-rw-r--r--tests/auto/declarative/repeater/data/repeater.qml6
-rw-r--r--tests/auto/declarative/repeater/tst_repeater.cpp22
37 files changed, 842 insertions, 259 deletions
diff --git a/tests/auto/declarative/datetimeformatter/tst_datetimeformatter.cpp b/tests/auto/declarative/datetimeformatter/tst_datetimeformatter.cpp
index 67cff02..556912e 100644
--- a/tests/auto/declarative/datetimeformatter/tst_datetimeformatter.cpp
+++ b/tests/auto/declarative/datetimeformatter/tst_datetimeformatter.cpp
@@ -2,6 +2,7 @@
#include <QtDeclarative/qmlengine.h>
#include <QtDeclarative/qmlcomponent.h>
#include <QtDeclarative/qmldatetimeformatter.h>
+#include <QDebug>
class tst_datetimeformatter : public QObject
{
@@ -18,8 +19,11 @@ private slots:
void tst_datetimeformatter::date()
{
QmlEngine engine;
- QmlComponent formatterComponent(&engine, "DateTimeFormatter { date: \"2008-12-24\" }");
+ QmlComponent formatterComponent(&engine, QByteArray("import Qt 4.6\n DateTimeFormatter { date: \"2008-12-24\" }"),
+ QUrl("file://"));
QmlDateTimeFormatter *formatter = qobject_cast<QmlDateTimeFormatter*>(formatterComponent.create());
+ if(formatterComponent.isError())
+ qDebug() << formatterComponent.errors();
QVERIFY(formatter != 0);
QDate date(2008,12,24);
@@ -38,8 +42,10 @@ void tst_datetimeformatter::date()
void tst_datetimeformatter::time()
{
QmlEngine engine;
- QmlComponent formatterComponent(&engine, "DateTimeFormatter { time: \"14:15:38.200\" }");
+ QmlComponent formatterComponent(&engine, "import Qt 4.6\n DateTimeFormatter { time: \"14:15:38.200\" }", QUrl("file://"));
QmlDateTimeFormatter *formatter = qobject_cast<QmlDateTimeFormatter*>(formatterComponent.create());
+ if(formatterComponent.isError())
+ qDebug() << formatterComponent.errors();
QVERIFY(formatter != 0);
QTime time(14,15,38,200);
@@ -64,8 +70,10 @@ void tst_datetimeformatter::time()
void tst_datetimeformatter::dateTime()
{
QmlEngine engine;
- QmlComponent formatterComponent(&engine, "DateTimeFormatter { dateTime: \"1978-03-04T09:13:54\" }");
+ QmlComponent formatterComponent(&engine, "import Qt 4.6\n DateTimeFormatter { dateTime: \"1978-03-04T09:13:54\" }", QUrl("file://"));
QmlDateTimeFormatter *formatter = qobject_cast<QmlDateTimeFormatter*>(formatterComponent.create());
+ if(formatterComponent.isError())
+ qDebug() << formatterComponent.errors();
QVERIFY(formatter != 0);
QDateTime dateTime(QDate(1978,03,04),QTime(9,13,54));
diff --git a/tests/auto/declarative/layouts/data/grid-spacing.qml b/tests/auto/declarative/layouts/data/grid-spacing.qml
index f9ae204..5b4a30d 100644
--- a/tests/auto/declarative/layouts/data/grid-spacing.qml
+++ b/tests/auto/declarative/layouts/data/grid-spacing.qml
@@ -6,32 +6,32 @@ Item {
Grid {
columns: 3
spacing: 4
- Rect {
- id: one
+ Rectangle {
+ objectName: "one"
color: "red"
width: 50
height: 50
}
- Rect {
- id: two
+ Rectangle {
+ objectName: "two"
color: "green"
width: 20
height: 50
}
- Rect {
- id: three
+ Rectangle {
+ objectName: "three"
color: "blue"
width: 50
height: 20
}
- Rect {
- id: four
+ Rectangle {
+ objectName: "four"
color: "cyan"
width: 50
height: 50
}
- Rect {
- id: five
+ Rectangle {
+ objectName: "five"
color: "magenta"
width: 10
height: 10
diff --git a/tests/auto/declarative/layouts/data/grid.qml b/tests/auto/declarative/layouts/data/grid.qml
index 3861f63..830df6a 100644
--- a/tests/auto/declarative/layouts/data/grid.qml
+++ b/tests/auto/declarative/layouts/data/grid.qml
@@ -5,32 +5,32 @@ Item {
height: 480
Grid {
columns: 3
- Rect {
- id: one
+ Rectangle {
+ objectName: "one"
color: "red"
width: 50
height: 50
}
- Rect {
- id: two
+ Rectangle {
+ objectName: "two"
color: "green"
width: 20
height: 50
}
- Rect {
- id: three
+ Rectangle {
+ objectName: "three"
color: "blue"
width: 50
height: 20
}
- Rect {
- id: four
+ Rectangle {
+ objectName: "four"
color: "cyan"
width: 50
height: 50
}
- Rect {
- id: five
+ Rectangle {
+ objectName: "five"
color: "magenta"
width: 10
height: 10
diff --git a/tests/auto/declarative/layouts/data/horizontal-spacing.qml b/tests/auto/declarative/layouts/data/horizontal-spacing.qml
index 8594ee6..32bf775 100644
--- a/tests/auto/declarative/layouts/data/horizontal-spacing.qml
+++ b/tests/auto/declarative/layouts/data/horizontal-spacing.qml
@@ -5,20 +5,20 @@ Item {
height: 480
Row {
spacing: 10
- Rect {
- id: one
+ Rectangle {
+ objectName: "one"
color: "red"
width: 50
height: 50
}
- Rect {
- id: two
+ Rectangle {
+ objectName: "two"
color: "red"
width: 20
height: 10
}
- Rect {
- id: three
+ Rectangle {
+ objectName: "three"
color: "red"
width: 40
height: 20
diff --git a/tests/auto/declarative/layouts/data/horizontal.qml b/tests/auto/declarative/layouts/data/horizontal.qml
index 673e77e..06ae151 100644
--- a/tests/auto/declarative/layouts/data/horizontal.qml
+++ b/tests/auto/declarative/layouts/data/horizontal.qml
@@ -4,20 +4,20 @@ Item {
width: 640
height: 480
Row {
- Rect {
- id: one
+ Rectangle {
+ objectName: "one"
color: "red"
width: 50
height: 50
}
- Rect {
- id: two
+ Rectangle {
+ objectName: "two"
color: "red"
width: 20
height: 10
}
- Rect {
- id: three
+ Rectangle {
+ objectName: "three"
color: "red"
width: 40
height: 20
diff --git a/tests/auto/declarative/layouts/data/vertical-spacing.qml b/tests/auto/declarative/layouts/data/vertical-spacing.qml
index 49bd8c6..69a8256 100644
--- a/tests/auto/declarative/layouts/data/vertical-spacing.qml
+++ b/tests/auto/declarative/layouts/data/vertical-spacing.qml
@@ -5,20 +5,20 @@ Item {
height: 480
Column {
spacing: 10
- Rect {
- id: one
+ Rectangle {
+ objectName: "one"
color: "red"
width: 50
height: 50
}
- Rect {
- id: two
+ Rectangle {
+ objectName: "two"
color: "red"
width: 20
height: 10
}
- Rect {
- id: three
+ Rectangle {
+ objectName: "three"
color: "red"
width: 40
height: 20
diff --git a/tests/auto/declarative/layouts/data/vertical.qml b/tests/auto/declarative/layouts/data/vertical.qml
index c8d3a11..856c180 100644
--- a/tests/auto/declarative/layouts/data/vertical.qml
+++ b/tests/auto/declarative/layouts/data/vertical.qml
@@ -4,20 +4,20 @@ Item {
width: 640
height: 480
Column {
- Rect {
- id: one
+ Rectangle {
+ objectName: "one"
color: "red"
width: 50
height: 50
}
- Rect {
- id: two
+ Rectangle {
+ objectName: "two"
color: "red"
width: 20
height: 10
}
- Rect {
- id: three
+ Rectangle {
+ objectName: "three"
color: "red"
width: 40
height: 20
diff --git a/tests/auto/declarative/layouts/tst_layouts.cpp b/tests/auto/declarative/layouts/tst_layouts.cpp
index cd4678e..3416b2e 100644
--- a/tests/auto/declarative/layouts/tst_layouts.cpp
+++ b/tests/auto/declarative/layouts/tst_layouts.cpp
@@ -20,8 +20,6 @@ private slots:
private:
QFxView *createView(const QString &filename);
- template<typename T>
- T *findItem(QFxItem *parent, const QString &id, int index=-1);
};
tst_QFxLayouts::tst_QFxLayouts()
@@ -35,13 +33,13 @@ void tst_QFxLayouts::test_horizontal()
canvas->execute();
qApp->processEvents();
- QFxRect *one = findItem<QFxRect>(canvas->root(), "one");
+ QFxRect *one = canvas->root()->findChild<QFxRect*>("one");
QVERIFY(one != 0);
- QFxRect *two = findItem<QFxRect>(canvas->root(), "two");
+ QFxRect *two = canvas->root()->findChild<QFxRect*>("two");
QVERIFY(two != 0);
- QFxRect *three = findItem<QFxRect>(canvas->root(), "three");
+ QFxRect *three = canvas->root()->findChild<QFxRect*>("three");
QVERIFY(three != 0);
QCOMPARE(one->x(), 0.0);
@@ -59,13 +57,13 @@ void tst_QFxLayouts::test_horizontal_spacing()
canvas->execute();
qApp->processEvents();
- QFxRect *one = findItem<QFxRect>(canvas->root(), "one");
+ QFxRect *one = canvas->root()->findChild<QFxRect*>("one");
QVERIFY(one != 0);
- QFxRect *two = findItem<QFxRect>(canvas->root(), "two");
+ QFxRect *two = canvas->root()->findChild<QFxRect*>("two");
QVERIFY(two != 0);
- QFxRect *three = findItem<QFxRect>(canvas->root(), "three");
+ QFxRect *three = canvas->root()->findChild<QFxRect*>("three");
QVERIFY(three != 0);
QCOMPARE(one->x(), 0.0);
@@ -83,13 +81,13 @@ void tst_QFxLayouts::test_vertical()
canvas->execute();
qApp->processEvents();
- QFxRect *one = findItem<QFxRect>(canvas->root(), "one");
+ QFxRect *one = canvas->root()->findChild<QFxRect*>("one");
QVERIFY(one != 0);
- QFxRect *two = findItem<QFxRect>(canvas->root(), "two");
+ QFxRect *two = canvas->root()->findChild<QFxRect*>("two");
QVERIFY(two != 0);
- QFxRect *three = findItem<QFxRect>(canvas->root(), "three");
+ QFxRect *three = canvas->root()->findChild<QFxRect*>("three");
QVERIFY(three != 0);
QCOMPARE(one->x(), 0.0);
@@ -107,13 +105,13 @@ void tst_QFxLayouts::test_vertical_spacing()
canvas->execute();
qApp->processEvents();
- QFxRect *one = findItem<QFxRect>(canvas->root(), "one");
+ QFxRect *one = canvas->root()->findChild<QFxRect*>("one");
QVERIFY(one != 0);
- QFxRect *two = findItem<QFxRect>(canvas->root(), "two");
+ QFxRect *two = canvas->root()->findChild<QFxRect*>("two");
QVERIFY(two != 0);
- QFxRect *three = findItem<QFxRect>(canvas->root(), "three");
+ QFxRect *three = canvas->root()->findChild<QFxRect*>("three");
QVERIFY(three != 0);
QCOMPARE(one->x(), 0.0);
@@ -131,15 +129,15 @@ void tst_QFxLayouts::test_grid()
canvas->execute();
qApp->processEvents();
- QFxRect *one = findItem<QFxRect>(canvas->root(), "one");
+ QFxRect *one = canvas->root()->findChild<QFxRect*>("one");
QVERIFY(one != 0);
- QFxRect *two = findItem<QFxRect>(canvas->root(), "two");
+ QFxRect *two = canvas->root()->findChild<QFxRect*>("two");
QVERIFY(two != 0);
- QFxRect *three = findItem<QFxRect>(canvas->root(), "three");
+ QFxRect *three = canvas->root()->findChild<QFxRect*>("three");
QVERIFY(three != 0);
- QFxRect *four = findItem<QFxRect>(canvas->root(), "four");
+ QFxRect *four = canvas->root()->findChild<QFxRect*>("four");
QVERIFY(four != 0);
- QFxRect *five = findItem<QFxRect>(canvas->root(), "five");
+ QFxRect *five = canvas->root()->findChild<QFxRect*>("five");
QVERIFY(five != 0);
QCOMPARE(one->x(), 0.0);
@@ -161,15 +159,15 @@ void tst_QFxLayouts::test_grid_spacing()
canvas->execute();
qApp->processEvents();
- QFxRect *one = findItem<QFxRect>(canvas->root(), "one");
+ QFxRect *one = canvas->root()->findChild<QFxRect*>("one");
QVERIFY(one != 0);
- QFxRect *two = findItem<QFxRect>(canvas->root(), "two");
+ QFxRect *two = canvas->root()->findChild<QFxRect*>("two");
QVERIFY(two != 0);
- QFxRect *three = findItem<QFxRect>(canvas->root(), "three");
+ QFxRect *three = canvas->root()->findChild<QFxRect*>("three");
QVERIFY(three != 0);
- QFxRect *four = findItem<QFxRect>(canvas->root(), "four");
+ QFxRect *four = canvas->root()->findChild<QFxRect*>("four");
QVERIFY(four != 0);
- QFxRect *five = findItem<QFxRect>(canvas->root(), "five");
+ QFxRect *five = canvas->root()->findChild<QFxRect*>("five");
QVERIFY(five != 0);
QCOMPARE(one->x(), 0.0);
@@ -196,36 +194,6 @@ QFxView *tst_QFxLayouts::createView(const QString &filename)
return canvas;
}
-/*
- Find an item with the specified objectName. If index is supplied then the
- item must also evaluate the {index} expression equal to index
-*/
-template<typename T>
-T *tst_QFxLayouts::findItem(QFxItem *parent, const QString &objectName, int index)
-{
- const QMetaObject &mo = T::staticMetaObject;
- for (int i = 0; i < parent->QGraphicsObject::children().count(); ++i) {
- QFxItem *item = qobject_cast<QFxItem*>(parent->QGraphicsObject::children().at(i));
- if(!item)
- continue;
- //qDebug() << item << item->objectName();
- if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
- if (index != -1) {
- QmlExpression e(qmlContext(item), "index", item);
- e.setTrackChange(false);
- if (e.value().toInt() == index)
- return static_cast<T*>(item);
- } else {
- return static_cast<T*>(item);
- }
- }
- item = findItem<T>(item, objectName, index);
- if (item)
- return static_cast<T*>(item);
- }
-
- return 0;
-}
QTEST_MAIN(tst_QFxLayouts)
diff --git a/tests/auto/declarative/listview/data/listview.qml b/tests/auto/declarative/listview/data/listview.qml
index 7a3d76f..1a241eb 100644
--- a/tests/auto/declarative/listview/data/listview.qml
+++ b/tests/auto/declarative/listview/data/listview.qml
@@ -9,6 +9,7 @@ Rectangle {
id: Delegate
Item {
id: wrapper
+ objectName: "wrapper"
height: 20
width: 240
Text {
@@ -17,11 +18,13 @@ Rectangle {
Text {
x: 30
id: textName
+ objectName: "textName"
text: name
}
Text {
x: 120
id: textNumber
+ objectName: "textNumber"
text: number
}
Text {
@@ -33,6 +36,7 @@ Rectangle {
]
ListView {
id: list
+ objectName: "list"
width: 240
height: 320
model: testModel
diff --git a/tests/auto/declarative/listview/tst_listview.cpp b/tests/auto/declarative/listview/tst_listview.cpp
index 8bf9c8a..ebc3053 100644
--- a/tests/auto/declarative/listview/tst_listview.cpp
+++ b/tests/auto/declarative/listview/tst_listview.cpp
@@ -188,7 +188,7 @@ void tst_QFxListView::items()
QFxItem *viewport = listview->viewport();
QVERIFY(viewport != 0);
- QCOMPARE(viewport->children()->count(), model.count()); // assumes all are visible
+ QCOMPARE(viewport->childItems().count(), model.count()); // assumes all are visible
for (int i = 0; i < model.count(); ++i) {
QFxText *name = findItem<QFxText>(viewport, "textName", i);
@@ -262,7 +262,7 @@ void tst_QFxListView::inserted()
// let transitions settle.
QTest::qWait(1000);
- QCOMPARE(viewport->children()->count(), model.count()); // assumes all are visible
+ QCOMPARE(viewport->childItems().count(), model.count()); // assumes all are visible
QFxText *name = findItem<QFxText>(viewport, "textName", 1);
QVERIFY(name != 0);
@@ -282,7 +282,7 @@ void tst_QFxListView::inserted()
// let transitions settle.
QTest::qWait(1000);
- QCOMPARE(viewport->children()->count(), model.count()); // assumes all are visible
+ QCOMPARE(viewport->childItems().count(), model.count()); // assumes all are visible
name = findItem<QFxText>(viewport, "textName", 0);
QVERIFY(name != 0);
@@ -336,7 +336,7 @@ void tst_QFxListView::removed()
QCOMPARE(number->text(), model.number(1));
// Confirm items positioned correctly
- for (int i = 0; i < model.count() && i < viewport->children()->count(); ++i) {
+ for (int i = 0; i < model.count() && i < viewport->childItems().count(); ++i) {
QFxItem *item = findItem<QFxItem>(viewport, "wrapper", i);
QVERIFY(item->y() == i*20);
}
@@ -355,7 +355,7 @@ void tst_QFxListView::removed()
QCOMPARE(number->text(), model.number(0));
// Confirm items positioned correctly
- for (int i = 0; i < model.count() && i < viewport->children()->count(); ++i) {
+ for (int i = 0; i < model.count() && i < viewport->childItems().count(); ++i) {
QFxItem *item = findItem<QFxItem>(viewport, "wrapper", i);
QCOMPARE(item->y(),i*20.0 + 20.0);
}
@@ -366,13 +366,13 @@ void tst_QFxListView::removed()
QTest::qWait(1000);
// Confirm items positioned correctly
- for (int i = 0; i < model.count() && i < viewport->children()->count(); ++i) {
+ for (int i = 0; i < model.count() && i < viewport->childItems().count(); ++i) {
QFxItem *item = findItem<QFxItem>(viewport, "wrapper", i);
QCOMPARE(item->y(),i*20.0+20.0);
}
// Remove items before visible
- listview->setYPosition(80);
+ listview->setViewportY(80);
listview->setCurrentIndex(10);
model.removeItem(1); // post: top item will be at 40
@@ -385,12 +385,12 @@ void tst_QFxListView::removed()
QCOMPARE(item->y(),40+i*20.0);
}
- listview->setYPosition(40); // That's the top now
+ listview->setViewportY(40); // That's the top now
// let transitions settle.
QTest::qWait(1000);
// Confirm items positioned correctly
- for (int i = 0; i < model.count() && i < viewport->children()->count(); ++i) {
+ for (int i = 0; i < model.count() && i < viewport->childItems().count(); ++i) {
QFxItem *item = findItem<QFxItem>(viewport, "wrapper", i);
QCOMPARE(item->y(),40+i*20.0);
}
@@ -459,10 +459,12 @@ template<typename T>
T *tst_QFxListView::findItem(QFxItem *parent, const QString &objectName, int index)
{
const QMetaObject &mo = T::staticMetaObject;
- qDebug() << parent->children()->count() << "children";
- for (int i = 0; i < parent->children()->count(); ++i) {
- QFxItem *item = parent->children()->at(i);
- qDebug() << "try" << item;
+ //qDebug() << parent->QGraphicsObject::children().count() << "children";
+ for (int i = 0; i < parent->QGraphicsObject::children().count(); ++i) {
+ QFxItem *item = qobject_cast<QFxItem*>(parent->QGraphicsObject::children().at(i));
+ if(!item)
+ continue;
+ //qDebug() << "try" << item;
if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
if (index != -1) {
QmlExpression e(qmlContext(item), "index", item);
diff --git a/tests/auto/declarative/numberformatter/tst_numberformatter.cpp b/tests/auto/declarative/numberformatter/tst_numberformatter.cpp
index 9a2f4f3..78ec347 100644
--- a/tests/auto/declarative/numberformatter/tst_numberformatter.cpp
+++ b/tests/auto/declarative/numberformatter/tst_numberformatter.cpp
@@ -166,11 +166,15 @@ void tst_numberformat::number()
QFETCH(QString, string);
QFETCH(float, number);
- QString componentStr = QString("NumberFormatter { number: \"") + string + QString("\" }");
+ QString componentStr = QString("import Qt 4.6\nNumberFormatter { number: \"") + string + QString("\" }");
QmlEngine engine;
- QmlComponent formatterComponent(&engine, componentStr.toAscii());
+ QmlComponent formatterComponent(&engine, componentStr.toAscii(), QUrl("file://"));
+ if(formatterComponent.isError())
+ qDebug() << formatterComponent.errors();
+ QVERIFY(formatterComponent.isReady());
QmlNumberFormatter *formatter = qobject_cast<QmlNumberFormatter*>(formatterComponent.create());
+ QVERIFY(formatterComponent.isReady());
QVERIFY(formatter != 0);
QCOMPARE((float)formatter->number(), number);
//qDebug() << formatter->format() << formatter->text();
@@ -201,10 +205,13 @@ void tst_numberformat::text()
QFETCH(QString, format);
QFETCH(QString, text);
- QString componentStr = QString("NumberFormatter { number: \"") + string + QString("\"; format: \"") + format + QString("\" }");
+ QString componentStr = QString("import Qt 4.6\nNumberFormatter { number: \"") + string + QString("\"; format: \"") + format + QString("\" }");
QmlEngine engine;
- QmlComponent formatterComponent(&engine, componentStr.toAscii());
+ QmlComponent formatterComponent(&engine, componentStr.toAscii(), QUrl("file://"));
+ if(formatterComponent.isError())
+ qDebug() << formatterComponent.errors();
+ QVERIFY(formatterComponent.isReady());
QmlNumberFormatter *formatter = qobject_cast<QmlNumberFormatter*>(formatterComponent.create());
QVERIFY(formatter != 0);
diff --git a/tests/auto/declarative/pathview/data/pathview.qml b/tests/auto/declarative/pathview/data/pathview.qml
index 7040e4c..be5673c 100644
--- a/tests/auto/declarative/pathview/data/pathview.qml
+++ b/tests/auto/declarative/pathview/data/pathview.qml
@@ -1,14 +1,15 @@
import Qt 4.6
-Rect {
+Rectangle {
width: 240
height: 320
color: "#ffffff"
resources: [
Component {
id: Delegate
- Rect {
+ Rectangle {
id: wrapper
+ objectName: "wrapper"
height: 20
width: 60
color: "white"
@@ -19,11 +20,13 @@ Rect {
Text {
x: 20
id: textName
+ objectName: "textName"
text: name
}
Text {
x: 40
id: textNumber
+ objectName: "textNumber"
text: number
}
}
@@ -31,11 +34,12 @@ Rect {
]
PathView {
id: view
+ objectName: "view"
width: 240
height: 320
model: testModel
delegate: Delegate
- snapPos: 0.01
+ snapPosition: 0.01
path: Path {
startY: 120
startX: 160
diff --git a/tests/auto/declarative/pathview/tst_pathview.cpp b/tests/auto/declarative/pathview/tst_pathview.cpp
index 9cae961..2933323 100644
--- a/tests/auto/declarative/pathview/tst_pathview.cpp
+++ b/tests/auto/declarative/pathview/tst_pathview.cpp
@@ -117,7 +117,7 @@ void tst_QFxPathView::items()
QFxPathView *pathview = findItem<QFxPathView>(canvas->root(), "view");
QVERIFY(pathview != 0);
- QCOMPARE(pathview->children()->count(), model.count()); // assumes all are visible
+ QCOMPARE(pathview->childItems().count(), model.count()); // assumes all are visible
for (int i = 0; i < model.count(); ++i) {
QFxText *name = findItem<QFxText>(pathview, "textName", i);
@@ -234,8 +234,10 @@ template<typename T>
T *tst_QFxPathView::findItem(QFxItem *parent, const QString &objectName, int index)
{
const QMetaObject &mo = T::staticMetaObject;
- for (int i = 0; i < parent->children()->count(); ++i) {
- QFxItem *item = parent->children()->at(i);
+ for (int i = 0; i < parent->children().count(); ++i) {
+ QFxItem *item = qobject_cast<QFxItem*>(parent->children().at(i));
+ if(!item)
+ continue;
if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
if (index != -1) {
QmlExpression e(qmlContext(item), "index", item);
diff --git a/tests/auto/declarative/qbindablemap/tst_qbindablemap.cpp b/tests/auto/declarative/qbindablemap/tst_qbindablemap.cpp
index a8046e6..c9c37ab 100644
--- a/tests/auto/declarative/qbindablemap/tst_qbindablemap.cpp
+++ b/tests/auto/declarative/qbindablemap/tst_qbindablemap.cpp
@@ -59,7 +59,9 @@ void tst_QBindableMap::changed()
QmlEngine engine;
QmlContext *ctxt = engine.rootContext();
ctxt->setContextProperty(QLatin1String("data"), &map);
- QmlComponent component(&engine, "Script { script: \"data.key1 = 'Hello World';\" }");
+ QmlComponent component(&engine, "import Qt 4.6\nScript { script: \"data.key1 = 'Hello World';\" }",
+ QUrl("file://"));
+ QVERIFY(component.isReady());
component.create();
QCOMPARE(spy.count(), 1);
QList<QVariant> arguments = spy.takeFirst();
diff --git a/tests/auto/declarative/qfxloader/NoResize.qml b/tests/auto/declarative/qfxloader/NoResize.qml
new file mode 100644
index 0000000..cfbb55a
--- /dev/null
+++ b/tests/auto/declarative/qfxloader/NoResize.qml
@@ -0,0 +1,7 @@
+import Qt 4.6
+
+Loader {
+ resizeMode: "NoResize"
+ width: 200; height: 80
+ source: "Rect120x60.qml"
+}
diff --git a/tests/auto/declarative/qfxloader/Rect120x60.qml b/tests/auto/declarative/qfxloader/Rect120x60.qml
new file mode 100644
index 0000000..aa4b0c2
--- /dev/null
+++ b/tests/auto/declarative/qfxloader/Rect120x60.qml
@@ -0,0 +1,6 @@
+import Qt 4.6
+
+Rectangle {
+ width: 120
+ height:60
+}
diff --git a/tests/auto/declarative/qfxloader/SetSourceComponent.qml b/tests/auto/declarative/qfxloader/SetSourceComponent.qml
new file mode 100644
index 0000000..c5dd7ff
--- /dev/null
+++ b/tests/auto/declarative/qfxloader/SetSourceComponent.qml
@@ -0,0 +1,6 @@
+import Qt 4.6
+
+Item {
+ Component { id: Comp; Rectangle { width: 120; height: 60 } }
+ Loader { sourceComponent: Comp }
+}
diff --git a/tests/auto/declarative/qfxloader/SizeToItem.qml b/tests/auto/declarative/qfxloader/SizeToItem.qml
new file mode 100644
index 0000000..b52fa03
--- /dev/null
+++ b/tests/auto/declarative/qfxloader/SizeToItem.qml
@@ -0,0 +1,6 @@
+import Qt 4.6
+
+Loader {
+ resizeMode: "SizeLoaderToItem"
+ source: "Rect120x60.qml"
+}
diff --git a/tests/auto/declarative/qfxloader/SizeToLoader.qml b/tests/auto/declarative/qfxloader/SizeToLoader.qml
new file mode 100644
index 0000000..1a107e1
--- /dev/null
+++ b/tests/auto/declarative/qfxloader/SizeToLoader.qml
@@ -0,0 +1,7 @@
+import Qt 4.6
+
+Loader {
+ resizeMode: "SizeItemToLoader"
+ width: 200; height: 80
+ source: "Rect120x60.qml"
+}
diff --git a/tests/auto/declarative/qfxloader/qfxloader.pro b/tests/auto/declarative/qfxloader/qfxloader.pro
new file mode 100644
index 0000000..643c18c
--- /dev/null
+++ b/tests/auto/declarative/qfxloader/qfxloader.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui
+SOURCES += tst_qfxloader.cpp
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qfxloader/tst_qfxloader.cpp b/tests/auto/declarative/qfxloader/tst_qfxloader.cpp
new file mode 100644
index 0000000..2109898
--- /dev/null
+++ b/tests/auto/declarative/qfxloader/tst_qfxloader.cpp
@@ -0,0 +1,103 @@
+#include <qtest.h>
+#include <QtDeclarative/qmlengine.h>
+#include <QtDeclarative/qmlcomponent.h>
+#include <QtDeclarative/qfxloader.h>
+
+class tst_qfxloader : public QObject
+
+{
+ Q_OBJECT
+public:
+ tst_qfxloader();
+
+private slots:
+ void url();
+ void component();
+ void sizeLoaderToItem();
+ void sizeItemToLoader();
+ void noResize();
+
+private:
+ QmlEngine engine;
+};
+
+/*
+inline QUrl TEST_FILE(const QString &filename)
+{
+ QFileInfo fileInfo(__FILE__);
+ return QUrl::fromLocalFile(fileInfo.absoluteDir().filePath(filename));
+}
+
+inline QUrl TEST_FILE(const char *filename)
+{
+ return TEST_FILE(QLatin1String(filename));
+}
+*/
+
+tst_qfxloader::tst_qfxloader()
+{
+}
+
+void tst_qfxloader::url()
+{
+ QmlComponent component(&engine, QByteArray("import Qt 4.6\nLoader { source: \"Rect120x60.qml\" }"), QUrl("file://" SRCDIR "/"));
+ QFxLoader *loader = qobject_cast<QFxLoader*>(component.create());
+ QVERIFY(loader != 0);
+ QVERIFY(loader->item());
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
+}
+
+void tst_qfxloader::component()
+{
+ QmlComponent component(&engine, QUrl("file://" SRCDIR "/SetSourceComponent.qml"));
+ QFxItem *item = qobject_cast<QFxItem*>(component.create());
+ QVERIFY(item);
+
+ QFxLoader *loader = qobject_cast<QFxLoader*>(item->QGraphicsObject::children().at(1));
+ QVERIFY(loader);
+ QVERIFY(loader->item());
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
+}
+
+void tst_qfxloader::sizeLoaderToItem()
+{
+ QmlComponent component(&engine, QUrl("file://" SRCDIR "/SizeToItem.qml"));
+ QFxLoader *loader = qobject_cast<QFxLoader*>(component.create());
+ QVERIFY(loader != 0);
+ QCOMPARE(loader->width(), 120.0);
+ QCOMPARE(loader->height(), 60.0);
+}
+
+void tst_qfxloader::sizeItemToLoader()
+{
+ QmlComponent component(&engine, QUrl("file://" SRCDIR "/SizeToLoader.qml"));
+ QFxLoader *loader = qobject_cast<QFxLoader*>(component.create());
+ QVERIFY(loader != 0);
+ QCOMPARE(loader->width(), 200.0);
+ QCOMPARE(loader->height(), 80.0);
+
+ QFxItem *rect = loader->item();
+ QVERIFY(rect);
+ QCOMPARE(rect->width(), 200.0);
+ QCOMPARE(rect->height(), 80.0);
+}
+
+void tst_qfxloader::noResize()
+{
+ QmlComponent component(&engine, QUrl("file://" SRCDIR "/NoResize.qml"));
+ QFxLoader *loader = qobject_cast<QFxLoader*>(component.create());
+ QVERIFY(loader != 0);
+ QCOMPARE(loader->width(), 200.0);
+ QCOMPARE(loader->height(), 80.0);
+
+ QFxItem *rect = loader->item();
+ QVERIFY(rect);
+ QCOMPARE(rect->width(), 120.0);
+ QCOMPARE(rect->height(), 60.0);
+}
+
+QTEST_MAIN(tst_qfxloader)
+
+#include "tst_qfxloader.moc"
diff --git a/tests/auto/declarative/qfxtext/tst_qfxtext.cpp b/tests/auto/declarative/qfxtext/tst_qfxtext.cpp
index 0eb9f97..cae85a4 100644
--- a/tests/auto/declarative/qfxtext/tst_qfxtext.cpp
+++ b/tests/auto/declarative/qfxtext/tst_qfxtext.cpp
@@ -19,8 +19,8 @@ private slots:
void elide();
// ### these tests may be trivial
- void hAlign();
- void vAlign();
+ void horizontalAlignment();
+ void verticalAlignment();
void font();
void style();
void color();
@@ -29,11 +29,11 @@ private:
QStringList standard;
QStringList richText;
- QStringList hAlignmentStrings;
- QStringList vAlignmentStrings;
+ QStringList horizontalAlignmentmentStrings;
+ QStringList verticalAlignmentmentStrings;
- QList<Qt::Alignment> vAlignments;
- QList<Qt::Alignment> hAlignments;
+ QList<Qt::Alignment> verticalAlignmentments;
+ QList<Qt::Alignment> horizontalAlignmentments;
QStringList styleStrings;
QList<QFxText::TextStyle> styles;
@@ -51,19 +51,19 @@ tst_qfxtext::tst_qfxtext()
richText << "<i>the <b>quick</b> brown <a href=\\\"http://www.google.com\\\">fox</a> jumped over the <b>lazy</b> dog</i>"
<< "<i>the <b>quick</b> brown <a href=\\\"http://www.google.com\\\">fox</a><br>jumped over the <b>lazy</b> dog</i>";
- hAlignmentStrings << "AlignLeft"
+ horizontalAlignmentmentStrings << "AlignLeft"
<< "AlignRight"
<< "AlignHCenter";
- vAlignmentStrings << "AlignTop"
+ verticalAlignmentmentStrings << "AlignTop"
<< "AlignBottom"
<< "AlignVCenter";
- hAlignments << Qt::AlignLeft
+ horizontalAlignmentments << Qt::AlignLeft
<< Qt::AlignRight
<< Qt::AlignHCenter;
- vAlignments << Qt::AlignTop
+ verticalAlignmentments << Qt::AlignTop
<< Qt::AlignBottom
<< Qt::AlignVCenter;
@@ -99,7 +99,7 @@ tst_qfxtext::tst_qfxtext()
void tst_qfxtext::text()
{
{
- QmlComponent textComponent(&engine, "Text { text: \"\" }");
+ QmlComponent textComponent(&engine, "import Qt 4.6\nText { text: \"\" }", QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
QVERIFY(textObject != 0);
@@ -108,8 +108,8 @@ void tst_qfxtext::text()
for (int i = 0; i < standard.size(); i++)
{
- QString componentStr = "Text { text: \"" + standard.at(i) + "\" }";
- QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QString componentStr = "import Qt 4.6\nText { text: \"" + standard.at(i) + "\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
QVERIFY(textObject != 0);
@@ -118,8 +118,8 @@ void tst_qfxtext::text()
for (int i = 0; i < richText.size(); i++)
{
- QString componentStr = "Text { text: \"" + richText.at(i) + "\" }";
- QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QString componentStr = "import Qt 4.6\nText { text: \"" + richText.at(i) + "\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
QVERIFY(textObject != 0);
@@ -132,7 +132,7 @@ void tst_qfxtext::width()
{
// uses Font metrics to find the width for standard and document to find the width for rich
{
- QmlComponent textComponent(&engine, "Text { text: \"\" }");
+ QmlComponent textComponent(&engine, "import Qt 4.6\nText { text: \"\" }", QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
QCOMPARE(textObject->width(), 0.);
@@ -144,8 +144,8 @@ void tst_qfxtext::width()
QFontMetrics fm(f);
int metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width();
- QString componentStr = "Text { text: \"" + standard.at(i) + "\" }";
- QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QString componentStr = "import Qt 4.6\nText { text: \"" + standard.at(i) + "\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
QCOMPARE(textObject->width(), qreal(metricWidth));
@@ -159,8 +159,8 @@ void tst_qfxtext::width()
int documentWidth = document.idealWidth();
- QString componentStr = "Text { text: \"" + richText.at(i) + "\" }";
- QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QString componentStr = "import Qt 4.6\nText { text: \"" + richText.at(i) + "\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
QCOMPARE(textObject->width(), qreal(documentWidth));
@@ -173,7 +173,7 @@ void tst_qfxtext::wrap()
// for specified width and wrap set true
{
- QmlComponent textComponent(&engine, "Text { text: \"\"; wrap: true; width: 300 }");
+ QmlComponent textComponent(&engine, "import Qt 4.6\nText { text: \"\"; wrap: true; width: 300 }", QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
QCOMPARE(textObject->width(), 300.);
@@ -181,8 +181,8 @@ void tst_qfxtext::wrap()
for (int i = 0; i < standard.size(); i++)
{
- QString componentStr = "Text { wrap: true; width: 300; text: \"" + standard.at(i) + "\" }";
- QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QString componentStr = "import Qt 4.6\nText { wrap: true; width: 300; text: \"" + standard.at(i) + "\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
QCOMPARE(textObject->width(), 300.);
@@ -190,8 +190,8 @@ void tst_qfxtext::wrap()
for (int i = 0; i < richText.size(); i++)
{
- QString componentStr = "Text { wrap: true; width: 300; text: \"" + richText.at(i) + "\" }";
- QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QString componentStr = "import Qt 4.6\nText { wrap: true; width: 300; text: \"" + richText.at(i) + "\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
QCOMPARE(textObject->width(), 300.);
@@ -208,7 +208,7 @@ void tst_qfxtext::elide()
// XXX Poor coverage.
{
- QmlComponent textComponent(&engine, ("Text { text: \"\"; "+elide+" width: 300 }").toLatin1());
+ QmlComponent textComponent(&engine, ("import Qt 4.6\nText { text: \"\"; "+elide+" width: 300 }").toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
QCOMPARE(textObject->width(), 300.);
@@ -216,8 +216,8 @@ void tst_qfxtext::elide()
for (int i = 0; i < standard.size(); i++)
{
- QString componentStr = "Text { "+elide+" width: 300; text: \"" + standard.at(i) + "\" }";
- QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QString componentStr = "import Qt 4.6\nText { "+elide+" width: 300; text: \"" + standard.at(i) + "\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
QCOMPARE(textObject->width(), 300.);
@@ -226,8 +226,8 @@ void tst_qfxtext::elide()
// richtext - does nothing
for (int i = 0; i < richText.size(); i++)
{
- QString componentStr = "Text { "+elide+" width: 300; text: \"" + richText.at(i) + "\" }";
- QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QString componentStr = "import Qt 4.6\nText { "+elide+" width: 300; text: \"" + richText.at(i) + "\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
QCOMPARE(textObject->width(), 300.);
@@ -236,61 +236,61 @@ void tst_qfxtext::elide()
}
//the alignment tests may be trivial o.oa
-void tst_qfxtext::hAlign()
+void tst_qfxtext::horizontalAlignment()
{
//test one align each, and then test if two align fails.
for (int i = 0; i < standard.size(); i++)
{
- for (int j=0; j < hAlignmentStrings.size(); j++)
+ for (int j=0; j < horizontalAlignmentmentStrings.size(); j++)
{
- QString componentStr = "Text { hAlign: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
- QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QString componentStr = "import Qt 4.6\nText { horizontalAlignment: \"" + horizontalAlignmentmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
- QCOMPARE((int)textObject->hAlign(), (int)hAlignments.at(j));
+ QCOMPARE((int)textObject->hAlign(), (int)horizontalAlignmentments.at(j));
}
}
for (int i = 0; i < richText.size(); i++)
{
- for (int j=0; j < hAlignmentStrings.size(); j++)
+ for (int j=0; j < horizontalAlignmentmentStrings.size(); j++)
{
- QString componentStr = "Text { hAlign: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
- QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QString componentStr = "import Qt 4.6\nText { horizontalAlignment: \"" + horizontalAlignmentmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
- QCOMPARE((int)textObject->hAlign(), (int)hAlignments.at(j));
+ QCOMPARE((int)textObject->hAlign(), (int)horizontalAlignmentments.at(j));
}
}
}
-void tst_qfxtext::vAlign()
+void tst_qfxtext::verticalAlignment()
{
//test one align each, and then test if two align fails.
for (int i = 0; i < standard.size(); i++)
{
- for (int j=0; j < vAlignmentStrings.size(); j++)
+ for (int j=0; j < verticalAlignmentmentStrings.size(); j++)
{
- QString componentStr = "Text { vAlign: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
- QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QString componentStr = "import Qt 4.6\nText { verticalAlignment: \"" + verticalAlignmentmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
- QCOMPARE((int)textObject->vAlign(), (int)vAlignments.at(j));
+ QCOMPARE((int)textObject->vAlign(), (int)verticalAlignmentments.at(j));
}
}
for (int i = 0; i < richText.size(); i++)
{
- for (int j=0; j < vAlignmentStrings.size(); j++)
+ for (int j=0; j < verticalAlignmentmentStrings.size(); j++)
{
- QString componentStr = "Text { vAlign: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
- QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QString componentStr = "import Qt 4.6\nText { verticalAlignment: \"" + verticalAlignmentmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
- QCOMPARE((int)textObject->vAlign(), (int)vAlignments.at(j));
+ QCOMPARE((int)textObject->vAlign(), (int)verticalAlignmentments.at(j));
}
}
@@ -300,49 +300,49 @@ void tst_qfxtext::font()
{
//test size, then bold, then italic, then family
{
- QString componentStr = "Text { font.size: 40; text: \"Hello World\" }";
- QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QString componentStr = "import Qt 4.6\nText { font.pointSize: 40; text: \"Hello World\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
- QCOMPARE(textObject->font()->size(), qreal(40));
- QCOMPARE(textObject->font()->bold(), false);
- QCOMPARE(textObject->font()->italic(), false);
+ QCOMPARE(textObject->font().pointSize(), 40);
+ QCOMPARE(textObject->font().bold(), false);
+ QCOMPARE(textObject->font().italic(), false);
}
{
- QString componentStr = "Text { font.bold: true; text: \"Hello World\" }";
- QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QString componentStr = "import Qt 4.6\nText { font.bold: true; text: \"Hello World\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
- QCOMPARE(textObject->font()->bold(), true);
- QCOMPARE(textObject->font()->italic(), false);
+ QCOMPARE(textObject->font().bold(), true);
+ QCOMPARE(textObject->font().italic(), false);
}
{
- QString componentStr = "Text { font.italic: true; text: \"Hello World\" }";
- QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QString componentStr = "import Qt 4.6\nText { font.italic: true; text: \"Hello World\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
- QCOMPARE(textObject->font()->italic(), true);
- QCOMPARE(textObject->font()->bold(), false);
+ QCOMPARE(textObject->font().italic(), true);
+ QCOMPARE(textObject->font().bold(), false);
}
-
+
{
- QString componentStr = "Text { font.family: \"Helvetica\"; text: \"Hello World\" }";
- QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QString componentStr = "import Qt 4.6\nText { font.family: \"Helvetica\"; text: \"Hello World\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
- QCOMPARE(textObject->font()->family(), QString("Helvetica"));
- QCOMPARE(textObject->font()->bold(), false);
- QCOMPARE(textObject->font()->italic(), false);
+ QCOMPARE(textObject->font().family(), QString("Helvetica"));
+ QCOMPARE(textObject->font().bold(), false);
+ QCOMPARE(textObject->font().italic(), false);
}
{
- QString componentStr = "Text { font.family: \"\"; text: \"Hello World\" }";
- QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QString componentStr = "import Qt 4.6\nText { font.family: \"\"; text: \"Hello World\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
- QCOMPARE(textObject->font()->family(), QString(""));
+ QCOMPARE(textObject->font().family(), QString(""));
}
}
@@ -351,8 +351,8 @@ void tst_qfxtext::style()
//test style
for (int i = 0; i < styles.size(); i++)
{
- QString componentStr = "Text { style: \"" + styleStrings.at(i) + "\"; text: \"Hello World\" }";
- QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QString componentStr = "import Qt 4.6\nText { style: \"" + styleStrings.at(i) + "\"; text: \"Hello World\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
QCOMPARE((int)textObject->style(), (int)styles.at(i));
@@ -365,8 +365,8 @@ void tst_qfxtext::color()
//test style
for (int i = 0; i < colorStrings.size(); i++)
{
- QString componentStr = "Text { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QString componentStr = "import Qt 4.6\nText { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
QCOMPARE(textObject->color(), QColor(colorStrings.at(i)));
@@ -375,8 +375,8 @@ void tst_qfxtext::color()
for (int i = 0; i < colorStrings.size(); i++)
{
- QString componentStr = "Text { styleColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QString componentStr = "import Qt 4.6\nText { styleColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
QCOMPARE(textObject->styleColor(), QColor(colorStrings.at(i)));
@@ -388,8 +388,8 @@ void tst_qfxtext::color()
{
for (int j = 0; j < colorStrings.size(); j++)
{
- QString componentStr = "Text { color: \"" + colorStrings.at(i) + "\"; styleColor: \"" + colorStrings.at(j) + "\"; text: \"Hello World\" }";
- QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QString componentStr = "import Qt 4.6\nText { color: \"" + colorStrings.at(i) + "\"; styleColor: \"" + colorStrings.at(j) + "\"; text: \"Hello World\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
QCOMPARE(textObject->color(), QColor(colorStrings.at(i)));
@@ -401,8 +401,8 @@ void tst_qfxtext::color()
QColor testColor("#001234");
testColor.setAlpha(170);
- QString componentStr = "Text { color: \"" + colorStr + "\"; text: \"Hello World\" }";
- QmlComponent textComponent(&engine, componentStr.toLatin1());
+ QString componentStr = "import Qt 4.6\nText { color: \"" + colorStr + "\"; text: \"Hello World\" }";
+ QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://"));
QFxText *textObject = qobject_cast<QFxText*>(textComponent.create());
QCOMPARE(textObject->color(), testColor);
diff --git a/tests/auto/declarative/qfxtextedit/data/cursorTest.qml b/tests/auto/declarative/qfxtextedit/data/cursorTest.qml
index 25e53d0..e5df8f1 100644
--- a/tests/auto/declarative/qfxtextedit/data/cursorTest.qml
+++ b/tests/auto/declarative/qfxtextedit/data/cursorTest.qml
@@ -1,8 +1,8 @@
import Qt 4.6
-Rect { width: 300; height: 300; color: "white"
- TextEdit { text: "Hello world!"; focusable: true; id: textEditObject
- resources: [ Component { id:cursor; Item { id:cursorInstance } } ]
+Rectangle { width: 300; height: 300; color: "white"
+ TextEdit { text: "Hello world!"; id: textEditObject; objectName: "textEditObject"
+ resources: [ Component { id:cursor; Item { id:cursorInstance; objectName: "cursorInstance" } } ]
cursorDelegate: cursor
}
}
diff --git a/tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp b/tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp
index 241dbad..c4fc506 100644
--- a/tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp
+++ b/tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp
@@ -89,7 +89,7 @@ tst_qfxtextedit::tst_qfxtextedit()
void tst_qfxtextedit::text()
{
{
- QmlComponent texteditComponent(&engine, "TextEdit { text: \"\" }", QUrl());
+ QmlComponent texteditComponent(&engine, "import Qt 4.6\nTextEdit { text: \"\" }", QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
QVERIFY(textEditObject != 0);
@@ -98,7 +98,7 @@ void tst_qfxtextedit::text()
for (int i = 0; i < standard.size(); i++)
{
- QString componentStr = "TextEdit { text: \"" + standard.at(i) + "\" }";
+ QString componentStr = "import Qt 4.6\nTextEdit { text: \"" + standard.at(i) + "\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
@@ -108,7 +108,7 @@ void tst_qfxtextedit::text()
for (int i = 0; i < richText.size(); i++)
{
- QString componentStr = "TextEdit { text: \"" + richText.at(i) + "\" }";
+ QString componentStr = "import Qt 4.6\nTextEdit { text: \"" + richText.at(i) + "\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
@@ -126,7 +126,7 @@ void tst_qfxtextedit::width()
{
// uses Font metrics to find the width for standard and document to find the width for rich
{
- QmlComponent texteditComponent(&engine, "TextEdit { text: \"\" }", QUrl());
+ QmlComponent texteditComponent(&engine, "import Qt 4.6\nTextEdit { text: \"\" }", QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
QVERIFY(textEditObject != 0);
@@ -139,7 +139,7 @@ void tst_qfxtextedit::width()
QFontMetrics fm(f);
int metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width();
- QString componentStr = "TextEdit { text: \"" + standard.at(i) + "\" }";
+ QString componentStr = "import Qt 4.6\nTextEdit { text: \"" + standard.at(i) + "\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
@@ -155,7 +155,7 @@ void tst_qfxtextedit::width()
int documentWidth = document.idealWidth();
- QString componentStr = "TextEdit { text: \"" + richText.at(i) + "\" }";
+ QString componentStr = "import Qt 4.6\nTextEdit { text: \"" + richText.at(i) + "\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
@@ -168,7 +168,7 @@ void tst_qfxtextedit::wrap()
{
// for specified width and wrap set true
{
- QmlComponent texteditComponent(&engine, "TextEdit { text: \"\"; wrap: true; width: 300 }", QUrl());
+ QmlComponent texteditComponent(&engine, "import Qt 4.6\nTextEdit { text: \"\"; wrap: true; width: 300 }", QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
QVERIFY(textEditObject != 0);
@@ -177,7 +177,7 @@ void tst_qfxtextedit::wrap()
for (int i = 0; i < standard.size(); i++)
{
- QString componentStr = "TextEdit { wrap: true; width: 300; text: \"" + standard.at(i) + "\" }";
+ QString componentStr = "import Qt 4.6\nTextEdit { wrap: true; width: 300; text: \"" + standard.at(i) + "\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
@@ -187,7 +187,7 @@ void tst_qfxtextedit::wrap()
for (int i = 0; i < richText.size(); i++)
{
- QString componentStr = "TextEdit { wrap: true; width: 300; text: \"" + richText.at(i) + "\" }";
+ QString componentStr = "import Qt 4.6\nTextEdit { wrap: true; width: 300; text: \"" + richText.at(i) + "\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
@@ -206,7 +206,7 @@ void tst_qfxtextedit::hAlign()
{
for (int j=0; j < hAlignmentStrings.size(); j++)
{
- QString componentStr = "TextEdit { hAlign: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
+ QString componentStr = "import Qt 4.6\nTextEdit { horizontalAlignment: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
@@ -219,7 +219,7 @@ void tst_qfxtextedit::hAlign()
{
for (int j=0; j < hAlignmentStrings.size(); j++)
{
- QString componentStr = "TextEdit { hAlign: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
+ QString componentStr = "import Qt 4.6\nTextEdit { horizontalAlignment: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
@@ -238,7 +238,7 @@ void tst_qfxtextedit::vAlign()
{
for (int j=0; j < vAlignmentStrings.size(); j++)
{
- QString componentStr = "TextEdit { vAlign: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
+ QString componentStr = "import Qt 4.6\nTextEdit { verticalAlignment: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
@@ -251,7 +251,7 @@ void tst_qfxtextedit::vAlign()
{
for (int j=0; j < vAlignmentStrings.size(); j++)
{
- QString componentStr = "TextEdit { vAlign: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
+ QString componentStr = "import Qt 4.6\nTextEdit { verticalAlignment: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
@@ -266,54 +266,54 @@ void tst_qfxtextedit::font()
{
//test size, then bold, then italic, then family
{
- QString componentStr = "TextEdit { font.size: 40; text: \"Hello World\" }";
+ QString componentStr = "import Qt 4.6\nTextEdit { font.pointSize: 40; text: \"Hello World\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->font()->size(), qreal(40));
- QCOMPARE(textEditObject->font()->bold(), false);
- QCOMPARE(textEditObject->font()->italic(), false);
+ QCOMPARE(textEditObject->font().pointSize(), 40);
+ QCOMPARE(textEditObject->font().bold(), false);
+ QCOMPARE(textEditObject->font().italic(), false);
}
{
- QString componentStr = "TextEdit { font.bold: true; text: \"Hello World\" }";
+ QString componentStr = "import Qt 4.6\nTextEdit { font.bold: true; text: \"Hello World\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->font()->bold(), true);
- QCOMPARE(textEditObject->font()->italic(), false);
+ QCOMPARE(textEditObject->font().bold(), true);
+ QCOMPARE(textEditObject->font().italic(), false);
}
{
- QString componentStr = "TextEdit { font.italic: true; text: \"Hello World\" }";
+ QString componentStr = "import Qt 4.6\nTextEdit { font.italic: true; text: \"Hello World\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->font()->italic(), true);
- QCOMPARE(textEditObject->font()->bold(), false);
+ QCOMPARE(textEditObject->font().italic(), true);
+ QCOMPARE(textEditObject->font().bold(), false);
}
{
- QString componentStr = "TextEdit { font.family: \"Helvetica\"; text: \"Hello World\" }";
+ QString componentStr = "import Qt 4.6\nTextEdit { font.family: \"Helvetica\"; text: \"Hello World\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->font()->family(), QString("Helvetica"));
- QCOMPARE(textEditObject->font()->bold(), false);
- QCOMPARE(textEditObject->font()->italic(), false);
+ QCOMPARE(textEditObject->font().family(), QString("Helvetica"));
+ QCOMPARE(textEditObject->font().bold(), false);
+ QCOMPARE(textEditObject->font().italic(), false);
}
{
- QString componentStr = "TextEdit { font.family: \"\"; text: \"Hello World\" }";
+ QString componentStr = "import Qt 4.6\nTextEdit { font.family: \"\"; text: \"Hello World\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->font()->family(), QString(""));
+ QCOMPARE(textEditObject->font().family(), QString(""));
}
}
@@ -322,7 +322,7 @@ void tst_qfxtextedit::color()
//test style
for (int i = 0; i < colorStrings.size(); i++)
{
- QString componentStr = "TextEdit { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
+ QString componentStr = "import Qt 4.6\nTextEdit { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
//qDebug() << "textEditObject: " << textEditObject->color() << "vs. " << QColor(colorStrings.at(i));
@@ -335,7 +335,7 @@ void tst_qfxtextedit::color()
QColor testColor("#001234");
testColor.setAlpha(170);
- QString componentStr = "TextEdit { color: \"" + colorStr + "\"; text: \"Hello World\" }";
+ QString componentStr = "import Qt 4.6\nTextEdit { color: \"" + colorStr + "\"; text: \"Hello World\" }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
@@ -347,7 +347,7 @@ void tst_qfxtextedit::color()
void tst_qfxtextedit::selection()
{
QString testStr = standard[0];//TODO: What should happen for multiline/rich text?
- QString componentStr = "TextEdit { text: \""+ testStr +"\"; }";
+ QString componentStr = "import Qt 4.6\nTextEdit { text: \""+ testStr +"\"; }";
QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
QVERIFY(textEditObject != 0);
diff --git a/tests/auto/declarative/qfxtextinput/data/navigation.qml b/tests/auto/declarative/qfxtextinput/data/navigation.qml
index c1a6162..282c52c 100644
--- a/tests/auto/declarative/qfxtextinput/data/navigation.qml
+++ b/tests/auto/declarative/qfxtextinput/data/navigation.qml
@@ -6,11 +6,11 @@ Rectangle {
width: 800; height: 600; color: "blue"
Item {
- id: FirstItem
+ id: FirstItem;
KeyNavigation.right: Input
}
- TextInput { id: Input; focus: true;
+ TextInput { id: Input; focus: true
KeyNavigation.left: FirstItem
KeyNavigation.right: LastItem
KeyNavigation.up: FirstItem
diff --git a/tests/auto/declarative/qfxtextinput/tst_qfxtextinput.cpp b/tests/auto/declarative/qfxtextinput/tst_qfxtextinput.cpp
index 852a868..c883aa3 100644
--- a/tests/auto/declarative/qfxtextinput/tst_qfxtextinput.cpp
+++ b/tests/auto/declarative/qfxtextinput/tst_qfxtextinput.cpp
@@ -1,8 +1,9 @@
#include <qtest.h>
+#include "../../../shared/util.h"
#include <QtDeclarative/qmlengine.h>
#include <QFile>
#include <QtDeclarative/qfxview.h>
-#include <qfxtextinput.h>
+#include <QFxTextInput>
#include <QDebug>
class tst_qfxtextinput : public QObject
@@ -13,6 +14,17 @@ public:
tst_qfxtextinput();
private slots:
+ void text();
+ void width();
+ void font();
+ void color();
+ void selection();
+
+ void maxLength();
+ void masks();
+ void validators();
+
+ void cursorDelegate();
void navigation();
private:
@@ -20,10 +32,280 @@ private:
QFxView *createView(const QString &filename);
QmlEngine engine;
+ QStringList standard;
+ QStringList colorStrings;
};
tst_qfxtextinput::tst_qfxtextinput()
{
+ standard << "the quick brown fox jumped over the lazy dog"
+ << "It's supercalifragisiticexpialidocious!"
+ << "Hello, world!";
+
+ colorStrings << "aliceblue"
+ << "antiquewhite"
+ << "aqua"
+ << "darkkhaki"
+ << "darkolivegreen"
+ << "dimgray"
+ << "palevioletred"
+ << "lightsteelblue"
+ << "#000000"
+ << "#AAAAAA"
+ << "#FFFFFF"
+ << "#2AC05F";
+}
+
+void tst_qfxtextinput::text()
+{
+ {
+ QmlComponent textinputComponent(&engine, "import Qt 4.6\nTextInput { text: \"\" }", QUrl());
+ QFxTextInput *textinputObject = qobject_cast<QFxTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->text(), QString(""));
+ }
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QString componentStr = "import Qt 4.6\nTextInput { text: \"" + standard.at(i) + "\" }";
+ QmlComponent textinputComponent(&engine, componentStr.toLatin1(), QUrl());
+ QFxTextInput *textinputObject = qobject_cast<QFxTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->text(), standard.at(i));
+ }
+
+}
+
+void tst_qfxtextinput::width()
+{
+ // uses Font metrics to find the width for standard
+ {
+ QmlComponent textinputComponent(&engine, "import Qt 4.6\nTextInput { text: \"\" }", QUrl());
+ QFxTextInput *textinputObject = qobject_cast<QFxTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->width(), 1.);//1 for the cursor
+ }
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QFont f;
+ QFontMetrics fm(f);
+ int metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width();
+
+ QString componentStr = "import Qt 4.6\nTextInput { text: \"" + standard.at(i) + "\" }";
+ QmlComponent textinputComponent(&engine, componentStr.toLatin1(), QUrl());
+ QFxTextInput *textinputObject = qobject_cast<QFxTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->width(), qreal(metricWidth) + 1.);//1 for the cursor
+ }
+}
+
+void tst_qfxtextinput::font()
+{
+ //test size, then bold, then italic, then family
+ {
+ QString componentStr = "import Qt 4.6\nTextInput { font.pointSize: 40; text: \"Hello World\" }";
+ QmlComponent textinputComponent(&engine, componentStr.toLatin1(), QUrl());
+ QFxTextInput *textinputObject = qobject_cast<QFxTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->font().pointSize(), 40);
+ QCOMPARE(textinputObject->font().bold(), false);
+ QCOMPARE(textinputObject->font().italic(), false);
+ }
+
+ {
+ QString componentStr = "import Qt 4.6\nTextInput { font.bold: true; text: \"Hello World\" }";
+ QmlComponent textinputComponent(&engine, componentStr.toLatin1(), QUrl());
+ QFxTextInput *textinputObject = qobject_cast<QFxTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->font().bold(), true);
+ QCOMPARE(textinputObject->font().italic(), false);
+ }
+
+ {
+ QString componentStr = "import Qt 4.6\nTextInput { font.italic: true; text: \"Hello World\" }";
+ QmlComponent textinputComponent(&engine, componentStr.toLatin1(), QUrl());
+ QFxTextInput *textinputObject = qobject_cast<QFxTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->font().italic(), true);
+ QCOMPARE(textinputObject->font().bold(), false);
+ }
+
+ {
+ QString componentStr = "import Qt 4.6\nTextInput { font.family: \"Helvetica\"; text: \"Hello World\" }";
+ QmlComponent textinputComponent(&engine, componentStr.toLatin1(), QUrl());
+ QFxTextInput *textinputObject = qobject_cast<QFxTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->font().family(), QString("Helvetica"));
+ QCOMPARE(textinputObject->font().bold(), false);
+ QCOMPARE(textinputObject->font().italic(), false);
+ }
+
+ {
+ QString componentStr = "import Qt 4.6\nTextInput { font.family: \"\"; text: \"Hello World\" }";
+ QmlComponent textinputComponent(&engine, componentStr.toLatin1(), QUrl());
+ QFxTextInput *textinputObject = qobject_cast<QFxTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->font().family(), QString(""));
+ }
+}
+
+void tst_qfxtextinput::color()
+{
+ //test style
+ for (int i = 0; i < colorStrings.size(); i++)
+ {
+ QString componentStr = "import Qt 4.6\nTextInput { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
+ QmlComponent textinputComponent(&engine, componentStr.toLatin1(), QUrl());
+ QFxTextInput *textinputObject = qobject_cast<QFxTextInput*>(textinputComponent.create());
+ //qDebug() << "textinputObject: " << textinputObject->color() << "vs. " << QColor(colorStrings.at(i));
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->color(), QColor(colorStrings.at(i)));
+ }
+
+ {
+ QString colorStr = "#AA001234";
+ QColor testColor("#001234");
+ testColor.setAlpha(170);
+
+ QString componentStr = "import Qt 4.6\nTextInput { color: \"" + colorStr + "\"; text: \"Hello World\" }";
+ QmlComponent textinputComponent(&engine, componentStr.toLatin1(), QUrl());
+ QFxTextInput *textinputObject = qobject_cast<QFxTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->color(), testColor);
+ }
+}
+
+void tst_qfxtextinput::selection()
+{
+ QString testStr = standard[0];
+ QString componentStr = "import Qt 4.6\nTextInput { text: \""+ testStr +"\"; }";
+ QmlComponent textinputComponent(&engine, componentStr.toLatin1(), QUrl());
+ QFxTextInput *textinputObject = qobject_cast<QFxTextInput*>(textinputComponent.create());
+ QVERIFY(textinputObject != 0);
+
+
+ //Test selection follows cursor
+ for(int i=0; i<= testStr.size(); i++) {
+ textinputObject->setCursorPosition(i);
+ QCOMPARE(textinputObject->cursorPosition(), i);
+ QCOMPARE(textinputObject->selectionStart(), i);
+ QCOMPARE(textinputObject->selectionEnd(), i);
+ QVERIFY(textinputObject->selectedText().isNull());
+ }
+
+ textinputObject->setCursorPosition(0);
+ QVERIFY(textinputObject->cursorPosition() == 0);
+ QVERIFY(textinputObject->selectionStart() == 0);
+ QVERIFY(textinputObject->selectionEnd() == 0);
+ QVERIFY(textinputObject->selectedText().isNull());
+
+ //Test selection
+ for(int i=0; i<= testStr.size(); i++) {
+ textinputObject->setSelectionEnd(i);
+ QCOMPARE(testStr.mid(0,i), textinputObject->selectedText());
+ }
+ for(int i=0; i<= testStr.size(); i++) {
+ textinputObject->setSelectionStart(i);
+ QCOMPARE(testStr.mid(i,testStr.size()-i), textinputObject->selectedText());
+ }
+
+ textinputObject->setCursorPosition(0);
+ QVERIFY(textinputObject->cursorPosition() == 0);
+ QVERIFY(textinputObject->selectionStart() == 0);
+ QVERIFY(textinputObject->selectionEnd() == 0);
+ QVERIFY(textinputObject->selectedText().isNull());
+
+ for(int i=0; i< testStr.size(); i++) {
+ textinputObject->setSelectionStart(i);
+ QCOMPARE(textinputObject->selectionEnd(), i);
+ QCOMPARE(testStr.mid(i,0), textinputObject->selectedText());
+ textinputObject->setSelectionEnd(i+1);
+ QCOMPARE(textinputObject->selectionStart(), i);
+ QCOMPARE(testStr.mid(i,1), textinputObject->selectedText());
+ }
+
+ for(int i= testStr.size() - 1; i>0; i--) {
+ textinputObject->setSelectionEnd(i);
+ QCOMPARE(testStr.mid(i,0), textinputObject->selectedText());
+ textinputObject->setSelectionStart(i-1);
+ QCOMPARE(testStr.mid(i-1,1), textinputObject->selectedText());
+ }
+
+ //Test Error Ignoring behaviour
+ textinputObject->setCursorPosition(0);
+ QVERIFY(textinputObject->selectedText().isNull());
+ textinputObject->setSelectionStart(-10);
+ QVERIFY(textinputObject->selectedText().isNull());
+ textinputObject->setSelectionStart(100);
+ QVERIFY(textinputObject->selectedText().isNull());
+ textinputObject->setSelectionEnd(-10);
+ QVERIFY(textinputObject->selectedText().isNull());
+ textinputObject->setSelectionEnd(100);
+ QVERIFY(textinputObject->selectedText().isNull());
+ textinputObject->setSelectionStart(0);
+ textinputObject->setSelectionEnd(10);
+ QVERIFY(textinputObject->selectedText().size() == 10);
+ textinputObject->setSelectionStart(-10);
+ QVERIFY(textinputObject->selectedText().size() == 10);
+ textinputObject->setSelectionStart(100);
+ QVERIFY(textinputObject->selectedText().size() == 10);
+ textinputObject->setSelectionEnd(-10);
+ QVERIFY(textinputObject->selectedText().size() == 10);
+ textinputObject->setSelectionEnd(100);
+ QVERIFY(textinputObject->selectedText().size() == 10);
+}
+
+void tst_qfxtextinput::maxLength()
+{
+ QFxView *canvas = createView(SRCDIR "/data/navigation.qml");
+ canvas->execute();
+ canvas->show();
+
+ QVERIFY(canvas->root() != 0);
+
+ QFxItem *input = qobject_cast<QFxItem *>(qvariant_cast<QObject *>(canvas->root()->property("myInput")));
+
+ QVERIFY(input != 0);
+ //TODO: Me
+}
+
+void tst_qfxtextinput::masks()
+{
+ QFxView *canvas = createView(SRCDIR "/data/navigation.qml");
+ canvas->execute();
+ canvas->show();
+
+ QVERIFY(canvas->root() != 0);
+
+ QFxItem *input = qobject_cast<QFxItem *>(qvariant_cast<QObject *>(canvas->root()->property("myInput")));
+
+ QVERIFY(input != 0);
+ //TODO: Me
+}
+
+void tst_qfxtextinput::validators()
+{
+ QFxView *canvas = createView(SRCDIR "/data/navigation.qml");
+ canvas->execute();
+ canvas->show();
+
+ QVERIFY(canvas->root() != 0);
+
+ QFxItem *input = qobject_cast<QFxItem *>(qvariant_cast<QObject *>(canvas->root()->property("myInput")));
+
+ QVERIFY(input != 0);
+ //TODO: Me
}
/*
@@ -41,7 +323,7 @@ void tst_qfxtextinput::navigation()
QFxItem *input = qobject_cast<QFxItem *>(qvariant_cast<QObject *>(canvas->root()->property("myInput")));
QVERIFY(input != 0);
- QVERIFY(input->hasFocus() == true);
+ QTRY_VERIFY(input->hasFocus() == true);
simulateKey(canvas, Qt::Key_Left);
QVERIFY(input->hasFocus() == false);
simulateKey(canvas, Qt::Key_Right);
@@ -52,6 +334,11 @@ void tst_qfxtextinput::navigation()
QVERIFY(input->hasFocus() == true);
}
+void tst_qfxtextinput::cursorDelegate()
+{
+ //TODO:Get the QFxTextInput test passing first
+}
+
void tst_qfxtextinput::simulateKey(QFxView *view, int key)
{
QKeyEvent press(QKeyEvent::KeyPress, key, 0);
diff --git a/tests/auto/declarative/qmlparser/Alias.qml b/tests/auto/declarative/qmlparser/Alias.qml
new file mode 100644
index 0000000..8264e0d
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/Alias.qml
@@ -0,0 +1,8 @@
+import Qt 4.6
+
+Object {
+ id: Root
+ property int value: 1892
+ property alias aliasValue: Root.value
+}
+
diff --git a/tests/auto/declarative/qmlparser/alias.1.qml b/tests/auto/declarative/qmlparser/alias.1.qml
new file mode 100644
index 0000000..492d99a
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/alias.1.qml
@@ -0,0 +1,8 @@
+import Test 1.0
+import Qt 4.6
+
+Object {
+ id: Root
+ property int value: 10
+ property alias valueAlias: Root.value
+}
diff --git a/tests/auto/declarative/qmlparser/alias.2.qml b/tests/auto/declarative/qmlparser/alias.2.qml
new file mode 100644
index 0000000..aa4d103
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/alias.2.qml
@@ -0,0 +1,8 @@
+import Test 1.0
+
+MyQmlObject {
+ id: Root
+ property alias aliasObject: Root.qmlobjectProperty
+
+ qmlobjectProperty: MyQmlObject { value : 10 }
+}
diff --git a/tests/auto/declarative/qmlparser/alias.3.qml b/tests/auto/declarative/qmlparser/alias.3.qml
new file mode 100644
index 0000000..e25fbae
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/alias.3.qml
@@ -0,0 +1,10 @@
+import Qt 4.6
+
+Object {
+ property var other
+ other: Alias { id: MyAliasObject }
+
+ property alias value: MyAliasObject.aliasValue
+ property alias value2: MyAliasObject.value
+}
+
diff --git a/tests/auto/declarative/qmlparser/customParserIdNotAllowed.errors.txt b/tests/auto/declarative/qmlparser/customParserIdNotAllowed.errors.txt
new file mode 100644
index 0000000..d28c0bd
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/customParserIdNotAllowed.errors.txt
@@ -0,0 +1 @@
+4:19:Cannot use reserved "id" property in ListModel
diff --git a/tests/auto/declarative/qmlparser/customParserIdNotAllowed.qml b/tests/auto/declarative/qmlparser/customParserIdNotAllowed.qml
new file mode 100644
index 0000000..e607768
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/customParserIdNotAllowed.qml
@@ -0,0 +1,5 @@
+import Qt 4.6
+ListModel {
+ ListElement { a: 10 }
+ ListElement { id: Foo; a: 12 }
+}
diff --git a/tests/auto/declarative/qmlparser/listItemDeleteSelf.qml b/tests/auto/declarative/qmlparser/listItemDeleteSelf.qml
new file mode 100644
index 0000000..fa2e831
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/listItemDeleteSelf.qml
@@ -0,0 +1,38 @@
+import Qt 4.6
+
+Item {
+ ListModel {
+ id: FruitModel
+ ListElement {
+ name: "Apple"
+ cost: 2.45
+ }
+ ListElement {
+ name: "Orange"
+ cost: 3.25
+ }
+ ListElement {
+ name: "Banana"
+ cost: 1.95
+ }
+ }
+
+ Component {
+ id: FruitDelegate
+ Item {
+ width: 200; height: 50
+ Text { text: name }
+ Text { text: '$'+cost; anchors.right: parent.right }
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: FruitModel.remove(index)
+ }
+ }
+ }
+
+ ListView {
+ model: FruitModel
+ delegate: FruitDelegate
+ anchors.fill: parent
+ }
+}
diff --git a/tests/auto/declarative/qmlparser/testtypes.h b/tests/auto/declarative/qmlparser/testtypes.h
index 3b5d3ae..e3e9aae 100644
--- a/tests/auto/declarative/qmlparser/testtypes.h
+++ b/tests/auto/declarative/qmlparser/testtypes.h
@@ -59,9 +59,11 @@ class MyQmlObject : public QObject, public MyInterface, public QmlParserStatus
Q_PROPERTY(MyInterface *interfaceProperty READ interface WRITE setInterface)
Q_PROPERTY(int onLiteralSignal READ onLiteralSignal WRITE setOnLiteralSignal);
Q_PROPERTY(MyCustomVariantType customType READ customType WRITE setCustomType);
+ Q_PROPERTY(MyQmlObject *qmlobjectProperty READ qmlobject WRITE setQmlobject)
+
Q_INTERFACES(MyInterface QmlParserStatus)
public:
- MyQmlObject() : m_value(-1), m_interface(0) { qRegisterMetaType<MyCustomVariantType>("MyCustomVariantType"); }
+ MyQmlObject() : m_value(-1), m_interface(0), m_qmlobject(0) { qRegisterMetaType<MyCustomVariantType>("MyCustomVariantType"); }
int value() const { return m_value; }
void setValue(int v) { m_value = v; }
@@ -88,6 +90,9 @@ public:
int onLiteralSignal() const { return m_value; }
void setOnLiteralSignal(int v) { m_value = v; }
+ MyQmlObject *qmlobject() const { return m_qmlobject; }
+ void setQmlobject(MyQmlObject *o) { m_qmlobject = o; }
+
MyCustomVariantType customType() const { return m_custom; }
void setCustomType(const MyCustomVariantType &v) { m_custom = v; }
public slots:
@@ -100,6 +105,7 @@ private:
friend class tst_qmlparser;
int m_value;
MyInterface *m_interface;
+ MyQmlObject *m_qmlobject;
MyCustomVariantType m_custom;
};
QML_DECLARE_TYPE(MyQmlObject);
diff --git a/tests/auto/declarative/qmlparser/tst_qmlparser.cpp b/tests/auto/declarative/qmlparser/tst_qmlparser.cpp
index e3735e7..b8bd0e7 100644
--- a/tests/auto/declarative/qmlparser/tst_qmlparser.cpp
+++ b/tests/auto/declarative/qmlparser/tst_qmlparser.cpp
@@ -48,6 +48,7 @@ private slots:
void customVariantTypes();
void valueTypes();
void cppnamespace();
+ void aliasProperties();
void importsBuiltin_data();
void importsBuiltin();
@@ -159,6 +160,8 @@ void tst_qmlparser::errors_data()
QTest::newRow("finalOverride") << "finalOverride.qml" << "finalOverride.errors.txt" << false;
QTest::newRow("importNamespaceConflict") << "importNamespaceConflict.qml" << "importNamespaceConflict.errors.txt" << false;
+
+ QTest::newRow("customParserIdNotAllowed") << "customParserIdNotAllowed.qml" << "customParserIdNotAllowed.errors.txt" << false;
}
void tst_qmlparser::errors()
@@ -311,7 +314,7 @@ void tst_qmlparser::assignTypeExtremes()
QCOMPARE(object->intProperty(), -0x77359400);
}
-// Tests that custom parser tyeps can be instantiated
+// Tests that custom parser types can be instantiated
void tst_qmlparser::customParserTypes()
{
QmlComponent component(&engine, TEST_FILE("customParserTypes.qml"));
@@ -517,6 +520,76 @@ void tst_qmlparser::cppnamespace()
delete object;
}
+void tst_qmlparser::aliasProperties()
+{
+ // Simple "int" alias
+ {
+ QmlComponent component(&engine, TEST_FILE("alias.1.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ // Read through alias
+ QCOMPARE(object->property("valueAlias").toInt(), 10);
+ object->setProperty("value", QVariant(13));
+ QCOMPARE(object->property("valueAlias").toInt(), 13);
+
+ // Write throught alias
+ object->setProperty("valueAlias", QVariant(19));
+ QCOMPARE(object->property("valueAlias").toInt(), 19);
+ QCOMPARE(object->property("value").toInt(), 19);
+
+ delete object;
+ }
+
+ // Complex object alias
+ {
+ QmlComponent component(&engine, TEST_FILE("alias.2.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ // Read through alias
+ MyQmlObject *v =
+ qvariant_cast<MyQmlObject *>(object->property("aliasObject"));
+ QVERIFY(v != 0);
+ QCOMPARE(v->value(), 10);
+
+ // Write through alias
+ MyQmlObject *v2 = new MyQmlObject();
+ v2->setParent(object);
+ object->setProperty("aliasObject", qVariantFromValue(v2));
+ MyQmlObject *v3 =
+ qvariant_cast<MyQmlObject *>(object->property("aliasObject"));
+ QVERIFY(v3 != 0);
+ QCOMPARE(v3, v2);
+
+ delete object;
+ }
+
+ // Nested aliases
+ {
+ QmlComponent component(&engine, TEST_FILE("alias.3.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("value").toInt(), 1892);
+ QCOMPARE(object->property("value2").toInt(), 1892);
+
+ object->setProperty("value", QVariant(1313));
+ QCOMPARE(object->property("value").toInt(), 1313);
+ QCOMPARE(object->property("value2").toInt(), 1313);
+
+ object->setProperty("value2", QVariant(8080));
+ QCOMPARE(object->property("value").toInt(), 8080);
+ QCOMPARE(object->property("value2").toInt(), 8080);
+
+ delete object;
+ }
+
+}
+
class TestType : public QObject {
Q_OBJECT
public:
diff --git a/tests/auto/declarative/repeater/data/repeater.qml b/tests/auto/declarative/repeater/data/repeater.qml
index 57b1183..57ba9dc 100644
--- a/tests/auto/declarative/repeater/data/repeater.qml
+++ b/tests/auto/declarative/repeater/data/repeater.qml
@@ -1,15 +1,17 @@
import Qt 4.6
-Rect {
+Rectangle {
id: container
+ objectName: "container"
width: 240
height: 320
color: "white"
Repeater {
id: repeater
+ objectName: "repeater"
width: 240
height: 320
- dataSource: testData
+ model: testData
Component {
Text {
y: index*20
diff --git a/tests/auto/declarative/repeater/tst_repeater.cpp b/tests/auto/declarative/repeater/tst_repeater.cpp
index 0e7c187..08f9154 100644
--- a/tests/auto/declarative/repeater/tst_repeater.cpp
+++ b/tests/auto/declarative/repeater/tst_repeater.cpp
@@ -17,7 +17,7 @@ private slots:
private:
QFxView *createView(const QString &filename);
template<typename T>
- T *findItem(QFxItem *parent, const QString &id);
+ T *findItem(QObject *parent, const QString &id);
};
tst_QFxRepeater::tst_QFxRepeater()
@@ -26,7 +26,7 @@ tst_QFxRepeater::tst_QFxRepeater()
void tst_QFxRepeater::stringList()
{
- QFxView *canvas = createView(SRCDIR "/data/repeater.xml");
+ QFxView *canvas = createView(SRCDIR "/data/repeater.qml");
QStringList data;
data << "One";
@@ -35,7 +35,7 @@ void tst_QFxRepeater::stringList()
data << "Four";
QmlContext *ctxt = canvas->rootContext();
- ctxt->setProperty("testData", data);
+ ctxt->setContextProperty("testData", data);
canvas->execute();
qApp->processEvents();
@@ -46,10 +46,10 @@ void tst_QFxRepeater::stringList()
QFxItem *container = findItem<QFxItem>(canvas->root(), "container");
QVERIFY(container != 0);
- QCOMPARE(container->children()->count(), data.count() + 1);
+ QCOMPARE(container->childItems().count(), data.count() + 1);
- for (int i = 1; i < container->children()->count(); ++i) {
- QFxText *name = qobject_cast<QFxText*>(container->children()->at(i));
+ for (int i = 1; i < container->childItems().count(); ++i) {
+ QFxText *name = qobject_cast<QFxText*>(container->childItems().at(i));
QVERIFY(name != 0);
QCOMPARE(name->text(), data.at(i-1));
}
@@ -65,20 +65,20 @@ QFxView *tst_QFxRepeater::createView(const QString &filename)
QFile file(filename);
file.open(QFile::ReadOnly);
- QString xml = file.readAll();
- canvas->setQml(xml, filename);
+ QString qml = file.readAll();
+ canvas->setQml(qml, filename);
return canvas;
}
template<typename T>
-T *tst_QFxRepeater::findItem(QFxItem *parent, const QString &objectName)
+T *tst_QFxRepeater::findItem(QObject *parent, const QString &objectName)
{
const QMetaObject &mo = T::staticMetaObject;
if (mo.cast(parent) && (objectName.isEmpty() || parent->objectName() == objectName))
return static_cast<T*>(parent);
- for (int i = 0; i < parent->children()->count(); ++i) {
- QFxItem *item = findItem<T>(parent->children()->at(i), objectName);
+ for (int i = 0; i < parent->children().count(); ++i) {
+ QFxItem *item = findItem<T>(parent->children().at(i), objectName);
if (item)
return static_cast<T*>(item);
}