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

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

Issue 1772183002: Resets hover state when ToolbarActionView is dragged (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2661
Patch Set: Created 4 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/custom_button.cc ('k') | ui/views/widget/widget.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/button/custom_button_unittest.cc
diff --git a/ui/views/controls/button/custom_button_unittest.cc b/ui/views/controls/button/custom_button_unittest.cc
index 13d54c6d68018611bcad4ae99ac3d9f54ac69820..10f4e9794faa88c9b0e7faffc375c6a8105da03c 100644
--- a/ui/views/controls/button/custom_button_unittest.cc
+++ b/ui/views/controls/button/custom_button_unittest.cc
@@ -8,6 +8,7 @@
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/layout.h"
+#include "ui/base/material_design/material_design_controller.h"
#include "ui/events/event_utils.h"
#include "ui/events/test/event_generator.h"
#include "ui/gfx/screen.h"
@@ -120,6 +121,8 @@ class TestButtonWithInkDrop : public TestCustomButton {
DISALLOW_COPY_AND_ASSIGN(TestButtonWithInkDrop);
};
+} // namespace
+
class CustomButtonTest : public ViewsTestBase {
public:
CustomButtonTest() {}
@@ -159,6 +162,9 @@ class CustomButtonTest : public ViewsTestBase {
TestCustomButton* button() { return button_; }
bool ink_shown() const { return ink_shown_; }
bool ink_hidden() const { return ink_hidden_; }
+ void SetDraggedView(View* dragged_view) {
+ widget_->dragged_view_ = dragged_view;
+ }
private:
scoped_ptr<Widget> widget_;
@@ -169,8 +175,6 @@ class CustomButtonTest : public ViewsTestBase {
DISALLOW_COPY_AND_ASSIGN(CustomButtonTest);
};
-} // namespace
-
// Tests that hover state changes correctly when visiblity/enableness changes.
TEST_F(CustomButtonTest, HoverStateOnVisibilityChange) {
ui::test::EventGenerator generator(GetContext(), widget()->GetNativeWindow());
@@ -392,6 +396,7 @@ TEST_F(CustomButtonTest, ButtonClickTogglesInkDrop) {
}
// Tests that pressing a button shows and releasing capture hides ink drop.
+// Releasing capture should also reset PRESSED button state to NORMAL.
TEST_F(CustomButtonTest, CaptureLossHidesInkDrop) {
gfx::Point old_cursor = gfx::Screen::GetScreen()->GetCursorScreenPoint();
CreateButtonWithInkDrop();
@@ -402,9 +407,16 @@ TEST_F(CustomButtonTest, CaptureLossHidesInkDrop) {
EXPECT_TRUE(ink_shown());
EXPECT_FALSE(ink_hidden());
+ EXPECT_EQ(Button::ButtonState::STATE_PRESSED, button()->state());
+ SetDraggedView(button());
widget()->SetCapture(button());
widget()->ReleaseCapture();
+ SetDraggedView(nullptr);
EXPECT_TRUE(ink_hidden());
+ EXPECT_EQ(ui::MaterialDesignController::IsModeMaterial()
+ ? Button::ButtonState::STATE_NORMAL
+ : Button::ButtonState::STATE_PRESSED,
+ button()->state());
}
} // namespace views
« no previous file with comments | « ui/views/controls/button/custom_button.cc ('k') | ui/views/widget/widget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698