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

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

Issue 2744463002: Add VectorIconButton functionality to ImageButton. (Closed)
Patch Set: check details 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
« no previous file with comments | « ui/views/controls/button/image_button_factory.cc ('k') | ui/views/controls/button/vector_icon_button.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/button/image_button_factory_unittest.cc
diff --git a/ui/views/controls/button/image_button_factory_unittest.cc b/ui/views/controls/button/image_button_factory_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..90edfb5b9cdf58c61907a6c9370aac9dbc4950b8
--- /dev/null
+++ b/ui/views/controls/button/image_button_factory_unittest.cc
@@ -0,0 +1,41 @@
+// 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_factory.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 ImageButtonFactoryTest;
+
+TEST_F(ImageButtonFactoryTest, CreateVectorImageButton) {
+ ImageButton* button = CreateVectorImageButton(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(ImageButtonFactoryTest, SetImageFromVectorIcon) {
+ ImageButton* button = CreateVectorImageButton(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());
+
+ // Default to black.
+ SetImageFromVectorIcon(button, ui::kCloseIcon);
+ EXPECT_EQ(color_utils::DeriveDefaultIconColor(SK_ColorBLACK),
+ button->GetInkDropBaseColor());
+ delete button;
+}
+
+} // views
« no previous file with comments | « ui/views/controls/button/image_button_factory.cc ('k') | ui/views/controls/button/vector_icon_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698