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

Side by Side Diff: chrome/browser/ui/autofill/autofill_popup_controller_unittest.cc

Issue 14053015: Don't add subtext padding if there is no subpadding. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 8 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "base/memory/weak_ptr.h" 6 #include "base/memory/weak_ptr.h"
7 #include "base/prefs/testing_pref_service.h" 7 #include "base/prefs/testing_pref_service.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" 9 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h"
10 #include "chrome/browser/ui/autofill/autofill_popup_view.h"
10 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 11 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
11 #include "chrome/test/base/testing_profile.h" 12 #include "chrome/test/base/testing_profile.h"
12 #include "components/autofill/browser/autofill_external_delegate.h" 13 #include "components/autofill/browser/autofill_external_delegate.h"
13 #include "components/autofill/browser/autofill_manager.h" 14 #include "components/autofill/browser/autofill_manager.h"
14 #include "components/autofill/browser/test_autofill_external_delegate.h" 15 #include "components/autofill/browser/test_autofill_external_delegate.h"
15 #include "components/autofill/browser/test_autofill_manager_delegate.h" 16 #include "components/autofill/browser/test_autofill_manager_delegate.h"
16 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAutofillClient.h" 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAutofillClient.h"
19 #include "ui/gfx/display.h" 20 #include "ui/gfx/display.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 const gfx::RectF& element_bounds() const { 103 const gfx::RectF& element_bounds() const {
103 return AutofillPopupControllerImpl::element_bounds(); 104 return AutofillPopupControllerImpl::element_bounds();
104 } 105 }
105 #if !defined(OS_ANDROID) 106 #if !defined(OS_ANDROID)
106 const gfx::Font& GetNameFontForRow(size_t index) const { 107 const gfx::Font& GetNameFontForRow(size_t index) const {
107 return AutofillPopupControllerImpl::GetNameFontForRow(index); 108 return AutofillPopupControllerImpl::GetNameFontForRow(index);
108 } 109 }
109 const gfx::Font& subtext_font() const { 110 const gfx::Font& subtext_font() const {
110 return AutofillPopupControllerImpl::subtext_font(); 111 return AutofillPopupControllerImpl::subtext_font();
111 } 112 }
113 int RowWidthWithoutText(int row) const {
114 return AutofillPopupControllerImpl::RowWidthWithoutText(row);
115 }
112 #endif 116 #endif
113 int GetDesiredPopupWidth() const { 117 int GetDesiredPopupWidth() const {
114 return AutofillPopupControllerImpl::GetDesiredPopupWidth(); 118 return AutofillPopupControllerImpl::GetDesiredPopupWidth();
115 } 119 }
116 int GetDesiredPopupHeight() const { 120 int GetDesiredPopupHeight() const {
117 return AutofillPopupControllerImpl::GetDesiredPopupHeight(); 121 return AutofillPopupControllerImpl::GetDesiredPopupHeight();
118 } 122 }
119 123
120 WeakPtr<AutofillPopupControllerImpl> GetWeakPtr() { 124 WeakPtr<AutofillPopupControllerImpl> GetWeakPtr() {
121 return AutofillPopupControllerImpl::GetWeakPtr(); 125 return AutofillPopupControllerImpl::GetWeakPtr();
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 283
280 // Make sure next skips the unselectable separator. 284 // Make sure next skips the unselectable separator.
281 autofill_popup_controller_->SelectNextLine(); 285 autofill_popup_controller_->SelectNextLine();
282 EXPECT_EQ(2, autofill_popup_controller_->selected_line()); 286 EXPECT_EQ(2, autofill_popup_controller_->selected_line());
283 287
284 // Make sure previous skips the unselectable separator. 288 // Make sure previous skips the unselectable separator.
285 autofill_popup_controller_->SelectPreviousLine(); 289 autofill_popup_controller_->SelectPreviousLine();
286 EXPECT_EQ(0, autofill_popup_controller_->selected_line()); 290 EXPECT_EQ(0, autofill_popup_controller_->selected_line());
287 } 291 }
288 292
293 TEST_F(AutofillPopupControllerUnitTest, RowWidthWithoutText) {
294 std::vector<string16> names(4);
295 std::vector<string16> subtexts(4);
296 std::vector<string16> icons(4);
297 std::vector<int> ids(4);
298
299 // Set up some visible display so the text values are kept.
300 gfx::Display display(0,
301 gfx::Rect(0, 0, 100, 100));
Ilya Sherman 2013/04/16 22:06:01 nit: Looks like this all fits on a single line.
csharp 2013/04/17 13:29:37 Done.
302 autofill_popup_controller_->set_display(display);
303
304 // Give elements 1 and 3 subtexts and elements 2 and 3 icons, to ensure
305 // and combinations of subtexts and icons.
Ilya Sherman 2013/04/16 22:06:01 nit: "and" -> "all"
csharp 2013/04/17 13:29:37 Done.
306 subtexts[1] = ASCIIToUTF16("x");
307 subtexts[3] = ASCIIToUTF16("x");
308 icons[2] = ASCIIToUTF16("x");
309 icons[3] = ASCIIToUTF16("x");
310 autofill_popup_controller_->Show(names, subtexts, icons, ids);
311
312 int base_size = AutofillPopupView::kEndPadding * 2;
313 int subtext_increase = AutofillPopupView::kNamePadding;
314 int icon_increase = AutofillPopupView::kIconPadding +
315 AutofillPopupView::kAutofillIconWidth;
316
317 EXPECT_EQ(base_size, autofill_popup_controller_->RowWidthWithoutText(0));
318 EXPECT_EQ(base_size + subtext_increase,
319 autofill_popup_controller_->RowWidthWithoutText(1));
320 EXPECT_EQ(base_size + icon_increase,
321 autofill_popup_controller_->RowWidthWithoutText(2));
322 EXPECT_EQ(base_size + subtext_increase + icon_increase,
323 autofill_popup_controller_->RowWidthWithoutText(3));
324 }
325
289 TEST_F(AutofillPopupControllerUnitTest, GetOrCreate) { 326 TEST_F(AutofillPopupControllerUnitTest, GetOrCreate) {
290 MockAutofillExternalDelegate delegate( 327 MockAutofillExternalDelegate delegate(
291 web_contents(), AutofillManager::FromWebContents(web_contents())); 328 web_contents(), AutofillManager::FromWebContents(web_contents()));
292 329
293 WeakPtr<AutofillPopupControllerImpl> controller = 330 WeakPtr<AutofillPopupControllerImpl> controller =
294 AutofillPopupControllerImpl::GetOrCreate( 331 AutofillPopupControllerImpl::GetOrCreate(
295 WeakPtr<AutofillPopupControllerImpl>(), &delegate, NULL, gfx::Rect()); 332 WeakPtr<AutofillPopupControllerImpl>(), &delegate, NULL, gfx::Rect());
296 EXPECT_TRUE(controller); 333 EXPECT_TRUE(controller);
297 334
298 controller->Hide(); 335 controller->Hide();
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 EXPECT_EQ(expected_popup_bounds[i].ToString(), 467 EXPECT_EQ(expected_popup_bounds[i].ToString(),
431 autofill_popup_controller->popup_bounds().ToString()) << 468 autofill_popup_controller->popup_bounds().ToString()) <<
432 "Popup bounds failed to match for test " << i; 469 "Popup bounds failed to match for test " << i;
433 470
434 // Hide the controller to delete it. 471 // Hide the controller to delete it.
435 autofill_popup_controller->DoHide(); 472 autofill_popup_controller->DoHide();
436 } 473 }
437 } 474 }
438 475
439 } // namespace autofill 476 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/ui/autofill/autofill_popup_controller_impl.cc ('k') | chrome/browser/ui/autofill/autofill_popup_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698