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 "extensions/browser/image_loader.h" |
6 | 6 |
| 7 #include "base/files/file_path.h" |
7 #include "base/json/json_file_value_serializer.h" | 8 #include "base/json/json_file_value_serializer.h" |
8 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
9 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/strings/string_util.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 12 #include "chrome/browser/chrome_notification_types.h" |
11 #include "chrome/common/chrome_paths.h" | 13 #include "chrome/common/chrome_paths.h" |
12 #include "content/public/browser/notification_service.h" | 14 #include "content/public/browser/notification_service.h" |
13 #include "content/public/test/test_browser_thread.h" | 15 #include "content/public/test/test_browser_thread.h" |
| 16 #include "extensions/browser/component_extension_resource_manager.h" |
| 17 #include "extensions/browser/extensions_browser_client.h" |
14 #include "extensions/common/constants.h" | 18 #include "extensions/common/constants.h" |
15 #include "extensions/common/extension.h" | 19 #include "extensions/common/extension.h" |
16 #include "extensions/common/extension_icon_set.h" | 20 #include "extensions/common/extension_icon_set.h" |
17 #include "extensions/common/extension_resource.h" | 21 #include "extensions/common/extension_resource.h" |
18 #include "extensions/common/manifest.h" | 22 #include "extensions/common/manifest.h" |
19 #include "extensions/common/manifest_handlers/icons_handler.h" | 23 #include "extensions/common/manifest_handlers/icons_handler.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
21 #include "third_party/skia/include/core/SkBitmap.h" | 25 #include "third_party/skia/include/core/SkBitmap.h" |
22 #include "ui/file_manager/grit/file_manager_resources.h" | |
23 #include "ui/gfx/image/image.h" | 26 #include "ui/gfx/image/image.h" |
24 #include "ui/gfx/image/image_family.h" | 27 #include "ui/gfx/image/image_family.h" |
25 #include "ui/gfx/image/image_skia.h" | 28 #include "ui/gfx/image/image_skia.h" |
26 #include "ui/gfx/size.h" | 29 #include "ui/gfx/size.h" |
27 | 30 |
| 31 #if defined(OS_CHROMEOS) |
| 32 #include "ui/file_manager/grit/file_manager_resources.h" |
| 33 #endif |
| 34 |
28 using content::BrowserThread; | 35 using content::BrowserThread; |
29 using extensions::Extension; | 36 using extensions::Extension; |
30 using extensions::ExtensionResource; | 37 using extensions::ExtensionResource; |
31 using extensions::ImageLoader; | 38 using extensions::ImageLoader; |
32 using extensions::Manifest; | 39 using extensions::Manifest; |
33 using extensions::UnloadedExtensionInfo; | 40 using extensions::UnloadedExtensionInfo; |
34 | 41 |
35 class ImageLoaderTest : public testing::Test { | 42 class ImageLoaderTest : public testing::Test { |
36 public: | 43 public: |
37 ImageLoaderTest() | 44 ImageLoaderTest() |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 | 316 |
310 const gfx::ImageSkiaRep* img_rep1 = &image_reps[0]; | 317 const gfx::ImageSkiaRep* img_rep1 = &image_reps[0]; |
311 const gfx::ImageSkiaRep* img_rep2 = &image_reps[1]; | 318 const gfx::ImageSkiaRep* img_rep2 = &image_reps[1]; |
312 EXPECT_EQ(extension_misc::EXTENSION_ICON_BITTY, img_rep1->pixel_width()); | 319 EXPECT_EQ(extension_misc::EXTENSION_ICON_BITTY, img_rep1->pixel_width()); |
313 EXPECT_EQ(1.0f, img_rep1->scale()); | 320 EXPECT_EQ(1.0f, img_rep1->scale()); |
314 EXPECT_EQ(extension_misc::EXTENSION_ICON_SMALLISH, img_rep2->pixel_width()); | 321 EXPECT_EQ(extension_misc::EXTENSION_ICON_SMALLISH, img_rep2->pixel_width()); |
315 EXPECT_EQ(2.0f, img_rep2->scale()); | 322 EXPECT_EQ(2.0f, img_rep2->scale()); |
316 } | 323 } |
317 | 324 |
318 // Tests IsComponentExtensionResource function. | 325 // Tests IsComponentExtensionResource function. |
| 326 // TODO(mukai): move this to ChromeComponentExtensionResourceManager's test. |
319 TEST_F(ImageLoaderTest, IsComponentExtensionResource) { | 327 TEST_F(ImageLoaderTest, IsComponentExtensionResource) { |
| 328 extensions::ComponentExtensionResourceManager* resource_manager = |
| 329 extensions::ExtensionsBrowserClient::Get()-> |
| 330 GetComponentExtensionResourceManager(); |
| 331 if (!resource_manager) |
| 332 return; |
| 333 |
320 scoped_refptr<Extension> extension(CreateExtension( | 334 scoped_refptr<Extension> extension(CreateExtension( |
321 "file_manager", Manifest::COMPONENT)); | 335 "file_manager", Manifest::COMPONENT)); |
322 ASSERT_TRUE(extension.get() != NULL); | 336 ASSERT_TRUE(extension.get() != NULL); |
323 | 337 |
324 ExtensionResource resource = extensions::IconsInfo::GetIconResource( | 338 ExtensionResource resource = extensions::IconsInfo::GetIconResource( |
325 extension.get(), | 339 extension.get(), |
326 extension_misc::EXTENSION_ICON_BITTY, | 340 extension_misc::EXTENSION_ICON_BITTY, |
327 ExtensionIconSet::MATCH_EXACTLY); | 341 ExtensionIconSet::MATCH_EXACTLY); |
328 | 342 |
329 #if defined(OS_CHROMEOS) | 343 #if defined(OS_CHROMEOS) |
330 int resource_id; | 344 int resource_id; |
331 ASSERT_EQ(true, | 345 ASSERT_TRUE(resource_manager->IsComponentExtensionResource( |
332 ImageLoader::IsComponentExtensionResource(extension->path(), | 346 extension->path(), |
333 resource.relative_path(), | 347 resource.relative_path(), |
334 &resource_id)); | 348 &resource_id)); |
335 ASSERT_EQ(IDR_FILE_MANAGER_ICON_16, resource_id); | 349 ASSERT_EQ(IDR_FILE_MANAGER_ICON_16, resource_id); |
336 #endif | 350 #endif |
337 } | 351 } |
OLD | NEW |