| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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 "ui/views/controls/button/toggle_button.h" | 5 #include "ui/views/controls/button/toggle_button.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "ui/events/event_utils.h" | 11 #include "ui/events/event_utils.h" |
| 12 #include "ui/views/style/platform_style.h" |
| 12 #include "ui/views/test/views_test_base.h" | 13 #include "ui/views/test/views_test_base.h" |
| 13 | 14 |
| 14 namespace views { | 15 namespace views { |
| 15 | 16 |
| 16 class TestToggleButton : public ToggleButton { | 17 class TestToggleButton : public ToggleButton { |
| 17 public: | 18 public: |
| 18 explicit TestToggleButton(int* counter) | 19 explicit TestToggleButton(int* counter) |
| 19 : ToggleButton(nullptr), counter_(counter) {} | 20 : ToggleButton(nullptr), counter_(counter) {} |
| 20 ~TestToggleButton() override { | 21 ~TestToggleButton() override { |
| 21 // Calling SetInkDropMode() in this subclass allows this class's | 22 // Calling SetInkDropMode() in this subclass allows this class's |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 | 84 |
| 84 // Starts ink drop animation on a ToggleButton and destroys the button. | 85 // Starts ink drop animation on a ToggleButton and destroys the button. |
| 85 // The test verifies that the ink drop layer is removed properly when the | 86 // The test verifies that the ink drop layer is removed properly when the |
| 86 // ToggleButton gets destroyed. | 87 // ToggleButton gets destroyed. |
| 87 TEST_F(ToggleButtonTest, ToggleButtonDestroyed) { | 88 TEST_F(ToggleButtonTest, ToggleButtonDestroyed) { |
| 88 EXPECT_EQ(0, counter()); | 89 EXPECT_EQ(0, counter()); |
| 89 gfx::Point center(10, 10); | 90 gfx::Point center(10, 10); |
| 90 button()->OnMousePressed(ui::MouseEvent( | 91 button()->OnMousePressed(ui::MouseEvent( |
| 91 ui::ET_MOUSE_PRESSED, center, center, ui::EventTimeForNow(), | 92 ui::ET_MOUSE_PRESSED, center, center, ui::EventTimeForNow(), |
| 92 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 93 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 93 EXPECT_EQ(1, counter()); | 94 // On platforms with no ripples, there should never be an ink drop layer. |
| 95 if (PlatformStyle::kUseRipples) |
| 96 EXPECT_EQ(1, counter()); |
| 97 else |
| 98 EXPECT_EQ(0, counter()); |
| 94 delete button(); | 99 delete button(); |
| 95 EXPECT_EQ(0, counter()); | 100 EXPECT_EQ(0, counter()); |
| 96 } | 101 } |
| 97 | 102 |
| 98 } // namespace views | 103 } // namespace views |
| OLD | NEW |