Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 <memory> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "chrome/browser/media/router/media_router_factory.h" | 8 #include "chrome/browser/media/router/media_router_factory.h" |
| 9 #include "chrome/browser/media/router/mock_media_router.h" | 9 #include "chrome/browser/media/router/mock_media_router.h" |
| 10 #include "chrome/test/base/testing_profile.h" | 10 #include "chrome/test/base/testing_profile.h" |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 32 | 32 |
| 33 private: | 33 private: |
| 34 content::TestBrowserThreadBundle thread_bundle_; | 34 content::TestBrowserThreadBundle thread_bundle_; |
| 35 TestingProfile profile_; | 35 TestingProfile profile_; |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 TEST_F(MediaRouterFactoryTest, CreateForRegularProfile) { | 38 TEST_F(MediaRouterFactoryTest, CreateForRegularProfile) { |
| 39 ASSERT_TRUE(MediaRouterFactory::GetApiForBrowserContext(profile())); | 39 ASSERT_TRUE(MediaRouterFactory::GetApiForBrowserContext(profile())); |
| 40 } | 40 } |
| 41 | 41 |
| 42 TEST_F(MediaRouterFactoryTest, CreateForOffTheRecordProfile) { | 42 TEST_F(MediaRouterFactoryTest, CreateForIncognitoProfile) { |
| 43 Profile* otr_profile = profile()->GetOffTheRecordProfile(); | 43 Profile* incognito_profile = profile()->GetOffTheRecordProfile(); |
| 44 ASSERT_TRUE(otr_profile); | 44 ASSERT_TRUE(incognito_profile); |
| 45 | 45 |
| 46 // Makes sure a MediaRouter can be created from an OTR Profile. | 46 // Makes sure a MediaRouter can be created from an incognito Profile. |
| 47 MediaRouter* router = | 47 MediaRouter* router = |
| 48 MediaRouterFactory::GetApiForBrowserContext(otr_profile); | 48 MediaRouterFactory::GetApiForBrowserContext(incognito_profile); |
| 49 ASSERT_TRUE(router); | 49 ASSERT_TRUE(router); |
| 50 | 50 |
| 51 // A Profile and its OTR Profile share the same MediaRouter instance. | 51 // A Profile and its incognito Profile share the same MediaRouter instance. |
| 52 ASSERT_EQ(router, MediaRouterFactory::GetApiForBrowserContext(profile())); | 52 ASSERT_EQ(router, MediaRouterFactory::GetApiForBrowserContext(profile())); |
| 53 } | 53 } |
| 54 | 54 |
| 55 TEST_F(MediaRouterFactoryTest, OffTheRecordBrowserContextShutdown) { | 55 TEST_F(MediaRouterFactoryTest, IncognitoBrowserContextShutdown) { |
| 56 MediaRouterFactory::GetMediaRouterFactoryForTest()->SetTestingFactory( | 56 MediaRouterFactory::GetMediaRouterFactoryForTest()->SetTestingFactory( |
| 57 profile(), &CreateMockMediaRouter); | 57 profile(), &CreateMockMediaRouter); |
| 58 | 58 |
| 59 // Creates an off the record profile. | 59 // Creates an incognito (off the record) profile. |
|
apacible
2016/07/09 06:07:28
nit: "(off the record)" can be removed.
trizzofo
2016/07/11 19:20:31
Done.
| |
| 60 profile()->GetOffTheRecordProfile(); | 60 profile()->GetOffTheRecordProfile(); |
| 61 MockMediaRouter* router = static_cast<MockMediaRouter*>( | 61 MockMediaRouter* router = static_cast<MockMediaRouter*>( |
| 62 MediaRouterFactory::GetApiForBrowserContext(profile())); | 62 MediaRouterFactory::GetApiForBrowserContext(profile())); |
| 63 ASSERT_TRUE(router); | 63 ASSERT_TRUE(router); |
| 64 EXPECT_CALL(*router, OnOffTheRecordProfileShutdown()); | 64 EXPECT_CALL(*router, OnIncognitoProfileShutdown()); |
| 65 profile()->DestroyOffTheRecordProfile(); | 65 profile()->DestroyOffTheRecordProfile(); |
| 66 } | 66 } |
| 67 | 67 |
| 68 } // namespace media_router | 68 } // namespace media_router |
| OLD | NEW |