|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the 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 #include <QtTest/QtTest> |
|
44 |
|
45 #include <q3dockarea.h> |
|
46 #include <q3dockwindow.h> |
|
47 #include <q3mainwindow.h> |
|
48 #include <qapplication.h> |
|
49 #include <qframe.h> |
|
50 #include <qlabel.h> |
|
51 #include <qlayout.h> |
|
52 #include <qmessagebox.h> |
|
53 #include <qpushbutton.h> |
|
54 |
|
55 //TESTED_CLASS= |
|
56 //TESTED_FILES= |
|
57 |
|
58 class tst_Q3DockWindow : public QObject |
|
59 { |
|
60 Q_OBJECT |
|
61 public: |
|
62 tst_Q3DockWindow(); |
|
63 virtual ~tst_Q3DockWindow(); |
|
64 |
|
65 |
|
66 public slots: |
|
67 void initTestCase(); |
|
68 void cleanupTestCase(); |
|
69 private slots: |
|
70 void parents(); |
|
71 void showChild(); |
|
72 }; |
|
73 |
|
74 QFrame *makeFrame( const char *text, QWidget *parent ) |
|
75 { |
|
76 QFrame* frame = new QFrame(parent); |
|
77 QVBoxLayout* layout = new QVBoxLayout(frame); |
|
78 layout->setAutoAdd(true); |
|
79 new QLabel(text, frame); |
|
80 frame->setMinimumSize(200, 200); |
|
81 return frame; |
|
82 } |
|
83 |
|
84 Q3DockWindow* makeDock( const char* text, QWidget* parent ) |
|
85 { |
|
86 Q3DockWindow* dock = new Q3DockWindow(Q3DockWindow::InDock, parent, text); |
|
87 dock->setResizeEnabled(true); |
|
88 dock->setCloseMode(Q3DockWindow::Always); |
|
89 dock->setCaption(text); |
|
90 dock->setWidget(makeFrame(text, dock)); |
|
91 dock->show(); |
|
92 |
|
93 return dock; |
|
94 } |
|
95 |
|
96 |
|
97 tst_Q3DockWindow::tst_Q3DockWindow() |
|
98 |
|
99 { |
|
100 } |
|
101 |
|
102 tst_Q3DockWindow::~tst_Q3DockWindow() |
|
103 { |
|
104 } |
|
105 |
|
106 void tst_Q3DockWindow::initTestCase() |
|
107 { |
|
108 // create a default mainwindow |
|
109 // If you run a widget test, this will be replaced in the testcase by the |
|
110 // widget under test |
|
111 QWidget *w = new QWidget(0,"mainWidget"); |
|
112 w->setFixedSize( 200, 200 ); |
|
113 qApp->setMainWidget( w ); |
|
114 w->show(); |
|
115 } |
|
116 |
|
117 void tst_Q3DockWindow::cleanupTestCase() |
|
118 { |
|
119 delete qApp->mainWidget(); |
|
120 } |
|
121 |
|
122 void tst_Q3DockWindow::parents() |
|
123 { |
|
124 // create 5 dock windows, one for each dock area |
|
125 // and one for the mainwindow, in the end they should |
|
126 // all except the one with the mainwindow as parent should |
|
127 // have the same dock() and parent() pointer. |
|
128 Q3MainWindow mw; |
|
129 QFrame *central = makeFrame( "Central", &mw ); |
|
130 mw.setCentralWidget( central ); |
|
131 |
|
132 Q3DockWindow *topDock = makeDock( "Top", mw.topDock() ); |
|
133 QVERIFY( topDock->area() == topDock->parent() ); |
|
134 |
|
135 Q3DockWindow *leftDock = makeDock( "Left", mw.leftDock() ); |
|
136 QVERIFY( leftDock->area() == leftDock->parent() ); |
|
137 |
|
138 Q3DockWindow *rightDock= makeDock( "Right", mw.rightDock() ); |
|
139 QVERIFY( rightDock->area() == rightDock->parent() ); |
|
140 |
|
141 Q3DockWindow *bottomDock = makeDock( "Bottom", mw.bottomDock() ); |
|
142 QVERIFY( bottomDock->area() == mw.bottomDock() ); |
|
143 |
|
144 Q3DockWindow *mainDock = makeDock( "MainWindow as parent", &mw ); |
|
145 QVERIFY( mainDock->parent() == mw.topDock() ); |
|
146 } |
|
147 |
|
148 |
|
149 void tst_Q3DockWindow::showChild() |
|
150 { |
|
151 // task 26225 |
|
152 // calling show dose not propergate to child widgets if |
|
153 // main window is already showing |
|
154 |
|
155 Q3MainWindow mw; |
|
156 mw.show(); |
|
157 Q3DockWindow * dock = new Q3DockWindow(&mw); |
|
158 QPushButton * qpb = new QPushButton("hi", dock); |
|
159 dock->setWidget(qpb); |
|
160 dock->show(); |
|
161 QVERIFY( mw.isVisible() ); |
|
162 QVERIFY( dock->isVisible() ); |
|
163 QVERIFY( qpb->isVisible() ); |
|
164 } |
|
165 |
|
166 |
|
167 |
|
168 QTEST_MAIN(tst_Q3DockWindow) |
|
169 #include "tst_q3dockwindow.moc" |
|
170 |