Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(738)

Side by Side Diff: third_party/WebKit/Source/web/tests/WebViewTest.cpp

Issue 2479663002: Move compositor InputHandler from RenderViewImpl to RenderWidget. (Closed)
Patch Set: Plumb pseudo touch-event-rects for OOPIFs to compositor. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 3335 matching lines...) Expand 10 before | Expand all | Expand 10 after
3346 WebString::fromUTF8(m_baseURL.c_str()), 3346 WebString::fromUTF8(m_baseURL.c_str()),
3347 WebString::fromUTF8("add_frame_in_unload.html")); 3347 WebString::fromUTF8("add_frame_in_unload.html"));
3348 m_webViewHelper.initializeAndLoad( 3348 m_webViewHelper.initializeAndLoad(
3349 m_baseURL + "add_frame_in_unload_wrapper.html", true, &frameClient); 3349 m_baseURL + "add_frame_in_unload_wrapper.html", true, &frameClient);
3350 FrameTestHelpers::loadFrame(m_webViewHelper.webView()->mainFrame(), 3350 FrameTestHelpers::loadFrame(m_webViewHelper.webView()->mainFrame(),
3351 "about:blank"); 3351 "about:blank");
3352 EXPECT_EQ(1, frameClient.count()); 3352 EXPECT_EQ(1, frameClient.count());
3353 m_webViewHelper.reset(); 3353 m_webViewHelper.reset();
3354 } 3354 }
3355 3355
3356 class TouchEventHandlerWebViewClient 3356 class TouchEventHandlerWebWidgetClient
3357 : public FrameTestHelpers::TestWebViewClient { 3357 : public FrameTestHelpers::TestWebWidgetClient {
3358 public: 3358 public:
3359 // WebWidgetClient methods 3359 // WebWidgetClient methods
3360 void hasTouchEventHandlers(bool state) override { 3360 void hasTouchEventHandlers(bool state) override {
3361 m_hasTouchEventHandlerCount[state]++; 3361 m_hasTouchEventHandlerCount[state]++;
3362 } 3362 }
3363 3363
3364 // Local methods 3364 // Local methods
3365 TouchEventHandlerWebViewClient() : m_hasTouchEventHandlerCount() {} 3365 TouchEventHandlerWebWidgetClient() : m_hasTouchEventHandlerCount() {}
3366 3366
3367 int getAndResetHasTouchEventHandlerCallCount(bool state) { 3367 int getAndResetHasTouchEventHandlerCallCount(bool state) {
3368 int value = m_hasTouchEventHandlerCount[state]; 3368 int value = m_hasTouchEventHandlerCount[state];
3369 m_hasTouchEventHandlerCount[state] = 0; 3369 m_hasTouchEventHandlerCount[state] = 0;
3370 return value; 3370 return value;
3371 } 3371 }
3372 3372
3373 private: 3373 private:
3374 int m_hasTouchEventHandlerCount[2]; 3374 int m_hasTouchEventHandlerCount[2];
3375 }; 3375 };
3376 3376
3377 // This test verifies that WebWidgetClient::hasTouchEventHandlers is called 3377 // This test verifies that WebWidgetClient::hasTouchEventHandlers is called
3378 // accordingly for various calls to EventHandlerRegistry::did{Add|Remove| 3378 // accordingly for various calls to EventHandlerRegistry::did{Add|Remove|
3379 // RemoveAll}EventHandler(..., TouchEvent). Verifying that those calls are made 3379 // RemoveAll}EventHandler(..., TouchEvent). Verifying that those calls are made
3380 // correctly is the job of LayoutTests/fast/events/event-handler-count.html. 3380 // correctly is the job of LayoutTests/fast/events/event-handler-count.html.
3381 TEST_P(WebViewTest, HasTouchEventHandlers) { 3381 TEST_P(WebViewTest, HasTouchEventHandlers) {
3382 TouchEventHandlerWebViewClient client; 3382 TouchEventHandlerWebWidgetClient client;
3383 // We need to create a LayerTreeView for the client before loading the page,
3384 // otherwise ChromeClient will default to assuming there are touch handlers.
3385 WebLayerTreeView* layerTreeView = client.initializeLayerTreeView();
3383 std::string url = m_baseURL + "has_touch_event_handlers.html"; 3386 std::string url = m_baseURL + "has_touch_event_handlers.html";
3384 URLTestHelpers::registerMockedURLLoad(toKURL(url), 3387 URLTestHelpers::registerMockedURLLoad(toKURL(url),
3385 "has_touch_event_handlers.html"); 3388 "has_touch_event_handlers.html");
3386 WebViewImpl* webViewImpl = 3389 WebViewImpl* webViewImpl =
3387 m_webViewHelper.initializeAndLoad(url, true, 0, &client); 3390 m_webViewHelper.initializeAndLoad(url, true, 0, 0, &client);
3391 ASSERT_TRUE(layerTreeView);
3388 const EventHandlerRegistry::EventHandlerClass touchEvent = 3392 const EventHandlerRegistry::EventHandlerClass touchEvent =
3389 EventHandlerRegistry::TouchStartOrMoveEventBlocking; 3393 EventHandlerRegistry::TouchStartOrMoveEventBlocking;
3390 3394
3391 // The page is initialized with at least one no-handlers call. 3395 // The page is initialized with at least one no-handlers call.
3392 // In practice we get two such calls because WebViewHelper::initializeAndLoad 3396 // In practice we get two such calls because WebViewHelper::initializeAndLoad
3393 // first initializes and empty frame, and then loads a document into it, so 3397 // first initializes an empty frame, and then loads a document into it, so
3394 // there are two FrameLoader::commitProvisionalLoad calls. 3398 // there are two FrameLoader::commitProvisionalLoad calls.
3395 EXPECT_GE(client.getAndResetHasTouchEventHandlerCallCount(false), 1); 3399 EXPECT_LT(0, client.getAndResetHasTouchEventHandlerCallCount(false));
3396 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true)); 3400 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(true));
3397 3401
3398 // Adding the first document handler results in a has-handlers call. 3402 // Adding the first document handler results in a has-handlers call.
3399 Document* document = webViewImpl->mainFrameImpl()->frame()->document(); 3403 Document* document = webViewImpl->mainFrameImpl()->frame()->document();
3400 EventHandlerRegistry* registry = 3404 EventHandlerRegistry* registry =
3401 &document->frameHost()->eventHandlerRegistry(); 3405 &document->frameHost()->eventHandlerRegistry();
3402 registry->didAddEventHandler(*document, touchEvent); 3406 registry->didAddEventHandler(*document, touchEvent);
3403 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false)); 3407 EXPECT_EQ(0, client.getAndResetHasTouchEventHandlerCallCount(false));
3404 EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(true)); 3408 EXPECT_EQ(1, client.getAndResetHasTouchEventHandlerCallCount(true));
3405 3409
(...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after
4352 frame->printBegin(printParams, WebNode()); 4356 frame->printBegin(printParams, WebNode());
4353 webView->resize(WebSize(500, 500)); 4357 webView->resize(WebSize(500, 500));
4354 EXPECT_EQ(500, vwElement->offsetWidth()); 4358 EXPECT_EQ(500, vwElement->offsetWidth());
4355 4359
4356 webView->resize(WebSize(800, 600)); 4360 webView->resize(WebSize(800, 600));
4357 frame->printEnd(); 4361 frame->printEnd();
4358 EXPECT_EQ(800, vwElement->offsetWidth()); 4362 EXPECT_EQ(800, vwElement->offsetWidth());
4359 } 4363 }
4360 4364
4361 } // namespace blink 4365 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698