summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2009-07-10 01:17:51 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2009-07-10 01:17:51 (GMT)
commit9c13caa3c99af01a9b4c3ff6e178e7dadb61741f (patch)
treeb69df0a23c4628359fc3740e09958980eda7478e /tests/auto/declarative
parentbb1bdcab28e4c52dcea37dfaaa435045b1985eeb (diff)
parent883da42f7c75775502c818aa456c8576d8457ff8 (diff)
downloadQt-9c13caa3c99af01a9b4c3ff6e178e7dadb61741f.zip
Qt-9c13caa3c99af01a9b4c3ff6e178e7dadb61741f.tar.gz
Qt-9c13caa3c99af01a9b4c3ff6e178e7dadb61741f.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui-gv
Conflicts: examples/itemviews/frozencolumn/main.cpp src/declarative/canvas/qsimplecanvas.cpp src/declarative/canvas/qsimplecanvas_p.h src/declarative/canvas/qsimplecanvasitem.h src/declarative/extra/qfxparticles.cpp src/declarative/fx/fx.pri src/declarative/fx/qfxblurfilter.h src/declarative/fx/qfxcontentwrapper.cpp src/declarative/fx/qfxflickable.cpp src/declarative/fx/qfxfocuspanel.h src/declarative/fx/qfxfocusrealm.h src/declarative/fx/qfxhighlightfilter.cpp src/declarative/fx/qfxhighlightfilter.h src/declarative/fx/qfximage.cpp src/declarative/fx/qfxitem.cpp src/declarative/fx/qfxitem.h src/declarative/fx/qfxrect.cpp src/declarative/fx/qfxreflectionfilter.h src/declarative/fx/qfxshadowfilter.cpp src/declarative/fx/qfxshadowfilter.h src/declarative/fx/qfxtext.cpp src/declarative/fx/qfxtext.h src/declarative/fx/qfxtextedit.cpp src/declarative/opengl/glbasicshaders.h src/declarative/test/qfxtestengine.cpp src/declarative/test/qfxtestengine.h src/declarative/test/qfxtestobjects.cpp src/declarative/test/qfxtestobjects.h src/declarative/test/qfxtestview.h src/declarative/util/qfxglobal.h src/declarative/util/qfxview.cpp src/gui/graphicsview/qgraphicsitem_p.h tools/qmlviewer/qmlviewer.cpp
Diffstat (limited to 'tests/auto/declarative')
-rw-r--r--tests/auto/declarative/animations/animations.pro5
-rw-r--r--tests/auto/declarative/animations/data/badproperty1.qml22
-rw-r--r--tests/auto/declarative/animations/data/badtype1.qml10
-rw-r--r--tests/auto/declarative/animations/data/badtype2.qml10
-rw-r--r--tests/auto/declarative/animations/data/badtype3.qml10
-rw-r--r--tests/auto/declarative/animations/data/badtype4.qml23
-rw-r--r--tests/auto/declarative/animations/data/color.qml10
-rw-r--r--tests/auto/declarative/animations/data/dotproperty.qml22
-rw-r--r--tests/auto/declarative/animations/data/mixedtype1.qml22
-rw-r--r--tests/auto/declarative/animations/data/mixedtype2.qml22
-rw-r--r--tests/auto/declarative/animations/data/number.qml10
-rw-r--r--tests/auto/declarative/animations/tst_animations.cpp97
-rw-r--r--tests/auto/declarative/qfxtextedit/data/cursorTest.qml6
-rw-r--r--tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp171
-rw-r--r--tests/auto/declarative/simplecanvasitem/simplecanvasitem.pro1
-rw-r--r--tests/auto/declarative/visual/bindinganimation/bindinganimation.qml12
-rw-r--r--tests/auto/declarative/visual/colorAnimation/colorAnimation.qml10
-rw-r--r--tests/auto/declarative/visual/easing/easing.qml12
-rw-r--r--tests/auto/declarative/visual/flipable/flipable.xml10
-rw-r--r--tests/auto/declarative/visual/pauseAnimation/pauseAnimation.qml4
20 files changed, 442 insertions, 47 deletions
diff --git a/tests/auto/declarative/animations/animations.pro b/tests/auto/declarative/animations/animations.pro
new file mode 100644
index 0000000..419da4e
--- /dev/null
+++ b/tests/auto/declarative/animations/animations.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative
+SOURCES += tst_animations.cpp
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/animations/data/badproperty1.qml b/tests/auto/declarative/animations/data/badproperty1.qml
new file mode 100644
index 0000000..dc35775
--- /dev/null
+++ b/tests/auto/declarative/animations/data/badproperty1.qml
@@ -0,0 +1,22 @@
+Rect {
+ id: Wrapper
+ width: 240
+ height: 320
+ Rect {
+ id: MyRect
+ color: "red"
+ width: 50; height: 50
+ x: 100; y: 100
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: if (Wrapper.state == "state1") Wrapper.state = ""; else Wrapper.state = "state1";
+ }
+ }
+ states: State {
+ name: "state1"
+ SetProperties { target: MyRect; pen.color: "blue" }
+ }
+ transitions: Transition {
+ ColorAnimation { target: MyRect; to: "red"; properties: "pen.colr"; duration: 1000 }
+ }
+}
diff --git a/tests/auto/declarative/animations/data/badtype1.qml b/tests/auto/declarative/animations/data/badtype1.qml
new file mode 100644
index 0000000..691d2b3
--- /dev/null
+++ b/tests/auto/declarative/animations/data/badtype1.qml
@@ -0,0 +1,10 @@
+Rect {
+ width: 240
+ height: 320
+ Rect {
+ color: "red"
+ width: 50; height: 50
+ x: 100; y: 100
+ x: PropertyAnimation { from: "blue"; to: "green"; running: true; }
+ }
+}
diff --git a/tests/auto/declarative/animations/data/badtype2.qml b/tests/auto/declarative/animations/data/badtype2.qml
new file mode 100644
index 0000000..aa248a6
--- /dev/null
+++ b/tests/auto/declarative/animations/data/badtype2.qml
@@ -0,0 +1,10 @@
+Rect {
+ width: 240
+ height: 320
+ Rect {
+ color: "red"
+ width: 50; height: 50
+ x: 100; y: 100
+ x: NumberAnimation { from: "blue"; to: "green"; running: true; }
+ }
+}
diff --git a/tests/auto/declarative/animations/data/badtype3.qml b/tests/auto/declarative/animations/data/badtype3.qml
new file mode 100644
index 0000000..f1a89b6
--- /dev/null
+++ b/tests/auto/declarative/animations/data/badtype3.qml
@@ -0,0 +1,10 @@
+Rect {
+ width: 240
+ height: 320
+ Rect {
+ color: "red"
+ color: ColorAnimation { from: 10; to: 15; running: true; }
+ width: 50; height: 50
+ x: 100; y: 100
+ }
+}
diff --git a/tests/auto/declarative/animations/data/badtype4.qml b/tests/auto/declarative/animations/data/badtype4.qml
new file mode 100644
index 0000000..fa4eebe
--- /dev/null
+++ b/tests/auto/declarative/animations/data/badtype4.qml
@@ -0,0 +1,23 @@
+Rect {
+ id: Wrapper
+ width: 240
+ height: 320
+ Rect {
+ id: MyRect
+ color: "red"
+ width: 50; height: 50
+ x: 100; y: 100
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: if (Wrapper.state == "state1") Wrapper.state = ""; else Wrapper.state = "state1";
+ }
+ }
+ states: State {
+ name: "state1"
+ SetProperties { target: MyRect; x: 200; color: "blue" }
+ }
+ transitions: Transition {
+ ColorAnimation { properties: "x,color"; duration: 1000 } //x is real, color is color
+ //NumberAnimation { properties: "x,color"; duration: 1000 } //x is real, color is color
+ }
+}
diff --git a/tests/auto/declarative/animations/data/color.qml b/tests/auto/declarative/animations/data/color.qml
new file mode 100644
index 0000000..051e0e1
--- /dev/null
+++ b/tests/auto/declarative/animations/data/color.qml
@@ -0,0 +1,10 @@
+Rect {
+ width: 240
+ height: 320
+ Rect {
+ color: "red"
+ color: PropertyAnimation { to: "green"; running: true }
+ width: 50; height: 50
+ x: 100; y: 100
+ }
+}
diff --git a/tests/auto/declarative/animations/data/dotproperty.qml b/tests/auto/declarative/animations/data/dotproperty.qml
new file mode 100644
index 0000000..2cfcefe
--- /dev/null
+++ b/tests/auto/declarative/animations/data/dotproperty.qml
@@ -0,0 +1,22 @@
+Rect {
+ id: Wrapper
+ width: 240
+ height: 320
+ Rect {
+ id: MyRect
+ color: "red"
+ width: 50; height: 50
+ x: 100; y: 100
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: if (Wrapper.state == "state1") Wrapper.state = ""; else Wrapper.state = "state1";
+ }
+ }
+ states: State {
+ name: "state1"
+ SetProperties { target: MyRect; pen.color: "blue" }
+ }
+ transitions: Transition {
+ ColorAnimation { properties: "pen.color"; duration: 1000 }
+ }
+}
diff --git a/tests/auto/declarative/animations/data/mixedtype1.qml b/tests/auto/declarative/animations/data/mixedtype1.qml
new file mode 100644
index 0000000..415bbfb
--- /dev/null
+++ b/tests/auto/declarative/animations/data/mixedtype1.qml
@@ -0,0 +1,22 @@
+Rect {
+ id: Wrapper
+ width: 240
+ height: 320
+ Rect {
+ id: MyRect
+ color: "red"
+ width: 50; height: 50
+ x: 100; y: 100
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: if (Wrapper.state == "state1") Wrapper.state = ""; else Wrapper.state = "state1";
+ }
+ }
+ states: State {
+ name: "state1"
+ SetProperties { target: MyRect; x: 200; width: 40 }
+ }
+ transitions: Transition {
+ PropertyAnimation { properties: "x,width"; duration: 1000 } //x is real, width is int
+ }
+}
diff --git a/tests/auto/declarative/animations/data/mixedtype2.qml b/tests/auto/declarative/animations/data/mixedtype2.qml
new file mode 100644
index 0000000..0e9fb8d
--- /dev/null
+++ b/tests/auto/declarative/animations/data/mixedtype2.qml
@@ -0,0 +1,22 @@
+Rect {
+ id: Wrapper
+ width: 240
+ height: 320
+ Rect {
+ id: MyRect
+ color: "red"
+ width: 50; height: 50
+ x: 100; y: 100
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: if (Wrapper.state == "state1") Wrapper.state = ""; else Wrapper.state = "state1";
+ }
+ }
+ states: State {
+ name: "state1"
+ SetProperties { target: MyRect; x: 200; color: "blue" }
+ }
+ transitions: Transition {
+ PropertyAnimation { properties: "x,color"; duration: 1000 } //x is real, color is color
+ }
+}
diff --git a/tests/auto/declarative/animations/data/number.qml b/tests/auto/declarative/animations/data/number.qml
new file mode 100644
index 0000000..feb551b
--- /dev/null
+++ b/tests/auto/declarative/animations/data/number.qml
@@ -0,0 +1,10 @@
+Rect {
+ width: 240
+ height: 320
+ Rect {
+ color: "red"
+ width: 50; height: 50
+ x: 100; y: 100
+ x: PropertyAnimation { from: 0; to: 200; duration: 1000; running: true }
+ }
+}
diff --git a/tests/auto/declarative/animations/tst_animations.cpp b/tests/auto/declarative/animations/tst_animations.cpp
new file mode 100644
index 0000000..a493454
--- /dev/null
+++ b/tests/auto/declarative/animations/tst_animations.cpp
@@ -0,0 +1,97 @@
+#include <qtest.h>
+#include <QtDeclarative/qmlengine.h>
+#include <QtDeclarative/qmlcomponent.h>
+#include <QtDeclarative/qfxview.h>
+#include <QtDeclarative/qfxrect.h>
+
+class tst_animations : public QObject
+{
+ Q_OBJECT
+public:
+ tst_animations() {}
+
+private slots:
+ void badTypes();
+ void badProperties();
+ //void mixedTypes();
+};
+
+void tst_animations::badTypes()
+{
+ //don't crash
+ {
+ QFxView *view = new QFxView;
+ view->setUrl(QUrl("file://" SRCDIR "/data/badtype1.qml"));
+
+ view->execute();
+ qApp->processEvents();
+
+ delete view;
+ }
+
+ //make sure we get a compiler error
+ {
+ QmlEngine engine;
+ QmlComponent c(&engine, QUrl("file://" SRCDIR "/data/badtype2.qml"));
+ QTest::ignoreMessage(QtWarningMsg, "QmlComponent: Component is not ready");
+ c.create();
+
+ QVERIFY(c.errors().count() == 1);
+ QCOMPARE(c.errors().at(0).description(), QLatin1String("Cannot convert value \"blue\" to double number"));
+ }
+
+ //make sure we get a compiler error
+ {
+ QmlEngine engine;
+ QmlComponent c(&engine, QUrl("file://" SRCDIR "/data/badtype3.qml"));
+ QTest::ignoreMessage(QtWarningMsg, "QmlComponent: Component is not ready");
+ c.create();
+
+ QVERIFY(c.errors().count() == 1);
+ QCOMPARE(c.errors().at(0).description(), QLatin1String("Cannot convert value \"10\" to color"));
+ }
+}
+
+void tst_animations::badProperties()
+{
+ //don't crash (should be runtime error)
+ {
+ QFxView *view = new QFxView;
+ view->setUrl(QUrl("file://" SRCDIR "/data/badproperty1.qml"));
+
+ view->execute();
+ qApp->processEvents();
+
+ delete view;
+ }
+}
+
+/*//test animating mixed types with property animation
+ //for example, int + real; color + real; etc
+void tst_animations::mixedTypes()
+{
+ //### this one isn't real robust because width will likely change to real as well
+ {
+ QFxView *view = new QFxView;
+ view->setUrl(QUrl("file://" SRCDIR "/data/mixedtype1.qml"));
+
+ view->execute();
+ qApp->processEvents();
+
+ delete view;
+ }
+
+ {
+ QFxView *view = new QFxView;
+ view->setUrl(QUrl("file://" SRCDIR "/data/mixedtype2.qml"));
+
+ view->execute();
+ qApp->processEvents();
+
+ delete view;
+ }
+}*/
+
+QTEST_MAIN(tst_animations)
+
+#include "tst_animations.moc"
diff --git a/tests/auto/declarative/qfxtextedit/data/cursorTest.qml b/tests/auto/declarative/qfxtextedit/data/cursorTest.qml
new file mode 100644
index 0000000..10ac2fd
--- /dev/null
+++ b/tests/auto/declarative/qfxtextedit/data/cursorTest.qml
@@ -0,0 +1,6 @@
+Rect { width: 300; height: 300; color: "white"
+ TextEdit { text: "Hello world!"; focusable: true; id: textEditObject
+ resources: [ Component { id:cursor; Item { id:cursorInstance } } ]
+ cursorDelegate: cursor
+ }
+}
diff --git a/tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp b/tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp
index 7be5b50..241dbad 100644
--- a/tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp
+++ b/tests/auto/declarative/qfxtextedit/tst_qfxtextedit.cpp
@@ -1,6 +1,8 @@
#include <qtest.h>
#include <QTextDocument>
#include <QtDeclarative/qmlengine.h>
+#include <QtDeclarative/qmlcontext.h>
+#include <QtDeclarative/qmlexpression.h>
#include <QtDeclarative/qmlcomponent.h>
#include <QtDeclarative/qfxtextedit.h>
#include <QFontMetrics>
@@ -22,6 +24,9 @@ private slots:
void vAlign();
void font();
void color();
+ void selection();
+
+ void cursorDelegate();
private:
QStringList standard;
@@ -84,7 +89,7 @@ tst_qfxtextedit::tst_qfxtextedit()
void tst_qfxtextedit::text()
{
{
- QmlComponent texteditComponent(&engine, "TextEdit { text: \"\" }");
+ QmlComponent texteditComponent(&engine, "TextEdit { text: \"\" }", QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
QVERIFY(textEditObject != 0);
@@ -94,7 +99,7 @@ void tst_qfxtextedit::text()
for (int i = 0; i < standard.size(); i++)
{
QString componentStr = "TextEdit { text: \"" + standard.at(i) + "\" }";
- QmlComponent texteditComponent(&engine, componentStr.toLatin1());
+ QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
QVERIFY(textEditObject != 0);
@@ -104,7 +109,7 @@ void tst_qfxtextedit::text()
for (int i = 0; i < richText.size(); i++)
{
QString componentStr = "TextEdit { text: \"" + richText.at(i) + "\" }";
- QmlComponent texteditComponent(&engine, componentStr.toLatin1());
+ QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
QVERIFY(textEditObject != 0);
@@ -121,9 +126,10 @@ 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: \"\" }");
+ QmlComponent texteditComponent(&engine, "TextEdit { text: \"\" }", QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
+ QVERIFY(textEditObject != 0);
QCOMPARE(textEditObject->width(), 0.);
}
@@ -134,9 +140,10 @@ void tst_qfxtextedit::width()
int metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width();
QString componentStr = "TextEdit { text: \"" + standard.at(i) + "\" }";
- QmlComponent texteditComponent(&engine, componentStr.toLatin1());
+ QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
+ QVERIFY(textEditObject != 0);
QCOMPARE(textEditObject->width(), qreal(metricWidth));
}
@@ -149,9 +156,10 @@ void tst_qfxtextedit::width()
int documentWidth = document.idealWidth();
QString componentStr = "TextEdit { text: \"" + richText.at(i) + "\" }";
- QmlComponent texteditComponent(&engine, componentStr.toLatin1());
+ QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
+ QVERIFY(textEditObject != 0);
QCOMPARE(textEditObject->width(), qreal(documentWidth));
}
}
@@ -160,27 +168,30 @@ void tst_qfxtextedit::wrap()
{
// for specified width and wrap set true
{
- QmlComponent texteditComponent(&engine, "TextEdit { text: \"\"; wrap: true; width: 300 }");
+ QmlComponent texteditComponent(&engine, "TextEdit { text: \"\"; wrap: true; width: 300 }", QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
+ QVERIFY(textEditObject != 0);
QCOMPARE(textEditObject->width(), 300.);
}
for (int i = 0; i < standard.size(); i++)
{
QString componentStr = "TextEdit { wrap: true; width: 300; text: \"" + standard.at(i) + "\" }";
- QmlComponent texteditComponent(&engine, componentStr.toLatin1());
+ QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
+ QVERIFY(textEditObject != 0);
QCOMPARE(textEditObject->width(), 300.);
}
for (int i = 0; i < richText.size(); i++)
{
QString componentStr = "TextEdit { wrap: true; width: 300; text: \"" + richText.at(i) + "\" }";
- QmlComponent texteditComponent(&engine, componentStr.toLatin1());
+ QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
+ QVERIFY(textEditObject != 0);
QCOMPARE(textEditObject->width(), 300.);
}
@@ -196,9 +207,10 @@ void tst_qfxtextedit::hAlign()
for (int j=0; j < hAlignmentStrings.size(); j++)
{
QString componentStr = "TextEdit { hAlign: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
- QmlComponent texteditComponent(&engine, componentStr.toLatin1());
+ QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
+ QVERIFY(textEditObject != 0);
QCOMPARE((int)textEditObject->hAlign(), (int)hAlignments.at(j));
}
}
@@ -208,9 +220,10 @@ void tst_qfxtextedit::hAlign()
for (int j=0; j < hAlignmentStrings.size(); j++)
{
QString componentStr = "TextEdit { hAlign: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
- QmlComponent texteditComponent(&engine, componentStr.toLatin1());
+ QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
+ QVERIFY(textEditObject != 0);
QCOMPARE((int)textEditObject->hAlign(), (int)hAlignments.at(j));
}
}
@@ -226,9 +239,10 @@ void tst_qfxtextedit::vAlign()
for (int j=0; j < vAlignmentStrings.size(); j++)
{
QString componentStr = "TextEdit { vAlign: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
- QmlComponent texteditComponent(&engine, componentStr.toLatin1());
+ QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
+ QVERIFY(textEditObject != 0);
QCOMPARE((int)textEditObject->vAlign(), (int)vAlignments.at(j));
}
}
@@ -238,9 +252,10 @@ void tst_qfxtextedit::vAlign()
for (int j=0; j < vAlignmentStrings.size(); j++)
{
QString componentStr = "TextEdit { vAlign: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
- QmlComponent texteditComponent(&engine, componentStr.toLatin1());
+ QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
+ QVERIFY(textEditObject != 0);
QCOMPARE((int)textEditObject->vAlign(), (int)vAlignments.at(j));
}
}
@@ -252,9 +267,10 @@ void tst_qfxtextedit::font()
//test size, then bold, then italic, then family
{
QString componentStr = "TextEdit { font.size: 40; text: \"Hello World\" }";
- QmlComponent texteditComponent(&engine, componentStr.toLatin1());
+ 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);
@@ -262,27 +278,30 @@ void tst_qfxtextedit::font()
{
QString componentStr = "TextEdit { font.bold: true; text: \"Hello World\" }";
- QmlComponent texteditComponent(&engine, componentStr.toLatin1());
+ 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);
}
{
QString componentStr = "TextEdit { font.italic: true; text: \"Hello World\" }";
- QmlComponent texteditComponent(&engine, componentStr.toLatin1());
+ 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);
}
{
QString componentStr = "TextEdit { font.family: \"Helvetica\"; text: \"Hello World\" }";
- QmlComponent texteditComponent(&engine, componentStr.toLatin1());
+ 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);
@@ -290,9 +309,10 @@ void tst_qfxtextedit::font()
{
QString componentStr = "TextEdit { font.family: \"\"; text: \"Hello World\" }";
- QmlComponent texteditComponent(&engine, componentStr.toLatin1());
+ QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
+ QVERIFY(textEditObject != 0);
QCOMPARE(textEditObject->font()->family(), QString(""));
}
}
@@ -303,9 +323,10 @@ void tst_qfxtextedit::color()
for (int i = 0; i < colorStrings.size(); i++)
{
QString componentStr = "TextEdit { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QmlComponent texteditComponent(&engine, componentStr.toLatin1());
+ QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
//qDebug() << "textEditObject: " << textEditObject->color() << "vs. " << QColor(colorStrings.at(i));
+ QVERIFY(textEditObject != 0);
QCOMPARE(textEditObject->color(), QColor(colorStrings.at(i)));
}
@@ -315,12 +336,122 @@ void tst_qfxtextedit::color()
testColor.setAlpha(170);
QString componentStr = "TextEdit { color: \"" + colorStr + "\"; text: \"Hello World\" }";
- QmlComponent texteditComponent(&engine, componentStr.toLatin1());
+ QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
+ QVERIFY(textEditObject != 0);
QCOMPARE(textEditObject->color(), testColor);
}
}
+
+void tst_qfxtextedit::selection()
+{
+ QString testStr = standard[0];//TODO: What should happen for multiline/rich text?
+ QString componentStr = "TextEdit { text: \""+ testStr +"\"; }";
+ QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl());
+ QFxTextEdit *textEditObject = qobject_cast<QFxTextEdit*>(texteditComponent.create());
+ QVERIFY(textEditObject != 0);
+
+
+ //Test selection follows cursor
+ for(int i=0; i<= testStr.size(); i++) {
+ textEditObject->setCursorPosition(i);
+ QCOMPARE(textEditObject->cursorPosition(), i);
+ QCOMPARE(textEditObject->selectionStart(), i);
+ QCOMPARE(textEditObject->selectionEnd(), i);
+ QVERIFY(textEditObject->selectedText().isNull());
+ }
+
+ textEditObject->setCursorPosition(0);
+ QVERIFY(textEditObject->cursorPosition() == 0);
+ QVERIFY(textEditObject->selectionStart() == 0);
+ QVERIFY(textEditObject->selectionEnd() == 0);
+ QVERIFY(textEditObject->selectedText().isNull());
+
+ //Test selection
+ for(int i=0; i<= testStr.size(); i++) {
+ textEditObject->setSelectionEnd(i);
+ QCOMPARE(testStr.mid(0,i), textEditObject->selectedText());
+ }
+ for(int i=0; i<= testStr.size(); i++) {
+ textEditObject->setSelectionStart(i);
+ QCOMPARE(testStr.mid(i,testStr.size()-i), textEditObject->selectedText());
+ }
+
+ textEditObject->setCursorPosition(0);
+ QVERIFY(textEditObject->cursorPosition() == 0);
+ QVERIFY(textEditObject->selectionStart() == 0);
+ QVERIFY(textEditObject->selectionEnd() == 0);
+ QVERIFY(textEditObject->selectedText().isNull());
+
+ for(int i=0; i< testStr.size(); i++) {
+ textEditObject->setSelectionStart(i);
+ QCOMPARE(textEditObject->selectionEnd(), i);
+ QCOMPARE(testStr.mid(i,0), textEditObject->selectedText());
+ textEditObject->setSelectionEnd(i+1);
+ QCOMPARE(textEditObject->selectionStart(), i);
+ QCOMPARE(testStr.mid(i,1), textEditObject->selectedText());
+ }
+
+ for(int i= testStr.size() - 1; i>0; i--) {
+ textEditObject->setSelectionEnd(i);
+ QCOMPARE(testStr.mid(i,0), textEditObject->selectedText());
+ textEditObject->setSelectionStart(i-1);
+ QCOMPARE(testStr.mid(i-1,1), textEditObject->selectedText());
+ }
+
+ //Test Error Ignoring behaviour
+ textEditObject->setCursorPosition(0);
+ QVERIFY(textEditObject->selectedText().isNull());
+ textEditObject->setSelectionStart(-10);
+ QVERIFY(textEditObject->selectedText().isNull());
+ textEditObject->setSelectionStart(100);
+ QVERIFY(textEditObject->selectedText().isNull());
+ textEditObject->setSelectionEnd(-10);
+ QVERIFY(textEditObject->selectedText().isNull());
+ textEditObject->setSelectionEnd(100);
+ QVERIFY(textEditObject->selectedText().isNull());
+ textEditObject->setSelectionStart(0);
+ textEditObject->setSelectionEnd(10);
+ QVERIFY(textEditObject->selectedText().size() == 10);
+ textEditObject->setSelectionStart(-10);
+ QVERIFY(textEditObject->selectedText().size() == 10);
+ textEditObject->setSelectionStart(100);
+ QVERIFY(textEditObject->selectedText().size() == 10);
+ textEditObject->setSelectionEnd(-10);
+ QVERIFY(textEditObject->selectedText().size() == 10);
+ textEditObject->setSelectionEnd(100);
+ QVERIFY(textEditObject->selectedText().size() == 10);
+}
+
+#include <QFxView>
+void tst_qfxtextedit::cursorDelegate()
+{
+ QFxView* view = new QFxView(0);
+ view->show();
+ view->setUrl(QUrl("data/cursorTest.qml"));
+ view->execute();
+ QFxTextEdit *textEditObject = view->root()->findChild<QFxTextEdit*>("textEditObject");
+ QVERIFY(textEditObject != 0);
+ QVERIFY(textEditObject->findChild<QFxItem*>("cursorInstance"));
+ //Test Delegate gets created
+ textEditObject->setFocus(true);
+ QFxItem* delegateObject = textEditObject->findChild<QFxItem*>("cursorInstance");
+ QVERIFY(delegateObject);
+ //Test Delegate gets moved
+ for(int i=0; i<= textEditObject->text().length(); i++){
+ textEditObject->setCursorPosition(i);
+ QCOMPARE(textEditObject->cursorRect().x(), qRound(delegateObject->x()));
+ QCOMPARE(textEditObject->cursorRect().y(), qRound(delegateObject->y()));
+ }
+ textEditObject->setCursorPosition(0);
+ QCOMPARE(textEditObject->cursorRect().x(), qRound(delegateObject->x()));
+ QCOMPARE(textEditObject->cursorRect().y(), qRound(delegateObject->y()));
+ //Test Delegate gets deleted
+ textEditObject->setCursorDelegate(0);
+ QVERIFY(!textEditObject->findChild<QFxItem*>("cursorInstance"));
+}
+
QTEST_MAIN(tst_qfxtextedit)
#include "tst_qfxtextedit.moc"
diff --git a/tests/auto/declarative/simplecanvasitem/simplecanvasitem.pro b/tests/auto/declarative/simplecanvasitem/simplecanvasitem.pro
index 114be8e..f4aea32 100644
--- a/tests/auto/declarative/simplecanvasitem/simplecanvasitem.pro
+++ b/tests/auto/declarative/simplecanvasitem/simplecanvasitem.pro
@@ -1,5 +1,6 @@
load(qttest_p4)
contains(QT_CONFIG,declarative): QT += declarative
+contains(QT_CONFIG, opengles2)|contains(QT_CONFIG, opengles1): QT += opengl
SOURCES += tst_simplecanvasitem.cpp
# Define SRCDIR equal to test's source directory
diff --git a/tests/auto/declarative/visual/bindinganimation/bindinganimation.qml b/tests/auto/declarative/visual/bindinganimation/bindinganimation.qml
index 61cedc2..69c5d81 100644
--- a/tests/auto/declarative/visual/bindinganimation/bindinganimation.qml
+++ b/tests/auto/declarative/visual/bindinganimation/bindinganimation.qml
@@ -13,21 +13,19 @@ Rect {
states: [
State {
name: "hello"
- SetProperty {
+ SetProperties {
target: MyRect
- property: "x"
- binding: 100
+ x: 100
}
- SetProperty {
+ SetProperties {
target: MyMouseRegion
- property: "onClicked"
- value: "Page.currentState = ''"
+ onClicked: "Page.currentState = ''"
}
}
]
transitions: [
Transition {
- NumericAnimation {
+ NumberAnimation {
properties: "x"
}
}
diff --git a/tests/auto/declarative/visual/colorAnimation/colorAnimation.qml b/tests/auto/declarative/visual/colorAnimation/colorAnimation.qml
index d351b8c..cb631d4 100644
--- a/tests/auto/declarative/visual/colorAnimation/colorAnimation.qml
+++ b/tests/auto/declarative/visual/colorAnimation/colorAnimation.qml
@@ -5,18 +5,16 @@ Rect {
states: [
State {
name: "first"
- SetProperty {
+ SetProperties {
target: mainrect
- property: "color"
- value: "red"
+ color: "red"
}
},
State {
name: "second"
- SetProperty {
+ SetProperties {
target: mainrect
- property: "color"
- value: "blue"
+ color: "blue"
}
}
]
diff --git a/tests/auto/declarative/visual/easing/easing.qml b/tests/auto/declarative/visual/easing/easing.qml
index 4a0ed14..7a58276 100644
--- a/tests/auto/declarative/visual/easing/easing.qml
+++ b/tests/auto/declarative/visual/easing/easing.qml
@@ -148,19 +148,17 @@ Rect {
State {
name: "from"
when: !mouse.pressed
- SetProperty {
+ SetProperties {
target: text
- property: "x"
- value: 0
+ x: 0
}
},
State {
name: "to"
when: mouse.pressed
- SetProperty {
+ SetProperties {
target: text
- property: "x"
- value: item.width-100
+ x: item.width-100
}
}
]
@@ -169,7 +167,7 @@ Rect {
fromState: "*"
toState: "to"
reversible: true
- NumericAnimation {
+ NumberAnimation {
properties: "x"
easing: type
}
diff --git a/tests/auto/declarative/visual/flipable/flipable.xml b/tests/auto/declarative/visual/flipable/flipable.xml
index d769e55..9288acc 100644
--- a/tests/auto/declarative/visual/flipable/flipable.xml
+++ b/tests/auto/declarative/visual/flipable/flipable.xml
@@ -104,17 +104,17 @@
</states>
<transitions>
<Transition fromState="*" toState="*">
- <NumericAnimation property="r" duration="500" />
+ <NumberAnimation property="r" duration="500" />
<SerialAnimation>
<SetPropertyAction target="{MeRect}" property="moveToParent" value="{Bounce}" />
<ParallelAnimation>
- <NumericAnimation target="{MeRect}" properties="x" to="0" duration="250" />
- <NumericAnimation target="{MeRect}" properties="y" to="0" easing="easeInQuad" duration="250"/>
+ <NumberAnimation target="{MeRect}" properties="x" to="0" duration="250" />
+ <NumberAnimation target="{MeRect}" properties="y" to="0" easing="easeInQuad" duration="250"/>
</ParallelAnimation>
<SetPropertyAction target="{MeRect}" property="moveToParent" />
<ParallelAnimation>
- <NumericAnimation target="{MeRect}" properties="x" to="0" duration="250"/>
- <NumericAnimation target="{MeRect}" properties="y" to="0" easing="easeOutQuad" duration="250"/>
+ <NumberAnimation target="{MeRect}" properties="x" to="0" duration="250"/>
+ <NumberAnimation target="{MeRect}" properties="y" to="0" easing="easeOutQuad" duration="250"/>
</ParallelAnimation>
</SerialAnimation>
</Transition>
diff --git a/tests/auto/declarative/visual/pauseAnimation/pauseAnimation.qml b/tests/auto/declarative/visual/pauseAnimation/pauseAnimation.qml
index 5c00f58..e0880f0 100644
--- a/tests/auto/declarative/visual/pauseAnimation/pauseAnimation.qml
+++ b/tests/auto/declarative/visual/pauseAnimation/pauseAnimation.qml
@@ -11,11 +11,11 @@ Rect {
y: SequentialAnimation {
running: true
repeat: true
- NumericAnimation {
+ NumberAnimation {
to: 0; duration: 500
easing: "easeInOutQuad"
}
- NumericAnimation {
+ NumberAnimation {
to: 200-img.height
easing: "easeOutBounce"
duration: 2000