diff options
Diffstat (limited to 'tests')
18 files changed, 1384 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickanimators/data/Box.qml b/tests/auto/quick/qquickanimators/data/Box.qml new file mode 100644 index 0000000000..cff3e7f929 --- /dev/null +++ b/tests/auto/quick/qquickanimators/data/Box.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 { + id: box + gradient: Gradient { + GradientStop { position: 0.1; color: "red" } + GradientStop { position: 0.9; color: "blue" } + } + width: 100 + height: 100 + anchors.centerIn: parent + antialiasing: true + + property int rotationChangeCounter: 0 + onRotationChanged: ++rotationChangeCounter; + + property int scaleChangeCounter: 0 + onScaleChanged: ++scaleChangeCounter; + + property int opacityChangeCounter: 0 + onOpacityChanged: ++opacityChangeCounter + + property int xChangeCounter: 0; + onXChanged: ++xChangeCounter; + + property int yChangeCounter: 0; + onYChanged: ++yChangeCounter; + +} diff --git a/tests/auto/quick/qquickanimators/data/tst_behavior.qml b/tests/auto/quick/qquickanimators/data/tst_behavior.qml new file mode 100644 index 0000000000..b22cc93b09 --- /dev/null +++ b/tests/auto/quick/qquickanimators/data/tst_behavior.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** 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 +import QtTest 1.0 + +Item { + id: root; + width: 200 + height: 200 + + TestCase { + id: testcase + name: "behavior" + when: box.scale == 2 + function test_endresult() { + compare(box.scaleChangeCounter, 1); + compare(box.scale, 2); + var image = grabImage(root); + compare(image.pixel(0, 0), Qt.rgba(1, 0, 0, 1)); + compare(image.pixel(199, 199), Qt.rgba(0, 0, 1, 1)); + } + } + + Box { + id: box + Behavior on scale { ScaleAnimator { id: animation; duration: 300; } } + } + + Timer { + interval: 1000; + repeat: false + running: true + onTriggered: box.scale = 2 + } +} diff --git a/tests/auto/quick/qquickanimators/data/tst_mixedparallel.qml b/tests/auto/quick/qquickanimators/data/tst_mixedparallel.qml new file mode 100644 index 0000000000..9cd28f2493 --- /dev/null +++ b/tests/auto/quick/qquickanimators/data/tst_mixedparallel.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** 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 +import QtTest 1.0 + +Item { + id: root; + width: 200 + height: 200 + + TestCase { + id: testcase + name: "mixedparallel" + when: !animation.running + function test_endresult() { + compare(box.rotationChangeCounter, 1); + compare(box.scale, 2); + compare(box.rotation, 180); + var image = grabImage(root); + compare(image.pixel(0, 0), Qt.rgba(0, 0, 1, 1)); + compare(image.pixel(199, 199), Qt.rgba(1, 0, 0, 1)); + } + } + + Box { + id: box + ParallelAnimation { + id: animation + NumberAnimation { target: box; property: "scale"; from: 1; to: 2.0; duration: 1000; } + RotationAnimator { target: box; from: 0; to: 180; duration: 1000; } + running: true + loops: 1; + } + } +} diff --git a/tests/auto/quick/qquickanimators/data/tst_mixedsequential.qml b/tests/auto/quick/qquickanimators/data/tst_mixedsequential.qml new file mode 100644 index 0000000000..4c62bc8018 --- /dev/null +++ b/tests/auto/quick/qquickanimators/data/tst_mixedsequential.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** 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 +import QtTest 1.0 + +Item { + id: root; + width: 200 + height: 200 + + TestCase { + id: testcase + name: "mixedsequential" + when: !animation.running + function test_endresult() { + compare(box.rotationChangeCounter, 1); + compare(box.scale, 2); + compare(box.rotation, 180); + var image = grabImage(root); + compare(image.pixel(0, 0), Qt.rgba(0, 0, 1, 1)); + compare(image.pixel(199, 199), Qt.rgba(1, 0, 0, 1)); + } + } + + Box { + id: box + ParallelAnimation { + id: animation + NumberAnimation { target: box; property: "scale"; from: 1; to: 2.0; duration: 500; } + RotationAnimator { target: box; from: 0; to: 180; duration: 500; } + running: true + loops: 1; + } + } +} diff --git a/tests/auto/quick/qquickanimators/data/tst_nested.qml b/tests/auto/quick/qquickanimators/data/tst_nested.qml new file mode 100644 index 0000000000..95cb70cb48 --- /dev/null +++ b/tests/auto/quick/qquickanimators/data/tst_nested.qml @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** 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 +import QtTest 1.0 + +Item { + id: root; + width: 200 + height: 200 + + TestCase { + id: testCase + name: "nested" + when: !animation.running + function test_endresult() { + compare(box.before, 2); + compare(box.after, 2); + } + } + + Box { + id: box + + anchors.centerIn: undefined + + property int before: 0; + property int after: 0; + + SequentialAnimation { + id: animation; + ScriptAction { script: box.before++; } + ParallelAnimation { + ScaleAnimator { target: box; from: 2.0; to: 1; duration: 500; } + OpacityAnimator { target: box; from: 0; to: 1; duration: 500; } + } + PauseAnimation { duration: 500 } + SequentialAnimation { + ParallelAnimation { + XAnimator { target: box; from: 0; to: 100; duration: 500} + RotationAnimator { target: box; from: 0; to: 90; duration: 500 } + } + ParallelAnimation { + XAnimator { target: box; from: 100; to: 0; duration: 500 } + RotationAnimator { target: box; from: 90; to: 0; duration: 500 } + } + } + ScriptAction { script: box.after++; } + running: true + loops: 2 + } + } + +} diff --git a/tests/auto/quick/qquickanimators/data/tst_on.qml b/tests/auto/quick/qquickanimators/data/tst_on.qml new file mode 100644 index 0000000000..e48d7107f9 --- /dev/null +++ b/tests/auto/quick/qquickanimators/data/tst_on.qml @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** 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 +import QtTest 1.0 + +Item { + id: root; + width: 200 + height: 200 + + TestCase { + id: testCase + name: "on" + when: !animx.running && !animy.running + && !anims.running && !animr.running + && !animo.running; + function test_endresult() { + compare(box.xChangeCounter, 1); + compare(box.yChangeCounter, 1); + compare(box.scaleChangeCounter, 1); + compare(box.rotationChangeCounter, 1); + compare(box.opacityChangeCounter, 1); + compare(box.x, 100); + compare(box.y, 100); + compare(box.scale, 2); + compare(box.rotation, 180); + compare(box.opacity, 0.5); + } + } + + Box { + id: box + anchors.centerIn: undefined + XAnimator on x { id: animx; from: 0; to: 100; duration: 1000 } + YAnimator on y { id: animy; from: 0; to: 100; duration: 1000 } + ScaleAnimator on scale { id: anims; from: 1; to: 2; duration: 1000 } + RotationAnimator on rotation { id: animr ; from: 0; to: 180; duration: 1000 } + OpacityAnimator on opacity { id: animo; from: 1; to: 0.5; duration: 1000 } + } +} diff --git a/tests/auto/quick/qquickanimators/data/tst_opacity.qml b/tests/auto/quick/qquickanimators/data/tst_opacity.qml new file mode 100644 index 0000000000..a785b2b3f3 --- /dev/null +++ b/tests/auto/quick/qquickanimators/data/tst_opacity.qml @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** 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 +import QtTest 1.0 + +Item { + id: root; + width: 200 + height: 200 + + TestCase { + id: testCase + name: "opacity" + when: !animation.running + function test_endresult() { + compare(box.opacityChangeCounter, 1); + compare(box.opacity, 0.5); + var image = grabImage(root); + compare(image.red(50, 50), 255); + verify(image.green(50, 50) > 0); + verify(image.blue(50, 50) > 0); + } + } + + Box { + id: box + + OpacityAnimator { + id: animation + target: box + from: 1; + to: 0.5 + duration: 1000 + running: true + } + } +} diff --git a/tests/auto/quick/qquickanimators/data/tst_parallel.qml b/tests/auto/quick/qquickanimators/data/tst_parallel.qml new file mode 100644 index 0000000000..3105d3c2dd --- /dev/null +++ b/tests/auto/quick/qquickanimators/data/tst_parallel.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** 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 +import QtTest 1.0 + +Item { + id: root; + width: 200 + height: 200 + + TestCase { + id: testcase + name: "parallel" + when: !animation.running + function test_endresult() { + compare(box.rotationChangeCounter, 1); + compare(box.scaleChangeCounter, 1); + compare(box.scale, 2); + compare(box.rotation, 180); + var image = grabImage(root); + compare(image.pixel(0, 0), Qt.rgba(0, 0, 1, 1)); + compare(image.pixel(199, 199), Qt.rgba(1, 0, 0, 1)); + } + } + + Box { + id: box + ParallelAnimation { + id: animation + ScaleAnimator { target: box; from: 1; to: 2.0; duration: 1000; } + RotationAnimator { target: box; from: 0; to: 180; duration: 1000; } + running: true + } + } +} diff --git a/tests/auto/quick/qquickanimators/data/tst_restart.qml b/tests/auto/quick/qquickanimators/data/tst_restart.qml new file mode 100644 index 0000000000..42c7a33a8b --- /dev/null +++ b/tests/auto/quick/qquickanimators/data/tst_restart.qml @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** 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 +import QtTest 1.0 + +Item { + id: root; + width: 200 + height: 200 + + property int restartCount: 5; + + TestCase { + id: testcase + name: "restart" + when: root.restartCount == 0 && animation.running == false; + function test_endresult() { + compare(box.scale, 2); + } + } + + Box { + id: box + + ScaleAnimator { + id: animation + target: box; + from: 1; + to: 2.0; + duration: 100; + loops: 1 + running: false; + } + + Timer { + id: timer; + interval: 500 + running: true + repeat: true + onTriggered: { + animation.running = true; + --root.restartCount; + } + } + } +} diff --git a/tests/auto/quick/qquickanimators/data/tst_rotation.qml b/tests/auto/quick/qquickanimators/data/tst_rotation.qml new file mode 100644 index 0000000000..517cf59456 --- /dev/null +++ b/tests/auto/quick/qquickanimators/data/tst_rotation.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** 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 +import QtTest 1.0 + +Item { + id: root; + width: 200 + height: 200 + + TestCase { + id: testCase + name: "rotation" + when: !animation.running + function test_endresult() { + compare(box.rotationChangeCounter, 1); + compare(box.rotation, 180); + var image = grabImage(root); + compare(image.pixel(50, 50), Qt.rgba(0, 0, 1)); + } + } + + Box { + id: box + RotationAnimator { + id: animation + target: box + from: 0; + to: 180 + duration: 1000 + easing.type: Easing.InOutBack + running: true + } + } +} diff --git a/tests/auto/quick/qquickanimators/data/tst_scale.qml b/tests/auto/quick/qquickanimators/data/tst_scale.qml new file mode 100644 index 0000000000..6fd4668684 --- /dev/null +++ b/tests/auto/quick/qquickanimators/data/tst_scale.qml @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** 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 +import QtTest 1.0 + +Item { + id: root; + width: 200 + height: 200 + + TestCase { + id: testCase + name: "scale" + when: !animation.running + function test_endresult() { + compare(box.scaleChangeCounter, 1); + compare(box.scale, 2); + var image = grabImage(root); + compare(image.pixel(0, 0), Qt.rgba(1, 0, 0)); + } + } + + Box { + id: box + + ScaleAnimator { + id: animation + target: box + from: 1; + to: 2.0 + duration: 1000 + easing.type: Easing.InOutCubic + running: true + } + } +} diff --git a/tests/auto/quick/qquickanimators/data/tst_sequential.qml b/tests/auto/quick/qquickanimators/data/tst_sequential.qml new file mode 100644 index 0000000000..2bb14f8acf --- /dev/null +++ b/tests/auto/quick/qquickanimators/data/tst_sequential.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** 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 +import QtTest 1.0 + +Item { + id: root; + width: 200 + height: 200 + + TestCase { + id: testcase + name: "parallel" + when: !animation.running + function test_endresult() { + compare(box.rotationChangeCounter, 1); + compare(box.scaleChangeCounter, 1); + compare(box.scale, 2); + compare(box.rotation, 180); + var image = grabImage(root); + compare(image.pixel(0, 0), Qt.rgba(0, 0, 1, 1)); + compare(image.pixel(199, 199), Qt.rgba(1, 0, 0, 1)); + } + } + + Box { + id: box + SequentialAnimation { + id: animation + ScaleAnimator { target: box; from: 1; to: 2.0; duration: 1000; } + RotationAnimator { target: box; from: 0; to: 180; duration: 1000; } + running: true + } + } +} diff --git a/tests/auto/quick/qquickanimators/data/tst_transformorigin.qml b/tests/auto/quick/qquickanimators/data/tst_transformorigin.qml new file mode 100644 index 0000000000..0211d0305d --- /dev/null +++ b/tests/auto/quick/qquickanimators/data/tst_transformorigin.qml @@ -0,0 +1,160 @@ +/**************************************************************************** +** +** 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 +import QtTest 1.0 + +Item { + id: root; + width: 300 + height: 300 + + Timer { + id: timer; + running: testCase.windowShown + interval: 1000 + repeat: false + onTriggered: triggered = true; + property bool triggered: false; + } + + TestCase { + id: testCase + name: "transformorigin" + when: timer.triggered + function test_endresult() { + + var image = grabImage(root); + + var white = Qt.rgba(1, 1, 1); + var blue = Qt.rgba(0, 0, 1); + + + // topleft + compare(image.pixel(40, 40), white); + compare(image.pixel(60, 40), white); + compare(image.pixel(40, 60), white); + compare(image.pixel(60, 60), blue); + + // top + compare(image.pixel(140, 40), white); + compare(image.pixel(160, 40), white); + compare(image.pixel(140, 60), blue); + compare(image.pixel(160, 60), blue); + + // topright + compare(image.pixel(240, 40), white); + compare(image.pixel(260, 40), white); + compare(image.pixel(240, 60), blue); + compare(image.pixel(260, 60), white); + + + // left + compare(image.pixel(40, 140), white); + compare(image.pixel(60, 140), blue); + compare(image.pixel(40, 160), white); + compare(image.pixel(60, 160), blue); + + // center + compare(image.pixel(140, 140), blue); + compare(image.pixel(160, 140), blue); + compare(image.pixel(140, 160), blue); + compare(image.pixel(160, 160), blue); + + // right + compare(image.pixel(240, 140), blue); + compare(image.pixel(260, 140), white); + compare(image.pixel(240, 160), blue); + compare(image.pixel(260, 160), white); + + + // bottomleft + compare(image.pixel(40, 240), white); + compare(image.pixel(60, 240), blue); + compare(image.pixel(40, 260), white); + compare(image.pixel(60, 260), white); + + // bottom + compare(image.pixel(140, 240), blue); + compare(image.pixel(160, 240), blue); + compare(image.pixel(140, 260), white); + compare(image.pixel(160, 260), white); + + // bottomright + compare(image.pixel(240, 240), blue); + compare(image.pixel(260, 240), white); + compare(image.pixel(240, 260), white); + compare(image.pixel(260, 260), white); + + } + } + + property var origins: [Item.TopLeft, Item.Top, Item.TopRight, + Item.Left, Item.Center, Item.Right, + Item.BottomLeft, Item.Bottom, Item.BottomRight]; + + Grid { + anchors.fill: parent + rows: 3 + columns: 3 + + Repeater { + model: 9 + Item { + width: 100 + height: 100 + Rectangle { + id: box + color: "blue" + anchors.centerIn: parent + width: 10 + height: 10 + antialiasing: true; + + transformOrigin: root.origins[index]; + + ScaleAnimator { target: box; from: 1; to: 5.5; duration: 1000; running: true; } + } + } + } + } + +} diff --git a/tests/auto/quick/qquickanimators/data/tst_transition.qml b/tests/auto/quick/qquickanimators/data/tst_transition.qml new file mode 100644 index 0000000000..8e21a6537e --- /dev/null +++ b/tests/auto/quick/qquickanimators/data/tst_transition.qml @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** 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 +import QtTest 1.0 + +Item { + id: root; + width: 200 + height: 200 + + TestCase { + id: testcase + name: "transition" + when: box.scale == 2 + function test_endresult() { + compare(box.scaleChangeCounter, 1); + compare(box.scale, 2); + var image = grabImage(root); + compare(image.pixel(0, 0), Qt.rgba(1, 0, 0)); + compare(image.pixel(199, 199), Qt.rgba(0, 0, 1)); + } + } + + states: [ + State { + name: "one" + PropertyChanges { target: box; scale: 1 } + }, + State { + name: "two" + PropertyChanges { target: box; scale: 2 } + } + ] + state: "one" + + transitions: [ + Transition { + ScaleAnimator { duration: 200; } + } + ] + + Box { + id: box + } + + Timer { + interval: 1000; + repeat: false + running: true + onTriggered: root.state = "two" + } +} diff --git a/tests/auto/quick/qquickanimators/data/tst_x.qml b/tests/auto/quick/qquickanimators/data/tst_x.qml new file mode 100644 index 0000000000..70ecf96346 --- /dev/null +++ b/tests/auto/quick/qquickanimators/data/tst_x.qml @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** 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 +import QtTest 1.0 + +Item { + id: root; + width: 200 + height: 200 + + TestCase { + id: testCase + name: "x" + when: !animation.running + function test_endresult() { + compare(box.xChangeCounter, 1); + compare(box.x, 100); + var image = grabImage(root); + compare(image.pixel(100, 50), Qt.rgba(1, 0, 0)); + compare(image.pixel(99, 50), Qt.rgba(1, 1, 1)); // outside on the left + } + } + + Box { + id: box + + anchors.centerIn: undefined + + XAnimator { + id: animation + target: box + from: 0; + to: 100 + duration: 1000 + running: true + } + } +} diff --git a/tests/auto/quick/qquickanimators/data/tst_y.qml b/tests/auto/quick/qquickanimators/data/tst_y.qml new file mode 100644 index 0000000000..428d42a6c3 --- /dev/null +++ b/tests/auto/quick/qquickanimators/data/tst_y.qml @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** 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 +import QtTest 1.0 + +Item { + id: root; + width: 200 + height: 200 + + TestCase { + id: testCase + name: "y" + when: !animation.running + function test_endresult() { + compare(box.yChangeCounter, 1); + compare(box.y, 100); + var image = grabImage(root); + compare(image.pixel(50, 100), Qt.rgba(1, 0, 0)); + compare(image.pixel(50, 99), Qt.rgba(1, 1, 1)); // outside on the left + } + } + + Box { + id: box + + anchors.centerIn: undefined + + YAnimator { + id: animation + target: box + from: 0; + to: 100 + duration: 1000 + running: true + } + } +} diff --git a/tests/auto/quick/qquickanimators/qquickanimators.pro b/tests/auto/quick/qquickanimators/qquickanimators.pro new file mode 100644 index 0000000000..4fa0438e41 --- /dev/null +++ b/tests/auto/quick/qquickanimators/qquickanimators.pro @@ -0,0 +1,14 @@ +QT += core-private gui-private qml-private +TEMPLATE=app +TARGET=tst_qquickanimators + +CONFIG += qmltestcase +SOURCES += tst_qquickanimators.cpp + +TESTDATA = data/* + +OTHER_FILES += \ + data/tst_scale.qml \ + data/Scale.qml \ + tst_on.qml \ + data/tst_nested.qml diff --git a/tests/auto/quick/qquickanimators/tst_qquickanimators.cpp b/tests/auto/quick/qquickanimators/tst_qquickanimators.cpp new file mode 100644 index 0000000000..f3f982091f --- /dev/null +++ b/tests/auto/quick/qquickanimators/tst_qquickanimators.cpp @@ -0,0 +1,44 @@ +/**************************************************************************** +** +** 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 <QtQuickTest/quicktest.h> + +QUICK_TEST_MAIN(qquickanimators) |