aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/scenegraph
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/quick/scenegraph')
-rw-r--r--tests/auto/quick/scenegraph/data/logo-big.jpgbin0 -> 14174 bytes
-rw-r--r--tests/auto/quick/scenegraph/data/logo-small.jpgbin0 -> 691 bytes
-rw-r--r--tests/auto/quick/scenegraph/data/manyWindows_dftext.qml50
-rw-r--r--tests/auto/quick/scenegraph/data/manyWindows_image.qml52
-rw-r--r--tests/auto/quick/scenegraph/data/manyWindows_ntext.qml51
-rw-r--r--tests/auto/quick/scenegraph/data/manyWindows_rects.qml70
-rw-r--r--tests/auto/quick/scenegraph/scenegraph.pro11
-rw-r--r--tests/auto/quick/scenegraph/tst_scenegraph.cpp209
8 files changed, 443 insertions, 0 deletions
diff --git a/tests/auto/quick/scenegraph/data/logo-big.jpg b/tests/auto/quick/scenegraph/data/logo-big.jpg
new file mode 100644
index 0000000000..1be71d9945
--- /dev/null
+++ b/tests/auto/quick/scenegraph/data/logo-big.jpg
Binary files differ
diff --git a/tests/auto/quick/scenegraph/data/logo-small.jpg b/tests/auto/quick/scenegraph/data/logo-small.jpg
new file mode 100644
index 0000000000..f11a5dfc6b
--- /dev/null
+++ b/tests/auto/quick/scenegraph/data/logo-small.jpg
Binary files differ
diff --git a/tests/auto/quick/scenegraph/data/manyWindows_dftext.qml b/tests/auto/quick/scenegraph/data/manyWindows_dftext.qml
new file mode 100644
index 0000000000..69d235d021
--- /dev/null
+++ b/tests/auto/quick/scenegraph/data/manyWindows_dftext.qml
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+
+Text
+{
+ width: 100
+ height: 100
+ text: "abcdefghijklmnopqrstuwABCDEFGHIJKLMNOPPQRSTUWXYZ1234567890!@#$%^&*()_"
+ wrapMode: Text.WrapAnywhere
+}
diff --git a/tests/auto/quick/scenegraph/data/manyWindows_image.qml b/tests/auto/quick/scenegraph/data/manyWindows_image.qml
new file mode 100644
index 0000000000..1b356110ed
--- /dev/null
+++ b/tests/auto/quick/scenegraph/data/manyWindows_image.qml
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+
+Image {
+ width: 100
+ height: 100
+ source: "logo-big.jpg"
+ Image {
+ anchors.centerIn: parent
+ source: "logo-small.jpg"
+ }
+}
diff --git a/tests/auto/quick/scenegraph/data/manyWindows_ntext.qml b/tests/auto/quick/scenegraph/data/manyWindows_ntext.qml
new file mode 100644
index 0000000000..ebd06e360b
--- /dev/null
+++ b/tests/auto/quick/scenegraph/data/manyWindows_ntext.qml
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+
+Text
+{
+ width: 100
+ height: 100
+ text: "abcdefghijklmnopqrstuwABCDEFGHIJKLMNOPPQRSTUWXYZ1234567890!@#$%^&*()_"
+ wrapMode: Text.WrapAnywhere
+ renderType: Text.NativeRendering
+}
diff --git a/tests/auto/quick/scenegraph/data/manyWindows_rects.qml b/tests/auto/quick/scenegraph/data/manyWindows_rects.qml
new file mode 100644
index 0000000000..984968985a
--- /dev/null
+++ b/tests/auto/quick/scenegraph/data/manyWindows_rects.qml
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+
+Rectangle {
+ width: 100
+ height: 100
+
+ gradient: Gradient {
+ GradientStop { position: 0; color: "black" }
+ GradientStop { position: 1; color: "red" }
+ }
+
+ Rectangle {
+ width: 40
+ height: 40
+ rotation: 30
+ color: "#00ff00";
+ antialiasing: true
+ x: parent.width / 3 - width / 2
+ y: parent.height / 3 - height/ 2
+ }
+ Rectangle {
+ width: 40
+ height: 40
+ rotation: 30
+ color: "blue"
+ x: parent.width * 2 / 3 - width / 2
+ y: parent.height * 2 / 3 - height/ 2
+ }
+}
diff --git a/tests/auto/quick/scenegraph/scenegraph.pro b/tests/auto/quick/scenegraph/scenegraph.pro
new file mode 100644
index 0000000000..7e7a8eb162
--- /dev/null
+++ b/tests/auto/quick/scenegraph/scenegraph.pro
@@ -0,0 +1,11 @@
+CONFIG += testcase
+TARGET = tst_scenegraph
+SOURCES += tst_scenegraph.cpp
+
+include (../../shared/util.pri)
+
+macx:CONFIG -= app_bundle
+
+QT += core-private gui-private qml-private quick-private testlib
+
+DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/quick/scenegraph/tst_scenegraph.cpp b/tests/auto/quick/scenegraph/tst_scenegraph.cpp
new file mode 100644
index 0000000000..cfa491ce97
--- /dev/null
+++ b/tests/auto/quick/scenegraph/tst_scenegraph.cpp
@@ -0,0 +1,209 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+
+#include <QtQuick>
+#include <private/qquickanimator_p.h>
+
+
+
+#include <QtQml>
+
+class tst_SceneGraph : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void manyWindows_data();
+ void manyWindows();
+
+};
+
+template <typename T> class ScopedList : public QList<T> {
+public:
+ ~ScopedList() { qDeleteAll(*this); }
+};
+
+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);
+ view->setSource(QUrl::fromLocalFile("data/" + file));
+ if (x >= 0 && y >= 0) view->setPosition(x, y);
+ if (w >= 0 && h >= 0) view->resize(w, h);
+ view->show();
+ return view;
+}
+
+QImage showAndGrab(const QString &file, int w, int h)
+{
+ QQuickView view;
+ view.setSource(QUrl::fromLocalFile(QStringLiteral("data/") + file));
+ if (w >= 0 && h >= 0)
+ view.resize(w, h);
+ view.create();
+ return view.grabWindow();
+}
+
+// Assumes the images are opaque white...
+bool containsSomethingOtherThanWhite(const QImage &image)
+{
+ Q_ASSERT(image.format() == QImage::Format_ARGB32_Premultiplied
+ || image.format() == QImage::Format_RGB32);
+ int w = image.width();
+ int h = image.height();
+ for (int y=0; y<h; ++y) {
+ const uint *pixels = (const uint *) image.constScanLine(y);
+ for (int x=0; x<w; ++x)
+ if (pixels[x] != 0xffffffff)
+ return true;
+ }
+ return false;
+}
+
+// To compare images, we need a special function with a bit of error
+// as glyphs has an invisible, but measurable variance depending
+// on where in the glyph cache they end up.
+bool compareImages(const QImage &ia, const QImage &ib)
+{
+ if (ia.size() != ib.size())
+ qDebug() << "images are of different size" << ia.size() << ib.size();
+ Q_ASSERT(ia.size() == ib.size());
+ Q_ASSERT(ia.format() == ib.format());
+
+ int w = ia.width();
+ int h = ia.height();
+ const int tolerance = 1;
+ for (int y=0; y<h; ++y) {
+ const uint *as= (const uint *) ia.constScanLine(y);
+ const uint *bs= (const uint *) ib.constScanLine(y);
+ for (int x=0; x<w; ++x) {
+ uint a = as[x];
+ uint b = bs[x];
+
+ // No tolerance for error in the alpha.
+ if ((a & 0xff000000) != (b & 0xff000000))
+ return false;
+ if (qAbs(qRed(a) - qRed(b)) > tolerance)
+ return false;
+ if (qAbs(qRed(a) - qRed(b)) > tolerance)
+ return false;
+ if (qAbs(qRed(a) - qRed(b)) > tolerance)
+ return false;
+ }
+ }
+ return true;
+}
+
+void tst_SceneGraph::manyWindows_data()
+{
+ QTest::addColumn<QString>("file");
+ QTest::addColumn<bool>("toplevel");
+
+ QTest::newRow("image,toplevel") << QStringLiteral("manyWindows_image.qml") << true;
+ QTest::newRow("image,subwindow") << QStringLiteral("manyWindows_image.qml") << false;
+ QTest::newRow("dftext,toplevel") << QStringLiteral("manyWindows_dftext.qml") << true;
+ QTest::newRow("dftext,subwindow") << QStringLiteral("manyWindows_dftext.qml") << false;
+ QTest::newRow("ntext,toplevel") << QStringLiteral("manyWindows_ntext.qml") << true;
+ QTest::newRow("ntext,subwindow") << QStringLiteral("manyWindows_ntext.qml") << false;
+ QTest::newRow("rects,toplevel") << QStringLiteral("manyWindows_rects.qml") << true;
+ QTest::newRow("rects,subwindow") << QStringLiteral("manyWindows_rects.qml") << false;
+}
+
+void tst_SceneGraph::manyWindows()
+{
+ QFETCH(QString, file);
+ QFETCH(bool, toplevel);
+
+ QScopedPointer<QWindow> parent;
+ if (!toplevel) {
+ parent.reset(new QWindow());
+ parent->resize(200, 200);
+ parent->show();
+ }
+
+ ScopedList <QQuickView *> views;
+
+ const int COUNT = 4;
+
+ QImage baseLine;
+ for (int i=0; i<COUNT; ++i) {
+ views << createView(file, parent.data(), (i % 2) * 100, (i / 2) * 100, 100, 100);
+ }
+ for (int i=0; i<COUNT; ++i) {
+ QQuickView *view = views.at(i);
+ QTest::qWaitForWindowExposed(view);
+ QImage content = view->grabWindow();
+ if (i == 0) {
+ baseLine = content;
+ QVERIFY(containsSomethingOtherThanWhite(baseLine));
+ } else {
+ QVERIFY(compareImages(content, baseLine));
+ }
+ }
+
+ // Wipe and recreate one (scope pointer delets it...)
+ delete views.takeLast();
+ QQuickView *last = createView(file, parent.data(), 100, 100, 100, 100);
+ QTest::qWaitForWindowExposed(last);
+ views << last;
+ QVERIFY(compareImages(baseLine, last->grabWindow()));
+
+ // Wipe and recreate all
+ qDeleteAll(views);
+ views.clear();
+
+ for (int i=0; i<COUNT; ++i) {
+ views << createView(file, parent.data(), (i % 2) * 100, (i / 2) * 100, 100, 100);
+ }
+ for (int i=0; i<COUNT; ++i) {
+ QQuickView *view = views.at(i);
+ QTest::qWaitForWindowExposed(view);
+ QImage content = view->grabWindow();
+ QVERIFY(compareImages(content, baseLine));
+ }
+}
+
+
+#include "tst_scenegraph.moc"
+
+QTEST_MAIN(tst_SceneGraph)
+