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

Side by Side Diff: services/ui/ws/window_manager_state_unittest.cc

Issue 2696873002: Change OnWindowInputEvent to use display_id to find the host and update event root_location in WS. (Closed)
Patch Set: nits Created 3 years, 9 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
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 "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 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 // then try to send any queued events. 377 // then try to send any queued events.
378 TEST_F(WindowManagerStateTest, DontSendQueuedEventsToADeadTree) { 378 TEST_F(WindowManagerStateTest, DontSendQueuedEventsToADeadTree) {
379 ServerWindow* target = window(); 379 ServerWindow* target = window();
380 TestChangeTracker* tracker = window_tree_client()->tracker(); 380 TestChangeTracker* tracker = window_tree_client()->tracker();
381 381
382 ui::MouseEvent press(ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5), 382 ui::MouseEvent press(ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5),
383 base::TimeTicks(), EF_LEFT_MOUSE_BUTTON, 383 base::TimeTicks(), EF_LEFT_MOUSE_BUTTON,
384 EF_LEFT_MOUSE_BUTTON); 384 EF_LEFT_MOUSE_BUTTON);
385 DispatchInputEventToWindow(target, press, nullptr); 385 DispatchInputEventToWindow(target, press, nullptr);
386 ASSERT_EQ(1u, tracker->changes()->size()); 386 ASSERT_EQ(1u, tracker->changes()->size());
387 EXPECT_EQ("InputEvent window=1,1 event_action=1", 387 EXPECT_EQ("InputEvent window=1,1 event_action=1 event_root_location=5,5",
388 ChangesToDescription1(*tracker->changes())[0]); 388 ChangesToDescription1(*tracker->changes())[0]);
389 tracker->changes()->clear(); 389 tracker->changes()->clear();
390 // The above is not setting TreeAwaitingInputAck. 390 // The above is not setting TreeAwaitingInputAck.
391 391
392 // Queue the key release event; it should not be immediately dispatched 392 // Queue the key release event; it should not be immediately dispatched
393 // because there's no ACK for the last one. 393 // because there's no ACK for the last one.
394 ui::MouseEvent release(ui::ET_MOUSE_RELEASED, gfx::Point(5, 5), 394 ui::MouseEvent release(ui::ET_MOUSE_RELEASED, gfx::Point(5, 5),
395 gfx::Point(5, 5), base::TimeTicks(), 395 gfx::Point(5, 5), base::TimeTicks(),
396 EF_LEFT_MOUSE_BUTTON, EF_LEFT_MOUSE_BUTTON); 396 EF_LEFT_MOUSE_BUTTON, EF_LEFT_MOUSE_BUTTON);
397 DispatchInputEventToWindow(target, release, nullptr); 397 DispatchInputEventToWindow(target, release, nullptr);
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 ui::PointerEvent move( 580 ui::PointerEvent move(
581 ui::ET_POINTER_MOVED, gfx::Point(25, 25), gfx::Point(25, 25), 0, 0, 0, 581 ui::ET_POINTER_MOVED, gfx::Point(25, 25), gfx::Point(25, 25), 0, 0, 0,
582 ui::PointerDetails(EventPointerType::POINTER_TYPE_MOUSE), 582 ui::PointerDetails(EventPointerType::POINTER_TYPE_MOUSE),
583 base::TimeTicks()); 583 base::TimeTicks());
584 window_manager_state()->ProcessEvent(move, 0); 584 window_manager_state()->ProcessEvent(move, 0);
585 // The event isn't over a valid target, which should trigger resetting the 585 // The event isn't over a valid target, which should trigger resetting the
586 // cursor to POINTER. 586 // cursor to POINTER.
587 EXPECT_EQ(ui::mojom::Cursor::POINTER, display_test_api.last_cursor()); 587 EXPECT_EQ(ui::mojom::Cursor::POINTER, display_test_api.last_cursor());
588 } 588 }
589 589
590 TEST_F(WindowManagerStateTest, RootLocationCoordinateConversion) {
591 TestWindowTreeClient* embed_connection = nullptr;
592 WindowTree* target_tree = nullptr;
593 ServerWindow* target = nullptr;
594 window()->SetBounds(gfx::Rect(10, 10, 100, 100));
595 CreateSecondaryTree(&embed_connection, &target_tree, &target);
596 TestWindowManager target_window_manager;
597 WindowTreeTestApi(target_tree)
598 .set_window_manager_internal(&target_window_manager);
599
600 const gfx::Point event_location(40, 50);
601 const gfx::Point event_root_location(30, 40);
602 ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_root_location,
603 base::TimeTicks(), 0, 0);
604 std::unique_ptr<Accelerator> accelerator = CreateAccelerator();
605 DispatchInputEventToWindow(target, mouse, accelerator.get());
606 TestChangeTracker* tracker = embed_connection->tracker();
607 ASSERT_EQ(1u, tracker->changes()->size());
608 EXPECT_EQ("InputEvent window=2,1 event_action=4 event_root_location=20,30",
609 ChangesToDescription1(*tracker->changes())[0]);
610 EXPECT_TRUE(wm_client()->tracker()->changes()->empty());
611 }
612
590 } // namespace test 613 } // namespace test
591 } // namespace ws 614 } // namespace ws
592 } // namespace ui 615 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698