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

Unified Diff: chrome/browser/media/router/discovery/dial/dial_registry_factory_unittest.cc

Issue 2754703005: [Device Discovery] Make DialRegistry a Singleton (Closed)
Patch Set: Created 3 years, 9 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/media/router/discovery/dial/dial_registry_factory_unittest.cc
diff --git a/chrome/browser/media/router/discovery/dial/dial_registry_factory_unittest.cc b/chrome/browser/media/router/discovery/dial/dial_registry_factory_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c26dc4bb5da826583f480538acc04a57a8f6dbcc
--- /dev/null
+++ b/chrome/browser/media/router/discovery/dial/dial_registry_factory_unittest.cc
@@ -0,0 +1,47 @@
+// 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 <memory>
+
+#include "base/memory/ptr_util.h"
+#include "chrome/browser/media/router/discovery/dial/dial_registry.h"
+#include "chrome/browser/media/router/discovery/dial/dial_registry_factory.h"
+#include "chrome/test/base/testing_profile.h"
+#include "content/public/browser/browser_context.h"
+#include "content/public/test/test_browser_thread_bundle.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace media_router {
+
+class DialRegistryFactoryTest : public testing::Test {
+ protected:
+ DialRegistryFactoryTest() {}
+ ~DialRegistryFactoryTest() override {}
+
+ Profile* profile() { return &profile_; }
+
+ private:
+ content::TestBrowserThreadBundle thread_bundle_;
+ TestingProfile profile_;
+};
+
+TEST_F(DialRegistryFactoryTest, CreateForRegularProfile) {
+ ASSERT_TRUE(DialRegistryFactory::GetForBrowserContext(profile()));
+}
+
+TEST_F(DialRegistryFactoryTest, CreateForIncognitoProfile) {
+ Profile* incognito_profile = profile()->GetOffTheRecordProfile();
+ ASSERT_TRUE(incognito_profile);
+
+ // Makes sure a DialRegistry can be created from an incognito Profile.
+ scoped_refptr<DialRegistry> dial_registry =
+ DialRegistryFactory::GetForBrowserContext(incognito_profile);
+ ASSERT_TRUE(dial_registry);
+
+ // A Profile and its incognito Profile share the same DialRegistry instance.
+ ASSERT_EQ(dial_registry,
+ DialRegistryFactory::GetForBrowserContext(profile()));
+}
+
+} // namespace media_router

Powered by Google App Engine
This is Rietveld 408576698