TestRunnerQt.h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. /*
  2. * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
  3. * Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/
  4. * Copyright (C) 2012 Apple Inc. All Rights Reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
  16. * its contributors may be used to endorse or promote products derived
  17. * from this software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
  20. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  21. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  22. * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
  23. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  24. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  25. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  26. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  28. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. #ifndef TestRunnerQt_h
  31. #define TestRunnerQt_h
  32. #include <QBasicTimer>
  33. #include <QObject>
  34. #include <QSize>
  35. #include <QString>
  36. #include <QTimer>
  37. #include <QTimerEvent>
  38. #include <QVariant>
  39. #include <QtDebug>
  40. #include <qwebdatabase.h>
  41. #include <qwebelement.h>
  42. #include <qwebframe.h>
  43. #include <qwebhistory.h>
  44. #include <qwebpage.h>
  45. #include <qwebsecurityorigin.h>
  46. class QWebFrame;
  47. class DumpRenderTreeSupportQt;
  48. class DumpRenderTree;
  49. class TestRunnerQt : public QObject {
  50. Q_OBJECT
  51. Q_PROPERTY(int webHistoryItemCount READ webHistoryItemCount)
  52. Q_PROPERTY(bool globalFlag READ globalFlag WRITE setGlobalFlag)
  53. public:
  54. TestRunnerQt(DumpRenderTree*);
  55. bool shouldDumpAsAudio() const { return m_audioDump; }
  56. bool shouldWaitUntilDone() const { return m_waitForDone; }
  57. bool shouldHandleErrorPages() const { return m_handleErrorPages; }
  58. bool waitForPolicy() const { return m_waitForPolicy; }
  59. bool ignoreReqestForPermission() const { return m_ignoreDesktopNotification; }
  60. const QByteArray& audioData() const { return m_audioData; }
  61. void reset();
  62. void setTimeout(int timeout) { m_timeout = timeout; }
  63. void setShouldTimeout(bool flag) { m_shouldTimeout = flag; }
  64. protected:
  65. void timerEvent(QTimerEvent*);
  66. Q_SIGNALS:
  67. void done();
  68. void showPage();
  69. void hidePage();
  70. void geolocationPermissionSet();
  71. public Q_SLOTS:
  72. void maybeDump(bool ok);
  73. void dumpNotifications();
  74. void waitUntilDone();
  75. int webHistoryItemCount();
  76. void keepWebHistory();
  77. void notifyDone();
  78. bool globalFlag() const { return m_globalFlag; }
  79. void setGlobalFlag(bool flag) { m_globalFlag = flag; }
  80. void handleErrorPages() { m_handleErrorPages = true; }
  81. void dumpEditingCallbacks();
  82. void dumpFrameLoadCallbacks();
  83. void dumpProgressFinishedCallback();
  84. void dumpUserGestureInFrameLoadCallbacks();
  85. void dumpResourceLoadCallbacks();
  86. void dumpResourceResponseMIMETypes();
  87. void dumpWillCacheResponse();
  88. void dumpHistoryCallbacks();
  89. void setWillSendRequestReturnsNullOnRedirect(bool enabled);
  90. void setWillSendRequestReturnsNull(bool enabled);
  91. void setWillSendRequestClearHeader(const QStringList& headers);
  92. void queueBackNavigation(int howFarBackward);
  93. void queueForwardNavigation(int howFarForward);
  94. void queueLoadHTMLString(const QString& content, const QString& baseURL = QString(), const QString& failingURL = QString());
  95. void queueReload();
  96. void queueLoadingScript(const QString& script);
  97. void queueNonLoadingScript(const QString& script);
  98. void provisionalLoad();
  99. int windowCount();
  100. void ignoreLegacyWebNotificationPermissionRequests();
  101. void simulateLegacyWebNotificationClick(const QString& title);
  102. void grantWebNotificationPermission(const QString& origin);
  103. void denyWebNotificationPermission(const QString& origin);
  104. void removeAllWebNotificationPermissions();
  105. void display();
  106. void displayInvalidatedRegion();
  107. void clearBackForwardList();
  108. QString pathToLocalResource(const QString& url);
  109. QString encodeHostName(const QString& host);
  110. QString decodeHostName(const QString& host);
  111. void dumpSelectionRect() const { }
  112. void setDeveloperExtrasEnabled(bool);
  113. void showWebInspector();
  114. void closeWebInspector();
  115. void evaluateInWebInspector(long callId, const QString& script);
  116. void removeAllVisitedLinks();
  117. void setAllowUniversalAccessFromFileURLs(bool enable);
  118. void setAllowFileAccessFromFileURLs(bool enable);
  119. void setAppCacheMaximumSize(unsigned long long quota);
  120. void setValueForUser(const QWebElement&, const QString& value);
  121. void setFixedContentsSize(int width, int height);
  122. void setPrivateBrowsingEnabled(bool);
  123. void setSpatialNavigationEnabled(bool);
  124. void setPopupBlockingEnabled(bool);
  125. void setPOSIXLocale(const QString& locale);
  126. void resetLoadFinished() { m_loadFinished = false; }
  127. void setWindowIsKey(bool);
  128. void setDeferMainResourceDataLoad(bool);
  129. void setJavaScriptCanAccessClipboard(bool enable);
  130. void setXSSAuditorEnabled(bool);
  131. void setCaretBrowsingEnabled(bool);
  132. void setAuthorAndUserStylesEnabled(bool);
  133. void setViewModeMediaFeature(const QString& mode);
  134. void execCommand(const QString& name, const QString& value = QString());
  135. bool isCommandEnabled(const QString& name) const;
  136. void addOriginAccessWhitelistEntry(const QString& sourceOrigin, const QString& destinationProtocol, const QString& destinationHost, bool allowDestinationSubdomains);
  137. void removeOriginAccessWhitelistEntry(const QString& sourceOrigin, const QString& destinationProtocol, const QString& destinationHost, bool allowDestinationSubdomains);
  138. void clearAllApplicationCaches();
  139. void setApplicationCacheOriginQuota(unsigned long long);
  140. QStringList originsWithApplicationCache();
  141. void setDatabaseQuota(int size);
  142. void clearAllDatabases();
  143. void setIconDatabaseEnabled(bool);
  144. void setCustomPolicyDelegate(bool enabled, bool permissive = false);
  145. void waitForPolicyDelegate();
  146. void overridePreference(const QString& name, const QVariant& value);
  147. void setUserStyleSheetLocation(const QString& url);
  148. void setUserStyleSheetEnabled(bool);
  149. void setDomainRelaxationForbiddenForURLScheme(bool forbidden, const QString& scheme);
  150. bool callShouldCloseOnWebView();
  151. void setMockDeviceOrientation(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma);
  152. void setMockGeolocationPositionUnavailableError(const QString& message);
  153. void setMockGeolocationPosition(double latitude, double longitude, double accuracy);
  154. void setGeolocationPermission(bool allow);
  155. int numberOfPendingGeolocationPermissionRequests();
  156. bool isGeolocationPermissionSet() const { return m_isGeolocationPermissionSet; }
  157. bool geolocationPermission() const { return m_geolocationPermission; }
  158. void addURLToRedirect(const QString& origin, const QString& destination);
  159. /*
  160. Policy values: 'on', 'auto' or 'off'.
  161. Orientation values: 'vertical' or 'horizontal'.
  162. */
  163. void setScrollbarPolicy(const QString& orientation, const QString& policy);
  164. void setAlwaysAcceptCookies(bool);
  165. void setAlwaysBlockCookies(bool);
  166. void setAudioResult(const QByteArray&);
  167. private Q_SLOTS:
  168. void processWork();
  169. private:
  170. void setGeolocationPermissionCommon(bool allow);
  171. private:
  172. bool m_hasDumped;
  173. bool m_audioDump;
  174. bool m_disallowIncreaseForApplicationCacheQuota;
  175. bool m_canOpenWindows;
  176. bool m_waitForDone;
  177. bool m_waitForPolicy;
  178. bool m_handleErrorPages;
  179. bool m_loadFinished;
  180. bool m_globalFlag;
  181. bool m_userStyleSheetEnabled;
  182. bool m_isGeolocationPermissionSet;
  183. bool m_geolocationPermission;
  184. QUrl m_userStyleSheetLocation;
  185. QBasicTimer m_timeoutTimer;
  186. QWebFrame* m_topLoadingFrame;
  187. DumpRenderTree* m_drt;
  188. QWebHistory* m_webHistory;
  189. bool m_ignoreDesktopNotification;
  190. QByteArray m_audioData;
  191. bool m_shouldTimeout;
  192. int m_timeout;
  193. };
  194. #endif // TestRunnerQt_h