1 /****************************************************************************
2 **
3 ** Copyright (C) 2015 The Qt Company Ltd.
4 ** Contact: http://www.qt.io/licensing/
5 **
6 ** This file is part of the test suite of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see http://www.qt.io/terms-conditions. For further
15 ** information use the contact form at http://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 or version 3 as published by the Free
20 ** Software Foundation and appearing in the file LICENSE.LGPLv21 and
21 ** LICENSE.LGPLv3 included in the packaging of this file. Please review the
22 ** following information to ensure the GNU Lesser General Public License
23 ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
24 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 **
26 ** As a special exception, The Qt Company gives you certain additional
27 ** rights. These rights are described in The Qt Company LGPL Exception
28 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 **
30 ** GNU General Public License Usage
31 ** Alternatively, this file may be used under the terms of the GNU
32 ** General Public License version 3.0 as published by the Free Software
33 ** Foundation and appearing in the file LICENSE.GPL included in the
34 ** packaging of this file.  Please review the following information to
35 ** ensure the GNU General Public License version 3.0 requirements will be
36 ** met: http://www.gnu.org/copyleft/gpl.html.
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 
43 #include <QtTest/QtTest>
44 #include <qapplication.h>
45 #include <qsplitter.h>
46 #include <qstyle.h>
47 #include <qfile.h>
48 #include <qtextstream.h>
49 #include <qlayout.h>
50 #include <qabstractscrollarea.h>
51 #include <qgraphicsview.h>
52 #include <qmdiarea.h>
53 #include <qscrollarea.h>
54 #include <qtextedit.h>
55 #include <qtreeview.h>
56 #include <qlabel.h>
57 #include <qdebug.h> // for file error messages
58 #include "../../shared/util.h"
59 
60 #if defined(Q_OS_SYMBIAN)
61 # define SRCDIR ""
62 #endif
63 
64 //TESTED_CLASS=
65 //TESTED_FILES=
66 
67 QT_FORWARD_DECLARE_CLASS(QSplitter)
68 QT_FORWARD_DECLARE_CLASS(QWidget)
69 class tst_QSplitter : public QObject
70 {
71     Q_OBJECT
72 
73 public:
74     tst_QSplitter();
75     virtual ~tst_QSplitter();
76 
77 public slots:
78     void initTestCase();
79     void cleanupTestCase();
80     void init();
81 private slots:
82     void getSetCheck();
83     void sizes(); // bare (as in empty)
84     void setSizes3();
85     void setSizes3_data();
86     void setSizes();
87     void setSizes_data();
88     void saveAndRestoreState();
89     void saveAndRestoreState_data();
90     void saveState_data();
91     void addWidget();
92     void insertWidget();
93     void setStretchFactor_data();
94     void setStretchFactor();
95     void testShowHide_data();
96     void testShowHide();
97     void testRemoval();
98     void rubberBandNotInSplitter();
99     void saveAndRestoreStateOfNotYetShownSplitter();
100 
101     // task-specific tests below me:
102     void task187373_addAbstractScrollAreas();
103     void task187373_addAbstractScrollAreas_data();
104     void task169702_sizes();
105     void taskQTBUG_4101_ensureOneNonCollapsedWidget_data();
106     void taskQTBUG_4101_ensureOneNonCollapsedWidget();
107 
108 private:
109     void removeThirdWidget();
110     void addThirdWidget();
111     QSplitter *splitter;
112     QWidget *w1;
113     QWidget *w2;
114     QWidget *w3;
115 };
116 
117 // Testing get/set functions
getSetCheck()118 void tst_QSplitter::getSetCheck()
119 {
120     QSplitter obj1;
121     // bool QSplitter::opaqueResize()
122     // void QSplitter::setOpaqueResize(bool)
123     obj1.setOpaqueResize(false);
124     QCOMPARE(false, obj1.opaqueResize());
125     obj1.setOpaqueResize(true);
126     QCOMPARE(true, obj1.opaqueResize());
127 }
128 
tst_QSplitter()129 tst_QSplitter::tst_QSplitter()
130     : w1(0), w2(0), w3(0)
131 {
132 }
133 
~tst_QSplitter()134 tst_QSplitter::~tst_QSplitter()
135 {
136 }
137 
sizes()138 void tst_QSplitter::sizes()
139 {
140     DEPENDS_ON("setSizes");
141 }
142 
initTestCase()143 void tst_QSplitter::initTestCase()
144 {
145     splitter = new QSplitter(Qt::Horizontal);
146     w1 = new QWidget;
147     w2 = new QWidget;
148     splitter->addWidget(w1);
149     splitter->addWidget(w2);
150 #if defined(QT3_SUPPORT)
151     qApp->setMainWidget(splitter);
152 #endif
153 }
154 
init()155 void tst_QSplitter::init()
156 {
157     removeThirdWidget();
158     w1->show();
159     w2->show();
160     w1->setMinimumSize(0, 0);
161     w2->setMinimumSize(0, 0);
162     splitter->setSizes(QList<int>() << 200 << 200);
163     qApp->sendPostedEvents();
164 }
165 
removeThirdWidget()166 void tst_QSplitter::removeThirdWidget()
167 {
168     delete w3;
169     w3 = 0;
170     int handleWidth = splitter->style()->pixelMetric(QStyle::PM_SplitterWidth);
171     splitter->setFixedSize(400 + handleWidth, 400);
172 }
173 
addThirdWidget()174 void tst_QSplitter::addThirdWidget()
175 {
176     if (!w3) {
177         w3 = new QWidget;
178         splitter->addWidget(w3);
179         int handleWidth = splitter->style()->pixelMetric(QStyle::PM_SplitterWidth);
180         splitter->setFixedSize(600 + 2 * handleWidth, 400);
181     }
182 }
183 
cleanupTestCase()184 void tst_QSplitter::cleanupTestCase()
185 {
186 #if defined(QT3_SUPPORT)
187     delete qApp->mainWidget();
188 #endif
189 }
190 
191 
192 typedef QList<int> IntList;
Q_DECLARE_METATYPE(IntList)193 Q_DECLARE_METATYPE(IntList)
194 
195 void tst_QSplitter::setSizes3()
196 {
197     QFETCH(IntList, minimumSizes);
198     QFETCH(IntList, splitterSizes);
199     QFETCH(IntList, collapsibleStates);
200     QFETCH(bool, childrenCollapse);
201 
202     QCOMPARE(minimumSizes.size(), splitterSizes.size());
203     if (minimumSizes.size() > 2)
204         addThirdWidget();
205     for (int i = 0; i < minimumSizes.size(); ++i) {
206         QWidget *w = splitter->widget(i);
207         w->setMinimumWidth(minimumSizes.at(i));
208         splitter->setCollapsible(splitter->indexOf(w), collapsibleStates.at(i));
209     }
210     splitter->setChildrenCollapsible(childrenCollapse);
211     splitter->setSizes(splitterSizes);
212     QTEST(splitter->sizes(), "expectedSizes");
213 }
214 
setSizes3_data()215 void tst_QSplitter::setSizes3_data()
216 {
217     QTest::addColumn<IntList>("minimumSizes");
218     QTest::addColumn<IntList>("splitterSizes");
219     QTest::addColumn<IntList>("expectedSizes");
220     QTest::addColumn<IntList>("collapsibleStates");
221     QTest::addColumn<bool>("childrenCollapse");
222 
223     QFile file(SRCDIR "setSizes3.dat");
224     if (!file.open(QIODevice::ReadOnly)) {
225         qDebug() << "Can't open file, reason:" << file.errorString();
226         return;
227     }
228     QTextStream ts(&file);
229     ts.setIntegerBase(10);
230 
231     QString dataName;
232     IntList minimumSizes;
233     IntList splitterSizes;
234     IntList expectedSizes;
235     IntList collapsibleStates;
236     int childrenCollapse;
237     while (!ts.atEnd()) {
238         int i1, i2, i3;
239         minimumSizes.clear();
240         splitterSizes.clear();
241         expectedSizes.clear();
242         collapsibleStates.clear();
243         ts >> dataName;
244         ts >> i1 >> i2 >> i3;
245         minimumSizes << i1 << i2 << i3;
246         ts >> i1 >> i2 >> i3;
247         splitterSizes << i1 << i2 << i3;
248         ts >> i1 >> i2 >> i3;
249         expectedSizes << i1 << i2 << i3;
250         ts >> i1 >> i2 >> i3;
251         collapsibleStates << i1 << i2 << i3;
252         ts >> childrenCollapse;
253         QTest::newRow(dataName.toLocal8Bit()) << minimumSizes << splitterSizes << expectedSizes << collapsibleStates << bool(childrenCollapse);
254         ts.skipWhiteSpace();
255     }
256 }
257 
setSizes()258 void tst_QSplitter::setSizes()
259 {
260 #if !defined(QT3_SUPPORT)
261     QSKIP("No Qt3Support", SkipAll);
262 #else
263     QFETCH(int, minSize1);
264     QFETCH(int, minSize2);
265     QFETCH(int, splitterSize1);
266     QFETCH(int, splitterSize2);
267     QFETCH(bool, collapse1);
268     QFETCH(bool, collapse2);
269     QFETCH(bool, childrencollapse);
270     QFETCH(int, resizeMode1);
271     QFETCH(int, resizeMode2);
272     QList<int> mySizes;
273     mySizes << splitterSize1 << splitterSize2;
274     w1->setMinimumWidth(minSize1);
275     w2->setMinimumWidth(minSize2);
276     splitter->setCollapsible(w1, collapse1);
277     splitter->setCollapsible(w2, collapse2);
278     splitter->setChildrenCollapsible(childrencollapse);
279     splitter->setResizeMode(w1, (QSplitter::ResizeMode)resizeMode1);
280     splitter->setResizeMode(w2, (QSplitter::ResizeMode)resizeMode2);
281     splitter->setSizes(mySizes);
282     mySizes = splitter->sizes();
283     QTEST(mySizes[0], "expected1");
284     QTEST(mySizes[1], "expected2");
285 #endif
286 }
287 
setSizes_data()288 void tst_QSplitter::setSizes_data()
289 {
290 #if defined(QT3_SUPPORT)
291     QTest::addColumn<int>("minSize1");
292     QTest::addColumn<int>("minSize2");
293     QTest::addColumn<int>("splitterSize1");
294     QTest::addColumn<int>("splitterSize2");
295     QTest::addColumn<int>("expected1");
296     QTest::addColumn<int>("expected2");
297     QTest::addColumn<bool>("collapse1");
298     QTest::addColumn<bool>("collapse2");
299     QTest::addColumn<bool>("childrencollapse");
300     QTest::addColumn<int>("resizeMode1");
301     QTest::addColumn<int>("resizeMode2");
302     QTest::newRow("ok00") << 100 << 50 << 100 << 300 << 100 << 300
303 			 << (bool)true << (bool)true << (bool)true
304 			 << (int)QSplitter::Auto << (int)QSplitter::Auto;
305     QTest::newRow("ok01") << 100 << 100 << 50 << 350 << 100 << 300
306 			 << (bool)true << (bool)true << (bool)true
307 			 << (int)QSplitter::Auto << (int)QSplitter::Auto;
308     QTest::newRow("ok02") << 100 << 100 << 350 << 50 << 300 << 100
309 			 << (bool)true << (bool)true << (bool)true
310 			 << (int)QSplitter::Auto << (int)QSplitter::Auto;
311     QTest::newRow("ok03") << 200 << 200 << 350 << 50 << 200 << 200
312 			 << (bool)true << (bool)true << (bool)true
313 			 << (int)QSplitter::Auto << (int)QSplitter::Auto;
314     QTest::newRow("ok04") << 200 << 200 << 200 << 200 << 200 << 200
315 			 << (bool)true << (bool)true << (bool)true
316 			 << (int)QSplitter::Auto << (int)QSplitter::Auto;
317     QTest::newRow("ok05") << 200 << 200 << 0 << 350 << 0 << 400
318 			 << (bool)true << (bool)true << (bool)true
319 			 << (int)QSplitter::Auto << (int)QSplitter::Auto;
320     QTest::newRow("ok06") << 200 << 200 << 350 << 0 << 400 << 0
321 			 << (bool)true << (bool)true << (bool)true
322 			 << (int)QSplitter::Auto << (int)QSplitter::Auto;
323     QTest::newRow("ok07") << 200 << 200 << 350 << 0 << 200 << 200
324 			 << (bool)true << (bool)false << (bool)true
325 			 << (int)QSplitter::Auto << (int)QSplitter::Auto;
326     QTest::newRow("ok08") << 200 << 200 << 350 << 0 << 200 << 200
327 			 << (bool)false << (bool)false << (bool)true
328 			 << (int)QSplitter::Auto << (int)QSplitter::Auto;
329     QTest::newRow("ok09") << 200 << 200 << 0 << 350 << 200 << 200
330 			 << (bool)false << (bool)true << (bool)true
331 			 << (int)QSplitter::Auto << (int)QSplitter::Auto;
332     QTest::newRow("ok10") << 200 << 200 << 0 << 350 << 200 << 200
333 			 << (bool)false << (bool)false << (bool)true
334 			 << (int)QSplitter::Auto << (int)QSplitter::Auto;
335 
336     QTest::newRow("ok20") << 100 << 50 << 100 << 300 << 100 << 300
337 			 << (bool)true << (bool)true << (bool)false
338 			 << (int)QSplitter::Auto << (int)QSplitter::Auto;
339     QTest::newRow("ok21") << 100 << 100 << 50 << 350 << 100 << 300
340 			 << (bool)true << (bool)true << (bool)false
341 			 << (int)QSplitter::Auto << (int)QSplitter::Auto;
342     QTest::newRow("ok22") << 100 << 100 << 350 << 50 << 300 << 100
343 			 << (bool)true << (bool)true << (bool)false
344 			 << (int)QSplitter::Auto << (int)QSplitter::Auto;
345     QTest::newRow("ok23") << 200 << 200 << 350 << 50 << 200 << 200
346 			 << (bool)true << (bool)true << (bool)false
347 			 << (int)QSplitter::Auto << (int)QSplitter::Auto;
348     QTest::newRow("ok24") << 200 << 200 << 200 << 200 << 200 << 200
349 			 << (bool)true << (bool)true << (bool)false
350 			 << (int)QSplitter::Auto << (int)QSplitter::Auto;
351     QTest::newRow("ok25") << 200 << 200 << 0 << 350 << 0 << 400
352 			 << (bool)true << (bool)true << (bool)false
353 			 << (int)QSplitter::Auto << (int)QSplitter::Auto;
354     QTest::newRow("ok26") << 200 << 200 << 350 << 0 << 400 << 0
355 			 << (bool)true << (bool)true << (bool)false
356 			 << (int)QSplitter::Auto << (int)QSplitter::Auto;
357     QTest::newRow("ok27") << 200 << 200 << 350 << 0 << 200 << 200
358 			 << (bool)true << (bool)false << (bool)false
359 			 << (int)QSplitter::Auto << (int)QSplitter::Auto;
360     QTest::newRow("ok28") << 200 << 200 << 350 << 0 << 200 << 200
361 			 << (bool)false << (bool)false << (bool)false
362 			 << (int)QSplitter::Auto << (int)QSplitter::Auto;
363     QTest::newRow("ok29") << 200 << 200 << 0 << 350 << 200 << 200
364 			 << (bool)false << (bool)true << (bool)false
365 			 << (int)QSplitter::Auto << (int)QSplitter::Auto;
366     QTest::newRow("ok30") << 200 << 200 << 0 << 350 << 200 << 200
367 			 << (bool)false << (bool)false << (bool)false
368 			 << (int)QSplitter::Auto << (int)QSplitter::Auto;
369     QTest::newRow("ok40") << 100 << 50 << 100 << 300 << 100 << 300
370 			 << (bool)true << (bool)true << (bool)false
371 			 << (int)QSplitter::Stretch << (int)QSplitter::Auto;
372     QTest::newRow("ok41") << 100 << 100 << 50 << 350 << 100 << 300
373 			 << (bool)true << (bool)true << (bool)false
374 			 << (int)QSplitter::Stretch << (int)QSplitter::Auto;
375     QTest::newRow("ok42") << 100 << 100 << 350 << 50 << 300 << 100
376 			 << (bool)true << (bool)true << (bool)false
377 			 << (int)QSplitter::Stretch << (int)QSplitter::Auto;
378     QTest::newRow("ok43") << 200 << 200 << 350 << 50 << 200 << 200
379 			 << (bool)true << (bool)true << (bool)false
380 			 << (int)QSplitter::Stretch << (int)QSplitter::Auto;
381     QTest::newRow("ok44") << 200 << 200 << 200 << 200 << 200 << 200
382 			 << (bool)true << (bool)true << (bool)false
383 			 << (int)QSplitter::Stretch << (int)QSplitter::Auto;
384     QTest::newRow("ok45") << 200 << 200 << 0 << 350 << 0 << 400
385 			 << (bool)true << (bool)true << (bool)false
386 			 << (int)QSplitter::Stretch << (int)QSplitter::Auto;
387     QTest::newRow("ok46") << 200 << 200 << 350 << 0 << 400 << 0
388 			 << (bool)true << (bool)true << (bool)false
389 			 << (int)QSplitter::Stretch << (int)QSplitter::Auto;
390     QTest::newRow("ok47") << 200 << 200 << 350 << 0 << 200 << 200
391 			 << (bool)true << (bool)false << (bool)false
392 			 << (int)QSplitter::Stretch << (int)QSplitter::Auto;
393     QTest::newRow("ok48") << 200 << 200 << 350 << 0 << 200 << 200
394 			 << (bool)false << (bool)false << (bool)false
395 			 << (int)QSplitter::Stretch << (int)QSplitter::Auto;
396     QTest::newRow("ok49") << 200 << 200 << 0 << 350 << 200 << 200
397 			 << (bool)false << (bool)true << (bool)false
398 			 << (int)QSplitter::Stretch << (int)QSplitter::Auto;
399     QTest::newRow("ok50") << 200 << 200 << 0 << 350 << 200 << 200
400 			 << (bool)false << (bool)false << (bool)false
401 			 << (int)QSplitter::Stretch << (int)QSplitter::Auto;
402 
403     QTest::newRow("ok60") << 100 << 50 << 100 << 300 << 100 << 300
404 			 << (bool)true << (bool)true << (bool)true
405 			 << (int)QSplitter::Stretch << (int)QSplitter::Auto;
406     QTest::newRow("ok61") << 100 << 100 << 50 << 350 << 100 << 300
407 			 << (bool)true << (bool)true << (bool)true
408 			 << (int)QSplitter::Stretch << (int)QSplitter::Auto;
409     QTest::newRow("ok62") << 100 << 100 << 350 << 50 << 300 << 100
410 			 << (bool)true << (bool)true << (bool)true
411 			 << (int)QSplitter::Stretch << (int)QSplitter::Auto;
412     QTest::newRow("ok63") << 200 << 200 << 350 << 50 << 200 << 200
413 			 << (bool)true << (bool)true << (bool)true
414 			 << (int)QSplitter::Stretch << (int)QSplitter::Auto;
415     QTest::newRow("ok64") << 200 << 200 << 200 << 200 << 200 << 200
416 			 << (bool)true << (bool)true << (bool)true
417 			 << (int)QSplitter::Stretch << (int)QSplitter::Auto;
418     QTest::newRow("ok65") << 200 << 200 << 0 << 350 << 0 << 400
419 			 << (bool)true << (bool)true << (bool)true
420 			 << (int)QSplitter::Stretch << (int)QSplitter::Auto;
421     QTest::newRow("ok66") << 200 << 200 << 350 << 0 << 400 << 0
422 			 << (bool)true << (bool)true << (bool)true
423 			 << (int)QSplitter::Stretch << (int)QSplitter::Auto;
424     QTest::newRow("ok67") << 200 << 200 << 350 << 0 << 200 << 200
425 			 << (bool)true << (bool)false << (bool)true
426 			 << (int)QSplitter::Stretch << (int)QSplitter::Auto;
427     QTest::newRow("ok68") << 200 << 200 << 350 << 0 << 200 << 200
428 			 << (bool)false << (bool)false << (bool)true
429 			 << (int)QSplitter::Stretch << (int)QSplitter::Auto;
430     QTest::newRow("ok69") << 200 << 200 << 0 << 350 << 200 << 200
431 			 << (bool)false << (bool)true << (bool)true
432 			 << (int)QSplitter::Stretch << (int)QSplitter::Auto;
433     QTest::newRow("ok70") << 200 << 200 << 0 << 350 << 200 << 200
434 			 << (bool)false << (bool)false << (bool)true
435 			 << (int)QSplitter::Stretch << (int)QSplitter::Auto;
436 
437     QTest::newRow("ok80") << 100 << 50 << 100 << 300 << 100 << 300
438 			 << (bool)true << (bool)true << (bool)true
439 			 << (int)QSplitter::Auto << (int)QSplitter::Stretch;
440     QTest::newRow("ok81") << 100 << 100 << 50 << 350 << 100 << 300
441 			 << (bool)true << (bool)true << (bool)true
442 			 << (int)QSplitter::Auto << (int)QSplitter::Stretch;
443     QTest::newRow("ok82") << 100 << 100 << 350 << 50 << 300 << 100
444 			 << (bool)true << (bool)true << (bool)true
445 			 << (int)QSplitter::Auto << (int)QSplitter::Stretch;
446     QTest::newRow("ok83") << 200 << 200 << 350 << 50 << 200 << 200
447 			 << (bool)true << (bool)true << (bool)true
448 			 << (int)QSplitter::Auto << (int)QSplitter::Stretch;
449     QTest::newRow("ok84") << 200 << 200 << 200 << 200 << 200 << 200
450 			 << (bool)true << (bool)true << (bool)true
451 			 << (int)QSplitter::Auto << (int)QSplitter::Stretch;
452     QTest::newRow("ok85") << 200 << 200 << 0 << 350 << 0 << 400
453 			 << (bool)true << (bool)true << (bool)true
454 			 << (int)QSplitter::Auto << (int)QSplitter::Stretch;
455     QTest::newRow("ok86") << 200 << 200 << 350 << 0 << 400 << 0
456 			 << (bool)true << (bool)true << (bool)true
457 			 << (int)QSplitter::Auto << (int)QSplitter::Stretch;
458     QTest::newRow("ok87") << 200 << 200 << 350 << 0 << 200 << 200
459 			 << (bool)true << (bool)false << (bool)true
460 			 << (int)QSplitter::Auto << (int)QSplitter::Stretch;
461     QTest::newRow("ok88") << 200 << 200 << 350 << 0 << 200 << 200
462 			 << (bool)false << (bool)false << (bool)true
463 			 << (int)QSplitter::Auto << (int)QSplitter::Stretch;
464     QTest::newRow("ok89") << 200 << 200 << 0 << 350 << 200 << 200
465 			 << (bool)false << (bool)true << (bool)true
466 			 << (int)QSplitter::Auto << (int)QSplitter::Stretch;
467     QTest::newRow("ok90") << 200 << 200 << 0 << 350 << 200 << 200
468 			 << (bool)false << (bool)false << (bool)true
469 			 << (int)QSplitter::Auto << (int)QSplitter::Stretch;
470 
471     QTest::newRow("ok100") << 100 << 50 << 100 << 300 << 100 << 300
472 			 << (bool)true << (bool)true << (bool)false
473 			 << (int)QSplitter::Auto << (int)QSplitter::Stretch;
474     QTest::newRow("ok101") << 100 << 100 << 50 << 350 << 100 << 300
475 			 << (bool)true << (bool)true << (bool)false
476 			 << (int)QSplitter::Auto << (int)QSplitter::Stretch;
477     QTest::newRow("ok102") << 100 << 100 << 350 << 50 << 300 << 100
478 			 << (bool)true << (bool)true << (bool)false
479 			 << (int)QSplitter::Auto << (int)QSplitter::Stretch;
480     QTest::newRow("ok103") << 200 << 200 << 350 << 50 << 200 << 200
481 			 << (bool)true << (bool)true << (bool)false
482 			 << (int)QSplitter::Auto << (int)QSplitter::Stretch;
483     QTest::newRow("ok104") << 200 << 200 << 200 << 200 << 200 << 200
484 			 << (bool)true << (bool)true << (bool)false
485 			 << (int)QSplitter::Auto << (int)QSplitter::Stretch;
486     QTest::newRow("ok105") << 200 << 200 << 0 << 350 << 0 << 400
487 			 << (bool)true << (bool)true << (bool)false
488 			 << (int)QSplitter::Auto << (int)QSplitter::Stretch;
489     QTest::newRow("ok106") << 200 << 200 << 350 << 0 << 400 << 0
490 			 << (bool)true << (bool)true << (bool)false
491 			 << (int)QSplitter::Auto << (int)QSplitter::Stretch;
492     QTest::newRow("ok107") << 200 << 200 << 350 << 0 << 200 << 200
493 			 << (bool)true << (bool)false << (bool)false
494 			 << (int)QSplitter::Auto << (int)QSplitter::Stretch;
495     QTest::newRow("ok108") << 200 << 200 << 350 << 0 << 200 << 200
496 			 << (bool)false << (bool)false << (bool)false
497 			 << (int)QSplitter::Auto << (int)QSplitter::Stretch;
498     QTest::newRow("ok109") << 200 << 200 << 0 << 350 << 200 << 200
499 			 << (bool)false << (bool)true << (bool)false
500 			 << (int)QSplitter::Auto << (int)QSplitter::Stretch;
501     QTest::newRow("ok110") << 200 << 200 << 0 << 350 << 200 << 200
502 			 << (bool)false << (bool)false << (bool)false
503 			 << (int)QSplitter::Auto << (int)QSplitter::Stretch;
504 
505     QTest::newRow("ok120") << 100 << 50 << 100 << 300 << 100 << 300
506 			 << (bool)true << (bool)true << (bool)true
507 			 << (int)QSplitter::KeepSize << (int)QSplitter::Auto;
508     QTest::newRow("ok121") << 100 << 100 << 50 << 350 << 100 << 300
509 			 << (bool)true << (bool)true << (bool)true
510 			 << (int)QSplitter::KeepSize << (int)QSplitter::Auto;
511     QTest::newRow("ok122") << 100 << 100 << 350 << 50 << 300 << 100
512 			 << (bool)true << (bool)true << (bool)true
513 			 << (int)QSplitter::KeepSize << (int)QSplitter::Auto;
514     QTest::newRow("ok123") << 200 << 200 << 350 << 50 << 200 << 200
515 			 << (bool)true << (bool)true << (bool)true
516 			 << (int)QSplitter::KeepSize << (int)QSplitter::Auto;
517     QTest::newRow("ok124") << 200 << 200 << 200 << 200 << 200 << 200
518 			 << (bool)true << (bool)true << (bool)true
519 			 << (int)QSplitter::KeepSize << (int)QSplitter::Auto;
520     QTest::newRow("ok125") << 200 << 200 << 0 << 350 << 0 << 400
521 			 << (bool)true << (bool)true << (bool)true
522 			 << (int)QSplitter::KeepSize << (int)QSplitter::Auto;
523     QTest::newRow("ok126") << 200 << 200 << 350 << 0 << 400 << 0
524 			 << (bool)true << (bool)true << (bool)true
525 			 << (int)QSplitter::KeepSize << (int)QSplitter::Auto;
526     QTest::newRow("ok127") << 200 << 200 << 350 << 0 << 200 << 200
527 			 << (bool)true << (bool)false << (bool)true
528 			 << (int)QSplitter::KeepSize << (int)QSplitter::Auto;
529     QTest::newRow("ok128") << 200 << 200 << 350 << 0 << 200 << 200
530 			 << (bool)false << (bool)false << (bool)true
531 			 << (int)QSplitter::KeepSize << (int)QSplitter::Auto;
532     QTest::newRow("ok129") << 200 << 200 << 0 << 350 << 200 << 200
533 			 << (bool)false << (bool)true << (bool)true
534 			 << (int)QSplitter::KeepSize << (int)QSplitter::Auto;
535     QTest::newRow("ok130") << 200 << 200 << 0 << 350 << 200 << 200
536 			 << (bool)false << (bool)false << (bool)true
537 			 << (int)QSplitter::KeepSize << (int)QSplitter::Auto;
538 
539     QTest::newRow("ok140") << 100 << 50 << 100 << 300 << 100 << 300
540 			 << (bool)true << (bool)true << (bool)false
541 			 << (int)QSplitter::KeepSize << (int)QSplitter::Auto;
542     QTest::newRow("ok141") << 100 << 100 << 50 << 350 << 100 << 300
543 			 << (bool)true << (bool)true << (bool)false
544 			 << (int)QSplitter::KeepSize << (int)QSplitter::Auto;
545     QTest::newRow("ok142") << 100 << 100 << 350 << 50 << 300 << 100
546 			 << (bool)true << (bool)true << (bool)false
547 			 << (int)QSplitter::KeepSize << (int)QSplitter::Auto;
548     QTest::newRow("ok143") << 200 << 200 << 350 << 50 << 200 << 200
549 			 << (bool)true << (bool)true << (bool)false
550 			 << (int)QSplitter::KeepSize << (int)QSplitter::Auto;
551     QTest::newRow("ok144") << 200 << 200 << 200 << 200 << 200 << 200
552 			 << (bool)true << (bool)true << (bool)false
553 			 << (int)QSplitter::KeepSize << (int)QSplitter::Auto;
554     QTest::newRow("ok145") << 200 << 200 << 0 << 350 << 0 << 400
555 			 << (bool)true << (bool)true << (bool)false
556 			 << (int)QSplitter::KeepSize << (int)QSplitter::Auto;
557     QTest::newRow("ok146") << 200 << 200 << 350 << 0 << 400 << 0
558 			 << (bool)true << (bool)true << (bool)false
559 			 << (int)QSplitter::KeepSize << (int)QSplitter::Auto;
560     QTest::newRow("ok147") << 200 << 200 << 350 << 0 << 200 << 200
561 			 << (bool)true << (bool)false << (bool)false
562 			 << (int)QSplitter::KeepSize << (int)QSplitter::Auto;
563     QTest::newRow("ok148") << 200 << 200 << 350 << 0 << 200 << 200
564 			 << (bool)false << (bool)false << (bool)false
565 			 << (int)QSplitter::KeepSize << (int)QSplitter::Auto;
566     QTest::newRow("ok149") << 200 << 200 << 0 << 350 << 200 << 200
567 			 << (bool)false << (bool)true << (bool)false
568 			 << (int)QSplitter::KeepSize << (int)QSplitter::Auto;
569     QTest::newRow("ok150") << 200 << 200 << 0 << 350 << 200 << 200
570 			 << (bool)false << (bool)false << (bool)false
571 			 << (int)QSplitter::KeepSize << (int)QSplitter::Auto;
572     QTest::newRow("ok160") << 100 << 50 << 100 << 300 << 100 << 300
573 			 << (bool)true << (bool)true << (bool)true
574 			 << (int)QSplitter::Auto << (int)QSplitter::KeepSize;
575     QTest::newRow("ok161") << 100 << 100 << 50 << 350 << 100 << 300
576 			 << (bool)true << (bool)true << (bool)true
577 			 << (int)QSplitter::Auto << (int)QSplitter::KeepSize;
578     QTest::newRow("ok162") << 100 << 100 << 350 << 50 << 300 << 100
579 			 << (bool)true << (bool)true << (bool)true
580 			 << (int)QSplitter::Auto << (int)QSplitter::KeepSize;
581     QTest::newRow("ok163") << 200 << 200 << 350 << 50 << 200 << 200
582 			 << (bool)true << (bool)true << (bool)true
583 			 << (int)QSplitter::Auto << (int)QSplitter::KeepSize;
584     QTest::newRow("ok164") << 200 << 200 << 200 << 200 << 200 << 200
585 			 << (bool)true << (bool)true << (bool)true
586 			 << (int)QSplitter::Auto << (int)QSplitter::KeepSize;
587     QTest::newRow("ok165") << 200 << 200 << 0 << 350 << 0 << 400
588 			 << (bool)true << (bool)true << (bool)true
589 			 << (int)QSplitter::Auto << (int)QSplitter::KeepSize;
590     QTest::newRow("ok166") << 200 << 200 << 350 << 0 << 400 << 0
591 			 << (bool)true << (bool)true << (bool)true
592 			 << (int)QSplitter::Auto << (int)QSplitter::KeepSize;
593     QTest::newRow("ok167") << 200 << 200 << 350 << 0 << 200 << 200
594 			 << (bool)true << (bool)false << (bool)true
595 			 << (int)QSplitter::Auto << (int)QSplitter::KeepSize;
596     QTest::newRow("ok168") << 200 << 200 << 350 << 0 << 200 << 200
597 			 << (bool)false << (bool)false << (bool)true
598 			 << (int)QSplitter::Auto << (int)QSplitter::KeepSize;
599     QTest::newRow("ok169") << 200 << 200 << 0 << 350 << 200 << 200
600 			 << (bool)false << (bool)true << (bool)true
601 			 << (int)QSplitter::Auto << (int)QSplitter::KeepSize;
602     QTest::newRow("ok170") << 200 << 200 << 0 << 350 << 200 << 200
603 			 << (bool)false << (bool)false << (bool)true
604 			 << (int)QSplitter::Auto << (int)QSplitter::KeepSize;
605     QTest::newRow("ok180") << 100 << 50 << 100 << 300 << 100 << 300
606 			 << (bool)true << (bool)true << (bool)false
607 			 << (int)QSplitter::Auto << (int)QSplitter::KeepSize;
608     QTest::newRow("ok181") << 100 << 100 << 50 << 350 << 100 << 300
609 			 << (bool)true << (bool)true << (bool)false
610 			 << (int)QSplitter::Auto << (int)QSplitter::KeepSize;
611     QTest::newRow("ok182") << 100 << 100 << 350 << 50 << 300 << 100
612 			 << (bool)true << (bool)true << (bool)false
613 			 << (int)QSplitter::Auto << (int)QSplitter::KeepSize;
614     QTest::newRow("ok183") << 200 << 200 << 350 << 50 << 200 << 200
615 			 << (bool)true << (bool)true << (bool)false
616 			 << (int)QSplitter::Auto << (int)QSplitter::KeepSize;
617     QTest::newRow("ok184") << 200 << 200 << 200 << 200 << 200 << 200
618 			 << (bool)true << (bool)true << (bool)false
619 			 << (int)QSplitter::Auto << (int)QSplitter::KeepSize;
620     QTest::newRow("ok185") << 200 << 200 << 0 << 350 << 0 << 400
621 			 << (bool)true << (bool)true << (bool)false
622 			 << (int)QSplitter::Auto << (int)QSplitter::KeepSize;
623     QTest::newRow("ok186") << 200 << 200 << 350 << 0 << 400 << 0
624 			 << (bool)true << (bool)true << (bool)false
625 			 << (int)QSplitter::Auto << (int)QSplitter::KeepSize;
626     QTest::newRow("ok187") << 200 << 200 << 350 << 0 << 200 << 200
627 			 << (bool)true << (bool)false << (bool)false
628 			 << (int)QSplitter::Auto << (int)QSplitter::KeepSize;
629     QTest::newRow("ok188") << 200 << 200 << 350 << 0 << 200 << 200
630 			 << (bool)false << (bool)false << (bool)false
631 			 << (int)QSplitter::Auto << (int)QSplitter::KeepSize;
632     QTest::newRow("ok189") << 200 << 200 << 0 << 350 << 200 << 200
633 			 << (bool)false << (bool)true << (bool)false
634 			 << (int)QSplitter::Auto << (int)QSplitter::KeepSize;
635     QTest::newRow("ok190") << 200 << 200 << 0 << 350 << 200 << 200
636 			 << (bool)false << (bool)false << (bool)false
637 			 << (int)QSplitter::Auto << (int)QSplitter::KeepSize;
638     QTest::newRow("ok200") << 100 << 50 << 100 << 300 << 100 << 300
639 			 << (bool)true << (bool)true << (bool)true
640 			 << (int)QSplitter::Stretch << (int)QSplitter::Stretch;
641     QTest::newRow("ok201") << 100 << 100 << 50 << 350 << 100 << 300
642 			 << (bool)true << (bool)true << (bool)true
643 			 << (int)QSplitter::Stretch << (int)QSplitter::Stretch;
644     QTest::newRow("ok202") << 100 << 100 << 350 << 50 << 300 << 100
645 			 << (bool)true << (bool)true << (bool)true
646 			 << (int)QSplitter::Stretch << (int)QSplitter::Stretch;
647     QTest::newRow("ok203") << 200 << 200 << 350 << 50 << 200 << 200
648 			 << (bool)true << (bool)true << (bool)true
649 			 << (int)QSplitter::Stretch << (int)QSplitter::Stretch;
650     QTest::newRow("ok204") << 200 << 200 << 200 << 200 << 200 << 200
651 			 << (bool)true << (bool)true << (bool)true
652 			 << (int)QSplitter::Stretch << (int)QSplitter::Stretch;
653     QTest::newRow("ok205") << 200 << 200 << 0 << 350 << 0 << 400
654 			 << (bool)true << (bool)true << (bool)true
655 			 << (int)QSplitter::Stretch << (int)QSplitter::Stretch;
656     QTest::newRow("ok206") << 200 << 200 << 350 << 0 << 400 << 0
657 			 << (bool)true << (bool)true << (bool)true
658 			 << (int)QSplitter::Stretch << (int)QSplitter::Stretch;
659     QTest::newRow("ok207") << 200 << 200 << 350 << 0 << 200 << 200
660 			 << (bool)true << (bool)false << (bool)true
661 			 << (int)QSplitter::Stretch << (int)QSplitter::Stretch;
662     QTest::newRow("ok208") << 200 << 200 << 350 << 0 << 200 << 200
663 			 << (bool)false << (bool)false << (bool)true
664 			 << (int)QSplitter::Stretch << (int)QSplitter::Stretch;
665     QTest::newRow("ok209") << 200 << 200 << 0 << 350 << 200 << 200
666 			 << (bool)false << (bool)true << (bool)true
667 			 << (int)QSplitter::Stretch << (int)QSplitter::Stretch;
668     QTest::newRow("ok210") << 200 << 200 << 0 << 350 << 200 << 200
669 			 << (bool)false << (bool)false << (bool)true
670 			 << (int)QSplitter::Stretch << (int)QSplitter::Stretch;
671     QTest::newRow("ok220") << 100 << 50 << 100 << 300 << 100 << 300
672 			 << (bool)true << (bool)true << (bool)false
673 			 << (int)QSplitter::Stretch << (int)QSplitter::Stretch;
674     QTest::newRow("ok221") << 100 << 100 << 50 << 350 << 100 << 300
675 			 << (bool)true << (bool)true << (bool)false
676 			 << (int)QSplitter::Stretch << (int)QSplitter::Stretch;
677     QTest::newRow("ok222") << 100 << 100 << 350 << 50 << 300 << 100
678 			 << (bool)true << (bool)true << (bool)false
679 			 << (int)QSplitter::Stretch << (int)QSplitter::Stretch;
680     QTest::newRow("ok223") << 200 << 200 << 350 << 50 << 200 << 200
681 			 << (bool)true << (bool)true << (bool)false
682 			 << (int)QSplitter::Stretch << (int)QSplitter::Stretch;
683     QTest::newRow("ok224") << 200 << 200 << 200 << 200 << 200 << 200
684 			 << (bool)true << (bool)true << (bool)false
685 			 << (int)QSplitter::Stretch << (int)QSplitter::Stretch;
686     QTest::newRow("ok225") << 200 << 200 << 0 << 350 << 0 << 400
687 			 << (bool)true << (bool)true << (bool)false
688 			 << (int)QSplitter::Stretch << (int)QSplitter::Stretch;
689     QTest::newRow("ok226") << 200 << 200 << 350 << 0 << 400 << 0
690 			 << (bool)true << (bool)true << (bool)false
691 			 << (int)QSplitter::Stretch << (int)QSplitter::Stretch;
692     QTest::newRow("ok227") << 200 << 200 << 350 << 0 << 200 << 200
693 			 << (bool)true << (bool)false << (bool)false
694 			 << (int)QSplitter::Stretch << (int)QSplitter::Stretch;
695     QTest::newRow("ok228") << 200 << 200 << 350 << 0 << 200 << 200
696 			 << (bool)false << (bool)false << (bool)false
697 			 << (int)QSplitter::Stretch << (int)QSplitter::Stretch;
698     QTest::newRow("ok229") << 200 << 200 << 0 << 350 << 200 << 200
699 			 << (bool)false << (bool)true << (bool)false
700 			 << (int)QSplitter::Stretch << (int)QSplitter::Stretch;
701     QTest::newRow("ok230") << 200 << 200 << 0 << 350 << 200 << 200
702 			 << (bool)false << (bool)false << (bool)false
703 			 << (int)QSplitter::Stretch << (int)QSplitter::Stretch;
704     QTest::newRow("ok240") << 100 << 50 << 100 << 300 << 100 << 300
705 			 << (bool)true << (bool)true << (bool)true
706 			 << (int)QSplitter::Stretch << (int)QSplitter::KeepSize;
707     QTest::newRow("ok241") << 100 << 100 << 50 << 350 << 100 << 300
708 			 << (bool)true << (bool)true << (bool)true
709 			 << (int)QSplitter::Stretch << (int)QSplitter::KeepSize;
710     QTest::newRow("ok242") << 100 << 100 << 350 << 50 << 300 << 100
711 			 << (bool)true << (bool)true << (bool)true
712 			 << (int)QSplitter::Stretch << (int)QSplitter::KeepSize;
713     QTest::newRow("ok243") << 200 << 200 << 350 << 50 << 200 << 200
714 			 << (bool)true << (bool)true << (bool)true
715 			 << (int)QSplitter::Stretch << (int)QSplitter::KeepSize;
716     QTest::newRow("ok244") << 200 << 200 << 200 << 200 << 200 << 200
717 			 << (bool)true << (bool)true << (bool)true
718 			 << (int)QSplitter::Stretch << (int)QSplitter::KeepSize;
719     QTest::newRow("ok245") << 200 << 200 << 0 << 350 << 0 << 400
720 			 << (bool)true << (bool)true << (bool)true
721 			 << (int)QSplitter::Stretch << (int)QSplitter::KeepSize;
722     QTest::newRow("ok246") << 200 << 200 << 350 << 0 << 400 << 0
723 			 << (bool)true << (bool)true << (bool)true
724 			 << (int)QSplitter::Stretch << (int)QSplitter::KeepSize;
725     QTest::newRow("ok247") << 200 << 200 << 350 << 0 << 200 << 200
726 			 << (bool)true << (bool)false << (bool)true
727 			 << (int)QSplitter::Stretch << (int)QSplitter::KeepSize;
728     QTest::newRow("ok248") << 200 << 200 << 350 << 0 << 200 << 200
729 			 << (bool)false << (bool)false << (bool)true
730 			 << (int)QSplitter::Stretch << (int)QSplitter::KeepSize;
731     QTest::newRow("ok249") << 200 << 200 << 0 << 350 << 200 << 200
732 			 << (bool)false << (bool)true << (bool)true
733 			 << (int)QSplitter::Stretch << (int)QSplitter::KeepSize;
734     QTest::newRow("ok250") << 200 << 200 << 0 << 350 << 200 << 200
735 			 << (bool)false << (bool)false << (bool)true
736 			 << (int)QSplitter::Stretch << (int)QSplitter::KeepSize;
737     QTest::newRow("ok260") << 100 << 50 << 100 << 300 << 100 << 300
738 			 << (bool)true << (bool)true << (bool)false
739 			 << (int)QSplitter::Stretch << (int)QSplitter::KeepSize;
740     QTest::newRow("ok261") << 100 << 100 << 50 << 350 << 100 << 300
741 			 << (bool)true << (bool)true << (bool)false
742 			 << (int)QSplitter::Stretch << (int)QSplitter::KeepSize;
743     QTest::newRow("ok262") << 100 << 100 << 350 << 50 << 300 << 100
744 			 << (bool)true << (bool)true << (bool)false
745 			 << (int)QSplitter::Stretch << (int)QSplitter::KeepSize;
746     QTest::newRow("ok263") << 200 << 200 << 350 << 50 << 200 << 200
747 			 << (bool)true << (bool)true << (bool)false
748 			 << (int)QSplitter::Stretch << (int)QSplitter::KeepSize;
749     QTest::newRow("ok264") << 200 << 200 << 200 << 200 << 200 << 200
750 			 << (bool)true << (bool)true << (bool)false
751 			 << (int)QSplitter::Stretch << (int)QSplitter::KeepSize;
752     QTest::newRow("ok265") << 200 << 200 << 0 << 350 << 0 << 400
753 			 << (bool)true << (bool)true << (bool)false
754 			 << (int)QSplitter::Stretch << (int)QSplitter::KeepSize;
755     QTest::newRow("ok266") << 200 << 200 << 350 << 0 << 400 << 0
756 			 << (bool)true << (bool)true << (bool)false
757 			 << (int)QSplitter::Stretch << (int)QSplitter::KeepSize;
758     QTest::newRow("ok267") << 200 << 200 << 350 << 0 << 200 << 200
759 			 << (bool)true << (bool)false << (bool)false
760 			 << (int)QSplitter::Stretch << (int)QSplitter::KeepSize;
761     QTest::newRow("ok268") << 200 << 200 << 350 << 0 << 200 << 200
762 			 << (bool)false << (bool)false << (bool)false
763 			 << (int)QSplitter::Stretch << (int)QSplitter::KeepSize;
764     QTest::newRow("ok269") << 200 << 200 << 0 << 350 << 200 << 200
765 			 << (bool)false << (bool)true << (bool)false
766 			 << (int)QSplitter::Stretch << (int)QSplitter::KeepSize;
767     QTest::newRow("ok270") << 200 << 200 << 0 << 350 << 200 << 200
768 			 << (bool)false << (bool)false << (bool)false
769 			 << (int)QSplitter::Stretch << (int)QSplitter::KeepSize;
770     QTest::newRow("ok280") << 100 << 50 << 100 << 300 << 100 << 300
771 			 << (bool)true << (bool)true << (bool)true
772 			 << (int)QSplitter::KeepSize << (int)QSplitter::Stretch;
773     QTest::newRow("ok281") << 100 << 100 << 50 << 350 << 100 << 300
774 			 << (bool)true << (bool)true << (bool)true
775 			 << (int)QSplitter::KeepSize << (int)QSplitter::Stretch;
776     QTest::newRow("ok282") << 100 << 100 << 350 << 50 << 300 << 100
777 			 << (bool)true << (bool)true << (bool)true
778 			 << (int)QSplitter::KeepSize << (int)QSplitter::Stretch;
779     QTest::newRow("ok283") << 200 << 200 << 350 << 50 << 200 << 200
780 			 << (bool)true << (bool)true << (bool)true
781 			 << (int)QSplitter::KeepSize << (int)QSplitter::Stretch;
782     QTest::newRow("ok284") << 200 << 200 << 200 << 200 << 200 << 200
783 			 << (bool)true << (bool)true << (bool)true
784 			 << (int)QSplitter::KeepSize << (int)QSplitter::Stretch;
785     QTest::newRow("ok285") << 200 << 200 << 0 << 350 << 0 << 400
786 			 << (bool)true << (bool)true << (bool)true
787 			 << (int)QSplitter::KeepSize << (int)QSplitter::Stretch;
788     QTest::newRow("ok286") << 200 << 200 << 350 << 0 << 400 << 0
789 			 << (bool)true << (bool)true << (bool)true
790 			 << (int)QSplitter::KeepSize << (int)QSplitter::Stretch;
791     QTest::newRow("ok287") << 200 << 200 << 350 << 0 << 200 << 200
792 			 << (bool)true << (bool)false << (bool)true
793 			 << (int)QSplitter::KeepSize << (int)QSplitter::Stretch;
794     QTest::newRow("ok288") << 200 << 200 << 350 << 0 << 200 << 200
795 			 << (bool)false << (bool)false << (bool)true
796 			 << (int)QSplitter::KeepSize << (int)QSplitter::Stretch;
797     QTest::newRow("ok289") << 200 << 200 << 0 << 350 << 200 << 200
798 			 << (bool)false << (bool)true << (bool)true
799 			 << (int)QSplitter::KeepSize << (int)QSplitter::Stretch;
800     QTest::newRow("ok290") << 200 << 200 << 0 << 350 << 200 << 200
801 			 << (bool)false << (bool)false << (bool)true
802 			 << (int)QSplitter::KeepSize << (int)QSplitter::Stretch;
803     QTest::newRow("ok300") << 100 << 50 << 100 << 300 << 100 << 300
804 			 << (bool)true << (bool)true << (bool)false
805 			 << (int)QSplitter::KeepSize << (int)QSplitter::Stretch;
806     QTest::newRow("ok301") << 100 << 100 << 50 << 350 << 100 << 300
807 			 << (bool)true << (bool)true << (bool)false
808 			 << (int)QSplitter::KeepSize << (int)QSplitter::Stretch;
809     QTest::newRow("ok302") << 100 << 100 << 350 << 50 << 300 << 100
810 			 << (bool)true << (bool)true << (bool)false
811 			 << (int)QSplitter::KeepSize << (int)QSplitter::Stretch;
812     QTest::newRow("ok303") << 200 << 200 << 350 << 50 << 200 << 200
813 			 << (bool)true << (bool)true << (bool)false
814 			 << (int)QSplitter::KeepSize << (int)QSplitter::Stretch;
815     QTest::newRow("ok304") << 200 << 200 << 200 << 200 << 200 << 200
816 			 << (bool)true << (bool)true << (bool)false
817 			 << (int)QSplitter::KeepSize << (int)QSplitter::Stretch;
818     QTest::newRow("ok305") << 200 << 200 << 0 << 350 << 0 << 400
819 			 << (bool)true << (bool)true << (bool)false
820 			 << (int)QSplitter::KeepSize << (int)QSplitter::Stretch;
821     QTest::newRow("ok306") << 200 << 200 << 350 << 0 << 400 << 0
822 			 << (bool)true << (bool)true << (bool)false
823 			 << (int)QSplitter::KeepSize << (int)QSplitter::Stretch;
824     QTest::newRow("ok307") << 200 << 200 << 350 << 0 << 200 << 200
825 			 << (bool)true << (bool)false << (bool)false
826 			 << (int)QSplitter::KeepSize << (int)QSplitter::Stretch;
827     QTest::newRow("ok308") << 200 << 200 << 350 << 0 << 200 << 200
828 			 << (bool)false << (bool)false << (bool)false
829 			 << (int)QSplitter::KeepSize << (int)QSplitter::Stretch;
830     QTest::newRow("ok309") << 200 << 200 << 0 << 350 << 200 << 200
831 			 << (bool)false << (bool)true << (bool)false
832 			 << (int)QSplitter::KeepSize << (int)QSplitter::Stretch;
833     QTest::newRow("ok310") << 200 << 200 << 0 << 350 << 200 << 200
834 			 << (bool)false << (bool)false << (bool)false
835 			 << (int)QSplitter::KeepSize << (int)QSplitter::Stretch;
836     QTest::newRow("ok320") << 100 << 50 << 100 << 300 << 100 << 300
837 			 << (bool)true << (bool)true << (bool)true
838 			 << (int)QSplitter::KeepSize << (int)QSplitter::KeepSize;
839     QTest::newRow("ok321") << 100 << 100 << 50 << 350 << 100 << 300
840 			 << (bool)true << (bool)true << (bool)true
841 			 << (int)QSplitter::KeepSize << (int)QSplitter::KeepSize;
842     QTest::newRow("ok322") << 100 << 100 << 350 << 50 << 300 << 100
843 			 << (bool)true << (bool)true << (bool)true
844 			 << (int)QSplitter::KeepSize << (int)QSplitter::KeepSize;
845     QTest::newRow("ok323") << 200 << 200 << 350 << 50 << 200 << 200
846 			 << (bool)true << (bool)true << (bool)true
847 			 << (int)QSplitter::KeepSize << (int)QSplitter::KeepSize;
848     QTest::newRow("ok324") << 200 << 200 << 200 << 200 << 200 << 200
849 			 << (bool)true << (bool)true << (bool)true
850 			 << (int)QSplitter::KeepSize << (int)QSplitter::KeepSize;
851     QTest::newRow("ok325") << 200 << 200 << 0 << 350 << 0 << 400
852 			 << (bool)true << (bool)true << (bool)true
853 			 << (int)QSplitter::KeepSize << (int)QSplitter::KeepSize;
854     QTest::newRow("ok326") << 200 << 200 << 350 << 0 << 400 << 0
855 			 << (bool)true << (bool)true << (bool)true
856 			 << (int)QSplitter::KeepSize << (int)QSplitter::KeepSize;
857     QTest::newRow("ok327") << 200 << 200 << 350 << 0 << 200 << 200
858 			 << (bool)true << (bool)false << (bool)true
859 			 << (int)QSplitter::KeepSize << (int)QSplitter::KeepSize;
860     QTest::newRow("ok328") << 200 << 200 << 350 << 0 << 200 << 200
861 			 << (bool)false << (bool)false << (bool)true
862 			 << (int)QSplitter::KeepSize << (int)QSplitter::KeepSize;
863     QTest::newRow("ok329") << 200 << 200 << 0 << 350 << 200 << 200
864 			 << (bool)false << (bool)true << (bool)true
865 			 << (int)QSplitter::KeepSize << (int)QSplitter::KeepSize;
866     QTest::newRow("ok330") << 200 << 200 << 0 << 350 << 200 << 200
867 			 << (bool)false << (bool)false << (bool)true
868 			 << (int)QSplitter::KeepSize << (int)QSplitter::KeepSize;
869     QTest::newRow("ok340") << 100 << 50 << 100 << 300 << 100 << 300
870 			 << (bool)true << (bool)true << (bool)false
871 			 << (int)QSplitter::KeepSize << (int)QSplitter::KeepSize;
872     QTest::newRow("ok341") << 100 << 100 << 50 << 350 << 100 << 300
873 			 << (bool)true << (bool)true << (bool)false
874 			 << (int)QSplitter::KeepSize << (int)QSplitter::KeepSize;
875     QTest::newRow("ok342") << 100 << 100 << 350 << 50 << 300 << 100
876 			 << (bool)true << (bool)true << (bool)false
877 			 << (int)QSplitter::KeepSize << (int)QSplitter::KeepSize;
878     QTest::newRow("ok343") << 200 << 200 << 350 << 50 << 200 << 200
879 			 << (bool)true << (bool)true << (bool)false
880 			 << (int)QSplitter::KeepSize << (int)QSplitter::KeepSize;
881     QTest::newRow("ok344") << 200 << 200 << 200 << 200 << 200 << 200
882 			 << (bool)true << (bool)true << (bool)false
883 			 << (int)QSplitter::KeepSize << (int)QSplitter::KeepSize;
884     QTest::newRow("ok345") << 200 << 200 << 0 << 350 << 0 << 400
885 			 << (bool)true << (bool)true << (bool)false
886 			 << (int)QSplitter::KeepSize << (int)QSplitter::KeepSize;
887     QTest::newRow("ok346") << 200 << 200 << 350 << 0 << 400 << 0
888 			 << (bool)true << (bool)true << (bool)false
889 			 << (int)QSplitter::KeepSize << (int)QSplitter::KeepSize;
890     QTest::newRow("ok347") << 200 << 200 << 350 << 0 << 200 << 200
891 			 << (bool)true << (bool)false << (bool)false
892 			 << (int)QSplitter::KeepSize << (int)QSplitter::KeepSize;
893     QTest::newRow("ok348") << 200 << 200 << 350 << 0 << 200 << 200
894 			 << (bool)false << (bool)false << (bool)false
895 			 << (int)QSplitter::KeepSize << (int)QSplitter::KeepSize;
896     QTest::newRow("ok349") << 200 << 200 << 0 << 350 << 200 << 200
897 			 << (bool)false << (bool)true << (bool)false
898 			 << (int)QSplitter::KeepSize << (int)QSplitter::KeepSize;
899     QTest::newRow("ok350") << 200 << 200 << 0 << 350 << 200 << 200
900 			 << (bool)false << (bool)false << (bool)false
901 			 << (int)QSplitter::KeepSize << (int)QSplitter::KeepSize;
902 #endif
903 }
904 
saveAndRestoreState_data()905 void tst_QSplitter::saveAndRestoreState_data()
906 {
907     saveState_data();
908 }
909 
saveAndRestoreState()910 void tst_QSplitter::saveAndRestoreState()
911 {
912     QFETCH(IntList, initialSizes);
913     splitter->setSizes(initialSizes);
914     QApplication::instance()->sendPostedEvents();
915 
916     QSplitter *splitter2 = new QSplitter(splitter->orientation() == Qt::Horizontal ?
917                                          Qt::Vertical : Qt::Horizontal);
918     for (int i = 0; i < splitter->count(); ++i) {
919         splitter2->addWidget(new QWidget());
920     }
921     splitter2->resize(splitter->size());
922     splitter2->setChildrenCollapsible(!splitter->childrenCollapsible());
923     splitter2->setOpaqueResize(!splitter->opaqueResize());
924     splitter2->setHandleWidth(splitter->handleWidth()+3);
925 
926     QByteArray ba = splitter->saveState();
927     QVERIFY(splitter2->restoreState(ba));
928 
929     QCOMPARE(splitter2->orientation(), splitter->orientation());
930     QCOMPARE(splitter2->handleWidth(), splitter->handleWidth());
931     QCOMPARE(splitter2->opaqueResize(), splitter->opaqueResize());
932     QCOMPARE(splitter2->childrenCollapsible(), splitter->childrenCollapsible());
933 
934     QList<int> l1 = splitter->sizes();
935     QList<int> l2 = splitter2->sizes();
936     QCOMPARE(l1.size(), l2.size());
937     for (int i = 0; i < splitter->sizes().size(); ++i) {
938         QCOMPARE(l2.at(i), l1.at(i));
939     }
940 
941     // destroy version and magic number
942     for (int i = 0; i < ba.size(); ++i)
943         ba[i] = ~ba.at(i);
944     QVERIFY(!splitter2->restoreState(ba));
945 
946     delete splitter2;
947 }
948 
saveAndRestoreStateOfNotYetShownSplitter()949 void tst_QSplitter::saveAndRestoreStateOfNotYetShownSplitter()
950 {
951     QSplitter *spl = new QSplitter;
952     QLabel *l1 = new QLabel;
953     QLabel *l2 = new QLabel;
954     spl->addWidget(l1);
955     spl->addWidget(l2);
956 
957     QByteArray ba = spl->saveState();
958     spl->restoreState(ba);
959     spl->show();
960     QTest::qWait(500);
961 
962     QCOMPARE(l1->geometry().isValid(), true);
963     QCOMPARE(l2->geometry().isValid(), true);
964 
965     delete spl;
966 }
967 
saveState_data()968 void tst_QSplitter::saveState_data()
969 {
970     QTest::addColumn<IntList>("initialSizes");
971     QTest::addColumn<bool>("hideWidget1");
972     QTest::addColumn<bool>("hideWidget2");
973     QTest::addColumn<QByteArray>("finalBa");
974 
975     QTest::newRow("ok0") << (IntList() << 200 << 200) << bool(false) << bool(false) << QByteArray("[200,200]");
976     QTest::newRow("ok1") << (IntList() << 300 << 100) << bool(false) << bool(false) << QByteArray("[300,100]");
977     QTest::newRow("ok2") << (IntList() << 100 << 300) << bool(false) << bool(false) << QByteArray("[100,300]");
978     QTest::newRow("ok3") << (IntList() << 200 << 200) << bool(false) << bool(true) << QByteArray("[200,H]");
979     QTest::newRow("ok4") << (IntList() << 200 << 200) << bool(true) << bool(false) << QByteArray("[H,200]");
980     QTest::newRow("ok5") << (IntList() << 200 << 200) << bool(false) << bool(false) << QByteArray("[200,200]");
981     QTest::newRow("ok6") << (IntList() << 200 << 200) << bool(false) << bool(false) << QByteArray("[200,200]");
982     QTest::newRow("ok7") << (IntList() << 200 << 200) << bool(false) << bool(false) << QByteArray("[200,200]");
983     QTest::newRow("ok8") << (IntList() << 200 << 200) << bool(true) << bool(true) << QByteArray("[H,H]");
984 }
985 
addWidget()986 void tst_QSplitter::addWidget()
987 {
988     QSplitter split;
989 
990     // Simple case
991     QWidget *widget1 = new QWidget;
992     QWidget *widget2 = new QWidget;
993     split.addWidget(widget1);
994     split.addWidget(widget2);
995     QCOMPARE(split.count(), 2);
996     QCOMPARE(split.indexOf(widget1), 0);
997     QCOMPARE(split.indexOf(widget2), 1);
998     QCOMPARE(split.widget(0), widget1);
999     QCOMPARE(split.widget(1), widget2);
1000 
1001 
1002     // Implicit Add
1003     QWidget *widget3 = new QWidget(&split);
1004     QCOMPARE(split.count(), 3);
1005     QCOMPARE(split.indexOf(widget3), 2);
1006     QCOMPARE(split.widget(2), widget3);
1007 
1008     // Try and add it again
1009     split.addWidget(widget3);
1010     QCOMPARE(split.count(), 3);
1011     QCOMPARE(split.indexOf(widget3), 2);
1012     QCOMPARE(split.widget(2), widget3);
1013 
1014     // Add a widget that is already in the splitter
1015     split.addWidget(widget1);
1016     QCOMPARE(split.count(), 3);
1017     QCOMPARE(split.indexOf(widget1), 2);
1018     QCOMPARE(split.widget(0), widget2);
1019     QCOMPARE(split.widget(1), widget3);
1020     QCOMPARE(split.widget(2), widget1);
1021 
1022     // Change a widget's parent
1023     widget2->setParent(0);
1024     QCOMPARE(split.count(), 2);
1025     QCOMPARE(split.indexOf(widget2), -1);
1026 
1027 
1028     // Add the widget in again.
1029     split.addWidget(widget2);
1030     QCOMPARE(split.count(), 3);
1031     QCOMPARE(split.indexOf(widget2), 2);
1032     QCOMPARE(split.widget(0), widget3);
1033     QCOMPARE(split.widget(1), widget1);
1034     QCOMPARE(split.widget(2), widget2);
1035 
1036     // Delete a widget
1037     delete widget1;
1038     QCOMPARE(split.count(), 2);
1039     QCOMPARE(split.indexOf(widget1), -1); // Nasty
1040     QCOMPARE(split.widget(0), widget3);
1041     QCOMPARE(split.widget(1), widget2);
1042 
1043     delete widget2;
1044 }
1045 
insertWidget()1046 void tst_QSplitter::insertWidget()
1047 {
1048     QSplitter split;
1049     QWidget *widget1 = new QWidget;
1050     QWidget *widget2 = new QWidget;
1051     QWidget *widget3 = new QWidget;
1052 
1053     split.insertWidget(0, widget1);
1054     QCOMPARE(split.count(), 1);
1055     QCOMPARE(split.indexOf(widget1), 0);
1056     QCOMPARE(split.widget(0), widget1);
1057 
1058     split.insertWidget(0, widget2);
1059     QCOMPARE(split.count(), 2);
1060     QCOMPARE(split.indexOf(widget1), 1);
1061     QCOMPARE(split.indexOf(widget2), 0);
1062     QCOMPARE(split.widget(0), widget2);
1063     QCOMPARE(split.widget(1), widget1);
1064 
1065     split.insertWidget(1, widget3);
1066     QCOMPARE(split.count(), 3);
1067     QCOMPARE(split.indexOf(widget1), 2);
1068     QCOMPARE(split.indexOf(widget2), 0);
1069     QCOMPARE(split.indexOf(widget3), 1);
1070     QCOMPARE(split.widget(0), widget2);
1071     QCOMPARE(split.widget(1), widget3);
1072     QCOMPARE(split.widget(2), widget1);
1073 
1074     delete widget3;
1075     QCOMPARE(split.count(), 2);
1076     QCOMPARE(split.indexOf(widget1), 1);
1077     QCOMPARE(split.indexOf(widget2), 0);
1078     QCOMPARE(split.widget(0), widget2);
1079     QCOMPARE(split.widget(1), widget1);
1080 
1081     widget3 = new QWidget;
1082     split.insertWidget(split.count() + 1, widget3);
1083     QCOMPARE(split.count(), 3);
1084     QCOMPARE(split.indexOf(widget1), 1);
1085     QCOMPARE(split.indexOf(widget2), 0);
1086     QCOMPARE(split.indexOf(widget3), 2);
1087     QCOMPARE(split.widget(0), widget2);
1088     QCOMPARE(split.widget(1), widget1);
1089     QCOMPARE(split.widget(2), widget3);
1090 
1091 
1092     // Try it again,
1093     split.insertWidget(split.count() + 1, widget3);
1094     QCOMPARE(split.count(), 3);
1095     QCOMPARE(split.indexOf(widget1), 1);
1096     QCOMPARE(split.indexOf(widget2), 0);
1097     QCOMPARE(split.indexOf(widget3), 2);
1098     QCOMPARE(split.widget(0), widget2);
1099     QCOMPARE(split.widget(1), widget1);
1100     QCOMPARE(split.widget(2), widget3);
1101 
1102     // Try to move widget2 to a bad place
1103     split.insertWidget(-1, widget2);
1104     QCOMPARE(split.count(), 3);
1105     QCOMPARE(split.indexOf(widget1), 0);
1106     QCOMPARE(split.indexOf(widget2), 2);
1107     QCOMPARE(split.indexOf(widget3), 1);
1108     QCOMPARE(split.widget(0), widget1);
1109     QCOMPARE(split.widget(1), widget3);
1110     QCOMPARE(split.widget(2), widget2);
1111 
1112     QWidget *widget4 = new QWidget(&split);
1113     QCOMPARE(split.count(), 4);
1114     QCOMPARE(split.indexOf(widget1), 0);
1115     QCOMPARE(split.indexOf(widget2), 2);
1116     QCOMPARE(split.indexOf(widget3), 1);
1117     QCOMPARE(split.indexOf(widget4), 3);
1118     QCOMPARE(split.widget(0), widget1);
1119     QCOMPARE(split.widget(1), widget3);
1120     QCOMPARE(split.widget(2), widget2);
1121     QCOMPARE(split.widget(3), widget4);
1122 
1123     QWidget *widget5 = new QWidget(&split);
1124     QCOMPARE(split.count(), 5);
1125     QCOMPARE(split.indexOf(widget1), 0);
1126     QCOMPARE(split.indexOf(widget2), 2);
1127     QCOMPARE(split.indexOf(widget3), 1);
1128     QCOMPARE(split.indexOf(widget4), 3);
1129     QCOMPARE(split.indexOf(widget5), 4);
1130     QCOMPARE(split.widget(0), widget1);
1131     QCOMPARE(split.widget(1), widget3);
1132     QCOMPARE(split.widget(2), widget2);
1133     QCOMPARE(split.widget(3), widget4);
1134     QCOMPARE(split.widget(4), widget5);
1135 
1136     split.insertWidget(2, widget4);
1137     QCOMPARE(split.count(), 5);
1138     QCOMPARE(split.indexOf(widget1), 0);
1139     QCOMPARE(split.indexOf(widget2), 3);
1140     QCOMPARE(split.indexOf(widget3), 1);
1141     QCOMPARE(split.indexOf(widget4), 2);
1142     QCOMPARE(split.indexOf(widget5), 4);
1143     QCOMPARE(split.widget(0), widget1);
1144     QCOMPARE(split.widget(1), widget3);
1145     QCOMPARE(split.widget(2), widget4);
1146     QCOMPARE(split.widget(3), widget2);
1147     QCOMPARE(split.widget(4), widget5);
1148 
1149     split.insertWidget(1, widget5);
1150     QCOMPARE(split.count(), 5);
1151     QCOMPARE(split.indexOf(widget1), 0);
1152     QCOMPARE(split.indexOf(widget2), 4);
1153     QCOMPARE(split.indexOf(widget3), 2);
1154     QCOMPARE(split.indexOf(widget4), 3);
1155     QCOMPARE(split.indexOf(widget5), 1);
1156     QCOMPARE(split.widget(0), widget1);
1157     QCOMPARE(split.widget(1), widget5);
1158     QCOMPARE(split.widget(2), widget3);
1159     QCOMPARE(split.widget(3), widget4);
1160     QCOMPARE(split.widget(4), widget2);
1161 }
1162 
setStretchFactor_data()1163 void tst_QSplitter::setStretchFactor_data()
1164 {
1165     QTest::addColumn<int>("orientation");
1166     QTest::addColumn<int>("widgetIndex");
1167     QTest::addColumn<int>("stretchFactor");
1168     QTest::addColumn<int>("expectedHStretch");
1169     QTest::addColumn<int>("expectedVStretch");
1170 
1171     QTest::newRow("ok01") << int(Qt::Horizontal) << 1 << 2 << 2 << 2;
1172     QTest::newRow("ok02") << int(Qt::Horizontal) << 2 << 0 << 0 << 0;
1173     QTest::newRow("ok03") << int(Qt::Horizontal) << 3 << 1 << 1 << 1;
1174     QTest::newRow("ok04") << int(Qt::Horizontal) << 0 << 7 << 7 << 7;
1175     QTest::newRow("ok05") << int(Qt::Vertical) << 0 << 0 << 0 << 0;
1176     QTest::newRow("ok06") << int(Qt::Vertical) << 1 << 1 << 1 << 1;
1177     QTest::newRow("ok07") << int(Qt::Vertical) << 2 << 2 << 2 << 2;
1178     QTest::newRow("ok08") << int(Qt::Vertical) << 3 << 5 << 5 << 5;
1179     QTest::newRow("ok08") << int(Qt::Vertical) << -1 << 5 << 0 << 0;
1180 }
1181 
setStretchFactor()1182 void tst_QSplitter::setStretchFactor()
1183 {
1184     QFETCH(int, orientation);
1185     Qt::Orientation orient = Qt::Orientation(orientation);
1186     QSplitter split(orient);
1187     QWidget *w = new QWidget;
1188     split.addWidget(w);
1189     w = new QWidget;
1190     split.addWidget(w);
1191     w = new QWidget;
1192     split.addWidget(w);
1193     w = new QWidget;
1194     split.addWidget(w);
1195 
1196     QFETCH(int, widgetIndex);
1197     QFETCH(int, stretchFactor);
1198     w = split.widget(widgetIndex);
1199     QSizePolicy sp;
1200     if (w) {
1201         QCOMPARE(sp.horizontalStretch(), 0);
1202         QCOMPARE(sp.verticalStretch(), 0);
1203     }
1204     split.setStretchFactor(widgetIndex, stretchFactor);
1205     if (w)
1206         sp = w->sizePolicy();
1207     QTEST(sp.horizontalStretch(), "expectedHStretch");
1208     QTEST(sp.verticalStretch(), "expectedVStretch");
1209 }
1210 
testShowHide_data()1211 void tst_QSplitter::testShowHide_data()
1212 {
1213     QTest::addColumn<bool>("hideWidget1");
1214     QTest::addColumn<bool>("hideWidget2");
1215     QTest::addColumn<QList<int> >("finalValues");
1216     QTest::addColumn<bool>("handleVisible");
1217 
1218     QSplitter *split = new QSplitter(Qt::Horizontal);
1219     QTest::newRow("hideNone") << false << false << (QList<int>() << 200 << 200) << true;
1220     QTest::newRow("hide2") << false << true << (QList<int>() << 400 + split->handleWidth() << 0) << false;
1221     QTest::newRow("hide1") << true << false << (QList<int>() << 0 << 400 + split->handleWidth()) << false;
1222     QTest::newRow("hideall") << true << true << (QList<int>() << 0 << 0) << false;
1223     delete split;
1224 }
1225 
testShowHide()1226 void tst_QSplitter::testShowHide()
1227 {
1228     QFETCH(bool, hideWidget1);
1229     QFETCH(bool, hideWidget2);
1230 
1231     QSplitter *split = new QSplitter(Qt::Horizontal);
1232 
1233     QWidget topLevel;
1234     QWidget widget(&topLevel);
1235     widget.resize(400 + split->handleWidth(), 200);
1236     QVBoxLayout *lay=new QVBoxLayout(&widget);
1237     lay->setMargin(0);
1238     lay->setSpacing(0);
1239     split->addWidget(new QWidget);
1240     split->addWidget(new QWidget);
1241     split->setSizes(QList<int>() << 200 << 200);
1242     lay->addWidget(split);
1243     widget.setLayout(lay);
1244     topLevel.show();
1245 
1246     QTest::qWait(100);
1247 
1248     widget.hide();
1249     split->widget(0)->setHidden(hideWidget1);
1250     split->widget(1)->setHidden(hideWidget2);
1251     widget.show();
1252     QTest::qWait(100);
1253 
1254     QTEST(split->sizes(), "finalValues");
1255     QTEST(split->handle(1)->isVisible(), "handleVisible");
1256 }
1257 
testRemoval()1258 void tst_QSplitter::testRemoval()
1259 {
1260 
1261     // This test relies on the internal structure of QSplitter That is, that
1262     // there is a handle before every splitter, but sometimes that handle is
1263     // hidden. But definiately when something is removed the front handle
1264     // should not be visible.
1265 
1266     QSplitter split;
1267     split.addWidget(new QWidget);
1268     split.addWidget(new QWidget);
1269     split.show();
1270     QTest::qWait(100);
1271 
1272     QCOMPARE(split.handle(0)->isVisible(), false);
1273     QSplitterHandle *handle = split.handle(1);
1274     QCOMPARE(handle->isVisible(), true);
1275 
1276     delete split.widget(0);
1277     QSplitterHandle *sameHandle = split.handle(0);
1278     QCOMPARE(handle, sameHandle);
1279     QCOMPARE(sameHandle->isVisible(), false);
1280 }
1281 
1282 class MyFriendlySplitter : public QSplitter
1283 {
1284 public:
MyFriendlySplitter(QWidget * parent=0)1285     MyFriendlySplitter(QWidget *parent = 0) : QSplitter(parent) {}
setRubberBand(int pos)1286     void setRubberBand(int pos) { QSplitter::setRubberBand(pos); }
1287 
1288     friend class tst_QSplitter;
1289 };
1290 
rubberBandNotInSplitter()1291 void tst_QSplitter::rubberBandNotInSplitter()
1292 {
1293     MyFriendlySplitter split;
1294     split.addWidget(new QWidget);
1295     split.addWidget(new QWidget);
1296     split.setOpaqueResize(false);
1297     QCOMPARE(split.count(), 2);
1298     split.setRubberBand(2);
1299     QCOMPARE(split.count(), 2);
1300 }
1301 
task187373_addAbstractScrollAreas_data()1302 void tst_QSplitter::task187373_addAbstractScrollAreas_data()
1303 {
1304     QTest::addColumn<QString>("className");
1305     QTest::addColumn<bool>("addInConstructor");
1306     QTest::addColumn<bool>("addOutsideConstructor");
1307 
1308     QStringList classNames;
1309     classNames << QLatin1String("QGraphicsView");
1310     classNames << QLatin1String("QMdiArea");
1311     classNames << QLatin1String("QScrollArea");
1312     classNames << QLatin1String("QTextEdit");
1313     classNames << QLatin1String("QTreeView");
1314 
1315     foreach (QString className, classNames) {
1316         QTest::newRow(qPrintable(QString("%1 1").arg(className))) << className << false << true;
1317         QTest::newRow(qPrintable(QString("%1 2").arg(className))) << className << true << false;
1318         QTest::newRow(qPrintable(QString("%1 3").arg(className))) << className << true << true;
1319     }
1320 }
1321 
task187373_createScrollArea(QSplitter * splitter,const QString & className,bool addInConstructor)1322 static QAbstractScrollArea *task187373_createScrollArea(
1323     QSplitter *splitter, const QString &className, bool addInConstructor)
1324 {
1325     if (className == QLatin1String("QGraphicsView"))
1326         return new QGraphicsView(addInConstructor ? splitter : 0);
1327     if (className == QLatin1String("QMdiArea"))
1328         return new QMdiArea(addInConstructor ? splitter : 0);
1329     if (className == QLatin1String("QScrollArea"))
1330         return new QScrollArea(addInConstructor ? splitter : 0);
1331     if (className == QLatin1String("QTextEdit"))
1332         return new QTextEdit(addInConstructor ? splitter : 0);
1333     if (className == QLatin1String("QTreeView"))
1334         return new QTreeView(addInConstructor ? splitter : 0);
1335     return 0;
1336 }
1337 
task187373_addAbstractScrollAreas()1338 void tst_QSplitter::task187373_addAbstractScrollAreas()
1339 {
1340     QFETCH(QString, className);
1341     QFETCH(bool, addInConstructor);
1342     QFETCH(bool, addOutsideConstructor);
1343     QVERIFY(addInConstructor || addOutsideConstructor);
1344 
1345     QSplitter *splitter = new QSplitter;
1346     splitter->show();
1347     QVERIFY(splitter->isVisible());
1348 
1349     QAbstractScrollArea *w = task187373_createScrollArea(splitter, className, addInConstructor);
1350     QVERIFY(w);
1351     if (addOutsideConstructor)
1352         splitter->addWidget(w);
1353 
1354     QTRY_VERIFY(w->isVisible());
1355     QVERIFY(!w->isHidden());
1356     QVERIFY(w->viewport()->isVisible());
1357     QVERIFY(!w->viewport()->isHidden());
1358 }
1359 
1360 //! A simple QTextEdit which can switch between two different size states
1361 class MyTextEdit : public QTextEdit
1362 {
1363     public:
MyTextEdit(const QString & text,QWidget * parent=NULL)1364         MyTextEdit(const QString & text, QWidget* parent = NULL)
1365             : QTextEdit(text, parent) ,  m_iFactor(1)
1366         {
1367             setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
1368         }
minimumSizeHint() const1369         virtual QSize minimumSizeHint () const
1370         {
1371             return QSize(200, 200) * m_iFactor;
1372         }
sizeHint() const1373         virtual QSize sizeHint() const
1374         {
1375             return QSize(390, 390) * m_iFactor;
1376         }
1377         int m_iFactor;
1378 };
1379 
task169702_sizes()1380 void tst_QSplitter::task169702_sizes()
1381 {
1382     QWidget topLevel;
1383     // Create two nested (non-collapsible) splitters
1384     QSplitter* outerSplitter = new QSplitter(Qt::Vertical, &topLevel);
1385     outerSplitter->setChildrenCollapsible(false);
1386     QSplitter* splitter = new QSplitter(Qt::Horizontal, outerSplitter);
1387     splitter->setChildrenCollapsible(false);
1388 
1389     // populate the outer splitter
1390     outerSplitter->addWidget(new QTextEdit("Foo"));
1391     outerSplitter->addWidget(splitter);
1392     outerSplitter->setStretchFactor(0, 1);
1393     outerSplitter->setStretchFactor(1, 0);
1394 
1395     // populate the inner splitter
1396     MyTextEdit* testW = new MyTextEdit("TextEdit with size restriction");
1397     splitter->addWidget(testW);
1398     splitter->addWidget(new QTextEdit("Bar"));
1399 
1400     outerSplitter->setGeometry(100, 100, 500, 500);
1401     topLevel.show();
1402 
1403     QTest::qWait(100);
1404     testW->m_iFactor++;
1405     testW->updateGeometry();
1406     QTest::qWait(500);//100 is too fast for Maemo
1407 
1408     //Make sure the minimimSizeHint is respected
1409     QCOMPARE(testW->size().height(), testW->minimumSizeHint().height());
1410 }
1411 
taskQTBUG_4101_ensureOneNonCollapsedWidget_data()1412 void tst_QSplitter::taskQTBUG_4101_ensureOneNonCollapsedWidget_data()
1413 {
1414     QTest::addColumn<bool>("testingHide");
1415 
1416     QTest::newRow("last non collapsed hidden") << true;
1417     QTest::newRow("last non collapsed deleted") << false;
1418 }
1419 
taskQTBUG_4101_ensureOneNonCollapsedWidget()1420 void tst_QSplitter::taskQTBUG_4101_ensureOneNonCollapsedWidget()
1421 {
1422     QFETCH(bool, testingHide);
1423 
1424     MyFriendlySplitter s;
1425     QLabel *l;
1426     for (int i = 0; i < 5; ++i) {
1427         l = new QLabel(QString("Label ") + QChar('A' + i));
1428         l->setAlignment(Qt::AlignCenter);
1429         s.addWidget(l);
1430         s.moveSplitter(0, i);  // Collapse all the labels except the last one.
1431     }
1432 
1433     s.show();
1434     if (testingHide)
1435         l->hide();
1436     else
1437         delete l;
1438     QTest::qWait(100);
1439     QVERIFY(s.sizes().at(0) > 0);
1440 }
1441 
1442 QTEST_MAIN(tst_QSplitter)
1443 #include "tst_qsplitter.moc"
1444