aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@digia.com>2014-08-09 23:42:20 +0200
committerJ-P Nurmi <jpnurmi@digia.com>2014-08-11 23:17:01 +0200
commitaf6ca36c8362bcda4ebe3a3bf369c85aaa98f47c (patch)
tree3b679898173e1920407a95cf69ca8d88c04c4f49 /tests
parent549f76b521bc1fa3bc49c78733b25acb4e029370 (diff)
Add OpenGLInfo attached type
[ChangeLog][QtQuick] Introduced OpenGLInfo attached type that provides information about the currently used OpenGL version. Change-Id: Ibdf365decf9d6331cf91c0bf541e493ced02a417 Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com> Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/qquickopenglinfo/data/basic.qml8
-rw-r--r--tests/auto/quick/qquickopenglinfo/qquickopenglinfo.pro15
-rw-r--r--tests/auto/quick/qquickopenglinfo/tst_qquickopenglinfo.cpp85
-rw-r--r--tests/auto/quick/quick.pro1
4 files changed, 109 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickopenglinfo/data/basic.qml b/tests/auto/quick/qquickopenglinfo/data/basic.qml
new file mode 100644
index 0000000000..b48447941b
--- /dev/null
+++ b/tests/auto/quick/qquickopenglinfo/data/basic.qml
@@ -0,0 +1,8 @@
+import QtQuick 2.4
+
+Item {
+ property int majorVersion: OpenGLInfo.majorVersion
+ property int minorVersion: OpenGLInfo.minorVersion
+ property int profile: OpenGLInfo.profile
+ property int renderableType: OpenGLInfo.renderableType
+}
diff --git a/tests/auto/quick/qquickopenglinfo/qquickopenglinfo.pro b/tests/auto/quick/qquickopenglinfo/qquickopenglinfo.pro
new file mode 100644
index 0000000000..8489dfffd2
--- /dev/null
+++ b/tests/auto/quick/qquickopenglinfo/qquickopenglinfo.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qquickopenglinfo
+SOURCES += tst_qquickopenglinfo.cpp
+
+TESTDATA = data/*
+include(../../shared/util.pri)
+
+osx:CONFIG -= app_bundle
+
+CONFIG += parallel_test
+QT += quick testlib
+
+OTHER_FILES += \
+ data/basic.qml
+
diff --git a/tests/auto/quick/qquickopenglinfo/tst_qquickopenglinfo.cpp b/tests/auto/quick/qquickopenglinfo/tst_qquickopenglinfo.cpp
new file mode 100644
index 0000000000..de28769e36
--- /dev/null
+++ b/tests/auto/quick/qquickopenglinfo/tst_qquickopenglinfo.cpp
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 BlackBerry Ltd.
+** 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 <QtTest/qtest.h>
+#include <QtTest/qsignalspy.h>
+
+#include <QtQuick/qquickitem.h>
+#include <QtQuick/qquickview.h>
+
+#include <QtGui/qopenglcontext.h>
+#include <QtGui/qsurfaceformat.h>
+
+#include "../../shared/util.h"
+
+class tst_QQuickOpenGLInfo : public QQmlDataTest
+{
+ Q_OBJECT
+
+private slots:
+ void testProperties();
+};
+
+void tst_QQuickOpenGLInfo::testProperties()
+{
+ QQuickView view;
+ view.setSource(QUrl::fromLocalFile("data/basic.qml"));
+
+ view.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
+
+ QSignalSpy spy(&view, SIGNAL(sceneGraphInitialized()));
+ spy.wait();
+
+ QVERIFY(view.openglContext());
+ QSurfaceFormat format = view.openglContext()->format();
+
+ QObject* obj = view.rootObject();
+ QVERIFY(obj);
+ QCOMPARE(obj->property("majorVersion").toInt(), format.majorVersion());
+ QCOMPARE(obj->property("minorVersion").toInt(), format.minorVersion());
+ QCOMPARE(obj->property("profile").toInt(), static_cast<int>(format.profile()));
+ QCOMPARE(obj->property("renderableType").toInt(), static_cast<int>(format.renderableType()));
+}
+
+QTEST_MAIN(tst_QQuickOpenGLInfo)
+
+#include "tst_qquickopenglinfo.moc"
diff --git a/tests/auto/quick/quick.pro b/tests/auto/quick/quick.pro
index 5f11da65e2..0a887534bd 100644
--- a/tests/auto/quick/quick.pro
+++ b/tests/auto/quick/quick.pro
@@ -56,6 +56,7 @@ QUICKTESTS = \
qquickloader \
qquickmousearea \
qquickmultipointtoucharea \
+ qquickopenglinfo \
qquickpainteditem \
qquickpathview \
qquickpincharea \