Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Side by Side Diff: ui/views/animation/ink_drop_host_view_unittest.cc

Issue 2117603002: Added tests and reworked ink-drop touch logic (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/views/animation/ink_drop_host_view.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 }
kylix_rd 2016/06/30 21:45:53 Added this override to work around the NOTREACHED
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
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
105 TEST_F(InkDropHostViewTest, DismissInkDropOnTouchOrGestureEvents) {
106 host_view_.SetSize(gfx::Size(20, 20));
107
108 test_api_.SetHasInkDrop(true);
109
110 // Ensure the target ink drop is in the expected state.
111 EXPECT_EQ(test_api_.ink_drop()->GetTargetInkDropState(),
112 InkDropState::HIDDEN);
113
114 ui::MouseEvent mouse_event(ui::ET_MOUSE_PRESSED, gfx::Point(5, 6),
115 gfx::Point(5, 6), ui::EventTimeForNow(),
116 ui::EF_LEFT_MOUSE_BUTTON, 0);
117
118 test_api_.AnimateInkDrop(InkDropState::ACTION_PENDING, &mouse_event);
119 EXPECT_EQ(test_api_.ink_drop()->GetTargetInkDropState(),
120 InkDropState::ACTION_PENDING);
121
122 ui::TouchEvent touch_event(ui::ET_TOUCH_PRESSED, gfx::Point(5, 6), 1,
123 ui::EventTimeForNow());
124
125 test_api_.AnimateInkDrop(InkDropState::ACTION_TRIGGERED, &touch_event);
126 EXPECT_EQ(test_api_.ink_drop()->GetTargetInkDropState(),
127 InkDropState::ACTION_TRIGGERED);
128 }
129 #endif
130
74 } // namespace test 131 } // namespace test
75 } // namespace views 132 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/animation/ink_drop_host_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698