OLD | NEW |
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 Loading... |
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 Loading... |
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 2686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2916 }; | 2927 }; |
2917 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 2928 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
2918 for (size_t i = 0; i < arraysize(kSupportedCardIdrs); ++i) { | 2929 for (size_t i = 0; i < arraysize(kSupportedCardIdrs); ++i) { |
2919 SCOPED_TRACE(base::IntToString(i)); | 2930 SCOPED_TRACE(base::IntToString(i)); |
2920 gfx::Image supported_card_icon = rb.GetImageNamed(kSupportedCardIdrs[i]); | 2931 gfx::Image supported_card_icon = rb.GetImageNamed(kSupportedCardIdrs[i]); |
2921 EXPECT_GE(placeholder_icon.Width(), supported_card_icon.Width()); | 2932 EXPECT_GE(placeholder_icon.Width(), supported_card_icon.Width()); |
2922 EXPECT_GE(placeholder_icon.Height(), supported_card_icon.Height()); | 2933 EXPECT_GE(placeholder_icon.Height(), supported_card_icon.Height()); |
2923 } | 2934 } |
2924 } | 2935 } |
2925 | 2936 |
| 2937 TEST_F(AutofillDialogControllerTest, CountryChangeUpdatesSection) { |
| 2938 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 2939 command_line->AppendSwitch(::switches::kEnableAutofillAddressI18n); |
| 2940 |
| 2941 Reset(); |
| 2942 |
| 2943 TestAutofillDialogView* view = controller()->GetView(); |
| 2944 view->ClearSectionUpdates(); |
| 2945 |
| 2946 controller()->UserEditedOrActivatedInput(SECTION_SHIPPING, |
| 2947 ADDRESS_HOME_COUNTRY, |
| 2948 gfx::NativeView(), |
| 2949 gfx::Rect(), |
| 2950 ASCIIToUTF16("China"), |
| 2951 true); |
| 2952 std::map<DialogSection, size_t> updates = view->section_updates(); |
| 2953 EXPECT_EQ(1U, updates[SECTION_SHIPPING]); |
| 2954 EXPECT_EQ(1U, updates.size()); |
| 2955 |
| 2956 view->ClearSectionUpdates(); |
| 2957 |
| 2958 controller()->UserEditedOrActivatedInput(SECTION_CC_BILLING, |
| 2959 ADDRESS_BILLING_COUNTRY, |
| 2960 gfx::NativeView(), |
| 2961 gfx::Rect(), |
| 2962 ASCIIToUTF16("France"), |
| 2963 true); |
| 2964 updates = view->section_updates(); |
| 2965 EXPECT_EQ(1U, updates[SECTION_CC_BILLING]); |
| 2966 EXPECT_EQ(1U, updates.size()); |
| 2967 |
| 2968 SwitchToAutofill(); |
| 2969 view->ClearSectionUpdates(); |
| 2970 |
| 2971 controller()->UserEditedOrActivatedInput(SECTION_BILLING, |
| 2972 ADDRESS_BILLING_COUNTRY, |
| 2973 gfx::NativeView(), |
| 2974 gfx::Rect(), |
| 2975 ASCIIToUTF16("Italy"), |
| 2976 true); |
| 2977 updates = view->section_updates(); |
| 2978 EXPECT_EQ(1U, updates[SECTION_BILLING]); |
| 2979 EXPECT_EQ(1U, updates.size()); |
| 2980 } |
| 2981 |
2926 } // namespace autofill | 2982 } // namespace autofill |
OLD | NEW |