[Chromium] TestInterfaces should be responsible for owning and binding AccessibilityC...
authorabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Jul 2012 09:09:57 +0000 (09:09 +0000)
committerabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Jul 2012 09:09:57 +0000 (09:09 +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@122828 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 6d6af26..7ceb6bc 100644 (file)
@@ -1,5 +1,37 @@
 2012-07-17  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-17  Adam Barth  <abarth@webkit.org>
+
         [Chromium] Move TextInputController into TestRunner.a
         https://bugs.webkit.org/show_bug.cgi?id=91457
 
index 5cfb2c2..032b979 100644 (file)
 #include "config.h"
 #include "TestInterfaces.h"
 
+#include "AccessibilityController.h"
 #include "GamepadController.h"
+#include "TextInputController.h"
 #include "platform/WebString.h"
 
 using WebKit::WebFrame;
 using WebKit::WebString;
+using WebKit::WebView;
 
 TestInterfaces::TestInterfaces()
 {
+    m_accessibilityController = adoptPtr(new AccessibilityController());
     m_gamepadController = adoptPtr(new GamepadController());
+    m_textInputController = adoptPtr(new TextInputController());
 }
 
 TestInterfaces::~TestInterfaces()
 {
+    m_accessibilityController->setWebView(0);
+    // m_gamepadController doesn't depend on WebView.
+    m_textInputController->setWebView(0);
 }
 
+void TestInterfaces::setWebView(WebView* webView)
+{
+    m_accessibilityController->setWebView(webView);
+    // m_gamepadController doesn't depend on WebView.
+    m_textInputController->setWebView(webView);
+}
+
+
 void TestInterfaces::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::resetAll()
 {
+    m_accessibilityController->reset();
     m_gamepadController->reset();
+    // m_textInputController doesn't have any state to reset.
 }
index e2404ad..f96693b 100644 (file)
 
 namespace WebKit {
 class WebFrame;
+class WebView;
 }
 
+class AccessibilityController;
 class GamepadController;
+class TextInputController;
 
 class TestInterfaces {
 public:
     TestInterfaces();
     ~TestInterfaces();
 
+    void setWebView(WebKit::WebView*);
+
     void bindTo(WebKit::WebFrame*);
     void resetAll();
 
+    AccessibilityController* accessibilityController() { return m_accessibilityController.get(); }
+
 private:
+    OwnPtr<AccessibilityController> m_accessibilityController;
     OwnPtr<GamepadController> m_gamepadController;
+    OwnPtr<TextInputController> m_textInputController;
 };
 
 #endif // TestInterfaces_h
index 0b65896..640bfee 100644 (file)
@@ -146,11 +146,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
@@ -175,15 +173,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.clear();
     m_drtDevToolsAgent->setWebView(0);
 }
 
@@ -294,7 +290,6 @@ void TestShell::resetTestController()
 {
     resetWebSettings(*webView());
     m_webPermissions->reset();
-    m_accessibilityController->reset();
     m_testInterfaces->resetAll();
     m_layoutTestController->reset();
     m_eventSender->reset();
@@ -728,12 +723,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 10d1ed3..aee3065 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>
@@ -95,7 +94,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
@@ -215,11 +214,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