initial import
[vuplus_webkit] / Source / WebKit2 / UIProcess / API / qt / tests / qtouchwebview / tst_qtouchwebview.cpp
1 /*
2     Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
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 #include <QAction>
21 #include <QtTest/QtTest>
22 #include <qtouchwebpage.h>
23 #include <qtouchwebview.h>
24 #include <qwebnavigationcontroller.h>
25 #include "../testwindow.h"
26 #include "../util.h"
27
28 Q_DECLARE_METATYPE(QTouchWebPage*);
29
30 class tst_QTouchWebView : public QObject {
31     Q_OBJECT
32 public:
33     tst_QTouchWebView();
34 private slots:
35     void init();
36     void cleanup();
37
38     void accessPage();
39     void navigationActionsStatusAtStartup();
40
41 private:
42     inline QTouchWebView* webView() const;
43     QScopedPointer<TestWindow> m_window;
44 };
45
46 tst_QTouchWebView::tst_QTouchWebView()
47 {
48     addQtWebProcessToPath();
49     qRegisterMetaType<QTouchWebPage*>("QTouchWebPage*");
50 }
51
52 void tst_QTouchWebView::init()
53 {
54     m_window.reset(new TestWindow(new QTouchWebView));
55 }
56
57 void tst_QTouchWebView::cleanup()
58 {
59     m_window.reset();
60 }
61
62 inline QTouchWebView* tst_QTouchWebView::webView() const
63 {
64     return static_cast<QTouchWebView*>(m_window->webView.data());
65 }
66
67 void tst_QTouchWebView::accessPage()
68 {
69     QTouchWebPage* const pageDirectAccess = webView()->page();
70
71     QVariant pagePropertyValue = webView()->property("page");
72     QTouchWebPage* const pagePropertyAccess = pagePropertyValue.value<QTouchWebPage*>();
73     QCOMPARE(pagePropertyAccess, pageDirectAccess);
74 }
75
76 void tst_QTouchWebView::navigationActionsStatusAtStartup()
77 {
78     QAction* backAction = webView()->page()->navigationController()->backAction();
79     QVERIFY(backAction);
80     QCOMPARE(backAction->isEnabled(), false);
81
82     QAction* forwardAction = webView()->page()->navigationController()->forwardAction();
83     QVERIFY(forwardAction);
84     QCOMPARE(forwardAction->isEnabled(), false);
85
86     QAction* stopAction = webView()->page()->navigationController()->stopAction();
87     QVERIFY(stopAction);
88     QCOMPARE(stopAction->isEnabled(), false);
89
90     QAction* reloadAction = webView()->page()->navigationController()->reloadAction();
91     QVERIFY(reloadAction);
92     QCOMPARE(reloadAction->isEnabled(), false);
93 }
94
95
96 QTEST_MAIN(tst_QTouchWebView)
97
98 #include "tst_qtouchwebview.moc"
99