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

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

Issue 10382144: Change SetImage, SetBackground, and SetToggledImage to take in a gfx::ImageSkia (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 8 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « ui/views/controls/button/image_button.cc ('k') | ui/views/controls/image_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/views/controls/button/image_button.h" 6 #include "ui/views/controls/button/image_button.h"
7 #include "ui/views/test/views_test_base.h" 7 #include "ui/views/test/views_test_base.h"
8 8
9 namespace { 9 namespace {
10 10
(...skipping 17 matching lines...) Expand all
28 EXPECT_TRUE(button.GetImageToPaint().empty()); 28 EXPECT_TRUE(button.GetImageToPaint().empty());
29 29
30 // Without a theme, buttons are 16x14 by default. 30 // Without a theme, buttons are 16x14 by default.
31 EXPECT_EQ("16x14", button.GetPreferredSize().ToString()); 31 EXPECT_EQ("16x14", button.GetPreferredSize().ToString());
32 32
33 // We can set a preferred size when we have no image. 33 // We can set a preferred size when we have no image.
34 button.SetPreferredSize(gfx::Size(5, 15)); 34 button.SetPreferredSize(gfx::Size(5, 15));
35 EXPECT_EQ("5x15", button.GetPreferredSize().ToString()); 35 EXPECT_EQ("5x15", button.GetPreferredSize().ToString());
36 36
37 // Set a normal image. 37 // Set a normal image.
38 SkBitmap normal_bitmap = CreateTestBitmap(10, 20); 38 gfx::ImageSkia normal_bitmap = CreateTestBitmap(10, 20);
39 button.SetImage(CustomButton::BS_NORMAL, &normal_bitmap); 39 button.SetImage(CustomButton::BS_NORMAL, &normal_bitmap);
40 40
41 // Image uses normal image for painting. 41 // Image uses normal image for painting.
42 EXPECT_FALSE(button.GetImageToPaint().empty()); 42 EXPECT_FALSE(button.GetImageToPaint().empty());
43 EXPECT_EQ(10, button.GetImageToPaint().width()); 43 EXPECT_EQ(10, button.GetImageToPaint().width());
44 EXPECT_EQ(20, button.GetImageToPaint().height()); 44 EXPECT_EQ(20, button.GetImageToPaint().height());
45 45
46 // Preferred size is the normal button size. 46 // Preferred size is the normal button size.
47 EXPECT_EQ("10x20", button.GetPreferredSize().ToString()); 47 EXPECT_EQ("10x20", button.GetPreferredSize().ToString());
48 48
49 // Set a pushed image. 49 // Set a pushed image.
50 SkBitmap pushed_bitmap = CreateTestBitmap(11, 21); 50 gfx::ImageSkia pushed_bitmap = CreateTestBitmap(11, 21);
51 button.SetImage(CustomButton::BS_PUSHED, &pushed_bitmap); 51 button.SetImage(CustomButton::BS_PUSHED, &pushed_bitmap);
52 52
53 // By convention, preferred size doesn't change, even though pushed image 53 // By convention, preferred size doesn't change, even though pushed image
54 // is bigger. 54 // is bigger.
55 EXPECT_EQ("10x20", button.GetPreferredSize().ToString()); 55 EXPECT_EQ("10x20", button.GetPreferredSize().ToString());
56 56
57 // We're still painting the normal image. 57 // We're still painting the normal image.
58 EXPECT_FALSE(button.GetImageToPaint().empty()); 58 EXPECT_FALSE(button.GetImageToPaint().empty());
59 EXPECT_EQ(10, button.GetImageToPaint().width()); 59 EXPECT_EQ(10, button.GetImageToPaint().width());
60 EXPECT_EQ(20, button.GetImageToPaint().height()); 60 EXPECT_EQ(20, button.GetImageToPaint().height());
(...skipping 12 matching lines...) Expand all
73 EXPECT_FALSE(button.GetImageToPaint().empty()); 73 EXPECT_FALSE(button.GetImageToPaint().empty());
74 EXPECT_EQ(10, button.GetImageToPaint().width()); 74 EXPECT_EQ(10, button.GetImageToPaint().width());
75 EXPECT_EQ(20, button.GetImageToPaint().height()); 75 EXPECT_EQ(20, button.GetImageToPaint().height());
76 76
77 // Reset the overlay bitmap. 77 // Reset the overlay bitmap.
78 button.SetOverlayImage(NULL); 78 button.SetOverlayImage(NULL);
79 EXPECT_TRUE(button.overlay_image_.empty()); 79 EXPECT_TRUE(button.overlay_image_.empty());
80 } 80 }
81 81
82 } // namespace views 82 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/button/image_button.cc ('k') | ui/views/controls/image_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698