| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 base::FilePath test_file; | 108 base::FilePath test_file; |
| 109 if (!PathService::Get(chrome::DIR_TEST_DATA, &test_file)) { | 109 if (!PathService::Get(chrome::DIR_TEST_DATA, &test_file)) { |
| 110 EXPECT_FALSE(true); | 110 EXPECT_FALSE(true); |
| 111 return NULL; | 111 return NULL; |
| 112 } | 112 } |
| 113 test_file = test_file.AppendASCII("extensions/api_test").AppendASCII(name); | 113 test_file = test_file.AppendASCII("extensions/api_test").AppendASCII(name); |
| 114 int error_code = 0; | 114 int error_code = 0; |
| 115 std::string error; | 115 std::string error; |
| 116 JSONFileValueDeserializer deserializer( | 116 JSONFileValueDeserializer deserializer( |
| 117 test_file.AppendASCII("manifest.json")); | 117 test_file.AppendASCII("manifest.json")); |
| 118 scoped_ptr<base::DictionaryValue> valid_value = base::DictionaryValue::From( | 118 std::unique_ptr<base::DictionaryValue> valid_value = |
| 119 deserializer.Deserialize(&error_code, &error)); | 119 base::DictionaryValue::From( |
| 120 deserializer.Deserialize(&error_code, &error)); |
| 120 EXPECT_EQ(0, error_code) << error; | 121 EXPECT_EQ(0, error_code) << error; |
| 121 if (error_code != 0) | 122 if (error_code != 0) |
| 122 return NULL; | 123 return NULL; |
| 123 | 124 |
| 124 EXPECT_TRUE(valid_value.get()); | 125 EXPECT_TRUE(valid_value.get()); |
| 125 if (!valid_value) | 126 if (!valid_value) |
| 126 return NULL; | 127 return NULL; |
| 127 | 128 |
| 128 scoped_refptr<Extension> extension = | 129 scoped_refptr<Extension> extension = |
| 129 Extension::Create(test_file, location, *valid_value, | 130 Extension::Create(test_file, location, *valid_value, |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 } | 173 } |
| 173 | 174 |
| 174 TestingProfile* profile() { return profile_.get(); } | 175 TestingProfile* profile() { return profile_.get(); } |
| 175 | 176 |
| 176 private: | 177 private: |
| 177 bool quit_in_icon_updated_; | 178 bool quit_in_icon_updated_; |
| 178 base::MessageLoop ui_loop_; | 179 base::MessageLoop ui_loop_; |
| 179 content::TestBrowserThread ui_thread_; | 180 content::TestBrowserThread ui_thread_; |
| 180 content::TestBrowserThread file_thread_; | 181 content::TestBrowserThread file_thread_; |
| 181 content::TestBrowserThread io_thread_; | 182 content::TestBrowserThread io_thread_; |
| 182 scoped_ptr<TestingProfile> profile_; | 183 std::unique_ptr<TestingProfile> profile_; |
| 183 ExtensionService* extension_service_; | 184 ExtensionService* extension_service_; |
| 184 | 185 |
| 185 #if defined OS_CHROMEOS | 186 #if defined OS_CHROMEOS |
| 186 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; | 187 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; |
| 187 chromeos::ScopedTestCrosSettings test_cros_settings_; | 188 chromeos::ScopedTestCrosSettings test_cros_settings_; |
| 188 chromeos::ScopedTestUserManager test_user_manager_; | 189 chromeos::ScopedTestUserManager test_user_manager_; |
| 189 #endif | 190 #endif |
| 190 | 191 |
| 191 DISALLOW_COPY_AND_ASSIGN(ExtensionActionIconFactoryTest); | 192 DISALLOW_COPY_AND_ASSIGN(ExtensionActionIconFactoryTest); |
| 192 }; | 193 }; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 ExtensionAction* browser_action = GetBrowserAction(*extension.get()); | 274 ExtensionAction* browser_action = GetBrowserAction(*extension.get()); |
| 274 ASSERT_TRUE(browser_action); | 275 ASSERT_TRUE(browser_action); |
| 275 ASSERT_FALSE(browser_action->default_icon()); | 276 ASSERT_FALSE(browser_action->default_icon()); |
| 276 ASSERT_TRUE(browser_action->GetExplicitlySetIcon(0 /*tab id*/).IsEmpty()); | 277 ASSERT_TRUE(browser_action->GetExplicitlySetIcon(0 /*tab id*/).IsEmpty()); |
| 277 | 278 |
| 278 int icon_size = ExtensionAction::ActionIconSize(); | 279 int icon_size = ExtensionAction::ActionIconSize(); |
| 279 gfx::Image default_icon = | 280 gfx::Image default_icon = |
| 280 EnsureImageSize(LoadIcon("browser_action/no_icon/icon.png"), icon_size); | 281 EnsureImageSize(LoadIcon("browser_action/no_icon/icon.png"), icon_size); |
| 281 ASSERT_FALSE(default_icon.IsEmpty()); | 282 ASSERT_FALSE(default_icon.IsEmpty()); |
| 282 | 283 |
| 283 scoped_ptr<ExtensionIconSet> default_icon_set(new ExtensionIconSet()); | 284 std::unique_ptr<ExtensionIconSet> default_icon_set(new ExtensionIconSet()); |
| 284 default_icon_set->Add(icon_size, "icon.png"); | 285 default_icon_set->Add(icon_size, "icon.png"); |
| 285 | 286 |
| 286 browser_action->SetDefaultIconForTest(std::move(default_icon_set)); | 287 browser_action->SetDefaultIconForTest(std::move(default_icon_set)); |
| 287 ASSERT_TRUE(browser_action->default_icon()); | 288 ASSERT_TRUE(browser_action->default_icon()); |
| 288 | 289 |
| 289 ExtensionActionIconFactory icon_factory( | 290 ExtensionActionIconFactory icon_factory( |
| 290 profile(), extension.get(), browser_action, this); | 291 profile(), extension.get(), browser_action, this); |
| 291 | 292 |
| 292 gfx::Image icon = icon_factory.GetIcon(0); | 293 gfx::Image icon = icon_factory.GetIcon(0); |
| 293 | 294 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 310 icon = icon_factory.GetIcon(1); | 311 icon = icon_factory.GetIcon(1); |
| 311 | 312 |
| 312 EXPECT_TRUE(ImageRepsAreEqual( | 313 EXPECT_TRUE(ImageRepsAreEqual( |
| 313 default_icon.ToImageSkia()->GetRepresentation(1.0f), | 314 default_icon.ToImageSkia()->GetRepresentation(1.0f), |
| 314 icon.ToImageSkia()->GetRepresentation(1.0f))); | 315 icon.ToImageSkia()->GetRepresentation(1.0f))); |
| 315 | 316 |
| 316 } | 317 } |
| 317 | 318 |
| 318 } // namespace | 319 } // namespace |
| 319 } // namespace extensions | 320 } // namespace extensions |
| OLD | NEW |