| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ash/common/wm/window_positioner.h" | 5 #include "ash/common/wm/window_positioner.h" |
| 6 #include "ash/common/wm/window_positioning_utils.h" | 6 #include "ash/common/wm/window_positioning_utils.h" |
| 7 #include "ash/common/wm_shell.h" | 7 #include "ash/common/wm_shell.h" |
| 8 #include "ash/common/wm_window.h" | 8 #include "ash/common/wm_window.h" |
| 9 #include "ash/public/cpp/shell_window_ids.h" | 9 #include "ash/public/cpp/shell_window_ids.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 using TouchTest = test::ExoTestBase; | 27 using TouchTest = test::ExoTestBase; |
| 28 | 28 |
| 29 class MockTouchDelegate : public TouchDelegate { | 29 class MockTouchDelegate : public TouchDelegate { |
| 30 public: | 30 public: |
| 31 MockTouchDelegate() {} | 31 MockTouchDelegate() {} |
| 32 | 32 |
| 33 // Overridden from TouchDelegate: | 33 // Overridden from TouchDelegate: |
| 34 MOCK_METHOD1(OnTouchDestroying, void(Touch*)); | 34 MOCK_METHOD1(OnTouchDestroying, void(Touch*)); |
| 35 MOCK_CONST_METHOD1(CanAcceptTouchEventsForSurface, bool(Surface*)); | 35 MOCK_CONST_METHOD1(CanAcceptTouchEventsForSurface, bool(Surface*)); |
| 36 MOCK_METHOD4(OnTouchDown, | 36 MOCK_METHOD4(OnTouchDown, |
| 37 void(Surface*, base::TimeTicks, int, const gfx::Point&)); | 37 void(Surface*, base::TimeTicks, int, const gfx::PointF&)); |
| 38 MOCK_METHOD2(OnTouchUp, void(base::TimeTicks, int)); | 38 MOCK_METHOD2(OnTouchUp, void(base::TimeTicks, int)); |
| 39 MOCK_METHOD3(OnTouchMotion, void(base::TimeTicks, int, const gfx::Point&)); | 39 MOCK_METHOD3(OnTouchMotion, void(base::TimeTicks, int, const gfx::PointF&)); |
| 40 MOCK_METHOD3(OnTouchShape, void(int, float, float)); | 40 MOCK_METHOD3(OnTouchShape, void(int, float, float)); |
| 41 MOCK_METHOD0(OnTouchFrame, void()); | 41 MOCK_METHOD0(OnTouchFrame, void()); |
| 42 MOCK_METHOD0(OnTouchCancel, void()); | 42 MOCK_METHOD0(OnTouchCancel, void()); |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 class MockTouchStylusDelegate : public TouchStylusDelegate { | 45 class MockTouchStylusDelegate : public TouchStylusDelegate { |
| 46 public: | 46 public: |
| 47 MockTouchStylusDelegate() {} | 47 MockTouchStylusDelegate() {} |
| 48 | 48 |
| 49 // Overridden from TouchStylusDelegate: | 49 // Overridden from TouchStylusDelegate: |
| 50 MOCK_METHOD1(OnTouchDestroying, void(Touch*)); | 50 MOCK_METHOD1(OnTouchDestroying, void(Touch*)); |
| 51 MOCK_METHOD2(OnTouchTool, void(int, ui::EventPointerType)); | 51 MOCK_METHOD2(OnTouchTool, void(int, ui::EventPointerType)); |
| 52 MOCK_METHOD3(OnTouchForce, void(base::TimeTicks, int, float)); | 52 MOCK_METHOD3(OnTouchForce, void(base::TimeTicks, int, float)); |
| 53 MOCK_METHOD3(OnTouchTilt, void(base::TimeTicks, int, const gfx::Vector2dF&)); | 53 MOCK_METHOD3(OnTouchTilt, void(base::TimeTicks, int, const gfx::Vector2dF&)); |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 TEST_F(TouchTest, OnTouchDown) { | 56 TEST_F(TouchTest, OnTouchDown) { |
| 57 MockTouchDelegate delegate; | 57 MockTouchDelegate delegate; |
| 58 std::unique_ptr<Touch> touch(new Touch(&delegate)); | 58 std::unique_ptr<Touch> touch(new Touch(&delegate)); |
| 59 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow()); | 59 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow()); |
| 60 | 60 |
| 61 auto bottom_window = exo_test_helper()->CreateWindow(10, 10, false); | 61 auto bottom_window = exo_test_helper()->CreateWindow(10, 10, false); |
| 62 auto top_window = exo_test_helper()->CreateWindow(8, 8, false); | 62 auto top_window = exo_test_helper()->CreateWindow(8, 8, false); |
| 63 | 63 |
| 64 EXPECT_CALL(delegate, OnTouchShape(testing::_, testing::_, testing::_)) | 64 EXPECT_CALL(delegate, OnTouchShape(testing::_, testing::_, testing::_)) |
| 65 .Times(testing::AnyNumber()); | 65 .Times(testing::AnyNumber()); |
| 66 EXPECT_CALL(delegate, CanAcceptTouchEventsForSurface(top_window.surface())) | 66 EXPECT_CALL(delegate, CanAcceptTouchEventsForSurface(top_window.surface())) |
| 67 .WillRepeatedly(testing::Return(true)); | 67 .WillRepeatedly(testing::Return(true)); |
| 68 EXPECT_CALL(delegate, | 68 EXPECT_CALL(delegate, |
| 69 OnTouchDown(top_window.surface(), testing::_, 1, gfx::Point())); | 69 OnTouchDown(top_window.surface(), testing::_, 1, gfx::PointF())); |
| 70 EXPECT_CALL(delegate, OnTouchFrame()); | 70 EXPECT_CALL(delegate, OnTouchFrame()); |
| 71 generator.set_current_location(top_window.origin()); | 71 generator.set_current_location(top_window.origin()); |
| 72 generator.PressTouchId(1); | 72 generator.PressTouchId(1); |
| 73 | 73 |
| 74 EXPECT_CALL(delegate, CanAcceptTouchEventsForSurface(bottom_window.surface())) | 74 EXPECT_CALL(delegate, CanAcceptTouchEventsForSurface(bottom_window.surface())) |
| 75 .WillRepeatedly(testing::Return(true)); | 75 .WillRepeatedly(testing::Return(true)); |
| 76 | 76 |
| 77 // Second touch point should be relative to the focus surface. | 77 // Second touch point should be relative to the focus surface. |
| 78 EXPECT_CALL(delegate, OnTouchDown(top_window.surface(), testing::_, 2, | 78 EXPECT_CALL(delegate, OnTouchDown(top_window.surface(), testing::_, 2, |
| 79 gfx::Point(-1, -1))); | 79 gfx::PointF(-1, -1))); |
| 80 EXPECT_CALL(delegate, OnTouchFrame()); | 80 EXPECT_CALL(delegate, OnTouchFrame()); |
| 81 | 81 |
| 82 generator.set_current_location(bottom_window.origin()); | 82 generator.set_current_location(bottom_window.origin()); |
| 83 generator.PressTouchId(2); | 83 generator.PressTouchId(2); |
| 84 | 84 |
| 85 EXPECT_CALL(delegate, OnTouchDestroying(touch.get())); | 85 EXPECT_CALL(delegate, OnTouchDestroying(touch.get())); |
| 86 touch.reset(); | 86 touch.reset(); |
| 87 } | 87 } |
| 88 | 88 |
| 89 TEST_F(TouchTest, OnTouchUp) { | 89 TEST_F(TouchTest, OnTouchUp) { |
| 90 auto window = exo_test_helper()->CreateWindow(10, 10, false); | 90 auto window = exo_test_helper()->CreateWindow(10, 10, false); |
| 91 | 91 |
| 92 MockTouchDelegate delegate; | 92 MockTouchDelegate delegate; |
| 93 std::unique_ptr<Touch> touch(new Touch(&delegate)); | 93 std::unique_ptr<Touch> touch(new Touch(&delegate)); |
| 94 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow()); | 94 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow()); |
| 95 | 95 |
| 96 EXPECT_CALL(delegate, OnTouchShape(testing::_, testing::_, testing::_)) | 96 EXPECT_CALL(delegate, OnTouchShape(testing::_, testing::_, testing::_)) |
| 97 .Times(testing::AnyNumber()); | 97 .Times(testing::AnyNumber()); |
| 98 EXPECT_CALL(delegate, CanAcceptTouchEventsForSurface(window.surface())) | 98 EXPECT_CALL(delegate, CanAcceptTouchEventsForSurface(window.surface())) |
| 99 .WillRepeatedly(testing::Return(true)); | 99 .WillRepeatedly(testing::Return(true)); |
| 100 EXPECT_CALL(delegate, OnTouchDown(window.surface(), testing::_, testing::_, | 100 EXPECT_CALL(delegate, OnTouchDown(window.surface(), testing::_, testing::_, |
| 101 gfx::Point())) | 101 gfx::PointF())) |
| 102 .Times(2); | 102 .Times(2); |
| 103 EXPECT_CALL(delegate, OnTouchFrame()).Times(2); | 103 EXPECT_CALL(delegate, OnTouchFrame()).Times(2); |
| 104 generator.set_current_location(window.origin()); | 104 generator.set_current_location(window.origin()); |
| 105 generator.PressTouchId(1); | 105 generator.PressTouchId(1); |
| 106 generator.PressTouchId(2); | 106 generator.PressTouchId(2); |
| 107 | 107 |
| 108 EXPECT_CALL(delegate, OnTouchUp(testing::_, 1)); | 108 EXPECT_CALL(delegate, OnTouchUp(testing::_, 1)); |
| 109 EXPECT_CALL(delegate, OnTouchFrame()); | 109 EXPECT_CALL(delegate, OnTouchFrame()); |
| 110 generator.ReleaseTouchId(1); | 110 generator.ReleaseTouchId(1); |
| 111 EXPECT_CALL(delegate, OnTouchUp(testing::_, 2)); | 111 EXPECT_CALL(delegate, OnTouchUp(testing::_, 2)); |
| 112 EXPECT_CALL(delegate, OnTouchFrame()); | 112 EXPECT_CALL(delegate, OnTouchFrame()); |
| 113 generator.ReleaseTouchId(2); | 113 generator.ReleaseTouchId(2); |
| 114 | 114 |
| 115 EXPECT_CALL(delegate, OnTouchDestroying(touch.get())); | 115 EXPECT_CALL(delegate, OnTouchDestroying(touch.get())); |
| 116 touch.reset(); | 116 touch.reset(); |
| 117 } | 117 } |
| 118 | 118 |
| 119 TEST_F(TouchTest, OnTouchMotion) { | 119 TEST_F(TouchTest, OnTouchMotion) { |
| 120 auto window = exo_test_helper()->CreateWindow(10, 10, false); | 120 auto window = exo_test_helper()->CreateWindow(10, 10, false); |
| 121 | 121 |
| 122 MockTouchDelegate delegate; | 122 MockTouchDelegate delegate; |
| 123 std::unique_ptr<Touch> touch(new Touch(&delegate)); | 123 std::unique_ptr<Touch> touch(new Touch(&delegate)); |
| 124 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow()); | 124 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow()); |
| 125 | 125 |
| 126 EXPECT_CALL(delegate, OnTouchShape(testing::_, testing::_, testing::_)) | 126 EXPECT_CALL(delegate, OnTouchShape(testing::_, testing::_, testing::_)) |
| 127 .Times(testing::AnyNumber()); | 127 .Times(testing::AnyNumber()); |
| 128 EXPECT_CALL(delegate, CanAcceptTouchEventsForSurface(window.surface())) | 128 EXPECT_CALL(delegate, CanAcceptTouchEventsForSurface(window.surface())) |
| 129 .WillRepeatedly(testing::Return(true)); | 129 .WillRepeatedly(testing::Return(true)); |
| 130 EXPECT_CALL(delegate, OnTouchDown(window.surface(), testing::_, testing::_, | 130 EXPECT_CALL(delegate, OnTouchDown(window.surface(), testing::_, testing::_, |
| 131 gfx::Point())); | 131 gfx::PointF())); |
| 132 EXPECT_CALL(delegate, | 132 EXPECT_CALL(delegate, |
| 133 OnTouchMotion(testing::_, testing::_, gfx::Point(5, 5))); | 133 OnTouchMotion(testing::_, testing::_, gfx::PointF(5, 5))); |
| 134 EXPECT_CALL(delegate, OnTouchUp(testing::_, testing::_)); | 134 EXPECT_CALL(delegate, OnTouchUp(testing::_, testing::_)); |
| 135 EXPECT_CALL(delegate, OnTouchFrame()).Times(3); | 135 EXPECT_CALL(delegate, OnTouchFrame()).Times(3); |
| 136 generator.set_current_location(window.origin()); | 136 generator.set_current_location(window.origin()); |
| 137 generator.PressMoveAndReleaseTouchBy(5, 5); | 137 generator.PressMoveAndReleaseTouchBy(5, 5); |
| 138 | 138 |
| 139 // Check if touch point motion outside focus surface is reported properly to | 139 // Check if touch point motion outside focus surface is reported properly to |
| 140 // the focus surface. | 140 // the focus surface. |
| 141 EXPECT_CALL(delegate, OnTouchDown(window.surface(), testing::_, testing::_, | 141 EXPECT_CALL(delegate, OnTouchDown(window.surface(), testing::_, testing::_, |
| 142 gfx::Point())); | 142 gfx::PointF())); |
| 143 EXPECT_CALL(delegate, | 143 EXPECT_CALL(delegate, |
| 144 OnTouchMotion(testing::_, testing::_, gfx::Point(100, 100))); | 144 OnTouchMotion(testing::_, testing::_, gfx::PointF(100, 100))); |
| 145 EXPECT_CALL(delegate, OnTouchUp(testing::_, testing::_)); | 145 EXPECT_CALL(delegate, OnTouchUp(testing::_, testing::_)); |
| 146 EXPECT_CALL(delegate, OnTouchFrame()).Times(3); | 146 EXPECT_CALL(delegate, OnTouchFrame()).Times(3); |
| 147 generator.set_current_location(window.origin()); | 147 generator.set_current_location(window.origin()); |
| 148 generator.PressMoveAndReleaseTouchBy(100, 100); | 148 generator.PressMoveAndReleaseTouchBy(100, 100); |
| 149 | 149 |
| 150 EXPECT_CALL(delegate, OnTouchDestroying(touch.get())); | 150 EXPECT_CALL(delegate, OnTouchDestroying(touch.get())); |
| 151 touch.reset(); | 151 touch.reset(); |
| 152 } | 152 } |
| 153 | 153 |
| 154 TEST_F(TouchTest, OnTouchShape) { | 154 TEST_F(TouchTest, OnTouchShape) { |
| 155 auto window = exo_test_helper()->CreateWindow(10, 10, false); | 155 auto window = exo_test_helper()->CreateWindow(10, 10, false); |
| 156 | 156 |
| 157 MockTouchDelegate delegate; | 157 MockTouchDelegate delegate; |
| 158 std::unique_ptr<Touch> touch(new Touch(&delegate)); | 158 std::unique_ptr<Touch> touch(new Touch(&delegate)); |
| 159 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow()); | 159 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow()); |
| 160 | 160 |
| 161 EXPECT_CALL(delegate, CanAcceptTouchEventsForSurface(window.surface())) | 161 EXPECT_CALL(delegate, CanAcceptTouchEventsForSurface(window.surface())) |
| 162 .WillRepeatedly(testing::Return(true)); | 162 .WillRepeatedly(testing::Return(true)); |
| 163 { | 163 { |
| 164 testing::InSequence sequence; | 164 testing::InSequence sequence; |
| 165 EXPECT_CALL(delegate, OnTouchDown(window.surface(), testing::_, testing::_, | 165 EXPECT_CALL(delegate, OnTouchDown(window.surface(), testing::_, testing::_, |
| 166 gfx::Point())); | 166 gfx::PointF())); |
| 167 EXPECT_CALL(delegate, OnTouchShape(testing::_, 1, 1)); | 167 EXPECT_CALL(delegate, OnTouchShape(testing::_, 1, 1)); |
| 168 EXPECT_CALL(delegate, OnTouchFrame()); | 168 EXPECT_CALL(delegate, OnTouchFrame()); |
| 169 EXPECT_CALL(delegate, | 169 EXPECT_CALL(delegate, |
| 170 OnTouchMotion(testing::_, testing::_, gfx::Point(5, 5))); | 170 OnTouchMotion(testing::_, testing::_, gfx::PointF(5, 5))); |
| 171 EXPECT_CALL(delegate, OnTouchShape(testing::_, 1, 1)); | 171 EXPECT_CALL(delegate, OnTouchShape(testing::_, 1, 1)); |
| 172 EXPECT_CALL(delegate, OnTouchFrame()); | 172 EXPECT_CALL(delegate, OnTouchFrame()); |
| 173 EXPECT_CALL(delegate, | 173 EXPECT_CALL(delegate, |
| 174 OnTouchMotion(testing::_, testing::_, gfx::Point(10, 10))); | 174 OnTouchMotion(testing::_, testing::_, gfx::PointF(10, 10))); |
| 175 EXPECT_CALL(delegate, OnTouchShape(testing::_, 20, 10)); | 175 EXPECT_CALL(delegate, OnTouchShape(testing::_, 20, 10)); |
| 176 EXPECT_CALL(delegate, OnTouchFrame()); | 176 EXPECT_CALL(delegate, OnTouchFrame()); |
| 177 EXPECT_CALL(delegate, OnTouchUp(testing::_, testing::_)); | 177 EXPECT_CALL(delegate, OnTouchUp(testing::_, testing::_)); |
| 178 EXPECT_CALL(delegate, OnTouchFrame()); | 178 EXPECT_CALL(delegate, OnTouchFrame()); |
| 179 } | 179 } |
| 180 generator.set_current_location(window.origin()); | 180 generator.set_current_location(window.origin()); |
| 181 generator.PressTouch(); | 181 generator.PressTouch(); |
| 182 generator.MoveTouchBy(5, 5); | 182 generator.MoveTouchBy(5, 5); |
| 183 generator.SetTouchRadius(20, 10); | 183 generator.SetTouchRadius(20, 10); |
| 184 generator.MoveTouchBy(5, 5); | 184 generator.MoveTouchBy(5, 5); |
| 185 generator.ReleaseTouch(); | 185 generator.ReleaseTouch(); |
| 186 EXPECT_CALL(delegate, OnTouchDestroying(touch.get())); | 186 EXPECT_CALL(delegate, OnTouchDestroying(touch.get())); |
| 187 touch.reset(); | 187 touch.reset(); |
| 188 } | 188 } |
| 189 | 189 |
| 190 TEST_F(TouchTest, OnTouchCancel) { | 190 TEST_F(TouchTest, OnTouchCancel) { |
| 191 auto window = exo_test_helper()->CreateWindow(10, 10, false); | 191 auto window = exo_test_helper()->CreateWindow(10, 10, false); |
| 192 | 192 |
| 193 MockTouchDelegate delegate; | 193 MockTouchDelegate delegate; |
| 194 std::unique_ptr<Touch> touch(new Touch(&delegate)); | 194 std::unique_ptr<Touch> touch(new Touch(&delegate)); |
| 195 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow()); | 195 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow()); |
| 196 | 196 |
| 197 EXPECT_CALL(delegate, OnTouchShape(testing::_, testing::_, testing::_)) | 197 EXPECT_CALL(delegate, OnTouchShape(testing::_, testing::_, testing::_)) |
| 198 .Times(testing::AnyNumber()); | 198 .Times(testing::AnyNumber()); |
| 199 EXPECT_CALL(delegate, CanAcceptTouchEventsForSurface(window.surface())) | 199 EXPECT_CALL(delegate, CanAcceptTouchEventsForSurface(window.surface())) |
| 200 .WillRepeatedly(testing::Return(true)); | 200 .WillRepeatedly(testing::Return(true)); |
| 201 EXPECT_CALL(delegate, OnTouchDown(window.surface(), testing::_, testing::_, | 201 EXPECT_CALL(delegate, OnTouchDown(window.surface(), testing::_, testing::_, |
| 202 gfx::Point())) | 202 gfx::PointF())) |
| 203 .Times(2); | 203 .Times(2); |
| 204 EXPECT_CALL(delegate, OnTouchFrame()).Times(2); | 204 EXPECT_CALL(delegate, OnTouchFrame()).Times(2); |
| 205 generator.set_current_location(window.origin()); | 205 generator.set_current_location(window.origin()); |
| 206 generator.PressTouchId(1); | 206 generator.PressTouchId(1); |
| 207 generator.PressTouchId(2); | 207 generator.PressTouchId(2); |
| 208 | 208 |
| 209 // One touch point being canceled is enough for OnTouchCancel to be called. | 209 // One touch point being canceled is enough for OnTouchCancel to be called. |
| 210 EXPECT_CALL(delegate, OnTouchCancel()); | 210 EXPECT_CALL(delegate, OnTouchCancel()); |
| 211 EXPECT_CALL(delegate, OnTouchFrame()); | 211 EXPECT_CALL(delegate, OnTouchFrame()); |
| 212 ui::TouchEvent cancel_event(ui::ET_TOUCH_CANCELLED, gfx::Point(), 1, | 212 ui::TouchEvent cancel_event(ui::ET_TOUCH_CANCELLED, gfx::Point(), 1, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 233 .Times(testing::AnyNumber()); | 233 .Times(testing::AnyNumber()); |
| 234 EXPECT_CALL(delegate, CanAcceptTouchEventsForSurface(window.surface())) | 234 EXPECT_CALL(delegate, CanAcceptTouchEventsForSurface(window.surface())) |
| 235 .WillRepeatedly(testing::Return(true)); | 235 .WillRepeatedly(testing::Return(true)); |
| 236 EXPECT_CALL(delegate, CanAcceptTouchEventsForSurface(modal.surface())) | 236 EXPECT_CALL(delegate, CanAcceptTouchEventsForSurface(modal.surface())) |
| 237 .WillRepeatedly(testing::Return(true)); | 237 .WillRepeatedly(testing::Return(true)); |
| 238 | 238 |
| 239 // Check if touch events on modal window are registered. | 239 // Check if touch events on modal window are registered. |
| 240 { | 240 { |
| 241 testing::InSequence sequence; | 241 testing::InSequence sequence; |
| 242 EXPECT_CALL(delegate, OnTouchDown(modal.surface(), testing::_, testing::_, | 242 EXPECT_CALL(delegate, OnTouchDown(modal.surface(), testing::_, testing::_, |
| 243 gfx::Point())); | 243 gfx::PointF())); |
| 244 EXPECT_CALL(delegate, OnTouchFrame()); | 244 EXPECT_CALL(delegate, OnTouchFrame()); |
| 245 EXPECT_CALL(delegate, | 245 EXPECT_CALL(delegate, |
| 246 OnTouchMotion(testing::_, testing::_, gfx::Point(1, 1))); | 246 OnTouchMotion(testing::_, testing::_, gfx::PointF(1, 1))); |
| 247 EXPECT_CALL(delegate, OnTouchFrame()); | 247 EXPECT_CALL(delegate, OnTouchFrame()); |
| 248 EXPECT_CALL(delegate, OnTouchUp(testing::_, testing::_)); | 248 EXPECT_CALL(delegate, OnTouchUp(testing::_, testing::_)); |
| 249 EXPECT_CALL(delegate, OnTouchFrame()); | 249 EXPECT_CALL(delegate, OnTouchFrame()); |
| 250 } | 250 } |
| 251 generator.set_current_location(modal.origin()); | 251 generator.set_current_location(modal.origin()); |
| 252 generator.PressMoveAndReleaseTouchBy(1, 1); | 252 generator.PressMoveAndReleaseTouchBy(1, 1); |
| 253 | 253 |
| 254 // Check if touch events on non-modal window are ignored. | 254 // Check if touch events on non-modal window are ignored. |
| 255 { | 255 { |
| 256 testing::InSequence sequence; | 256 testing::InSequence sequence; |
| 257 EXPECT_CALL(delegate, OnTouchDown(window.surface(), testing::_, testing::_, | 257 EXPECT_CALL(delegate, OnTouchDown(window.surface(), testing::_, testing::_, |
| 258 gfx::Point())) | 258 gfx::PointF())) |
| 259 .Times(0); | 259 .Times(0); |
| 260 EXPECT_CALL(delegate, | 260 EXPECT_CALL(delegate, |
| 261 OnTouchMotion(testing::_, testing::_, gfx::Point(1, 1))) | 261 OnTouchMotion(testing::_, testing::_, gfx::PointF(1, 1))) |
| 262 .Times(0); | 262 .Times(0); |
| 263 EXPECT_CALL(delegate, OnTouchUp(testing::_, testing::_)).Times(0); | 263 EXPECT_CALL(delegate, OnTouchUp(testing::_, testing::_)).Times(0); |
| 264 EXPECT_CALL(delegate, OnTouchFrame()).Times(0); | 264 EXPECT_CALL(delegate, OnTouchFrame()).Times(0); |
| 265 } | 265 } |
| 266 generator.set_current_location(window.origin()); | 266 generator.set_current_location(window.origin()); |
| 267 generator.PressMoveAndReleaseTouchBy(1, 1); | 267 generator.PressMoveAndReleaseTouchBy(1, 1); |
| 268 | 268 |
| 269 // Make the window non-modal. | 269 // Make the window non-modal. |
| 270 modal.shell_surface()->SetSystemModal(false); | 270 modal.shell_surface()->SetSystemModal(false); |
| 271 EXPECT_FALSE(ash::WmShell::Get()->IsSystemModalWindowOpen()); | 271 EXPECT_FALSE(ash::WmShell::Get()->IsSystemModalWindowOpen()); |
| 272 | 272 |
| 273 // Check if touch events on non-modal window are registered. | 273 // Check if touch events on non-modal window are registered. |
| 274 { | 274 { |
| 275 testing::InSequence sequence; | 275 testing::InSequence sequence; |
| 276 EXPECT_CALL(delegate, OnTouchDown(window.surface(), testing::_, testing::_, | 276 EXPECT_CALL(delegate, OnTouchDown(window.surface(), testing::_, testing::_, |
| 277 gfx::Point())); | 277 gfx::PointF())); |
| 278 EXPECT_CALL(delegate, OnTouchFrame()); | 278 EXPECT_CALL(delegate, OnTouchFrame()); |
| 279 EXPECT_CALL(delegate, | 279 EXPECT_CALL(delegate, |
| 280 OnTouchMotion(testing::_, testing::_, gfx::Point(1, 1))); | 280 OnTouchMotion(testing::_, testing::_, gfx::PointF(1, 1))); |
| 281 EXPECT_CALL(delegate, OnTouchFrame()); | 281 EXPECT_CALL(delegate, OnTouchFrame()); |
| 282 EXPECT_CALL(delegate, OnTouchUp(testing::_, testing::_)); | 282 EXPECT_CALL(delegate, OnTouchUp(testing::_, testing::_)); |
| 283 EXPECT_CALL(delegate, OnTouchFrame()); | 283 EXPECT_CALL(delegate, OnTouchFrame()); |
| 284 } | 284 } |
| 285 generator.set_current_location(window.origin()); | 285 generator.set_current_location(window.origin()); |
| 286 generator.PressMoveAndReleaseTouchBy(1, 1); | 286 generator.PressMoveAndReleaseTouchBy(1, 1); |
| 287 | 287 |
| 288 EXPECT_CALL(delegate, OnTouchDestroying(touch.get())); | 288 EXPECT_CALL(delegate, OnTouchDestroying(touch.get())); |
| 289 touch.reset(); | 289 touch.reset(); |
| 290 } | 290 } |
| 291 | 291 |
| 292 TEST_F(TouchTest, OnTouchTool) { | 292 TEST_F(TouchTest, OnTouchTool) { |
| 293 auto window = exo_test_helper()->CreateWindow(10, 10, false); | 293 auto window = exo_test_helper()->CreateWindow(10, 10, false); |
| 294 | 294 |
| 295 MockTouchDelegate delegate; | 295 MockTouchDelegate delegate; |
| 296 MockTouchStylusDelegate stylus_delegate; | 296 MockTouchStylusDelegate stylus_delegate; |
| 297 std::unique_ptr<Touch> touch(new Touch(&delegate)); | 297 std::unique_ptr<Touch> touch(new Touch(&delegate)); |
| 298 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow()); | 298 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow()); |
| 299 touch->SetStylusDelegate(&stylus_delegate); | 299 touch->SetStylusDelegate(&stylus_delegate); |
| 300 | 300 |
| 301 EXPECT_CALL(delegate, OnTouchShape(testing::_, testing::_, testing::_)) | 301 EXPECT_CALL(delegate, OnTouchShape(testing::_, testing::_, testing::_)) |
| 302 .Times(testing::AnyNumber()); | 302 .Times(testing::AnyNumber()); |
| 303 EXPECT_CALL(delegate, CanAcceptTouchEventsForSurface(window.surface())) | 303 EXPECT_CALL(delegate, CanAcceptTouchEventsForSurface(window.surface())) |
| 304 .WillRepeatedly(testing::Return(true)); | 304 .WillRepeatedly(testing::Return(true)); |
| 305 | 305 |
| 306 // Expect tool change to happen before frame of down event. | 306 // Expect tool change to happen before frame of down event. |
| 307 { | 307 { |
| 308 testing::InSequence sequence; | 308 testing::InSequence sequence; |
| 309 EXPECT_CALL(delegate, OnTouchDown(window.surface(), testing::_, testing::_, | 309 EXPECT_CALL(delegate, OnTouchDown(window.surface(), testing::_, testing::_, |
| 310 gfx::Point())); | 310 gfx::PointF())); |
| 311 EXPECT_CALL(stylus_delegate, | 311 EXPECT_CALL(stylus_delegate, |
| 312 OnTouchTool(0, ui::EventPointerType::POINTER_TYPE_PEN)); | 312 OnTouchTool(0, ui::EventPointerType::POINTER_TYPE_PEN)); |
| 313 EXPECT_CALL(delegate, OnTouchFrame()); | 313 EXPECT_CALL(delegate, OnTouchFrame()); |
| 314 EXPECT_CALL(delegate, OnTouchUp(testing::_, testing::_)); | 314 EXPECT_CALL(delegate, OnTouchUp(testing::_, testing::_)); |
| 315 EXPECT_CALL(delegate, OnTouchFrame()); | 315 EXPECT_CALL(delegate, OnTouchFrame()); |
| 316 } | 316 } |
| 317 generator.set_current_location(window.origin()); | 317 generator.set_current_location(window.origin()); |
| 318 generator.SetTouchPointerType(ui::EventPointerType::POINTER_TYPE_PEN); | 318 generator.SetTouchPointerType(ui::EventPointerType::POINTER_TYPE_PEN); |
| 319 generator.PressTouch(); | 319 generator.PressTouch(); |
| 320 generator.ReleaseTouch(); | 320 generator.ReleaseTouch(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 334 | 334 |
| 335 EXPECT_CALL(delegate, OnTouchShape(testing::_, testing::_, testing::_)) | 335 EXPECT_CALL(delegate, OnTouchShape(testing::_, testing::_, testing::_)) |
| 336 .Times(testing::AnyNumber()); | 336 .Times(testing::AnyNumber()); |
| 337 EXPECT_CALL(delegate, CanAcceptTouchEventsForSurface(window.surface())) | 337 EXPECT_CALL(delegate, CanAcceptTouchEventsForSurface(window.surface())) |
| 338 .WillRepeatedly(testing::Return(true)); | 338 .WillRepeatedly(testing::Return(true)); |
| 339 | 339 |
| 340 // Expect tool change to happen before frame of down event. | 340 // Expect tool change to happen before frame of down event. |
| 341 { | 341 { |
| 342 testing::InSequence sequence; | 342 testing::InSequence sequence; |
| 343 EXPECT_CALL(delegate, OnTouchDown(window.surface(), testing::_, testing::_, | 343 EXPECT_CALL(delegate, OnTouchDown(window.surface(), testing::_, testing::_, |
| 344 gfx::Point())); | 344 gfx::PointF())); |
| 345 EXPECT_CALL(stylus_delegate, | 345 EXPECT_CALL(stylus_delegate, |
| 346 OnTouchTool(0, ui::EventPointerType::POINTER_TYPE_PEN)); | 346 OnTouchTool(0, ui::EventPointerType::POINTER_TYPE_PEN)); |
| 347 EXPECT_CALL(stylus_delegate, OnTouchForce(testing::_, 0, 1.0)); | 347 EXPECT_CALL(stylus_delegate, OnTouchForce(testing::_, 0, 1.0)); |
| 348 EXPECT_CALL(delegate, OnTouchFrame()); | 348 EXPECT_CALL(delegate, OnTouchFrame()); |
| 349 EXPECT_CALL(delegate, OnTouchUp(testing::_, testing::_)); | 349 EXPECT_CALL(delegate, OnTouchUp(testing::_, testing::_)); |
| 350 EXPECT_CALL(delegate, OnTouchFrame()); | 350 EXPECT_CALL(delegate, OnTouchFrame()); |
| 351 } | 351 } |
| 352 generator.set_current_location(window.origin()); | 352 generator.set_current_location(window.origin()); |
| 353 generator.SetTouchPointerType(ui::EventPointerType::POINTER_TYPE_PEN); | 353 generator.SetTouchPointerType(ui::EventPointerType::POINTER_TYPE_PEN); |
| 354 generator.SetTouchForce(1.0); | 354 generator.SetTouchForce(1.0); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 370 | 370 |
| 371 EXPECT_CALL(delegate, OnTouchShape(testing::_, testing::_, testing::_)) | 371 EXPECT_CALL(delegate, OnTouchShape(testing::_, testing::_, testing::_)) |
| 372 .Times(testing::AnyNumber()); | 372 .Times(testing::AnyNumber()); |
| 373 EXPECT_CALL(delegate, CanAcceptTouchEventsForSurface(window.surface())) | 373 EXPECT_CALL(delegate, CanAcceptTouchEventsForSurface(window.surface())) |
| 374 .WillRepeatedly(testing::Return(true)); | 374 .WillRepeatedly(testing::Return(true)); |
| 375 | 375 |
| 376 // Expect tool change to happen before frame of down event. | 376 // Expect tool change to happen before frame of down event. |
| 377 { | 377 { |
| 378 testing::InSequence sequence; | 378 testing::InSequence sequence; |
| 379 EXPECT_CALL(delegate, OnTouchDown(window.surface(), testing::_, testing::_, | 379 EXPECT_CALL(delegate, OnTouchDown(window.surface(), testing::_, testing::_, |
| 380 gfx::Point())); | 380 gfx::PointF())); |
| 381 EXPECT_CALL(stylus_delegate, | 381 EXPECT_CALL(stylus_delegate, |
| 382 OnTouchTool(0, ui::EventPointerType::POINTER_TYPE_PEN)); | 382 OnTouchTool(0, ui::EventPointerType::POINTER_TYPE_PEN)); |
| 383 EXPECT_CALL(stylus_delegate, | 383 EXPECT_CALL(stylus_delegate, |
| 384 OnTouchTilt(testing::_, 0, gfx::Vector2dF(1.0, 2.0))); | 384 OnTouchTilt(testing::_, 0, gfx::Vector2dF(1.0, 2.0))); |
| 385 EXPECT_CALL(delegate, OnTouchFrame()); | 385 EXPECT_CALL(delegate, OnTouchFrame()); |
| 386 EXPECT_CALL(delegate, OnTouchUp(testing::_, testing::_)); | 386 EXPECT_CALL(delegate, OnTouchUp(testing::_, testing::_)); |
| 387 EXPECT_CALL(delegate, OnTouchFrame()); | 387 EXPECT_CALL(delegate, OnTouchFrame()); |
| 388 } | 388 } |
| 389 generator.set_current_location(window.origin()); | 389 generator.set_current_location(window.origin()); |
| 390 generator.SetTouchPointerType(ui::EventPointerType::POINTER_TYPE_PEN); | 390 generator.SetTouchPointerType(ui::EventPointerType::POINTER_TYPE_PEN); |
| 391 generator.SetTouchTilt(1.0, 2.0); | 391 generator.SetTouchTilt(1.0, 2.0); |
| 392 generator.PressTouch(); | 392 generator.PressTouch(); |
| 393 generator.ReleaseTouch(); | 393 generator.ReleaseTouch(); |
| 394 | 394 |
| 395 EXPECT_CALL(delegate, OnTouchDestroying(touch.get())); | 395 EXPECT_CALL(delegate, OnTouchDestroying(touch.get())); |
| 396 touch.reset(); | 396 touch.reset(); |
| 397 } | 397 } |
| 398 | 398 |
| 399 } // namespace | 399 } // namespace |
| 400 } // namespace exo | 400 } // namespace exo |
| OLD | NEW |