| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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 "chrome/browser/ui/autofill/autofill_popup_layout_model.h" | 5 #include "chrome/browser/ui/autofill/autofill_popup_layout_model.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| 11 #include "chrome/browser/ui/autofill/autofill_popup_view.h" | 11 #include "chrome/browser/ui/autofill/autofill_popup_view.h" |
| 12 #include "chrome/browser/ui/autofill/autofill_popup_view_delegate.h" | 12 #include "chrome/browser/ui/autofill/autofill_popup_view_delegate.h" |
| 13 #include "chrome/browser/ui/autofill/popup_constants.h" | 13 #include "chrome/browser/ui/autofill/popup_constants.h" |
| 14 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 14 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| 15 #include "components/autofill/core/browser/popup_item_ids.h" |
| 15 #include "components/autofill/core/browser/suggestion.h" | 16 #include "components/autofill/core/browser/suggestion.h" |
| 16 #include "components/grit/components_scaled_resources.h" | 17 #include "components/grit/components_scaled_resources.h" |
| 17 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 19 #include "ui/base/resource/resource_bundle.h" | 20 #include "ui/base/resource/resource_bundle.h" |
| 20 #include "ui/gfx/geometry/point.h" | 21 #include "ui/gfx/geometry/point.h" |
| 21 #include "ui/gfx/geometry/rect.h" | 22 #include "ui/gfx/geometry/rect.h" |
| 22 #include "ui/gfx/geometry/rect_f.h" | 23 #include "ui/gfx/geometry/rect_f.h" |
| 24 #include "ui/gfx/image/image_skia.h" |
| 23 #include "ui/gfx/native_widget_types.h" | 25 #include "ui/gfx/native_widget_types.h" |
| 24 | 26 |
| 25 namespace autofill { | 27 namespace autofill { |
| 26 | 28 |
| 27 namespace { | 29 namespace { |
| 28 | 30 |
| 29 class TestAutofillPopupViewDelegate : public AutofillPopupViewDelegate { | 31 class TestAutofillPopupViewDelegate : public AutofillPopupViewDelegate { |
| 30 public: | 32 public: |
| 31 explicit TestAutofillPopupViewDelegate(content::WebContents* web_contents) | 33 explicit TestAutofillPopupViewDelegate(content::WebContents* web_contents) |
| 32 : element_bounds_(0.0, 0.0, 100.0, 100.0), | 34 : element_bounds_(0.0, 0.0, 100.0, 100.0), |
| (...skipping 10 matching lines...) Expand all Loading... |
| 43 bool IsRTL() const override { return false; } | 45 bool IsRTL() const override { return false; } |
| 44 | 46 |
| 45 const std::vector<autofill::Suggestion> GetSuggestions() override { | 47 const std::vector<autofill::Suggestion> GetSuggestions() override { |
| 46 // Give elements 1 and 3 subtexts and elements 2 and 3 icons, to ensure | 48 // Give elements 1 and 3 subtexts and elements 2 and 3 icons, to ensure |
| 47 // all combinations of subtexts and icons. | 49 // all combinations of subtexts and icons. |
| 48 std::vector<Suggestion> suggestions; | 50 std::vector<Suggestion> suggestions; |
| 49 suggestions.push_back(Suggestion("", "", "", 0)); | 51 suggestions.push_back(Suggestion("", "", "", 0)); |
| 50 suggestions.push_back(Suggestion("", "x", "", 0)); | 52 suggestions.push_back(Suggestion("", "x", "", 0)); |
| 51 suggestions.push_back(Suggestion("", "", "americanExpressCC", 0)); | 53 suggestions.push_back(Suggestion("", "", "americanExpressCC", 0)); |
| 52 suggestions.push_back(Suggestion("", "x", "genericCC", 0)); | 54 suggestions.push_back(Suggestion("", "x", "genericCC", 0)); |
| 55 // Http warning message. |
| 56 suggestions.push_back( |
| 57 Suggestion("x", "x", "httpWarning", |
| 58 POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE)); |
| 53 return suggestions; | 59 return suggestions; |
| 54 } | 60 } |
| 55 #if !defined(OS_ANDROID) | 61 #if !defined(OS_ANDROID) |
| 56 int GetElidedValueWidthForRow(size_t row) override { return 0; } | 62 int GetElidedValueWidthForRow(size_t row) override { return 0; } |
| 57 int GetElidedLabelWidthForRow(size_t row) override { return 0; } | 63 int GetElidedLabelWidthForRow(size_t row) override { return 0; } |
| 58 #endif | 64 #endif |
| 59 | 65 |
| 60 private: | 66 private: |
| 61 gfx::RectF element_bounds_; | 67 gfx::RectF element_bounds_; |
| 62 gfx::NativeView container_view_; | 68 gfx::NativeView container_view_; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 ui::ResourceBundle::GetSharedInstance() | 101 ui::ResourceBundle::GetSharedInstance() |
| 96 .GetImageNamed(IDR_AUTOFILL_CC_AMEX) | 102 .GetImageNamed(IDR_AUTOFILL_CC_AMEX) |
| 97 .Width(), | 103 .Width(), |
| 98 layout_model()->RowWidthWithoutText(2, /* with_label= */ false)); | 104 layout_model()->RowWidthWithoutText(2, /* with_label= */ false)); |
| 99 EXPECT_EQ(base_size + subtext_increase + | 105 EXPECT_EQ(base_size + subtext_increase + |
| 100 AutofillPopupLayoutModel::kIconPadding + | 106 AutofillPopupLayoutModel::kIconPadding + |
| 101 ui::ResourceBundle::GetSharedInstance() | 107 ui::ResourceBundle::GetSharedInstance() |
| 102 .GetImageNamed(IDR_AUTOFILL_CC_GENERIC) | 108 .GetImageNamed(IDR_AUTOFILL_CC_GENERIC) |
| 103 .Width(), | 109 .Width(), |
| 104 layout_model()->RowWidthWithoutText(3, /* with_label= */ true)); | 110 layout_model()->RowWidthWithoutText(3, /* with_label= */ true)); |
| 111 EXPECT_EQ(base_size + AutofillPopupLayoutModel::kHttpWarningNamePadding + |
| 112 AutofillPopupLayoutModel::kHttpWarningIconPadding + |
| 113 layout_model()->GetIconImage(4).width(), |
| 114 layout_model()->RowWidthWithoutText(4, /* with_label= */ true)); |
| 105 } | 115 } |
| 106 #endif | 116 #endif |
| 107 | 117 |
| 108 } // namespace autofill | 118 } // namespace autofill |
| OLD | NEW |