diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2009-04-22 04:47:24 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2009-04-22 04:47:24 (GMT) |
commit | 2366667fc97eb6a56203b2dd7dac776ff4164abd (patch) | |
tree | b2acb6cc6bfe475d7e619e4788973b61fff775e0 /tests/auto/declarative/simplecanvasitem/tst_simplecanvasitem.cpp | |
parent | 2c762f3b8b284a7c6dc0c499b7052013bad5b707 (diff) | |
download | Qt-2366667fc97eb6a56203b2dd7dac776ff4164abd.zip Qt-2366667fc97eb6a56203b2dd7dac776ff4164abd.tar.gz Qt-2366667fc97eb6a56203b2dd7dac776ff4164abd.tar.bz2 |
Initial import of kinetic-dui branch from the old kinetic
Diffstat (limited to 'tests/auto/declarative/simplecanvasitem/tst_simplecanvasitem.cpp')
-rw-r--r-- | tests/auto/declarative/simplecanvasitem/tst_simplecanvasitem.cpp | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/tests/auto/declarative/simplecanvasitem/tst_simplecanvasitem.cpp b/tests/auto/declarative/simplecanvasitem/tst_simplecanvasitem.cpp new file mode 100644 index 0000000..47608a0 --- /dev/null +++ b/tests/auto/declarative/simplecanvasitem/tst_simplecanvasitem.cpp @@ -0,0 +1,79 @@ +#include <QtTest/QtTest> +#include <qfxview.h> +#include <qfxitem.h> +#include <qsimplecanvasitem.h> + +/* + Note: this autotest is specifically to test SimpleCanvasItem as a component of + Qt Declarative, and therefore will have all items created in XML. +*/ +class tst_SimpleCanvasItem : public QObject +{ + Q_OBJECT +public: + tst_SimpleCanvasItem(); + +private slots: + void test_pos(); + void test_scenePos(); +private: + QFxView *createView(const QString &filename); +}; + +tst_SimpleCanvasItem::tst_SimpleCanvasItem() +{ +} + +void tst_SimpleCanvasItem::test_pos() +{ + QFxView *canvas = createView(SRCDIR "/data/test.xml"); + canvas->execute(); + qApp->processEvents(); + QSimpleCanvasItem* root = qobject_cast<QSimpleCanvasItem*>(canvas->root()); + QVERIFY(root); + + QCOMPARE(root->pos(), QPointF(0,0)); + QCOMPARE(root->children().at(0)->pos(), QPointF(20,20)); + QCOMPARE(root->children().at(0)->children().at(0)->pos(), QPointF(20,20)); + QCOMPARE(root->children().at(2)->pos(), QPointF(60,20)); + QCOMPARE(root->children().at(3)->pos(), QPointF(20,40)); + QCOMPARE(root->children().at(5)->pos(), QPointF(40,40)); +} + +void tst_SimpleCanvasItem::test_scenePos() +{ + QFxView *canvas = createView(SRCDIR "/data/test.xml"); + canvas->execute(); + qApp->processEvents(); + QSimpleCanvasItem* root = qobject_cast<QSimpleCanvasItem*>(canvas->root()); + QVERIFY(root); + +#ifdef CANVAS_GL + QCOMPARE(root->transform(), QMatrix4x4()); +#else + QCOMPARE(root->transform(), QTransform()); +#endif + QCOMPARE(root->scenePos(), QPointF(0,0)); + QCOMPARE(root->children().at(0)->scenePos(), QPointF(20,20)); + QCOMPARE(root->children().at(0)->children().at(0)->scenePos(), QPointF(40,40)); + QCOMPARE(root->children().at(2)->scenePos(), QPointF(60,20)); + QCOMPARE(root->children().at(3)->scenePos(), QPointF(20,40)); + QCOMPARE(root->children().at(5)->scenePos(), QPointF(40,40)); +} + +QFxView *tst_SimpleCanvasItem::createView(const QString &filename) +{ + QFxView *canvas = new QFxView(0); + canvas->setFixedSize(240,320); + + QFile file(filename); + file.open(QFile::ReadOnly); + QString xml = file.readAll(); + canvas->setXml(xml, filename); + + return canvas; +} + +QTEST_MAIN(tst_SimpleCanvasItem) + +#include "tst_simplecanvasitem.moc" |