1/*
2 * Copyright (C) 2009 Holger Hans Peter Freyther
3 *
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.
8 *
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.
13 *
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.
18 */
19
20#ifndef QT_NO_BEARERMANAGEMENT
21#include <QNetworkConfigurationManager>
22#endif
23
24#include <QtTest/QtTest>
25
26#include <qwebframe.h>
27#include <qwebview.h>
28#include <qpainter.h>
29
30#include "util.h"
31
32class tst_Loading : public QObject
33{
34    Q_OBJECT
35
36public:
37
38public Q_SLOTS:
39    void init();
40    void cleanup();
41
42private Q_SLOTS:
43    void load_data();
44    void load();
45
46private:
47#ifndef QT_NO_BEARERMANAGEMENT
48    QNetworkConfigurationManager m_manager;
49#endif
50    QWebView* m_view;
51    QWebPage* m_page;
52};
53
54void tst_Loading::init()
55{
56    m_view = new QWebView;
57    m_page = m_view->page();
58
59    QSize viewportSize(1024, 768);
60    m_view->setFixedSize(viewportSize);
61    m_page->setViewportSize(viewportSize);
62}
63
64void tst_Loading::cleanup()
65{
66    delete m_view;
67}
68
69void tst_Loading::load_data()
70{
71    QTest::addColumn<QUrl>("url");
72    QTest::newRow("amazon") << QUrl("http://www.amazon.com");
73    QTest::newRow("kde") << QUrl("http://www.kde.org");
74    QTest::newRow("apple") << QUrl("http://www.apple.com");
75}
76
77void tst_Loading::load()
78{
79    QFETCH(QUrl, url);
80
81#ifndef QT_NO_BEARERMANAGEMENT
82    if (!m_manager.isOnline())
83        W_QSKIP("This test requires an active network connection", SkipSingle);
84#endif
85
86    QBENCHMARK {
87        m_view->load(url);
88
89        // really wait for loading, painting is in another test
90        ::waitForSignal(m_view, SIGNAL(loadFinished(bool)), 0);
91    }
92}
93
94QTEST_MAIN(tst_Loading)
95#include "tst_loading.moc"
96