aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qquickcanvas/tst_qquickcanvas.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/declarative/qquickcanvas/tst_qquickcanvas.cpp')
-rw-r--r--tests/auto/declarative/qquickcanvas/tst_qquickcanvas.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/auto/declarative/qquickcanvas/tst_qquickcanvas.cpp b/tests/auto/declarative/qquickcanvas/tst_qquickcanvas.cpp
index 95fcd82dfa..829d666b7e 100644
--- a/tests/auto/declarative/qquickcanvas/tst_qquickcanvas.cpp
+++ b/tests/auto/declarative/qquickcanvas/tst_qquickcanvas.cpp
@@ -44,8 +44,11 @@
#include <QTouchEvent>
#include <QtDeclarative/QQuickItem>
#include <QtDeclarative/QQuickCanvas>
+#include <QtDeclarative/QDeclarativeEngine>
+#include <QtDeclarative/QDeclarativeComponent>
#include <QtDeclarative/private/qquickrectangle_p.h>
#include <QtGui/QWindowSystemInterface>
+#include "../shared/util.h"
struct TouchEventData {
QEvent::Type type;
@@ -197,6 +200,9 @@ private slots:
void clearCanvas();
void mouseFiltering();
+
+ void qmlCreation();
+ void clearColor();
};
tst_qquickcanvas::tst_qquickcanvas()
@@ -516,6 +522,35 @@ void tst_qquickcanvas::mouseFiltering()
QCOMPARE(topItem->mousePressId, 3);
}
+void tst_qquickcanvas::qmlCreation()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine);
+ component.loadUrl(TESTDATA("window.qml"));
+ QObject* created = component.create();
+ QVERIFY(created);
+
+ QQuickCanvas* canvas = qobject_cast<QQuickCanvas*>(created);
+ QVERIFY(canvas);
+ QCOMPARE(canvas->clearColor(), QColor(Qt::green));
+
+ QQuickItem* item = canvas->findChild<QQuickItem*>("item");
+ QVERIFY(item);
+ QCOMPARE(item->canvas(), canvas);
+}
+
+void tst_qquickcanvas::clearColor()
+{
+ //### Can we examine rendering to make sure it is really blue?
+ QQuickCanvas *canvas = new QQuickCanvas;
+ canvas->resize(250, 250);
+ canvas->move(100, 100);
+ canvas->setClearColor(Qt::blue);
+ canvas->show();
+ QTest::qWaitForWindowShown(canvas);
+ QCOMPARE(canvas->clearColor(), QColor(Qt::blue));
+ delete canvas;
+}
QTEST_MAIN(tst_qquickcanvas)