aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/scenegraph/tst_scenegraph.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/quick/scenegraph/tst_scenegraph.cpp')
-rw-r--r--tests/auto/quick/scenegraph/tst_scenegraph.cpp52
1 files changed, 51 insertions, 1 deletions
diff --git a/tests/auto/quick/scenegraph/tst_scenegraph.cpp b/tests/auto/quick/scenegraph/tst_scenegraph.cpp
index d510fdcda8..301174656c 100644
--- a/tests/auto/quick/scenegraph/tst_scenegraph.cpp
+++ b/tests/auto/quick/scenegraph/tst_scenegraph.cpp
@@ -45,14 +45,59 @@
#include <private/qopenglcontext_p.h>
-
#include <QtQml>
+class PerPixelRect : public QQuickItem
+{
+ Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
+ Q_OBJECT
+public:
+ PerPixelRect() {
+ setFlag(ItemHasContents);
+ }
+
+ void setColor(const QColor &c) {
+ if (c == m_color)
+ return;
+ m_color = c;
+ emit colorChanged(c);
+ }
+
+ QColor color() const { return m_color; }
+
+ QSGNode *updatePaintNode(QSGNode *old, UpdatePaintNodeData *)
+ {
+ if (old)
+ delete old;
+
+ QSGNode *node = new QSGNode();
+
+ for (int y=0; y<height(); ++y) {
+ for (int x=0; x<width(); ++x) {
+ QSGSimpleRectNode *rn = new QSGSimpleRectNode();
+ rn->setRect(x, y, 1, 1);
+ rn->setColor(m_color);
+ node->appendChildNode(rn);
+ }
+ }
+
+ return node;
+ }
+
+Q_SIGNALS:
+ void colorChanged(const QColor &c );
+
+private:
+ QColor m_color;
+};
+
class tst_SceneGraph : public QObject
{
Q_OBJECT
private slots:
+ void initTestCase();
+
void manyWindows_data();
void manyWindows();
@@ -67,6 +112,11 @@ public:
~ScopedList() { qDeleteAll(*this); }
};
+void tst_SceneGraph::initTestCase()
+{
+ qmlRegisterType<PerPixelRect>("SceneGraphTest", 1, 0, "PerPixelRect");
+}
+
QQuickView *createView(const QString &file, QWindow *parent = 0, int x = -1, int y = -1, int w = -1, int h = -1)
{
QQuickView *view = new QQuickView(parent);