| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/json/json_file_value_serializer.h" | 9 #include "base/json/json_file_value_serializer.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 // Used to test behavior including images defined by an image skia source. | 50 // Used to test behavior including images defined by an image skia source. |
| 51 // |GetImageForScale| simply returns image representation from the image given | 51 // |GetImageForScale| simply returns image representation from the image given |
| 52 // in the ctor. | 52 // in the ctor. |
| 53 class MockImageSkiaSource : public gfx::ImageSkiaSource { | 53 class MockImageSkiaSource : public gfx::ImageSkiaSource { |
| 54 public: | 54 public: |
| 55 explicit MockImageSkiaSource(const gfx::ImageSkia& image) | 55 explicit MockImageSkiaSource(const gfx::ImageSkia& image) |
| 56 : image_(image) { | 56 : image_(image) { |
| 57 } | 57 } |
| 58 virtual ~MockImageSkiaSource() {} | 58 virtual ~MockImageSkiaSource() {} |
| 59 | 59 |
| 60 virtual gfx::ImageSkiaRep GetImageForScale(float scale) OVERRIDE { | 60 virtual gfx::ImageSkiaRep GetImageForScale(float scale) override { |
| 61 return image_.GetRepresentation(scale); | 61 return image_.GetRepresentation(scale); |
| 62 } | 62 } |
| 63 | 63 |
| 64 private: | 64 private: |
| 65 gfx::ImageSkia image_; | 65 gfx::ImageSkia image_; |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 // Helper class for synchronously loading extension image resource. | 68 // Helper class for synchronously loading extension image resource. |
| 69 class TestImageLoader { | 69 class TestImageLoader { |
| 70 public: | 70 public: |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 | 160 |
| 161 EXPECT_TRUE(valid_value.get()); | 161 EXPECT_TRUE(valid_value.get()); |
| 162 if (!valid_value) | 162 if (!valid_value) |
| 163 return NULL; | 163 return NULL; |
| 164 | 164 |
| 165 return Extension::Create(test_file, location, *valid_value, | 165 return Extension::Create(test_file, location, *valid_value, |
| 166 Extension::NO_FLAGS, &error); | 166 Extension::NO_FLAGS, &error); |
| 167 } | 167 } |
| 168 | 168 |
| 169 // testing::Test overrides: | 169 // testing::Test overrides: |
| 170 virtual void SetUp() OVERRIDE { | 170 virtual void SetUp() override { |
| 171 file_thread_.Start(); | 171 file_thread_.Start(); |
| 172 io_thread_.Start(); | 172 io_thread_.Start(); |
| 173 } | 173 } |
| 174 | 174 |
| 175 // IconImage::Delegate overrides: | 175 // IconImage::Delegate overrides: |
| 176 virtual void OnExtensionIconImageChanged(IconImage* image) OVERRIDE { | 176 virtual void OnExtensionIconImageChanged(IconImage* image) override { |
| 177 image_loaded_count_++; | 177 image_loaded_count_++; |
| 178 if (quit_in_image_loaded_) | 178 if (quit_in_image_loaded_) |
| 179 base::MessageLoop::current()->Quit(); | 179 base::MessageLoop::current()->Quit(); |
| 180 } | 180 } |
| 181 | 181 |
| 182 gfx::ImageSkia GetDefaultIcon() { | 182 gfx::ImageSkia GetDefaultIcon() { |
| 183 return gfx::ImageSkia(gfx::ImageSkiaRep(gfx::Size(16, 16), 1.0f)); | 183 return gfx::ImageSkia(gfx::ImageSkiaRep(gfx::Size(16, 16), 1.0f)); |
| 184 } | 184 } |
| 185 | 185 |
| 186 // Loads an image to be used in test from the extension. | 186 // Loads an image to be used in test from the extension. |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 // image of the size. It could be blank or a rescale from the existing 1.0f | 556 // image of the size. It could be blank or a rescale from the existing 1.0f |
| 557 // icon. | 557 // icon. |
| 558 representation = image_skia.GetRepresentation(2.0f); | 558 representation = image_skia.GetRepresentation(2.0f); |
| 559 | 559 |
| 560 EXPECT_EQ(16, representation.GetWidth()); | 560 EXPECT_EQ(16, representation.GetWidth()); |
| 561 EXPECT_EQ(16, representation.GetHeight()); | 561 EXPECT_EQ(16, representation.GetHeight()); |
| 562 EXPECT_EQ(2.0f, representation.scale()); | 562 EXPECT_EQ(2.0f, representation.scale()); |
| 563 } | 563 } |
| 564 | 564 |
| 565 } // namespace extensions | 565 } // namespace extensions |
| OLD | NEW |