| Index: chrome/browser/ui/autofill/popup_controller_common_unittest.cc
|
| diff --git a/chrome/browser/ui/autofill/popup_controller_common_unittest.cc b/chrome/browser/ui/autofill/popup_controller_common_unittest.cc
|
| index df41106bf1ce6c75b761bd5c70dc047b7211404e..5e755ae713f7e8df732e97c900a80d563e112520 100644
|
| --- a/chrome/browser/ui/autofill/popup_controller_common_unittest.cc
|
| +++ b/chrome/browser/ui/autofill/popup_controller_common_unittest.cc
|
| @@ -29,56 +29,62 @@ TEST_F(PopupControllerBaseTest, GetPopupBoundsTest) {
|
| gfx::Display display(0,
|
| gfx::Rect(0, 0, 2 * desired_width, 2 * desired_height));
|
|
|
| - // Store the possible element bounds and the popup bounds they should result
|
| - // in.
|
| - std::vector<gfx::RectF> element_bounds;
|
| - std::vector<gfx::Rect> expected_popup_bounds;
|
| -
|
| - // The popup grows down and to the right.
|
| - element_bounds.push_back(gfx::RectF(0, 0, 0, 0));
|
| - expected_popup_bounds.push_back(
|
| - gfx::Rect(0, 0, desired_width, desired_height));
|
| -
|
| - // The popup grows down and to the left.
|
| - element_bounds.push_back(gfx::RectF(2 * desired_width, 0, 0, 0));
|
| - expected_popup_bounds.push_back(
|
| - gfx::Rect(desired_width, 0, desired_width, desired_height));
|
| -
|
| - // The popup grows up and to the right.
|
| - element_bounds.push_back(gfx::RectF(0, 2 * desired_height, 0, 0));
|
| - expected_popup_bounds.push_back(
|
| - gfx::Rect(0, desired_height, desired_width, desired_height));
|
| -
|
| - // The popup grows up and to the left.
|
| - element_bounds.push_back(
|
| - gfx::RectF(2 * desired_width, 2 * desired_height, 0, 0));
|
| - expected_popup_bounds.push_back(
|
| - gfx::Rect(desired_width, desired_height, desired_width, desired_height));
|
| -
|
| - // The popup would be partial off the top and left side of the screen.
|
| - element_bounds.push_back(
|
| - gfx::RectF(-desired_width / 2, -desired_height / 2, 0, 0));
|
| - expected_popup_bounds.push_back(
|
| - gfx::Rect(0, 0, desired_width, desired_height));
|
| -
|
| - // The popup would be partially off the bottom and the right side of
|
| - // the screen.
|
| - element_bounds.push_back(
|
| - gfx::RectF(desired_width * 1.5, desired_height * 1.5, 0, 0));
|
| - expected_popup_bounds.push_back(
|
| - gfx::Rect((desired_width + 1) / 2, (desired_height + 1) / 2,
|
| - desired_width, desired_height));
|
| -
|
| - for (size_t i = 0; i < element_bounds.size(); ++i) {
|
| + struct {
|
| + gfx::RectF element_bounds;
|
| + gfx::Rect expected_popup_bounds_ltr;
|
| + // Non-empty only when it differs from the ltr expectation.
|
| + gfx::Rect expected_popup_bounds_rtl;
|
| + } test_cases[] = {
|
| + // The popup grows down and to the end.
|
| + {gfx::RectF(38, 0, 5, 0),
|
| + gfx::Rect(38, 0, desired_width, desired_height),
|
| + gfx::Rect(3, 0, desired_width, desired_height)},
|
| +
|
| + // The popup grows down and to the left when there's no room on the right.
|
| + {gfx::RectF(2 * desired_width, 0, 5, 0),
|
| + gfx::Rect(desired_width, 0, desired_width, desired_height)},
|
| +
|
| + // The popup grows up and to the right.
|
| + {gfx::RectF(0, 2 * desired_height, 5, 0),
|
| + gfx::Rect(0, desired_height, desired_width, desired_height)},
|
| +
|
| + // The popup grows up and to the left.
|
| + {gfx::RectF(2 * desired_width, 2 * desired_height, 5, 0),
|
| + gfx::Rect(desired_width, desired_height, desired_width, desired_height)},
|
| +
|
| + // The popup would be partial off the top and left side of the screen.
|
| + {gfx::RectF(-desired_width / 2, -desired_height / 2, 5, 0),
|
| + gfx::Rect(0, 0, desired_width, desired_height)},
|
| +
|
| + // The popup would be partially off the bottom and the right side of
|
| + // the screen.
|
| + {gfx::RectF(desired_width * 1.5, desired_height * 1.5, 5, 0),
|
| + gfx::Rect((desired_width * 1.5 + 5 - desired_width),
|
| + (desired_height * 1.5 - desired_height), desired_width,
|
| + desired_height)},
|
| + };
|
| +
|
| + for (size_t i = 0; i < arraysize(test_cases); ++i) {
|
| scoped_ptr<TestPopupControllerCommon> popup_controller(
|
| - new TestPopupControllerCommon(element_bounds[i]));
|
| + new TestPopupControllerCommon(test_cases[i].element_bounds,
|
| + base::i18n::LEFT_TO_RIGHT));
|
| popup_controller->set_display(display);
|
| gfx::Rect actual_popup_bounds =
|
| popup_controller->GetPopupBounds(desired_width, desired_height);
|
| + EXPECT_EQ(test_cases[i].expected_popup_bounds_ltr.ToString(),
|
| + actual_popup_bounds.ToString())
|
| + << "Popup bounds failed to match for ltr test " << i;
|
|
|
| - EXPECT_EQ(expected_popup_bounds[i].ToString(),
|
| - actual_popup_bounds.ToString()) <<
|
| - "Popup bounds failed to match for test " << i;
|
| + popup_controller.reset(new TestPopupControllerCommon(
|
| + test_cases[i].element_bounds, base::i18n::RIGHT_TO_LEFT));
|
| + popup_controller->set_display(display);
|
| + actual_popup_bounds =
|
| + popup_controller->GetPopupBounds(desired_width, desired_height);
|
| + gfx::Rect expected_popup_bounds = test_cases[i].expected_popup_bounds_rtl;
|
| + if (expected_popup_bounds.IsEmpty())
|
| + expected_popup_bounds = test_cases[i].expected_popup_bounds_ltr;
|
| + EXPECT_EQ(expected_popup_bounds.ToString(), actual_popup_bounds.ToString())
|
| + << "Popup bounds failed to match for rtl test " << i;
|
| }
|
| }
|
|
|
|
|