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/common/credential_manager_messages
.h" | 5 #include "components/password_manager/content/common/credential_manager_messages
.h" |
6 #include "components/password_manager/content/renderer/credential_manager_client
.h" | 6 #include "components/password_manager/content/renderer/credential_manager_client
.h" |
7 #include "content/public/test/render_view_test.h" | 7 #include "content/public/test/render_view_test.h" |
8 #include "ipc/ipc_test_sink.h" | 8 #include "ipc/ipc_test_sink.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "third_party/WebKit/public/platform/WebCredential.h" | 10 #include "third_party/WebKit/public/platform/WebCredential.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 // | 55 // |
56 // Clears any pending messages upon return. | 56 // Clears any pending messages upon return. |
57 bool ExtractRequestId(uint32 message_id, int& request_id) { | 57 bool ExtractRequestId(uint32 message_id, int& request_id) { |
58 request_id = -1; | 58 request_id = -1; |
59 const IPC::Message* message = sink().GetFirstMessageMatching(message_id); | 59 const IPC::Message* message = sink().GetFirstMessageMatching(message_id); |
60 if (!message) | 60 if (!message) |
61 return false; | 61 return false; |
62 | 62 |
63 switch (message_id) { | 63 switch (message_id) { |
64 case CredentialManagerHostMsg_NotifyFailedSignIn::ID: { | 64 case CredentialManagerHostMsg_NotifyFailedSignIn::ID: { |
65 Tuple<int, CredentialInfo> param; | 65 base::Tuple<int, CredentialInfo> param; |
66 CredentialManagerHostMsg_NotifyFailedSignIn::Read(message, ¶m); | 66 CredentialManagerHostMsg_NotifyFailedSignIn::Read(message, ¶m); |
67 request_id = get<0>(param); | 67 request_id = base::get<0>(param); |
68 break; | 68 break; |
69 } | 69 } |
70 | 70 |
71 case CredentialManagerHostMsg_NotifySignedIn::ID: { | 71 case CredentialManagerHostMsg_NotifySignedIn::ID: { |
72 Tuple<int, CredentialInfo> param; | 72 base::Tuple<int, CredentialInfo> param; |
73 CredentialManagerHostMsg_NotifySignedIn::Read(message, ¶m); | 73 CredentialManagerHostMsg_NotifySignedIn::Read(message, ¶m); |
74 request_id = get<0>(param); | 74 request_id = base::get<0>(param); |
75 break; | 75 break; |
76 } | 76 } |
77 | 77 |
78 case CredentialManagerHostMsg_NotifySignedOut::ID: { | 78 case CredentialManagerHostMsg_NotifySignedOut::ID: { |
79 Tuple<int> param; | 79 base::Tuple<int> param; |
80 CredentialManagerHostMsg_NotifySignedOut::Read(message, ¶m); | 80 CredentialManagerHostMsg_NotifySignedOut::Read(message, ¶m); |
81 request_id = get<0>(param); | 81 request_id = base::get<0>(param); |
82 break; | 82 break; |
83 } | 83 } |
84 | 84 |
85 case CredentialManagerHostMsg_RequestCredential::ID: { | 85 case CredentialManagerHostMsg_RequestCredential::ID: { |
86 Tuple<int, bool, std::vector<GURL>> param; | 86 base::Tuple<int, bool, std::vector<GURL>> param; |
87 CredentialManagerHostMsg_RequestCredential::Read(message, ¶m); | 87 CredentialManagerHostMsg_RequestCredential::Read(message, ¶m); |
88 request_id = get<0>(param); | 88 request_id = base::get<0>(param); |
89 break; | 89 break; |
90 } | 90 } |
91 | 91 |
92 default: | 92 default: |
93 break; | 93 break; |
94 } | 94 } |
95 sink().ClearMessages(); | 95 sink().ClearMessages(); |
96 return request_id != -1; | 96 return request_id != -1; |
97 } | 97 } |
98 | 98 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 EXPECT_TRUE(ExtractRequestId(CredentialManagerHostMsg_RequestCredential::ID, | 237 EXPECT_TRUE(ExtractRequestId(CredentialManagerHostMsg_RequestCredential::ID, |
238 request_id)); | 238 request_id)); |
239 | 239 |
240 CredentialInfo info; // Send an empty credential in response. | 240 CredentialInfo info; // Send an empty credential in response. |
241 client_->OnSendCredential(request_id, info); | 241 client_->OnSendCredential(request_id, info); |
242 EXPECT_TRUE(callback_succeeded()); | 242 EXPECT_TRUE(callback_succeeded()); |
243 EXPECT_FALSE(callback_errored()); | 243 EXPECT_FALSE(callback_errored()); |
244 } | 244 } |
245 | 245 |
246 } // namespace password_manager | 246 } // namespace password_manager |
OLD | NEW |