diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2011-11-18 19:32:56 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-11-29 03:29:53 +0100 |
commit | ba0d63fd220ff215150e827a21a42c8de3372dd4 (patch) | |
tree | 7182b6234404ce421c14338170e27d72223510e6 /tests | |
parent | 6a198083e5f61fb51c5f1c5d77366edd404bc7c2 (diff) |
Initial window implementation
Includes adding a color property on QQuickCanvas. Note that most Window
related properties come from the QWindow inheritance.
Task-number: QTBUG-19799
Change-Id: I00f6c90a1e2a5c85d787793d6edac2cd7d5309ab
Reviewed-by: Alan Alpert <alan.alpert@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative/qquickcanvas/data/window.qml | 9 | ||||
-rw-r--r-- | tests/auto/declarative/qquickcanvas/tst_qquickcanvas.cpp | 35 |
2 files changed, 44 insertions, 0 deletions
diff --git a/tests/auto/declarative/qquickcanvas/data/window.qml b/tests/auto/declarative/qquickcanvas/data/window.qml new file mode 100644 index 0000000000..d79d5161b5 --- /dev/null +++ b/tests/auto/declarative/qquickcanvas/data/window.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 +import QtQuick.Window 2.0 as Window + +Window.Window { + color: "#00FF00" + Item { + objectName: "item" + } +} 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) |