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/renderer/credential_manager_client
.h" |
| 6 |
5 #include <stdint.h> | 7 #include <stdint.h> |
6 | 8 |
| 9 #include <memory> |
7 #include <tuple> | 10 #include <tuple> |
8 | 11 |
9 #include "components/password_manager/content/common/credential_manager_messages
.h" | 12 #include "components/password_manager/content/common/credential_manager_messages
.h" |
10 #include "components/password_manager/content/renderer/credential_manager_client
.h" | |
11 #include "content/public/test/render_view_test.h" | 13 #include "content/public/test/render_view_test.h" |
12 #include "ipc/ipc_test_sink.h" | 14 #include "ipc/ipc_test_sink.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
14 #include "third_party/WebKit/public/platform/WebCredential.h" | 16 #include "third_party/WebKit/public/platform/WebCredential.h" |
15 #include "third_party/WebKit/public/platform/WebCredentialManagerClient.h" | 17 #include "third_party/WebKit/public/platform/WebCredentialManagerClient.h" |
16 #include "third_party/WebKit/public/platform/WebCredentialManagerError.h" | 18 #include "third_party/WebKit/public/platform/WebCredentialManagerError.h" |
17 #include "third_party/WebKit/public/platform/WebPassOwnPtr.h" | |
18 #include "third_party/WebKit/public/platform/WebPasswordCredential.h" | 19 #include "third_party/WebKit/public/platform/WebPasswordCredential.h" |
19 | 20 |
20 namespace password_manager { | 21 namespace password_manager { |
21 | 22 |
22 namespace { | 23 namespace { |
23 | 24 |
24 class CredentialManagerClientTest : public content::RenderViewTest { | 25 class CredentialManagerClientTest : public content::RenderViewTest { |
25 public: | 26 public: |
26 CredentialManagerClientTest() | 27 CredentialManagerClientTest() |
27 : callback_errored_(false), callback_succeeded_(false) {} | 28 : callback_errored_(false), callback_succeeded_(false) {} |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 }; | 124 }; |
124 | 125 |
125 class TestRequestCallbacks | 126 class TestRequestCallbacks |
126 : public blink::WebCredentialManagerClient::RequestCallbacks { | 127 : public blink::WebCredentialManagerClient::RequestCallbacks { |
127 public: | 128 public: |
128 explicit TestRequestCallbacks(CredentialManagerClientTest* test) | 129 explicit TestRequestCallbacks(CredentialManagerClientTest* test) |
129 : test_(test) {} | 130 : test_(test) {} |
130 | 131 |
131 ~TestRequestCallbacks() override {} | 132 ~TestRequestCallbacks() override {} |
132 | 133 |
133 void onSuccess(blink::WebPassOwnPtr<blink::WebCredential>) override { | 134 void onSuccess(std::unique_ptr<blink::WebCredential>) override { |
134 test_->set_callback_succeeded(true); | 135 test_->set_callback_succeeded(true); |
135 } | 136 } |
136 | 137 |
137 void onError(blink::WebCredentialManagerError reason) override { | 138 void onError(blink::WebCredentialManagerError reason) override { |
138 test_->set_callback_errored(true); | 139 test_->set_callback_errored(true); |
139 } | 140 } |
140 | 141 |
141 private: | 142 private: |
142 CredentialManagerClientTest* test_; | 143 CredentialManagerClientTest* test_; |
143 }; | 144 }; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 EXPECT_TRUE(ExtractRequestId(CredentialManagerHostMsg_RequestCredential::ID, | 211 EXPECT_TRUE(ExtractRequestId(CredentialManagerHostMsg_RequestCredential::ID, |
211 request_id)); | 212 request_id)); |
212 | 213 |
213 CredentialInfo info; // Send an empty credential in response. | 214 CredentialInfo info; // Send an empty credential in response. |
214 client_->OnSendCredential(request_id, info); | 215 client_->OnSendCredential(request_id, info); |
215 EXPECT_TRUE(callback_succeeded()); | 216 EXPECT_TRUE(callback_succeeded()); |
216 EXPECT_FALSE(callback_errored()); | 217 EXPECT_FALSE(callback_errored()); |
217 } | 218 } |
218 | 219 |
219 } // namespace password_manager | 220 } // namespace password_manager |
OLD | NEW |