Commit 79376c45 authored by Vladislav Kaznacheev's avatar Vladislav Kaznacheev Committed by Commit Bot

Increase coverage in MenuControllerTest.TestSubmenuFitsOnScreen

The tests submitted with the original CL (crrev.com/c/1790475) did not
exercise every new code path. This CL fixes that.

Also added SetRTLForTesting(false) to TearDown to avoid affecting
the global environment.

Bug: 991227
Test: MenuControllerTest
Change-Id: I80c1d1089cd8032c67b4d046fa61a64ec1db6afc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1808090Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Vladislav Kaznacheev <kaznacheev@chromium.org>
Cr-Commit-Position: refs/heads/master@{#697093}
parent c6edebc2
......@@ -365,6 +365,7 @@ class MenuControllerTest : public ViewsTestBase,
owner_->CloseNow();
DestroyMenuController();
ViewsTestBase::TearDown();
base::i18n::SetRTLForTesting(false);
}
void ReleaseTouchId(int id) { event_generator_->ReleaseTouchId(id); }
......@@ -1862,9 +1863,10 @@ TEST_P(MenuControllerTest, TestSubmenuFitsOnScreen) {
const int menu_width = MenuConfig::instance().touchable_menu_width;
const gfx::Size parent_size(menu_width, menu_width);
const gfx::Size parent_size_wide(menu_width * 2, menu_width);
const int kDisplayWidth = parent_size.width() * 2;
const int kDisplayHeight = parent_size.height() * 2;
const int kDisplayWidth = parent_size.width() * 3;
const int kDisplayHeight = parent_size.height() * 3;
// Simulate multiple display layouts.
for (int x = -1; x <= 1; x++)
......@@ -1875,6 +1877,7 @@ TEST_P(MenuControllerTest, TestSubmenuFitsOnScreen) {
const int x_min = monitor_bounds.x();
const int x_max = monitor_bounds.right() - parent_size.width();
const int x_mid = (x_min + x_max) / 2;
const int x_qtr = x_min + (x_max - x_min) / 4;
const int y_min = monitor_bounds.y();
const int y_max = monitor_bounds.bottom() - parent_size.height();
......@@ -1890,6 +1893,11 @@ TEST_P(MenuControllerTest, TestSubmenuFitsOnScreen) {
gfx::Rect(gfx::Point(x_min, y_mid), parent_size));
TestSubmenuFitsOnScreen(sub_item, monitor_bounds,
gfx::Rect(gfx::Point(x_min, y_max), parent_size));
// Extra wide menu: test with insufficient room on both sides.
TestSubmenuFitsOnScreen(
sub_item, monitor_bounds,
gfx::Rect(gfx::Point(x_qtr, y_min), parent_size_wide));
}
}
......
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