Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(265)

Side by Side Diff: ui/views/controls/button/blue_button_unittest.cc

Issue 2069733002: MD - Use real comboboxes in website settings popup. Hide borders (but (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add comment Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "ui/base/material_design/material_design_controller.h" 10 #include "ui/base/material_design/material_design_controller.h"
11 #include "ui/gfx/canvas.h" 11 #include "ui/gfx/canvas.h"
12 #include "ui/gfx/skia_util.h" 12 #include "ui/gfx/skia_util.h"
13 #include "ui/views/controls/button/label_button_border.h" 13 #include "ui/views/controls/button/label_button_border.h"
14 #include "ui/views/test/widget_test.h" 14 #include "ui/views/test/widget_test.h"
15 15
16 namespace views { 16 namespace views {
17 17
18 using BlueButtonTest = test::WidgetTest; 18 using BlueButtonTest = test::WidgetTest;
19 19
20 TEST_F(BlueButtonTest, Border) { 20 TEST_F(BlueButtonTest, Border) {
21 // The buttons must be added to a Widget so that borders are correctly 21 // The buttons must be added to a Widget so that borders are correctly
22 // applied once the NativeTheme is determined. 22 // applied once the NativeTheme is determined.
23 Widget* widget = CreateTopLevelPlatformWidget(); 23 Widget* widget = CreateTopLevelPlatformWidget();
24 24
25 // Compared to a normal LabelButton... 25 // Compared to a normal LabelButton...
26 LabelButton* button = new LabelButton(nullptr, base::ASCIIToUTF16("foo")); 26 LabelButton* button = new LabelButton(nullptr, base::ASCIIToUTF16("foo"));
27 EXPECT_EQ(Button::STYLE_TEXTBUTTON, button->style()); 27 EXPECT_EQ(Button::STYLE_TEXTBUTTON, button->style());
28 // Focus painter by default only in non-md. 28 // Focus painter by default.
29 EXPECT_EQ(ui::MaterialDesignController::IsModeMaterial(), 29 EXPECT_TRUE(button->focus_painter());
30 !button->focus_painter());
31 30
32 // Switch to the same style as BlueButton for a more compelling comparison. 31 // Switch to the same style as BlueButton for a more compelling comparison.
33 button->SetStyle(Button::STYLE_BUTTON); 32 button->SetStyle(Button::STYLE_BUTTON);
34 EXPECT_EQ(Button::STYLE_BUTTON, button->style()); 33 EXPECT_EQ(Button::STYLE_BUTTON, button->style());
35 EXPECT_FALSE(button->focus_painter()); 34 EXPECT_FALSE(button->focus_painter());
36 35
37 widget->GetContentsView()->AddChildView(button); 36 widget->GetContentsView()->AddChildView(button);
38 button->SizeToPreferredSize(); 37 button->SizeToPreferredSize();
39 gfx::Canvas button_canvas(button->size(), 1.0, true); 38 gfx::Canvas button_canvas(button->size(), 1.0, true);
40 button->border()->Paint(*button, &button_canvas); 39 button->border()->Paint(*button, &button_canvas);
(...skipping 21 matching lines...) Expand all
62 blue_button->border()->Paint(*blue_button, &canvas); 61 blue_button->border()->Paint(*blue_button, &canvas);
63 EXPECT_EQ(button->GetText(), blue_button->GetText()); 62 EXPECT_EQ(button->GetText(), blue_button->GetText());
64 EXPECT_EQ(button->size(), blue_button->size()); 63 EXPECT_EQ(button->size(), blue_button->size());
65 EXPECT_FALSE(gfx::BitmapsAreEqual(button_canvas.ExtractImageRep().sk_bitmap(), 64 EXPECT_FALSE(gfx::BitmapsAreEqual(button_canvas.ExtractImageRep().sk_bitmap(),
66 canvas.ExtractImageRep().sk_bitmap())); 65 canvas.ExtractImageRep().sk_bitmap()));
67 66
68 widget->CloseNow(); 67 widget->CloseNow();
69 } 68 }
70 69
71 } // namespace views 70 } // namespace views
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/website_settings/permissions_bubble_view.cc ('k') | ui/views/controls/button/label_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698