1c2fa96b43209e83fd99e7dc14033e23a12cde00
[profile/ivi/qtdeclarative.git] / tests / testapplications / elements / content / ImageElement.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: imageelementtest
46     anchors.fill: parent
47     property string testtext: ""
48
49     Item {
50         id: imageelementcontainer
51         height: 100; width: 100; clip: true
52         anchors.centerIn: parent
53         Behavior on height { NumberAnimation { duration: 1000 } }
54         Behavior on width { NumberAnimation { duration: 1000 } }
55         Image {
56             id: imageelement
57             anchors.fill: parent
58             source: "pics/nokialogo.gif"; sourceSize.width: 60; sourceSize.height: 80
59         }
60     }
61
62     SystemTestHelp { id: helpbubble; visible: statenum != 0
63         anchors { top: parent.top; horizontalCenter: parent.horizontalCenter; topMargin: 50 }
64     }
65     BugPanel { id: bugpanel }
66
67     states: [
68         State { name: "start"; when: statenum == 1
69             PropertyChanges { target: imageelementtest
70                 testtext: "This is an Image element. It should be small and be showing the Nokia logo, but slightly stretched.\n"+
71                 "Next, it should animatedly increase to twice its size" }
72         },
73         State { name: "large"; when: statenum == 2
74             PropertyChanges { target: imageelementcontainer; height: 200; width: 200 }
75             PropertyChanges { target: imageelementtest
76                 testtext: "It should be large and still showing the slightly stretched Nokia logo.\n"+
77                 "Next, it will change to preserve its aspect ratio" }
78         },
79         State { name: "largefit"; when: statenum == 3
80             PropertyChanges { target: imageelementcontainer; height: 200; width: 200 }
81             PropertyChanges { target: imageelement; fillMode: Image.PreserveAspectFit }
82             PropertyChanges { target: imageelementtest
83                 testtext: "It should be large and now showing the Nokia logo normally (longer horizontally).\n"+
84                 "Next, it will change its aspect ratio to fit, but cropping the sides" }
85         },
86         State { name: "largecrop"; when: statenum == 4
87             PropertyChanges { target: imageelementcontainer; height: 200; width: 200 }
88             PropertyChanges { target: imageelement; fillMode: Image.PreserveAspectCrop }
89             PropertyChanges { target: imageelementtest
90                 testtext: "It should be large and now showing the Nokia logo with the sides removed.\n"+
91                 "Next, let's change the image to tile the square" }
92         },
93         State { name: "largetile"; when: statenum == 5
94             PropertyChanges { target: imageelementcontainer; height: 200; width: 200 }
95             PropertyChanges { target: imageelement; fillMode: Image.Tile;  }
96             PropertyChanges { target: imageelementtest
97                 testtext: "The image should be repeated both horizontally and vertically.\n"+
98                 "Next, let's change the image to tile the square vertically" }
99         },
100         State { name: "largetilevertical"; when: statenum == 6
101             PropertyChanges { target: imageelementcontainer; height: 200; width: 200 }
102             PropertyChanges { target: imageelement; fillMode: Image.TileVertically;  }
103             PropertyChanges { target: imageelementtest
104                 testtext: "The image should be repeated only vertically.\n"+
105                 "Next, let's change the image to tile the square horizontally" }
106         },
107         State { name: "largetilehorizontal"; when: statenum == 7
108             PropertyChanges { target: imageelementcontainer; height: 200; width: 200 }
109             PropertyChanges { target: imageelement; fillMode: Image.TileHorizontally;  }
110             PropertyChanges { target: imageelementtest
111                 testtext: "The image should be repeated only horizontally.\n"+
112                 "The next step will return the image to a small, stretched state" }
113         }
114     ]
115
116 }