OLD | NEW |
---|---|
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 "content/browser/renderer_host/render_widget_host_view_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
301 private: | 301 private: |
302 aura::Window* owner_; | 302 aura::Window* owner_; |
303 DISALLOW_COPY_AND_ASSIGN(FullscreenLayoutManager); | 303 DISALLOW_COPY_AND_ASSIGN(FullscreenLayoutManager); |
304 }; | 304 }; |
305 | 305 |
306 class MockWindowObserver : public aura::WindowObserver { | 306 class MockWindowObserver : public aura::WindowObserver { |
307 public: | 307 public: |
308 MOCK_METHOD2(OnDelegatedFrameDamage, void(aura::Window*, const gfx::Rect&)); | 308 MOCK_METHOD2(OnDelegatedFrameDamage, void(aura::Window*, const gfx::Rect&)); |
309 }; | 309 }; |
310 | 310 |
311 const WebInputEvent* GetInputEventFromMessage(const IPC::Message& message) { | |
312 PickleIterator iter(message); | |
313 const char* data; | |
314 int data_length; | |
315 if (!message.ReadData(&iter, &data, &data_length)) | |
316 return NULL; | |
317 return reinterpret_cast<const WebInputEvent*>(data); | |
318 } | |
319 | |
311 } // namespace | 320 } // namespace |
312 | 321 |
313 class RenderWidgetHostViewAuraTest : public testing::Test { | 322 class RenderWidgetHostViewAuraTest : public testing::Test { |
314 public: | 323 public: |
315 RenderWidgetHostViewAuraTest() | 324 RenderWidgetHostViewAuraTest() |
316 : widget_host_uses_shutdown_to_destroy_(false), | 325 : widget_host_uses_shutdown_to_destroy_(false), |
317 is_guest_view_hack_(false), | 326 is_guest_view_hack_(false), |
318 browser_thread_for_ui_(BrowserThread::UI, &message_loop_) {} | 327 browser_thread_for_ui_(BrowserThread::UI, &message_loop_) {} |
319 | 328 |
320 void SetUpEnvironment() { | 329 void SetUpEnvironment() { |
(...skipping 2672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2993 | 3002 |
2994 const NativeWebKeyboardEvent* event = delegate_.last_event(); | 3003 const NativeWebKeyboardEvent* event = delegate_.last_event(); |
2995 EXPECT_NE(nullptr, event); | 3004 EXPECT_NE(nullptr, event); |
2996 if (event) { | 3005 if (event) { |
2997 EXPECT_EQ(key_event.key_code(), event->windowsKeyCode); | 3006 EXPECT_EQ(key_event.key_code(), event->windowsKeyCode); |
2998 EXPECT_EQ(ui::KeycodeConverter::DomCodeToNativeKeycode(key_event.code()), | 3007 EXPECT_EQ(ui::KeycodeConverter::DomCodeToNativeKeycode(key_event.code()), |
2999 event->nativeKeyCode); | 3008 event->nativeKeyCode); |
3000 } | 3009 } |
3001 } | 3010 } |
3002 | 3011 |
3012 TEST_F(RenderWidgetHostViewAuraTest, SetCanScrollForWebMouseWheelEvent) { | |
3013 view_->InitAsChild(NULL); | |
3014 view_->Show(); | |
3015 | |
3016 sink_->ClearMessages(); | |
3017 | |
3018 // Simulates the mouse wheel event with ctrl modifier applied. | |
3019 ui::MouseWheelEvent event(gfx::Vector2d(1, 1), | |
3020 gfx::Point(), gfx::Point(), | |
3021 ui::EF_CONTROL_DOWN, 0); | |
3022 view_->OnMouseEvent(&event); | |
3023 | |
3024 const WebInputEvent* input_event = | |
3025 GetInputEventFromMessage(*sink_->GetMessageAt(0)); | |
3026 const WebMouseWheelEvent* wheel_event = | |
3027 static_cast<const WebMouseWheelEvent*>(input_event); | |
3028 // Check if the canScroll set to false when ctrl-scroll is generated from | |
3029 // mouse wheel event. | |
3030 EXPECT_FALSE(wheel_event->canScroll); | |
3031 sink_->ClearMessages(); | |
3032 | |
3033 // Ack'ing the outstanding event should flush the pending touch queue. | |
Rick Byers
2014/12/19 15:44:46
nit: not "touch", maybe just "event"?
lanwei
2014/12/20 02:32:03
Done.
| |
3034 InputHostMsg_HandleInputEvent_ACK_Params ack; | |
3035 ack.type = blink::WebInputEvent::MouseWheel; | |
3036 ack.state = INPUT_EVENT_ACK_STATE_CONSUMED; | |
3037 widget_host_->OnMessageReceived(InputHostMsg_HandleInputEvent_ACK(0, ack)); | |
3038 | |
3039 // Simulates the mouse wheel event with no modifier applied. | |
3040 event = ui::MouseWheelEvent(gfx::Vector2d(1, 1), gfx::Point(), gfx::Point(), | |
3041 ui::EF_NONE, 0); | |
3042 | |
3043 view_->OnMouseEvent(&event); | |
3044 | |
3045 input_event = GetInputEventFromMessage(*sink_->GetMessageAt(0)); | |
3046 wheel_event = static_cast<const WebMouseWheelEvent*>(input_event); | |
3047 // Check if the canScroll set to true when no modifier is applied to the | |
3048 // mouse wheel event. | |
3049 EXPECT_TRUE(wheel_event->canScroll); | |
3050 sink_->ClearMessages(); | |
3051 | |
3052 ack.type = blink::WebInputEvent::MouseWheel; | |
3053 ack.state = INPUT_EVENT_ACK_STATE_CONSUMED; | |
3054 widget_host_->OnMessageReceived(InputHostMsg_HandleInputEvent_ACK(0, ack)); | |
3055 | |
3056 // Simulates the scroll event with ctrl modifier applied. | |
3057 ui::ScrollEvent scroll(ui::ET_SCROLL, gfx::Point(0, 0), ui::EventTimeForNow(), | |
3058 0, 0, 5, 0, 5, 2); | |
Rick Byers
2014/12/19 15:44:46
Looks like you forgot to actually set the ctrl mod
lanwei
2014/12/20 02:32:03
Done.
| |
3059 view_->OnScrollEvent(&scroll); | |
3060 | |
3061 input_event = GetInputEventFromMessage(*sink_->GetMessageAt(0)); | |
3062 wheel_event = static_cast<const WebMouseWheelEvent*>(input_event); | |
3063 // Check if the canScroll set to true when ctrl-tpuchpad-scroll is generated | |
3064 // from scroll event. | |
3065 EXPECT_TRUE(wheel_event->canScroll); | |
3066 | |
3067 | |
3068 } | |
3069 | |
3003 } // namespace content | 3070 } // namespace content |
OLD | NEW |