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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 // | 45 // |
46 // Clears any pending messages upon return. | 46 // Clears any pending messages upon return. |
47 bool ExtractRequestId(uint32 message_id, int& request_id) { | 47 bool ExtractRequestId(uint32 message_id, int& request_id) { |
48 request_id = -1; | 48 request_id = -1; |
49 const IPC::Message* message = sink().GetFirstMessageMatching(message_id); | 49 const IPC::Message* message = sink().GetFirstMessageMatching(message_id); |
50 if (!message) | 50 if (!message) |
51 return false; | 51 return false; |
52 | 52 |
53 switch (message_id) { | 53 switch (message_id) { |
54 case CredentialManagerHostMsg_NotifyFailedSignIn::ID: { | 54 case CredentialManagerHostMsg_NotifyFailedSignIn::ID: { |
55 Tuple2<int, CredentialInfo> param; | 55 Tuple<int, CredentialInfo> param; |
56 CredentialManagerHostMsg_NotifyFailedSignIn::Read(message, ¶m); | 56 CredentialManagerHostMsg_NotifyFailedSignIn::Read(message, ¶m); |
57 request_id = param.a; | 57 request_id = get<0>(param); |
58 break; | 58 break; |
59 } | 59 } |
60 | 60 |
61 case CredentialManagerHostMsg_NotifySignedIn::ID: { | 61 case CredentialManagerHostMsg_NotifySignedIn::ID: { |
62 Tuple2<int, CredentialInfo> param; | 62 Tuple<int, CredentialInfo> param; |
63 CredentialManagerHostMsg_NotifySignedIn::Read(message, ¶m); | 63 CredentialManagerHostMsg_NotifySignedIn::Read(message, ¶m); |
64 request_id = param.a; | 64 request_id = get<0>(param); |
65 break; | 65 break; |
66 } | 66 } |
67 | 67 |
68 case CredentialManagerHostMsg_NotifySignedOut::ID: { | 68 case CredentialManagerHostMsg_NotifySignedOut::ID: { |
69 Tuple1<int> param; | 69 Tuple<int> param; |
70 CredentialManagerHostMsg_NotifySignedOut::Read(message, ¶m); | 70 CredentialManagerHostMsg_NotifySignedOut::Read(message, ¶m); |
71 request_id = param.a; | 71 request_id = get<0>(param); |
72 break; | 72 break; |
73 } | 73 } |
74 | 74 |
75 case CredentialManagerHostMsg_RequestCredential::ID: { | 75 case CredentialManagerHostMsg_RequestCredential::ID: { |
76 Tuple3<int, bool, std::vector<GURL> > param; | 76 Tuple<int, bool, std::vector<GURL> > param; |
77 CredentialManagerHostMsg_RequestCredential::Read(message, ¶m); | 77 CredentialManagerHostMsg_RequestCredential::Read(message, ¶m); |
78 request_id = param.a; | 78 request_id = get<0>(param); |
79 break; | 79 break; |
80 } | 80 } |
81 | 81 |
82 default: | 82 default: |
83 break; | 83 break; |
84 } | 84 } |
85 sink().ClearMessages(); | 85 sink().ClearMessages(); |
86 return request_id != -1; | 86 return request_id != -1; |
87 } | 87 } |
88 | 88 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 EXPECT_TRUE(ExtractRequestId(CredentialManagerHostMsg_RequestCredential::ID, | 227 EXPECT_TRUE(ExtractRequestId(CredentialManagerHostMsg_RequestCredential::ID, |
228 request_id)); | 228 request_id)); |
229 | 229 |
230 CredentialInfo info; // Send an empty credential in response. | 230 CredentialInfo info; // Send an empty credential in response. |
231 client_->OnSendCredential(request_id, info); | 231 client_->OnSendCredential(request_id, info); |
232 EXPECT_TRUE(callback_succeeded()); | 232 EXPECT_TRUE(callback_succeeded()); |
233 EXPECT_FALSE(callback_errored()); | 233 EXPECT_FALSE(callback_errored()); |
234 } | 234 } |
235 | 235 |
236 } // namespace password_manager | 236 } // namespace password_manager |
OLD | NEW |