2 * Copyright (C) 2009 Holger Hans Peter Freyther
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
20 #include <QtTest/QtTest>
22 #include "common_init.h"
24 #include <qwebframe.h>
29 * Starts an event loop that runs until the given signal is received.
30 Optionally the event loop
31 * can return earlier on a timeout.
33 * \return \p true if the requested signal was received
36 static bool waitForSignal(QObject* obj, const char* signal, int timeout = 0)
39 QObject::connect(obj, signal, &loop, SLOT(quit()));
41 QSignalSpy timeoutSpy(&timer, SIGNAL(timeout()));
43 QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
44 timer.setSingleShot(true);
48 return timeoutSpy.isEmpty();
51 class tst_Loading : public QObject
69 void tst_Loading::init()
71 QWebSettings::globalSettings()->setMaximumPagesInCache(0);
72 QWebSettings::globalSettings()->setObjectCacheCapacities(0, 0, 0);
74 m_view = new QWebView;
75 m_page = m_view->page();
77 QSize viewportSize(1024, 768);
78 m_view->setFixedSize(viewportSize);
79 m_page->setViewportSize(viewportSize);
81 // this makes us different to the loading test...
85 void tst_Loading::cleanup()
90 void tst_Loading::load()
92 const QList<QUrl> urls = test_urls();
95 foreach(const QUrl& url, urls) {
97 // really wait for loading..
98 ::waitForSignal(m_view, SIGNAL(loadFinished(bool)));
101 m_view->load(QUrl("about:blank"));
102 QWebSettings::clearMemoryCaches();
106 QTEST_MAIN(tst_Loading)
107 #include "tst_cycler.moc"