OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #import "ios/chrome/browser/ui/settings/autofill_collection_view_controller.h" | 5 #import "ios/chrome/browser/ui/settings/autofill_collection_view_controller.h" |
6 | 6 |
7 #include "base/guid.h" | 7 #include "base/guid.h" |
8 #include "base/mac/foundation_util.h" | 8 #include "base/mac/foundation_util.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #import "base/test/ios/wait_util.h" | 10 #import "base/test/ios/wait_util.h" |
11 #include "components/autofill/core/browser/autofill_profile.h" | 11 #include "components/autofill/core/browser/autofill_profile.h" |
12 #include "components/autofill/core/browser/credit_card.h" | 12 #include "components/autofill/core/browser/credit_card.h" |
13 #include "components/autofill/core/browser/personal_data_manager.h" | 13 #include "components/autofill/core/browser/personal_data_manager.h" |
14 #include "ios/chrome/browser/autofill/personal_data_manager_factory.h" | 14 #include "ios/chrome/browser/autofill/personal_data_manager_factory.h" |
15 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" | 15 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" |
16 #import "ios/chrome/browser/ui/collection_view/collection_view_controller_test.h
" | 16 #import "ios/chrome/browser/ui/collection_view/collection_view_controller_test.h
" |
17 #include "ios/chrome/browser/ui/settings/personal_data_manager_data_changed_obse
rver.h" | 17 #include "ios/chrome/browser/ui/settings/personal_data_manager_data_changed_obse
rver.h" |
18 #include "ios/web/public/test/test_web_thread_bundle.h" | 18 #include "ios/web/public/test/test_web_thread_bundle.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
20 | 20 |
| 21 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 22 #error "This file requires ARC support." |
| 23 #endif |
| 24 |
21 @interface SettingsRootCollectionViewController (ExposedForTesting) | 25 @interface SettingsRootCollectionViewController (ExposedForTesting) |
22 - (void)editButtonPressed; | 26 - (void)editButtonPressed; |
23 @end | 27 @end |
24 | 28 |
25 namespace { | 29 namespace { |
26 | 30 |
27 class AutofillCollectionViewControllerTest | 31 class AutofillCollectionViewControllerTest |
28 : public CollectionViewControllerTest { | 32 : public CollectionViewControllerTest { |
29 protected: | 33 protected: |
30 AutofillCollectionViewControllerTest() { | 34 AutofillCollectionViewControllerTest() { |
31 TestChromeBrowserState::Builder test_cbs_builder; | 35 TestChromeBrowserState::Builder test_cbs_builder; |
32 chrome_browser_state_ = test_cbs_builder.Build(); | 36 chrome_browser_state_ = test_cbs_builder.Build(); |
33 // Profile import requires a PersonalDataManager which itself needs the | 37 // Profile import requires a PersonalDataManager which itself needs the |
34 // WebDataService; this is not initialized on a TestChromeBrowserState by | 38 // WebDataService; this is not initialized on a TestChromeBrowserState by |
35 // default. | 39 // default. |
36 chrome_browser_state_->CreateWebDataService(); | 40 chrome_browser_state_->CreateWebDataService(); |
37 } | 41 } |
38 | 42 |
39 CollectionViewController* NewController() override NS_RETURNS_RETAINED { | 43 CollectionViewController* InstantiateController() override { |
40 return [[AutofillCollectionViewController alloc] | 44 return [[AutofillCollectionViewController alloc] |
41 initWithBrowserState:chrome_browser_state_.get()]; | 45 initWithBrowserState:chrome_browser_state_.get()]; |
42 } | 46 } |
43 | 47 |
44 void AddProfile(const std::string& origin, | 48 void AddProfile(const std::string& origin, |
45 const std::string& name, | 49 const std::string& name, |
46 const std::string& address) { | 50 const std::string& address) { |
47 autofill::PersonalDataManager* personal_data_manager = | 51 autofill::PersonalDataManager* personal_data_manager = |
48 autofill::PersonalDataManagerFactory::GetForBrowserState( | 52 autofill::PersonalDataManagerFactory::GetForBrowserState( |
49 chrome_browser_state_.get()); | 53 chrome_browser_state_.get()); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 | 153 |
150 // Exit 'edit' mode. | 154 // Exit 'edit' mode. |
151 [view_controller editButtonPressed]; | 155 [view_controller editButtonPressed]; |
152 | 156 |
153 // Verify the resulting UI. | 157 // Verify the resulting UI. |
154 EXPECT_EQ(1, NumberOfSections()); | 158 EXPECT_EQ(1, NumberOfSections()); |
155 EXPECT_EQ(2, NumberOfItemsInSection(0)); | 159 EXPECT_EQ(2, NumberOfItemsInSection(0)); |
156 } | 160 } |
157 | 161 |
158 } // namespace | 162 } // namespace |
OLD | NEW |