aboutsummaryrefslogtreecommitdiffstats
path: root/tests/testapplications
diff options
context:
space:
mode:
authorDamian Jansen <damian.jansen@nokia.com>2012-04-03 14:21:23 +1000
committerQt by Nokia <qt-info@nokia.com>2012-05-14 03:03:41 +0200
commit73dffd7b38045e50d3dc568251bfe5d79aa84e0f (patch)
tree588f17323295ba40b6e0b9ac633b5d087462e24b /tests/testapplications
parentb1439a30be78af06f56f83dee25be5cde5be2181 (diff)
AnimatedSprite system tests
Basic sprite tests to validate frame rate and source changes Change-Id: I0279e89c55a4b5da5a0ee00a40c53ede1e27390a Reviewed-by: Alan Alpert <alan.alpert@nokia.com>
Diffstat (limited to 'tests/testapplications')
-rw-r--r--tests/testapplications/animatedsprite/animatedsprite.qml130
-rw-r--r--tests/testapplications/animatedsprite/animatedspriteadvance.qml201
-rw-r--r--tests/testapplications/animatedsprite/bear_black.pngbin0 -> 22508 bytes
-rw-r--r--tests/testapplications/animatedsprite/bear_brown.pngbin0 -> 22447 bytes
-rw-r--r--tests/testapplications/animatedsprite/bear_eyes_blue.pngbin0 -> 21859 bytes
-rw-r--r--tests/testapplications/animatedsprite/bear_eyes_brown.pngbin0 -> 22078 bytes
-rw-r--r--tests/testapplications/animatedsprite/bear_eyes_green.pngbin0 -> 21897 bytes
-rw-r--r--tests/testapplications/animatedsprite/bear_fur_gray.pngbin0 -> 19994 bytes
-rw-r--r--tests/testapplications/animatedsprite/bear_fur_orange.pngbin0 -> 19973 bytes
-rw-r--r--tests/testapplications/animatedsprite/bear_fur_pink.pngbin0 -> 20032 bytes
-rw-r--r--tests/testapplications/animatedsprite/bear_polar.pngbin0 -> 22272 bytes
-rw-r--r--tests/testapplications/animatedsprite/bear_tiles.pngbin0 -> 40349 bytes
12 files changed, 331 insertions, 0 deletions
diff --git a/tests/testapplications/animatedsprite/animatedsprite.qml b/tests/testapplications/animatedsprite/animatedsprite.qml
new file mode 100644
index 0000000000..5a08671663
--- /dev/null
+++ b/tests/testapplications/animatedsprite/animatedsprite.qml
@@ -0,0 +1,130 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: main
+
+ property bool reversed: false
+ property real speed: 5
+ property bool framesync: false
+
+ width: 320
+ height: 480
+ color: "lightgray"
+
+ Column {
+ id: controls
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: 30
+ width: parent.width - 10
+ spacing: 5
+ Text {
+ text: framesync ? "Rate: FrameSync" : "Rate: FrameRate"
+ width: controls.width
+ height: 50
+ verticalAlignment: Text.AlignVCenter
+ horizontalAlignment: Text.AlignHCenter
+ MouseArea {
+ anchors.fill: parent
+ onClicked: framesync = !framesync
+ }
+ Rectangle { anchors.fill: parent; color: "transparent"; border.color: "black"; radius: 5 }
+ }
+ Text {
+ text: reversed ? "Reverse" : "Forward"
+ width: controls.width
+ height: 50
+ verticalAlignment: Text.AlignVCenter
+ horizontalAlignment: Text.AlignHCenter
+ MouseArea {
+ anchors.fill: parent
+ onClicked: reversed = !reversed
+ }
+ Rectangle { anchors.fill: parent; color: "transparent"; border.color: "black"; radius: 5 }
+ }
+
+ Text {
+ text: "FPS: "+s1.frameRate
+ width: controls.width
+ height: 50
+ verticalAlignment: Text.AlignVCenter
+ horizontalAlignment: Text.AlignHCenter
+ Rectangle {
+ height: parent.height
+ width: height
+ Text { anchors.centerIn: parent; text: "-" }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: speed = speed - 1
+ }
+ }
+ Rectangle {
+ height: parent.height
+ width: height
+ anchors.right: parent.right
+ Text { anchors.centerIn: parent; text: "+" }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: speed = speed + 1
+ }
+ }
+ Rectangle { anchors.fill: parent; color: "transparent"; border.color: "black"; radius: 5 }
+ }
+ }
+
+ AnimatedSprite {
+ id: s1
+ anchors.centerIn: parent
+ anchors.verticalCenterOffset: -80
+ running: true
+ height: 125
+ width: 125
+ frameCount: 13
+ frameDuration: 50
+ frameRate: speed
+ frameSync: framesync
+ reverse: reversed
+ interpolate: false
+ source: "bear_tiles.png"
+ }
+}
diff --git a/tests/testapplications/animatedsprite/animatedspriteadvance.qml b/tests/testapplications/animatedsprite/animatedspriteadvance.qml
new file mode 100644
index 0000000000..50f1a18f5a
--- /dev/null
+++ b/tests/testapplications/animatedsprite/animatedspriteadvance.qml
@@ -0,0 +1,201 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: main
+
+ width: 320
+ height: 480
+ color: "lightgray"
+ Column {
+ Text { text: "Current frame: "+s1.currentFrame }
+ Text { text: "Delay: " + animcontroller.interval + "msec" }
+ }
+
+ Row {
+ height: parent.height / 3
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.bottom: parent.bottom
+ spacing: 5
+ Column {
+ height: parent.height
+ width: 80
+ Text { id: bodytxt; width: parent.width; text: "Body"; horizontalAlignment: Text.AlignHCenter }
+ Rectangle {
+ height: 30
+ width: parent.width
+ color: "white"
+ MouseArea {
+ anchors.fill: parent
+ onClicked: { s1.source = "bear_polar.png" }
+ }
+ }
+ Rectangle {
+ height: 30
+ width: parent.width
+ color: "black"
+ MouseArea {
+ anchors.fill: parent
+ onClicked: { s1.source = "bear_black.png" }
+ }
+ }
+ Rectangle {
+ height: 30
+ width: parent.width
+ color: "brown"
+ MouseArea {
+ anchors.fill: parent
+ onClicked: { s1.source = "bear_brown.png" }
+ }
+ }
+ }
+ Column {
+ height: parent.height
+ width: 80
+ Text { id: eyestxt; width: parent.width; text: "Eyes"; horizontalAlignment: Text.AlignHCenter }
+ Rectangle {
+ height: 30
+ width: parent.width
+ color: "brown"
+ MouseArea {
+ anchors.fill: parent
+ onClicked: { s2.source = "bear_eyes_brown.png" }
+ }
+ }
+ Rectangle {
+ height: 30
+ width: parent.width
+ color: "blue"
+ MouseArea {
+ anchors.fill: parent
+ onClicked: { s2.source = "bear_eyes_blue.png" }
+ }
+ }
+ Rectangle {
+ height: 30
+ width: parent.width
+ color: "green"
+ MouseArea {
+ anchors.fill: parent
+ onClicked: { s2.source = "bear_eyes_green.png" }
+ }
+ }
+ }
+ Column {
+ height: parent.height
+ width: 80
+ Text { id: furtxt; width: parent.width; text: "Fur"; horizontalAlignment: Text.AlignHCenter }
+ Rectangle {
+ height: 30
+ width: parent.width
+ color: "orange"
+ MouseArea {
+ anchors.fill: parent
+ onClicked: { s3.source = "bear_fur_orange.png" }
+ }
+ }
+ Rectangle {
+ height: 30
+ width: parent.width
+ color: "gray"
+ MouseArea {
+ anchors.fill: parent
+ onClicked: { s3.source = "bear_fur_gray.png" }
+ }
+ }
+ Rectangle {
+ height: 30
+ width: parent.width
+ color: "magenta"
+ MouseArea {
+ anchors.fill: parent
+ onClicked: { s3.source = "bear_fur_pink.png" }
+ }
+ }
+ }
+ }
+
+ function advanceall() {
+ s1.advance();
+ s2.advance();
+ s3.advance();
+ if (s2.currentFrame!=s1.currentFrame || s3.currentFrame!=s1.currentFrame)
+ console.log("Frames out of sync!")
+ }
+
+ AnimatedSprite {
+ id: s1
+ x: 100
+ y: 100
+ running: true
+ paused: true
+ height: 125
+ width: 125
+ frameCount: 13
+ interpolate: false
+ source: "bear_brown.png"
+ }
+
+ AnimatedSprite {
+ id: s2
+ anchors.fill: s1
+ running: true
+ paused: s1.paused
+ frameCount: 13
+ interpolate: false
+ source: "bear_eyes_brown.png"
+ onSourceChanged: { currentFrame = s1.currentFrame }
+ }
+
+ AnimatedSprite {
+ id: s3
+ anchors.fill: s1
+ running: true
+ paused: s1.paused
+ frameCount: 13
+ interpolate: false
+ source: "bear_fur_orange.png"
+ onSourceChanged: { currentFrame = s1.currentFrame }
+ }
+
+ Timer { id: animcontroller; interval: 75; running: true; repeat: true; onTriggered: { advanceall(); } }
+}
diff --git a/tests/testapplications/animatedsprite/bear_black.png b/tests/testapplications/animatedsprite/bear_black.png
new file mode 100644
index 0000000000..d014132ef9
--- /dev/null
+++ b/tests/testapplications/animatedsprite/bear_black.png
Binary files differ
diff --git a/tests/testapplications/animatedsprite/bear_brown.png b/tests/testapplications/animatedsprite/bear_brown.png
new file mode 100644
index 0000000000..514d45650c
--- /dev/null
+++ b/tests/testapplications/animatedsprite/bear_brown.png
Binary files differ
diff --git a/tests/testapplications/animatedsprite/bear_eyes_blue.png b/tests/testapplications/animatedsprite/bear_eyes_blue.png
new file mode 100644
index 0000000000..aca9172cf6
--- /dev/null
+++ b/tests/testapplications/animatedsprite/bear_eyes_blue.png
Binary files differ
diff --git a/tests/testapplications/animatedsprite/bear_eyes_brown.png b/tests/testapplications/animatedsprite/bear_eyes_brown.png
new file mode 100644
index 0000000000..2790f81727
--- /dev/null
+++ b/tests/testapplications/animatedsprite/bear_eyes_brown.png
Binary files differ
diff --git a/tests/testapplications/animatedsprite/bear_eyes_green.png b/tests/testapplications/animatedsprite/bear_eyes_green.png
new file mode 100644
index 0000000000..31f49449cf
--- /dev/null
+++ b/tests/testapplications/animatedsprite/bear_eyes_green.png
Binary files differ
diff --git a/tests/testapplications/animatedsprite/bear_fur_gray.png b/tests/testapplications/animatedsprite/bear_fur_gray.png
new file mode 100644
index 0000000000..782b2443bb
--- /dev/null
+++ b/tests/testapplications/animatedsprite/bear_fur_gray.png
Binary files differ
diff --git a/tests/testapplications/animatedsprite/bear_fur_orange.png b/tests/testapplications/animatedsprite/bear_fur_orange.png
new file mode 100644
index 0000000000..5334fc7c88
--- /dev/null
+++ b/tests/testapplications/animatedsprite/bear_fur_orange.png
Binary files differ
diff --git a/tests/testapplications/animatedsprite/bear_fur_pink.png b/tests/testapplications/animatedsprite/bear_fur_pink.png
new file mode 100644
index 0000000000..efbde0d930
--- /dev/null
+++ b/tests/testapplications/animatedsprite/bear_fur_pink.png
Binary files differ
diff --git a/tests/testapplications/animatedsprite/bear_polar.png b/tests/testapplications/animatedsprite/bear_polar.png
new file mode 100644
index 0000000000..dab96b9d51
--- /dev/null
+++ b/tests/testapplications/animatedsprite/bear_polar.png
Binary files differ
diff --git a/tests/testapplications/animatedsprite/bear_tiles.png b/tests/testapplications/animatedsprite/bear_tiles.png
new file mode 100644
index 0000000000..6bbb2a9b6d
--- /dev/null
+++ b/tests/testapplications/animatedsprite/bear_tiles.png
Binary files differ