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 #include "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
6 #include "ui/base/layout.h" | 6 #include "ui/base/layout.h" |
7 #include "ui/views/border.h" | 7 #include "ui/views/border.h" |
8 #include "ui/views/controls/button/image_button.h" | 8 #include "ui/views/controls/button/image_button.h" |
9 #include "ui/views/test/views_test_base.h" | 9 #include "ui/views/test/views_test_base.h" |
10 | 10 |
11 namespace { | 11 namespace { |
12 | 12 |
13 gfx::ImageSkia CreateTestImage(int width, int height) { | 13 gfx::ImageSkia CreateTestImage(int width, int height) { |
14 SkBitmap bitmap; | 14 SkBitmap bitmap; |
15 bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height); | 15 bitmap.allocN32Pixels(width, height); |
16 bitmap.allocPixels(); | |
17 return gfx::ImageSkia::CreateFrom1xBitmap(bitmap); | 16 return gfx::ImageSkia::CreateFrom1xBitmap(bitmap); |
18 } | 17 } |
19 | 18 |
20 } // namespace | 19 } // namespace |
21 | 20 |
22 namespace views { | 21 namespace views { |
23 | 22 |
24 typedef ViewsTestBase ImageButtonTest; | 23 typedef ViewsTestBase ImageButtonTest; |
25 | 24 |
26 TEST_F(ImageButtonTest, Basics) { | 25 TEST_F(ImageButtonTest, Basics) { |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 ImageButton::ALIGN_BOTTOM); | 138 ImageButton::ALIGN_BOTTOM); |
140 button.SetDrawImageMirrored(true); | 139 button.SetDrawImageMirrored(true); |
141 | 140 |
142 // Because the coordinates are flipped, we should expect this to draw as if | 141 // Because the coordinates are flipped, we should expect this to draw as if |
143 // it were ALIGN_LEFT. | 142 // it were ALIGN_LEFT. |
144 EXPECT_EQ(gfx::Point(0, 0).ToString(), | 143 EXPECT_EQ(gfx::Point(0, 0).ToString(), |
145 button.ComputeImagePaintPosition(image).ToString()); | 144 button.ComputeImagePaintPosition(image).ToString()); |
146 } | 145 } |
147 | 146 |
148 } // namespace views | 147 } // namespace views |
OLD | NEW |