Chromium Code Reviews| 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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 227 dispatcher()->OnRequestCredential(kRequestId, false, federations); | 227 dispatcher()->OnRequestCredential(kRequestId, false, federations); |
| 228 | 228 |
| 229 RunAllPendingTasks(); | 229 RunAllPendingTasks(); |
| 230 | 230 |
| 231 const uint32 kMsgID = CredentialManagerMsg_SendCredential::ID; | 231 const uint32 kMsgID = CredentialManagerMsg_SendCredential::ID; |
| 232 const IPC::Message* message = | 232 const IPC::Message* message = |
| 233 process()->sink().GetFirstMessageMatching(kMsgID); | 233 process()->sink().GetFirstMessageMatching(kMsgID); |
| 234 EXPECT_TRUE(message); | 234 EXPECT_TRUE(message); |
| 235 CredentialManagerMsg_SendCredential::Param param; | 235 CredentialManagerMsg_SendCredential::Param param; |
| 236 CredentialManagerMsg_SendCredential::Read(message, ¶m); | 236 CredentialManagerMsg_SendCredential::Read(message, ¶m); |
| 237 EXPECT_EQ(CREDENTIAL_TYPE_EMPTY, param.b.type); | 237 EXPECT_EQ(CREDENTIAL_TYPE_EMPTY, get<1>(param).type); |
| 238 process()->sink().ClearMessages(); | 238 process()->sink().ClearMessages(); |
| 239 EXPECT_FALSE(client_->did_prompt_user_to_choose()); | 239 EXPECT_FALSE(client_->did_prompt_user_to_choose()); |
| 240 } | 240 } |
| 241 | 241 |
| 242 TEST_F(ContentCredentialManagerDispatcherTest, | 242 TEST_F(ContentCredentialManagerDispatcherTest, |
| 243 CredentialManagerOnRequestCredentialWithCrossOriginPasswordStore) { | 243 CredentialManagerOnRequestCredentialWithCrossOriginPasswordStore) { |
| 244 store_->AddLogin(cross_origin_form_); | 244 store_->AddLogin(cross_origin_form_); |
| 245 | 245 |
| 246 std::vector<GURL> federations; | 246 std::vector<GURL> federations; |
| 247 dispatcher()->OnRequestCredential(kRequestId, false, federations); | 247 dispatcher()->OnRequestCredential(kRequestId, false, federations); |
| 248 | 248 |
| 249 RunAllPendingTasks(); | 249 RunAllPendingTasks(); |
| 250 | 250 |
| 251 const uint32 kMsgID = CredentialManagerMsg_SendCredential::ID; | 251 const uint32 kMsgID = CredentialManagerMsg_SendCredential::ID; |
| 252 const IPC::Message* message = | 252 const IPC::Message* message = |
| 253 process()->sink().GetFirstMessageMatching(kMsgID); | 253 process()->sink().GetFirstMessageMatching(kMsgID); |
| 254 EXPECT_TRUE(message); | 254 EXPECT_TRUE(message); |
| 255 CredentialManagerMsg_SendCredential::Param param; | 255 CredentialManagerMsg_SendCredential::Param param; |
| 256 CredentialManagerMsg_SendCredential::Read(message, ¶m); | 256 CredentialManagerMsg_SendCredential::Read(message, ¶m); |
| 257 EXPECT_EQ(CREDENTIAL_TYPE_EMPTY, param.b.type); | 257 EXPECT_EQ(CREDENTIAL_TYPE_EMPTY, get<1>(param).type); |
| 258 process()->sink().ClearMessages(); | 258 process()->sink().ClearMessages(); |
| 259 EXPECT_FALSE(client_->did_prompt_user_to_choose()); | 259 EXPECT_FALSE(client_->did_prompt_user_to_choose()); |
| 260 } | 260 } |
| 261 | 261 |
| 262 TEST_F(ContentCredentialManagerDispatcherTest, | 262 TEST_F(ContentCredentialManagerDispatcherTest, |
| 263 CredentialManagerOnRequestCredentialWithFullPasswordStore) { | 263 CredentialManagerOnRequestCredentialWithFullPasswordStore) { |
| 264 store_->AddLogin(form_); | 264 store_->AddLogin(form_); |
| 265 | 265 |
| 266 std::vector<GURL> federations; | 266 std::vector<GURL> federations; |
| 267 dispatcher()->OnRequestCredential(kRequestId, false, federations); | 267 dispatcher()->OnRequestCredential(kRequestId, false, federations); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 284 dispatcher()->OnRequestCredential(kRequestId, false, federations); | 284 dispatcher()->OnRequestCredential(kRequestId, false, federations); |
| 285 | 285 |
| 286 // Check that the second request triggered a rejection. | 286 // Check that the second request triggered a rejection. |
| 287 uint32 kMsgID = CredentialManagerMsg_RejectCredentialRequest::ID; | 287 uint32 kMsgID = CredentialManagerMsg_RejectCredentialRequest::ID; |
| 288 const IPC::Message* message = | 288 const IPC::Message* message = |
| 289 process()->sink().GetFirstMessageMatching(kMsgID); | 289 process()->sink().GetFirstMessageMatching(kMsgID); |
| 290 EXPECT_TRUE(message); | 290 EXPECT_TRUE(message); |
| 291 CredentialManagerMsg_RejectCredentialRequest::Param reject_param; | 291 CredentialManagerMsg_RejectCredentialRequest::Param reject_param; |
| 292 CredentialManagerMsg_RejectCredentialRequest::Read(message, &reject_param); | 292 CredentialManagerMsg_RejectCredentialRequest::Read(message, &reject_param); |
| 293 EXPECT_EQ(blink::WebCredentialManagerError::ErrorTypePendingRequest, | 293 EXPECT_EQ(blink::WebCredentialManagerError::ErrorTypePendingRequest, |
| 294 reject_param.b); | 294 get<1>(reject_param)); |
| 295 EXPECT_FALSE(client_->did_prompt_user_to_choose()); | 295 EXPECT_FALSE(client_->did_prompt_user_to_choose()); |
| 296 | 296 |
| 297 process()->sink().ClearMessages(); | 297 process()->sink().ClearMessages(); |
| 298 | 298 |
| 299 // Execute the PasswordStore asynchronousness. | 299 // Execute the PasswordStore asynchronousness. |
| 300 RunAllPendingTasks(); | 300 RunAllPendingTasks(); |
| 301 | 301 |
| 302 // Check that the first request resolves. | 302 // Check that the first request resolves. |
| 303 kMsgID = CredentialManagerMsg_SendCredential::ID; | 303 kMsgID = CredentialManagerMsg_SendCredential::ID; |
| 304 message = process()->sink().GetFirstMessageMatching(kMsgID); | 304 message = process()->sink().GetFirstMessageMatching(kMsgID); |
| 305 EXPECT_TRUE(message); | 305 EXPECT_TRUE(message); |
| 306 CredentialManagerMsg_SendCredential::Param send_param; | 306 CredentialManagerMsg_SendCredential::Param send_param; |
| 307 CredentialManagerMsg_SendCredential::Read(message, &send_param); | 307 CredentialManagerMsg_SendCredential::Read(message, &send_param); |
| 308 CredentialManagerMsg_SendCredential::Read(message, &send_param); | 308 EXPECT_NE(CREDENTIAL_TYPE_EMPTY, get<1>(send_param).type); |
|
Nico
2014/12/22 17:03:12
Heh.
| |
| 309 EXPECT_NE(CREDENTIAL_TYPE_EMPTY, send_param.b.type); | |
| 310 process()->sink().ClearMessages(); | 309 process()->sink().ClearMessages(); |
| 311 EXPECT_TRUE(client_->did_prompt_user_to_choose()); | 310 EXPECT_TRUE(client_->did_prompt_user_to_choose()); |
| 312 } | 311 } |
| 313 | 312 |
| 314 } // namespace password_manager | 313 } // namespace password_manager |
| OLD | NEW |