| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_action_icon_factory.h" | 5 #include "chrome/browser/extensions/extension_action_icon_factory.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 | 137 |
| 138 // testing::Test overrides: | 138 // testing::Test overrides: |
| 139 void SetUp() override { | 139 void SetUp() override { |
| 140 file_thread_.Start(); | 140 file_thread_.Start(); |
| 141 io_thread_.Start(); | 141 io_thread_.Start(); |
| 142 profile_.reset(new TestingProfile); | 142 profile_.reset(new TestingProfile); |
| 143 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | 143 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
| 144 extension_service_ = static_cast<extensions::TestExtensionSystem*>( | 144 extension_service_ = static_cast<extensions::TestExtensionSystem*>( |
| 145 extensions::ExtensionSystem::Get(profile_.get()))-> | 145 extensions::ExtensionSystem::Get(profile_.get()))-> |
| 146 CreateExtensionService(&command_line, base::FilePath(), false); | 146 CreateExtensionService(&command_line, base::FilePath(), false); |
| 147 // Any call by a previous test to MaterialDesignController::GetMode() will | 147 material_design_state_.reset( |
| 148 // initialize and cache the mode. This ensures that these tests will run | 148 new ui::test::MaterialDesignControllerTestAPI(GetParam())); |
| 149 // from a non-initialized state. | |
| 150 ui::test::MaterialDesignControllerTestAPI::UninitializeMode(); | |
| 151 ui::test::MaterialDesignControllerTestAPI::SetMode(GetParam()); | |
| 152 } | 149 } |
| 153 | 150 |
| 154 void TearDown() override { | 151 void TearDown() override { |
| 155 ui::test::MaterialDesignControllerTestAPI::UninitializeMode(); | 152 material_design_state_.reset(); |
| 156 profile_.reset(); // Get all DeleteSoon calls sent to ui_loop_. | 153 profile_.reset(); // Get all DeleteSoon calls sent to ui_loop_. |
| 157 ui_loop_.RunUntilIdle(); | 154 ui_loop_.RunUntilIdle(); |
| 158 } | 155 } |
| 159 | 156 |
| 160 // ExtensionActionIconFactory::Observer overrides: | 157 // ExtensionActionIconFactory::Observer overrides: |
| 161 void OnIconUpdated() override { | 158 void OnIconUpdated() override { |
| 162 if (quit_in_icon_updated_) | 159 if (quit_in_icon_updated_) |
| 163 base::MessageLoop::current()->QuitWhenIdle(); | 160 base::MessageLoop::current()->QuitWhenIdle(); |
| 164 } | 161 } |
| 165 | 162 |
| 166 gfx::ImageSkia GetFavicon() { | 163 gfx::ImageSkia GetFavicon() { |
| 167 return *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 164 return *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 168 IDR_EXTENSIONS_FAVICON); | 165 IDR_EXTENSIONS_FAVICON); |
| 169 } | 166 } |
| 170 | 167 |
| 171 ExtensionAction* GetBrowserAction(const Extension& extension) { | 168 ExtensionAction* GetBrowserAction(const Extension& extension) { |
| 172 return ExtensionActionManager::Get(profile())->GetBrowserAction(extension); | 169 return ExtensionActionManager::Get(profile())->GetBrowserAction(extension); |
| 173 } | 170 } |
| 174 | 171 |
| 175 TestingProfile* profile() { return profile_.get(); } | 172 TestingProfile* profile() { return profile_.get(); } |
| 176 | 173 |
| 177 private: | 174 private: |
| 178 bool quit_in_icon_updated_; | 175 bool quit_in_icon_updated_; |
| 179 base::MessageLoop ui_loop_; | 176 base::MessageLoop ui_loop_; |
| 180 content::TestBrowserThread ui_thread_; | 177 content::TestBrowserThread ui_thread_; |
| 181 content::TestBrowserThread file_thread_; | 178 content::TestBrowserThread file_thread_; |
| 182 content::TestBrowserThread io_thread_; | 179 content::TestBrowserThread io_thread_; |
| 183 std::unique_ptr<TestingProfile> profile_; | 180 std::unique_ptr<TestingProfile> profile_; |
| 184 ExtensionService* extension_service_; | 181 ExtensionService* extension_service_; |
| 182 std::unique_ptr<ui::test::MaterialDesignControllerTestAPI> |
| 183 material_design_state_; |
| 185 | 184 |
| 186 #if defined OS_CHROMEOS | 185 #if defined OS_CHROMEOS |
| 187 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; | 186 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; |
| 188 chromeos::ScopedTestCrosSettings test_cros_settings_; | 187 chromeos::ScopedTestCrosSettings test_cros_settings_; |
| 189 chromeos::ScopedTestUserManager test_user_manager_; | 188 chromeos::ScopedTestUserManager test_user_manager_; |
| 190 #endif | 189 #endif |
| 191 | 190 |
| 192 DISALLOW_COPY_AND_ASSIGN(ExtensionActionIconFactoryTest); | 191 DISALLOW_COPY_AND_ASSIGN(ExtensionActionIconFactoryTest); |
| 193 }; | 192 }; |
| 194 | 193 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 icon = icon_factory.GetIcon(1); | 310 icon = icon_factory.GetIcon(1); |
| 312 | 311 |
| 313 EXPECT_TRUE(ImageRepsAreEqual( | 312 EXPECT_TRUE(ImageRepsAreEqual( |
| 314 default_icon.ToImageSkia()->GetRepresentation(1.0f), | 313 default_icon.ToImageSkia()->GetRepresentation(1.0f), |
| 315 icon.ToImageSkia()->GetRepresentation(1.0f))); | 314 icon.ToImageSkia()->GetRepresentation(1.0f))); |
| 316 | 315 |
| 317 } | 316 } |
| 318 | 317 |
| 319 } // namespace | 318 } // namespace |
| 320 } // namespace extensions | 319 } // namespace extensions |
| OLD | NEW |