| 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 "services/ui/ws/window_manager_state.h" | 5 #include "services/ui/ws/window_manager_state.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 ASSERT_TRUE(window_manager_state()->event_dispatcher()->AddAccelerator( | 238 ASSERT_TRUE(window_manager_state()->event_dispatcher()->AddAccelerator( |
| 239 accelerator_id, std::move(matcher))); | 239 accelerator_id, std::move(matcher))); |
| 240 } | 240 } |
| 241 TestChangeTracker* tracker = wm_client()->tracker(); | 241 TestChangeTracker* tracker = wm_client()->tracker(); |
| 242 tracker->changes()->clear(); | 242 tracker->changes()->clear(); |
| 243 TestChangeTracker* tracker2 = window_tree_client()->tracker(); | 243 TestChangeTracker* tracker2 = window_tree_client()->tracker(); |
| 244 tracker2->changes()->clear(); | 244 tracker2->changes()->clear(); |
| 245 | 245 |
| 246 // Send an ensure only the pre accelerator is called. | 246 // Send an ensure only the pre accelerator is called. |
| 247 ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_CONTROL_DOWN); | 247 ui::KeyEvent key(ui::ET_KEY_PRESSED, ui::VKEY_W, ui::EF_CONTROL_DOWN); |
| 248 window_manager_state()->ProcessEvent(key); | 248 window_manager_state()->ProcessEvent(key, 0); |
| 249 EXPECT_TRUE(window_manager()->on_accelerator_called()); | 249 EXPECT_TRUE(window_manager()->on_accelerator_called()); |
| 250 EXPECT_EQ(accelerator_id, window_manager()->on_accelerator_id()); | 250 EXPECT_EQ(accelerator_id, window_manager()->on_accelerator_id()); |
| 251 EXPECT_TRUE(tracker->changes()->empty()); | 251 EXPECT_TRUE(tracker->changes()->empty()); |
| 252 EXPECT_TRUE(tracker2->changes()->empty()); | 252 EXPECT_TRUE(tracker2->changes()->empty()); |
| 253 | 253 |
| 254 // Ack the accelerator, saying we consumed it. | 254 // Ack the accelerator, saying we consumed it. |
| 255 WindowTreeTestApi(tree()).AckLastAccelerator(mojom::EventResult::HANDLED); | 255 WindowTreeTestApi(tree()).AckLastAccelerator(mojom::EventResult::HANDLED); |
| 256 // Nothing should change. | 256 // Nothing should change. |
| 257 EXPECT_TRUE(tracker->changes()->empty()); | 257 EXPECT_TRUE(tracker->changes()->empty()); |
| 258 EXPECT_TRUE(tracker2->changes()->empty()); | 258 EXPECT_TRUE(tracker2->changes()->empty()); |
| 259 | 259 |
| 260 window_manager()->ClearAcceleratorCalled(); | 260 window_manager()->ClearAcceleratorCalled(); |
| 261 | 261 |
| 262 // Repeat, but respond with UNHANDLED. | 262 // Repeat, but respond with UNHANDLED. |
| 263 window_manager_state()->ProcessEvent(key); | 263 window_manager_state()->ProcessEvent(key, 0); |
| 264 EXPECT_TRUE(window_manager()->on_accelerator_called()); | 264 EXPECT_TRUE(window_manager()->on_accelerator_called()); |
| 265 EXPECT_EQ(accelerator_id, window_manager()->on_accelerator_id()); | 265 EXPECT_EQ(accelerator_id, window_manager()->on_accelerator_id()); |
| 266 EXPECT_TRUE(tracker->changes()->empty()); | 266 EXPECT_TRUE(tracker->changes()->empty()); |
| 267 EXPECT_TRUE(tracker2->changes()->empty()); | 267 EXPECT_TRUE(tracker2->changes()->empty()); |
| 268 WindowTreeTestApi(tree()).AckLastAccelerator(mojom::EventResult::UNHANDLED); | 268 WindowTreeTestApi(tree()).AckLastAccelerator(mojom::EventResult::UNHANDLED); |
| 269 | 269 |
| 270 EXPECT_TRUE(tracker->changes()->empty()); | 270 EXPECT_TRUE(tracker->changes()->empty()); |
| 271 // The focused window should get the event. | 271 // The focused window should get the event. |
| 272 EXPECT_EQ("InputEvent window=0,11 event_action=7", | 272 EXPECT_EQ("InputEvent window=0,11 event_action=7", |
| 273 SingleChangeToDescription(*tracker2->changes())); | 273 SingleChangeToDescription(*tracker2->changes())); |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 ASSERT_EQ(1u, window_server()->display_manager()->displays().size()); | 575 ASSERT_EQ(1u, window_server()->display_manager()->displays().size()); |
| 576 Display* display = *(window_server()->display_manager()->displays().begin()); | 576 Display* display = *(window_server()->display_manager()->displays().begin()); |
| 577 DisplayTestApi display_test_api(display); | 577 DisplayTestApi display_test_api(display); |
| 578 // This test assumes the default is not a pointer, otherwise it can't detect | 578 // This test assumes the default is not a pointer, otherwise it can't detect |
| 579 // the change. | 579 // the change. |
| 580 EXPECT_NE(ui::mojom::Cursor::POINTER, display_test_api.last_cursor()); | 580 EXPECT_NE(ui::mojom::Cursor::POINTER, display_test_api.last_cursor()); |
| 581 ui::PointerEvent move( | 581 ui::PointerEvent move( |
| 582 ui::ET_POINTER_MOVED, gfx::Point(), gfx::Point(), 0, 0, 0, | 582 ui::ET_POINTER_MOVED, gfx::Point(), gfx::Point(), 0, 0, 0, |
| 583 ui::PointerDetails(EventPointerType::POINTER_TYPE_MOUSE), | 583 ui::PointerDetails(EventPointerType::POINTER_TYPE_MOUSE), |
| 584 base::TimeTicks()); | 584 base::TimeTicks()); |
| 585 window_manager_state()->ProcessEvent(move); | 585 window_manager_state()->ProcessEvent(move, 0); |
| 586 // The event isn't over a valid target, which should trigger resetting the | 586 // The event isn't over a valid target, which should trigger resetting the |
| 587 // cursor to POINTER. | 587 // cursor to POINTER. |
| 588 EXPECT_EQ(ui::mojom::Cursor::POINTER, display_test_api.last_cursor()); | 588 EXPECT_EQ(ui::mojom::Cursor::POINTER, display_test_api.last_cursor()); |
| 589 EXPECT_TRUE(tracker->changes()->empty()); | 589 EXPECT_TRUE(tracker->changes()->empty()); |
| 590 } | 590 } |
| 591 | 591 |
| 592 } // namespace test | 592 } // namespace test |
| 593 } // namespace ws | 593 } // namespace ws |
| 594 } // namespace ui | 594 } // namespace ui |
| OLD | NEW |