OLD | NEW |
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 #ifndef CHROME_BROWSER_UI_AUTOFILL_MOCK_ADDRESS_VALIDATOR_H_ | 5 #ifndef CHROME_BROWSER_UI_AUTOFILL_MOCK_ADDRESS_VALIDATOR_H_ |
6 #define CHROME_BROWSER_UI_AUTOFILL_MOCK_ADDRESS_VALIDATOR_H_ | 6 #define CHROME_BROWSER_UI_AUTOFILL_MOCK_ADDRESS_VALIDATOR_H_ |
7 | 7 |
| 8 #define I18N_ADDRESSINPUT_UTIL_BASICTYPES_H_ // Use base/basictypes.h instead. |
| 9 |
8 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
9 #include "testing/gmock/include/gmock/gmock.h" | 11 #include "testing/gmock/include/gmock/gmock.h" |
10 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/addre
ss_data.h" | 12 #include "third_party/libaddressinput/chromium/preload_address_validator.h" |
11 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/addre
ss_validator.h" | 13 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_da
ta.h" |
12 | 14 |
13 namespace autofill { | 15 namespace autofill { |
14 | 16 |
15 MATCHER_P(CountryCodeMatcher, country_code, "Checks an AddressData's country") { | 17 MATCHER_P(CountryCodeMatcher, region_code, "Checks an AddressData's country") { |
16 // |arg| is an AddressData object. | 18 // |arg| is an AddressData object. |
17 return arg.country_code == country_code; | 19 return arg.region_code == region_code; |
18 } | 20 } |
19 | 21 |
20 class MockAddressValidator : public ::i18n::addressinput::AddressValidator { | 22 class MockAddressValidator : public PreloadAddressValidator { |
21 public: | 23 public: |
22 MockAddressValidator(); | 24 MockAddressValidator(); |
23 virtual ~MockAddressValidator(); | 25 virtual ~MockAddressValidator(); |
24 | 26 |
25 MOCK_METHOD1(LoadRules, void(const std::string& country_code)); | 27 virtual void LoadRules(const std::string& region_code, |
| 28 const Callback& /*loaded*/) OVERRIDE { |
| 29 MockLoadRules(region_code); // Discard callback |loaded|. |
| 30 } |
26 | 31 |
27 MOCK_CONST_METHOD3(ValidateAddress, | 32 MOCK_METHOD1(MockLoadRules, |
28 ::i18n::addressinput::AddressValidator::Status( | 33 void(const std::string& region_code)); |
| 34 |
| 35 MOCK_CONST_METHOD3(Validate, |
| 36 PreloadAddressValidator::Status( |
29 const ::i18n::addressinput::AddressData& address, | 37 const ::i18n::addressinput::AddressData& address, |
30 const ::i18n::addressinput::AddressProblemFilter& filter, | 38 const ::i18n::addressinput::FieldProblemMap* filter, |
31 ::i18n::addressinput::AddressProblems* problems)); | 39 ::i18n::addressinput::FieldProblemMap* problems)); |
32 | 40 |
33 MOCK_CONST_METHOD4(GetSuggestions, | 41 MOCK_CONST_METHOD4(GetSuggestions, |
34 ::i18n::addressinput::AddressValidator::Status( | 42 PreloadAddressValidator::Status( |
35 const ::i18n::addressinput::AddressData& user_input, | 43 const ::i18n::addressinput::AddressData& user_input, |
36 ::i18n::addressinput::AddressField focused_field, | 44 ::i18n::addressinput::AddressField focused_field, |
37 size_t suggestions_limit, | 45 size_t suggestions_limit, |
38 std::vector< ::i18n::addressinput::AddressData>* suggestions)); | 46 std::vector< ::i18n::addressinput::AddressData>* suggestions)); |
39 | 47 |
40 MOCK_CONST_METHOD1(CanonicalizeAdministrativeArea, | 48 MOCK_CONST_METHOD1(CanonicalizeAdministrativeArea, |
41 bool(::i18n::addressinput::AddressData* address_data)); | 49 bool(::i18n::addressinput::AddressData* address_data)); |
42 | 50 |
43 private: | 51 private: |
44 DISALLOW_COPY_AND_ASSIGN(MockAddressValidator); | 52 DISALLOW_COPY_AND_ASSIGN(MockAddressValidator); |
45 }; | 53 }; |
46 | 54 |
47 } // namespace autofill | 55 } // namespace autofill |
48 | 56 |
49 #endif // CHROME_BROWSER_UI_AUTOFILL_MOCK_ADDRESS_VALIDATOR_H_ | 57 #endif // CHROME_BROWSER_UI_AUTOFILL_MOCK_ADDRESS_VALIDATOR_H_ |
OLD | NEW |