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

Unified Diff: ui/views/controls/button/image_button_unittest.cc

Issue 2744463002: Add VectorIconButton functionality to ImageButton. (Closed)
Patch Set: fix cros build Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: ui/views/controls/button/image_button_unittest.cc
diff --git a/ui/views/controls/button/image_button_unittest.cc b/ui/views/controls/button/image_button_unittest.cc
index ccd62cef04682685788478535da0493b1d1f3205..c768421939b24a157347182c72d8d3606604f41e 100644
--- a/ui/views/controls/button/image_button_unittest.cc
+++ b/ui/views/controls/button/image_button_unittest.cc
@@ -2,11 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "ui/views/controls/button/image_button.h"
+
#include "base/macros.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/layout.h"
+#include "ui/vector_icons/vector_icons.h"
#include "ui/views/border.h"
-#include "ui/views/controls/button/image_button.h"
#include "ui/views/test/views_test_base.h"
namespace {
@@ -199,4 +201,26 @@ TEST_F(ImageButtonTest, PreferredSizeInvalidation) {
EXPECT_EQ(1, parent.pref_size_changed_calls());
}
+TEST_F(ImageButtonTest, Padding) {
+ ImageButton button(nullptr);
+ gfx::ImageSkia image = CreateTestImage(5, 10);
+ button.SetImage(CustomButton::STATE_NORMAL, &image);
+ button.SetPadding(gfx::Insets(2, 5, 7, 13));
+ EXPECT_EQ("23x19", button.GetPreferredSize().ToString());
+}
+
+namespace {
+class TestImageButtonDelegate : public ImageButtonDelegate {
+ void ButtonPressed(Button* sender, const ui::Event& event) override {}
+};
+}
+
+TEST_F(ImageButtonTest, VectorIcon) {
+ TestImageButtonDelegate delegate;
+ ImageButton button(&delegate);
+ button.SetVectorIcon(ui::kCloseIcon);
+ EXPECT_FALSE(button.GetImage(CustomButton::STATE_NORMAL).isNull());
+ EXPECT_FALSE(button.GetImage(CustomButton::STATE_DISABLED).isNull());
+}
+
} // namespace views

Powered by Google App Engine
This is Rietveld 408576698