OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/extensions/extension_web_ui.h" |
| 6 |
5 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/memory/ptr_util.h" |
6 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
7 #include "build/build_config.h" | 10 #include "build/build_config.h" |
8 #include "chrome/browser/extensions/extension_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
9 #include "chrome/browser/extensions/extension_web_ui.h" | |
10 #include "chrome/browser/extensions/extension_web_ui_override_registrar.h" | 12 #include "chrome/browser/extensions/extension_web_ui_override_registrar.h" |
11 #include "chrome/browser/extensions/test_extension_system.h" | 13 #include "chrome/browser/extensions/test_extension_system.h" |
12 #include "chrome/test/base/testing_profile.h" | 14 #include "chrome/test/base/testing_profile.h" |
13 #include "content/public/test/test_browser_thread.h" | 15 #include "content/public/test/test_browser_thread.h" |
14 #include "extensions/browser/extension_system.h" | 16 #include "extensions/browser/extension_system.h" |
15 #include "extensions/common/extension.h" | 17 #include "extensions/common/extension.h" |
16 #include "extensions/common/extension_builder.h" | 18 #include "extensions/common/extension_builder.h" |
17 #include "extensions/common/manifest_constants.h" | 19 #include "extensions/common/manifest_constants.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
19 | 21 |
20 #if defined(OS_CHROMEOS) | 22 #if defined(OS_CHROMEOS) |
21 #include "chrome/browser/chromeos/login/users/scoped_test_user_manager.h" | 23 #include "chrome/browser/chromeos/login/users/scoped_test_user_manager.h" |
22 #include "chrome/browser/chromeos/settings/cros_settings.h" | 24 #include "chrome/browser/chromeos/settings/cros_settings.h" |
23 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 25 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
24 #endif | 26 #endif |
25 | 27 |
26 namespace extensions { | 28 namespace extensions { |
27 | 29 |
28 namespace { | 30 namespace { |
29 | 31 |
30 scoped_ptr<KeyedService> BuildOverrideRegistrar( | 32 std::unique_ptr<KeyedService> BuildOverrideRegistrar( |
31 content::BrowserContext* context) { | 33 content::BrowserContext* context) { |
32 return make_scoped_ptr(new ExtensionWebUIOverrideRegistrar(context)); | 34 return base::WrapUnique(new ExtensionWebUIOverrideRegistrar(context)); |
33 } | 35 } |
34 | 36 |
35 } // namespace | 37 } // namespace |
36 | 38 |
37 class ExtensionWebUITest : public testing::Test { | 39 class ExtensionWebUITest : public testing::Test { |
38 public: | 40 public: |
39 ExtensionWebUITest() | 41 ExtensionWebUITest() |
40 : ui_thread_(content::BrowserThread::UI, &message_loop_) {} | 42 : ui_thread_(content::BrowserThread::UI, &message_loop_) {} |
41 | 43 |
42 protected: | 44 protected: |
43 void SetUp() override { | 45 void SetUp() override { |
44 profile_.reset(new TestingProfile()); | 46 profile_.reset(new TestingProfile()); |
45 TestExtensionSystem* system = | 47 TestExtensionSystem* system = |
46 static_cast<TestExtensionSystem*>(ExtensionSystem::Get(profile_.get())); | 48 static_cast<TestExtensionSystem*>(ExtensionSystem::Get(profile_.get())); |
47 extension_service_ = system->CreateExtensionService( | 49 extension_service_ = system->CreateExtensionService( |
48 base::CommandLine::ForCurrentProcess(), base::FilePath(), false); | 50 base::CommandLine::ForCurrentProcess(), base::FilePath(), false); |
49 ExtensionWebUIOverrideRegistrar::GetFactoryInstance()->SetTestingFactory( | 51 ExtensionWebUIOverrideRegistrar::GetFactoryInstance()->SetTestingFactory( |
50 profile_.get(), &BuildOverrideRegistrar); | 52 profile_.get(), &BuildOverrideRegistrar); |
51 ExtensionWebUIOverrideRegistrar::GetFactoryInstance()->Get(profile_.get()); | 53 ExtensionWebUIOverrideRegistrar::GetFactoryInstance()->Get(profile_.get()); |
52 } | 54 } |
53 | 55 |
54 void TearDown() override { | 56 void TearDown() override { |
55 profile_.reset(); | 57 profile_.reset(); |
56 message_loop_.RunUntilIdle(); | 58 message_loop_.RunUntilIdle(); |
57 } | 59 } |
58 | 60 |
59 scoped_ptr<TestingProfile> profile_; | 61 std::unique_ptr<TestingProfile> profile_; |
60 ExtensionService* extension_service_; | 62 ExtensionService* extension_service_; |
61 base::MessageLoop message_loop_; | 63 base::MessageLoop message_loop_; |
62 content::TestBrowserThread ui_thread_; | 64 content::TestBrowserThread ui_thread_; |
63 | 65 |
64 #if defined OS_CHROMEOS | 66 #if defined OS_CHROMEOS |
65 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; | 67 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; |
66 chromeos::ScopedTestCrosSettings test_cros_settings_; | 68 chromeos::ScopedTestCrosSettings test_cros_settings_; |
67 chromeos::ScopedTestUserManager test_user_manager_; | 69 chromeos::ScopedTestUserManager test_user_manager_; |
68 #endif | 70 #endif |
69 }; | 71 }; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 changed_url = kBookmarksUrl; | 154 changed_url = kBookmarksUrl; |
153 EXPECT_TRUE( | 155 EXPECT_TRUE( |
154 ExtensionWebUI::HandleChromeURLOverride(&changed_url, profile_.get())); | 156 ExtensionWebUI::HandleChromeURLOverride(&changed_url, profile_.get())); |
155 EXPECT_EQ(kExpectedUnpackedOverrideUrl, changed_url); | 157 EXPECT_EQ(kExpectedUnpackedOverrideUrl, changed_url); |
156 EXPECT_TRUE(ExtensionWebUI::HandleChromeURLOverrideReverse(&changed_url, | 158 EXPECT_TRUE(ExtensionWebUI::HandleChromeURLOverrideReverse(&changed_url, |
157 profile_.get())); | 159 profile_.get())); |
158 EXPECT_EQ(kBookmarksUrl, changed_url); | 160 EXPECT_EQ(kBookmarksUrl, changed_url); |
159 } | 161 } |
160 | 162 |
161 } // namespace extensions | 163 } // namespace extensions |
OLD | NEW |