[Chromium] TestInterfaces should be responsible for owning and binding AccessibilityC...
authorabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Jul 2012 21:24:22 +0000 (21:24 +0000)
committerabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Jul 2012 21:24:22 +0000 (21:24 +0000)
https://bugs.webkit.org/show_bug.cgi?id=91459

Reviewed by Ryosuke Niwa.

Rather than having TestShell own and bind each of these JavaScript APIs
individually, TestShell should delegate that work to TestInterfaces.
This patch moves AccessibilityController and TextInputController to be
the responsibility of TestInterfaces.

* DumpRenderTree/chromium/TestRunner/TestInterfaces.cpp:
(TestInterfaces::TestInterfaces):
(TestInterfaces::~TestInterfaces):
(TestInterfaces::setWebView):
(TestInterfaces::bindTo):
(TestInterfaces::resetAll):
* DumpRenderTree/chromium/TestRunner/TestInterfaces.h:
(WebKit):
(TestInterfaces):
(TestInterfaces::accessibilityController):
* DumpRenderTree/chromium/TestShell.cpp:
(TestShell::initialize):
(TestShell::createMainWindow):
(TestShell::~TestShell):
(TestShell::resetTestController):
(TestShell::bindJSObjectsToWindow):
* DumpRenderTree/chromium/TestShell.h:
(TestShell::accessibilityController):
(TestShell):

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

Tools/ChangeLog
Tools/DumpRenderTree/chromium/TestRunner/TestInterfaces.cpp
Tools/DumpRenderTree/chromium/TestRunner/TestInterfaces.h
Tools/DumpRenderTree/chromium/TestShell.cpp
Tools/DumpRenderTree/chromium/TestShell.h

index 1b94537..a4e3357 100644 (file)
@@ -1,3 +1,35 @@
+2012-07-23  Adam Barth  <abarth@webkit.org>
+
+        [Chromium] TestInterfaces should be responsible for owning and binding AccessibilityController and TextInputController
+        https://bugs.webkit.org/show_bug.cgi?id=91459
+
+        Reviewed by Ryosuke Niwa.
+
+        Rather than having TestShell own and bind each of these JavaScript APIs
+        individually, TestShell should delegate that work to TestInterfaces.
+        This patch moves AccessibilityController and TextInputController to be
+        the responsibility of TestInterfaces.
+
+        * DumpRenderTree/chromium/TestRunner/TestInterfaces.cpp:
+        (TestInterfaces::TestInterfaces):
+        (TestInterfaces::~TestInterfaces):
+        (TestInterfaces::setWebView):
+        (TestInterfaces::bindTo):
+        (TestInterfaces::resetAll):
+        * DumpRenderTree/chromium/TestRunner/TestInterfaces.h:
+        (WebKit):
+        (TestInterfaces):
+        (TestInterfaces::accessibilityController):
+        * DumpRenderTree/chromium/TestShell.cpp:
+        (TestShell::initialize):
+        (TestShell::createMainWindow):
+        (TestShell::~TestShell):
+        (TestShell::resetTestController):
+        (TestShell::bindJSObjectsToWindow):
+        * DumpRenderTree/chromium/TestShell.h:
+        (TestShell::accessibilityController):
+        (TestShell):
+
 2012-07-23  Balazs Kelemen  <kbalazs@webkit.org>
 
         nrwt swallows early exceptions
index c0d532a..b7c85ed 100644 (file)
 #include "config.h"
 #include "TestInterfaces.h"
 
+#include "AccessibilityController.h"
 #include "GamepadController.h"
+#include "TextInputController.h"
 #include "platform/WebString.h"
 
 #include <wtf/OwnPtr.h>
 
 using WebKit::WebFrame;
 using WebKit::WebString;
+using WebKit::WebView;
 
 class TestInterfaces::Internal {
 public:
     Internal();
     ~Internal();
 
+    void setWebView(WebView* webView);
     void bindTo(WebFrame*);
     void resetAll();
 
+    AccessibilityController* accessibilityController() { return m_accessibilityController.get(); }
+
 private:
+    OwnPtr<AccessibilityController> m_accessibilityController;
     OwnPtr<GamepadController> m_gamepadController;
+    OwnPtr<TextInputController> m_textInputController;
 };
 
 TestInterfaces::Internal::Internal()
 {
+    m_accessibilityController = adoptPtr(new AccessibilityController());
     m_gamepadController = adoptPtr(new GamepadController());
+    m_textInputController = adoptPtr(new TextInputController());
 }
 
 TestInterfaces::Internal::~Internal()
 {
+    m_accessibilityController->setWebView(0);
+    // m_gamepadController doesn't depend on WebView.
+    m_textInputController->setWebView(0);
+}
+
+void TestInterfaces::Internal::setWebView(WebView* webView)
+{
+    m_accessibilityController->setWebView(webView);
+    // m_gamepadController doesn't depend on WebView.
+    m_textInputController->setWebView(webView);
 }
 
 void TestInterfaces::Internal::bindTo(WebFrame* frame)
 {
+    m_accessibilityController->bindToJavascript(frame, WebString::fromUTF8("accessibilityController"));
     m_gamepadController->bindToJavascript(frame, WebString::fromUTF8("gamepadController"));
+    m_textInputController->bindToJavascript(frame, WebString::fromUTF8("textInputController"));
 }
 
 void TestInterfaces::Internal::resetAll()
 {
+    m_accessibilityController->reset();
     m_gamepadController->reset();
+    // m_textInputController doesn't have any state to reset.
 }
 
 TestInterfaces::TestInterfaces()
