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/save_passwords_collection_view_controlle
r.h" | 5 #import "ios/chrome/browser/ui/settings/save_passwords_collection_view_controlle
r.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #import "base/test/ios/wait_util.h" | 11 #import "base/test/ios/wait_util.h" |
12 #include "components/autofill/core/common/password_form.h" | 12 #include "components/autofill/core/common/password_form.h" |
13 #include "components/password_manager/core/browser/mock_password_store.h" | 13 #include "components/password_manager/core/browser/mock_password_store.h" |
14 #include "components/password_manager/core/browser/password_manager_test_utils.h
" | 14 #include "components/password_manager/core/browser/password_manager_test_utils.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 #include "ios/chrome/browser/passwords/ios_chrome_password_store_factory.h" | 16 #include "ios/chrome/browser/passwords/ios_chrome_password_store_factory.h" |
17 #import "ios/chrome/browser/ui/collection_view/collection_view_controller_test.h
" | 17 #import "ios/chrome/browser/ui/collection_view/collection_view_controller_test.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 SavePasswordsCollectionViewController (InternalMethods) | 25 @interface SavePasswordsCollectionViewController (InternalMethods) |
22 - (void)onGetPasswordStoreResults: | 26 - (void)onGetPasswordStoreResults: |
23 (const std::vector<autofill::PasswordForm*>&)result; | 27 (const std::vector<autofill::PasswordForm*>&)result; |
24 @end | 28 @end |
25 | 29 |
26 namespace { | 30 namespace { |
27 | 31 |
28 class SavePasswordsCollectionViewControllerTest | 32 class SavePasswordsCollectionViewControllerTest |
29 : public CollectionViewControllerTest { | 33 : public CollectionViewControllerTest { |
30 protected: | 34 protected: |
31 SavePasswordsCollectionViewControllerTest() | 35 SavePasswordsCollectionViewControllerTest() |
32 : thread_bundle_(web::TestWebThreadBundle::REAL_DB_THREAD) {} | 36 : thread_bundle_(web::TestWebThreadBundle::REAL_DB_THREAD) {} |
33 | 37 |
34 void SetUp() override { | 38 void SetUp() override { |
35 TestChromeBrowserState::Builder test_cbs_builder; | 39 TestChromeBrowserState::Builder test_cbs_builder; |
36 chrome_browser_state_ = test_cbs_builder.Build(); | 40 chrome_browser_state_ = test_cbs_builder.Build(); |
37 CollectionViewControllerTest::SetUp(); | 41 CollectionViewControllerTest::SetUp(); |
38 IOSChromePasswordStoreFactory::GetInstance()->SetTestingFactory( | 42 IOSChromePasswordStoreFactory::GetInstance()->SetTestingFactory( |
39 chrome_browser_state_.get(), | 43 chrome_browser_state_.get(), |
40 &password_manager::BuildPasswordStore< | 44 &password_manager::BuildPasswordStore< |
41 web::BrowserState, password_manager::MockPasswordStore>); | 45 web::BrowserState, password_manager::MockPasswordStore>); |
42 CreateController(); | 46 CreateController(); |
43 } | 47 } |
44 | 48 |
45 CollectionViewController* NewController() override NS_RETURNS_RETAINED { | 49 CollectionViewController* InstantiateController() override { |
46 return [[SavePasswordsCollectionViewController alloc] | 50 return [[SavePasswordsCollectionViewController alloc] |
47 initWithBrowserState:chrome_browser_state_.get()]; | 51 initWithBrowserState:chrome_browser_state_.get()]; |
48 } | 52 } |
49 | 53 |
50 // Adds a form to SavePasswordsTableViewController. | 54 // Adds a form to SavePasswordsTableViewController. |
51 void AddPasswordForm(autofill::PasswordForm* form) { | 55 void AddPasswordForm(autofill::PasswordForm* form) { |
52 SavePasswordsCollectionViewController* save_password_controller = | 56 SavePasswordsCollectionViewController* save_password_controller = |
53 static_cast<SavePasswordsCollectionViewController*>(controller()); | 57 static_cast<SavePasswordsCollectionViewController*>(controller()); |
54 std::vector<autofill::PasswordForm*> passwords; | 58 std::vector<autofill::PasswordForm*> passwords; |
55 passwords.push_back(form); | 59 passwords.push_back(form); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 | 177 |
174 // Delete item in blacklisted passwords section. | 178 // Delete item in blacklisted passwords section. |
175 deleteItemWithWait(2, 0); | 179 deleteItemWithWait(2, 0); |
176 EXPECT_EQ(1, NumberOfItemsInSection(2)); | 180 EXPECT_EQ(1, NumberOfItemsInSection(2)); |
177 deleteItemWithWait(2, 0); | 181 deleteItemWithWait(2, 0); |
178 // There should be no password sections remaining. | 182 // There should be no password sections remaining. |
179 EXPECT_EQ(2, NumberOfSections()); | 183 EXPECT_EQ(2, NumberOfSections()); |
180 } | 184 } |
181 | 185 |
182 } // namespace | 186 } // namespace |
OLD | NEW |