| 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 "extensions/browser/extension_icon_image.h" | 5 #include "extensions/browser/extension_icon_image.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/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "chrome/common/chrome_paths.h" | |
| 11 #include "chrome/test/base/testing_profile.h" | 10 #include "chrome/test/base/testing_profile.h" |
| 12 #include "content/public/test/test_browser_thread.h" | 11 #include "content/public/test/test_browser_thread.h" |
| 13 #include "extensions/browser/image_loader.h" | 12 #include "extensions/browser/image_loader.h" |
| 14 #include "extensions/common/extension.h" | 13 #include "extensions/common/extension.h" |
| 14 #include "extensions/common/extension_paths.h" |
| 15 #include "extensions/common/manifest.h" | 15 #include "extensions/common/manifest.h" |
| 16 #include "extensions/common/manifest_handlers/icons_handler.h" | 16 #include "extensions/common/manifest_handlers/icons_handler.h" |
| 17 #include "skia/ext/image_operations.h" | 17 #include "skia/ext/image_operations.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 19 #include "ui/base/resource/resource_bundle.h" | 19 #include "ui/base/resource/resource_bundle.h" |
| 20 #include "ui/gfx/image/image_skia_source.h" | 20 #include "ui/gfx/image/image_skia_source.h" |
| 21 #include "ui/gfx/skia_util.h" | 21 #include "ui/gfx/skia_util.h" |
| 22 | 22 |
| 23 using content::BrowserThread; | 23 using content::BrowserThread; |
| 24 using extensions::Extension; | 24 using extensions::Extension; |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 int ImageLoadedCount() { | 134 int ImageLoadedCount() { |
| 135 int result = image_loaded_count_; | 135 int result = image_loaded_count_; |
| 136 image_loaded_count_ = 0; | 136 image_loaded_count_ = 0; |
| 137 return result; | 137 return result; |
| 138 } | 138 } |
| 139 | 139 |
| 140 scoped_refptr<Extension> CreateExtension(const char* name, | 140 scoped_refptr<Extension> CreateExtension(const char* name, |
| 141 Manifest::Location location) { | 141 Manifest::Location location) { |
| 142 // Create and load an extension. | 142 // Create and load an extension. |
| 143 base::FilePath test_file; | 143 base::FilePath test_file; |
| 144 if (!PathService::Get(chrome::DIR_TEST_DATA, &test_file)) { | 144 if (!PathService::Get(extensions::DIR_TEST_DATA, &test_file)) { |
| 145 EXPECT_FALSE(true); | 145 EXPECT_FALSE(true); |
| 146 return NULL; | 146 return NULL; |
| 147 } | 147 } |
| 148 test_file = test_file.AppendASCII("extensions").AppendASCII(name); | 148 test_file = test_file.AppendASCII(name); |
| 149 int error_code = 0; | 149 int error_code = 0; |
| 150 std::string error; | 150 std::string error; |
| 151 JSONFileValueSerializer serializer(test_file.AppendASCII("app.json")); | 151 JSONFileValueSerializer serializer(test_file.AppendASCII("manifest.json")); |
| 152 scoped_ptr<base::DictionaryValue> valid_value( | 152 scoped_ptr<base::DictionaryValue> valid_value( |
| 153 static_cast<base::DictionaryValue*>(serializer.Deserialize(&error_code, | 153 static_cast<base::DictionaryValue*>(serializer.Deserialize(&error_code, |
| 154 &error))); | 154 &error))); |
| 155 EXPECT_EQ(0, error_code) << error; | 155 EXPECT_EQ(0, error_code) << error; |
| 156 if (error_code != 0) | 156 if (error_code != 0) |
| 157 return NULL; | 157 return NULL; |
| 158 | 158 |
| 159 EXPECT_TRUE(valid_value.get()); | 159 EXPECT_TRUE(valid_value.get()); |
| 160 if (!valid_value) | 160 if (!valid_value) |
| 161 return NULL; | 161 return NULL; |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 | 560 |
| 561 // When requesting another representation, we should not crash and return some | 561 // When requesting another representation, we should not crash and return some |
| 562 // image of the size. It could be blank or a rescale from the existing 1.0f | 562 // image of the size. It could be blank or a rescale from the existing 1.0f |
| 563 // icon. | 563 // icon. |
| 564 representation = image_skia.GetRepresentation(2.0f); | 564 representation = image_skia.GetRepresentation(2.0f); |
| 565 | 565 |
| 566 EXPECT_EQ(16, representation.GetWidth()); | 566 EXPECT_EQ(16, representation.GetWidth()); |
| 567 EXPECT_EQ(16, representation.GetHeight()); | 567 EXPECT_EQ(16, representation.GetHeight()); |
| 568 EXPECT_EQ(2.0f, representation.scale()); | 568 EXPECT_EQ(2.0f, representation.scale()); |
| 569 } | 569 } |
| OLD | NEW |