[chromium] move notification related methods to TestRunner
authorjochen@chromium.org <jochen@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 20 Jan 2013 10:50:07 +0000 (10:50 +0000)
committerjochen@chromium.org <jochen@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 20 Jan 2013 10:50:07 +0000 (10:50 +0000)
https://bugs.webkit.org/show_bug.cgi?id=107269

Reviewed by Adam Barth.

* DumpRenderTree/chromium/DRTTestRunner.cpp:
(DRTTestRunner::DRTTestRunner):
* DumpRenderTree/chromium/DRTTestRunner.h:
(DRTTestRunner):
* DumpRenderTree/chromium/TestRunner/public/WebTestDelegate.h:
(WebTestDelegate):
(WebTestRunner::WebTestDelegate::grantWebNotificationPermission):
(WebTestRunner::WebTestDelegate::simulateLegacyWebNotificationClick):
* DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp:
(WebTestRunner::TestRunner::TestRunner):
(WebTestRunner):
(WebTestRunner::TestRunner::grantWebNotificationPermission):
(WebTestRunner::TestRunner::simulateLegacyWebNotificationClick):
* DumpRenderTree/chromium/TestRunner/src/TestRunner.h:
(TestRunner):
* DumpRenderTree/chromium/WebViewHost.cpp:
(WebViewHost::grantWebNotificationPermission):
(WebViewHost::simulateLegacyWebNotificationClick):
* DumpRenderTree/chromium/WebViewHost.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@140271 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/DumpRenderTree/chromium/DRTTestRunner.cpp
Tools/DumpRenderTree/chromium/DRTTestRunner.h
Tools/DumpRenderTree/chromium/TestRunner/public/WebTestDelegate.h
Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp
Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.h
Tools/DumpRenderTree/chromium/WebViewHost.cpp
Tools/DumpRenderTree/chromium/WebViewHost.h

index 8d6441f..96ce041 100644 (file)
@@ -1,5 +1,32 @@
 2013-01-20  Jochen Eisinger  <jochen@chromium.org>
 
+        [chromium] move notification related methods to TestRunner
+        https://bugs.webkit.org/show_bug.cgi?id=107269
+
+        Reviewed by Adam Barth.
+
+        * DumpRenderTree/chromium/DRTTestRunner.cpp:
+        (DRTTestRunner::DRTTestRunner):
+        * DumpRenderTree/chromium/DRTTestRunner.h:
+        (DRTTestRunner):
+        * DumpRenderTree/chromium/TestRunner/public/WebTestDelegate.h:
+        (WebTestDelegate):
+        (WebTestRunner::WebTestDelegate::grantWebNotificationPermission):
+        (WebTestRunner::WebTestDelegate::simulateLegacyWebNotificationClick):
+        * DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp:
+        (WebTestRunner::TestRunner::TestRunner):
+        (WebTestRunner):
+        (WebTestRunner::TestRunner::grantWebNotificationPermission):
+        (WebTestRunner::TestRunner::simulateLegacyWebNotificationClick):
+        * DumpRenderTree/chromium/TestRunner/src/TestRunner.h:
+        (TestRunner):
+        * DumpRenderTree/chromium/WebViewHost.cpp:
+        (WebViewHost::grantWebNotificationPermission):
+        (WebViewHost::simulateLegacyWebNotificationClick):
+        * DumpRenderTree/chromium/WebViewHost.h:
+
+2013-01-20  Jochen Eisinger  <jochen@chromium.org>
+
         [chromium] move geolocation related methods to TestRunner
         https://bugs.webkit.org/show_bug.cgi?id=107267
 
index 283cc34..dbc0b1d 100644 (file)
@@ -48,7 +48,6 @@
 #include "WebIDBFactory.h"
 #include "WebInputElement.h"
 #include "WebKit.h"
-#include "WebNotificationPresenter.h"
 #include "WebPrintParams.h"
 #include "WebScriptSource.h"
 #include "WebSecurityPolicy.h"
@@ -102,9 +101,6 @@ DRTTestRunner::DRTTestRunner(TestShell* shell)
 #endif
     bindMethod("display", &DRTTestRunner::display);
     bindMethod("displayInvalidatedRegion", &DRTTestRunner::displayInvalidatedRegion);
