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

Side by Side Diff: chrome/browser/ui/autofill/popup_controller_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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/autofill/popup_controller_common.h"
6
7 #include <stddef.h>
8
9 #include "base/macros.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "chrome/browser/ui/autofill/test_popup_controller_common.h"
12 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
13 #include "ui/gfx/display.h"
14 #include "ui/gfx/geometry/rect.h"
15
16 namespace autofill {
17
18 class PopupControllerBaseTest : public ChromeRenderViewHostTestHarness {
19 public:
20 PopupControllerBaseTest() {}
21 ~PopupControllerBaseTest() override {}
22
23 private:
24 DISALLOW_COPY_AND_ASSIGN(PopupControllerBaseTest);
25 };
26
27 TEST_F(PopupControllerBaseTest, GetPopupBoundsTest) {
28 int desired_width = 40;
29 int desired_height = 16;
30
31 // Set up the visible screen space.
32 gfx::Display display(0,
33 gfx::Rect(0, 0, 2 * desired_width, 2 * desired_height));
34
35 struct {
36 gfx::RectF element_bounds;
37 gfx::Rect expected_popup_bounds_ltr;
38 // Non-empty only when it differs from the ltr expectation.
39 gfx::Rect expected_popup_bounds_rtl;
40 } test_cases[] = {
41 // The popup grows down and to the end.
42 {gfx::RectF(38, 0, 5, 0),
43 gfx::Rect(38, 0, desired_width, desired_height),
44 gfx::Rect(3, 0, desired_width, desired_height)},
45
46 // The popup grows down and to the left when there's no room on the right.
47 {gfx::RectF(2 * desired_width, 0, 5, 0),
48 gfx::Rect(desired_width, 0, desired_width, desired_height)},
49
50 // The popup grows up and to the right.
51 {gfx::RectF(0, 2 * desired_height, 5, 0),
52 gfx::Rect(0, desired_height, desired_width, desired_height)},
53
54 // The popup grows up and to the left.
55 {gfx::RectF(2 * desired_width, 2 * desired_height, 5, 0),
56 gfx::Rect(desired_width, desired_height, desired_width, desired_height)},
57
58 // The popup would be partial off the top and left side of the screen.
59 {gfx::RectF(-desired_width / 2, -desired_height / 2, 5, 0),
60 gfx::Rect(0, 0, desired_width, desired_height)},
61
62 // The popup would be partially off the bottom and the right side of
63 // the screen.
64 {gfx::RectF(desired_width * 1.5, desired_height * 1.5, 5, 0),
65 gfx::Rect((desired_width * 1.5 + 5 - desired_width),
66 (desired_height * 1.5 - desired_height), desired_width,
67 desired_height)},
68 };
69
70 for (size_t i = 0; i < arraysize(test_cases); ++i) {
71 scoped_ptr<TestPopupControllerCommon> popup_controller(
72 new TestPopupControllerCommon(test_cases[i].element_bounds,
73 base::i18n::LEFT_TO_RIGHT));
74 popup_controller->set_display(display);
75 gfx::Rect actual_popup_bounds =
76 popup_controller->GetPopupBounds(desired_width, desired_height);
77 EXPECT_EQ(test_cases[i].expected_popup_bounds_ltr.ToString(),
78 actual_popup_bounds.ToString())
79 << "Popup bounds failed to match for ltr test " << i;
80
81 popup_controller.reset(new TestPopupControllerCommon(
82 test_cases[i].element_bounds, base::i18n::RIGHT_TO_LEFT));
83 popup_controller->set_display(display);
84 actual_popup_bounds =
85 popup_controller->GetPopupBounds(desired_width, desired_height);
86 gfx::Rect expected_popup_bounds = test_cases[i].expected_popup_bounds_rtl;
87 if (expected_popup_bounds.IsEmpty())
88 expected_popup_bounds = test_cases[i].expected_popup_bounds_ltr;
89 EXPECT_EQ(expected_popup_bounds.ToString(), actual_popup_bounds.ToString())
90 << "Popup bounds failed to match for rtl test " << i;
91 }
92 }
93
94 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/ui/autofill/popup_controller_common.cc ('k') | chrome/browser/ui/autofill/popup_view_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698