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" | 5 #include "components/password_manager/content/renderer/credential_manager_client
.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <tuple> | 10 #include <tuple> |
11 | 11 |
12 #include "base/location.h" | 12 #include "base/location.h" |
13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
14 #include "base/threading/thread_task_runner_handle.h" | 14 #include "base/threading/thread_task_runner_handle.h" |
15 #include "content/public/common/service_registry.h" | |
16 #include "content/public/renderer/render_frame.h" | 15 #include "content/public/renderer/render_frame.h" |
17 #include "content/public/renderer/render_view.h" | 16 #include "content/public/renderer/render_view.h" |
18 #include "content/public/test/render_view_test.h" | 17 #include "content/public/test/render_view_test.h" |
19 #include "mojo/public/cpp/bindings/binding_set.h" | 18 #include "mojo/public/cpp/bindings/binding_set.h" |
| 19 #include "services/shell/public/cpp/interface_provider.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
21 #include "third_party/WebKit/public/platform/WebCredential.h" | 21 #include "third_party/WebKit/public/platform/WebCredential.h" |
22 #include "third_party/WebKit/public/platform/WebCredentialManagerClient.h" | 22 #include "third_party/WebKit/public/platform/WebCredentialManagerClient.h" |
23 #include "third_party/WebKit/public/platform/WebCredentialManagerError.h" | 23 #include "third_party/WebKit/public/platform/WebCredentialManagerError.h" |
24 #include "third_party/WebKit/public/platform/WebPasswordCredential.h" | 24 #include "third_party/WebKit/public/platform/WebPasswordCredential.h" |
25 | 25 |
26 using content::ServiceRegistry; | |
27 | |
28 namespace password_manager { | 26 namespace password_manager { |
29 | 27 |
30 namespace { | 28 namespace { |
31 | 29 |
32 const char kTestCredentialPassword[] = "https://password.com/"; | 30 const char kTestCredentialPassword[] = "https://password.com/"; |
33 const char kTestCredentialEmpty[] = "https://empty.com/"; | 31 const char kTestCredentialEmpty[] = "https://empty.com/"; |
34 const char kTestCredentialReject[] = "https://reject.com/"; | 32 const char kTestCredentialReject[] = "https://reject.com/"; |
35 | 33 |
36 class FakeCredentialManager : public mojom::CredentialManager { | 34 class FakeCredentialManager : public mojom::CredentialManager { |
37 public: | 35 public: |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 class CredentialManagerClientTest : public content::RenderViewTest { | 77 class CredentialManagerClientTest : public content::RenderViewTest { |
80 public: | 78 public: |
81 CredentialManagerClientTest() | 79 CredentialManagerClientTest() |
82 : callback_errored_(false), callback_succeeded_(false) {} | 80 : callback_errored_(false), callback_succeeded_(false) {} |
83 ~CredentialManagerClientTest() override {} | 81 ~CredentialManagerClientTest() override {} |
84 | 82 |
85 void SetUp() override { | 83 void SetUp() override { |
86 content::RenderViewTest::SetUp(); | 84 content::RenderViewTest::SetUp(); |
87 client_.reset(new CredentialManagerClient(view_)); | 85 client_.reset(new CredentialManagerClient(view_)); |
88 | 86 |
89 ServiceRegistry* registry = | 87 shell::InterfaceProvider* remote_interfaces = |
90 view_->GetMainRenderFrame()->GetServiceRegistry(); | 88 view_->GetMainRenderFrame()->GetRemoteInterfaces(); |
91 registry->AddServiceOverrideForTesting( | 89 shell::InterfaceProvider::TestApi test_api(remote_interfaces); |
| 90 test_api.SetBinderForName( |
92 mojom::CredentialManager::Name_, | 91 mojom::CredentialManager::Name_, |
93 base::Bind(&CredentialManagerClientTest::BindCredentialManager, | 92 base::Bind(&CredentialManagerClientTest::BindCredentialManager, |
94 base::Unretained(this))); | 93 base::Unretained(this))); |
95 } | 94 } |
96 | 95 |
97 void TearDown() override { | 96 void TearDown() override { |
98 credential_.reset(); | 97 credential_.reset(); |
99 client_.reset(); | 98 client_.reset(); |
100 content::RenderViewTest::TearDown(); | 99 content::RenderViewTest::TearDown(); |
101 } | 100 } |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 | 241 |
243 EXPECT_FALSE(callback_succeeded()); | 242 EXPECT_FALSE(callback_succeeded()); |
244 EXPECT_TRUE(callback_errored()); | 243 EXPECT_TRUE(callback_errored()); |
245 EXPECT_FALSE(credential_); | 244 EXPECT_FALSE(credential_); |
246 EXPECT_EQ(blink::WebCredentialManagerError:: | 245 EXPECT_EQ(blink::WebCredentialManagerError:: |
247 WebCredentialManagerPasswordStoreUnavailableError, | 246 WebCredentialManagerPasswordStoreUnavailableError, |
248 error_); | 247 error_); |
249 } | 248 } |
250 | 249 |
251 } // namespace password_manager | 250 } // namespace password_manager |
OLD | NEW |