1 /* 2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> 3 * Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of 15 * its contributors may be used to endorse or promote products derived 16 * from this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 30 #ifndef DUMPRENDERTREE_H 31 #define DUMPRENDERTREE_H 32 33 #include <QList> 34 #include <QObject> 35 #include <QTextStream> 36 #include <QSocketNotifier> 37 38 QT_BEGIN_NAMESPACE 39 class QUrl; 40 class QFile; 41 QT_END_NAMESPACE 42 class QWebPage; 43 class QWebFrame; 44 45 class LayoutTestController; 46 class EventSender; 47 class TextInputController; 48 class GCController; 49 50 namespace WebCore { 51 52 class DumpRenderTree : public QObject { 53 Q_OBJECT 54 55 public: 56 DumpRenderTree(); 57 virtual ~DumpRenderTree(); 58 59 // Initialize in multi-file mode, used by run-webkit-tests. 60 void open(); 61 62 // Initialize in single-file mode. 63 void open(const QUrl& url); 64 65 void setDumpPixels(bool); 66 67 void closeRemainingWindows(); 68 void resetToConsistentStateBeforeTesting(); 69 layoutTestController()70 LayoutTestController *layoutTestController() const { return m_controller; } eventSender()71 EventSender *eventSender() const { return m_eventSender; } textInputController()72 TextInputController *textInputController() const { return m_textInputController; } 73 74 QWebPage *createWindow(); 75 int windowCount() const; 76 webPage()77 QWebPage *webPage() const { return m_page; } 78 79 80 #if defined(Q_WS_X11) 81 static void initializeFonts(); 82 #endif 83 84 public Q_SLOTS: 85 void initJSObjects(); 86 void readStdin(int); 87 void dump(); 88 void titleChanged(const QString &s); 89 void connectFrame(QWebFrame *frame); 90 void dumpDatabaseQuota(QWebFrame* frame, const QString& dbName); 91 92 Q_SIGNALS: 93 void quit(); 94 95 private: 96 QString dumpFramesAsText(QWebFrame* frame); 97 QString dumpBackForwardList(); 98 LayoutTestController *m_controller; 99 100 bool m_dumpPixels; 101 QString m_expectedHash; 102 103 QWebPage *m_page; 104 105 EventSender *m_eventSender; 106 TextInputController *m_textInputController; 107 GCController* m_gcController; 108 109 QFile *m_stdin; 110 QSocketNotifier* m_notifier; 111 112 QList<QWidget *> windows; 113 }; 114 115 } 116 117 #endif 118