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

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

Issue 178263004: rAc - Only show countries we're able to fill in. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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/country_combobox_model.h" 5 #include "chrome/browser/ui/autofill/country_combobox_model.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/test/base/testing_profile.h" 9 #include "chrome/test/base/testing_profile.h"
10 #include "components/autofill/core/browser/autofill_country.h" 10 #include "components/autofill/core/browser/autofill_country.h"
11 #include "components/autofill/core/browser/test_personal_data_manager.h" 11 #include "components/autofill/core/browser/test_personal_data_manager.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/addre ss_ui.h" 13 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/addre ss_ui.h"
14 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/addre ss_ui_component.h" 14 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/addre ss_ui_component.h"
15 15
16 namespace autofill { 16 namespace autofill {
17 17
18 class CountryComboboxModelTest : public testing::Test { 18 class CountryComboboxModelTest : public testing::Test {
19 public: 19 public:
20 CountryComboboxModelTest() { 20 CountryComboboxModelTest() {
21 manager_.Init(NULL, profile_.GetPrefs(), false); 21 manager_.Init(NULL, profile_.GetPrefs(), false);
22 manager_.set_timezone_country_code("KR"); 22 manager_.set_timezone_country_code("KR");
23 CreateModel(true); 23 CreateModel(true);
24 } 24 }
25 virtual ~CountryComboboxModelTest() {} 25 virtual ~CountryComboboxModelTest() {}
26 26
27 protected: 27 protected:
28 void CreateModel(bool show_partially_supported_countries) { 28 void CreateModel(bool show_partially_supported_countries) {
29 model_.reset(new CountryComboboxModel( 29 model_.reset(new CountryComboboxModel(
30 manager_, show_partially_supported_countries)); 30 manager_,
31 std::set<base::string16>(),
32 show_partially_supported_countries));
31 } 33 }
32 34
33 TestPersonalDataManager* manager() { return &manager_; } 35 TestPersonalDataManager* manager() { return &manager_; }
34 CountryComboboxModel* model() { return model_.get(); } 36 CountryComboboxModel* model() { return model_.get(); }
35 37
36 private: 38 private:
37 // NB: order is important here - |profile_| must go down after |manager_|. 39 // NB: order is important here - |profile_| must go down after |manager_|.
38 TestingProfile profile_; 40 TestingProfile profile_;
39 TestPersonalDataManager manager_; 41 TestPersonalDataManager manager_;
40 scoped_ptr<CountryComboboxModel> model_; 42 scoped_ptr<CountryComboboxModel> model_;
(...skipping 27 matching lines...) Expand all
68 for (int i = 0; i < model()->GetItemCount(); ++i) { 70 for (int i = 0; i < model()->GetItemCount(); ++i) {
69 ASSERT_FALSE(model()->IsItemSeparatorAt(i)); 71 ASSERT_FALSE(model()->IsItemSeparatorAt(i));
70 std::string country_code = model()->countries()[i]->country_code(); 72 std::string country_code = model()->countries()[i]->country_code();
71 std::vector< ::i18n::addressinput::AddressUiComponent> components = 73 std::vector< ::i18n::addressinput::AddressUiComponent> components =
72 ::i18n::addressinput::BuildComponents(country_code); 74 ::i18n::addressinput::BuildComponents(country_code);
73 ASSERT_FALSE(components.empty()); 75 ASSERT_FALSE(components.empty());
74 for (size_t j = 0; j < components.size(); ++j) { 76 for (size_t j = 0; j < components.size(); ++j) {
75 EXPECT_NE(components[j].field, ::i18n::addressinput::DEPENDENT_LOCALITY); 77 EXPECT_NE(components[j].field, ::i18n::addressinput::DEPENDENT_LOCALITY);
76 } 78 }
77 } 79 }
78 } 80 }
Dan Beam 2014/03/01 03:38:10 can you add a test of the country filtering logic
Evan Stade 2014/03/03 18:37:00 Adding a test here or in formstructure would not a
Dan Beam 2014/03/03 22:20:00 fine
Ilya Sherman 2014/03/03 23:55:54 IMO that means you're testing the wrong things at
Evan Stade 2014/03/04 00:11:30 This is what the bots are for. They make sure to c
Ilya Sherman 2014/03/04 00:53:57 That's true, though bots are much slower than runn
Evan Stade 2014/03/04 01:05:14 In fact I do think this, but unit tests are freque
79 81
80 } // namespace autofill 82 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698