-#if ENABLE(NOTIFICATIONS)
-    bindMethod("grantWebNotificationPermission", &DRTTestRunner::grantWebNotificationPermission);
-#endif
     bindMethod("notifyDone", &DRTTestRunner::notifyDone);
     bindMethod("queueBackNavigation", &DRTTestRunner::queueBackNavigation);
     bindMethod("queueForwardNavigation", &DRTTestRunner::queueForwardNavigation);
@@ -118,9 +114,6 @@ DRTTestRunner::DRTTestRunner(TestShell* shell)
     bindMethod("setWillSendRequestClearHeader", &DRTTestRunner::setWillSendRequestClearHeader);
     bindMethod("setWillSendRequestReturnsNull", &DRTTestRunner::setWillSendRequestReturnsNull);
     bindMethod("setWillSendRequestReturnsNullOnRedirect", &DRTTestRunner::setWillSendRequestReturnsNullOnRedirect);
-#if ENABLE(NOTIFICATIONS)
-    bindMethod("simulateLegacyWebNotificationClick", &DRTTestRunner::simulateLegacyWebNotificationClick);
-#endif
     bindMethod("waitForPolicyDelegate", &DRTTestRunner::waitForPolicyDelegate);
     bindMethod("waitUntilDone", &DRTTestRunner::waitUntilDone);
     bindMethod("windowCount", &DRTTestRunner::windowCount);
@@ -450,35 +443,6 @@ void DRTTestRunner::setWillSendRequestReturnsNull(const CppArgumentList& argumen
     result->setNull();
 }
 
-
-#if ENABLE(NOTIFICATIONS)
-void DRTTestRunner::grantWebNotificationPermission(const CppArgumentList& arguments, CppVariant* result)
-{
-    if (arguments.size() != 1 || !arguments[0].isString()) {
-        result->set(false);
-        return;
-    }
-#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
-    m_shell->notificationPresenter()->grantPermission(cppVariantToWebString(arguments[0]));
-#endif
-    result->set(true);
-}
-
-void DRTTestRunner::simulateLegacyWebNotificationClick(const CppArgumentList& arguments, CppVariant* result)
-{
-    if (arguments.size() != 1 || !arguments[0].isString()) {
-        result->set(false);
-        return;
-    }
-#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
-    if (m_shell->notificationPresenter()->simulateClick(cppVariantToWebString(arguments[0])))
-        result->set(true);
-    else
-#endif
-        result->set(false);
-}
-#endif
-
 void DRTTestRunner::display(const CppArgumentList& arguments, CppVariant* result)
 {
     WebViewHost* host = m_shell->webViewHost();
index eba0b91..3e0ceb9 100644 (file)
@@ -107,13 +107,6 @@ public:
     // Causes WillSendRequest to return an empty request.
     void setWillSendRequestReturnsNull(const CppArgumentList&, CppVariant*);
 
-#if ENABLE(NOTIFICATIONS)
-    // Grants permission for desktop notifications to an origin
-    void grantWebNotificationPermission(const CppArgumentList&, CppVariant*);
-    // Simulates a click on a desktop notification.
-    void simulateLegacyWebNotificationClick(const CppArgumentList&, CppVariant*);
-#endif
-
     void display(const CppArgumentList&, CppVariant*);
     void displayInvalidatedRegion(const CppArgumentList&, CppVariant*);
 
index 531fc8c..6a87fe7 100644 (file)
@@ -103,6 +103,10 @@ public:
     virtual void setGeolocationPermission(bool) { }
     virtual void setMockGeolocationPosition(double, double, double) { }
     virtual void setMockGeolocationPositionUnavailableError(const std::string&) { }
+#if ENABLE(NOTIFICATIONS)
+    virtual void grantWebNotificationPermission(const std::string&) { }
+    virtual bool simulateLegacyWebNotificationClick(const std::string&) { return false; }
+#endif
 };
 
 }
