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

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

Issue 124533003: Add country combobox to change country and rebuild address inputs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: mac Created 6 years, 11 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 (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 <map> 5 #include <map>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/guid.h" 9 #include "base/guid.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/prefs/pref_service.h" 12 #include "base/prefs/pref_service.h"
13 #include "base/run_loop.h" 13 #include "base/run_loop.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/string_piece.h" 15 #include "base/strings/string_piece.h"
16 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "base/tuple.h" 17 #include "base/tuple.h"
18 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h" 18 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h"
19 #include "chrome/browser/ui/autofill/autofill_dialog_view.h" 19 #include "chrome/browser/ui/autofill/autofill_dialog_view.h"
20 #include "chrome/browser/ui/autofill/generated_credit_card_bubble_controller.h" 20 #include "chrome/browser/ui/autofill/generated_credit_card_bubble_controller.h"
21 #include "chrome/browser/ui/autofill/mock_new_credit_card_bubble_controller.h" 21 #include "chrome/browser/ui/autofill/mock_new_credit_card_bubble_controller.h"
22 #include "chrome/browser/ui/autofill/test_generated_credit_card_bubble_controlle r.h" 22 #include "chrome/browser/ui/autofill/test_generated_credit_card_bubble_controlle r.h"
23 #include "chrome/browser/webdata/web_data_service_factory.h" 23 #include "chrome/browser/webdata/web_data_service_factory.h"
24 #include "chrome/common/chrome_switches.h"
24 #include "chrome/common/pref_names.h" 25 #include "chrome/common/pref_names.h"
25 #include "chrome/common/render_messages.h" 26 #include "chrome/common/render_messages.h"
26 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 27 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
27 #include "chrome/test/base/scoped_testing_local_state.h" 28 #include "chrome/test/base/scoped_testing_local_state.h"
28 #include "chrome/test/base/testing_browser_process.h" 29 #include "chrome/test/base/testing_browser_process.h"
29 #include "chrome/test/base/testing_profile.h" 30 #include "chrome/test/base/testing_profile.h"
30 #include "components/autofill/content/browser/risk/proto/fingerprint.pb.h" 31 #include "components/autofill/content/browser/risk/proto/fingerprint.pb.h"
31 #include "components/autofill/content/browser/wallet/full_wallet.h" 32 #include "components/autofill/content/browser/wallet/full_wallet.h"
32 #include "components/autofill/content/browser/wallet/gaia_account.h" 33 #include "components/autofill/content/browser/wallet/gaia_account.h"
33 #include "components/autofill/content/browser/wallet/instrument.h" 34 #include "components/autofill/content/browser/wallet/instrument.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 164
164 virtual void UpdateOverlay() OVERRIDE { 165 virtual void UpdateOverlay() OVERRIDE {
165 EXPECT_GE(updates_started_, 1); 166 EXPECT_GE(updates_started_, 1);
166 } 167 }
167 168
168 virtual void UpdateDetailArea() OVERRIDE { 169 virtual void UpdateDetailArea() OVERRIDE {
169 EXPECT_GE(updates_started_, 1); 170 EXPECT_GE(updates_started_, 1);
170 } 171 }
171 172
172 virtual void UpdateSection(DialogSection section) OVERRIDE { 173 virtual void UpdateSection(DialogSection section) OVERRIDE {
174 section_updates_[section]++;
173 EXPECT_GE(updates_started_, 1); 175 EXPECT_GE(updates_started_, 1);
174 } 176 }
175 177
176 virtual void UpdateErrorBubble() OVERRIDE { 178 virtual void UpdateErrorBubble() OVERRIDE {
177 EXPECT_GE(updates_started_, 1); 179 EXPECT_GE(updates_started_, 1);
178 } 180 }
179 181
180 virtual void FillSection(DialogSection section, 182 virtual void FillSection(DialogSection section,
181 ServerFieldType originating_type) OVERRIDE {} 183 ServerFieldType originating_type) OVERRIDE {}
182 virtual void GetUserInput(DialogSection section, FieldValueMap* output) 184 virtual void GetUserInput(DialogSection section, FieldValueMap* output)
(...skipping 25 matching lines...) Expand all
208 virtual void OnSignInResize(const gfx::Size& pref_size) OVERRIDE {} 210 virtual void OnSignInResize(const gfx::Size& pref_size) OVERRIDE {}
209 211
210 void SetUserInput(DialogSection section, const FieldValueMap& map) { 212 void SetUserInput(DialogSection section, const FieldValueMap& map) {
211 outputs_[section] = map; 213 outputs_[section] = map;
212 } 214 }
213 215
214 void CheckSaveDetailsLocallyCheckbox(bool checked) { 216 void CheckSaveDetailsLocallyCheckbox(bool checked) {
215 save_details_locally_checked_ = checked; 217 save_details_locally_checked_ = checked;
216 } 218 }
217 219
220 void ClearSectionUpdates() {
221 section_updates_.clear();
222 }
223
224 std::map<DialogSection, size_t> section_updates() const {
225 return section_updates_;
226 }
227
218 private: 228 private:
219 std::map<DialogSection, FieldValueMap> outputs_; 229 std::map<DialogSection, FieldValueMap> outputs_;
230 std::map<DialogSection, size_t> section_updates_;
220 231
221 int updates_started_; 232 int updates_started_;
222 bool save_details_locally_checked_; 233 bool save_details_locally_checked_;
223 234
224 DISALLOW_COPY_AND_ASSIGN(TestAutofillDialogView); 235 DISALLOW_COPY_AND_ASSIGN(TestAutofillDialogView);
225 }; 236 };
226 237
227 class TestAutofillDialogController 238 class TestAutofillDialogController
228 : public AutofillDialogControllerImpl, 239 : public AutofillDialogControllerImpl,
229 public base::SupportsWeakPtr<TestAutofillDialogController> { 240 public base::SupportsWeakPtr<TestAutofillDialogController> {
(...skipping 2675 matching lines...) Expand 10 before | Expand all | Expand 10 after
2905 }; 2916 };
2906 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 2917 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
2907 for (size_t i = 0; i < arraysize(kSupportedCardIdrs); ++i) { 2918 for (size_t i = 0; i < arraysize(kSupportedCardIdrs); ++i) {
2908 SCOPED_TRACE(base::IntToString(i)); 2919 SCOPED_TRACE(base::IntToString(i));
2909 gfx::Image supported_card_icon = rb.GetImageNamed(kSupportedCardIdrs[i]); 2920 gfx::Image supported_card_icon = rb.GetImageNamed(kSupportedCardIdrs[i]);
2910 EXPECT_GE(placeholder_icon.Width(), supported_card_icon.Width()); 2921 EXPECT_GE(placeholder_icon.Width(), supported_card_icon.Width());
2911 EXPECT_GE(placeholder_icon.Height(), supported_card_icon.Height()); 2922 EXPECT_GE(placeholder_icon.Height(), supported_card_icon.Height());
2912 } 2923 }
2913 } 2924 }
2914 2925
2926 TEST_F(AutofillDialogControllerTest, CountryChangeUpdatesSection) {
2927 CommandLine* command_line = CommandLine::ForCurrentProcess();
2928 command_line->AppendSwitch(::switches::kEnableAutofillAddressI18n);
2929
2930 Reset();
2931
2932 TestAutofillDialogView* view = controller()->GetView();
2933 view->ClearSectionUpdates();
2934
2935 controller()->UserEditedOrActivatedInput(SECTION_SHIPPING,
2936 ADDRESS_HOME_COUNTRY,
2937 gfx::NativeView(),
2938 gfx::Rect(),
2939 ASCIIToUTF16("China"),
2940 true);
2941 std::map<DialogSection, size_t> updates = view->section_updates();
2942 EXPECT_EQ(1U, updates[SECTION_SHIPPING]);
2943 EXPECT_EQ(1U, updates.size());
2944
2945 view->ClearSectionUpdates();
2946
2947 controller()->UserEditedOrActivatedInput(SECTION_CC_BILLING,
2948 ADDRESS_BILLING_COUNTRY,
2949 gfx::NativeView(),
2950 gfx::Rect(),
2951 ASCIIToUTF16("France"),
2952 true);
2953 updates = view->section_updates();
2954 EXPECT_EQ(1U, updates[SECTION_CC_BILLING]);
2955 EXPECT_EQ(1U, updates.size());
2956
2957 SwitchToAutofill();
2958 view->ClearSectionUpdates();
2959
2960 controller()->UserEditedOrActivatedInput(SECTION_BILLING,
2961 ADDRESS_BILLING_COUNTRY,
2962 gfx::NativeView(),
2963 gfx::Rect(),
2964 ASCIIToUTF16("Italy"),
2965 true);
2966 updates = view->section_updates();
2967 EXPECT_EQ(1U, updates[SECTION_BILLING]);
2968 EXPECT_EQ(1U, updates.size());
2969 }
2970
2915 } // namespace autofill 2971 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698