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

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

Issue 851853002: It is time. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Trying to reup because the last upload failed. Created 5 years, 11 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/views/controls/button/blue_button.cc ('k') | ui/views/controls/button/button.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ui/views/controls/button/blue_button.h"
6
7 #include "base/strings/string16.h"
8 #include "base/strings/utf_string_conversions.h"
9 #include "ui/gfx/canvas.h"
10 #include "ui/gfx/skia_util.h"
11 #include "ui/views/controls/button/label_button_border.h"
12 #include "ui/views/test/views_test_base.h"
13
14 namespace views {
15
16 namespace {
17
18 class TestBlueButton : public BlueButton {
19 public:
20 TestBlueButton() : BlueButton(NULL, base::ASCIIToUTF16("foo")) {}
21 virtual ~TestBlueButton() {}
22
23 using BlueButton::OnNativeThemeChanged;
24
25 private:
26 DISALLOW_COPY_AND_ASSIGN(TestBlueButton);
27 };
28
29 } // namespace
30
31 typedef ViewsTestBase BlueButtonTest;
32
33 TEST_F(BlueButtonTest, Border) {
34 // Compared to a normal LabelButton...
35 LabelButton button(NULL, base::ASCIIToUTF16("foo"));
36 button.SetBoundsRect(gfx::Rect(gfx::Point(0, 0), button.GetPreferredSize()));
37 gfx::Canvas button_canvas(button.bounds().size(), 1.0, true);
38 button.border()->Paint(button, &button_canvas);
39
40 // ... a special blue border should be used.
41 TestBlueButton blue_button;
42 blue_button.SetBoundsRect(gfx::Rect(gfx::Point(0, 0),
43 blue_button.GetPreferredSize()));
44 gfx::Canvas canvas(blue_button.bounds().size(), 1.0, true);
45 blue_button.border()->Paint(blue_button, &canvas);
46 EXPECT_EQ(button.GetText(), blue_button.GetText());
47 EXPECT_FALSE(gfx::BitmapsAreEqual(button_canvas.ExtractImageRep().sk_bitmap(),
48 canvas.ExtractImageRep().sk_bitmap()));
49
50 // Make sure it's still used after the native theme "changes".
51 blue_button.OnNativeThemeChanged(NULL);
52 gfx::Canvas canvas2(blue_button.bounds().size(), 1.0, true);
53 blue_button.border()->Paint(blue_button, &canvas2);
54
55 EXPECT_TRUE(gfx::BitmapsAreEqual(canvas.ExtractImageRep().sk_bitmap(),
56 canvas2.ExtractImageRep().sk_bitmap()));
57 }
58
59 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/button/blue_button.cc ('k') | ui/views/controls/button/button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698