| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/views/controls/button/blue_button.h" | 5 #include "ui/views/controls/button/blue_button.h" |
| 6 | 6 |
| 7 #include "base/strings/string16.h" | 7 #include "base/strings/string16.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "cc/paint/skia_paint_canvas.h" | 10 #include "cc/paint/skia_paint_canvas.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 // applied once the NativeTheme is determined. | 23 // applied once the NativeTheme is determined. |
| 24 Widget* widget = CreateTopLevelPlatformWidget(); | 24 Widget* widget = CreateTopLevelPlatformWidget(); |
| 25 | 25 |
| 26 // Compared to a normal LabelButton... | 26 // Compared to a normal LabelButton... |
| 27 LabelButton* button = new LabelButton(nullptr, base::ASCIIToUTF16("foo")); | 27 LabelButton* button = new LabelButton(nullptr, base::ASCIIToUTF16("foo")); |
| 28 EXPECT_EQ(Button::STYLE_TEXTBUTTON, button->style()); | 28 EXPECT_EQ(Button::STYLE_TEXTBUTTON, button->style()); |
| 29 // Focus painter by default. | 29 // Focus painter by default. |
| 30 EXPECT_TRUE(button->focus_painter()); | 30 EXPECT_TRUE(button->focus_painter()); |
| 31 | 31 |
| 32 // Switch to the same style as BlueButton for a more compelling comparison. | 32 // Switch to the same style as BlueButton for a more compelling comparison. |
| 33 button->SetStyle(Button::STYLE_BUTTON); | 33 button->SetStyleDeprecated(Button::STYLE_BUTTON); |
| 34 EXPECT_EQ(Button::STYLE_BUTTON, button->style()); | 34 EXPECT_EQ(Button::STYLE_BUTTON, button->style()); |
| 35 EXPECT_FALSE(button->focus_painter()); | 35 EXPECT_FALSE(button->focus_painter()); |
| 36 | 36 |
| 37 widget->GetContentsView()->AddChildView(button); | 37 widget->GetContentsView()->AddChildView(button); |
| 38 button->SizeToPreferredSize(); | 38 button->SizeToPreferredSize(); |
| 39 | 39 |
| 40 SkBitmap button_bitmap; | 40 SkBitmap button_bitmap; |
| 41 button_bitmap.allocN32Pixels(button->size().width(), button->size().height(), | 41 button_bitmap.allocN32Pixels(button->size().width(), button->size().height(), |
| 42 true /* opaque */); | 42 true /* opaque */); |
| 43 cc::SkiaPaintCanvas button_paint_canvas(button_bitmap); | 43 cc::SkiaPaintCanvas button_paint_canvas(button_bitmap); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 71 gfx::Canvas blue_button_canvas(&blue_button_paint_canvas, 1.f); | 71 gfx::Canvas blue_button_canvas(&blue_button_paint_canvas, 1.f); |
| 72 blue_button->border()->Paint(*blue_button, &blue_button_canvas); | 72 blue_button->border()->Paint(*blue_button, &blue_button_canvas); |
| 73 EXPECT_EQ(button->GetText(), blue_button->GetText()); | 73 EXPECT_EQ(button->GetText(), blue_button->GetText()); |
| 74 EXPECT_EQ(button->size(), blue_button->size()); | 74 EXPECT_EQ(button->size(), blue_button->size()); |
| 75 EXPECT_FALSE(gfx::BitmapsAreEqual(button_bitmap, blue_button_bitmap)); | 75 EXPECT_FALSE(gfx::BitmapsAreEqual(button_bitmap, blue_button_bitmap)); |
| 76 | 76 |
| 77 widget->CloseNow(); | 77 widget->CloseNow(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 } // namespace views | 80 } // namespace views |
| OLD | NEW |