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

Side by Side Diff: content/browser/renderer_host/render_widget_host_unittest.cc

Issue 63253002: Rename WebKit namespace to blink (part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/memory/shared_memory.h" 8 #include "base/memory/shared_memory.h"
9 #include "base/timer/timer.h" 9 #include "base/timer/timer.h"
10 #include "content/browser/browser_thread_impl.h" 10 #include "content/browser/browser_thread_impl.h"
(...skipping 28 matching lines...) Expand all
39 #include "ui/aura/env.h" 39 #include "ui/aura/env.h"
40 #include "ui/aura/test/test_screen.h" 40 #include "ui/aura/test/test_screen.h"
41 #endif 41 #endif
42 42
43 #if defined(OS_WIN) || defined(USE_AURA) 43 #if defined(OS_WIN) || defined(USE_AURA)
44 #include "content/browser/renderer_host/ui_events_helper.h" 44 #include "content/browser/renderer_host/ui_events_helper.h"
45 #include "ui/events/event.h" 45 #include "ui/events/event.h"
46 #endif 46 #endif
47 47
48 using base::TimeDelta; 48 using base::TimeDelta;
49 using WebKit::WebGestureEvent; 49 using blink::WebGestureEvent;
50 using WebKit::WebInputEvent; 50 using blink::WebInputEvent;
51 using WebKit::WebMouseWheelEvent; 51 using blink::WebMouseWheelEvent;
52 using WebKit::WebTouchEvent; 52 using blink::WebTouchEvent;
53 using WebKit::WebTouchPoint; 53 using blink::WebTouchPoint;
54 54
55 namespace content { 55 namespace content {
56 56
57 // TestOverscrollDelegate ------------------------------------------------------ 57 // TestOverscrollDelegate ------------------------------------------------------
58 58
59 class TestOverscrollDelegate : public OverscrollControllerDelegate { 59 class TestOverscrollDelegate : public OverscrollControllerDelegate {
60 public: 60 public:
61 explicit TestOverscrollDelegate(RenderWidgetHostView* view) 61 explicit TestOverscrollDelegate(RenderWidgetHostView* view)
62 : view_(view), 62 : view_(view),
63 current_mode_(OVERSCROLL_NONE), 63 current_mode_(OVERSCROLL_NONE),
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 } 432 }
433 433
434 // Sets the bounds returned by GetViewBounds. 434 // Sets the bounds returned by GetViewBounds.
435 void set_bounds(const gfx::Rect& bounds) { 435 void set_bounds(const gfx::Rect& bounds) {
436 bounds_ = bounds; 436 bounds_ = bounds;
437 } 437 }
438 438
439 const WebTouchEvent& acked_event() const { return acked_event_; } 439 const WebTouchEvent& acked_event() const { return acked_event_; }
440 int acked_event_count() const { return acked_event_count_; } 440 int acked_event_count() const { return acked_event_count_; }
441 void ClearAckedEvent() { 441 void ClearAckedEvent() {
442 acked_event_.type = WebKit::WebInputEvent::Undefined; 442 acked_event_.type = blink::WebInputEvent::Undefined;
443 acked_event_count_ = 0; 443 acked_event_count_ = 0;
444 } 444 }
445 445
446 const WebMouseWheelEvent& unhandled_wheel_event() const { 446 const WebMouseWheelEvent& unhandled_wheel_event() const {
447 return unhandled_wheel_event_; 447 return unhandled_wheel_event_;
448 } 448 }
449 int gesture_event_type() const { return gesture_event_type_; } 449 int gesture_event_type() const { return gesture_event_type_; }
450 InputEventAckState ack_result() const { return ack_result_; } 450 InputEventAckState ack_result() const { return ack_result_; }
451 451
452 void SetMockPhysicalBackingSize(const gfx::Size& mock_physical_backing_size) { 452 void SetMockPhysicalBackingSize(const gfx::Size& mock_physical_backing_size) {
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 : process_(NULL), 594 : process_(NULL),
595 handle_key_press_event_(false), 595 handle_key_press_event_(false),
596 handle_mouse_event_(false) { 596 handle_mouse_event_(false) {
597 } 597 }
598 virtual ~RenderWidgetHostTest() { 598 virtual ~RenderWidgetHostTest() {
599 } 599 }
600 600
601 bool KeyPressEventCallback(const NativeWebKeyboardEvent& /* event */) { 601 bool KeyPressEventCallback(const NativeWebKeyboardEvent& /* event */) {
602 return handle_key_press_event_; 602 return handle_key_press_event_;
603 } 603 }
604 bool MouseEventCallback(const WebKit::WebMouseEvent& /* event */) { 604 bool MouseEventCallback(const blink::WebMouseEvent& /* event */) {
605 return handle_mouse_event_; 605 return handle_mouse_event_;
606 } 606 }
607 607
608 protected: 608 protected:
609 // testing::Test 609 // testing::Test
610 virtual void SetUp() { 610 virtual void SetUp() {
611 browser_context_.reset(new TestBrowserContext()); 611 browser_context_.reset(new TestBrowserContext());
612 delegate_.reset(new MockRenderWidgetHostDelegate()); 612 delegate_.reset(new MockRenderWidgetHostDelegate());
613 process_ = new RenderWidgetHostProcess(browser_context_.get()); 613 process_ = new RenderWidgetHostProcess(browser_context_.get());
614 #if defined(USE_AURA) 614 #if defined(USE_AURA)
(...skipping 1321 matching lines...) Expand 10 before | Expand all | Expand 10 after
1936 SendTouchEvent(); 1936 SendTouchEvent();
1937 EXPECT_EQ(1U, process_->sink().message_count()); 1937 EXPECT_EQ(1U, process_->sink().message_count());
1938 EXPECT_FALSE(host_->TouchEventQueueEmpty()); 1938 EXPECT_FALSE(host_->TouchEventQueueEmpty());
1939 process_->sink().ClearMessages(); 1939 process_->sink().ClearMessages();
1940 1940
1941 SendInputEventACK(WebInputEvent::TouchEnd, 1941 SendInputEventACK(WebInputEvent::TouchEnd,
1942 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1942 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1943 EXPECT_EQ(0U, process_->sink().message_count()); 1943 EXPECT_EQ(0U, process_->sink().message_count());
1944 EXPECT_TRUE(host_->TouchEventQueueEmpty()); 1944 EXPECT_TRUE(host_->TouchEventQueueEmpty());
1945 1945
1946 SimulateGestureEvent(WebKit::WebInputEvent::GestureScrollEnd, 1946 SimulateGestureEvent(blink::WebInputEvent::GestureScrollEnd,
1947 WebGestureEvent::Touchscreen); 1947 WebGestureEvent::Touchscreen);
1948 base::MessageLoop::current()->PostDelayedTask( 1948 base::MessageLoop::current()->PostDelayedTask(
1949 FROM_HERE, 1949 FROM_HERE,
1950 base::MessageLoop::QuitClosure(), 1950 base::MessageLoop::QuitClosure(),
1951 TimeDelta::FromMilliseconds(10)); 1951 TimeDelta::FromMilliseconds(10));
1952 base::MessageLoop::current()->Run(); 1952 base::MessageLoop::current()->Run();
1953 EXPECT_EQ(1U, process_->sink().message_count()); 1953 EXPECT_EQ(1U, process_->sink().message_count());
1954 EXPECT_TRUE(host_->TouchEventQueueEmpty()); 1954 EXPECT_TRUE(host_->TouchEventQueueEmpty());
1955 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 1955 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
1956 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 1956 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1994 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 1994 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1995 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); 1995 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize());
1996 EXPECT_EQ(0U, process_->sink().message_count()); 1996 EXPECT_EQ(0U, process_->sink().message_count());
1997 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); 1997 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode());
1998 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); 1998 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode());
1999 EXPECT_EQ(55.f, host_->overscroll_delta_x()); 1999 EXPECT_EQ(55.f, host_->overscroll_delta_x());
2000 EXPECT_EQ(5.f, host_->overscroll_delegate()->delta_x()); 2000 EXPECT_EQ(5.f, host_->overscroll_delegate()->delta_x());
2001 EXPECT_EQ(-5.f, host_->overscroll_delegate()->delta_y()); 2001 EXPECT_EQ(-5.f, host_->overscroll_delegate()->delta_y());
2002 2002
2003 // Send end event. 2003 // Send end event.
2004 SimulateGestureEvent(WebKit::WebInputEvent::GestureScrollEnd, 2004 SimulateGestureEvent(blink::WebInputEvent::GestureScrollEnd,
2005 WebGestureEvent::Touchscreen); 2005 WebGestureEvent::Touchscreen);
2006 EXPECT_EQ(0U, process_->sink().message_count()); 2006 EXPECT_EQ(0U, process_->sink().message_count());
2007 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 2007 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
2008 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 2008 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
2009 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->completed_mode()); 2009 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->completed_mode());
2010 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); 2010 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize());
2011 EXPECT_EQ(1U, host_->GestureEventDebouncingQueueSize()); 2011 EXPECT_EQ(1U, host_->GestureEventDebouncingQueueSize());
2012 base::MessageLoop::current()->PostDelayedTask( 2012 base::MessageLoop::current()->PostDelayedTask(
2013 FROM_HERE, 2013 FROM_HERE,
2014 base::MessageLoop::QuitClosure(), 2014 base::MessageLoop::QuitClosure(),
2015 TimeDelta::FromMilliseconds(10)); 2015 TimeDelta::FromMilliseconds(10));
2016 base::MessageLoop::current()->Run(); 2016 base::MessageLoop::current()->Run();
2017 EXPECT_EQ(1U, process_->sink().message_count()); 2017 EXPECT_EQ(1U, process_->sink().message_count());
2018 process_->sink().ClearMessages(); 2018 process_->sink().ClearMessages();
2019 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); 2019 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize());
2020 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); 2020 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize());
2021 2021
2022 SendInputEventACK(WebKit::WebInputEvent::GestureScrollEnd, 2022 SendInputEventACK(blink::WebInputEvent::GestureScrollEnd,
2023 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2023 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2024 EXPECT_EQ(0U, process_->sink().message_count()); 2024 EXPECT_EQ(0U, process_->sink().message_count());
2025 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); 2025 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize());
2026 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); 2026 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize());
2027 2027
2028 // Start scrolling. Receive ACK as it being processed. 2028 // Start scrolling. Receive ACK as it being processed.
2029 SimulateGestureEvent(WebInputEvent::GestureScrollBegin, 2029 SimulateGestureEvent(WebInputEvent::GestureScrollBegin,
2030 WebGestureEvent::Touchscreen); 2030 WebGestureEvent::Touchscreen);
2031 EXPECT_EQ(1U, process_->sink().message_count()); 2031 EXPECT_EQ(1U, process_->sink().message_count());
2032 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); 2032 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize());
(...skipping 19 matching lines...) Expand all
2052 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2052 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2053 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); 2053 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize());
2054 EXPECT_EQ(0U, process_->sink().message_count()); 2054 EXPECT_EQ(0U, process_->sink().message_count());
2055 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode()); 2055 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_mode());
2056 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode()); 2056 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->current_mode());
2057 EXPECT_EQ(235.f, host_->overscroll_delta_x()); 2057 EXPECT_EQ(235.f, host_->overscroll_delta_x());
2058 EXPECT_EQ(185.f, host_->overscroll_delegate()->delta_x()); 2058 EXPECT_EQ(185.f, host_->overscroll_delegate()->delta_x());
2059 EXPECT_EQ(-5.f, host_->overscroll_delegate()->delta_y()); 2059 EXPECT_EQ(-5.f, host_->overscroll_delegate()->delta_y());
2060 2060
2061 // Send end event. 2061 // Send end event.
2062 SimulateGestureEvent(WebKit::WebInputEvent::GestureScrollEnd, 2062 SimulateGestureEvent(blink::WebInputEvent::GestureScrollEnd,
2063 WebGestureEvent::Touchscreen); 2063 WebGestureEvent::Touchscreen);
2064 EXPECT_EQ(0U, process_->sink().message_count()); 2064 EXPECT_EQ(0U, process_->sink().message_count());
2065 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode()); 2065 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_mode());
2066 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode()); 2066 EXPECT_EQ(OVERSCROLL_NONE, host_->overscroll_delegate()->current_mode());
2067 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->completed_mode()); 2067 EXPECT_EQ(OVERSCROLL_EAST, host_->overscroll_delegate()->completed_mode());
2068 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); 2068 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize());
2069 EXPECT_EQ(1U, host_->GestureEventDebouncingQueueSize()); 2069 EXPECT_EQ(1U, host_->GestureEventDebouncingQueueSize());
2070 2070
2071 base::MessageLoop::current()->PostDelayedTask( 2071 base::MessageLoop::current()->PostDelayedTask(
2072 FROM_HERE, 2072 FROM_HERE,
2073 base::MessageLoop::QuitClosure(), 2073 base::MessageLoop::QuitClosure(),
2074 TimeDelta::FromMilliseconds(10)); 2074 TimeDelta::FromMilliseconds(10));
2075 base::MessageLoop::current()->Run(); 2075 base::MessageLoop::current()->Run();
2076 EXPECT_EQ(1U, process_->sink().message_count()); 2076 EXPECT_EQ(1U, process_->sink().message_count());
2077 process_->sink().ClearMessages(); 2077 process_->sink().ClearMessages();
2078 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize()); 2078 EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize());
2079 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); 2079 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize());
2080 2080
2081 SendInputEventACK(WebKit::WebInputEvent::GestureScrollEnd, 2081 SendInputEventACK(blink::WebInputEvent::GestureScrollEnd,
2082 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2082 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2083 EXPECT_EQ(0U, process_->sink().message_count()); 2083 EXPECT_EQ(0U, process_->sink().message_count());
2084 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize()); 2084 EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize());
2085 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize()); 2085 EXPECT_EQ(0U, host_->GestureEventDebouncingQueueSize());
2086 } 2086 }
2087 2087
2088 TEST_F(RenderWidgetHostTest, OverscrollDirectionChange) { 2088 TEST_F(RenderWidgetHostTest, OverscrollDirectionChange) {
2089 host_->SetupForOverscrollControllerTest(); 2089 host_->SetupForOverscrollControllerTest();
2090 host_->set_debounce_interval_time_ms(100); 2090 host_->set_debounce_interval_time_ms(100);
2091 process_->sink().ClearMessages(); 2091 process_->sink().ClearMessages();
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
2477 2477
2478 TEST_F(RenderWidgetHostTest, InputRouterReceivesHasTouchEventHandlers) { 2478 TEST_F(RenderWidgetHostTest, InputRouterReceivesHasTouchEventHandlers) {
2479 host_->SetupForInputRouterTest(); 2479 host_->SetupForInputRouterTest();
2480 2480
2481 host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true)); 2481 host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true));
2482 2482
2483 EXPECT_TRUE(host_->mock_input_router()->message_received_); 2483 EXPECT_TRUE(host_->mock_input_router()->message_received_);
2484 } 2484 }
2485 2485
2486 } // namespace content 2486 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698