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

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

Issue 2744463002: Add VectorIconButton functionality to ImageButton. (Closed)
Patch Set: tests 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_util_unittest.cc
diff --git a/ui/views/controls/button/image_button_util_unittest.cc b/ui/views/controls/button/image_button_util_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ac73f991e2bdd51f7b2d6d09acc2e5b91928d4d4
--- /dev/null
+++ b/ui/views/controls/button/image_button_util_unittest.cc
@@ -0,0 +1,36 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// 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_util.h"
+
+#include "ui/gfx/color_utils.h"
+#include "ui/vector_icons/vector_icons.h"
+#include "ui/views/animation/test/ink_drop_host_view_test_api.h"
+#include "ui/views/controls/button/button.h"
+#include "ui/views/controls/button/image_button.h"
+#include "ui/views/test/views_test_base.h"
+
+namespace views {
+
+typedef ViewsTestBase ImageButtonUtilTest;
+
+TEST_F(ImageButtonUtilTest, CreateImageButtonWithVectorIconStyling) {
+ ImageButton* button = CreateImageButtonWithVectorIconStyling(nullptr);
+ EXPECT_EQ(ImageButton::ALIGN_CENTER, button->h_alignment_);
+ EXPECT_EQ(ImageButton::ALIGN_MIDDLE, button->v_alignment_);
+ EXPECT_TRUE(test::InkDropHostViewTestApi(button).HasGestureHandler());
+ delete button;
+}
+
+TEST_F(ImageButtonUtilTest, SetImageFromVectorIcon) {
+ ImageButton* button = CreateImageButtonWithVectorIconStyling(nullptr);
+ SetImageFromVectorIcon(button, ui::kCloseIcon, SK_ColorRED);
+ EXPECT_FALSE(button->GetImage(CustomButton::STATE_NORMAL).isNull());
+ EXPECT_FALSE(button->GetImage(CustomButton::STATE_DISABLED).isNull());
+ EXPECT_EQ(color_utils::DeriveDefaultIconColor(SK_ColorRED),
+ button->GetInkDropBaseColor());
+ delete button;
+}
+
+} // views

Powered by Google App Engine
This is Rietveld 408576698