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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 autofill::PasswordForm cross_origin_form_; | 165 autofill::PasswordForm cross_origin_form_; |
166 scoped_refptr<TestPasswordStore> store_; | 166 scoped_refptr<TestPasswordStore> store_; |
167 scoped_ptr<ContentCredentialManagerDispatcher> dispatcher_; | 167 scoped_ptr<ContentCredentialManagerDispatcher> dispatcher_; |
168 scoped_ptr<TestPasswordManagerClient> client_; | 168 scoped_ptr<TestPasswordManagerClient> client_; |
169 StubPasswordManagerDriver stub_driver_; | 169 StubPasswordManagerDriver stub_driver_; |
170 }; | 170 }; |
171 | 171 |
172 TEST_F(ContentCredentialManagerDispatcherTest, | 172 TEST_F(ContentCredentialManagerDispatcherTest, |
173 CredentialManagerOnNotifyFailedSignIn) { | 173 CredentialManagerOnNotifyFailedSignIn) { |
174 CredentialInfo info; | 174 CredentialInfo info; |
175 info.type = CREDENTIAL_TYPE_LOCAL; | 175 info.type = CredentialType::CREDENTIAL_TYPE_LOCAL; |
176 dispatcher()->OnNotifyFailedSignIn(kRequestId, info); | 176 dispatcher()->OnNotifyFailedSignIn(kRequestId, info); |
177 | 177 |
178 const uint32 kMsgID = CredentialManagerMsg_AcknowledgeFailedSignIn::ID; | 178 const uint32 kMsgID = CredentialManagerMsg_AcknowledgeFailedSignIn::ID; |
179 const IPC::Message* message = | 179 const IPC::Message* message = |
180 process()->sink().GetFirstMessageMatching(kMsgID); | 180 process()->sink().GetFirstMessageMatching(kMsgID); |
181 EXPECT_TRUE(message); | 181 EXPECT_TRUE(message); |
182 process()->sink().ClearMessages(); | 182 process()->sink().ClearMessages(); |
183 } | 183 } |
184 | 184 |
185 TEST_F(ContentCredentialManagerDispatcherTest, | 185 TEST_F(ContentCredentialManagerDispatcherTest, |
(...skipping 41 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, get<1>(param).type); | 237 EXPECT_EQ(CredentialType::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, get<1>(param).type); | 257 EXPECT_EQ(CredentialType::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 30 matching lines...) Expand all Loading... |
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 EXPECT_NE(CREDENTIAL_TYPE_EMPTY, get<1>(send_param).type); | 308 EXPECT_NE(CredentialType::CREDENTIAL_TYPE_EMPTY, get<1>(send_param).type); |
309 process()->sink().ClearMessages(); | 309 process()->sink().ClearMessages(); |
310 EXPECT_TRUE(client_->did_prompt_user_to_choose()); | 310 EXPECT_TRUE(client_->did_prompt_user_to_choose()); |
311 } | 311 } |
312 | 312 |
313 } // namespace password_manager | 313 } // namespace password_manager |
OLD | NEW |