index 9bd7c18..6770177 100644 (file)
@@ -221,6 +221,10 @@ TestRunner::TestRunner()
     bindMethod("setGeolocationPermission", &TestRunner::setGeolocationPermission);
     bindMethod("setMockGeolocationPositionUnavailableError", &TestRunner::setMockGeolocationPositionUnavailableError);
     bindMethod("setMockGeolocationPosition", &TestRunner::setMockGeolocationPosition);
+#if ENABLE(NOTIFICATIONS)
+    bindMethod("grantWebNotificationPermission", &TestRunner::grantWebNotificationPermission);
+    bindMethod("simulateLegacyWebNotificationClick", &TestRunner::simulateLegacyWebNotificationClick);
+#endif
 
     // Properties.
     bindProperty("workerThreadCount", &TestRunner::workerThreadCount);
@@ -1462,6 +1466,27 @@ void TestRunner::setMockGeolocationPositionUnavailableError(const CppArgumentLis
     m_delegate->setMockGeolocationPositionUnavailableError(arguments[0].toString());
 }
 
+#if ENABLE(NOTIFICATIONS)
+void TestRunner::grantWebNotificationPermission(const CppArgumentList& arguments, CppVariant* result)
+{
+    if (arguments.size() != 1 || !arguments[0].isString()) {
+        result->set(false);
+        return;
+    }
+    m_delegate->grantWebNotificationPermission(arguments[0].toString());
+    result->set(true);
+}
+
+void TestRunner::simulateLegacyWebNotificationClick(const CppArgumentList& arguments, CppVariant* result)
+{
+    if (arguments.size() != 1 || !arguments[0].isString()) {
+        result->set(false);
+        return;
+    }
+    result->set(m_delegate->simulateLegacyWebNotificationClick(arguments[0].toString()));
+}
+#endif
+
 void TestRunner::dumpEditingCallbacks(const CppArgumentList&, CppVariant* result)
 {
     m_dumpEditingCallbacks = true;
index 84f1e20..70df4bd 100644 (file)
@@ -376,6 +376,13 @@ private:
     void setMockGeolocationPosition(const CppArgumentList&, CppVariant*);
     void setMockGeolocationPositionUnavailableError(const CppArgumentList&, CppVariant*);
 
+#if ENABLE(NOTIFICATIONS)
+    // Grants permission for desktop notifications to an origin
+    void grantWebNotificationPermission(const CppArgumentList&, CppVariant*);
+    // Simulates a click on a desktop notification.
+    void simulateLegacyWebNotificationClick(const CppArgumentList&, CppVariant*);
+#endif
+
     ///////////////////////////////////////////////////////////////////////////
     // Properties
     void workerThreadCount(CppVariant*);
index e634177..9e4d7aa 100644 (file)
@@ -1171,6 +1171,18 @@ void WebViewHost::setMockGeolocationPositionUnavailableError(const std::string&
         windowList[i]->geolocationClientMock()->setPositionUnavailableError(WebString::fromUTF8(message));
 }
 
+#if ENABLE(NOTIFICATIONS)
+void WebViewHost::grantWebNotificationPermission(const std::string& origin)
+{
+    m_shell->notificationPresenter()->grantPermission(WebString::fromUTF8(origin));
+}
+
+bool WebViewHost::simulateLegacyWebNotificationClick(const std::string& notificationIdentifier)
+{
+    return m_shell->notificationPresenter()->simulateClick(WebString::fromUTF8(notificationIdentifier));
+}
+#endif
+
 // Public functions -----------------------------------------------------------
 
 WebViewHost::WebViewHost(TestShell* shell)
index 58edadf..1b71508 100644 (file)
@@ -164,6 +164,10 @@ class WebViewHost : public WebKit::WebViewClient, public WebKit::WebFrameClient,
     virtual void setGeolocationPermission(bool) OVERRIDE;
     virtual void setMockGeolocationPosition(double, double, double) OVERRIDE;
     virtual void setMockGeolocationPositionUnavailableError(const std::string&) OVERRIDE;
+#if ENABLE(NOTIFICATIONS)
+    virtual void grantWebNotificationPermission(const std::string&) OVERRIDE;
+    virtual bool simulateLegacyWebNotificationClick(const std::string&) OVERRIDE;
+#endif
 
     // NavigationHost
     virtual bool navigate(const TestNavigationEntry&, bool reload);