| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 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/animation/ink_drop_host_view.h" | 5 #include "ui/views/animation/ink_drop_host_view.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "ui/events/event.h" | 9 #include "ui/events/event.h" |
| 10 #include "ui/events/event_constants.h" | 10 #include "ui/events/event_constants.h" |
| 11 #include "ui/events/event_utils.h" | 11 #include "ui/events/event_utils.h" |
| 12 #include "ui/gfx/geometry/point.h" | 12 #include "ui/gfx/geometry/point.h" |
| 13 #include "ui/gfx/geometry/size.h" | 13 #include "ui/gfx/geometry/size.h" |
| 14 #include "ui/views/animation/test/ink_drop_host_view_test_api.h" | 14 #include "ui/views/animation/test/ink_drop_host_view_test_api.h" |
| 15 | 15 |
| 16 namespace views { | 16 namespace views { |
| 17 namespace test { | 17 namespace test { |
| 18 using InkDropMode = InkDropHostViewTestApi::InkDropMode; |
| 18 | 19 |
| 19 class InkDropHostViewTest : public testing::Test { | 20 class InkDropHostViewTest : public testing::Test { |
| 20 public: | 21 public: |
| 21 InkDropHostViewTest(); | 22 InkDropHostViewTest(); |
| 22 ~InkDropHostViewTest() override; | 23 ~InkDropHostViewTest() override; |
| 23 | 24 |
| 24 protected: | 25 protected: |
| 25 // Test target. | 26 // Test target. |
| 26 InkDropHostView host_view_; | 27 InkDropHostView host_view_; |
| 27 | 28 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 50 host_view_.SetSize(gfx::Size(20, 20)); | 51 host_view_.SetSize(gfx::Size(20, 20)); |
| 51 | 52 |
| 52 ui::MouseEvent located_event(ui::ET_MOUSE_PRESSED, gfx::Point(5, 6), | 53 ui::MouseEvent located_event(ui::ET_MOUSE_PRESSED, gfx::Point(5, 6), |
| 53 gfx::Point(5, 6), ui::EventTimeForNow(), | 54 gfx::Point(5, 6), ui::EventTimeForNow(), |
| 54 ui::EF_LEFT_MOUSE_BUTTON, 0); | 55 ui::EF_LEFT_MOUSE_BUTTON, 0); |
| 55 | 56 |
| 56 test_api_.AnimateInkDrop(InkDropState::ACTION_PENDING, &located_event); | 57 test_api_.AnimateInkDrop(InkDropState::ACTION_PENDING, &located_event); |
| 57 EXPECT_EQ(gfx::Point(5, 6), test_api_.GetInkDropCenterBasedOnLastEvent()); | 58 EXPECT_EQ(gfx::Point(5, 6), test_api_.GetInkDropCenterBasedOnLastEvent()); |
| 58 } | 59 } |
| 59 | 60 |
| 60 // Verifies that SetHasInkDrop() sets up gesture handling properly. | 61 // Verifies that SetInkDropMode() sets up gesture handling properly. |
| 61 TEST_F(InkDropHostViewTest, SetHasInkDropGestureHandler) { | 62 TEST_F(InkDropHostViewTest, SetInkDropModeGestureHandler) { |
| 62 EXPECT_FALSE(test_api_.HasGestureHandler()); | 63 EXPECT_FALSE(test_api_.HasGestureHandler()); |
| 63 | 64 |
| 64 test_api_.SetHasInkDrop(true); | 65 test_api_.SetInkDropMode(InkDropMode::ON_NO_GESTURE_HANDLER); |
| 66 EXPECT_FALSE(test_api_.HasGestureHandler()); |
| 67 |
| 68 test_api_.SetInkDropMode(InkDropMode::ON); |
| 65 EXPECT_TRUE(test_api_.HasGestureHandler()); | 69 EXPECT_TRUE(test_api_.HasGestureHandler()); |
| 66 | 70 |
| 67 test_api_.SetHasInkDrop(true); | 71 // Enabling gesture handler the second time should just work (no crash). |
| 72 test_api_.SetInkDropMode(InkDropMode::ON); |
| 68 EXPECT_TRUE(test_api_.HasGestureHandler()); | 73 EXPECT_TRUE(test_api_.HasGestureHandler()); |
| 69 | 74 |
| 70 test_api_.SetHasInkDrop(false); | 75 test_api_.SetInkDropMode(InkDropMode::OFF); |
| 71 EXPECT_FALSE(test_api_.HasGestureHandler()); | 76 EXPECT_FALSE(test_api_.HasGestureHandler()); |
| 72 } | 77 } |
| 73 | 78 |
| 74 } // namespace test | 79 } // namespace test |
| 75 } // namespace views | 80 } // namespace views |
| OLD | NEW |