Chromium Code Reviews| 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. | |
| 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); | |
|
Rick Byers
2014/12/18 15:18:14
Great, this is the key case you want to test. But
lanwei
2014/12/19 02:55:44
Done.
| |
| 3031 } | |
| 3032 | |
| 3003 } // namespace content | 3033 } // namespace content |
| OLD | NEW |