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

Side by Side Diff: components/autofill/core/browser/region_combobox_model_unittest.cc

Issue 2803443003: [Payments] Added region load failure tolerance and tests to PR editor. (Closed)
Patch Set: Removed unneeded include. Created 3 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "components/autofill/core/browser/region_combobox_model.h" 5 #include "components/autofill/core/browser/region_combobox_model.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 16 matching lines...) Expand all
27 class RegionComboboxModelTest : public testing::Test { 27 class RegionComboboxModelTest : public testing::Test {
28 public: 28 public:
29 RegionComboboxModelTest() 29 RegionComboboxModelTest()
30 : pref_service_(autofill::test::PrefServiceForTesting()) { 30 : pref_service_(autofill::test::PrefServiceForTesting()) {
31 manager_.SetTestingPrefService(pref_service_.get()); 31 manager_.SetTestingPrefService(pref_service_.get());
32 manager_.set_timezone_country_code(kTestCountryCode); 32 manager_.set_timezone_country_code(kTestCountryCode);
33 } 33 }
34 34
35 void SetupCombobox(bool source_failure) { 35 void SetupCombobox(bool source_failure) {
36 model_.reset(new RegionComboboxModel( 36 model_.reset(new RegionComboboxModel(
37 base::WrapUnique(new TestSource(source_failure)), 37 base::MakeUnique<TestSource>(source_failure),
38 base::WrapUnique(new ::i18n::addressinput::NullStorage), 38 base::MakeUnique<::i18n::addressinput::NullStorage>(),
39 manager_.app_locale(), kTestCountryCode)); 39 manager_.app_locale(), kTestCountryCode));
40 } 40 }
41 41
42 void TearDown() override { manager_.SetTestingPrefService(nullptr); } 42 void TearDown() override { manager_.SetTestingPrefService(nullptr); }
43 43
44 RegionComboboxModel* model() { return model_.get(); } 44 RegionComboboxModel* model() { return model_.get(); }
45 45
46 private: 46 private:
47 // The source that returns the region data. Using 47 // The source that returns the region data. Using
48 // third_party/libaddressinput/src/cpp/test/testdata_source.h wouldn't help 48 // third_party/libaddressinput/src/cpp/test/testdata_source.h wouldn't help
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 std::unique_ptr<RegionComboboxModel> model_; 87 std::unique_ptr<RegionComboboxModel> model_;
88 }; 88 };
89 89
90 // Make sure the two regions returned by the source are properly set in the 90 // Make sure the two regions returned by the source are properly set in the
91 // model. 91 // model.
92 TEST_F(RegionComboboxModelTest, QuebecOntarioRegions) { 92 TEST_F(RegionComboboxModelTest, QuebecOntarioRegions) {
93 SetupCombobox(false); 93 SetupCombobox(false);
94 EXPECT_EQ(2, model()->GetItemCount()); 94 EXPECT_EQ(2, model()->GetItemCount());
95 EXPECT_EQ(base::ASCIIToUTF16(kQuebec), model()->GetItemAt(0)); 95 EXPECT_EQ(base::ASCIIToUTF16(kQuebec), model()->GetItemAt(0));
96 EXPECT_EQ(base::ASCIIToUTF16(kOntario), model()->GetItemAt(1)); 96 EXPECT_EQ(base::ASCIIToUTF16(kOntario), model()->GetItemAt(1));
97 EXPECT_FALSE(model()->failed_to_load_data());
97 } 98 }
98 99
99 // Make sure the combo box properly support source failures. 100 // Make sure the combo box properly support source failures.
100 TEST_F(RegionComboboxModelTest, FailingSource) { 101 TEST_F(RegionComboboxModelTest, FailingSource) {
101 SetupCombobox(true); 102 SetupCombobox(true);
102 EXPECT_EQ(0, model()->GetItemCount()); 103 EXPECT_EQ(1, model()->GetItemCount());
104 EXPECT_TRUE(model()->failed_to_load_data());
103 } 105 }
104 106
105 } // namespace autofill 107 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/region_combobox_model.cc ('k') | components/payments/content/payment_request_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698