@@ -80,6 +104,11 @@ TestInterfaces::~TestInterfaces()
     delete m_internal;
 }
 
+void TestInterfaces::setWebView(WebView* webView)
+{
+    m_internal->setWebView(webView);
+}
+
 void TestInterfaces::bindTo(WebFrame* frame)
 {
     m_internal->bindTo(frame);
@@ -89,3 +118,8 @@ void TestInterfaces::resetAll()
 {
     m_internal->resetAll();
 }
+
+AccessibilityController* TestInterfaces::accessibilityController()
+{
+    return m_internal->accessibilityController();
+}
index 16ed5a6..304434f 100644 (file)
 
 namespace WebKit {
 class WebFrame;
+class WebView;
 }
 
+class AccessibilityController;
+
 class TestInterfaces {
 public:
     TestInterfaces();
     ~TestInterfaces();
 
+    void setWebView(WebKit::WebView* webView);
     void bindTo(WebKit::WebFrame*);
     void resetAll();
 
+    AccessibilityController* accessibilityController();
+
 private:
     class Internal;
     Internal* m_internal;
index b4142ea..7ebb5ae 100644 (file)
@@ -145,11 +145,9 @@ TestShell::TestShell()
 void TestShell::initialize()
 {
     m_webPermissions = adoptPtr(new WebPermissions(this));
-    m_accessibilityController = adoptPtr(new AccessibilityController());
     m_testInterfaces = adoptPtr(new TestInterfaces());
     m_layoutTestController = adoptPtr(new LayoutTestController(this));
     m_eventSender = adoptPtr(new EventSender(this));
-    m_textInputController = adoptPtr(new TextInputController());
 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
     m_notificationPresenter = adoptPtr(new NotificationPresenter(this));
 #endif
@@ -173,15 +171,13 @@ void TestShell::createMainWindow()
     m_drtDevToolsAgent = adoptPtr(new DRTDevToolsAgent);
     m_webViewHost = adoptPtr(createNewWindow(WebURL(), m_drtDevToolsAgent.get()));
     m_webView = m_webViewHost->webView();
-    m_accessibilityController->setWebView(m_webView);
-    m_textInputController->setWebView(m_webView);
+    m_testInterfaces->setWebView(m_webView);
     m_drtDevToolsAgent->setWebView(m_webView);
 }
 
 TestShell::~TestShell()
 {
-    m_accessibilityController->setWebView(0);
-    m_textInputController->setWebView(0);
+    m_testInterfaces->setWebView(0);
     m_drtDevToolsAgent->setWebView(0);
 }
 
@@ -292,7 +288,6 @@ void TestShell::resetTestController()
 {
     resetWebSettings(*webView());
     m_webPermissions->reset();
-    m_accessibilityController->reset();
     m_testInterfaces->resetAll();
     m_layoutTestController->reset();
     m_eventSender->reset();
@@ -721,12 +716,10 @@ void TestShell::dumpImage(SkCanvas* canvas) const
 void TestShell::bindJSObjectsToWindow(WebFrame* frame)
 {
     WebTestingSupport::injectInternalsObject(frame);
-    m_accessibilityController->bindToJavascript(frame, WebString::fromUTF8("accessibilityController"));
     m_testInterfaces->bindTo(frame);
     m_layoutTestController->bindToJavascript(frame, WebString::fromUTF8("layoutTestController"));
     m_layoutTestController->bindToJavascript(frame, WebString::fromUTF8("testRunner"));
     m_eventSender->bindToJavascript(frame, WebString::fromUTF8("eventSender"));
-    m_textInputController->bindToJavascript(frame, WebString::fromUTF8("textInputController"));
 }
 
 WebViewHost* TestShell::createNewWindow(const WebKit::WebURL& url)
index 7ea5790..0778163 100644 (file)
@@ -38,7 +38,6 @@
 #include "NotificationPresenter.h"
 #include "TestEventPrinter.h"
 #include "TestInterfaces.h"
-#include "TextInputController.h"
 #include "WebPreferences.h"
 #include "WebViewHost.h"
 #include <string>
@@ -93,7 +92,7 @@ public:
     WebViewHost* webViewHost() const { return m_webViewHost.get(); }
     LayoutTestController* layoutTestController() const { return m_layoutTestController.get(); }
     EventSender* eventSender() const { return m_eventSender.get(); }
-    AccessibilityController* accessibilityController() const { return m_accessibilityController.get(); }
+    AccessibilityController* accessibilityController() const { return m_testInterfaces->accessibilityController(); }
 #if ENABLE(NOTIFICATIONS)
     NotificationPresenter* notificationPresenter() const { return m_notificationPresenter.get(); }
 #endif
@@ -214,11 +213,9 @@ private:
     OwnPtr<WebPermissions> m_webPermissions;
     OwnPtr<DRTDevToolsAgent> m_drtDevToolsAgent;
     OwnPtr<DRTDevToolsClient> m_drtDevToolsClient;
-    OwnPtr<AccessibilityController> m_accessibilityController;
     OwnPtr<TestInterfaces> m_testInterfaces;
     OwnPtr<EventSender> m_eventSender;
     OwnPtr<LayoutTestController> m_layoutTestController;
-    OwnPtr<TextInputController> m_textInputController;
 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
     OwnPtr<NotificationPresenter> m_notificationPresenter;
 #endif