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 #include "components/password_manager/content/browser/content_credential_manager
_dispatcher.h" | 5 #include "components/password_manager/content/browser/content_credential_manager
_dispatcher.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 | 72 |
73 } // namespace | 73 } // namespace |
74 | 74 |
75 namespace password_manager { | 75 namespace password_manager { |
76 | 76 |
77 class ContentCredentialManagerDispatcherTest | 77 class ContentCredentialManagerDispatcherTest |
78 : public content::RenderViewHostTestHarness { | 78 : public content::RenderViewHostTestHarness { |
79 public: | 79 public: |
80 ContentCredentialManagerDispatcherTest() {} | 80 ContentCredentialManagerDispatcherTest() {} |
81 | 81 |
82 virtual void SetUp() override { | 82 void SetUp() override { |
83 content::RenderViewHostTestHarness::SetUp(); | 83 content::RenderViewHostTestHarness::SetUp(); |
84 store_ = new TestPasswordStore; | 84 store_ = new TestPasswordStore; |
85 client_.reset(new TestPasswordManagerClient(store_.get())); | 85 client_.reset(new TestPasswordManagerClient(store_.get())); |
86 dispatcher_.reset( | 86 dispatcher_.reset( |
87 new ContentCredentialManagerDispatcher(web_contents(), client_.get())); | 87 new ContentCredentialManagerDispatcher(web_contents(), client_.get())); |
88 | 88 |
89 NavigateAndCommit(GURL("https://example.com/test.html")); | 89 NavigateAndCommit(GURL("https://example.com/test.html")); |
90 | 90 |
91 form_.username_value = base::ASCIIToUTF16("Username"); | 91 form_.username_value = base::ASCIIToUTF16("Username"); |
92 form_.display_name = base::ASCIIToUTF16("Display Name"); | 92 form_.display_name = base::ASCIIToUTF16("Display Name"); |
93 form_.password_value = base::ASCIIToUTF16("Password"); | 93 form_.password_value = base::ASCIIToUTF16("Password"); |
94 form_.origin = web_contents()->GetLastCommittedURL().GetOrigin(); | 94 form_.origin = web_contents()->GetLastCommittedURL().GetOrigin(); |
95 form_.signon_realm = form_.origin.spec(); | 95 form_.signon_realm = form_.origin.spec(); |
96 form_.scheme = autofill::PasswordForm::SCHEME_HTML; | 96 form_.scheme = autofill::PasswordForm::SCHEME_HTML; |
97 | 97 |
98 store_->Clear(); | 98 store_->Clear(); |
99 EXPECT_TRUE(store_->IsEmpty()); | 99 EXPECT_TRUE(store_->IsEmpty()); |
100 } | 100 } |
101 | 101 |
102 virtual void TearDown() override { | 102 void TearDown() override { |
103 store_->Shutdown(); | 103 store_->Shutdown(); |
104 content::RenderViewHostTestHarness::TearDown(); | 104 content::RenderViewHostTestHarness::TearDown(); |
105 } | 105 } |
106 | 106 |
107 ContentCredentialManagerDispatcher* dispatcher() { return dispatcher_.get(); } | 107 ContentCredentialManagerDispatcher* dispatcher() { return dispatcher_.get(); } |
108 | 108 |
109 protected: | 109 protected: |
110 autofill::PasswordForm form_; | 110 autofill::PasswordForm form_; |
111 scoped_refptr<TestPasswordStore> store_; | 111 scoped_refptr<TestPasswordStore> store_; |
112 scoped_ptr<ContentCredentialManagerDispatcher> dispatcher_; | 112 scoped_ptr<ContentCredentialManagerDispatcher> dispatcher_; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 message = process()->sink().GetFirstMessageMatching(kMsgID); | 226 message = process()->sink().GetFirstMessageMatching(kMsgID); |
227 EXPECT_TRUE(message); | 227 EXPECT_TRUE(message); |
228 CredentialManagerMsg_SendCredential::Param send_param; | 228 CredentialManagerMsg_SendCredential::Param send_param; |
229 CredentialManagerMsg_SendCredential::Read(message, &send_param); | 229 CredentialManagerMsg_SendCredential::Read(message, &send_param); |
230 CredentialManagerMsg_SendCredential::Read(message, &send_param); | 230 CredentialManagerMsg_SendCredential::Read(message, &send_param); |
231 EXPECT_NE(CREDENTIAL_TYPE_EMPTY, send_param.b.type); | 231 EXPECT_NE(CREDENTIAL_TYPE_EMPTY, send_param.b.type); |
232 process()->sink().ClearMessages(); | 232 process()->sink().ClearMessages(); |
233 } | 233 } |
234 | 234 |
235 } // namespace password_manager | 235 } // namespace password_manager |
OLD | NEW |