d15c55a08674ff757a8c849b5d20790eb8dc69c7
[profile/ivi/qtdeclarative.git] / tests / testapplications / elements / content / SpriteImageElement.qml
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: http://www.qt-project.org/
6 **
7 ** This file is part of the test suite of the Qt Toolkit.
8 **
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 **
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 **
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
29 **
30 ** Other Usage
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 import QtQuick 2.0
43
44 Item {
45     id: spriteimageelementtest
46     anchors.fill: parent
47     property string testtext: ""
48     SpriteImage {
49         id: spriteimage
50         sprites: [Sprite {
51             name: "happy"
52             source: "pics/squarefacesprite2.png"
53             frames: 6
54             duration: 120
55             to: {"silly": 1, "sad":0}
56         }, Sprite {
57             name: "silly"
58             source: "pics/squarefacesprite.png"
59             frames: 6
60             duration: 120
61             to: {"happy": 1, "sad": 0}
62         }, Sprite {
63             name: "sad"
64             source: "pics/squarefacesprite3.png"
65             frames: 6
66             duration: 120
67             to: {"evil": 0.5, "sad": 1, "cyclops" : 0}
68         }, Sprite {
69             name: "cyclops"
70             source: "pics/squarefacesprite4.png"
71             frames: 6
72             duration: 120
73             to: {"love": 0.1, "boggled": 0.1, "cyclops" : 0.1}
74         }, Sprite {
75             name: "evil"
76             source: "pics/squarefacesprite5.png"
77             frames: 6
78             duration: 120
79             to: {"sad": 1.0, "cyclops" : 0}
80         }, Sprite {
81             name: "love"
82             source: "pics/squarefacesprite6.png"
83             frames: 6
84             duration: 120
85             to: {"love": 0.1, "boggled": 0.1, "cyclops" : 0.1}
86         }, Sprite {
87             name: "boggled"
88             source: "pics/squarefacesprite7.png"
89             frames: 6
90             duration: 120
91             to: {"love": 0.1, "boggled": 0.1, "cyclops" : 0.1, "dying":0}
92         }, Sprite {
93             name: "dying"
94             source: "pics/squarefacespriteX.png"
95             frames: 4
96             duration: 120
97             to: {"dead":1.0}
98         }, Sprite {
99             name: "dead"
100             source: "pics/squarefacespriteXX.png"
101             frames: 1
102             duration: 10000
103         }]
104
105         width: 300
106         height: 300
107         anchors.horizontalCenter: parent.horizontalCenter
108         anchors.bottom: parent.bottom
109     }
110
111
112     SystemTestHelp { id: helpbubble; visible: statenum != 0
113         anchors { top: parent.top; horizontalCenter: parent.horizontalCenter; topMargin: 50 }
114     }
115     BugPanel { id: bugpanel }
116
117     states: [
118         State { name: "start"; when: statenum == 1
119             StateChangeScript { script: spriteimage.jumpTo("happy"); }
120             PropertyChanges { target: spriteimageelementtest
121                 testtext: "This is a SpriteImage element. It should be animating currently."+
122                 "It should alternate between winking and sticking out its tongue." }
123         },
124         State { name: "stochastic2"; when: statenum == 2
125             StateChangeScript { script: spriteimage.jumpTo("sad"); }
126             PropertyChanges { target: spriteimageelementtest
127                 testtext: "The sprite should now be animating between frowning and being evil."+
128                 "This should not be alternating, but mostly frowning with the occasional evil eyes."+
129                 "After an evil eyes animation, it should return to frowning at least once." }
130         },
131         State { name: "stochastic3"; when: statenum == 3
132             StateChangeScript { script: spriteimage.jumpTo("cyclops"); }
133             PropertyChanges { target: spriteimageelementtest
134                 testtext: "The sprite should now be animating fairly randomly between three animations where it does silly things with its eyes.\n"+
135                 "Next the sprite will animate into a static 'dead' state."+
136                 "When it does, it should first animate to and play through the 'big eyes' animation (if it is not currently playing that animation) before it enters the dying animation."}
137         },
138         State { name: "dead"; when: statenum == 4
139             PropertyChanges { target: spriteimage; goalState: "dead" }
140             PropertyChanges { target: spriteimageelementtest
141                 testtext: "After a brief dying animation, the image should now be static.\n"+
142                 "Advance to restart the test." }
143         }
144     ]
145 }