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

Side by Side Diff: chrome/browser/ui/passwords/manage_passwords_state_unittest.cc

Issue 1260263002: Move ShouldFilterAutofillResult from ChromePasswordManagerClient to PasswordManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First version with sync layer, IsSyncCredential TODO still pending Created 5 years, 4 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
OLDNEW
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 #include "chrome/browser/ui/passwords/manage_passwords_state.h" 5 #include "chrome/browser/ui/passwords/manage_passwords_state.h"
6 6
7 #include "base/memory/scoped_ptr.h"
7 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
8 #include "components/password_manager/core/browser/password_form_manager.h" 9 #include "components/password_manager/core/browser/password_form_manager.h"
9 #include "components/password_manager/core/browser/stub_password_manager_client. h" 10 #include "components/password_manager/core/browser/stub_password_manager_client. h"
10 #include "components/password_manager/core/common/credential_manager_types.h" 11 #include "components/password_manager/core/common/credential_manager_types.h"
12 #include "components/password_manager/sync/browser/sync_store_result_filter.h"
11 #include "testing/gmock/include/gmock/gmock.h" 13 #include "testing/gmock/include/gmock/gmock.h"
12 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
13 15
14 using ::testing::_; 16 using ::testing::_;
15 using ::testing::Contains; 17 using ::testing::Contains;
16 using ::testing::ElementsAre; 18 using ::testing::ElementsAre;
17 using ::testing::IsEmpty; 19 using ::testing::IsEmpty;
18 using ::testing::Not; 20 using ::testing::Not;
19 using ::testing::Pointee; 21 using ::testing::Pointee;
20 using ::testing::UnorderedElementsAre; 22 using ::testing::UnorderedElementsAre;
21 23
22 namespace { 24 namespace {
23 25
26 class TestPasswordManagerClient
27 : public password_manager::StubPasswordManagerClient {
28 scoped_ptr<password_manager::StoreResultFilter> CreateStoreResultFilter()
29 const override {
30 return make_scoped_ptr(new password_manager::SyncStoreResultFilter(this));
31 }
32 };
33
24 class ManagePasswordsStateTest : public testing::Test { 34 class ManagePasswordsStateTest : public testing::Test {
25 public: 35 public:
26 void SetUp() override { 36 void SetUp() override {
27 test_local_form_.origin = GURL("http://example.com"); 37 test_local_form_.origin = GURL("http://example.com");
28 test_local_form_.username_value = base::ASCIIToUTF16("username"); 38 test_local_form_.username_value = base::ASCIIToUTF16("username");
29 test_local_form_.password_value = base::ASCIIToUTF16("12345"); 39 test_local_form_.password_value = base::ASCIIToUTF16("12345");
30 40
31 test_submitted_form_ = test_local_form_; 41 test_submitted_form_ = test_local_form_;
32 test_submitted_form_.username_value = base::ASCIIToUTF16("new one"); 42 test_submitted_form_.username_value = base::ASCIIToUTF16("new one");
33 test_submitted_form_.password_value = base::ASCIIToUTF16("asdfjkl;"); 43 test_submitted_form_.password_value = base::ASCIIToUTF16("asdfjkl;");
(...skipping 16 matching lines...) Expand all
50 // affect the state. 60 // affect the state.
51 void TestNoisyUpdates(); 61 void TestNoisyUpdates();
52 62
53 // Pushes both relevant and irrelevant updates to |passwords_data_|. 63 // Pushes both relevant and irrelevant updates to |passwords_data_|.
54 void TestAllUpdates(); 64 void TestAllUpdates();
55 65
56 MOCK_METHOD1(OnChooseCredential, 66 MOCK_METHOD1(OnChooseCredential,
57 void(const password_manager::CredentialInfo&)); 67 void(const password_manager::CredentialInfo&));
58 68
59 private: 69 private:
60 password_manager::StubPasswordManagerClient client_; 70 TestPasswordManagerClient client_;
61 71
62 ManagePasswordsState passwords_data_; 72 ManagePasswordsState passwords_data_;
63 autofill::PasswordForm test_local_form_; 73 autofill::PasswordForm test_local_form_;
64 autofill::PasswordForm test_submitted_form_; 74 autofill::PasswordForm test_submitted_form_;
65 autofill::PasswordForm test_federated_form_; 75 autofill::PasswordForm test_federated_form_;
66 }; 76 };
67 77
68 scoped_ptr<password_manager::PasswordFormManager> 78 scoped_ptr<password_manager::PasswordFormManager>
69 ManagePasswordsStateTest::CreateFormManager() { 79 ManagePasswordsStateTest::CreateFormManager() {
70 scoped_ptr<password_manager::PasswordFormManager> test_form_manager( 80 scoped_ptr<password_manager::PasswordFormManager> test_form_manager(
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 password_manager::PasswordStoreChange::REMOVE, blacklisted); 588 password_manager::PasswordStoreChange::REMOVE, blacklisted);
579 passwords_data().ProcessLoginsChanged(list); 589 passwords_data().ProcessLoginsChanged(list);
580 EXPECT_THAT(passwords_data().GetCurrentForms(), 590 EXPECT_THAT(passwords_data().GetCurrentForms(),
581 ElementsAre(Pointee(test_local_form()))); 591 ElementsAre(Pointee(test_local_form())));
582 EXPECT_THAT(passwords_data().federated_credentials_forms(), IsEmpty()); 592 EXPECT_THAT(passwords_data().federated_credentials_forms(), IsEmpty());
583 EXPECT_EQ(password_manager::ui::MANAGE_STATE, passwords_data().state()); 593 EXPECT_EQ(password_manager::ui::MANAGE_STATE, passwords_data().state());
584 EXPECT_EQ(test_submitted_form().origin, passwords_data().origin()); 594 EXPECT_EQ(test_submitted_form().origin, passwords_data().origin());
585 } 595 }
586 596
587 } // namespace 597 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698