| 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 "chrome/browser/media/router/media_router_ui_service.h" | 7 #include "chrome/browser/media/router/media_router_ui_service.h" |
| 8 #include "chrome/browser/media/router/media_router_ui_service_factory.h" | 8 #include "chrome/browser/media/router/media_router_ui_service_factory.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/toolbar/toolbar_actions_model.h" | 10 #include "chrome/browser/ui/toolbar/toolbar_actions_model.h" |
| 11 #include "chrome/browser/ui/toolbar/toolbar_actions_model_factory.h" | 11 #include "chrome/browser/ui/toolbar/toolbar_actions_model_factory.h" |
| 12 #include "chrome/test/base/testing_profile.h" | 12 #include "chrome/test/base/testing_profile.h" |
| 13 #include "content/public/test/test_browser_thread_bundle.h" | 13 #include "content/public/test/test_browser_thread_bundle.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 15 |
| 16 namespace media_router { | 16 namespace media_router { |
| 17 | 17 |
| 18 class MediaRouterUIServiceFactoryUnitTest : public testing::Test { | 18 class MediaRouterUIServiceFactoryUnitTest : public testing::Test { |
| 19 public: | 19 public: |
| 20 MediaRouterUIServiceFactoryUnitTest() {} | 20 MediaRouterUIServiceFactoryUnitTest() {} |
| 21 ~MediaRouterUIServiceFactoryUnitTest() override {} | 21 ~MediaRouterUIServiceFactoryUnitTest() override {} |
| 22 | 22 |
| 23 void SetUp() override { | 23 void SetUp() override { |
| 24 MediaRouterUIServiceFactory::SetUseInTests(); |
| 25 |
| 24 TestingProfile::Builder builder; | 26 TestingProfile::Builder builder; |
| 25 // MediaRouterUIService instantiates MediaRouterActionController, which | 27 // MediaRouterUIService instantiates MediaRouterActionController, which |
| 26 // requires ToolbarActionsModel. | 28 // requires ToolbarActionsModel. |
| 27 builder.AddTestingFactory(ToolbarActionsModelFactory::GetInstance(), | 29 builder.AddTestingFactory(ToolbarActionsModelFactory::GetInstance(), |
| 28 BuildFakeToolBarActionsModel); | 30 BuildFakeToolBarActionsModel); |
| 29 profile_ = builder.Build(); | 31 profile_ = builder.Build(); |
| 30 } | 32 } |
| 31 | 33 |
| 32 static std::unique_ptr<KeyedService> BuildFakeToolBarActionsModel( | 34 static std::unique_ptr<KeyedService> BuildFakeToolBarActionsModel( |
| 33 content::BrowserContext* context) { | 35 content::BrowserContext* context) { |
| 34 return std::unique_ptr<ToolbarActionsModel>( | 36 return std::unique_ptr<ToolbarActionsModel>( |
| 35 new ToolbarActionsModel(static_cast<Profile*>(context), nullptr)); | 37 new ToolbarActionsModel(static_cast<Profile*>(context), nullptr)); |
| 36 } | 38 } |
| 37 | 39 |
| 38 protected: | 40 protected: |
| 39 content::TestBrowserThreadBundle thread_bundle_; | 41 content::TestBrowserThreadBundle thread_bundle_; |
| 40 Profile* profile() { return profile_.get(); } | 42 Profile* profile() { return profile_.get(); } |
| 41 | 43 |
| 42 private: | 44 private: |
| 43 std::unique_ptr<Profile> profile_; | 45 std::unique_ptr<Profile> profile_; |
| 44 }; | 46 }; |
| 45 | 47 |
| 46 TEST_F(MediaRouterUIServiceFactoryUnitTest, CreateService) { | 48 TEST_F(MediaRouterUIServiceFactoryUnitTest, CreateService) { |
| 47 MediaRouterUIService* service = | 49 MediaRouterUIService* service = |
| 48 MediaRouterUIServiceFactory::GetForBrowserContext(profile()); | 50 MediaRouterUIServiceFactory::GetForBrowserContext(profile()); |
| 49 ASSERT_TRUE(service); | 51 ASSERT_TRUE(service); |
| 50 } | 52 } |
| 51 | 53 |
| 52 } // namespace media_router | 54 } // namespace media_router |
| OLD | NEW |