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 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "ui/base/layout.h" | 9 #include "ui/base/layout.h" |
10 #include "ui/gfx/image/image_unittest_util.h" | 10 #include "ui/gfx/image/image_unittest_util.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 #include "third_party/skia/include/core/SkBitmap.h" | 12 #include "third_party/skia/include/core/SkBitmap.h" |
13 | 13 |
14 #if defined(TOOLKIT_GTK) | 14 #if defined(TOOLKIT_GTK) |
15 #include "ui/gfx/gtk_util.h" | 15 #include "ui/gfx/gtk_util.h" |
16 #elif defined(OS_MACOSX) | 16 #elif defined(OS_MACOSX) |
17 #include "base/mac/mac_util.h" | 17 #include "base/mac/mac_util.h" |
18 #include "skia/ext/skia_utils_mac.h" | 18 #include "skia/ext/skia_utils_mac.h" |
19 #endif | 19 #endif |
20 | 20 |
21 namespace gfx { | 21 namespace gfx { |
22 namespace test { | 22 namespace test { |
23 | 23 |
24 #if defined(OS_MACOSX) | |
25 | |
26 void SetSupportedScaleFactorsTo1xAnd2x() { | 24 void SetSupportedScaleFactorsTo1xAnd2x() { |
27 std::vector<ui::ScaleFactor> supported_scale_factors; | 25 std::vector<ui::ScaleFactor> supported_scale_factors; |
28 supported_scale_factors.push_back(ui::SCALE_FACTOR_100P); | 26 supported_scale_factors.push_back(ui::SCALE_FACTOR_100P); |
29 supported_scale_factors.push_back(ui::SCALE_FACTOR_200P); | 27 supported_scale_factors.push_back(ui::SCALE_FACTOR_200P); |
30 ui::test::SetSupportedScaleFactors(supported_scale_factors); | 28 ui::test::SetSupportedScaleFactors(supported_scale_factors); |
31 } | 29 } |
32 | 30 |
33 #endif // OS_MACOSX | |
34 | |
35 const SkBitmap CreateBitmap(int width, int height) { | 31 const SkBitmap CreateBitmap(int width, int height) { |
36 SkBitmap bitmap; | 32 SkBitmap bitmap; |
37 bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height); | 33 bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height); |
38 bitmap.allocPixels(); | 34 bitmap.allocPixels(); |
39 bitmap.eraseRGB(255, 0, 0); | 35 bitmap.eraseRGB(255, 0, 0); |
40 return bitmap; | 36 return bitmap; |
41 } | 37 } |
42 | 38 |
43 gfx::Image CreateImage() { | 39 gfx::Image CreateImage() { |
44 return CreateImage(100, 50); | 40 return CreateImage(100, 50); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 bool PlatformImagesEqual(PlatformImage image1, PlatformImage image2) { | 120 bool PlatformImagesEqual(PlatformImage image1, PlatformImage image2) { |
125 #if defined(OS_MACOSX) || defined(TOOLKIT_GTK) | 121 #if defined(OS_MACOSX) || defined(TOOLKIT_GTK) |
126 return image1 == image2; | 122 return image1 == image2; |
127 #else | 123 #else |
128 return image1.getPixels() == image2.getPixels(); | 124 return image1.getPixels() == image2.getPixels(); |
129 #endif | 125 #endif |
130 } | 126 } |
131 | 127 |
132 } // namespace test | 128 } // namespace test |
133 } // namespace gfx | 129 } // namespace gfx |
OLD | NEW |