Commit fc95355a authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Introduce ViewsTestBase::AllocateTestWidget().

This provides a customization point for subclasses to override, to
change the Widget subclass that's instantiated by CreateTestWidget().
This will be necessary to remove DefaultThemeProvider, because
ChromeViewsTestBase will need to provide widgets with a non-null
ThemeProvider at that point, and subclassing Widget is the only way to
do so.

Bug: none
Change-Id: I9057301e2a86449832e036ce943d595e56954e74
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2143518
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Commit-Queue: Thomas Lukaszewicz <tluk@chromium.org>
Reviewed-by: default avatarThomas Lukaszewicz <tluk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#757880}
parent 417c3a99
......@@ -132,7 +132,7 @@ Widget::InitParams ViewsTestBase::CreateParams(Widget::InitParams::Type type) {
std::unique_ptr<Widget> ViewsTestBase::CreateTestWidget(
Widget::InitParams::Type type) {
Widget::InitParams params = CreateParamsForTestWidget(type);
auto widget = std::make_unique<Widget>();
std::unique_ptr<Widget> widget = AllocateTestWidget();
widget->Init(std::move(params));
return widget;
}
......@@ -183,6 +183,10 @@ NativeWidget* ViewsTestBase::CreateNativeWidgetForTest(
#endif
}
std::unique_ptr<Widget> ViewsTestBase::AllocateTestWidget() {
return std::make_unique<Widget>();
}
Widget::InitParams ViewsTestBase::CreateParamsForTestWidget(
Widget::InitParams::Type type) {
Widget::InitParams params = CreateParams(type);
......
......@@ -121,6 +121,11 @@ class ViewsTestBase : public PlatformTest {
const Widget::InitParams& init_params,
internal::NativeWidgetDelegate* delegate);
// Instantiates a Widget for CreateTestWidget(), but does no other
// initialization. Overriding this allows subclasses to customize the Widget
// subclass returned from CreateTestWidget().
virtual std::unique_ptr<Widget> AllocateTestWidget();
Widget::InitParams CreateParamsForTestWidget(
Widget::InitParams::Type type =
Widget::InitParams::TYPE_WINDOW_FRAMELESS);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment