afakhry | d91a619 | 2015-08-28 15:52:19 | [diff] [blame] | 1 | // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef EXTENSIONS_BROWSER_TEST_IMAGE_LOADER_H_ |
| 6 | #define EXTENSIONS_BROWSER_TEST_IMAGE_LOADER_H_ |
| 7 | |
avi | c9cec10 | 2015-12-23 00:39:26 | [diff] [blame] | 8 | #include "base/macros.h" |
afakhry | d91a619 | 2015-08-28 15:52:19 | [diff] [blame] | 9 | #include "base/run_loop.h" |
| 10 | #include "ui/gfx/image/image.h" |
| 11 | |
| 12 | namespace extensions { |
| 13 | |
| 14 | class Extension; |
| 15 | |
| 16 | // Helper class for synchronously loading an extension image resource. |
| 17 | class TestImageLoader { |
| 18 | public: |
| 19 | TestImageLoader(); |
| 20 | ~TestImageLoader(); |
| 21 | |
| 22 | // Loads an image to be used in test from |extension|. |
| 23 | // The image will be loaded from the relative path |image_path|. |
| 24 | static SkBitmap LoadAndGetExtensionBitmap(const Extension* extension, |
| 25 | const std::string& image_path, |
| 26 | int size); |
| 27 | |
| 28 | private: |
| 29 | void OnImageLoaded(const gfx::Image& image); |
| 30 | |
| 31 | SkBitmap LoadAndGetBitmap(const Extension* extension, |
| 32 | const std::string& path, |
| 33 | int size); |
| 34 | |
| 35 | gfx::Image image_; |
| 36 | base::Closure loader_message_loop_quit_; |
| 37 | bool waiting_; |
| 38 | bool image_loaded_; |
| 39 | |
| 40 | DISALLOW_COPY_AND_ASSIGN(TestImageLoader); |
| 41 | }; |
| 42 | |
| 43 | } // namespace extensions |
| 44 | |
| 45 | #endif // EXTENSIONS_BROWSER_TEST_IMAGE_LOADER_H_ |