|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the examples 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 |
|
43 #include "mainwindow.h" |
|
44 #include "autotest.h" |
|
45 |
|
46 |
|
47 void autoTest::initTestCase() |
|
48 { |
|
49 Q_INIT_RESOURCE(qtp_svgviewer); |
|
50 } |
|
51 |
|
52 void autoTest::testDefaults() |
|
53 { |
|
54 |
|
55 MainWindow mw; |
|
56 mw.openFile(":/files/bubbles.svg"); |
|
57 mw.show(); |
|
58 |
|
59 // Test default values for widget properties |
|
60 // QVERIFY( !mw.acceptDrops() ); |
|
61 // QVERIFY( !mw.hasEditFocus() ); |
|
62 QVERIFY( !mw.hasFocus() ); |
|
63 QVERIFY( !mw.hasMouseTracking() ); |
|
64 QVERIFY( mw.isActiveWindow() ); |
|
65 QVERIFY( mw.isEnabled() ); |
|
66 /* |
|
67 // QVERIFY( mw.isFullScreen() ); |
|
68 // QVERIFY( mw.isHidden() ); |
|
69 QVERIFY( mw.isMaximized() ); |
|
70 QVERIFY( mw.isMinimized() ); |
|
71 QVERIFY( mw.isModal() ); |
|
72 QVERIFY( !mw.isVisible() ); |
|
73 QVERIFY( mw.isWindow() ); |
|
74 QVERIFY( mw.isWindowModified() ); |
|
75 QVERIFY( mw.underMouse() ); |
|
76 QVERIFY( mw.updatesEnabled() ); |
|
77 */ |
|
78 |
|
79 mw.hide(); |
|
80 |
|
81 } |
|
82 |
|
83 void autoTest::testMainWindow() |
|
84 { |
|
85 MainWindow mw; |
|
86 mw.openFile(":/files/bubbles.svg"); |
|
87 mw.show(); |
|
88 |
|
89 // What to test here... |
|
90 // renderer switch |
|
91 // |
|
92 |
|
93 QMenu *rendererMenu = NULL; |
|
94 QMenu *viewMenu = NULL; |
|
95 QList<QMenu *> allMenus = mw.findChildren<QMenu *>(); |
|
96 QVERIFY( allMenus.count() > 0 ); |
|
97 |
|
98 for ( int i = 0; i < allMenus.count(); i++ ) |
|
99 { |
|
100 if ( allMenus.at(i)->title() == QString("&Renderer")) |
|
101 { |
|
102 rendererMenu = allMenus.at(i); |
|
103 } |
|
104 else if ( allMenus.at(i)->title() == QString("&View")) |
|
105 { |
|
106 viewMenu = allMenus.at(i); |
|
107 } |
|
108 else |
|
109 { |
|
110 // not currently tested by this autotest |
|
111 } |
|
112 } |
|
113 QVERIFY( rendererMenu ); |
|
114 QVERIFY( !rendererMenu->isEmpty() ); |
|
115 |
|
116 QVERIFY( viewMenu ); |
|
117 QVERIFY( !viewMenu->isEmpty() ); |
|
118 |
|
119 QAction *backgroundAction = NULL; |
|
120 QAction *outlineAction = NULL; |
|
121 QAction *nativeAction = NULL; |
|
122 QAction *openglAction = NULL; |
|
123 QAction *imageAction = NULL; |
|
124 QList<QAction *> allActions = mw.findChildren<QAction *>(); |
|
125 QVERIFY( allActions.count() > 0 ); |
|
126 |
|
127 for ( int i = 0; i < allActions.count(); i++ ) |
|
128 { |
|
129 if ( allActions.at(i)->text() == QString("&Background")) |
|
130 { |
|
131 backgroundAction = allActions.at(i); |
|
132 } |
|
133 else if ( allActions.at(i)->text() == QString("&Outline")) |
|
134 { |
|
135 outlineAction = allActions.at(i); |
|
136 } |
|
137 else if ( allActions.at(i)->text() == QString("&Native")) |
|
138 { |
|
139 nativeAction = allActions.at(i); |
|
140 } |
|
141 else if ( allActions.at(i)->text() == QString("&OpenGL")) |
|
142 { |
|
143 openglAction = allActions.at(i); |
|
144 } |
|
145 else if ( allActions.at(i)->text() == QString("&Image")) |
|
146 { |
|
147 imageAction = allActions.at(i); |
|
148 } |
|
149 else |
|
150 { |
|
151 // not currently tested by this autotest |
|
152 } |
|
153 } |
|
154 QVERIFY( backgroundAction ); |
|
155 QVERIFY( outlineAction ); |
|
156 |
|
157 rendererMenu->show(); |
|
158 QTest::qWait(300); |
|
159 imageAction->trigger(); |
|
160 QTest::qWait(200); |
|
161 rendererMenu->hide(); |
|
162 QTest::qWait(1000); |
|
163 |
|
164 #ifndef QT_NO_OPENGL |
|
165 rendererMenu->show(); |
|
166 QTest::qWait(300); |
|
167 openglAction->trigger(); |
|
168 QTest::qWait(200); |
|
169 rendererMenu->hide(); |
|
170 QTest::qWait(1000); |
|
171 #endif |
|
172 |
|
173 rendererMenu->show(); |
|
174 QTest::qWait(300); |
|
175 nativeAction->trigger(); |
|
176 QTest::qWait(200); |
|
177 rendererMenu->hide(); |
|
178 QTest::qWait(1000); |
|
179 |
|
180 viewMenu->show(); |
|
181 QTest::qWait(300); |
|
182 backgroundAction->trigger(); |
|
183 QTest::qWait(200); |
|
184 viewMenu->hide(); |
|
185 QTest::qWait(500); |
|
186 |
|
187 viewMenu->show(); |
|
188 QTest::qWait(300); |
|
189 backgroundAction->trigger(); |
|
190 QTest::qWait(200); |
|
191 viewMenu->hide(); |
|
192 QTest::qWait(500); |
|
193 |
|
194 viewMenu->show(); |
|
195 QTest::qWait(300); |
|
196 outlineAction->trigger(); |
|
197 viewMenu->hide(); // calling trigger directly doesn't hide menu item |
|
198 QTest::qWait(500); |
|
199 |
|
200 viewMenu->show(); |
|
201 QTest::qWait(300); |
|
202 outlineAction->trigger(); // have to use trigger method, because qaction won't accept mouse clicks |
|
203 viewMenu->hide(); // calling trigger directly doesn't hide menu item |
|
204 QTest::qWait(1000); |
|
205 |
|
206 QTest::qWait(2000); |
|
207 mw.hide(); |
|
208 |
|
209 |
|
210 } |