| Index: trunk/Source/web/tests/WebViewTest.cpp
|
| ===================================================================
|
| --- trunk/Source/web/tests/WebViewTest.cpp (revision 177995)
|
| +++ trunk/Source/web/tests/WebViewTest.cpp (working copy)
|
| @@ -33,7 +33,6 @@
|
|
|
| #include "core/dom/Document.h"
|
| #include "core/dom/Element.h"
|
| -#include "core/frame/EventHandlerRegistry.h"
|
| #include "core/frame/FrameView.h"
|
| #include "core/frame/LocalFrame.h"
|
| #include "core/frame/Settings.h"
|
| @@ -1679,17 +1678,15 @@
|
| int m_hasTouchEventHandlerCount[2];
|
| };
|
|
|
| -// This test verifies that WebWidgetClient::hasTouchEventHandlers is called
|
| -// accordingly for various calls to EventHandlerRegistry::did{Add|Remove|
|
| -// RemoveAll}EventHandler(..., TouchEvent). Verifying that those calls are made
|
| -// correctly is the job of LayoutTests/fast/events/event-handler-count.html.
|
| +// This test verifies that WebWidgetClient::hasTouchEventHandlers is called accordingly for various
|
| +// calls to Document::did{Add|Remove|Clear}TouchEventHandler. Verifying that those calls are made
|
| +// correctly is the job of LayoutTests/fast/events/touch/touch-handler-count.html.
|
| TEST_F(WebViewTest, HasTouchEventHandlers)
|
| {
|
| TouchEventHandlerWebViewClient client;
|
| std::string url = m_baseURL + "has_touch_event_handlers.html";
|
| URLTestHelpers::registerMockedURLLoad(toKURL(url), "has_touch_event_handlers.html");
|
| WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(url, true, 0, &client);
|
| - const WebCore::EventHandlerRegistry::EventHandlerClass touchEvent = WebCore::EventHandlerRegistry::TouchEvent;
|
|
|
| // The page is initialized with at least one no-handlers call.
|
| // In practice we get two such calls because WebViewHelper::initializeAndLoad first
|
| @@ -1700,56 +1697,55 @@
|
|
|
| // Adding the first document handler results in a has-handlers call.
|
| WebCore::Document* document = webViewImpl->mainFrameImpl()->frame()->document();
|
| - WebCore::EventHandlerRegistry* registry = &document->frameHost()->eventHandlerRegistry();
|
| - registry->didAddEventHandler(*document, touchEvent);
|
| + document->didAddTouchEventHandler(document);
|
| EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false));
|
| EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(true));
|
|
|
| // Adding another handler has no effect.
|
| - registry->didAddEventHandler(*document, touchEvent);
|
| + document->didAddTouchEventHandler(document);
|
| EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false));
|
| EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true));
|
|
|
| // Removing the duplicate handler has no effect.
|
| - registry->didRemoveEventHandler(*document, touchEvent);
|
| + document->didRemoveTouchEventHandler(document);
|
| EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false));
|
| EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true));
|
|
|
| // Removing the final handler results in a no-handlers call.
|
| - registry->didRemoveEventHandler(*document, touchEvent);
|
| + document->didRemoveTouchEventHandler(document);
|
| EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(false));
|
| EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true));
|
|
|
| // Adding a handler on a div results in a has-handlers call.
|
| WebCore::Element* parentDiv = document->getElementById("parentdiv");
|
| ASSERT(parentDiv);
|
| - registry->didAddEventHandler(*parentDiv, touchEvent);
|
| + document->didAddTouchEventHandler(parentDiv);
|
| EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false));
|
| EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(true));
|
|
|
| // Adding a duplicate handler on the div, clearing all document handlers
|
| // (of which there are none) and removing the extra handler on the div
|
| // all have no effect.
|
| - registry->didAddEventHandler(*parentDiv, touchEvent);
|
| - registry->didRemoveAllEventHandlers(*document);
|
| - registry->didRemoveEventHandler(*parentDiv, touchEvent);
|
| + document->didAddTouchEventHandler(parentDiv);
|
| + document->didClearTouchEventHandlers(document);
|
| + document->didRemoveTouchEventHandler(parentDiv);
|
| EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false));
|
| EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true));
|
|
|
| // Removing the final handler on the div results in a no-handlers call.
|
| - registry->didRemoveEventHandler(*parentDiv, touchEvent);
|
| + document->didRemoveTouchEventHandler(parentDiv);
|
| EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(false));
|
| EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true));
|
|
|
| // Adding two handlers then clearing them in a single call results in a
|
| // has-handlers then no-handlers call.
|
| - registry->didAddEventHandler(*parentDiv, touchEvent);
|
| + document->didAddTouchEventHandler(parentDiv);
|
| EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false));
|
| EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(true));
|
| - registry->didAddEventHandler(*parentDiv, touchEvent);
|
| + document->didAddTouchEventHandler(parentDiv);
|
| EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false));
|
| EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true));
|
| - registry->didRemoveAllEventHandlers(*parentDiv);
|
| + document->didClearTouchEventHandlers(parentDiv);
|
| EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(false));
|
| EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true));
|
|
|
| @@ -1759,42 +1755,42 @@
|
| WebCore::Document* childDocument = toHTMLIFrameElement(childFrame)->contentDocument();
|
| WebCore::Element* childDiv = childDocument->getElementById("childdiv");
|
| ASSERT(childDiv);
|
| - registry->didAddEventHandler(*childDiv, touchEvent);
|
| + childDocument->didAddTouchEventHandler(childDiv);
|
| EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false));
|
| EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(true));
|
|
|
| // Adding and clearing handlers in the parent doc or elsewhere in the child doc
|
| // has no impact.
|
| - registry->didAddEventHandler(*document, touchEvent);
|
| - registry->didAddEventHandler(*childFrame, touchEvent);
|
| - registry->didAddEventHandler(*childDocument, touchEvent);
|
| - registry->didRemoveAllEventHandlers(*document);
|
| - registry->didRemoveAllEventHandlers(*childFrame);
|
| - registry->didRemoveAllEventHandlers(*childDocument);
|
| + document->didAddTouchEventHandler(document);
|
| + document->didAddTouchEventHandler(childFrame);
|
| + childDocument->didAddTouchEventHandler(childDocument);
|
| + document->didClearTouchEventHandlers(document);
|
| + document->didClearTouchEventHandlers(childFrame);
|
| + childDocument->didClearTouchEventHandlers(childDocument);
|
| EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false));
|
| EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true));
|
|
|
| // Removing the final handler inside the child frame results in a no-handlers call.
|
| - registry->didRemoveAllEventHandlers(*childDiv);
|
| + childDocument->didRemoveTouchEventHandler(childDiv);
|
| EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(false));
|
| EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true));
|
|
|
| // Adding a handler inside the child frame results in a has-handlers call.
|
| - registry->didAddEventHandler(*childDocument, touchEvent);
|
| + childDocument->didAddTouchEventHandler(childDocument);
|
| EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false));
|
| EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(true));
|
|
|
| // Adding a handler in the parent document and removing the one in the frame
|
| // has no effect.
|
| - registry->didAddEventHandler(*childFrame, touchEvent);
|
| - registry->didRemoveEventHandler(*childDocument, touchEvent);
|
| - registry->didRemoveAllEventHandlers(*childDocument);
|
| - registry->didRemoveAllEventHandlers(*document);
|
| + document->didAddTouchEventHandler(childFrame);
|
| + childDocument->didRemoveTouchEventHandler(childDocument);
|
| + childDocument->didClearTouchEventHandlers(childDocument);
|
| + document->didClearTouchEventHandlers(document);
|
| EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false));
|
| EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true));
|
|
|
| // Now removing the handler in the parent document results in a no-handlers call.
|
| - registry->didRemoveEventHandler(*childFrame, touchEvent);
|
| + document->didRemoveTouchEventHandler(childFrame);
|
| EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(false));
|
| EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true));
|
|
|
|
|