| 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/image_loader.h" | 5 #include "chrome/browser/extensions/image_loader.h" |
| 6 | 6 |
| 7 #include "base/json/json_file_value_serializer.h" | 7 #include "base/json/json_file_value_serializer.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "chrome/common/chrome_notification_types.h" | 10 #include "chrome/common/chrome_notification_types.h" |
| 11 #include "chrome/common/chrome_paths.h" | 11 #include "chrome/common/chrome_paths.h" |
| 12 #include "chrome/common/extensions/extension.h" | 12 #include "chrome/common/extensions/extension.h" |
| 13 #include "chrome/common/extensions/extension_constants.h" | 13 #include "chrome/common/extensions/extension_constants.h" |
| 14 #include "chrome/common/extensions/extension_icon_set.h" | 14 #include "chrome/common/extensions/extension_icon_set.h" |
| 15 #include "chrome/common/extensions/manifest.h" | 15 #include "chrome/common/extensions/manifest.h" |
| 16 #include "chrome/common/extensions/manifest_handler.h" | |
| 17 #include "chrome/common/extensions/manifest_handlers/icons_handler.h" | 16 #include "chrome/common/extensions/manifest_handlers/icons_handler.h" |
| 18 #include "content/public/browser/notification_service.h" | 17 #include "content/public/browser/notification_service.h" |
| 19 #include "content/public/test/test_browser_thread.h" | 18 #include "content/public/test/test_browser_thread.h" |
| 20 #include "extensions/common/extension_resource.h" | 19 #include "extensions/common/extension_resource.h" |
| 21 #include "grit/component_extension_resources.h" | 20 #include "grit/component_extension_resources.h" |
| 22 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 23 #include "third_party/skia/include/core/SkBitmap.h" | 22 #include "third_party/skia/include/core/SkBitmap.h" |
| 24 #include "ui/gfx/image/image.h" | 23 #include "ui/gfx/image/image.h" |
| 25 #include "ui/gfx/image/image_skia.h" | 24 #include "ui/gfx/image/image_skia.h" |
| 26 #include "ui/gfx/size.h" | 25 #include "ui/gfx/size.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 } | 92 } |
| 94 return Extension::Create(test_file, location, *valid_value, | 93 return Extension::Create(test_file, location, *valid_value, |
| 95 Extension::NO_FLAGS, &error); | 94 Extension::NO_FLAGS, &error); |
| 96 } | 95 } |
| 97 | 96 |
| 98 gfx::Image image_; | 97 gfx::Image image_; |
| 99 | 98 |
| 100 private: | 99 private: |
| 101 virtual void SetUp() OVERRIDE { | 100 virtual void SetUp() OVERRIDE { |
| 102 testing::Test::SetUp(); | 101 testing::Test::SetUp(); |
| 103 (new extensions::IconsHandler)->Register(); | |
| 104 | |
| 105 file_thread_.Start(); | 102 file_thread_.Start(); |
| 106 io_thread_.Start(); | 103 io_thread_.Start(); |
| 107 } | 104 } |
| 108 | 105 |
| 109 virtual void TearDown() OVERRIDE { | |
| 110 extensions::ManifestHandler::ClearRegistryForTesting(); | |
| 111 } | |
| 112 | |
| 113 int image_loaded_count_; | 106 int image_loaded_count_; |
| 114 bool quit_in_image_loaded_; | 107 bool quit_in_image_loaded_; |
| 115 MessageLoop ui_loop_; | 108 MessageLoop ui_loop_; |
| 116 content::TestBrowserThread ui_thread_; | 109 content::TestBrowserThread ui_thread_; |
| 117 content::TestBrowserThread file_thread_; | 110 content::TestBrowserThread file_thread_; |
| 118 content::TestBrowserThread io_thread_; | 111 content::TestBrowserThread io_thread_; |
| 119 }; | 112 }; |
| 120 | 113 |
| 121 // Tests loading an image works correctly. | 114 // Tests loading an image works correctly. |
| 122 TEST_F(ImageLoaderTest, LoadImage) { | 115 TEST_F(ImageLoaderTest, LoadImage) { |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 | 251 |
| 259 #if defined(FILE_MANAGER_EXTENSION) | 252 #if defined(FILE_MANAGER_EXTENSION) |
| 260 int resource_id; | 253 int resource_id; |
| 261 ASSERT_EQ(true, | 254 ASSERT_EQ(true, |
| 262 ImageLoader::IsComponentExtensionResource(extension->path(), | 255 ImageLoader::IsComponentExtensionResource(extension->path(), |
| 263 resource.relative_path(), | 256 resource.relative_path(), |
| 264 &resource_id)); | 257 &resource_id)); |
| 265 ASSERT_EQ(IDR_FILE_MANAGER_ICON_16, resource_id); | 258 ASSERT_EQ(IDR_FILE_MANAGER_ICON_16, resource_id); |
| 266 #endif | 259 #endif |
| 267 } | 260 } |
| OLD | NEW |