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

Scope usage of TestScreen in an omnibox test more narrowly.

Setting up TestScreen too early causes problems with AshTestHelper,
which I'll be enabling soon for ChromeViewsTestBase.  This restricts
it to only be alive for a narrow window of time.

Bug: none
Change-Id: If6d3b059175cf438a3df00469a8406d24a66b5a6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2132971
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Commit-Queue: Tommy Li <tommycli@chromium.org>
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#755561}
parent 00ac0b2a
......@@ -60,6 +60,14 @@ class OmniboxResultViewTest : public ChromeViewsTestBase {
// Create a widget and assign bounds to support calls to HitTestPoint.
widget_ = CreateTestWidget();
// Install |test_screen_| after superclass setup and widget creation; on Ash
// both these require the Screen to work well with the underlying Shell, and
// TestScreen has no knowledge of that.
test_screen_ = std::make_unique<display::test::TestScreen>();
scoped_screen_override_ =
std::make_unique<display::test::ScopedScreenOverride>(
test_screen_.get());
edit_model_ = std::make_unique<OmniboxEditModel>(
nullptr, nullptr, std::make_unique<TestOmniboxClient>());
popup_view_ =
......@@ -77,6 +85,8 @@ class OmniboxResultViewTest : public ChromeViewsTestBase {
}
void TearDown() override {
scoped_screen_override_.reset();
test_screen_.reset();
widget_.reset();
ChromeViewsTestBase::TearDown();
}
......@@ -91,7 +101,7 @@ class OmniboxResultViewTest : public ChromeViewsTestBase {
int flags,
float x,
float y) {
test_screen_.set_cursor_screen_point(gfx::Point(x, y));
test_screen_->set_cursor_screen_point(gfx::Point(x, y));
return ui::MouseEvent(type, gfx::Point(x, y), gfx::Point(),
ui::EventTimeForNow(), flags, 0);
}
......@@ -105,8 +115,8 @@ class OmniboxResultViewTest : public ChromeViewsTestBase {
OmniboxResultView* result_view_;
std::unique_ptr<views::Widget> widget_;
display::test::TestScreen test_screen_;
display::test::ScopedScreenOverride scoped_screen_override_{&test_screen_};
std::unique_ptr<display::test::TestScreen> test_screen_;
std::unique_ptr<display::test::ScopedScreenOverride> scoped_screen_override_;
};
TEST_F(OmniboxResultViewTest, MousePressedWithLeftButtonSelectsThisResult) {
......
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