OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "components/webauth/authenticator_web_contents_manager.h" |
| 6 |
| 7 #include "components/webauth/authenticator_impl.h" |
| 8 #include "content/public/browser/render_frame_host.h" |
| 9 #include "content/public/browser/web_contents.h" |
| 10 #include "content/public/test/test_renderer_host.h" |
| 11 #include "content/test/test_render_frame_host.h" |
| 12 #include "testing/gmock/include/gmock/gmock.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 |
| 15 using ::testing::_; |
| 16 |
| 17 using webauth::mojom::AuthenticatorPtr; |
| 18 |
| 19 class AuthenticatorManagerTest : public content::RenderViewHostTestHarness { |
| 20 public: |
| 21 AuthenticatorManagerTest() {} |
| 22 ~AuthenticatorManagerTest() override {} |
| 23 }; |
| 24 |
| 25 // Test that the manager can be created. |
| 26 TEST_F(AuthenticatorManagerTest, CreateForWebContents) { |
| 27 AuthenticatorWebContentsManager* manager = |
| 28 AuthenticatorWebContentsManager::GetOrCreateForWebContents( |
| 29 web_contents()); |
| 30 ASSERT_NE(manager, nullptr); |
| 31 } |
| 32 |
| 33 // Test that the manager creates an authenticator. |
| 34 TEST_F(AuthenticatorManagerTest, CreateAuthenticator) { |
| 35 AuthenticatorPtr authenticator; |
| 36 AuthenticatorPtr nullInterface; |
| 37 AuthenticatorWebContentsManager::GetOrCreateForWebContents(web_contents()) |
| 38 ->CreateAuthenticator(main_rfh(), mojo::MakeRequest(&authenticator)); |
| 39 EXPECT_FALSE(authenticator.Equals(nullInterface)); |
| 40 } |
| 41 |
| 42 // Test that the same AuthenticatorManager is returned for the same web content. |
| 43 TEST_F(AuthenticatorManagerTest, MultipleManagers) { |
| 44 AuthenticatorWebContentsManager* manager = |
| 45 AuthenticatorWebContentsManager::GetOrCreateForWebContents( |
| 46 web_contents()); |
| 47 AuthenticatorWebContentsManager* manager2 = |
| 48 AuthenticatorWebContentsManager::GetOrCreateForWebContents( |
| 49 web_contents()); |
| 50 EXPECT_TRUE(manager == manager2); |
| 51 } |
OLD | NEW |