author | Eckhart Koeppen <eckhart.koppen@nokia.com> |
Wed, 21 Apr 2010 11:15:19 +0300 | |
branch | RCL_3 |
changeset 11 | 25a739ee40f4 |
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:
3
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 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 |
||
44 |
#include <QtTest/QtTest> |
|
45 |
||
46 |
||
47 |
#include <qaction.h> |
|
48 |
#include <qdockwidget.h> |
|
49 |
#include <qmainwindow.h> |
|
50 |
#include <qlineedit.h> |
|
51 |
#include <QDesktopWidget> |
|
52 |
#include <QtGui/QPainter> |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
53 |
#include "private/qdockwidget_p.h" |
0 | 54 |
|
55 |
bool hasFeature(QDockWidget *dockwidget, QDockWidget::DockWidgetFeature feature) |
|
56 |
{ return (dockwidget->features() & feature) == feature; } |
|
57 |
||
58 |
void setFeature(QDockWidget *dockwidget, QDockWidget::DockWidgetFeature feature, bool on = true) |
|
59 |
{ |
|
60 |
const QDockWidget::DockWidgetFeatures features = dockwidget->features(); |
|
61 |
dockwidget->setFeatures(on ? features | feature : features & ~feature); |
|
62 |
} |
|
63 |
||
64 |
//TESTED_FILES= |
|
65 |
||
66 |
class tst_QDockWidget : public QObject |
|
67 |
{ |
|
68 |
Q_OBJECT |
|
69 |
||
70 |
public: |
|
71 |
tst_QDockWidget(); |
|
72 |
||
73 |
private slots: |
|
74 |
void getSetCheck(); |
|
75 |
void widget(); |
|
76 |
void setWidget(); |
|
77 |
void setFeatures(); |
|
78 |
void features(); |
|
79 |
void setFloating(); |
|
80 |
void setAllowedAreas(); |
|
81 |
void allowedAreas(); |
|
82 |
void isAreaAllowed(); |
|
83 |
void toggleViewAction(); |
|
84 |
void featuresChanged(); |
|
85 |
void topLevelChanged(); |
|
86 |
void allowedAreasChanged(); |
|
87 |
void visibilityChanged(); |
|
88 |
void dockLocationChanged(); |
|
89 |
void setTitleBarWidget(); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
90 |
void titleBarDoubleClick(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
91 |
void restoreStateOfFloating(); |
0 | 92 |
// task specific tests: |
93 |
void task165177_deleteFocusWidget(); |
|
94 |
void task169808_setFloating(); |
|
95 |
void task237438_setFloatingCrash(); |
|
96 |
void task248604_infiniteResize(); |
|
97 |
void task258459_visibilityChanged(); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
98 |
void taskQTBUG_1665_closableChanged(); |
0 | 99 |
}; |
100 |
||
101 |
// Testing get/set functions |
|
102 |
void tst_QDockWidget::getSetCheck() |
|
103 |
{ |
|
104 |
QDockWidget obj1; |
|
105 |
// QWidget * QDockWidget::widget() |
|
106 |
// void QDockWidget::setWidget(QWidget *) |
|
107 |
QWidget *var1 = new QWidget(); |
|
108 |
obj1.setWidget(var1); |
|
109 |
QCOMPARE(var1, obj1.widget()); |
|
110 |
obj1.setWidget((QWidget *)0); |
|
111 |
QCOMPARE((QWidget *)0, obj1.widget()); |
|
112 |
delete var1; |
|
113 |
||
114 |
// DockWidgetFeatures QDockWidget::features() |
|
115 |
// void QDockWidget::setFeatures(DockWidgetFeatures) |
|
116 |
obj1.setFeatures(QDockWidget::DockWidgetFeatures(QDockWidget::DockWidgetClosable)); |
|
117 |
QCOMPARE(QDockWidget::DockWidgetFeatures(QDockWidget::DockWidgetClosable), obj1.features()); |
|
118 |
obj1.setFeatures(QDockWidget::DockWidgetFeatures(QDockWidget::DockWidgetMovable)); |
|
119 |
QCOMPARE(QDockWidget::DockWidgetFeatures(QDockWidget::DockWidgetMovable), obj1.features()); |
|
120 |
obj1.setFeatures(QDockWidget::DockWidgetFeatures(QDockWidget::DockWidgetFloatable)); |
|
121 |
QCOMPARE(QDockWidget::DockWidgetFeatures(QDockWidget::DockWidgetFloatable), obj1.features()); |
|
122 |
obj1.setFeatures(QDockWidget::DockWidgetFeatures(QDockWidget::AllDockWidgetFeatures)); |
|
123 |
QCOMPARE(QDockWidget::DockWidgetFeatures(QDockWidget::AllDockWidgetFeatures), obj1.features()); |
|
124 |
obj1.setFeatures(QDockWidget::DockWidgetFeatures(QDockWidget::NoDockWidgetFeatures)); |
|
125 |
QCOMPARE(QDockWidget::DockWidgetFeatures(QDockWidget::NoDockWidgetFeatures), obj1.features()); |
|
126 |
} |
|
127 |
||
128 |
tst_QDockWidget::tst_QDockWidget() |
|
129 |
{ |
|
130 |
qRegisterMetaType<QDockWidget::DockWidgetFeatures>("QDockWidget::DockWidgetFeatures"); |
|
131 |
qRegisterMetaType<Qt::DockWidgetAreas>("Qt::DockWidgetAreas"); |
|
132 |
} |
|
133 |
||
134 |
void tst_QDockWidget::widget() |
|
135 |
{ |
|
136 |
{ |
|
137 |
QDockWidget dw; |
|
138 |
QVERIFY(dw.widget() == 0); |
|
139 |
} |
|
140 |
||
141 |
{ |
|
142 |
QDockWidget dw; |
|
143 |
QWidget *w1 = new QWidget; |
|
144 |
QWidget *w2 = new QWidget; |
|
145 |
||
146 |
dw.setWidget(w1); |
|
147 |
QVERIFY(dw.widget() != 0); |
|
148 |
QVERIFY(dw.widget() == w1); |
|
149 |
QCOMPARE(w1->parentWidget(), (QWidget*)&dw); |
|
150 |
||
151 |
dw.setWidget(0); |
|
152 |
QVERIFY(dw.widget() == 0); |
|
153 |
||
154 |
dw.setWidget(w2); |
|
155 |
QVERIFY(dw.widget() != 0); |
|
156 |
QVERIFY(dw.widget() == w2); |
|
157 |
QCOMPARE(w2->parentWidget(), (QWidget*)&dw); |
|
158 |
||
159 |
dw.setWidget(0); |
|
160 |
QVERIFY(dw.widget() == 0); |
|
161 |
||
162 |
dw.setWidget(w1); |
|
163 |
QVERIFY(dw.widget() != 0); |
|
164 |
QVERIFY(dw.widget() == w1); |
|
165 |
QCOMPARE(w1->parentWidget(), (QWidget*)&dw); |
|
166 |
||
167 |
dw.setWidget(w2); |
|
168 |
QVERIFY(dw.widget() != 0); |
|
169 |
QVERIFY(dw.widget() == w2); |
|
170 |
QCOMPARE(w2->parentWidget(), (QWidget*)&dw); |
|
171 |
||
172 |
dw.setWidget(0); |
|
173 |
QVERIFY(dw.widget() == 0); |
|
174 |
} |
|
175 |
||
176 |
{ |
|
177 |
QDockWidget dw; |
|
178 |
QWidget *w1 = new QWidget; |
|
179 |
QWidget *w2 = new QWidget; |
|
180 |
||
181 |
dw.setWidget(w1); |
|
182 |
QVERIFY(dw.widget() != 0); |
|
183 |
QVERIFY(dw.widget() == w1); |
|
184 |
QCOMPARE(w1->parentWidget(), (QWidget*)&dw); |
|
185 |
||
186 |
w1->setParent(0); |
|
187 |
QVERIFY(dw.widget() == 0); |
|
188 |
||
189 |
dw.setWidget(w2); |
|
190 |
QVERIFY(dw.widget() != 0); |
|
191 |
QVERIFY(dw.widget() == w2); |
|
192 |
QCOMPARE(w2->parentWidget(), (QWidget*)&dw); |
|
193 |
||
194 |
w2->setParent(0); |
|
195 |
QVERIFY(dw.widget() == 0); |
|
196 |
||
197 |
dw.setWidget(w1); |
|
198 |
QVERIFY(dw.widget() != 0); |
|
199 |
QVERIFY(dw.widget() == w1); |
|
200 |
QCOMPARE(w1->parentWidget(), (QWidget*)&dw); |
|
201 |
||
202 |
dw.setWidget(w2); |
|
203 |
QVERIFY(dw.widget() != 0); |
|
204 |
QVERIFY(dw.widget() == w2); |
|
205 |
QCOMPARE(w2->parentWidget(), (QWidget*)&dw); |
|
206 |
||
207 |
w1->setParent(0); |
|
208 |
QVERIFY(dw.widget() != 0); |
|
209 |
QVERIFY(dw.widget() == w2); |
|
210 |
QCOMPARE(w2->parentWidget(), (QWidget*)&dw); |
|
211 |
||
212 |
w2->setParent(0); |
|
213 |
QVERIFY(dw.widget() == 0); |
|
214 |
delete w1; |
|
215 |
delete w2; |
|
216 |
} |
|
217 |
} |
|
218 |
||
219 |
void tst_QDockWidget::setWidget() |
|
220 |
{ DEPENDS_ON("setWidget()"); } |
|
221 |
||
222 |
void tst_QDockWidget::setFeatures() |
|
223 |
{ DEPENDS_ON("features()"); } |
|
224 |
||
225 |
void tst_QDockWidget::features() |
|
226 |
{ |
|
227 |
QDockWidget dw; |
|
228 |
||
229 |
QSignalSpy spy(&dw, SIGNAL(featuresChanged(QDockWidget::DockWidgetFeatures))); |
|
230 |
||
231 |
// default features for dock widgets |
|
232 |
int allDockWidgetFeatures = QDockWidget::DockWidgetClosable | |
|
233 |
QDockWidget::DockWidgetMovable | |
|
234 |
QDockWidget::DockWidgetFloatable; |
|
235 |
||
236 |
// defaults |
|
237 |
QCOMPARE(dw.features(), allDockWidgetFeatures); |
|
238 |
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable)); |
|
239 |
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetMovable)); |
|
240 |
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetFloatable)); |
|
241 |
||
242 |
// test individual setting |
|
243 |
setFeature(&dw, QDockWidget::DockWidgetClosable, false); |
|
244 |
QCOMPARE(dw.features(), QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable); |
|
245 |
QVERIFY(!hasFeature(&dw, QDockWidget::DockWidgetClosable)); |
|
246 |
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetMovable)); |
|
247 |
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetFloatable)); |
|
248 |
QCOMPARE(spy.count(), 1); |
|
249 |
QCOMPARE((int)*(static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData())), |
|
250 |
(int)dw.features()); |
|
251 |
spy.clear(); |
|
252 |
dw.setFeatures(dw.features()); |
|
253 |
QCOMPARE(spy.count(), 0); |
|
254 |
spy.clear(); |
|
255 |
||
256 |
setFeature(&dw, QDockWidget::DockWidgetClosable); |
|
257 |
QCOMPARE(dw.features(), allDockWidgetFeatures); |
|
258 |
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable)); |
|
259 |
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetMovable)); |
|
260 |
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetFloatable)); |
|
261 |
QCOMPARE(spy.count(), 1); |
|
262 |
QCOMPARE((int)*static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData()), |
|
263 |
(int)dw.features()); |
|
264 |
spy.clear(); |
|
265 |
dw.setFeatures(dw.features()); |
|
266 |
QCOMPARE(spy.count(), 0); |
|
267 |
spy.clear(); |
|
268 |
||
269 |
setFeature(&dw, QDockWidget::DockWidgetMovable, false); |
|
270 |
QCOMPARE(dw.features(), QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetFloatable); |
|
271 |
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable)); |
|
272 |
QVERIFY(!hasFeature(&dw, QDockWidget::DockWidgetMovable)); |
|
273 |
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetFloatable)); |
|
274 |
QCOMPARE(spy.count(), 1); |
|
275 |
QCOMPARE((int)*static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData()), |
|
276 |
(int)dw.features()); |
|
277 |
spy.clear(); |
|
278 |
dw.setFeatures(dw.features()); |
|
279 |
QCOMPARE(spy.count(), 0); |
|
280 |
spy.clear(); |
|
281 |
||
282 |
setFeature(&dw, QDockWidget::DockWidgetMovable); |
|
283 |
QCOMPARE(dw.features(), allDockWidgetFeatures); |
|
284 |
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable)); |
|
285 |
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetMovable)); |
|
286 |
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetFloatable)); |
|
287 |
QCOMPARE(spy.count(), 1); |
|
288 |
QCOMPARE((int)*static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData()), |
|
289 |
(int)dw.features()); |
|
290 |
spy.clear(); |
|
291 |
dw.setFeatures(dw.features()); |
|
292 |
QCOMPARE(spy.count(), 0); |
|
293 |
spy.clear(); |
|
294 |
||
295 |
setFeature(&dw, QDockWidget::DockWidgetFloatable, false); |
|
296 |
QCOMPARE(dw.features(), QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable); |
|
297 |
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable)); |
|
298 |
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetMovable)); |
|
299 |
QVERIFY(!hasFeature(&dw, QDockWidget::DockWidgetFloatable)); |
|
300 |
QCOMPARE(spy.count(), 1); |
|
301 |
QCOMPARE((int)*static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData()), |
|
302 |
(int)dw.features()); |
|
303 |
spy.clear(); |
|
304 |
dw.setFeatures(dw.features()); |
|
305 |
QCOMPARE(spy.count(), 0); |
|
306 |
spy.clear(); |
|
307 |
||
308 |
setFeature(&dw, QDockWidget::DockWidgetFloatable); |
|
309 |
QCOMPARE(dw.features(), allDockWidgetFeatures); |
|
310 |
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable)); |
|
311 |
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetMovable)); |
|
312 |
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetFloatable)); |
|
313 |
QCOMPARE(spy.count(), 1); |
|
314 |
QCOMPARE((int)*static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData()), |
|
315 |
(int)dw.features()); |
|
316 |
spy.clear(); |
|
317 |
dw.setFeatures(dw.features()); |
|
318 |
QCOMPARE(spy.count(), 0); |
|
319 |
spy.clear(); |
|
320 |
||
321 |
// set all at once |
|
322 |
dw.setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable); |
|
323 |
QCOMPARE(dw.features(), QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable); |
|
324 |
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable)); |
|
325 |
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetMovable)); |
|
326 |
QVERIFY(!hasFeature(&dw, QDockWidget::DockWidgetFloatable)); |
|
327 |
QCOMPARE(spy.count(), 1); |
|
328 |
QCOMPARE((int)*static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData()), |
|
329 |
(int)dw.features()); |
|
330 |
spy.clear(); |
|
331 |
dw.setFeatures(dw.features()); |
|
332 |
QCOMPARE(spy.count(), 0); |
|
333 |
spy.clear(); |
|
334 |
||
335 |
dw.setFeatures(QDockWidget::DockWidgetClosable); |
|
336 |
QCOMPARE(dw.features(), QDockWidget::DockWidgetClosable); |
|
337 |
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable)); |
|
338 |
QVERIFY(!hasFeature(&dw, QDockWidget::DockWidgetMovable)); |
|
339 |
QVERIFY(!hasFeature(&dw, QDockWidget::DockWidgetFloatable)); |
|
340 |
QCOMPARE(spy.count(), 1); |
|
341 |
QCOMPARE((int)*static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData()), |
|
342 |
(int)dw.features()); |
|
343 |
spy.clear(); |
|
344 |
dw.setFeatures(dw.features()); |
|
345 |
QCOMPARE(spy.count(), 0); |
|
346 |
spy.clear(); |
|
347 |
||
348 |
dw.setFeatures(QDockWidget::AllDockWidgetFeatures); |
|
349 |
QCOMPARE(dw.features(), QDockWidget::AllDockWidgetFeatures); |
|
350 |
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable)); |
|
351 |
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetMovable)); |
|
352 |
QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetFloatable)); |
|
353 |
QCOMPARE(spy.count(), 1); |
|
354 |
QCOMPARE((int)*static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData()), |
|
355 |
(int)dw.features()); |
|
356 |
spy.clear(); |
|
357 |
dw.setFeatures(dw.features()); |
|
358 |
QCOMPARE(spy.count(), 0); |
|
359 |
spy.clear(); |
|
360 |
} |
|
361 |
||
362 |
void tst_QDockWidget::setFloating() |
|
363 |
{ |
|
364 |
QMainWindow mw; |
|
365 |
QDockWidget dw; |
|
366 |
mw.addDockWidget(Qt::LeftDockWidgetArea, &dw); |
|
367 |
||
368 |
mw.show(); |
|
369 |
#ifdef Q_WS_X11 |
|
370 |
qt_x11_wait_for_window_manager(&mw); |
|
371 |
#endif |
|
372 |
||
373 |
QVERIFY(!dw.isFloating()); |
|
374 |
||
375 |
QSignalSpy spy(&dw, SIGNAL(topLevelChanged(bool))); |
|
376 |
||
377 |
dw.setFloating(true); |
|
378 |
QVERIFY(dw.isFloating()); |
|
379 |
QCOMPARE(spy.count(), 1); |
|
380 |
QCOMPARE(spy.at(0).value(0).toBool(), dw.isFloating()); |
|
381 |
spy.clear(); |
|
382 |
dw.setFloating(dw.isFloating()); |
|
383 |
QCOMPARE(spy.count(), 0); |
|
384 |
spy.clear(); |
|
385 |
||
386 |
dw.setFloating(false); |
|
387 |
QVERIFY(!dw.isFloating()); |
|
388 |
QCOMPARE(spy.count(), 1); |
|
389 |
QCOMPARE(spy.at(0).value(0).toBool(), dw.isFloating()); |
|
390 |
spy.clear(); |
|
391 |
dw.setFloating(dw.isFloating()); |
|
392 |
QCOMPARE(spy.count(), 0); |
|
393 |
spy.clear(); |
|
394 |
} |
|
395 |
||
396 |
void tst_QDockWidget::setAllowedAreas() |
|
397 |
{ DEPENDS_ON("allowedAreas()"); } |
|
398 |
||
399 |
void tst_QDockWidget::allowedAreas() |
|
400 |
{ |
|
401 |
QDockWidget dw; |
|
402 |
||
403 |
QSignalSpy spy(&dw, SIGNAL(allowedAreasChanged(Qt::DockWidgetAreas))); |
|
404 |
||
405 |
// default |
|
406 |
QCOMPARE(dw.allowedAreas(), Qt::AllDockWidgetAreas); |
|
407 |
QVERIFY(dw.isAreaAllowed(Qt::LeftDockWidgetArea)); |
|
408 |
QVERIFY(dw.isAreaAllowed(Qt::RightDockWidgetArea)); |
|
409 |
QVERIFY(dw.isAreaAllowed(Qt::TopDockWidgetArea)); |
|
410 |
QVERIFY(dw.isAreaAllowed(Qt::BottomDockWidgetArea)); |
|
411 |
||
412 |
// a single dock window area |
|
413 |
dw.setAllowedAreas(Qt::LeftDockWidgetArea); |
|
414 |
QCOMPARE(dw.allowedAreas(), Qt::LeftDockWidgetArea); |
|
415 |
QVERIFY(dw.isAreaAllowed(Qt::LeftDockWidgetArea)); |
|
416 |
QVERIFY(!dw.isAreaAllowed(Qt::RightDockWidgetArea)); |
|
417 |
QVERIFY(!dw.isAreaAllowed(Qt::TopDockWidgetArea)); |
|
418 |
QVERIFY(!dw.isAreaAllowed(Qt::BottomDockWidgetArea)); |
|
419 |
QCOMPARE(spy.count(), 1); |
|
420 |
QCOMPARE(*static_cast<const Qt::DockWidgetAreas *>(spy.at(0).value(0).constData()), |
|
421 |
dw.allowedAreas()); |
|
422 |
spy.clear(); |
|
423 |
dw.setAllowedAreas(dw.allowedAreas()); |
|
424 |
QCOMPARE(spy.count(), 0); |
|
425 |
||
426 |
dw.setAllowedAreas(Qt::RightDockWidgetArea); |
|
427 |
QCOMPARE(dw.allowedAreas(), Qt::RightDockWidgetArea); |
|
428 |
QVERIFY(!dw.isAreaAllowed(Qt::LeftDockWidgetArea)); |
|
429 |
QVERIFY(dw.isAreaAllowed(Qt::RightDockWidgetArea)); |
|
430 |
QVERIFY(!dw.isAreaAllowed(Qt::TopDockWidgetArea)); |
|
431 |
QVERIFY(!dw.isAreaAllowed(Qt::BottomDockWidgetArea)); |
|
432 |
QCOMPARE(spy.count(), 1); |
|
433 |
QCOMPARE(*static_cast<const Qt::DockWidgetAreas *>(spy.at(0).value(0).constData()), |
|
434 |
dw.allowedAreas()); |
|
435 |
spy.clear(); |
|
436 |
dw.setAllowedAreas(dw.allowedAreas()); |
|
437 |
QCOMPARE(spy.count(), 0); |
|
438 |
||
439 |
dw.setAllowedAreas(Qt::TopDockWidgetArea); |
|
440 |
QCOMPARE(dw.allowedAreas(), Qt::TopDockWidgetArea); |
|
441 |
QVERIFY(!dw.isAreaAllowed(Qt::LeftDockWidgetArea)); |
|
442 |
QVERIFY(!dw.isAreaAllowed(Qt::RightDockWidgetArea)); |
|
443 |
QVERIFY(dw.isAreaAllowed(Qt::TopDockWidgetArea)); |
|
444 |
QVERIFY(!dw.isAreaAllowed(Qt::BottomDockWidgetArea)); |
|
445 |
QCOMPARE(spy.count(), 1); |
|
446 |
QCOMPARE(*static_cast<const Qt::DockWidgetAreas *>(spy.at(0).value(0).constData()), |
|
447 |
dw.allowedAreas()); |
|
448 |
spy.clear(); |
|
449 |
dw.setAllowedAreas(dw.allowedAreas()); |
|
450 |
QCOMPARE(spy.count(), 0); |
|
451 |
||
452 |
dw.setAllowedAreas(Qt::BottomDockWidgetArea); |
|
453 |
QCOMPARE(dw.allowedAreas(), Qt::BottomDockWidgetArea); |
|
454 |
QVERIFY(!dw.isAreaAllowed(Qt::LeftDockWidgetArea)); |
|
455 |
QVERIFY(!dw.isAreaAllowed(Qt::RightDockWidgetArea)); |
|
456 |
QVERIFY(!dw.isAreaAllowed(Qt::TopDockWidgetArea)); |
|
457 |
QVERIFY(dw.isAreaAllowed(Qt::BottomDockWidgetArea)); |
|
458 |
QCOMPARE(spy.count(), 1); |
|
459 |
QCOMPARE(*static_cast<const Qt::DockWidgetAreas *>(spy.at(0).value(0).constData()), |
|
460 |
dw.allowedAreas()); |
|
461 |
spy.clear(); |
|
462 |
dw.setAllowedAreas(dw.allowedAreas()); |
|
463 |
QCOMPARE(spy.count(), 0); |
|
464 |
||
465 |
// multiple dock window areas |
|
466 |
dw.setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea); |
|
467 |
QCOMPARE(dw.allowedAreas(), Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea); |
|
468 |
QVERIFY(!dw.isAreaAllowed(Qt::LeftDockWidgetArea)); |
|
469 |
QVERIFY(!dw.isAreaAllowed(Qt::RightDockWidgetArea)); |
|
470 |
QVERIFY(dw.isAreaAllowed(Qt::TopDockWidgetArea)); |
|
471 |
QVERIFY(dw.isAreaAllowed(Qt::BottomDockWidgetArea)); |
|
472 |
QCOMPARE(spy.count(), 1); |
|
473 |
QCOMPARE(*static_cast<const Qt::DockWidgetAreas *>(spy.at(0).value(0).constData()), |
|
474 |
dw.allowedAreas()); |
|
475 |
spy.clear(); |
|
476 |
dw.setAllowedAreas(dw.allowedAreas()); |
|
477 |
QCOMPARE(spy.count(), 0); |
|
478 |
||
479 |
dw.setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); |
|
480 |
QCOMPARE(dw.allowedAreas(), Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); |
|
481 |
QVERIFY(dw.isAreaAllowed(Qt::LeftDockWidgetArea)); |
|
482 |
QVERIFY(dw.isAreaAllowed(Qt::RightDockWidgetArea)); |
|
483 |
QVERIFY(!dw.isAreaAllowed(Qt::TopDockWidgetArea)); |
|
484 |
QVERIFY(!dw.isAreaAllowed(Qt::BottomDockWidgetArea)); |
|
485 |
QCOMPARE(spy.count(), 1); |
|
486 |
QCOMPARE(*static_cast<const Qt::DockWidgetAreas *>(spy.at(0).value(0).constData()), |
|
487 |
dw.allowedAreas()); |
|
488 |
spy.clear(); |
|
489 |
dw.setAllowedAreas(dw.allowedAreas()); |
|
490 |
QCOMPARE(spy.count(), 0); |
|
491 |
||
492 |
dw.setAllowedAreas(Qt::TopDockWidgetArea | Qt::LeftDockWidgetArea); |
|
493 |
QCOMPARE(dw.allowedAreas(), Qt::TopDockWidgetArea | Qt::LeftDockWidgetArea); |
|
494 |
QVERIFY(dw.isAreaAllowed(Qt::LeftDockWidgetArea)); |
|
495 |
QVERIFY(!dw.isAreaAllowed(Qt::RightDockWidgetArea)); |
|
496 |
QVERIFY(dw.isAreaAllowed(Qt::TopDockWidgetArea)); |
|
497 |
QVERIFY(!dw.isAreaAllowed(Qt::BottomDockWidgetArea)); |
|
498 |
QCOMPARE(spy.count(), 1); |
|
499 |
QCOMPARE(*static_cast<const Qt::DockWidgetAreas *>(spy.at(0).value(0).constData()), |
|
500 |
dw.allowedAreas()); |
|
501 |
spy.clear(); |
|
502 |
dw.setAllowedAreas(dw.allowedAreas()); |
|
503 |
QCOMPARE(spy.count(), 0); |
|
504 |
||
505 |
dw.setAllowedAreas(Qt::BottomDockWidgetArea | Qt::RightDockWidgetArea); |
|
506 |
QCOMPARE(dw.allowedAreas(), Qt::BottomDockWidgetArea | Qt::RightDockWidgetArea); |
|
507 |
QVERIFY(!dw.isAreaAllowed(Qt::LeftDockWidgetArea)); |
|
508 |
QVERIFY(dw.isAreaAllowed(Qt::RightDockWidgetArea)); |
|
509 |
QVERIFY(!dw.isAreaAllowed(Qt::TopDockWidgetArea)); |
|
510 |
QVERIFY(dw.isAreaAllowed(Qt::BottomDockWidgetArea)); |
|
511 |
QCOMPARE(spy.count(), 1); |
|
512 |
QCOMPARE(*static_cast<const Qt::DockWidgetAreas *>(spy.at(0).value(0).constData()), |
|
513 |
dw.allowedAreas()); |
|
514 |
spy.clear(); |
|
515 |
dw.setAllowedAreas(dw.allowedAreas()); |
|
516 |
QCOMPARE(spy.count(), 0); |
|
517 |
} |
|
518 |
||
519 |
void tst_QDockWidget::isAreaAllowed() |
|
520 |
{ DEPENDS_ON("allowedAreas()"); } |
|
521 |
||
522 |
void tst_QDockWidget::toggleViewAction() |
|
523 |
{ |
|
524 |
QMainWindow mw; |
|
525 |
QDockWidget dw(&mw); |
|
526 |
mw.addDockWidget(Qt::LeftDockWidgetArea, &dw); |
|
527 |
mw.show(); |
|
528 |
QAction *toggleViewAction = dw.toggleViewAction(); |
|
529 |
QVERIFY(!dw.isHidden()); |
|
530 |
toggleViewAction->trigger(); |
|
531 |
QVERIFY(dw.isHidden()); |
|
532 |
toggleViewAction->trigger(); |
|
533 |
QVERIFY(!dw.isHidden()); |
|
534 |
toggleViewAction->trigger(); |
|
535 |
QVERIFY(dw.isHidden()); |
|
536 |
} |
|
537 |
||
538 |
void tst_QDockWidget::visibilityChanged() |
|
539 |
{ |
|
540 |
QMainWindow mw; |
|
541 |
QDockWidget dw; |
|
542 |
QSignalSpy spy(&dw, SIGNAL(visibilityChanged(bool))); |
|
543 |
||
544 |
mw.addDockWidget(Qt::LeftDockWidgetArea, &dw); |
|
545 |
mw.show(); |
|
546 |
||
547 |
QCOMPARE(spy.count(), 1); |
|
548 |
QCOMPARE(spy.at(0).at(0).toBool(), true); |
|
549 |
spy.clear(); |
|
550 |
||
551 |
dw.hide(); |
|
552 |
QCOMPARE(spy.count(), 1); |
|
553 |
QCOMPARE(spy.at(0).at(0).toBool(), false); |
|
554 |
spy.clear(); |
|
555 |
||
556 |
dw.hide(); |
|
557 |
QCOMPARE(spy.count(), 0); |
|
558 |
||
559 |
dw.show(); |
|
560 |
QCOMPARE(spy.count(), 1); |
|
561 |
QCOMPARE(spy.at(0).at(0).toBool(), true); |
|
562 |
spy.clear(); |
|
563 |
||
564 |
dw.show(); |
|
565 |
QCOMPARE(spy.count(), 0); |
|
566 |
||
567 |
QDockWidget dw2; |
|
568 |
mw.tabifyDockWidget(&dw, &dw2); |
|
569 |
dw2.show(); |
|
570 |
dw2.raise(); |
|
571 |
QCOMPARE(spy.count(), 1); |
|
572 |
QCOMPARE(spy.at(0).at(0).toBool(), false); |
|
573 |
spy.clear(); |
|
574 |
||
575 |
dw2.hide(); |
|
576 |
qApp->processEvents(); |
|
577 |
QCOMPARE(spy.count(), 1); |
|
578 |
QCOMPARE(spy.at(0).at(0).toBool(), true); |
|
579 |
spy.clear(); |
|
580 |
||
581 |
dw2.show(); |
|
582 |
dw2.raise(); |
|
583 |
qApp->processEvents(); |
|
584 |
QCOMPARE(spy.count(), 1); |
|
585 |
QCOMPARE(spy.at(0).at(0).toBool(), false); |
|
586 |
spy.clear(); |
|
587 |
||
588 |
dw.raise(); |
|
589 |
QCOMPARE(spy.count(), 1); |
|
590 |
QCOMPARE(spy.at(0).at(0).toBool(), true); |
|
591 |
spy.clear(); |
|
592 |
||
593 |
dw.raise(); |
|
594 |
QCOMPARE(spy.count(), 0); |
|
595 |
||
596 |
dw2.raise(); |
|
597 |
QCOMPARE(spy.count(), 1); |
|
598 |
QCOMPARE(spy.at(0).at(0).toBool(), false); |
|
599 |
spy.clear(); |
|
600 |
||
601 |
dw2.raise(); |
|
602 |
QCOMPARE(spy.count(), 0); |
|
603 |
||
604 |
mw.addDockWidget(Qt::RightDockWidgetArea, &dw2); |
|
605 |
QTest::qWait(200); |
|
606 |
QCOMPARE(spy.count(), 1); |
|
607 |
QCOMPARE(spy.at(0).at(0).toBool(), true); |
|
608 |
} |
|
609 |
||
610 |
Q_DECLARE_METATYPE(Qt::DockWidgetArea) |
|
611 |
||
612 |
void tst_QDockWidget::dockLocationChanged() |
|
613 |
{ |
|
614 |
qRegisterMetaType<Qt::DockWidgetArea>("Qt::DockWidgetArea"); |
|
615 |
||
616 |
QMainWindow mw; |
|
617 |
QDockWidget dw; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
618 |
dw.setObjectName("dock1"); |
0 | 619 |
QSignalSpy spy(&dw, SIGNAL(dockLocationChanged(Qt::DockWidgetArea))); |
620 |
||
621 |
mw.addDockWidget(Qt::LeftDockWidgetArea, &dw); |
|
622 |
QCOMPARE(spy.count(), 1); |
|
623 |
QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)), |
|
624 |
Qt::LeftDockWidgetArea); |
|
625 |
spy.clear(); |
|
626 |
||
627 |
mw.addDockWidget(Qt::LeftDockWidgetArea, &dw); |
|
628 |
QCOMPARE(spy.count(), 1); |
|
629 |
QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)), |
|
630 |
Qt::LeftDockWidgetArea); |
|
631 |
spy.clear(); |
|
632 |
||
633 |
mw.addDockWidget(Qt::RightDockWidgetArea, &dw); |
|
634 |
QCOMPARE(spy.count(), 1); |
|
635 |
QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)), |
|
636 |
Qt::RightDockWidgetArea); |
|
637 |
spy.clear(); |
|
638 |
||
639 |
mw.removeDockWidget(&dw); |
|
640 |
QCOMPARE(spy.count(), 0); |
|
641 |
||
642 |
QDockWidget dw2; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
643 |
dw2.setObjectName("dock2"); |
0 | 644 |
mw.addDockWidget(Qt::TopDockWidgetArea, &dw2); |
645 |
mw.tabifyDockWidget(&dw2, &dw); |
|
646 |
QCOMPARE(spy.count(), 1); |
|
647 |
QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)), |
|
648 |
Qt::TopDockWidgetArea); |
|
649 |
spy.clear(); |
|
650 |
||
651 |
mw.splitDockWidget(&dw2, &dw, Qt::Horizontal); |
|
652 |
QCOMPARE(spy.count(), 1); |
|
653 |
QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)), |
|
654 |
Qt::TopDockWidgetArea); |
|
655 |
spy.clear(); |
|
656 |
||
657 |
dw.setFloating(true); |
|
658 |
QTest::qWait(100); |
|
659 |
dw.setFloating(false); |
|
660 |
QTest::qWait(100); |
|
661 |
QCOMPARE(spy.count(), 1); |
|
662 |
QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)), |
|
663 |
Qt::TopDockWidgetArea); |
|
664 |
spy.clear(); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
665 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
666 |
QByteArray ba = mw.saveState(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
667 |
mw.restoreState(ba); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
668 |
QCOMPARE(spy.count(), 1); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
669 |
QCOMPARE(qvariant_cast<Qt::DockWidgetArea>(spy.at(0).at(0)), |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
670 |
Qt::TopDockWidgetArea); |
0 | 671 |
} |
672 |
||
673 |
void tst_QDockWidget::featuresChanged() |
|
674 |
{ DEPENDS_ON("features()"); } |
|
675 |
||
676 |
void tst_QDockWidget::topLevelChanged() |
|
677 |
{ DEPENDS_ON("setFloating()"); } |
|
678 |
||
679 |
void tst_QDockWidget::allowedAreasChanged() |
|
680 |
{ DEPENDS_ON("allowedAreas()"); } |
|
681 |
||
682 |
void tst_QDockWidget::setTitleBarWidget() |
|
683 |
{ |
|
684 |
//test the successive usage of setTitleBarWidget |
|
685 |
||
686 |
QDockWidget dock; |
|
687 |
QWidget w, w2; |
|
688 |
||
689 |
dock.show(); |
|
690 |
qApp->processEvents(); |
|
691 |
||
692 |
dock.setTitleBarWidget(&w); |
|
693 |
qApp->processEvents(); |
|
694 |
QCOMPARE(w.isVisible(), true); |
|
695 |
||
696 |
//set another widget as the titlebar widget |
|
697 |
dock.setTitleBarWidget(&w2); // this used to crash (task 184668) |
|
698 |
qApp->processEvents(); |
|
699 |
QCOMPARE(w.isVisible(), false); |
|
700 |
QCOMPARE(w2.isVisible(), true); |
|
701 |
||
702 |
//tries to reset the titlebarwidget to none |
|
703 |
dock.setTitleBarWidget(0); |
|
704 |
qApp->processEvents(); |
|
705 |
QCOMPARE(w.isVisible(), false); |
|
706 |
QCOMPARE(w2.isVisible(), false); |
|
707 |
} |
|
708 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
709 |
void tst_QDockWidget::titleBarDoubleClick() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
710 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
711 |
QMainWindow win; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
712 |
QDockWidget dock(&win); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
713 |
win.show(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
714 |
dock.setFloating(true); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
715 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
716 |
QEvent e(QEvent::NonClientAreaMouseButtonDblClick); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
717 |
QApplication::sendEvent(&dock, &e); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
718 |
QVERIFY(dock.isFloating()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
719 |
QCOMPARE(win.dockWidgetArea(&dock), Qt::NoDockWidgetArea); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
720 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
721 |
win.addDockWidget(Qt::TopDockWidgetArea, &dock); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
722 |
dock.setFloating(true); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
723 |
QApplication::sendEvent(&dock, &e); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
724 |
QVERIFY(!dock.isFloating()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
725 |
QCOMPARE(win.dockWidgetArea(&dock), Qt::TopDockWidgetArea); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
726 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
727 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
728 |
void tst_QDockWidget::restoreStateOfFloating() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
729 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
730 |
QMainWindow mw; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
731 |
QDockWidget dock; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
732 |
dock.setObjectName("dock1"); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
733 |
mw.addDockWidget(Qt::TopDockWidgetArea, &dock); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
734 |
QVERIFY(!dock.isFloating()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
735 |
QByteArray ba = mw.saveState(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
736 |
dock.setFloating(true); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
737 |
QVERIFY(dock.isFloating()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
738 |
QVERIFY(mw.restoreState(ba)); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
739 |
QVERIFY(!dock.isFloating()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
740 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
741 |
|
0 | 742 |
|
743 |
void tst_QDockWidget::task165177_deleteFocusWidget() |
|
744 |
{ |
|
745 |
QMainWindow mw; |
|
746 |
QDockWidget *dw = new QDockWidget(&mw); |
|
747 |
mw.addDockWidget(Qt::LeftDockWidgetArea, dw); |
|
748 |
QLineEdit *ledit = new QLineEdit; |
|
749 |
dw->setWidget(ledit); |
|
750 |
mw.show(); |
|
751 |
#ifdef Q_WS_X11 |
|
752 |
qt_x11_wait_for_window_manager(&mw); |
|
753 |
#endif |
|
754 |
qApp->processEvents(); |
|
755 |
dw->setFloating(true); |
|
756 |
delete ledit; |
|
757 |
QCOMPARE(mw.focusWidget(), (QWidget *)0); |
|
758 |
QCOMPARE(dw->focusWidget(), (QWidget *)0); |
|
759 |
} |
|
760 |
||
761 |
void tst_QDockWidget::task169808_setFloating() |
|
762 |
{ |
|
763 |
//we try to test if the sizeHint of the dock widget widget is taken into account |
|
764 |
||
765 |
class MyWidget : public QWidget |
|
766 |
{ |
|
767 |
public: |
|
768 |
QSize sizeHint() const |
|
769 |
{ |
|
770 |
const QRect& deskRect = qApp->desktop()->availableGeometry(); |
|
771 |
return QSize(qMin(300, deskRect.width()), 300); |
|
772 |
} |
|
773 |
||
774 |
QSize minimumSizeHint() const |
|
775 |
{ |
|
776 |
return QSize(20,20); |
|
777 |
} |
|
778 |
||
779 |
void paintEvent(QPaintEvent *) |
|
780 |
{ |
|
781 |
QPainter p(this); |
|
782 |
p.fillRect(rect(), Qt::red); |
|
783 |
} |
|
784 |
}; |
|
785 |
QMainWindow mw; |
|
786 |
mw.setCentralWidget(new MyWidget); |
|
787 |
QDockWidget *dw = new QDockWidget("my dock"); |
|
788 |
dw->setWidget(new MyWidget); |
|
789 |
mw.addDockWidget(Qt::LeftDockWidgetArea, dw); |
|
790 |
dw->setFloating(true); |
|
791 |
mw.show(); |
|
792 |
#ifdef Q_WS_X11 |
|
793 |
qt_x11_wait_for_window_manager(&mw); |
|
794 |
#endif |
|
795 |
||
796 |
QCOMPARE(dw->widget()->size(), dw->widget()->sizeHint()); |
|
797 |
||
798 |
//and now we try to test if the contents margin is taken into account |
|
799 |
dw->widget()->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); |
|
800 |
dw->setFloating(false); |
|
801 |
#ifdef Q_WS_X11 |
|
802 |
qt_x11_wait_for_window_manager(&mw); |
|
803 |
#endif |
|
804 |
QTest::qWait(100); //leave time processing events |
|
805 |
||
806 |
||
807 |
const QSize oldSize = dw->size(); |
|
808 |
const int margin = 20; |
|
809 |
||
810 |
dw->setContentsMargins(margin, margin, margin, margin); |
|
811 |
||
812 |
#ifdef Q_WS_X11 |
|
813 |
qt_x11_wait_for_window_manager(&mw); |
|
814 |
#endif |
|
815 |
QTest::qWait(100); //leave time processing events |
|
816 |
||
817 |
//widget size shouldn't have changed |
|
818 |
QCOMPARE(dw->widget()->size(), dw->widget()->sizeHint()); |
|
819 |
//dockwidget should be bigger |
|
820 |
QCOMPARE(dw->size(), oldSize + QSize(margin * 2, margin * 2)); |
|
821 |
||
822 |
||
823 |
} |
|
824 |
||
825 |
void tst_QDockWidget::task237438_setFloatingCrash() |
|
826 |
{ |
|
827 |
//should not crash |
|
828 |
QDockWidget pqdwDock; |
|
829 |
pqdwDock.setFloating(false); |
|
830 |
pqdwDock.show(); |
|
831 |
} |
|
832 |
||
833 |
void tst_QDockWidget::task248604_infiniteResize() |
|
834 |
{ |
|
835 |
QDockWidget d; |
|
836 |
QTabWidget *t = new QTabWidget; |
|
837 |
t->addTab(new QWidget, "Foo"); |
|
838 |
d.setWidget(t); |
|
839 |
d.setContentsMargins(2, 2, 2, 2); |
|
840 |
d.setMinimumSize(320, 240); |
|
841 |
d.show(); |
|
842 |
QTest::qWait(400); |
|
843 |
QCOMPARE(d.size(), QSize(320, 240)); |
|
844 |
} |
|
845 |
||
846 |
||
847 |
void tst_QDockWidget::task258459_visibilityChanged() |
|
848 |
{ |
|
849 |
QMainWindow win; |
|
850 |
QDockWidget dock1, dock2; |
|
851 |
win.addDockWidget(Qt::RightDockWidgetArea, &dock1); |
|
852 |
win.tabifyDockWidget(&dock1, &dock2); |
|
853 |
QSignalSpy spy1(&dock1, SIGNAL(visibilityChanged(bool))); |
|
854 |
QSignalSpy spy2(&dock2, SIGNAL(visibilityChanged(bool))); |
|
855 |
win.show(); |
|
856 |
QTest::qWait(200); |
|
857 |
QCOMPARE(spy1.count(), 1); |
|
858 |
QCOMPARE(spy1.first().first().toBool(), false); //dock1 is invisible |
|
859 |
QCOMPARE(spy2.count(), 1); |
|
860 |
QCOMPARE(spy2.first().first().toBool(), true); //dock1 is visible |
|
861 |
} |
|
862 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
863 |
void tst_QDockWidget::taskQTBUG_1665_closableChanged() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
864 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
865 |
QDockWidget dock; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
866 |
dock.show(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
867 |
QTest::qWaitForWindowShown(&dock); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
868 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
869 |
QDockWidgetLayout *l = qobject_cast<QDockWidgetLayout*>(dock.layout()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
870 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
871 |
if (l && !l->nativeWindowDeco()) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
872 |
QSKIP("this machine doesn't support native dock widget", SkipAll); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
873 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
874 |
QVERIFY(dock.windowFlags() & Qt::WindowCloseButtonHint); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
875 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
876 |
//now let's remove the closable attribute |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
877 |
dock.setFeatures(dock.features() ^ QDockWidget::DockWidgetClosable); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
878 |
QVERIFY(!(dock.windowFlags() & Qt::WindowCloseButtonHint)); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
879 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
880 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
881 |
|
0 | 882 |
QTEST_MAIN(tst_QDockWidget) |
883 |
#include "tst_qdockwidget.moc" |