| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 3336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3347 WebString::fromUTF8(m_baseURL.c_str()), | 3347 WebString::fromUTF8(m_baseURL.c_str()), |
| 3348 WebString::fromUTF8("add_frame_in_unload.html")); | 3348 WebString::fromUTF8("add_frame_in_unload.html")); |
| 3349 m_webViewHelper.initializeAndLoad( | 3349 m_webViewHelper.initializeAndLoad( |
| 3350 m_baseURL + "add_frame_in_unload_wrapper.html", true, &frameClient); | 3350 m_baseURL + "add_frame_in_unload_wrapper.html", true, &frameClient); |
| 3351 FrameTestHelpers::loadFrame(m_webViewHelper.webView()->mainFrame(), | 3351 FrameTestHelpers::loadFrame(m_webViewHelper.webView()->mainFrame(), |
| 3352 "about:blank"); | 3352 "about:blank"); |
| 3353 EXPECT_EQ(1, frameClient.count()); | 3353 EXPECT_EQ(1, frameClient.count()); |
| 3354 m_webViewHelper.reset(); | 3354 m_webViewHelper.reset(); |
| 3355 } | 3355 } |
| 3356 | 3356 |
| 3357 class TouchEventHandlerWebViewClient | 3357 class TouchEventHandlerWebWidgetClient |
| 3358 : public FrameTestHelpers::TestWebViewClient { | 3358 : public FrameTestHelpers::TestWebWidgetClient { |
| 3359 public: | 3359 public: |
| 3360 // WebWidgetClient methods | 3360 // WebWidgetClient methods |
| 3361 void hasTouchEventHandlers(bool state) override { | 3361 void hasTouchEventHandlers(bool state) override { |
| 3362 m_hasTouchEventHandlerCount[state]++; | 3362 m_hasTouchEventHandlerCount[state]++; |
| 3363 } | 3363 } |
| 3364 | 3364 |
| 3365 // Local methods | 3365 // Local methods |
| 3366 TouchEventHandlerWebViewClient() : m_hasTouchEventHandlerCount() {} | 3366 TouchEventHandlerWebWidgetClient() : m_hasTouchEventHandlerCount() {} |
| 3367 | 3367 |
| 3368 int getAndResetHasTouchEventHandlerCallCount(bool state) { | 3368 int getAndResetHasTouchEventHandlerCallCount(bool state) { |
| 3369 int value = m_hasTouchEventHandlerCount[state]; | 3369 int value = m_hasTouchEventHandlerCount[state]; |
| 3370 m_hasTouchEventHandlerCount[state] = 0; | 3370 m_hasTouchEventHandlerCount[state] = 0; |
| 3371 return value; | 3371 return value; |
| 3372 } | 3372 } |
| 3373 | 3373 |
| 3374 private: | 3374 private: |
| 3375 int m_hasTouchEventHandlerCount[2]; | 3375 int m_hasTouchEventHandlerCount[2]; |
| 3376 }; | 3376 }; |
| 3377 | 3377 |
| 3378 // This test verifies that WebWidgetClient::hasTouchEventHandlers is called | 3378 // This test verifies that WebWidgetClient::hasTouchEventHandlers is called |
| 3379 // accordingly for various calls to EventHandlerRegistry::did{Add|Remove| | 3379 // accordingly for various calls to EventHandlerRegistry::did{Add|Remove| |
| 3380 // RemoveAll}EventHandler(..., TouchEvent). Verifying that those calls are made | 3380 // RemoveAll}EventHandler(..., TouchEvent). Verifying that those calls are made |
| 3381 // correctly is the job of LayoutTests/fast/events/event-handler-count.html. | 3381 // correctly is the job of LayoutTests/fast/events/event-handler-count.html. |
| 3382 TEST_P(WebViewTest, HasTouchEventHandlers) { | 3382 TEST_P(WebViewTest, HasTouchEventHandlers) { |
| 3383 TouchEventHandlerWebViewClient client; | 3383 TouchEventHandlerWebWidgetClient client; |
| 3384 // We need to create a LayerTreeView for the client before loading the page, |
| 3385 // otherwise ChromeClient will default to assuming there are touch handlers. |
| 3386 WebLayerTreeView* layerTreeView = client.initializeLayerTreeView(); |
| 3384 std::string url = m_baseURL + "has_touch_event_handlers.html"; | 3387 std::string url = m_baseURL + "has_touch_event_handlers.html"; |
| 3385 URLTestHelpers::registerMockedURLLoad(toKURL(url), | 3388 URLTestHelpers::registerMockedURLLoad(toKURL(url), |
| 3386 "has_touch_event_handlers.html"); | 3389 "has_touch_event_handlers.html"); |
| 3387 WebViewImpl* webViewImpl = | 3390 WebViewImpl* webViewImpl = |
| 3388 m_webViewHelper.initializeAndLoad(url, true, 0, &client); | 3391 m_webViewHelper.initializeAndLoad(url, true, 0, 0, &client); |
| 3392 ASSERT_TRUE(layerTreeView); |
| 3389 const EventHandlerRegistry::EventHandlerClass touchEvent = | 3393 const EventHandlerRegistry::EventHandlerClass touchEvent = |
| 3390 EventHandlerRegistry::TouchStartOrMoveEventBlocking; | 3394 EventHandlerRegistry::TouchStartOrMoveEventBlocking; |
| 3391 | 3395 |
| 3392 // The page is initialized with at least one no-handlers call. | 3396 // The page is initialized with at least one no-handlers call. |
| 3393 // In practice we get two such calls because WebViewHelper::initializeAndLoad | 3397 // In practice we get two such calls because WebViewHelper::initializeAndLoad |
| 3394 // first initializes and empty frame, and then loads a document into it, so | 3398 // first initializes an empty frame, and then loads a document into it, so |
| 3395 // there are two FrameLoader::commitProvisionalLoad calls. | 3399 // there are two FrameLoader::commitProvisionalLoad calls. |
| 3396 EXPECT_GE(client.getAndResetHasTouchEventHandlerCallCount(false), 1); | 3400 EXPECT_LT(0, client.getAndResetHasTouchEventHandlerCallCount(false)); |
| 3397 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true)); | 3401 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true)); |
| 3398 | 3402 |
| 3399 // Adding the first document handler results in a has-handlers call. | 3403 // Adding the first document handler results in a has-handlers call. |
| 3400 Document* document = webViewImpl->mainFrameImpl()->frame()->document(); | 3404 Document* document = webViewImpl->mainFrameImpl()->frame()->document(); |
| 3401 EventHandlerRegistry* registry = | 3405 EventHandlerRegistry* registry = |
| 3402 &document->frameHost()->eventHandlerRegistry(); | 3406 &document->frameHost()->eventHandlerRegistry(); |
| 3403 registry->didAddEventHandler(*document, touchEvent); | 3407 registry->didAddEventHandler(*document, touchEvent); |
| 3404 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false)); | 3408 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false)); |
| 3405 EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(true)); | 3409 EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(true)); |
| 3406 | 3410 |
| (...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4376 EXPECT_EQ(expectedWidth, vwElement->offsetWidth()); | 4380 EXPECT_EQ(expectedWidth, vwElement->offsetWidth()); |
| 4377 EXPECT_EQ(expectedHeight, vwElement->offsetHeight()); | 4381 EXPECT_EQ(expectedHeight, vwElement->offsetHeight()); |
| 4378 | 4382 |
| 4379 webView->resize(WebSize(800, 600)); | 4383 webView->resize(WebSize(800, 600)); |
| 4380 frame->printEnd(); | 4384 frame->printEnd(); |
| 4381 | 4385 |
| 4382 EXPECT_EQ(800, vwElement->offsetWidth()); | 4386 EXPECT_EQ(800, vwElement->offsetWidth()); |
| 4383 } | 4387 } |
| 4384 | 4388 |
| 4385 } // namespace blink | 4389 } // namespace blink |
| OLD | NEW |