[payments] Use actual images in Iban testsInclude the 100% scaled resources in components_tests_pak so that theautofill IBAN images are available for tests, and remove the workaroundsin tests introduced to handle the lack of images.Bug: 432395473Change-Id:I1bef5fcbde8b352d4d456ea74469780f012d6a21Reviewed-on:https://chromium-review.googlesource.com/c/chromium/src/+/6768373Reviewed-by: Olivia Saul <osaul@google.com>Auto-Submit: Greg Thompson <grt@chromium.org>Commit-Queue: Olivia Saul <osaul@google.com>Cr-Commit-Position: refs/heads/main@{#1488995}
diff --gita/components/BUILD.gnb/components/BUILD.gnindex fc3bbe71..333709f 100644--- a/components/BUILD.gn+++ b/components/BUILD.gn
@@ -964,6 +964,7 @@ "$root_gen_dir/components/arc/input_overlay_resources.pak", "$root_gen_dir/components/autofill/core/browser/geo/autofill_address_rewriter_resources.pak", "$root_gen_dir/components/components_resources.pak",+ "$root_gen_dir/components/components_resources_100_percent.pak", "$root_gen_dir/components/metrics/metrics_server_urls.pak", "$root_gen_dir/components/omnibox/resources/omnibox_pedal_synonyms_en-US.pak", "$root_gen_dir/components/plus_addresses/resources/strings/plus_addresses_strings_en-US.pak",
diff --gita/components/autofill/core/browser/payments/iban_manager_unittest.ccb/components/autofill/core/browser/payments/iban_manager_unittest.ccindex 6114f3e..eac584eb 100644--- a/components/autofill/core/browser/payments/iban_manager_unittest.cc+++ b/components/autofill/core/browser/payments/iban_manager_unittest.cc
@@ -30,7 +30,6 @@ #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/base/l10n/l10n_util.h"-#include "ui/base/resource/mock_resource_bundle_delegate.h" #include "ui/gfx/image/image_unittest_util.h" using testing::_;@@ -83,17 +82,6 @@ test_api(*form_structure_).SetFieldTypes({IBAN_VALUE}); autofill_field_ = form_structure_->field(0);- ui::ResourceBundle::InitSharedInstanceWithLocale(- "en-US", &mock_resource_delegate_,- ui::ResourceBundle::DO_NOT_LOAD_COMMON_RESOURCES);- if (IsNewFopDisplayEnabled()) {- ON_CALL(mock_resource_delegate_, GetImageNamed(IDR_AUTOFILL_IBAN))- .WillByDefault(testing::Return(gfx::test::CreateImage(100, 50)));- } else {- ON_CALL(mock_resource_delegate_, GetImageNamed(IDR_AUTOFILL_IBAN_OLD))- .WillByDefault(testing::Return(gfx::test::CreateImage(100, 50)));- }- ON_CALL(*autofill_client_.GetAutofillOptimizationGuide(), ShouldBlockSingleFieldSuggestions) .WillByDefault(testing::Return(false));@@ -107,10 +95,6 @@ #endif }- void TearDown() override {- ui::ResourceBundle::CleanupSharedInstance();- }- // Sets up the TestPersonalDataManager with a local IBAN. Iban SetUpLocalIban(std::string_view value, std::string_view nickname) { Iban iban;@@ -185,8 +169,6 @@ raw_ptr<AutofillField> autofill_field_; IbanManager iban_manager_{ &autofill_client_.GetPersonalDataManager().payments_data_manager()};- testing::NiceMock<ui::MockResourceBundleDelegate> mock_resource_delegate_;- ui::ResourceBundle::SharedInstanceSwapperForTesting resource_bundle_swapper_; base::test::ScopedFeatureList feature_list_metadata_; };
diff --gita/components/autofill/core/browser/suggestions/payments/iban_suggestion_generator_unittest.ccb/components/autofill/core/browser/suggestions/payments/iban_suggestion_generator_unittest.ccindex a579ed0..5cbccb4 100644--- a/components/autofill/core/browser/suggestions/payments/iban_suggestion_generator_unittest.cc+++ b/components/autofill/core/browser/suggestions/payments/iban_suggestion_generator_unittest.cc
@@ -21,7 +21,6 @@ #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/base/l10n/l10n_util.h"-#include "ui/base/resource/mock_resource_bundle_delegate.h" #include "ui/gfx/image/image_unittest_util.h" namespace autofill {@@ -49,26 +48,11 @@ test::CreateTestIbanFormData(/*value=*/"")); test_api(*form_structure_).SetFieldTypes({IBAN_VALUE});- ui::ResourceBundle::InitSharedInstanceWithLocale(- "en-US", &mock_resource_delegate_,- ui::ResourceBundle::DO_NOT_LOAD_COMMON_RESOURCES);- if (IsNewFopDisplayEnabled()) {- ON_CALL(mock_resource_delegate_, GetImageNamed(IDR_AUTOFILL_IBAN))- .WillByDefault(testing::Return(gfx::test::CreateImage(100, 50)));- } else {- ON_CALL(mock_resource_delegate_, GetImageNamed(IDR_AUTOFILL_IBAN_OLD))- .WillByDefault(testing::Return(gfx::test::CreateImage(100, 50)));- }- ON_CALL(*autofill_client_.GetAutofillOptimizationGuide(), ShouldBlockSingleFieldSuggestions) .WillByDefault(testing::Return(false)); }- ~IbanSuggestionGeneratorTest() override {- ui::ResourceBundle::CleanupSharedInstance();- }- bool IsNewFopDisplayEnabled() const { #if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_IOS) return false;@@ -156,8 +140,6 @@ TestAutofillClient autofill_client_; std::unique_ptr<PrefService> prefs_; std::unique_ptr<FormStructure> form_structure_;- testing::NiceMock<ui::MockResourceBundleDelegate> mock_resource_delegate_;- ui::ResourceBundle::SharedInstanceSwapperForTesting resource_bundle_swapper_; base::test::ScopedFeatureList feature_list_; };
diff --gita/components/autofill/core/browser/suggestions/payments/payments_suggestion_generator_unittest.ccb/components/autofill/core/browser/suggestions/payments/payments_suggestion_generator_unittest.ccindex cd8da48..658b5744 100644--- a/components/autofill/core/browser/suggestions/payments/payments_suggestion_generator_unittest.cc+++ b/components/autofill/core/browser/suggestions/payments/payments_suggestion_generator_unittest.cc
@@ -54,8 +54,6 @@ #include "components/sync/test/test_sync_service.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/base/l10n/l10n_util.h"-#include "ui/base/resource/mock_resource_bundle_delegate.h"-#include "ui/base/resource/resource_bundle.h" #include "ui/gfx/image/image.h" #include "ui/gfx/image/image_unittest_util.h" #include "ui/resources/grit/ui_resources.h"@@ -226,10 +224,6 @@ } void TearDown() override {- if (did_set_up_image_resource_for_test_) {- CleanUpIbanImageResources();- did_set_up_image_resource_for_test_ = false;- } credit_card_form_event_logger_->OnDestroyed(); }@@ -259,11 +253,6 @@ gfx::Image CustomIconForTest() { return gfx::test::CreateImage(32, 32); }- void CleanUpIbanImageResources() {- ui::ResourceBundle::CleanupSharedInstance();- resource_bundle_swapper_.reset();- }- bool VerifyCardArtImageExpectation(Suggestion& suggestion, const GURL& expected_url, const gfx::Image& expected_image) {@@ -298,12 +287,6 @@ TestBrowserAutofillManager autofill_manager_{&autofill_driver_}; protected:- testing::NiceMock<ui::MockResourceBundleDelegate> mock_resource_delegate_;- std::unique_ptr<ui::ResourceBundle::SharedInstanceSwapperForTesting>- resource_bundle_swapper_;- // Tracks whether SetUpIbanImageResources() has been called, so that the- // created images can be cleaned up when the test has finished.- bool did_set_up_image_resource_for_test_ = false; std::unique_ptr<MockCreditCardFormEventLogger> credit_card_form_event_logger_; };@@ -2238,22 +2221,6 @@ ~AutofillIbanSuggestionContentTest() override = default;- void SetUpIbanImageResources() {- resource_bundle_swapper_ =- std::make_unique<ui::ResourceBundle::SharedInstanceSwapperForTesting>();- ui::ResourceBundle::InitSharedInstanceWithLocale(- "en-US", &mock_resource_delegate_,- ui::ResourceBundle::DO_NOT_LOAD_COMMON_RESOURCES);- if (IsNewFopDisplayEnabled()) {- ON_CALL(mock_resource_delegate_, GetImageNamed(IDR_AUTOFILL_IBAN))- .WillByDefault(testing::Return(CustomIconForTest()));- } else {- ON_CALL(mock_resource_delegate_, GetImageNamed(IDR_AUTOFILL_IBAN_OLD))- .WillByDefault(testing::Return(CustomIconForTest()));- }- did_set_up_image_resource_for_test_ = true;- }- bool IsNewFopDisplayEnabled() const { #if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_IOS) return false;@@ -2271,8 +2238,6 @@ ::testing::Bool()); TEST_P(AutofillIbanSuggestionContentTest, GetLocalIbanSuggestions) {- SetUpIbanImageResources();- auto MakeLocalIban = [](const std::u16string& value, const std::u16string& nickname) { Iban iban(Iban::Guid(base::Uuid::GenerateRandomV4().AsLowercaseString()));@@ -2326,8 +2291,6 @@ } TEST_P(AutofillIbanSuggestionContentTest, GetServerIbanSuggestions) {- SetUpIbanImageResources();- Iban server_iban1 = test::GetServerIban(); Iban server_iban2 = test::GetServerIban2(); Iban server_iban3 = test::GetServerIban3();@@ -2366,8 +2329,6 @@ } TEST_P(AutofillIbanSuggestionContentTest, GetLocalAndServerIbanSuggestions) {- SetUpIbanImageResources();- Iban server_iban1 = test::GetServerIban(); Iban server_iban2 = test::GetServerIban2(); Iban local_iban1 = test::GetLocalIban();