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

Side by Side Diff: chrome/browser/media/router/media_router_factory_unittest.cc

Issue 1877273002: [Media Router Tests] Add tests for MediaRouterFactory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git cl try Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/media/router/media_router_factory.cc ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 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 "chrome/browser/media/router/media_router_factory.h"
6
7 #include "chrome/browser/media/router/mock_media_router.h"
8 #include "chrome/test/base/testing_profile.h"
9 #include "content/public/browser/browser_context.h"
10 #include "content/public/test/test_browser_thread_bundle.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12
13 namespace media_router {
14
15 namespace {
16
17 scoped_ptr<KeyedService> CreateMockMediaRouter(
dcheng 2016/04/26 08:26:12 Please use std::unique_ptr and base::WrapUnique. s
18 content::BrowserContext* context) {
19 return make_scoped_ptr(new MockMediaRouter);
20 }
21
22 } // namespace
23
24 class MediaRouterFactoryTest : public testing::Test {
25 protected:
26 MediaRouterFactoryTest() {}
27 ~MediaRouterFactoryTest() override {}
28
29 Profile* profile() { return &profile_; }
30
31 private:
32 content::TestBrowserThreadBundle thread_bundle_;
33 TestingProfile profile_;
34 };
35
36 TEST_F(MediaRouterFactoryTest, CreateForRegularProfile) {
37 ASSERT_TRUE(MediaRouterFactory::GetApiForBrowserContext(profile()));
38 }
39
40 TEST_F(MediaRouterFactoryTest, CreateForOffTheRecordProfile) {
41 Profile* otr_profile = profile()->GetOffTheRecordProfile();
42 ASSERT_TRUE(otr_profile);
43
44 // Makes sure a MediaRouter can be created from an OTR Profile.
45 MediaRouter* router =
46 MediaRouterFactory::GetApiForBrowserContext(otr_profile);
47 ASSERT_TRUE(router);
48
49 // A Profile and its OTR Profile share the same MediaRouter instance.
50 ASSERT_EQ(router, MediaRouterFactory::GetApiForBrowserContext(profile()));
51 }
52
53 TEST_F(MediaRouterFactoryTest, OffTheRecordBrowserContextShutdown) {
54 MediaRouterFactory::GetMediaRouterFactoryForTest()->SetTestingFactory(
55 profile(), &CreateMockMediaRouter);
56
57 // Creates an off the record profile.
58 profile()->GetOffTheRecordProfile();
59 MockMediaRouter* router = static_cast<MockMediaRouter*>(
60 MediaRouterFactory::GetApiForBrowserContext(profile()));
61 ASSERT_TRUE(router);
62 EXPECT_CALL(*router, OnOffTheRecordProfileShutdown());
63 profile()->DestroyOffTheRecordProfile();
64 }
65
66 } // namespace media_router
OLDNEW
« no previous file with comments | « chrome/browser/media/router/media_router_factory.cc ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698