|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the examples of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 |
|
43 #include <QTcpServer> |
|
44 #include <QTcpSocket> |
|
45 #include <QtWebKit> |
|
46 |
|
47 #include "browserwindow.h" |
|
48 #include "addressbar.h" |
|
49 #include "homeview.h" |
|
50 #include "browserview.h" |
|
51 #include "httpserver.h" |
|
52 #include "autotest.h" |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 // |
|
58 class serverThread : public QThread |
|
59 { |
|
60 public: |
|
61 void run(); |
|
62 }; |
|
63 |
|
64 void serverThread::run() |
|
65 { |
|
66 httpServer testServer; |
|
67 |
|
68 while ( testServer.isDone() ) |
|
69 { |
|
70 QTest::qWait(1000); |
|
71 } |
|
72 } |
|
73 |
|
74 |
|
75 // |
|
76 // from here normal autotest stuff follows... |
|
77 // |
|
78 |
|
79 |
|
80 void autoTest::initTestCase() |
|
81 { |
|
82 } |
|
83 |
|
84 void autoTest::testDefaults() |
|
85 { |
|
86 BrowserWindow bw; |
|
87 bw.show(); |
|
88 |
|
89 |
|
90 // Test default values for widget properties |
|
91 QCOMPARE( bw.acceptDrops(), false ); |
|
92 // QCOMPARE( bw.hasEditFocus(), false ); |
|
93 /* |
|
94 QCOMPARE( bw.hasFocus(), false ); |
|
95 QCOMPARE( bw.hasMouseTracking(), false ); |
|
96 QCOMPARE( bw.isActiveWindow(), false ); |
|
97 QCOMPARE( bw.isEnabled(), true ); |
|
98 QCOMPARE( bw.isFullScreen(), false ); |
|
99 QCOMPARE( bw.isHidden(), false ); |
|
100 QCOMPARE( bw.isMaximized(), false ); |
|
101 QCOMPARE( bw.isMinimized(), false ); |
|
102 QCOMPARE( bw.isModal(), false ); |
|
103 QCOMPARE( bw.isVisible(), true ); |
|
104 QCOMPARE( bw.isWindow(), true ); |
|
105 QCOMPARE( bw.isWindowModified(), false ); |
|
106 QCOMPARE( bw.underMouse(), false ); |
|
107 QCOMPARE( bw.updatesEnabled(), true ); |
|
108 */ |
|
109 bw.hide(); |
|
110 } |
|
111 |
|
112 void autoTest::testBrowser() |
|
113 { |
|
114 BrowserWindow bw; |
|
115 // bw.show(); |
|
116 QWebSettings::globalSettings()->setObjectCacheCapacities(128*1024, 1024*1024, 1024*1024); |
|
117 QWebSettings::globalSettings()->setMaximumPagesInCache(3); |
|
118 |
|
119 bw.showFullScreen(); |
|
120 |
|
121 HomeView *hView = NULL; |
|
122 QList<HomeView *> firstHiew = bw.findChildren<HomeView *>(); |
|
123 if ( firstHiew.count() > 0 ) |
|
124 hView = firstHiew.at(0); |
|
125 else |
|
126 hView = bw.getHomeView(); |
|
127 QVERIFY( !hView ); |
|
128 |
|
129 QTest::qWait(2000); |
|
130 |
|
131 QList<HomeView *> secHiew = bw.findChildren<HomeView *>(); |
|
132 if ( secHiew.count() > 0 ) |
|
133 hView = secHiew.at(0); |
|
134 else |
|
135 hView = bw.getHomeView(); |
|
136 QVERIFY( hView ); |
|
137 |
|
138 BrowserView *bView = NULL; |
|
139 QList<BrowserView *> browView = bw.findChildren<BrowserView *>(); |
|
140 QVERIFY( browView.count() > 0 ); |
|
141 bView = browView.at(0); |
|
142 QVERIFY( bView ); |
|
143 |
|
144 AddressBar *addrBar = NULL; |
|
145 QList<AddressBar *> allBars = hView->findChildren<AddressBar *>(); |
|
146 QVERIFY( allBars.count() > 0 ); |
|
147 addrBar = allBars.at(0); |
|
148 QVERIFY( addrBar ); |
|
149 |
|
150 QLineEdit *addrEdit = NULL; |
|
151 QList<QLineEdit *> allLineEds = addrBar->findChildren<QLineEdit *>(); |
|
152 if ( allLineEds.count() > 0 ) |
|
153 addrEdit = allLineEds.at(0); |
|
154 else |
|
155 addrEdit = addrBar->getLineEdit(); |
|
156 QVERIFY( addrEdit ); |
|
157 |
|
158 QToolButton *goButton = NULL; |
|
159 QList<QToolButton *> aToolBtn = addrBar->findChildren<QToolButton *>(); |
|
160 if ( aToolBtn.count() > 0 ) |
|
161 goButton = aToolBtn.at(0); |
|
162 else |
|
163 goButton = addrBar->getToolButton(); |
|
164 QVERIFY( goButton ); |
|
165 |
|
166 serverThread mojave; |
|
167 mojave.start(); |
|
168 |
|
169 QTest::qWait(2000); |
|
170 |
|
171 |
|
172 // Fill in actual test set... (not much really) |
|
173 // test at least these; |
|
174 // class BookmarksView : public QWidget |
|
175 // try to click these |
|
176 // QPixmap zoomInPixmap; |
|
177 // QPixmap zoomOutPixmap; |
|
178 // QListWidget *m_iconView = new QListWidget(this); |
|
179 // m_toolButton = new QToolButton(parent); |
|
180 // m_toolButton->setText("Go"); |
|
181 |
|
182 QTest::qWait(3000); |
|
183 addrEdit->clear(); |
|
184 addrEdit->setFocus(Qt::OtherFocusReason); |
|
185 QTest::keyClicks( addrEdit, "http://127.0.0.1/index.html" ); |
|
186 addrEdit->clearFocus(); |
|
187 goButton->click(); |
|
188 QTest::qWait(2000); |
|
189 |
|
190 addrEdit->clear(); |
|
191 addrEdit->setFocus(Qt::OtherFocusReason); |
|
192 QTest::keyClicks( addrEdit, "http://www.example.net" ); |
|
193 addrEdit->clearFocus(); |
|
194 goButton->click(); |
|
195 QTest::qWait(3000); |
|
196 |
|
197 if ( mojave.isRunning() ) |
|
198 { |
|
199 mojave.quit(); |
|
200 QFAIL("GET not received by the stub server."); |
|
201 } |
|
202 |
|
203 QTest::qWait(3000); |
|
204 |
|
205 bw.showBrowserView(); |
|
206 QTest::qWait(2000); |
|
207 |
|
208 bw.hide(); |
|
209 QTest::qWait(1000); |
|
210 |
|
211 bw.close(); |
|
212 QTest::qWait(1000); |
|
213 } |