Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2032)

Unified Diff: chrome/browser/ui/autofill/popup_view_common_unittest.cc

Issue 1570783003: [Autofill] Move functions from the AutofillPopupController to AutofillPopupLayoutModel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed nit Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/autofill/popup_view_common_unittest.cc
diff --git a/chrome/browser/ui/autofill/popup_controller_common_unittest.cc b/chrome/browser/ui/autofill/popup_view_common_unittest.cc
similarity index 56%
rename from chrome/browser/ui/autofill/popup_controller_common_unittest.cc
rename to chrome/browser/ui/autofill/popup_view_common_unittest.cc
index 2de743e812bb2c388b1f3a5702d05cbc15e102e8..7a295c8b18b91f90307527aaf4fe903a47470f7e 100644
--- a/chrome/browser/ui/autofill/popup_controller_common_unittest.cc
+++ b/chrome/browser/ui/autofill/popup_view_common_unittest.cc
@@ -1,88 +1,102 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
+// 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 "chrome/browser/ui/autofill/popup_controller_common.h"
+#include "chrome/browser/ui/autofill/popup_view_common.h"
#include <stddef.h>
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
-#include "chrome/browser/ui/autofill/test_popup_controller_common.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
+#include "content/public/browser/web_contents.h"
#include "ui/gfx/display.h"
#include "ui/gfx/geometry/rect.h"
namespace autofill {
-class PopupControllerBaseTest : public ChromeRenderViewHostTestHarness {
+namespace {
+
+// Test class which overrides specific behavior for testing.
+class TestPopupViewCommon : public PopupViewCommon {
+ public:
+ explicit TestPopupViewCommon(const gfx::Display& display)
+ : display_(display) {}
+
+ gfx::Display GetDisplayNearestPoint(const gfx::Point& point,
+ gfx::NativeView container_view) override {
+ return display_;
+ }
+
+ private:
+ gfx::Display display_;
+};
+
+} // namespace
+
+class PopupViewCommonTest : public ChromeRenderViewHostTestHarness {
public:
- PopupControllerBaseTest() {}
- ~PopupControllerBaseTest() override {}
+ PopupViewCommonTest() {}
+ ~PopupViewCommonTest() override {}
private:
- DISALLOW_COPY_AND_ASSIGN(PopupControllerBaseTest);
+ DISALLOW_COPY_AND_ASSIGN(PopupViewCommonTest);
};
-TEST_F(PopupControllerBaseTest, GetPopupBoundsTest) {
+TEST_F(PopupViewCommonTest, CalculatePopupBounds) {
int desired_width = 40;
int desired_height = 16;
// Set up the visible screen space.
gfx::Display display(0,
gfx::Rect(0, 0, 2 * desired_width, 2 * desired_height));
+ TestPopupViewCommon view_common(display);
struct {
- gfx::RectF element_bounds;
+ gfx::Rect 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(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(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, 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(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(-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, 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(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);
+ gfx::Rect actual_popup_bounds = view_common.CalculatePopupBounds(
+ desired_width, desired_height, test_cases[i].element_bounds,
+ web_contents()->GetNativeView(), /* is_rtl= */ false);
EXPECT_EQ(test_cases[i].expected_popup_bounds_ltr.ToString(),
actual_popup_bounds.ToString())
<< "Popup bounds failed to match for ltr 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);
+ actual_popup_bounds = view_common.CalculatePopupBounds(
+ desired_width, desired_height, test_cases[i].element_bounds,
+ web_contents()->GetNativeView(), /* is_rtl= */ true);
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;
« no previous file with comments | « chrome/browser/ui/autofill/popup_view_common.cc ('k') | chrome/browser/ui/autofill/test_popup_controller_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698