| 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/color_palette.h" |
| 12 #include "ui/gfx/geometry/point.h" | 13 #include "ui/gfx/geometry/point.h" |
| 13 #include "ui/gfx/geometry/size.h" | 14 #include "ui/gfx/geometry/size.h" |
| 14 #include "ui/views/animation/test/ink_drop_host_view_test_api.h" | 15 #include "ui/views/animation/test/ink_drop_host_view_test_api.h" |
| 15 | 16 |
| 16 namespace views { | 17 namespace views { |
| 17 namespace test { | 18 namespace test { |
| 18 | 19 |
| 20 class InkDropHostViewColor : public InkDropHostView { |
| 21 protected: |
| 22 SkColor GetInkDropBaseColor() const override { |
| 23 return gfx::kPlaceholderColor; |
| 24 } |
| 25 }; |
| 26 |
| 19 class InkDropHostViewTest : public testing::Test { | 27 class InkDropHostViewTest : public testing::Test { |
| 20 public: | 28 public: |
| 21 InkDropHostViewTest(); | 29 InkDropHostViewTest(); |
| 22 ~InkDropHostViewTest() override; | 30 ~InkDropHostViewTest() override; |
| 23 | 31 |
| 24 protected: | 32 protected: |
| 25 // Test target. | 33 // Test target. |
| 26 InkDropHostView host_view_; | 34 InkDropHostViewColor host_view_; |
| 27 | 35 |
| 28 // Provides internal access to |host_view_| test target. | 36 // Provides internal access to |host_view_| test target. |
| 29 InkDropHostViewTestApi test_api_; | 37 InkDropHostViewTestApi test_api_; |
| 30 | 38 |
| 31 private: | 39 private: |
| 32 DISALLOW_COPY_AND_ASSIGN(InkDropHostViewTest); | 40 DISALLOW_COPY_AND_ASSIGN(InkDropHostViewTest); |
| 33 }; | 41 }; |
| 34 | 42 |
| 35 InkDropHostViewTest::InkDropHostViewTest() : test_api_(&host_view_) {} | 43 InkDropHostViewTest::InkDropHostViewTest() : test_api_(&host_view_) {} |
| 36 | 44 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 64 test_api_.SetHasInkDrop(true); | 72 test_api_.SetHasInkDrop(true); |
| 65 EXPECT_TRUE(test_api_.HasGestureHandler()); | 73 EXPECT_TRUE(test_api_.HasGestureHandler()); |
| 66 | 74 |
| 67 test_api_.SetHasInkDrop(true); | 75 test_api_.SetHasInkDrop(true); |
| 68 EXPECT_TRUE(test_api_.HasGestureHandler()); | 76 EXPECT_TRUE(test_api_.HasGestureHandler()); |
| 69 | 77 |
| 70 test_api_.SetHasInkDrop(false); | 78 test_api_.SetHasInkDrop(false); |
| 71 EXPECT_FALSE(test_api_.HasGestureHandler()); | 79 EXPECT_FALSE(test_api_.HasGestureHandler()); |
| 72 } | 80 } |
| 73 | 81 |
| 82 #if defined(OS_WIN) |
| 83 TEST_F(InkDropHostViewTest, NoInkDropOnTouchOrGestureEvents) { |
| 84 host_view_.SetSize(gfx::Size(20, 20)); |
| 85 |
| 86 test_api_.SetHasInkDrop(true); |
| 87 |
| 88 // Ensure the target ink drop is in the expected state. |
| 89 EXPECT_EQ(test_api_.ink_drop()->GetTargetInkDropState(), |
| 90 InkDropState::HIDDEN); |
| 91 |
| 92 ui::TouchEvent touch_event(ui::ET_TOUCH_PRESSED, gfx::Point(5, 6), 1, |
| 93 ui::EventTimeForNow()); |
| 94 |
| 95 test_api_.AnimateInkDrop(InkDropState::ACTION_PENDING, &touch_event); |
| 96 EXPECT_EQ(test_api_.ink_drop()->GetTargetInkDropState(), |
| 97 InkDropState::HIDDEN); |
| 98 |
| 99 test_api_.AnimateInkDrop(InkDropState::ALTERNATE_ACTION_PENDING, |
| 100 &touch_event); |
| 101 EXPECT_EQ(test_api_.ink_drop()->GetTargetInkDropState(), |
| 102 InkDropState::HIDDEN); |
| 103 |
| 104 ui::GestureEvent gesture_event(5.0f, 6.0f, 0, ui::EventTimeForNow(), |
| 105 ui::GestureEventDetails(ui::ET_GESTURE_TAP)); |
| 106 |
| 107 test_api_.AnimateInkDrop(InkDropState::ACTION_PENDING, &gesture_event); |
| 108 EXPECT_EQ(test_api_.ink_drop()->GetTargetInkDropState(), |
| 109 InkDropState::HIDDEN); |
| 110 |
| 111 test_api_.AnimateInkDrop(InkDropState::ALTERNATE_ACTION_PENDING, |
| 112 &gesture_event); |
| 113 EXPECT_EQ(test_api_.ink_drop()->GetTargetInkDropState(), |
| 114 InkDropState::HIDDEN); |
| 115 } |
| 116 |
| 117 TEST_F(InkDropHostViewTest, DismissInkDropOnTouchOrGestureEvents) { |
| 118 host_view_.SetSize(gfx::Size(20, 20)); |
| 119 |
| 120 test_api_.SetHasInkDrop(true); |
| 121 |
| 122 // Ensure the target ink drop is in the expected state. |
| 123 EXPECT_EQ(test_api_.ink_drop()->GetTargetInkDropState(), |
| 124 InkDropState::HIDDEN); |
| 125 |
| 126 ui::MouseEvent mouse_event(ui::ET_MOUSE_PRESSED, gfx::Point(5, 6), |
| 127 gfx::Point(5, 6), ui::EventTimeForNow(), |
| 128 ui::EF_LEFT_MOUSE_BUTTON, 0); |
| 129 |
| 130 test_api_.AnimateInkDrop(InkDropState::ACTION_PENDING, &mouse_event); |
| 131 EXPECT_EQ(test_api_.ink_drop()->GetTargetInkDropState(), |
| 132 InkDropState::ACTION_PENDING); |
| 133 |
| 134 ui::TouchEvent touch_event(ui::ET_TOUCH_PRESSED, gfx::Point(5, 6), 1, |
| 135 ui::EventTimeForNow()); |
| 136 |
| 137 test_api_.AnimateInkDrop(InkDropState::ACTION_TRIGGERED, &touch_event); |
| 138 EXPECT_EQ(test_api_.ink_drop()->GetTargetInkDropState(), |
| 139 InkDropState::ACTION_TRIGGERED); |
| 140 } |
| 141 #endif |
| 142 |
| 74 } // namespace test | 143 } // namespace test |
| 75 } // namespace views | 144 } // namespace views |
| OLD | NEW |