author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 15 Mar 2010 12:43:09 +0200 | |
branch | RCL_3 |
changeset 6 | dee5afe5301f |
parent 4 | 3b1da2848fc7 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the test suite module of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#include <QtGui> |
|
43 |
#include <qtest.h> |
|
44 |
||
45 |
#include "dummyobject.h" |
|
46 |
#include "dummyanimation.h" |
|
47 |
#include "rectanimation.h" |
|
48 |
||
49 |
#define ITERATION_COUNT 10e3 |
|
50 |
||
51 |
class tst_qanimation : public QObject |
|
52 |
{ |
|
53 |
Q_OBJECT |
|
54 |
private slots: |
|
55 |
void itemPropertyAnimation(); |
|
56 |
void itemPropertyAnimation_data() { data();} |
|
57 |
void dummyAnimation(); |
|
58 |
void dummyAnimation_data() { data();} |
|
59 |
void dummyPropertyAnimation(); |
|
60 |
void dummyPropertyAnimation_data() { data();} |
|
61 |
void rectAnimation(); |
|
62 |
void rectAnimation_data() { data();} |
|
63 |
||
64 |
void floatAnimation_data() { data(); } |
|
65 |
void floatAnimation(); |
|
66 |
||
67 |
private: |
|
68 |
void data(); |
|
69 |
}; |
|
70 |
||
71 |
||
72 |
void tst_qanimation::data() |
|
73 |
{ |
|
74 |
QTest::addColumn<bool>("started"); |
|
75 |
QTest::newRow("NotRunning") << false; |
|
76 |
QTest::newRow("Running") << true; |
|
77 |
} |
|
78 |
||
79 |
void tst_qanimation::itemPropertyAnimation() |
|
80 |
{ |
|
81 |
QFETCH(bool, started); |
|
82 |
QGraphicsWidget item; |
|
83 |
||
84 |
//then the property animation |
|
85 |
{ |
|
86 |
QPropertyAnimation anim(&item, "pos"); |
|
87 |
anim.setDuration(ITERATION_COUNT); |
|
88 |
anim.setStartValue(QPointF(0,0)); |
|
89 |
anim.setEndValue(QPointF(ITERATION_COUNT,ITERATION_COUNT)); |
|
90 |
if (started) |
|
91 |
anim.start(); |
|
92 |
QBENCHMARK { |
|
93 |
for(int i = 0; i < ITERATION_COUNT; ++i) { |
|
94 |
anim.setCurrentTime(i); |
|
95 |
} |
|
96 |
} |
|
97 |
} |
|
98 |
||
99 |
} |
|
100 |
||
101 |
void tst_qanimation::dummyAnimation() |
|
102 |
{ |
|
103 |
QFETCH(bool, started); |
|
104 |
DummyObject dummy; |
|
105 |
||
106 |
//first the dummy animation |
|
107 |
{ |
|
108 |
DummyAnimation anim(&dummy); |
|
109 |
anim.setDuration(ITERATION_COUNT); |
|
110 |
anim.setStartValue(QRect(0, 0, 0, 0)); |
|
111 |
anim.setEndValue(QRect(0, 0, ITERATION_COUNT,ITERATION_COUNT)); |
|
112 |
if (started) |
|
113 |
anim.start(); |
|
114 |
QBENCHMARK { |
|
115 |
for(int i = 0; i < anim.duration(); ++i) { |
|
116 |
anim.setCurrentTime(i); |
|
117 |
} |
|
118 |
} |
|
119 |
} |
|
120 |
} |
|
121 |
||
122 |
void tst_qanimation::dummyPropertyAnimation() |
|
123 |
{ |
|
124 |
QFETCH(bool, started); |
|
125 |
DummyObject dummy; |
|
126 |
||
127 |
//then the property animation |
|
128 |
{ |
|
129 |
QPropertyAnimation anim(&dummy, "rect"); |
|
130 |
anim.setDuration(ITERATION_COUNT); |
|
131 |
anim.setStartValue(QRect(0, 0, 0, 0)); |
|
132 |
anim.setEndValue(QRect(0, 0, ITERATION_COUNT,ITERATION_COUNT)); |
|
133 |
if (started) |
|
134 |
anim.start(); |
|
135 |
QBENCHMARK { |
|
136 |
for(int i = 0; i < ITERATION_COUNT; ++i) { |
|
137 |
anim.setCurrentTime(i); |
|
138 |
} |
|
139 |
} |
|
140 |
} |
|
141 |
} |
|
142 |
||
143 |
void tst_qanimation::rectAnimation() |
|
144 |
{ |
|
145 |
//this is the simplest animation you can do |
|
146 |
QFETCH(bool, started); |
|
147 |
DummyObject dummy; |
|
148 |
||
149 |
//then the property animation |
|
150 |
{ |
|
151 |
RectAnimation anim(&dummy); |
|
152 |
anim.setDuration(ITERATION_COUNT); |
|
153 |
anim.setStartValue(QRect(0, 0, 0, 0)); |
|
154 |
anim.setEndValue(QRect(0, 0, ITERATION_COUNT,ITERATION_COUNT)); |
|
155 |
if (started) |
|
156 |
anim.start(); |
|
157 |
QBENCHMARK { |
|
158 |
for(int i = 0; i < ITERATION_COUNT; ++i) { |
|
159 |
anim.setCurrentTime(i); |
|
160 |
} |
|
161 |
} |
|
162 |
} |
|
163 |
} |
|
164 |
||
165 |
void tst_qanimation::floatAnimation() |
|
166 |
{ |
|
167 |
//this is the simplest animation you can do |
|
168 |
QFETCH(bool, started); |
|
169 |
DummyObject dummy; |
|
170 |
||
171 |
//then the property animation |
|
172 |
{ |
|
173 |
QPropertyAnimation anim(&dummy, "opacity"); |
|
174 |
anim.setDuration(ITERATION_COUNT); |
|
175 |
anim.setStartValue(0.f); |
|
176 |
anim.setEndValue(1.f); |
|
177 |
if (started) |
|
178 |
anim.start(); |
|
179 |
QBENCHMARK { |
|
180 |
for(int i = 0; i < ITERATION_COUNT; ++i) { |
|
181 |
anim.setCurrentTime(i); |
|
182 |
} |
|
183 |
} |
|
184 |
} |
|
185 |
} |
|
186 |
||
187 |
||
188 |
||
189 |
QTEST_MAIN(tst_qanimation) |
|
190 |
||
191 |
#include "main.moc" |