| 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" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 host_view_.SetSize(gfx::Size(20, 20)); | 56 host_view_.SetSize(gfx::Size(20, 20)); |
| 57 test_api_.AnimateInkDrop(InkDropState::ACTION_PENDING, nullptr); | 57 test_api_.AnimateInkDrop(InkDropState::ACTION_PENDING, nullptr); |
| 58 EXPECT_EQ(gfx::Point(10, 10), test_api_.GetInkDropCenterBasedOnLastEvent()); | 58 EXPECT_EQ(gfx::Point(10, 10), test_api_.GetInkDropCenterBasedOnLastEvent()); |
| 59 } | 59 } |
| 60 | 60 |
| 61 // Verifies the return value of GetInkDropCenterBasedOnLastEvent() for a located | 61 // Verifies the return value of GetInkDropCenterBasedOnLastEvent() for a located |
| 62 // Event. | 62 // Event. |
| 63 TEST_F(InkDropHostViewTest, GetInkDropCenterBasedOnLastEventForLocatedEvent) { | 63 TEST_F(InkDropHostViewTest, GetInkDropCenterBasedOnLastEventForLocatedEvent) { |
| 64 host_view_.SetSize(gfx::Size(20, 20)); | 64 host_view_.SetSize(gfx::Size(20, 20)); |
| 65 | 65 |
| 66 ui::MouseEvent located_event(ui::ET_MOUSE_PRESSED, gfx::Point(5, 6), | 66 ui::MouseEvent located_event( |
| 67 gfx::Point(5, 6), ui::EventTimeForNow(), | 67 ui::ET_MOUSE_PRESSED, gfx::Point(5, 6), gfx::Point(5, 6), |
| 68 ui::EF_LEFT_MOUSE_BUTTON, 0); | 68 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 0, |
| 69 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 69 | 70 |
| 70 test_api_.AnimateInkDrop(InkDropState::ACTION_PENDING, &located_event); | 71 test_api_.AnimateInkDrop(InkDropState::ACTION_PENDING, &located_event); |
| 71 EXPECT_EQ(gfx::Point(5, 6), test_api_.GetInkDropCenterBasedOnLastEvent()); | 72 EXPECT_EQ(gfx::Point(5, 6), test_api_.GetInkDropCenterBasedOnLastEvent()); |
| 72 } | 73 } |
| 73 | 74 |
| 74 // Verifies that SetInkDropMode() sets up gesture handling properly. | 75 // Verifies that SetInkDropMode() sets up gesture handling properly. |
| 75 TEST_F(InkDropHostViewTest, SetInkDropModeGestureHandler) { | 76 TEST_F(InkDropHostViewTest, SetInkDropModeGestureHandler) { |
| 76 EXPECT_FALSE(test_api_.HasGestureHandler()); | 77 EXPECT_FALSE(test_api_.HasGestureHandler()); |
| 77 | 78 |
| 78 test_api_.SetInkDropMode(InkDropMode::ON_NO_GESTURE_HANDLER); | 79 test_api_.SetInkDropMode(InkDropMode::ON_NO_GESTURE_HANDLER); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 | 144 |
| 144 TEST_F(InkDropHostViewTest, DismissInkDropOnTouchOrGestureEvents) { | 145 TEST_F(InkDropHostViewTest, DismissInkDropOnTouchOrGestureEvents) { |
| 145 host_view_.SetSize(gfx::Size(20, 20)); | 146 host_view_.SetSize(gfx::Size(20, 20)); |
| 146 | 147 |
| 147 test_api_.SetInkDropMode(InkDropMode::ON_NO_GESTURE_HANDLER); | 148 test_api_.SetInkDropMode(InkDropMode::ON_NO_GESTURE_HANDLER); |
| 148 | 149 |
| 149 // Ensure the target ink drop is in the expected state. | 150 // Ensure the target ink drop is in the expected state. |
| 150 EXPECT_EQ(test_api_.GetInkDrop()->GetTargetInkDropState(), | 151 EXPECT_EQ(test_api_.GetInkDrop()->GetTargetInkDropState(), |
| 151 InkDropState::HIDDEN); | 152 InkDropState::HIDDEN); |
| 152 | 153 |
| 153 ui::MouseEvent mouse_event(ui::ET_MOUSE_PRESSED, gfx::Point(5, 6), | 154 ui::MouseEvent mouse_event( |
| 154 gfx::Point(5, 6), ui::EventTimeForNow(), | 155 ui::ET_MOUSE_PRESSED, gfx::Point(5, 6), gfx::Point(5, 6), |
| 155 ui::EF_LEFT_MOUSE_BUTTON, 0); | 156 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 0, |
| 157 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 156 | 158 |
| 157 test_api_.AnimateInkDrop(InkDropState::ACTION_PENDING, &mouse_event); | 159 test_api_.AnimateInkDrop(InkDropState::ACTION_PENDING, &mouse_event); |
| 158 EXPECT_EQ(test_api_.GetInkDrop()->GetTargetInkDropState(), | 160 EXPECT_EQ(test_api_.GetInkDrop()->GetTargetInkDropState(), |
| 159 InkDropState::ACTION_PENDING); | 161 InkDropState::ACTION_PENDING); |
| 160 | 162 |
| 161 ui::TouchEvent touch_event( | 163 ui::TouchEvent touch_event( |
| 162 ui::ET_TOUCH_PRESSED, gfx::Point(5, 6), ui::EventTimeForNow(), | 164 ui::ET_TOUCH_PRESSED, gfx::Point(5, 6), ui::EventTimeForNow(), |
| 163 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1)); | 165 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1)); |
| 164 | 166 |
| 165 test_api_.AnimateInkDrop(InkDropState::ACTION_TRIGGERED, &touch_event); | 167 test_api_.AnimateInkDrop(InkDropState::ACTION_TRIGGERED, &touch_event); |
| 166 EXPECT_EQ(test_api_.GetInkDrop()->GetTargetInkDropState(), | 168 EXPECT_EQ(test_api_.GetInkDrop()->GetTargetInkDropState(), |
| 167 InkDropState::ACTION_TRIGGERED); | 169 InkDropState::ACTION_TRIGGERED); |
| 168 } | 170 } |
| 169 #endif | 171 #endif |
| 170 | 172 |
| 171 } // namespace test | 173 } // namespace test |
| 172 } // namespace views | 174 } // namespace views |
| OLD | NEW |