diff options
-rw-r--r-- | ui/views/BUILD.gn | 1 | ||||
-rw-r--r-- | ui/views/mus/BUILD.gn | 2 | ||||
-rw-r--r-- | ui/views/mus/native_widget_mus.cc | 3 | ||||
-rw-r--r-- | ui/views/test/capture_tracking_view.h | 6 | ||||
-rw-r--r-- | ui/views/test/native_widget_factory.cc | 99 | ||||
-rw-r--r-- | ui/views/test/native_widget_factory.h | 46 | ||||
-rw-r--r-- | ui/views/test/native_widget_factory_desktop.cc | 71 | ||||
-rw-r--r-- | ui/views/test/native_widget_factory_mus.cc | 21 | ||||
-rw-r--r-- | ui/views/test/widget_test.cc | 65 | ||||
-rw-r--r-- | ui/views/test/widget_test.h | 38 | ||||
-rw-r--r-- | ui/views/test/widget_test_aura.cc | 5 | ||||
-rw-r--r-- | ui/views/test/widget_test_mac.mm | 1 | ||||
-rw-r--r-- | ui/views/views.gyp | 8 | ||||
-rw-r--r-- | ui/views/widget/desktop_aura/desktop_native_widget_aura_unittest.cc | 8 | ||||
-rw-r--r-- | ui/views/widget/desktop_widget_unittest.cc | 7 | ||||
-rw-r--r-- | ui/views/widget/native_widget_mac_unittest.mm | 8 | ||||
-rw-r--r-- | ui/views/widget/widget_interactive_uitest.cc | 41 | ||||
-rw-r--r-- | ui/views/widget/widget_unittest.cc | 130 |
18 files changed, 374 insertions, 186 deletions
diff --git a/ui/views/BUILD.gn b/ui/views/BUILD.gn index 5c471a5..7c957c3 100644 --- a/ui/views/BUILD.gn +++ b/ui/views/BUILD.gn @@ -199,6 +199,7 @@ static_library("test_support") { ] sources = [ "test/default_platform_test_helper.cc", + "test/native_widget_factory_desktop.cc", ] } diff --git a/ui/views/mus/BUILD.gn b/ui/views/mus/BUILD.gn index c9b0ec3..3c79078 100644 --- a/ui/views/mus/BUILD.gn +++ b/ui/views/mus/BUILD.gn @@ -145,7 +145,9 @@ test("views_mus_unittests") { sources = [ "../run_all_unittests.cc", "../run_all_unittests.h", + "../test/native_widget_factory_mus.cc", "../view_targeter_unittest.cc", + "../widget/native_widget_unittest.cc", "platform_test_helper_mus.cc", "run_all_unittests_mus.cc", ] diff --git a/ui/views/mus/native_widget_mus.cc b/ui/views/mus/native_widget_mus.cc index 2ecb52d..40c9d2d 100644 --- a/ui/views/mus/native_widget_mus.cc +++ b/ui/views/mus/native_widget_mus.cc @@ -26,6 +26,7 @@ #include "ui/views/mus/window_manager_constants_converters.h" #include "ui/views/mus/window_manager_frame_values.h" #include "ui/views/mus/window_tree_host_mus.h" +#include "ui/views/widget/native_widget_aura.h" #include "ui/views/widget/widget_delegate.h" #include "ui/views/window/custom_frame_view.h" #include "ui/wm/core/base_focus_rules.h" @@ -307,6 +308,8 @@ NonClientFrameView* NativeWidgetMus::CreateNonClientFrameView() { } void NativeWidgetMus::InitNativeWidget(const Widget::InitParams& params) { + NativeWidgetAura::RegisterNativeWidgetForWindow(this, content_); + ownership_ = params.ownership; window_->SetCanFocus(params.activatable == Widget::InitParams::ACTIVATABLE_YES); diff --git a/ui/views/test/capture_tracking_view.h b/ui/views/test/capture_tracking_view.h index d5dcfbe..5964916 100644 --- a/ui/views/test/capture_tracking_view.h +++ b/ui/views/test/capture_tracking_view.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef UI_VIEWS_TEST_CAPTURE_TRACKING_VIEW_ -#define UI_VIEWS_TEST_CAPTURE_TRACKING_VIEW_ +#ifndef UI_VIEWS_TEST_CAPTURE_TRACKING_VIEW_H_ +#define UI_VIEWS_TEST_CAPTURE_TRACKING_VIEW_H_ #include "base/compiler_specific.h" #include "base/macros.h" @@ -41,4 +41,4 @@ class CaptureTrackingView : public views::View { } // namespace test } // namespace views -#endif // UI_VIEWS_TEST_CAPTURE_TRACKING_VIEW_ +#endif // UI_VIEWS_TEST_CAPTURE_TRACKING_VIEW_H_ diff --git a/ui/views/test/native_widget_factory.cc b/ui/views/test/native_widget_factory.cc new file mode 100644 index 0000000..ae449ab --- /dev/null +++ b/ui/views/test/native_widget_factory.cc @@ -0,0 +1,99 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ui/views/test/native_widget_factory.h" + +#if defined(USE_AURA) +#include "ui/views/widget/native_widget_aura.h" +#if !defined(OS_CHROMEOS) +#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" +#endif +#elif defined(OS_MACOSX) +#include "ui/views/widget/native_widget_mac.h" +#endif + +namespace views { +namespace test { + +#if defined(USE_AURA) +using PlatformNativeWidget = NativeWidgetAura; +#elif defined(OS_MACOSX) +using PlatformNativeWidget = NativeWidgetMac; +#endif + +namespace { + +// NativeWidget implementation that adds the following: +// . capture can be mocked. +// . a boolean is set when the NativeWiget is destroyed. +class TestPlatformNativeWidget : public PlatformNativeWidget { + public: + TestPlatformNativeWidget(internal::NativeWidgetDelegate* delegate, + bool mock_capture, + bool* destroyed); + ~TestPlatformNativeWidget() override; + + void SetCapture() override; + void ReleaseCapture() override; + bool HasCapture() const override; + + private: + bool mouse_capture_; + const bool mock_capture_; + bool* destroyed_; + + DISALLOW_COPY_AND_ASSIGN(TestPlatformNativeWidget); +}; + +// A widget that assumes mouse capture always works. It won't in testing, so we +// mock it. +TestPlatformNativeWidget::TestPlatformNativeWidget( + internal::NativeWidgetDelegate* delegate, + bool mock_capture, + bool* destroyed) + : PlatformNativeWidget(delegate), + mouse_capture_(false), + mock_capture_(mock_capture), + destroyed_(destroyed) {} + +TestPlatformNativeWidget::~TestPlatformNativeWidget() { + if (destroyed_) + *destroyed_ = true; +} + +void TestPlatformNativeWidget::SetCapture() { + if (mock_capture_) + mouse_capture_ = true; + else + PlatformNativeWidget::SetCapture(); +} + +void TestPlatformNativeWidget::ReleaseCapture() { + if (mock_capture_) { + if (mouse_capture_) + delegate()->OnMouseCaptureLost(); + mouse_capture_ = false; + } else { + PlatformNativeWidget::ReleaseCapture(); + } +} + +bool TestPlatformNativeWidget::HasCapture() const { + return mock_capture_ ? mouse_capture_ : PlatformNativeWidget::HasCapture(); +} + +} // namespace + +// Factory methods ------------------------------------------------------------ + +NativeWidget* CreatePlatformNativeWidgetImpl( + const Widget::InitParams& init_params, + Widget* widget, + uint32_t type, + bool* destroyed) { + return new TestPlatformNativeWidget(widget, type == kStubCapture, destroyed); +} + +} // namespace test +} // namespace views diff --git a/ui/views/test/native_widget_factory.h b/ui/views/test/native_widget_factory.h new file mode 100644 index 0000000..ed089b0 --- /dev/null +++ b/ui/views/test/native_widget_factory.h @@ -0,0 +1,46 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_VIEWS_TEST_NATIVE_WIDGET_FACTORY_H_ +#define UI_VIEWS_TEST_NATIVE_WIDGET_FACTORY_H_ + +#include <stdint.h> + +#include "ui/views/widget/widget.h" + +namespace views { + +class NativeWidget; +class Widget; + +namespace test { + +// Values supplied to |behavior|. +// NativeWidget implementation is not customized in anyway. +const uint32_t kDefault = 0u; +// Indicates capture should be mocked out and not interact with the system. +const uint32_t kStubCapture = 1 << 0; + +// Creates the appropriate platform specific NativeWidget implementation. +// If |destroyed| is non-null it it set to true from the destructor of the +// NativeWidget. +NativeWidget* CreatePlatformNativeWidgetImpl( + const Widget::InitParams& init_params, + Widget* widget, + uint32_t behavior, + bool* destroyed); + +// Creates the appropriate desktop platform specific NativeWidget +// implementation. On some platforms this is the same as +// CreatePlatformNativeWidgetImpl(). If |destroyed| is non-null it it set to +// true from the destructor of the NativeWidget. +NativeWidget* CreatePlatformDesktopNativeWidgetImpl( + const Widget::InitParams& init_params, + Widget* widget, + bool* destroyed); + +} // namespace test +} // namespace views + +#endif // UI_VIEWS_TEST_NATIVE_WIDGET_FACTORY_H_ diff --git a/ui/views/test/native_widget_factory_desktop.cc b/ui/views/test/native_widget_factory_desktop.cc new file mode 100644 index 0000000..dfc97ad --- /dev/null +++ b/ui/views/test/native_widget_factory_desktop.cc @@ -0,0 +1,71 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ui/views/test/native_widget_factory.h" + +#if defined(USE_AURA) +#include "ui/views/widget/native_widget_aura.h" +#if !defined(OS_CHROMEOS) +#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" +#endif +#elif defined(OS_MACOSX) +#include "ui/views/widget/native_widget_mac.h" +#endif + +namespace views { +namespace test { + +#if !defined(OS_CHROMEOS) + +#if defined(OS_MACOSX) +using PlatformDesktopNativeWidget = NativeWidgetMac; +#else +using PlatformDesktopNativeWidget = DesktopNativeWidgetAura; +#endif + +namespace { + +class TestPlatformDesktopNativeWidget : public PlatformDesktopNativeWidget { + public: + TestPlatformDesktopNativeWidget(internal::NativeWidgetDelegate* delegate, + bool* destroyed); + ~TestPlatformDesktopNativeWidget() override; + + private: + bool mouse_capture_; + bool* destroyed_; + + DISALLOW_COPY_AND_ASSIGN(TestPlatformDesktopNativeWidget); +}; + +// A widget that assumes mouse capture always works. It won't in testing, so we +// mock it. +TestPlatformDesktopNativeWidget::TestPlatformDesktopNativeWidget( + internal::NativeWidgetDelegate* delegate, + bool* destroyed) + : PlatformDesktopNativeWidget(delegate), destroyed_(destroyed) {} + +TestPlatformDesktopNativeWidget::~TestPlatformDesktopNativeWidget() { + if (destroyed_) + *destroyed_ = true; +} + +} // namespace + +#endif + +NativeWidget* CreatePlatformDesktopNativeWidgetImpl( + const Widget::InitParams& init_params, + Widget* widget, + bool* destroyed) { +#if defined(OS_CHROMEOS) + // Chromeos only has one NativeWidgetType. + return CreatePlatformNativeWidgetImpl(init_params, widget, 0u, destroyed); +#else + return new TestPlatformDesktopNativeWidget(widget, destroyed); +#endif +} + +} // namespace test +} // namespace views diff --git a/ui/views/test/native_widget_factory_mus.cc b/ui/views/test/native_widget_factory_mus.cc new file mode 100644 index 0000000..9469c0c --- /dev/null +++ b/ui/views/test/native_widget_factory_mus.cc @@ -0,0 +1,21 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ui/views/test/native_widget_factory.h" + +#include "ui/views/mus/window_manager_connection.h" + +namespace views { +namespace test { + +NativeWidget* CreatePlatformDesktopNativeWidgetImpl( + const Widget::InitParams& init_params, + Widget* widget, + bool* destroyed) { + return WindowManagerConnection::Get()->CreateNativeWidgetMus( + std::map<std::string, std::vector<uint8_t>>(), init_params, widget); +} + +} // namespace test +} // namespace views diff --git a/ui/views/test/widget_test.cc b/ui/views/test/widget_test.cc index b0db3dd..9beca6d 100644 --- a/ui/views/test/widget_test.cc +++ b/ui/views/test/widget_test.cc @@ -6,66 +6,47 @@ #include "build/build_config.h" #include "ui/gfx/native_widget_types.h" +#include "ui/views/test/native_widget_factory.h" #include "ui/views/widget/root_view.h" namespace views { namespace test { namespace { -// Helper to encapsulate common parts of the WidgetTest::Create* methods, -template <class NativeWidgetType> -Widget* CreateHelper(Widget::InitParams params) { +Widget* CreateTopLevelPlatformWidgetWithStubbedCapture( + ViewsTestBase* test, + Widget::InitParams::Type type) { Widget* widget = new Widget; - params.native_widget = new NativeWidgetType(widget); + Widget::InitParams params = test->CreateParams(type); + params.native_widget = + CreatePlatformNativeWidgetImpl(params, widget, kStubCapture, nullptr); widget->Init(params); return widget; } -Widget* CreateHelper(Widget::InitParams params) { - return CreateHelper<NativeWidgetCapture>(params); -} - } // namespace -// A widget that assumes mouse capture always works. It won't in testing, so we -// mock it. -NativeWidgetCapture::NativeWidgetCapture( - internal::NativeWidgetDelegate* delegate) - : PlatformNativeWidget(delegate), - mouse_capture_(false) {} - -NativeWidgetCapture::~NativeWidgetCapture() {} - -void NativeWidgetCapture::SetCapture() { - mouse_capture_ = true; -} - -void NativeWidgetCapture::ReleaseCapture() { - if (mouse_capture_) - delegate()->OnMouseCaptureLost(); - mouse_capture_ = false; -} - -bool NativeWidgetCapture::HasCapture() const { - return mouse_capture_; -} - WidgetTest::WidgetTest() {} WidgetTest::~WidgetTest() {} Widget* WidgetTest::CreateTopLevelPlatformWidget() { - return CreateHelper(CreateParams(Widget::InitParams::TYPE_WINDOW)); + return CreateTopLevelPlatformWidgetWithStubbedCapture( + this, Widget::InitParams::TYPE_WINDOW); } Widget* WidgetTest::CreateTopLevelFramelessPlatformWidget() { - return CreateHelper(CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS)); + return CreateTopLevelPlatformWidgetWithStubbedCapture( + this, Widget::InitParams::TYPE_WINDOW_FRAMELESS); } Widget* WidgetTest::CreateChildPlatformWidget( gfx::NativeView parent_native_view) { Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_CONTROL); params.parent = parent_native_view; - Widget* child = CreateHelper(params); + Widget* child = new Widget; + params.native_widget = + CreatePlatformNativeWidgetImpl(params, child, kStubCapture, nullptr); + child->Init(params); child->SetContentsView(new View); return child; } @@ -91,13 +72,12 @@ Widget* WidgetTest::CreateChildNativeWidget() { } Widget* WidgetTest::CreateNativeDesktopWidget() { -#if defined(OS_CHROMEOS) - return CreateHelper<PlatformNativeWidget>( - CreateParams(Widget::InitParams::TYPE_WINDOW)); -#else - return CreateHelper<PlatformDesktopNativeWidget>( - CreateParams(Widget::InitParams::TYPE_WINDOW)); -#endif + Widget* widget = new Widget; + Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW); + params.native_widget = + CreatePlatformDesktopNativeWidgetImpl(params, widget, nullptr); + widget->Init(params); + return widget; } View* WidgetTest::GetMousePressedHandler(internal::RootView* root_view) { @@ -124,7 +104,8 @@ TestDesktopWidgetDelegate::~TestDesktopWidgetDelegate() { void TestDesktopWidgetDelegate::InitWidget(Widget::InitParams init_params) { init_params.delegate = this; #if !defined(OS_CHROMEOS) - init_params.native_widget = new PlatformDesktopNativeWidget(widget_); + init_params.native_widget = + CreatePlatformDesktopNativeWidgetImpl(init_params, widget_, nullptr); #endif init_params.bounds = initial_bounds_; widget_->Init(init_params); diff --git a/ui/views/test/widget_test.h b/ui/views/test/widget_test.h index e1eeb76..0eee5ee 100644 --- a/ui/views/test/widget_test.h +++ b/ui/views/test/widget_test.h @@ -11,15 +11,6 @@ #include "ui/views/test/views_test_base.h" #include "ui/views/widget/widget_delegate.h" -#if defined(USE_AURA) -#include "ui/views/widget/native_widget_aura.h" -#if !defined(OS_CHROMEOS) -#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" -#endif -#elif defined(OS_MACOSX) -#include "ui/views/widget/native_widget_mac.h" -#endif - namespace ui { namespace internal { class InputMethodDelegate; @@ -32,16 +23,6 @@ namespace views { class NativeWidget; class Widget; -#if defined(USE_AURA) -typedef NativeWidgetAura PlatformNativeWidget; -#if !defined(OS_CHROMEOS) -typedef DesktopNativeWidgetAura PlatformDesktopNativeWidget; -#endif -#elif defined(OS_MACOSX) -typedef NativeWidgetMac PlatformNativeWidget; -typedef NativeWidgetMac PlatformDesktopNativeWidget; -#endif - namespace internal { class RootView; @@ -50,23 +31,6 @@ class RootView; namespace test { -// A widget that assumes mouse capture always works. It won't on Aura in -// testing, so we mock it. -class NativeWidgetCapture : public PlatformNativeWidget { - public: - explicit NativeWidgetCapture(internal::NativeWidgetDelegate* delegate); - ~NativeWidgetCapture() override; - - void SetCapture() override; - void ReleaseCapture() override; - bool HasCapture() const override; - - private: - bool mouse_capture_; - - DISALLOW_COPY_AND_ASSIGN(NativeWidgetCapture); -}; - class WidgetTest : public ViewsTestBase { public: // Scoped handle that fakes all widgets into claiming they are active. This @@ -88,7 +52,7 @@ class WidgetTest : public ViewsTestBase { ~WidgetTest() override; // Create Widgets with |native_widget| in InitParams set to an instance of - // test::NativeWidgetCapture. + // platform specific widget type that has stubbled capture calls. Widget* CreateTopLevelPlatformWidget(); Widget* CreateTopLevelFramelessPlatformWidget(); Widget* CreateChildPlatformWidget(gfx::NativeView parent_native_view); diff --git a/ui/views/test/widget_test_aura.cc b/ui/views/test/widget_test_aura.cc index 0a76030..5e06892 100644 --- a/ui/views/test/widget_test_aura.cc +++ b/ui/views/test/widget_test_aura.cc @@ -15,6 +15,11 @@ #include "ui/gfx/x/x11_types.h" #endif +#if defined(USE_AURA) +#include "ui/aura/window.h" +#include "ui/aura/window_delegate.h" +#endif + namespace views { namespace test { diff --git a/ui/views/test/widget_test_mac.mm b/ui/views/test/widget_test_mac.mm index a4e1345..47a88e5 100644 --- a/ui/views/test/widget_test_mac.mm +++ b/ui/views/test/widget_test_mac.mm @@ -10,6 +10,7 @@ #import "base/mac/scoped_objc_class_swizzler.h" #include "base/macros.h" #import "ui/views/cocoa/bridged_native_widget.h" +#include "ui/views/widget/native_widget_mac.h" #include "ui/views/widget/root_view.h" @interface IsKeyWindowDonor : NSObject diff --git a/ui/views/views.gyp b/ui/views/views.gyp index 14d92ce..e137487 100644 --- a/ui/views/views.gyp +++ b/ui/views/views.gyp @@ -502,6 +502,8 @@ 'test/focus_manager_test.h', 'test/menu_runner_test_api.cc', 'test/menu_runner_test_api.h', + 'test/native_widget_factory.cc', + 'test/native_widget_factory.h', 'test/scoped_views_test_helper.cc', 'test/scoped_views_test_helper.h', 'test/slider_test_api.cc', @@ -817,10 +819,10 @@ ], 'sources': [ '<@(views_test_support_sources)', - # These two sources are not listed in views_test_support_sources as - # they are not used by the gn target that pulls in - # views_test_support_sources. + # These are not listed in views_test_support_sources as they are not + # used by the gn target that pulls in views_test_support_sources. 'test/default_platform_test_helper.cc', + 'test/native_widget_factory_desktop.cc', 'test/platform_test_helper.h', ], 'conditions': [ diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura_unittest.cc b/ui/views/widget/desktop_aura/desktop_native_widget_aura_unittest.cc index 8c638ae..7c69e3f 100644 --- a/ui/views/widget/desktop_aura/desktop_native_widget_aura_unittest.cc +++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura_unittest.cc @@ -18,6 +18,7 @@ #include "ui/events/event_utils.h" #include "ui/events/test/event_generator.h" #include "ui/gfx/screen.h" +#include "ui/views/test/native_widget_factory.h" #include "ui/views/test/test_views.h" #include "ui/views/test/test_views_delegate.h" #include "ui/views/test/views_test_base.h" @@ -486,7 +487,8 @@ void RunCloseWidgetDuringDispatchTest(WidgetTest* test, Widget* widget = new Widget; Widget::InitParams params = test->CreateParams(Widget::InitParams::TYPE_POPUP); - params.native_widget = new PlatformDesktopNativeWidget(widget); + params.native_widget = + CreatePlatformDesktopNativeWidgetImpl(params, widget, nullptr); params.bounds = gfx::Rect(0, 0, 50, 100); widget->Init(params); widget->SetContentsView(new CloseWidgetView(last_event_type)); @@ -528,8 +530,8 @@ TEST_F(WidgetTest, WindowMouseModalityTest) { gfx::Rect initial_bounds(0, 0, 500, 500); init_params.bounds = initial_bounds; init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; - init_params.native_widget = - new PlatformDesktopNativeWidget(&top_level_widget); + init_params.native_widget = CreatePlatformDesktopNativeWidgetImpl( + init_params, &top_level_widget, nullptr); top_level_widget.Init(init_params); top_level_widget.Show(); EXPECT_TRUE(top_level_widget.IsVisible()); diff --git a/ui/views/widget/desktop_widget_unittest.cc b/ui/views/widget/desktop_widget_unittest.cc index 6bd67c6..0004cca 100644 --- a/ui/views/widget/desktop_widget_unittest.cc +++ b/ui/views/widget/desktop_widget_unittest.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "ui/views/test/native_widget_factory.h" #include "ui/views/test/views_test_base.h" #include "ui/views/test/widget_test.h" #include "ui/views/widget/widget.h" @@ -18,7 +19,8 @@ TEST_F(DesktopScreenPositionClientTest, PositionDialog) { Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW); params.bounds = gfx::Rect(10, 11, 200, 200); params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; - params.native_widget = new PlatformDesktopNativeWidget(&parent_widget); + params.native_widget = test::CreatePlatformDesktopNativeWidgetImpl( + params, &parent_widget, nullptr); parent_widget.Init(params); // Owned by |dialog|. @@ -52,7 +54,8 @@ TEST_F(DesktopScreenPositionClientTest, PositionControlWithNonRootParent) { CreateParams(Widget::InitParams::TYPE_WINDOW); params1.bounds = gfx::Rect(origin, gfx::Size(700, 600)); params1.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; - params1.native_widget = new PlatformDesktopNativeWidget(&widget1); + params1.native_widget = + test::CreatePlatformDesktopNativeWidgetImpl(params1, &widget1, nullptr); widget1.Init(params1); Widget::InitParams params2 = diff --git a/ui/views/widget/native_widget_mac_unittest.mm b/ui/views/widget/native_widget_mac_unittest.mm index 24b00dd..8526aee 100644 --- a/ui/views/widget/native_widget_mac_unittest.mm +++ b/ui/views/widget/native_widget_mac_unittest.mm @@ -28,6 +28,7 @@ #include "ui/views/controls/button/label_button.h" #include "ui/views/controls/label.h" #include "ui/views/native_cursor.h" +#include "ui/views/test/native_widget_factory.h" #include "ui/views/test/test_widget_observer.h" #include "ui/views/test/widget_test.h" #include "ui/views/widget/native_widget_private.h" @@ -945,7 +946,9 @@ class ParentCloseMonitor : public WidgetObserver { Widget::InitParams init_params(Widget::InitParams::TYPE_WINDOW_FRAMELESS); init_params.parent = parent->GetNativeView(); init_params.bounds = gfx::Rect(100, 100, 100, 100); - init_params.native_widget = new NativeWidgetCapture(child); + init_params.native_widget = + CreatePlatformNativeWidgetImpl(init_params, child, kStubCapture, + nullptr); child->Init(init_params); child->Show(); @@ -1109,7 +1112,8 @@ TEST_F(NativeWidgetMacTest, DoesHideTitle) { // Same as CreateTopLevelPlatformWidget but with a custom delegate. Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW); Widget* widget = new Widget; - params.native_widget = new NativeWidgetCapture(widget); + params.native_widget = + CreatePlatformNativeWidgetImpl(params, widget, kStubCapture, nullptr); CustomTitleWidgetDelegate delegate(widget); params.delegate = &delegate; params.bounds = gfx::Rect(0, 0, 800, 600); diff --git a/ui/views/widget/widget_interactive_uitest.cc b/ui/views/widget/widget_interactive_uitest.cc index 50a5763..d077c3d 100644 --- a/ui/views/widget/widget_interactive_uitest.cc +++ b/ui/views/widget/widget_interactive_uitest.cc @@ -26,6 +26,7 @@ #include "ui/views/controls/textfield/textfield_test_api.h" #include "ui/views/focus/focus_manager.h" #include "ui/views/test/focus_manager_test.h" +#include "ui/views/test/native_widget_factory.h" #include "ui/views/test/widget_test.h" #include "ui/views/touchui/touch_selection_controller_impl.h" #include "ui/views/widget/widget.h" @@ -838,8 +839,8 @@ TEST_F(WidgetTestInteractive, WindowModalWindowDestroyedActivationTest) { gfx::Rect initial_bounds(0, 0, 500, 500); init_params.bounds = initial_bounds; init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; - init_params.native_widget = - new PlatformDesktopNativeWidget(&top_level_widget); + init_params.native_widget = CreatePlatformDesktopNativeWidgetImpl( + init_params, &top_level_widget, nullptr); top_level_widget.Init(init_params); ShowSync(&top_level_widget); @@ -907,8 +908,8 @@ TEST_F(WidgetTestInteractive, MAYBE_SystemModalWindowReleasesCapture) { gfx::Rect initial_bounds(0, 0, 500, 500); init_params.bounds = initial_bounds; init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; - init_params.native_widget = - new PlatformDesktopNativeWidget(&top_level_widget); + init_params.native_widget = CreatePlatformDesktopNativeWidgetImpl( + init_params, &top_level_widget, nullptr); top_level_widget.Init(init_params); ShowSync(&top_level_widget); @@ -945,9 +946,8 @@ TEST_F(WidgetTestInteractive, CanActivateFlagIsHonored) { init_params.bounds = gfx::Rect(0, 0, 200, 200); init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; init_params.activatable = Widget::InitParams::ACTIVATABLE_NO; -#if !defined(OS_CHROMEOS) - init_params.native_widget = new PlatformDesktopNativeWidget(&widget); -#endif // !defined(OS_CHROMEOS) + init_params.native_widget = + CreatePlatformDesktopNativeWidgetImpl(init_params, &widget, nullptr); widget.Init(init_params); widget.Show(); @@ -1112,7 +1112,8 @@ TEST_F(WidgetTestInteractive, InactiveWidgetDoesNotGrabActivation) { Widget widget2; Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); - params.native_widget = new PlatformDesktopNativeWidget(&widget2); + params.native_widget = + CreatePlatformDesktopNativeWidgetImpl(params, &widget2, nullptr); params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; widget2.Init(params); widget2.Show(); @@ -1272,8 +1273,8 @@ class WidgetCaptureTest : public ViewsTestBase { CaptureLostTrackingWidget widget1; Widget::InitParams params1 = CreateParams(views::Widget::InitParams::TYPE_WINDOW); - params1.native_widget = CreateNativeWidget(use_desktop_native_widget, - &widget1); + params1.native_widget = + CreateNativeWidget(params1, use_desktop_native_widget, &widget1); params1.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; widget1.Init(params1); widget1.Show(); @@ -1282,8 +1283,8 @@ class WidgetCaptureTest : public ViewsTestBase { Widget::InitParams params2 = CreateParams(views::Widget::InitParams::TYPE_WINDOW); params2.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; - params2.native_widget = CreateNativeWidget(use_desktop_native_widget, - &widget2); + params2.native_widget = + CreateNativeWidget(params2, use_desktop_native_widget, &widget2); widget2.Init(params2); widget2.Show(); @@ -1309,13 +1310,12 @@ class WidgetCaptureTest : public ViewsTestBase { EXPECT_FALSE(widget2.GetAndClearGotCaptureLost()); } - NativeWidget* CreateNativeWidget(bool create_desktop_native_widget, + NativeWidget* CreateNativeWidget(const Widget::InitParams& params, + bool create_desktop_native_widget, Widget* widget) { -#if !defined(OS_CHROMEOS) if (create_desktop_native_widget) - return new PlatformDesktopNativeWidget(widget); -#endif - return NULL; + return CreatePlatformDesktopNativeWidgetImpl(params, widget, nullptr); + return CreatePlatformNativeWidgetImpl(params, widget, kDefault, nullptr); } private: @@ -1381,7 +1381,7 @@ TEST_F(WidgetCaptureTest, MAYBE_MouseExitOnCaptureGrab) { Widget widget1; Widget::InitParams params1 = CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS); - params1.native_widget = CreateNativeWidget(true, &widget1); + params1.native_widget = CreateNativeWidget(params1, true, &widget1); params1.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; widget1.Init(params1); MouseView* mouse_view1 = new MouseView; @@ -1392,7 +1392,7 @@ TEST_F(WidgetCaptureTest, MAYBE_MouseExitOnCaptureGrab) { Widget widget2; Widget::InitParams params2 = CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS); - params2.native_widget = CreateNativeWidget(true, &widget2); + params2.native_widget = CreateNativeWidget(params2, true, &widget2); params2.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; widget2.Init(params2); widget2.Show(); @@ -1444,7 +1444,8 @@ TEST_F(WidgetCaptureTest, SetCaptureToNonToplevel) { Widget toplevel; Widget::InitParams toplevel_params = CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS); - toplevel_params.native_widget = CreateNativeWidget(true, &toplevel); + toplevel_params.native_widget = CreateNativeWidget(toplevel_params, true, + &toplevel); toplevel_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; toplevel.Init(toplevel_params); toplevel.Show(); diff --git a/ui/views/widget/widget_unittest.cc b/ui/views/widget/widget_unittest.cc index 1ca9e88..a7ab121 100644 --- a/ui/views/widget/widget_unittest.cc +++ b/ui/views/widget/widget_unittest.cc @@ -23,10 +23,12 @@ #include "ui/gfx/native_widget_types.h" #include "ui/views/bubble/bubble_delegate.h" #include "ui/views/controls/textfield/textfield.h" +#include "ui/views/test/native_widget_factory.h" #include "ui/views/test/test_views.h" #include "ui/views/test/test_widget_observer.h" #include "ui/views/test/widget_test.h" #include "ui/views/widget/native_widget_delegate.h" +#include "ui/views/widget/native_widget_private.h" #include "ui/views/widget/root_view.h" #include "ui/views/widget/widget_deletion_observer.h" #include "ui/views/widget/widget_removals_observer.h" @@ -368,44 +370,6 @@ struct OwnershipTestState { bool native_widget_deleted; }; -// A platform NativeWidget subclass that updates a bag of state when it is -// destroyed. -class OwnershipTestNativeWidget : public PlatformNativeWidget { - public: - OwnershipTestNativeWidget(internal::NativeWidgetDelegate* delegate, - OwnershipTestState* state) - : PlatformNativeWidget(delegate), - state_(state) { - } - ~OwnershipTestNativeWidget() override { - state_->native_widget_deleted = true; - } - - private: - OwnershipTestState* state_; - - DISALLOW_COPY_AND_ASSIGN(OwnershipTestNativeWidget); -}; - -// A views NativeWidget subclass that updates a bag of state when it is -// destroyed. -class OwnershipTestNativeWidgetAura : public NativeWidgetCapture { - public: - OwnershipTestNativeWidgetAura(internal::NativeWidgetDelegate* delegate, - OwnershipTestState* state) - : NativeWidgetCapture(delegate), - state_(state) { - } - ~OwnershipTestNativeWidgetAura() override { - state_->native_widget_deleted = true; - } - - private: - OwnershipTestState* state_; - - DISALLOW_COPY_AND_ASSIGN(OwnershipTestNativeWidgetAura); -}; - // A Widget subclass that updates a bag of state when it is destroyed. class OwnershipTestWidget : public Widget { public: @@ -418,6 +382,8 @@ class OwnershipTestWidget : public Widget { DISALLOW_COPY_AND_ASSIGN(OwnershipTestWidget); }; +// TODO(sky): add coverage of ownership for the desktop variants. + // Widget owns its NativeWidget, part 1: NativeWidget is a platform-native // widget. TEST_F(WidgetOwnershipTest, Ownership_WidgetOwnsPlatformNativeWidget) { @@ -425,8 +391,8 @@ TEST_F(WidgetOwnershipTest, Ownership_WidgetOwnsPlatformNativeWidget) { scoped_ptr<Widget> widget(new OwnershipTestWidget(&state)); Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); - params.native_widget = - new OwnershipTestNativeWidgetAura(widget.get(), &state); + params.native_widget = CreatePlatformNativeWidgetImpl( + params, widget.get(), kStubCapture, &state.native_widget_deleted); params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; widget->Init(params); @@ -446,8 +412,8 @@ TEST_F(WidgetOwnershipTest, Ownership_WidgetOwnsViewsNativeWidget) { scoped_ptr<Widget> widget(new OwnershipTestWidget(&state)); Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); - params.native_widget = - new OwnershipTestNativeWidgetAura(widget.get(), &state); + params.native_widget = CreatePlatformNativeWidgetImpl( + params, widget.get(), kStubCapture, &state.native_widget_deleted); params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; widget->Init(params); @@ -471,9 +437,9 @@ TEST_F(WidgetOwnershipTest, scoped_ptr<Widget> widget(new OwnershipTestWidget(&state)); Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); - params.native_widget = - new OwnershipTestNativeWidgetAura(widget.get(), &state); params.parent = toplevel->GetNativeView(); + params.native_widget = CreatePlatformNativeWidgetImpl( + params, widget.get(), kStubCapture, &state.native_widget_deleted); params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; widget->Init(params); @@ -501,8 +467,8 @@ TEST_F(WidgetOwnershipTest, Ownership_PlatformNativeWidgetOwnsWidget) { Widget* widget = new OwnershipTestWidget(&state); Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); - params.native_widget = - new OwnershipTestNativeWidgetAura(widget, &state); + params.native_widget = CreatePlatformNativeWidgetImpl( + params, widget, kStubCapture, &state.native_widget_deleted); widget->Init(params); // Now destroy the native widget. @@ -520,9 +486,9 @@ TEST_F(WidgetOwnershipTest, Ownership_ViewsNativeWidgetOwnsWidget) { Widget* widget = new OwnershipTestWidget(&state); Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); - params.native_widget = - new OwnershipTestNativeWidgetAura(widget, &state); params.parent = toplevel->GetNativeView(); + params.native_widget = CreatePlatformNativeWidgetImpl( + params, widget, kStubCapture, &state.native_widget_deleted); widget->Init(params); // Now destroy the native widget. This is achieved by closing the toplevel. @@ -544,8 +510,8 @@ TEST_F(WidgetOwnershipTest, Widget* widget = new OwnershipTestWidget(&state); Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); - params.native_widget = - new OwnershipTestNativeWidgetAura(widget, &state); + params.native_widget = CreatePlatformNativeWidgetImpl( + params, widget, kStubCapture, &state.native_widget_deleted); widget->Init(params); // Now simulate a destroy of the platform native widget from the OS: @@ -565,9 +531,9 @@ TEST_F(WidgetOwnershipTest, Widget* widget = new OwnershipTestWidget(&state); Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); - params.native_widget = - new OwnershipTestNativeWidgetAura(widget, &state); params.parent = toplevel->GetNativeView(); + params.native_widget = CreatePlatformNativeWidgetImpl( + params, widget, kStubCapture, &state.native_widget_deleted); widget->Init(params); // Destroy the widget (achieved by closing the toplevel). @@ -591,9 +557,9 @@ TEST_F(WidgetOwnershipTest, Widget* widget = new OwnershipTestWidget(&state); Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); - params.native_widget = - new OwnershipTestNativeWidgetAura(widget, &state); params.parent = toplevel->GetNativeView(); + params.native_widget = CreatePlatformNativeWidgetImpl( + params, widget, kStubCapture, &state.native_widget_deleted); widget->Init(params); // Destroy the widget. @@ -617,8 +583,8 @@ TEST_F(WidgetOwnershipTest, scoped_ptr<Widget> widget(new OwnershipTestWidget(&state)); Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); - params.native_widget = - new OwnershipTestNativeWidgetAura(widget.get(), &state); + params.native_widget = CreatePlatformNativeWidgetImpl( + params, widget.get(), kStubCapture, &state.native_widget_deleted); params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; params.delegate = delegate_view; widget->Init(params); @@ -707,7 +673,8 @@ TEST_F(WidgetWithDestroyedNativeViewTest, Test) { { Widget widget; Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); - params.native_widget = new PlatformDesktopNativeWidget(&widget); + params.native_widget = + CreatePlatformDesktopNativeWidgetImpl(params, &widget, nullptr); params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; widget.Init(params); widget.Show(); @@ -1240,7 +1207,8 @@ TEST_F(WidgetTest, DISABLED_FocusChangesOnBubble) { init_params.bounds = gfx::Rect(0, 0, 200, 200); init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; #if !defined(OS_CHROMEOS) - init_params.native_widget = new PlatformDesktopNativeWidget(&widget); + init_params.native_widget = + CreatePlatformDesktopNativeWidgetImpl(init_params, &widget, nullptr); #endif widget.Init(init_params); widget.SetContentsView(contents_view); @@ -1310,7 +1278,8 @@ TEST_F(WidgetTest, TestViewWidthAfterMinimizingWidget) { gfx::Rect initial_bounds(0, 0, 300, 400); init_params.bounds = initial_bounds; init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; - init_params.native_widget = new PlatformDesktopNativeWidget(&widget); + init_params.native_widget = + CreatePlatformDesktopNativeWidgetImpl(init_params, &widget, nullptr); widget.Init(init_params); NonClientView* non_client_view = widget.non_client_view(); NonClientFrameView* frame_view = new MinimumSizeFrameView(&widget); @@ -1384,7 +1353,8 @@ class DesktopAuraTestValidPaintWidget : public views::Widget { void DesktopAuraTestValidPaintWidget::InitForTest(InitParams init_params) { init_params.bounds = gfx::Rect(0, 0, 200, 200); init_params.ownership = InitParams::WIDGET_OWNS_NATIVE_WIDGET; - init_params.native_widget = new PlatformDesktopNativeWidget(this); + init_params.native_widget = + CreatePlatformDesktopNativeWidgetImpl(init_params, this, nullptr); Init(init_params); View* contents_view = new View; @@ -1431,7 +1401,8 @@ TEST_F(WidgetTest, TestWindowVisibilityAfterHide) { gfx::Rect initial_bounds(0, 0, 300, 400); init_params.bounds = initial_bounds; init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; - init_params.native_widget = new PlatformDesktopNativeWidget(&widget); + init_params.native_widget = + CreatePlatformDesktopNativeWidgetImpl(init_params, &widget, nullptr); widget.Init(init_params); NonClientView* non_client_view = widget.non_client_view(); NonClientFrameView* frame_view = new MinimumSizeFrameView(&widget); @@ -1776,7 +1747,8 @@ class WidgetWindowTitleTest : public WidgetTest { #if !defined(OS_CHROMEOS) if (desktop_native_widget) - init_params.native_widget = new PlatformDesktopNativeWidget(widget.get()); + init_params.native_widget = CreatePlatformDesktopNativeWidgetImpl( + init_params, widget.get(), nullptr); #else DCHECK(!desktop_native_widget) << "DesktopNativeWidget does not exist on non-Aura or on ChromeOS."; @@ -1896,7 +1868,8 @@ bool RunGetNativeThemeFromDestructor(const Widget::InitParams& in_params, params.delegate = new GetNativeThemeFromDestructorView; #if !defined(OS_CHROMEOS) if (is_first_run) { - params.native_widget = new PlatformDesktopNativeWidget(widget.get()); + params.native_widget = + CreatePlatformDesktopNativeWidgetImpl(params, widget.get(), nullptr); needs_second_run = true; } #endif @@ -1980,7 +1953,8 @@ TEST_F(WidgetTest, CloseDestroys) { CreateParams(views::Widget::InitParams::TYPE_MENU); params.opacity = Widget::InitParams::OPAQUE_WINDOW; #if !defined(OS_CHROMEOS) - params.native_widget = new PlatformDesktopNativeWidget(widget); + params.native_widget = + CreatePlatformDesktopNativeWidgetImpl(params, widget, nullptr); #endif widget->Init(params); widget->Show(); @@ -2907,8 +2881,10 @@ class WidgetChildDestructionTest : public WidgetTest { Widget::InitParams params = CreateParams(views::Widget::InitParams::TYPE_WINDOW); #if !defined(OS_CHROMEOS) - if (top_level_has_desktop_native_widget_aura) - params.native_widget = new PlatformDesktopNativeWidget(top_level); + if (top_level_has_desktop_native_widget_aura) { + params.native_widget = + CreatePlatformDesktopNativeWidgetImpl(params, top_level, nullptr); + } #endif top_level->Init(params); top_level->GetRootView()->AddChildView( @@ -2920,8 +2896,10 @@ class WidgetChildDestructionTest : public WidgetTest { CreateParams(views::Widget::InitParams::TYPE_POPUP); child_params.parent = top_level->GetNativeView(); #if !defined(OS_CHROMEOS) - if (child_has_desktop_native_widget_aura) - child_params.native_widget = new PlatformDesktopNativeWidget(child); + if (child_has_desktop_native_widget_aura) { + child_params.native_widget = + CreatePlatformDesktopNativeWidgetImpl(child_params, child, nullptr); + } #endif child->Init(child_params); child->GetRootView()->AddChildView( @@ -2982,8 +2960,8 @@ TEST_F(WidgetTest, FullscreenStatePropagated) { #if !defined(OS_CHROMEOS) { Widget top_level_widget; - init_params.native_widget = - new PlatformDesktopNativeWidget(&top_level_widget); + init_params.native_widget = CreatePlatformDesktopNativeWidgetImpl( + init_params, &top_level_widget, nullptr); top_level_widget.Init(init_params); top_level_widget.SetFullscreen(true); EXPECT_EQ(top_level_widget.IsVisible(), @@ -3079,7 +3057,8 @@ TEST_F(WidgetTest, IsActiveFromDestroy) { Widget parent_widget; Widget::InitParams parent_params = CreateParams(Widget::InitParams::TYPE_POPUP); - parent_params.native_widget = new PlatformDesktopNativeWidget(&parent_widget); + parent_params.native_widget = CreatePlatformDesktopNativeWidgetImpl( + parent_params, &parent_widget, nullptr); parent_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; parent_widget.Init(parent_params); parent_widget.Show(); @@ -3192,7 +3171,8 @@ TEST_F(WidgetTest, CharMessagesAsKeyboardMessagesDoesNotCrash) { Widget widget; Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW); - params.native_widget = new PlatformDesktopNativeWidget(&widget); + params.native_widget = + CreatePlatformDesktopNativeWidgetImpl(params, &widget, nullptr); params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; widget.Init(params); widget.Show(); @@ -3294,7 +3274,8 @@ TEST_F(WidgetTest, SysCommandMoveOnNCLButtonDownOnCaptionAndMoveTest) { Widget widget; Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW); - params.native_widget = new PlatformDesktopNativeWidget(&widget); + params.native_widget = + CreatePlatformDesktopNativeWidgetImpl(params, &widget, nullptr); params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; widget.Init(params); widget.SetBounds(gfx::Rect(0, 0, 200, 200)); @@ -3366,7 +3347,8 @@ TEST_F(WidgetTest, DestroyInSysCommandNCLButtonDownOnCaption) { Widget widget; Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW); - params.native_widget = new PlatformDesktopNativeWidget(&widget); + params.native_widget = + CreatePlatformDesktopNativeWidgetImpl(params, &widget, nullptr); params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; widget.Init(params); widget.SetBounds(gfx::Rect(0, 0, 200, 200)); |