Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/native_widget_factory.h" | 5 #include "ui/views/test/native_widget_factory.h" |
| 6 | 6 |
| 7 #include "ui/views/test/test_platform_native_widget.h" | |
| 8 | |
| 7 #if defined(USE_AURA) | 9 #if defined(USE_AURA) |
| 10 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | |
| 8 #include "ui/views/widget/native_widget_aura.h" | 11 #include "ui/views/widget/native_widget_aura.h" |
| 9 #if !defined(OS_CHROMEOS) | |
| 10 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | |
| 11 #endif | |
| 12 #elif defined(OS_MACOSX) | 12 #elif defined(OS_MACOSX) |
| 13 #include "ui/views/widget/native_widget_mac.h" | 13 #include "ui/views/widget/native_widget_mac.h" |
| 14 #endif | 14 #endif |
| 15 | 15 |
| 16 namespace views { | 16 namespace views { |
| 17 namespace test { | 17 namespace test { |
| 18 | 18 |
| 19 #if !defined(OS_CHROMEOS) | 19 NativeWidget* CreatePlatformNativeWidgetImpl( |
| 20 | 20 const Widget::InitParams& init_params, |
| 21 Widget* widget, | |
| 22 uint32_t type, | |
| 23 bool* destroyed) { | |
| 21 #if defined(OS_MACOSX) | 24 #if defined(OS_MACOSX) |
| 22 using PlatformDesktopNativeWidget = NativeWidgetMac; | 25 return new TestPlatformNativeWidget<NativeWidgetMac>( |
| 26 widget, type == kStubCapture, destroyed); | |
| 23 #else | 27 #else |
| 24 using PlatformDesktopNativeWidget = DesktopNativeWidgetAura; | 28 return new TestPlatformNativeWidget<NativeWidgetAura>( |
| 29 widget, type == kStubCapture, destroyed); | |
| 25 #endif | 30 #endif |
| 26 | |
| 27 namespace { | |
| 28 | |
| 29 class TestPlatformDesktopNativeWidget : public PlatformDesktopNativeWidget { | |
| 30 public: | |
| 31 TestPlatformDesktopNativeWidget(internal::NativeWidgetDelegate* delegate, | |
| 32 bool* destroyed); | |
| 33 ~TestPlatformDesktopNativeWidget() override; | |
| 34 | |
| 35 private: | |
| 36 bool* destroyed_; | |
| 37 | |
| 38 DISALLOW_COPY_AND_ASSIGN(TestPlatformDesktopNativeWidget); | |
| 39 }; | |
| 40 | |
| 41 // A widget that assumes mouse capture always works. It won't in testing, so we | |
| 42 // mock it. | |
| 43 TestPlatformDesktopNativeWidget::TestPlatformDesktopNativeWidget( | |
| 44 internal::NativeWidgetDelegate* delegate, | |
| 45 bool* destroyed) | |
| 46 : PlatformDesktopNativeWidget(delegate), destroyed_(destroyed) {} | |
| 47 | |
| 48 TestPlatformDesktopNativeWidget::~TestPlatformDesktopNativeWidget() { | |
| 49 if (destroyed_) | |
| 50 *destroyed_ = true; | |
| 51 } | 31 } |
| 52 | 32 |
| 53 } // namespace | |
| 54 | |
| 55 #endif | |
| 56 | |
| 57 NativeWidget* CreatePlatformDesktopNativeWidgetImpl( | 33 NativeWidget* CreatePlatformDesktopNativeWidgetImpl( |
| 58 const Widget::InitParams& init_params, | 34 const Widget::InitParams& init_params, |
| 59 Widget* widget, | 35 Widget* widget, |
| 60 bool* destroyed) { | 36 bool* destroyed) { |
| 61 #if defined(OS_CHROMEOS) | 37 #if defined(OS_MACOSX) |
| 62 // Chromeos only has one NativeWidgetType. | 38 return new TestPlatformNativeWidget<NativeWidgetMac>(widget, false, |
| 63 return CreatePlatformNativeWidgetImpl(init_params, widget, 0u, destroyed); | 39 destroyed); |
| 64 #else | 40 #elif defined(OS_CHROMEOS) |
| 65 return new TestPlatformDesktopNativeWidget(widget, destroyed); | 41 // Chromeos only has one NativeWidgetType. Chromeos with aura-mus does not |
| 42 // compile this file. | |
| 43 return new TestPlatformNativeWidget<NativeWidgetAura>(widget, false, | |
| 44 destroyed); | |
| 45 #elif defined(USE_AURA) | |
|
msw
2016/11/11 00:29:24
I guess this isn't compiled anywhere that lacks a
sky
2016/11/11 01:09:13
Done.
| |
| 46 return new TestPlatformNativeWidget<DesktopNativeWidgetAura>(widget, false, | |
| 47 destroyed); | |
| 66 #endif | 48 #endif |
| 67 } | 49 } |
| 68 | 50 |
| 69 } // namespace test | 51 } // namespace test |
| 70 } // namespace views | 52 } // namespace views |
| OLD | NEW |