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/shell_window_ids.h" |
5 #include "ash/common/wm/window_positioner.h" | 6 #include "ash/common/wm/window_positioner.h" |
| 7 #include "ash/common/wm_shell.h" |
6 #include "ash/shell.h" | 8 #include "ash/shell.h" |
7 #include "ash/wm/window_util.h" | 9 #include "ash/wm/window_util.h" |
8 #include "components/exo/buffer.h" | 10 #include "components/exo/buffer.h" |
9 #include "components/exo/shell_surface.h" | 11 #include "components/exo/shell_surface.h" |
10 #include "components/exo/surface.h" | 12 #include "components/exo/surface.h" |
11 #include "components/exo/test/exo_test_base.h" | 13 #include "components/exo/test/exo_test_base.h" |
12 #include "components/exo/test/exo_test_helper.h" | 14 #include "components/exo/test/exo_test_helper.h" |
13 #include "components/exo/touch.h" | 15 #include "components/exo/touch.h" |
14 #include "components/exo/touch_delegate.h" | 16 #include "components/exo/touch_delegate.h" |
15 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 // One touch point being canceled is enough for OnTouchCancel to be called. | 183 // One touch point being canceled is enough for OnTouchCancel to be called. |
182 EXPECT_CALL(delegate, OnTouchCancel()); | 184 EXPECT_CALL(delegate, OnTouchCancel()); |
183 ui::TouchEvent cancel_event(ui::ET_TOUCH_CANCELLED, gfx::Point(), 1, | 185 ui::TouchEvent cancel_event(ui::ET_TOUCH_CANCELLED, gfx::Point(), 1, |
184 ui::EventTimeForNow()); | 186 ui::EventTimeForNow()); |
185 generator.Dispatch(&cancel_event); | 187 generator.Dispatch(&cancel_event); |
186 | 188 |
187 EXPECT_CALL(delegate, OnTouchDestroying(touch.get())); | 189 EXPECT_CALL(delegate, OnTouchDestroying(touch.get())); |
188 touch.reset(); | 190 touch.reset(); |
189 } | 191 } |
190 | 192 |
| 193 TEST_F(TouchTest, IgnoreTouchEventDuringModal) { |
| 194 std::unique_ptr<Surface> surface(new Surface); |
| 195 std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get())); |
| 196 std::unique_ptr<Buffer> buffer( |
| 197 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(gfx::Size(10, 10)))); |
| 198 surface->Attach(buffer.get()); |
| 199 surface->Commit(); |
| 200 gfx::Point location = surface->window()->GetBoundsInScreen().origin(); |
| 201 |
| 202 MockTouchDelegate delegate; |
| 203 std::unique_ptr<Touch> touch(new Touch(&delegate)); |
| 204 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow()); |
| 205 |
| 206 // Create surface for modal window. |
| 207 std::unique_ptr<Surface> surface2(new Surface); |
| 208 std::unique_ptr<ShellSurface> shell_surface2( |
| 209 new ShellSurface(surface2.get(), nullptr, gfx::Rect(0, 0, 5, 5), true, |
| 210 ash::kShellWindowId_SystemModalContainer)); |
| 211 std::unique_ptr<Buffer> buffer2( |
| 212 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(gfx::Size(5, 5)))); |
| 213 surface2->Attach(buffer2.get()); |
| 214 surface2->Commit(); |
| 215 ash::wm::CenterWindow(surface2->window()); |
| 216 |
| 217 // Make the window modal. |
| 218 shell_surface2->SetSystemModal(true); |
| 219 EXPECT_TRUE(ash::WmShell::Get()->IsSystemModalWindowOpen()); |
| 220 |
| 221 EXPECT_CALL(delegate, CanAcceptTouchEventsForSurface(surface.get())) |
| 222 .WillRepeatedly(testing::Return(true)); |
| 223 |
| 224 // Check if touch events on non-modal window are ignored. |
| 225 { |
| 226 testing::InSequence sequence; |
| 227 EXPECT_CALL(delegate, OnTouchDown(surface.get(), testing::_, testing::_, |
| 228 gfx::Point())) |
| 229 .Times(0); |
| 230 EXPECT_CALL(delegate, |
| 231 OnTouchMotion(testing::_, testing::_, gfx::Point(100, 100))) |
| 232 .Times(0); |
| 233 EXPECT_CALL(delegate, OnTouchUp(testing::_, testing::_)).Times(0); |
| 234 } |
| 235 generator.set_current_location(location); |
| 236 generator.PressMoveAndReleaseTouchBy(100, 100); |
| 237 |
| 238 // Make the window non-modal. |
| 239 shell_surface2->SetSystemModal(false); |
| 240 EXPECT_FALSE(ash::WmShell::Get()->IsSystemModalWindowOpen()); |
| 241 |
| 242 // Check if touch events on non-modal window are registered. |
| 243 { |
| 244 testing::InSequence sequence; |
| 245 EXPECT_CALL(delegate, OnTouchDown(surface.get(), testing::_, testing::_, |
| 246 gfx::Point())); |
| 247 EXPECT_CALL(delegate, |
| 248 OnTouchMotion(testing::_, testing::_, gfx::Point(100, 100))); |
| 249 EXPECT_CALL(delegate, OnTouchUp(testing::_, testing::_)); |
| 250 } |
| 251 generator.set_current_location(location); |
| 252 generator.PressMoveAndReleaseTouchBy(100, 100); |
| 253 |
| 254 EXPECT_CALL(delegate, OnTouchDestroying(touch.get())); |
| 255 touch.reset(); |
| 256 } |
| 257 |
191 } // namespace | 258 } // namespace |
192 } // namespace exo | 259 } // namespace exo |
OLD | NEW |