| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ui/views/test/widget_test.h" | 5 #include "ui/views/test/widget_test.h" |
| 6 | 6 |
| 7 #include "ui/gfx/native_widget_types.h" | 7 #include "ui/gfx/native_widget_types.h" |
| 8 #include "ui/views/widget/root_view.h" | 8 #include "ui/views/widget/root_view.h" |
| 9 | 9 |
| 10 namespace views { | 10 namespace views { |
| 11 namespace test { | 11 namespace test { |
| 12 | 12 |
| 13 // A widget that assumes mouse capture always works. It won't on Aura in | 13 // A widget that assumes mouse capture always works. It won't in testing, so we |
| 14 // testing, so we mock it. | 14 // mock it. |
| 15 #if defined(USE_AURA) | |
| 16 NativeWidgetCapture::NativeWidgetCapture( | 15 NativeWidgetCapture::NativeWidgetCapture( |
| 17 internal::NativeWidgetDelegate* delegate) | 16 internal::NativeWidgetDelegate* delegate) |
| 18 : NativeWidgetPlatform(delegate), | 17 : NativeWidgetAura(delegate), |
| 19 mouse_capture_(false) {} | 18 mouse_capture_(false) {} |
| 20 NativeWidgetCapture::~NativeWidgetCapture() {} | 19 NativeWidgetCapture::~NativeWidgetCapture() {} |
| 21 | 20 |
| 22 void NativeWidgetCapture::SetCapture() { | 21 void NativeWidgetCapture::SetCapture() { |
| 23 mouse_capture_ = true; | 22 mouse_capture_ = true; |
| 24 } | 23 } |
| 25 | 24 |
| 26 void NativeWidgetCapture::ReleaseCapture() { | 25 void NativeWidgetCapture::ReleaseCapture() { |
| 27 if (mouse_capture_) | 26 if (mouse_capture_) |
| 28 delegate()->OnMouseCaptureLost(); | 27 delegate()->OnMouseCaptureLost(); |
| 29 mouse_capture_ = false; | 28 mouse_capture_ = false; |
| 30 } | 29 } |
| 31 | 30 |
| 32 bool NativeWidgetCapture::HasCapture() const { | 31 bool NativeWidgetCapture::HasCapture() const { |
| 33 return mouse_capture_; | 32 return mouse_capture_; |
| 34 } | 33 } |
| 35 #endif | |
| 36 | 34 |
| 37 WidgetTest::WidgetTest() {} | 35 WidgetTest::WidgetTest() {} |
| 38 WidgetTest::~WidgetTest() {} | 36 WidgetTest::~WidgetTest() {} |
| 39 | 37 |
| 40 NativeWidget* WidgetTest::CreatePlatformNativeWidget( | 38 NativeWidget* WidgetTest::CreatePlatformNativeWidget( |
| 41 internal::NativeWidgetDelegate* delegate) { | 39 internal::NativeWidgetDelegate* delegate) { |
| 42 return new NativeWidgetPlatformForTest(delegate); | 40 return new NativeWidgetCapture(delegate); |
| 43 } | 41 } |
| 44 | 42 |
| 45 Widget* WidgetTest::CreateTopLevelPlatformWidget() { | 43 Widget* WidgetTest::CreateTopLevelPlatformWidget() { |
| 46 Widget* toplevel = new Widget; | 44 Widget* toplevel = new Widget; |
| 47 Widget::InitParams toplevel_params = | 45 Widget::InitParams toplevel_params = |
| 48 CreateParams(Widget::InitParams::TYPE_WINDOW); | 46 CreateParams(Widget::InitParams::TYPE_WINDOW); |
| 49 toplevel_params.native_widget = CreatePlatformNativeWidget(toplevel); | 47 toplevel_params.native_widget = CreatePlatformNativeWidget(toplevel); |
| 50 toplevel->Init(toplevel_params); | 48 toplevel->Init(toplevel_params); |
| 51 return toplevel; | 49 return toplevel; |
| 52 } | 50 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 View* WidgetTest::GetMouseMoveHandler(internal::RootView* root_view) { | 97 View* WidgetTest::GetMouseMoveHandler(internal::RootView* root_view) { |
| 100 return root_view->mouse_move_handler_; | 98 return root_view->mouse_move_handler_; |
| 101 } | 99 } |
| 102 | 100 |
| 103 View* WidgetTest::GetGestureHandler(internal::RootView* root_view) { | 101 View* WidgetTest::GetGestureHandler(internal::RootView* root_view) { |
| 104 return root_view->gesture_handler_; | 102 return root_view->gesture_handler_; |
| 105 } | 103 } |
| 106 | 104 |
| 107 } // namespace test | 105 } // namespace test |
| 108 } // namespace views | 106 } // namespace views |
| OLD | NEW |