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

Side by Side Diff: ui/views/style/mac/dialog_button_border_mac_unittest.cc

Issue 1340683002: Remove base's implicit_cast. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: implicitcast: numericstest Created 5 years, 3 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
« no previous file with comments | « ui/base/page_transition_types.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/style/mac/dialog_button_border_mac.h" 5 #include "ui/views/style/mac/dialog_button_border_mac.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "third_party/skia/include/core/SkCanvas.h" 8 #include "third_party/skia/include/core/SkCanvas.h"
9 #include "ui/compositor/canvas_painter.h" 9 #include "ui/compositor/canvas_painter.h"
10 #include "ui/gfx/canvas.h" 10 #include "ui/gfx/canvas.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 const gfx::Point center = view->bounds().CenterPoint(); 56 const gfx::Point center = view->bounds().CenterPoint();
57 gfx::Canvas canvas(view->bounds().size(), 1.0, false /* is_opaque */); 57 gfx::Canvas canvas(view->bounds().size(), 1.0, false /* is_opaque */);
58 SkCanvas* sk_canvas = canvas.sk_canvas(); 58 SkCanvas* sk_canvas = canvas.sk_canvas();
59 59
60 // Read a pixel - it should be blank. 60 // Read a pixel - it should be blank.
61 SkColor initial_pixel; 61 SkColor initial_pixel;
62 SkBitmap bitmap; 62 SkBitmap bitmap;
63 bitmap.allocN32Pixels(1, 1); 63 bitmap.allocN32Pixels(1, 1);
64 EXPECT_TRUE(sk_canvas->readPixels(&bitmap, center.x(), center.y())); 64 EXPECT_TRUE(sk_canvas->readPixels(&bitmap, center.x(), center.y()));
65 initial_pixel = bitmap.getColor(0, 0); 65 initial_pixel = bitmap.getColor(0, 0);
66 EXPECT_EQ(implicit_cast<SkColor>(SK_ColorTRANSPARENT), initial_pixel); 66 EXPECT_EQ(static_cast<SkColor>(SK_ColorTRANSPARENT), initial_pixel);
67 67
68 view->Paint(ui::CanvasPainter(&canvas, 1.f).context()); 68 view->Paint(ui::CanvasPainter(&canvas, 1.f).context());
69 69
70 // Ensure save()/restore() calls are balanced. 70 // Ensure save()/restore() calls are balanced.
71 EXPECT_EQ(1, sk_canvas->getSaveCount()); 71 EXPECT_EQ(1, sk_canvas->getSaveCount());
72 72
73 // Ensure "something" happened. This assumes the border is a 73 // Ensure "something" happened. This assumes the border is a
74 // DialogButtonBorderMac, which always modifies the center pixel. 74 // DialogButtonBorderMac, which always modifies the center pixel.
75 EXPECT_TRUE(sk_canvas->readPixels(&bitmap, center.x(), center.y())); 75 EXPECT_TRUE(sk_canvas->readPixels(&bitmap, center.x(), center.y()));
76 return bitmap.getColor(0, 0); 76 return bitmap.getColor(0, 0);
77 } 77 }
78 78
79 void TestPaintAllStates(CustomButton* button, bool verify) { 79 void TestPaintAllStates(CustomButton* button, bool verify) {
80 for (int i = 0; i < Button::STATE_COUNT; ++i) { 80 for (int i = 0; i < Button::STATE_COUNT; ++i) {
81 Button::ButtonState state = static_cast<Button::ButtonState>(i); 81 Button::ButtonState state = static_cast<Button::ButtonState>(i);
82 SCOPED_TRACE(testing::Message() << "Button::ButtonState: " << state); 82 SCOPED_TRACE(testing::Message() << "Button::ButtonState: " << state);
83 button->SetState(state); 83 button->SetState(state);
84 SkColor color = TestPaint(button); 84 SkColor color = TestPaint(button);
85 if (verify) 85 if (verify)
86 EXPECT_NE(implicit_cast<SkColor>(SK_ColorTRANSPARENT), color); 86 EXPECT_NE(static_cast<SkColor>(SK_ColorTRANSPARENT), color);
87 } 87 }
88 } 88 }
89 89
90 } // namespace 90 } // namespace
91 91
92 using DialogButtonBorderMacTest = ViewsTestBase; 92 using DialogButtonBorderMacTest = ViewsTestBase;
93 93
94 // Verify that the DialogButtonBorderMac insets are consistent with the 94 // Verify that the DialogButtonBorderMac insets are consistent with the
95 // minimum size, and they're correctly carried across to the View's preferred 95 // minimum size, and they're correctly carried across to the View's preferred
96 // size. 96 // size.
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 187
188 // Any call to SetBorder() will immediately prevent themed buttons and adding 188 // Any call to SetBorder() will immediately prevent themed buttons and adding
189 // to a Widget (to pick up a NativeTheme) shouldn't restore them. 189 // to a Widget (to pick up a NativeTheme) shouldn't restore them.
190 button.SetBorder(Border::NullBorder()); 190 button.SetBorder(Border::NullBorder());
191 EXPECT_FALSE(BorderIsDialogButton(button)); 191 EXPECT_FALSE(BorderIsDialogButton(button));
192 button.SimulateAddToWidget(); 192 button.SimulateAddToWidget();
193 EXPECT_FALSE(BorderIsDialogButton(button)); 193 EXPECT_FALSE(BorderIsDialogButton(button));
194 } 194 }
195 195
196 } // namespace views 196 } // namespace views
OLDNEW
« no previous file with comments | « ui/base/page_transition_types.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698