| 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 namespace { |
| 19 using InkDropMode = InkDropHostViewTestApi::InkDropMode; |
| 20 } |
| 18 | 21 |
| 19 class InkDropHostViewTest : public testing::Test { | 22 class InkDropHostViewTest : public testing::Test { |
| 20 public: | 23 public: |
| 21 InkDropHostViewTest(); | 24 InkDropHostViewTest(); |
| 22 ~InkDropHostViewTest() override; | 25 ~InkDropHostViewTest() override; |
| 23 | 26 |
| 24 protected: | 27 protected: |
| 25 // Test target. | 28 // Test target. |
| 26 InkDropHostView host_view_; | 29 InkDropHostView host_view_; |
| 27 | 30 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 50 host_view_.SetSize(gfx::Size(20, 20)); | 53 host_view_.SetSize(gfx::Size(20, 20)); |
| 51 | 54 |
| 52 ui::MouseEvent located_event(ui::ET_MOUSE_PRESSED, gfx::Point(5, 6), | 55 ui::MouseEvent located_event(ui::ET_MOUSE_PRESSED, gfx::Point(5, 6), |
| 53 gfx::Point(5, 6), ui::EventTimeForNow(), | 56 gfx::Point(5, 6), ui::EventTimeForNow(), |
| 54 ui::EF_LEFT_MOUSE_BUTTON, 0); | 57 ui::EF_LEFT_MOUSE_BUTTON, 0); |
| 55 | 58 |
| 56 test_api_.AnimateInkDrop(InkDropState::ACTION_PENDING, &located_event); | 59 test_api_.AnimateInkDrop(InkDropState::ACTION_PENDING, &located_event); |
| 57 EXPECT_EQ(gfx::Point(5, 6), test_api_.GetInkDropCenterBasedOnLastEvent()); | 60 EXPECT_EQ(gfx::Point(5, 6), test_api_.GetInkDropCenterBasedOnLastEvent()); |
| 58 } | 61 } |
| 59 | 62 |
| 60 // Verifies that SetHasInkDrop() sets up gesture handling properly. | 63 // Verifies that SetInkDropMode() sets up gesture handling properly. |
| 61 TEST_F(InkDropHostViewTest, SetHasInkDropGestureHandler) { | 64 TEST_F(InkDropHostViewTest, SetInkDropModeGestureHandler) { |
| 62 EXPECT_FALSE(test_api_.HasGestureHandler()); | 65 EXPECT_FALSE(test_api_.HasGestureHandler()); |
| 63 | 66 |
| 64 test_api_.SetHasInkDrop(true); | 67 test_api_.SetInkDropMode(InkDropMode::INK_DROP_WITHOUT_GESTURE_HANDLING); |
| 68 EXPECT_FALSE(test_api_.HasGestureHandler()); |
| 69 |
| 70 test_api_.SetInkDropMode(InkDropMode::INK_DROP_WITH_GESTURE_HANDLING); |
| 65 EXPECT_TRUE(test_api_.HasGestureHandler()); | 71 EXPECT_TRUE(test_api_.HasGestureHandler()); |
| 66 | 72 |
| 67 test_api_.SetHasInkDrop(true); | 73 // Enabling gesture handler the second time should just work (no crash). |
| 74 test_api_.SetInkDropMode(InkDropMode::INK_DROP_WITH_GESTURE_HANDLING); |
| 68 EXPECT_TRUE(test_api_.HasGestureHandler()); | 75 EXPECT_TRUE(test_api_.HasGestureHandler()); |
| 69 | 76 |
| 70 test_api_.SetHasInkDrop(false); | 77 test_api_.SetInkDropMode(InkDropMode::NO_INK_DROP); |
| 71 EXPECT_FALSE(test_api_.HasGestureHandler()); | 78 EXPECT_FALSE(test_api_.HasGestureHandler()); |
| 72 } | 79 } |
| 73 | 80 |
| 74 } // namespace test | 81 } // namespace test |
| 75 } // namespace views | 82 } // namespace views |
| OLD | NEW |