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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
131 | 131 |
132 NavigateAndCommit(GURL("https://example.com/test.html")); | 132 NavigateAndCommit(GURL("https://example.com/test.html")); |
133 | 133 |
134 form_.username_value = base::ASCIIToUTF16("Username"); | 134 form_.username_value = base::ASCIIToUTF16("Username"); |
135 form_.display_name = base::ASCIIToUTF16("Display Name"); | 135 form_.display_name = base::ASCIIToUTF16("Display Name"); |
136 form_.password_value = base::ASCIIToUTF16("Password"); | 136 form_.password_value = base::ASCIIToUTF16("Password"); |
137 form_.origin = web_contents()->GetLastCommittedURL().GetOrigin(); | 137 form_.origin = web_contents()->GetLastCommittedURL().GetOrigin(); |
138 form_.signon_realm = form_.origin.spec(); | 138 form_.signon_realm = form_.origin.spec(); |
139 form_.scheme = autofill::PasswordForm::SCHEME_HTML; | 139 form_.scheme = autofill::PasswordForm::SCHEME_HTML; |
140 | 140 |
141 cross_origin_form_.username_value = base::ASCIIToUTF16("Username"); | |
142 cross_origin_form_.display_name = base::ASCIIToUTF16("Display Name"); | |
143 cross_origin_form_.password_value = base::ASCIIToUTF16("Password"); | |
144 cross_origin_form_.origin = GURL("https://example.net/"); | |
145 cross_origin_form_.signon_realm = cross_origin_form_.origin.spec(); | |
146 cross_origin_form_.scheme = autofill::PasswordForm::SCHEME_HTML; | |
147 | |
141 store_->Clear(); | 148 store_->Clear(); |
142 EXPECT_TRUE(store_->IsEmpty()); | 149 EXPECT_TRUE(store_->IsEmpty()); |
143 } | 150 } |
144 | 151 |
145 void TearDown() override { | 152 void TearDown() override { |
146 store_->Shutdown(); | 153 store_->Shutdown(); |
147 content::RenderViewHostTestHarness::TearDown(); | 154 content::RenderViewHostTestHarness::TearDown(); |
148 } | 155 } |
149 | 156 |
150 ContentCredentialManagerDispatcher* dispatcher() { return dispatcher_.get(); } | 157 ContentCredentialManagerDispatcher* dispatcher() { return dispatcher_.get(); } |
151 | 158 |
152 protected: | 159 protected: |
153 autofill::PasswordForm form_; | 160 autofill::PasswordForm form_; |
161 autofill::PasswordForm cross_origin_form_; | |
154 scoped_refptr<TestPasswordStore> store_; | 162 scoped_refptr<TestPasswordStore> store_; |
155 scoped_ptr<ContentCredentialManagerDispatcher> dispatcher_; | 163 scoped_ptr<ContentCredentialManagerDispatcher> dispatcher_; |
156 scoped_ptr<TestPasswordManagerClient> client_; | 164 scoped_ptr<TestPasswordManagerClient> client_; |
157 StubPasswordManagerDriver stub_driver_; | 165 StubPasswordManagerDriver stub_driver_; |
158 }; | 166 }; |
159 | 167 |
160 TEST_F(ContentCredentialManagerDispatcherTest, | 168 TEST_F(ContentCredentialManagerDispatcherTest, |
161 CredentialManagerOnNotifyFailedSignIn) { | 169 CredentialManagerOnNotifyFailedSignIn) { |
162 CredentialInfo info; | 170 CredentialInfo info; |
163 info.type = CREDENTIAL_TYPE_LOCAL; | 171 info.type = CREDENTIAL_TYPE_LOCAL; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
223 CredentialManagerMsg_SendCredential::Param param; | 231 CredentialManagerMsg_SendCredential::Param param; |
224 CredentialManagerMsg_SendCredential::Read(message, ¶m); | 232 CredentialManagerMsg_SendCredential::Read(message, ¶m); |
225 EXPECT_EQ(CREDENTIAL_TYPE_EMPTY, param.b.type); | 233 EXPECT_EQ(CREDENTIAL_TYPE_EMPTY, param.b.type); |
226 process()->sink().ClearMessages(); | 234 process()->sink().ClearMessages(); |
227 EXPECT_FALSE(client_->did_prompt_user_to_choose()); | 235 EXPECT_FALSE(client_->did_prompt_user_to_choose()); |
228 } | 236 } |
229 | 237 |
230 TEST_F(ContentCredentialManagerDispatcherTest, | 238 TEST_F(ContentCredentialManagerDispatcherTest, |
231 CredentialManagerOnRequestCredentialWithFullPasswordStore) { | 239 CredentialManagerOnRequestCredentialWithFullPasswordStore) { |
232 store_->AddLogin(form_); | 240 store_->AddLogin(form_); |
241 store_->AddLogin(cross_origin_form_); | |
vabr (Chromium)
2014/12/15 10:47:22
I'm not sure what are you testing here. That the S
Mike West
2014/12/15 12:59:24
We're now requesting all the data, not just all th
vabr (Chromium)
2014/12/15 13:27:25
Acknowledged, the new test makes good sense to me.
| |
233 | 242 |
234 std::vector<GURL> federations; | 243 std::vector<GURL> federations; |
235 dispatcher()->OnRequestCredential(kRequestId, false, federations); | 244 dispatcher()->OnRequestCredential(kRequestId, false, federations); |
236 | 245 |
237 RunAllPendingTasks(); | 246 RunAllPendingTasks(); |
238 | 247 |
239 const uint32 kMsgID = CredentialManagerMsg_SendCredential::ID; | 248 const uint32 kMsgID = CredentialManagerMsg_SendCredential::ID; |
240 const IPC::Message* message = | 249 const IPC::Message* message = |
241 process()->sink().GetFirstMessageMatching(kMsgID); | 250 process()->sink().GetFirstMessageMatching(kMsgID); |
242 EXPECT_TRUE(message); | 251 EXPECT_TRUE(message); |
(...skipping 30 matching lines...) Expand all Loading... | |
273 EXPECT_TRUE(message); | 282 EXPECT_TRUE(message); |
274 CredentialManagerMsg_SendCredential::Param send_param; | 283 CredentialManagerMsg_SendCredential::Param send_param; |
275 CredentialManagerMsg_SendCredential::Read(message, &send_param); | 284 CredentialManagerMsg_SendCredential::Read(message, &send_param); |
276 CredentialManagerMsg_SendCredential::Read(message, &send_param); | 285 CredentialManagerMsg_SendCredential::Read(message, &send_param); |
277 EXPECT_NE(CREDENTIAL_TYPE_EMPTY, send_param.b.type); | 286 EXPECT_NE(CREDENTIAL_TYPE_EMPTY, send_param.b.type); |
278 process()->sink().ClearMessages(); | 287 process()->sink().ClearMessages(); |
279 EXPECT_TRUE(client_->did_prompt_user_to_choose()); | 288 EXPECT_TRUE(client_->did_prompt_user_to_choose()); |
280 } | 289 } |
281 | 290 |
282 } // namespace password_manager | 291 } // namespace password_manager |
OLD | NEW |