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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 ui::EF_LEFT_MOUSE_BUTTON, 0); | 63 ui::EF_LEFT_MOUSE_BUTTON, 0); |
64 | 64 |
65 test_api_.AnimateInkDrop(InkDropState::ACTION_PENDING, &located_event); | 65 test_api_.AnimateInkDrop(InkDropState::ACTION_PENDING, &located_event); |
66 EXPECT_EQ(gfx::Point(5, 6), test_api_.GetInkDropCenterBasedOnLastEvent()); | 66 EXPECT_EQ(gfx::Point(5, 6), test_api_.GetInkDropCenterBasedOnLastEvent()); |
67 } | 67 } |
68 | 68 |
69 // Verifies that SetInkDropMode() sets up gesture handling properly. | 69 // Verifies that SetInkDropMode() sets up gesture handling properly. |
70 TEST_F(InkDropHostViewTest, SetInkDropModeGestureHandler) { | 70 TEST_F(InkDropHostViewTest, SetInkDropModeGestureHandler) { |
71 EXPECT_FALSE(test_api_.HasGestureHandler()); | 71 EXPECT_FALSE(test_api_.HasGestureHandler()); |
72 | 72 |
73 test_api_.SetInkDropMode(InkDropMode::ON_NO_GESTURE_HANDLER); | 73 host_view_.SetInkDropMode(InkDropMode::ON_NO_GESTURE_HANDLER); |
74 EXPECT_FALSE(test_api_.HasGestureHandler()); | 74 EXPECT_FALSE(test_api_.HasGestureHandler()); |
75 | 75 |
76 test_api_.SetInkDropMode(InkDropMode::ON); | 76 host_view_.SetInkDropMode(InkDropMode::ON); |
77 EXPECT_TRUE(test_api_.HasGestureHandler()); | 77 EXPECT_TRUE(test_api_.HasGestureHandler()); |
78 | 78 |
79 // Enabling gesture handler the second time should just work (no crash). | 79 // Enabling gesture handler the second time should just work (no crash). |
80 test_api_.SetInkDropMode(InkDropMode::ON); | 80 host_view_.SetInkDropMode(InkDropMode::ON); |
81 EXPECT_TRUE(test_api_.HasGestureHandler()); | 81 EXPECT_TRUE(test_api_.HasGestureHandler()); |
82 | 82 |
83 test_api_.SetInkDropMode(InkDropMode::OFF); | 83 host_view_.SetInkDropMode(InkDropMode::OFF); |
84 EXPECT_FALSE(test_api_.HasGestureHandler()); | 84 EXPECT_FALSE(test_api_.HasGestureHandler()); |
85 } | 85 } |
86 | 86 |
87 #if defined(OS_WIN) | 87 #if defined(OS_WIN) |
88 TEST_F(InkDropHostViewTest, NoInkDropOnTouchOrGestureEvents) { | 88 TEST_F(InkDropHostViewTest, NoInkDropOnTouchOrGestureEvents) { |
89 host_view_.SetSize(gfx::Size(20, 20)); | 89 host_view_.SetSize(gfx::Size(20, 20)); |
90 | 90 |
91 test_api_.SetInkDropMode(InkDropMode::ON_NO_GESTURE_HANDLER); | 91 host_view_.SetInkDropMode(InkDropMode::ON_NO_GESTURE_HANDLER); |
92 | 92 |
93 // Ensure the target ink drop is in the expected state. | 93 // Ensure the target ink drop is in the expected state. |
94 EXPECT_EQ(test_api_.ink_drop()->GetTargetInkDropState(), | 94 EXPECT_EQ(test_api_.ink_drop()->GetTargetInkDropState(), |
95 InkDropState::HIDDEN); | 95 InkDropState::HIDDEN); |
96 | 96 |
97 ui::TouchEvent touch_event(ui::ET_TOUCH_PRESSED, gfx::Point(5, 6), 1, | 97 ui::TouchEvent touch_event(ui::ET_TOUCH_PRESSED, gfx::Point(5, 6), 1, |
98 ui::EventTimeForNow()); | 98 ui::EventTimeForNow()); |
99 | 99 |
100 test_api_.AnimateInkDrop(InkDropState::ACTION_PENDING, &touch_event); | 100 test_api_.AnimateInkDrop(InkDropState::ACTION_PENDING, &touch_event); |
101 EXPECT_EQ(test_api_.ink_drop()->GetTargetInkDropState(), | 101 EXPECT_EQ(test_api_.ink_drop()->GetTargetInkDropState(), |
(...skipping 13 matching lines...) Expand all Loading... |
115 | 115 |
116 test_api_.AnimateInkDrop(InkDropState::ALTERNATE_ACTION_PENDING, | 116 test_api_.AnimateInkDrop(InkDropState::ALTERNATE_ACTION_PENDING, |
117 &gesture_event); | 117 &gesture_event); |
118 EXPECT_EQ(test_api_.ink_drop()->GetTargetInkDropState(), | 118 EXPECT_EQ(test_api_.ink_drop()->GetTargetInkDropState(), |
119 InkDropState::HIDDEN); | 119 InkDropState::HIDDEN); |
120 } | 120 } |
121 | 121 |
122 TEST_F(InkDropHostViewTest, DismissInkDropOnTouchOrGestureEvents) { | 122 TEST_F(InkDropHostViewTest, DismissInkDropOnTouchOrGestureEvents) { |
123 host_view_.SetSize(gfx::Size(20, 20)); | 123 host_view_.SetSize(gfx::Size(20, 20)); |
124 | 124 |
125 test_api_.SetInkDropMode(InkDropMode::ON_NO_GESTURE_HANDLER); | 125 host_view_.SetInkDropMode(InkDropMode::ON_NO_GESTURE_HANDLER); |
126 | 126 |
127 // Ensure the target ink drop is in the expected state. | 127 // Ensure the target ink drop is in the expected state. |
128 EXPECT_EQ(test_api_.ink_drop()->GetTargetInkDropState(), | 128 EXPECT_EQ(test_api_.ink_drop()->GetTargetInkDropState(), |
129 InkDropState::HIDDEN); | 129 InkDropState::HIDDEN); |
130 | 130 |
131 ui::MouseEvent mouse_event(ui::ET_MOUSE_PRESSED, gfx::Point(5, 6), | 131 ui::MouseEvent mouse_event(ui::ET_MOUSE_PRESSED, gfx::Point(5, 6), |
132 gfx::Point(5, 6), ui::EventTimeForNow(), | 132 gfx::Point(5, 6), ui::EventTimeForNow(), |
133 ui::EF_LEFT_MOUSE_BUTTON, 0); | 133 ui::EF_LEFT_MOUSE_BUTTON, 0); |
134 | 134 |
135 test_api_.AnimateInkDrop(InkDropState::ACTION_PENDING, &mouse_event); | 135 test_api_.AnimateInkDrop(InkDropState::ACTION_PENDING, &mouse_event); |
136 EXPECT_EQ(test_api_.ink_drop()->GetTargetInkDropState(), | 136 EXPECT_EQ(test_api_.ink_drop()->GetTargetInkDropState(), |
137 InkDropState::ACTION_PENDING); | 137 InkDropState::ACTION_PENDING); |
138 | 138 |
139 ui::TouchEvent touch_event(ui::ET_TOUCH_PRESSED, gfx::Point(5, 6), 1, | 139 ui::TouchEvent touch_event(ui::ET_TOUCH_PRESSED, gfx::Point(5, 6), 1, |
140 ui::EventTimeForNow()); | 140 ui::EventTimeForNow()); |
141 | 141 |
142 test_api_.AnimateInkDrop(InkDropState::ACTION_TRIGGERED, &touch_event); | 142 test_api_.AnimateInkDrop(InkDropState::ACTION_TRIGGERED, &touch_event); |
143 EXPECT_EQ(test_api_.ink_drop()->GetTargetInkDropState(), | 143 EXPECT_EQ(test_api_.ink_drop()->GetTargetInkDropState(), |
144 InkDropState::ACTION_TRIGGERED); | 144 InkDropState::ACTION_TRIGGERED); |
145 } | 145 } |
146 #endif | 146 #endif |
147 | 147 |
148 } // namespace test | 148 } // namespace test |
149 } // namespace views | 149 } // namespace views |
OLD | NEW |