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 // Because the unit tests for gfx::Image are spread across multiple | 5 // Because the unit tests for gfx::Image are spread across multiple |
6 // implementation files, this header contains the reusable components. | 6 // implementation files, this header contains the reusable components. |
7 | 7 |
8 #ifndef UI_GFX_IMAGE_IMAGE_UNITTEST_UTIL_H_ | 8 #ifndef UI_GFX_IMAGE_IMAGE_UNITTEST_UTIL_H_ |
9 #define UI_GFX_IMAGE_IMAGE_UNITTEST_UTIL_H_ | 9 #define UI_GFX_IMAGE_IMAGE_UNITTEST_UTIL_H_ |
10 | 10 |
11 #include "ui/base/layout.h" | |
12 #include "ui/gfx/image/image.h" | 11 #include "ui/gfx/image/image.h" |
13 #include "third_party/skia/include/core/SkColor.h" | 12 #include "third_party/skia/include/core/SkColor.h" |
14 | 13 |
15 namespace gfx { | 14 namespace gfx { |
16 namespace test { | 15 namespace test { |
17 | 16 |
18 #if defined(OS_IOS) | 17 #if defined(OS_IOS) |
19 typedef UIImage* PlatformImage; | 18 typedef UIImage* PlatformImage; |
20 #elif defined(OS_MACOSX) | 19 #elif defined(OS_MACOSX) |
21 typedef NSImage* PlatformImage; | 20 typedef NSImage* PlatformImage; |
22 #elif defined(TOOLKIT_GTK) | 21 #elif defined(TOOLKIT_GTK) |
23 typedef GdkPixbuf* PlatformImage; | 22 typedef GdkPixbuf* PlatformImage; |
24 #else | 23 #else |
25 typedef gfx::ImageSkia PlatformImage; | 24 typedef gfx::ImageSkia PlatformImage; |
26 #endif | 25 #endif |
27 | 26 |
28 std::vector<ui::ScaleFactor> Get1xAnd2xScaleFactors(); | 27 std::vector<float> Get1xAnd2xScales(); |
29 | 28 |
30 // Create a bitmap of |width|x|height|. | 29 // Create a bitmap of |width|x|height|. |
31 const SkBitmap CreateBitmap(int width, int height); | 30 const SkBitmap CreateBitmap(int width, int height); |
32 | 31 |
33 // Creates an ImageSkia of |width|x|height| DIP with bitmap data for an | 32 // Creates an ImageSkia of |width|x|height| DIP with bitmap data for an |
34 // arbitrary scale factor. | 33 // arbitrary scale factor. |
35 gfx::ImageSkia CreateImageSkia(int width, int height); | 34 gfx::ImageSkia CreateImageSkia(int width, int height); |
36 | 35 |
37 // Returns PNG encoded bytes for a bitmap of |edge_size|x|edge_size|. | 36 // Returns PNG encoded bytes for a bitmap of |edge_size|x|edge_size|. |
38 scoped_refptr<base::RefCountedMemory> CreatePNGBytes(int edge_size); | 37 scoped_refptr<base::RefCountedMemory> CreatePNGBytes(int edge_size); |
(...skipping 19 matching lines...) Expand all Loading... |
58 // described by |width|, |height|, and |scale_factors|. | 57 // described by |width|, |height|, and |scale_factors|. |
59 // The structure matches if: | 58 // The structure matches if: |
60 // - |image_skia| is non null. | 59 // - |image_skia| is non null. |
61 // - |image_skia| has ImageSkiaReps of |scale_factors|. | 60 // - |image_skia| has ImageSkiaReps of |scale_factors|. |
62 // - Each of the ImageSkiaReps has a pixel size of |image_skia|.size() * | 61 // - Each of the ImageSkiaReps has a pixel size of |image_skia|.size() * |
63 // scale_factor. | 62 // scale_factor. |
64 bool ImageSkiaStructureMatches( | 63 bool ImageSkiaStructureMatches( |
65 const gfx::ImageSkia& image_skia, | 64 const gfx::ImageSkia& image_skia, |
66 int width, | 65 int width, |
67 int height, | 66 int height, |
68 const std::vector<ui::ScaleFactor>& scale_factors); | 67 const std::vector<float>& scale_factors); |
69 | 68 |
70 bool IsEmpty(const gfx::Image& image); | 69 bool IsEmpty(const gfx::Image& image); |
71 | 70 |
72 PlatformImage CreatePlatformImage(); | 71 PlatformImage CreatePlatformImage(); |
73 | 72 |
74 gfx::Image::RepresentationType GetPlatformRepresentationType(); | 73 gfx::Image::RepresentationType GetPlatformRepresentationType(); |
75 | 74 |
76 PlatformImage ToPlatformType(const gfx::Image& image); | 75 PlatformImage ToPlatformType(const gfx::Image& image); |
77 PlatformImage CopyPlatformType(const gfx::Image& image); | 76 PlatformImage CopyPlatformType(const gfx::Image& image); |
78 | 77 |
79 SkColor GetPlatformImageColor(PlatformImage image, int x, int y); | 78 SkColor GetPlatformImageColor(PlatformImage image, int x, int y); |
80 void CheckColors(SkColor color1, SkColor color2); | 79 void CheckColors(SkColor color1, SkColor color2); |
81 void CheckIsTransparent(SkColor color); | 80 void CheckIsTransparent(SkColor color); |
82 | 81 |
83 bool IsPlatformImageValid(PlatformImage image); | 82 bool IsPlatformImageValid(PlatformImage image); |
84 | 83 |
85 bool PlatformImagesEqual(PlatformImage image1, PlatformImage image2); | 84 bool PlatformImagesEqual(PlatformImage image1, PlatformImage image2); |
86 | 85 |
87 } // namespace test | 86 } // namespace test |
88 } // namespace gfx | 87 } // namespace gfx |
89 | 88 |
90 #endif // UI_GFX_IMAGE_IMAGE_UNITTEST_UTIL_H_ | 89 #endif // UI_GFX_IMAGE_IMAGE_UNITTEST_UTIL_H_ |
OLD | NEW |