From 73e0a268895d9110697b0a3be38a1225ebd58255 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomi=20Korpip=C3=A4=C3=A4?= <tomi.korpipaa@digia.com> Date: Thu, 21 Aug 2014 13:23:55 +0300 Subject: [PATCH] Added initial autotests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I8390dc18ecaf013331022fe3fa0af8fd9620130d Reviewed-by: Pasi Keränen <pasi.keranen@digia.com> --- tests/auto/auto.pro | 4 + tests/auto/qmltest/canvas3d/tst_canvas3d.qml | 145 +++++++++++++++++++ tests/auto/qmltest/qmltest.pro | 6 + tests/auto/qmltest/tst_qmltest.cpp | 38 +++++ tests/tests.pro | 2 + 5 files changed, 195 insertions(+) create mode 100644 tests/auto/auto.pro create mode 100644 tests/auto/qmltest/canvas3d/tst_canvas3d.qml create mode 100644 tests/auto/qmltest/qmltest.pro create mode 100644 tests/auto/qmltest/tst_qmltest.cpp create mode 100644 tests/tests.pro diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro new file mode 100644 index 0000000..237e511 --- /dev/null +++ b/tests/auto/auto.pro @@ -0,0 +1,4 @@ +TEMPLATE = subdirs +SUBDIRS = qmltest + +installed_cmake.depends = cmake diff --git a/tests/auto/qmltest/canvas3d/tst_canvas3d.qml b/tests/auto/qmltest/canvas3d/tst_canvas3d.qml new file mode 100644 index 0000000..e99d09c --- /dev/null +++ b/tests/auto/qmltest/canvas3d/tst_canvas3d.qml @@ -0,0 +1,145 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later 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 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.2 +import QtCanvas3D 1.0 +import QtTest 1.0 + +Item { + id: top + height: 150 + width: 150 + + Canvas3D { + id: empty + } + + Canvas3D { + id: log_only_calls + logAllCalls: true + logAllErrors: false + } + + Canvas3D { + id: no_logs + logAllErrors: false + } + + Canvas3D { + id: animated + animated: true + } + + Canvas3D { + id: imageloader + imageLoader: TextureImageLoader { + id: loader + } + } + + Canvas3D { + id: basic_context + anchors.fill: parent + function initGL() {} + function renderGL() {} + } + + Canvas3D { + id: depth_context + anchors.fill: parent + function initGL() {} + function renderGL() {} + } + + Canvas3D { + id: aa_context + anchors.fill: parent + function initGL() {} + function renderGL() {} + } + + TestCase { + name: "Canvas3D" + when: windowShown + + function test_empty() { + compare(empty.width, 0) + compare(empty.height, 0) + compare(empty.logAllCalls, false) + compare(empty.logAllErrors, true) + compare(empty.animated, false) + compare(empty.imageLoader, null) + compare(empty.context, null) + } + + function test_log_only_calls() { + compare(log_only_calls.logAllCalls, true) + compare(log_only_calls.logAllErrors, false) + log_only_calls.logAllCalls = false + } + + function test_no_logs() { + compare(no_logs.logAllCalls, false) + compare(no_logs.logAllErrors, false) + } + + function test_animated() { + compare(animated.animated, true) + } + + function test_imageloader() { + compare(imageloader.imageLoader, loader) + } + + function test_basic_context() { + waitForRendering(basic_context) + basic_context.getContext("basic") + compare(basic_context.context.canvas, basic_context) + } + + function test_depth_context() { + waitForRendering(depth_context) + depth_context.getContext("depth", {depth:true}) + compare(depth_context.context.canvas, depth_context) + } + + function test_aa_context() { + waitForRendering(aa_context) + aa_context.getContext("antialias", {antialias:true}) + compare(aa_context.context.canvas, aa_context) + } + } +} diff --git a/tests/auto/qmltest/qmltest.pro b/tests/auto/qmltest/qmltest.pro new file mode 100644 index 0000000..306c873 --- /dev/null +++ b/tests/auto/qmltest/qmltest.pro @@ -0,0 +1,6 @@ +TEMPLATE = app +TARGET = tst_qmltest +CONFIG += qmltestcase +CONFIG += console +SOURCES += tst_qmltest.cpp +OTHER_FILES += canvas3d\tst_canvas3d.qml diff --git a/tests/auto/qmltest/tst_qmltest.cpp b/tests/auto/qmltest/tst_qmltest.cpp new file mode 100644 index 0000000..44c1dde --- /dev/null +++ b/tests/auto/qmltest/tst_qmltest.cpp @@ -0,0 +1,38 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later 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 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtQuickTest/quicktest.h> +QUICK_TEST_MAIN(qmltest) diff --git a/tests/tests.pro b/tests/tests.pro new file mode 100644 index 0000000..157ef34 --- /dev/null +++ b/tests/tests.pro @@ -0,0 +1,2 @@ +TEMPLATE = subdirs +SUBDIRS += auto -- GitLab