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

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: TODO 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 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 // then try to send any queued events. 378 // then try to send any queued events.
379 TEST_F(WindowManagerStateTest, DontSendQueuedEventsToADeadTree) { 379 TEST_F(WindowManagerStateTest, DontSendQueuedEventsToADeadTree) {
380 ServerWindow* target = window(); 380 ServerWindow* target = window();
381 TestChangeTracker* tracker = window_tree_client()->tracker(); 381 TestChangeTracker* tracker = window_tree_client()->tracker();
382 382
383 ui::MouseEvent press(ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5), 383 ui::MouseEvent press(ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5),
384 base::TimeTicks(), EF_LEFT_MOUSE_BUTTON, 384 base::TimeTicks(), EF_LEFT_MOUSE_BUTTON,
385 EF_LEFT_MOUSE_BUTTON); 385 EF_LEFT_MOUSE_BUTTON);
386 DispatchInputEventToWindow(target, press, nullptr); 386 DispatchInputEventToWindow(target, press, nullptr);
387 ASSERT_EQ(1u, tracker->changes()->size()); 387 ASSERT_EQ(1u, tracker->changes()->size());
388 EXPECT_EQ("InputEvent window=1,1 event_action=1", 388 EXPECT_EQ("InputEvent window=1,1 event_action=1 event_root_location=5,5",
389 ChangesToDescription1(*tracker->changes())[0]); 389 ChangesToDescription1(*tracker->changes())[0]);
390 tracker->changes()->clear(); 390 tracker->changes()->clear();
391 // The above is not setting TreeAwaitingInputAck. 391 // The above is not setting TreeAwaitingInputAck.
392 392
393 // Queue the key release event; it should not be immediately dispatched 393 // Queue the key release event; it should not be immediately dispatched
394 // because there's no ACK for the last one. 394 // because there's no ACK for the last one.
395 ui::MouseEvent release(ui::ET_MOUSE_RELEASED, gfx::Point(5, 5), 395 ui::MouseEvent release(ui::ET_MOUSE_RELEASED, gfx::Point(5, 5),
396 gfx::Point(5, 5), base::TimeTicks(), 396 gfx::Point(5, 5), base::TimeTicks(),
397 EF_LEFT_MOUSE_BUTTON, EF_LEFT_MOUSE_BUTTON); 397 EF_LEFT_MOUSE_BUTTON, EF_LEFT_MOUSE_BUTTON);
398 DispatchInputEventToWindow(target, release, nullptr); 398 DispatchInputEventToWindow(target, release, nullptr);
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 ui::PointerEvent move( 581 ui::PointerEvent move(
582 ui::ET_POINTER_MOVED, gfx::Point(25, 25), gfx::Point(25, 25), 0, 0, 0, 582 ui::ET_POINTER_MOVED, gfx::Point(25, 25), gfx::Point(25, 25), 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, 0); 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 } 589 }
590 590
591 TEST_F(WindowManagerStateTest, RootLocationCoordinateConversion) {
592 TestWindowTreeClient* embed_connection = nullptr;
593 WindowTree* target_tree = nullptr;
594 ServerWindow* target = nullptr;
595 window()->SetBounds(gfx::Rect(10, 10, 100, 100));
596 CreateSecondaryTree(&embed_connection, &target_tree, &target);
597 TestWindowManager target_window_manager;
598 WindowTreeTestApi(target_tree)
599 .set_window_manager_internal(&target_window_manager);
600
601 const gfx::Point event_location(40, 50);
602 const gfx::Point event_root_location(30, 40);
603 ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_root_location,
604 base::TimeTicks(), 0, 0);
605 std::unique_ptr<Accelerator> accelerator = CreateAccelerator();
606 DispatchInputEventToWindow(target, mouse, accelerator.get());
607 TestChangeTracker* tracker = embed_connection->tracker();
608 ASSERT_EQ(1u, tracker->changes()->size());
609 EXPECT_EQ("InputEvent window=2,1 event_action=4 event_root_location=20,30",
610 ChangesToDescription1(*tracker->changes())[0]);
611 EXPECT_TRUE(wm_client()->tracker()->changes()->empty());
612 }
613
591 } // namespace test 614 } // namespace test
592 } // namespace ws 615 } // namespace ws
593 } // namespace ui 616 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698