Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10008)

Unified Diff: chrome/browser/webauth/authenticator_web_contents_manager_unittest.cc

Issue 2788823002: Add the Mojo implementation of authenticator.mojom's MakeCredential. (Closed)
Patch Set: Address comments on unittests Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/webauth/authenticator_web_contents_manager_unittest.cc
diff --git a/chrome/browser/webauth/authenticator_web_contents_manager_unittest.cc b/chrome/browser/webauth/authenticator_web_contents_manager_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8c7c8f0495a73527049f0ff2c72726b8e27e8852
--- /dev/null
+++ b/chrome/browser/webauth/authenticator_web_contents_manager_unittest.cc
@@ -0,0 +1,55 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/webauth/authenticator_web_contents_manager.h"
+
+#include "chrome/test/base/chrome_render_view_host_test_harness.h"
+#include "components/webauth/authenticator_impl.h"
+#include "content/public/browser/render_process_host.h"
+#include "content/public/browser/web_contents.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+using ::testing::_;
+
+using webauth::mojom::AuthenticatorPtr;
+
+class AuthenticatorManagerTest : public ChromeRenderViewHostTestHarness {
+ public:
+ AuthenticatorManagerTest() {}
+ ~AuthenticatorManagerTest() override {}
+
+ private:
+ void SetUp() override { ChromeRenderViewHostTestHarness::SetUp(); }
+
+ void TearDown() override { ChromeRenderViewHostTestHarness::TearDown(); }
+};
+
+// Test that the manager can be created.
+TEST_F(AuthenticatorManagerTest, CreateForWebContents) {
+ AuthenticatorWebContentsManager* manager =
+ AuthenticatorWebContentsManager::GetOrCreateForWebContents(
+ web_contents());
+ ASSERT_NE(manager, nullptr);
+}
+
+// Test that the manager creates an authenticator.
+TEST_F(AuthenticatorManagerTest, CreateAuthenticator) {
+ AuthenticatorPtr authenticator;
+ AuthenticatorPtr nullInterface;
+ AuthenticatorWebContentsManager::GetOrCreateForWebContents(web_contents())
+ ->CreateAuthenticator(main_rfh(), mojo::MakeRequest(&authenticator));
+ EXPECT_FALSE(authenticator.Equals(nullInterface));
+}
+
+// Test that the same AuthenticatorManager is returned for the same web content.
+TEST_F(AuthenticatorManagerTest, MultipleManagers) {
+ AuthenticatorWebContentsManager* manager =
+ AuthenticatorWebContentsManager::GetOrCreateForWebContents(
+ web_contents());
+ AuthenticatorWebContentsManager* manager2 =
+ AuthenticatorWebContentsManager::GetOrCreateForWebContents(
+ web_contents());
+ EXPECT_TRUE(manager == manager2);
+}

Powered by Google App Engine
This is Rietveld 408576698