blob: c1fb4425c130ab6ebd2c950f38bdb89d09e7e634 [file] [log] [blame]
afakhryd91a6192015-08-28 15:52:191// 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
avic9cec102015-12-23 00:39:268#include "base/macros.h"
afakhryd91a6192015-08-28 15:52:199#include "base/run_loop.h"
10#include "ui/gfx/image/image.h"
11
12namespace extensions {
13
14class Extension;
15
16// Helper class for synchronously loading an extension image resource.
17class 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_