| Index: services/ui/ws/window_tree_unittest.cc
|
| diff --git a/services/ui/ws/window_tree_unittest.cc b/services/ui/ws/window_tree_unittest.cc
|
| index 356e40d1c48df6dd7a049e686fbf66561cf098a2..9513eb52db5fd9bf0f9c0632c77c272386c5d22e 100644
|
| --- a/services/ui/ws/window_tree_unittest.cc
|
| +++ b/services/ui/ws/window_tree_unittest.cc
|
| @@ -133,9 +133,6 @@ class WindowTreeTest : public testing::Test {
|
| return window_event_targeting_helper_.cursor();
|
| }
|
| Display* display() { return window_event_targeting_helper_.display(); }
|
| - TestWindowTreeBinding* last_binding() {
|
| - return window_event_targeting_helper_.last_binding();
|
| - }
|
| TestWindowTreeClient* last_window_tree_client() {
|
| return window_event_targeting_helper_.last_window_tree_client();
|
| }
|
| @@ -476,7 +473,8 @@ TEST_F(WindowTreeTest, CursorChangesWhenMouseOverWindowAndWindowSetsCursor) {
|
| // dispatched. This is only to place the mouse cursor over that window though.
|
| DispatchEventAndAckImmediately(CreateMouseMoveEvent(21, 22));
|
|
|
| - window->SetPredefinedCursor(mojom::Cursor::IBEAM);
|
| + // Set the cursor on the parent as that is where the cursor is picked up from.
|
| + window->parent()->SetPredefinedCursor(mojom::Cursor::IBEAM);
|
|
|
| // Because the cursor is over the window when SetCursor was called, we should
|
| // have immediately changed the cursor.
|
| @@ -492,7 +490,8 @@ TEST_F(WindowTreeTest, CursorChangesWhenEnteringWindowWithDifferentCursor) {
|
| // Let's create a pointer event outside the window and then move the pointer
|
| // inside.
|
| DispatchEventAndAckImmediately(CreateMouseMoveEvent(5, 5));
|
| - window->SetPredefinedCursor(mojom::Cursor::IBEAM);
|
| + // Set the cursor on the parent as that is where the cursor is picked up from.
|
| + window->parent()->SetPredefinedCursor(mojom::Cursor::IBEAM);
|
| EXPECT_EQ(mojom::Cursor::POINTER, cursor_id());
|
|
|
| DispatchEventAndAckImmediately(CreateMouseMoveEvent(21, 22));
|
| @@ -525,7 +524,8 @@ TEST_F(WindowTreeTest, DragOutsideWindow) {
|
| // Start with the cursor outside the window. Setting the cursor shouldn't
|
| // change the cursor.
|
| DispatchEventAndAckImmediately(CreateMouseMoveEvent(5, 5));
|
| - window->SetPredefinedCursor(mojom::Cursor::IBEAM);
|
| + // Set the cursor on the parent as that is where the cursor is picked up from.
|
| + window->parent()->SetPredefinedCursor(mojom::Cursor::IBEAM);
|
| EXPECT_EQ(mojom::Cursor::POINTER, cursor_id());
|
|
|
| // Move the pointer to the inside of the window
|
| @@ -543,7 +543,7 @@ TEST_F(WindowTreeTest, DragOutsideWindow) {
|
| // Release the cursor. We should now adapt the cursor of the window
|
| // underneath the pointer.
|
| DispatchEventAndAckImmediately(CreateMouseUpEvent(5, 5));
|
| - EXPECT_EQ(mojom::Cursor::CURSOR_NULL, cursor_id());
|
| + EXPECT_EQ(mojom::Cursor::POINTER, cursor_id());
|
| }
|
|
|
| TEST_F(WindowTreeTest, ChangingWindowBoundsChangesCursor) {
|
| @@ -554,7 +554,8 @@ TEST_F(WindowTreeTest, ChangingWindowBoundsChangesCursor) {
|
|
|
| // Put the cursor just outside the bounds of the window.
|
| DispatchEventAndAckImmediately(CreateMouseMoveEvent(41, 41));
|
| - window->SetPredefinedCursor(mojom::Cursor::IBEAM);
|
| + // Sets the cursor on the root as that is where the cursor is picked up from.
|
| + window->parent()->SetPredefinedCursor(mojom::Cursor::IBEAM);
|
| EXPECT_EQ(mojom::Cursor::POINTER, cursor_id());
|
|
|
| // Expand the bounds of the window so they now include where the cursor now
|
| @@ -564,36 +565,70 @@ TEST_F(WindowTreeTest, ChangingWindowBoundsChangesCursor) {
|
|
|
| // Contract the bounds again.
|
| window->SetBounds(gfx::Rect(20, 20, 20, 20));
|
| - EXPECT_EQ(mojom::Cursor::CURSOR_NULL, cursor_id());
|
| + EXPECT_EQ(mojom::Cursor::POINTER, cursor_id());
|
| }
|
|
|
| TEST_F(WindowTreeTest, WindowReorderingChangesCursor) {
|
| - TestWindowTreeClient* embed_client = nullptr;
|
| - WindowTree* tree = nullptr;
|
| - ServerWindow* window1 = nullptr;
|
| - EXPECT_NO_FATAL_FAILURE(SetupEventTargeting(&embed_client, &tree, &window1));
|
| -
|
| - // Create a second window right over the first.
|
| - const ClientWindowId embed_window_id(FirstRootId(tree));
|
| - const ClientWindowId child2_id(BuildClientWindowId(tree, 2));
|
| - EXPECT_TRUE(tree->NewWindow(child2_id, ServerWindow::Properties()));
|
| - ServerWindow* child2 = tree->GetWindowByClientId(child2_id);
|
| - ASSERT_TRUE(child2);
|
| - EXPECT_TRUE(tree->AddWindow(embed_window_id, child2_id));
|
| - child2->SetVisible(true);
|
| - child2->SetBounds(gfx::Rect(20, 20, 20, 20));
|
| -
|
| - // Give each window a different cursor.
|
| - window1->SetPredefinedCursor(mojom::Cursor::IBEAM);
|
| - child2->SetPredefinedCursor(mojom::Cursor::HAND);
|
| -
|
| - // We expect window2 to be over window1 now.
|
| - DispatchEventAndAckImmediately(CreateMouseMoveEvent(22, 22));
|
| - EXPECT_EQ(mojom::Cursor::HAND, cursor_id());
|
| -
|
| - // But when we put window2 at the bottom, we should adapt window1's cursor.
|
| - child2->parent()->StackChildAtBottom(child2);
|
| + // Setup two trees parented to the root with the same bounds.
|
| + ServerWindow* embed_window1 =
|
| + window_event_targeting_helper_.CreatePrimaryTree(
|
| + gfx::Rect(0, 0, 200, 200), gfx::Rect(0, 0, 50, 50));
|
| + ServerWindow* embed_window2 =
|
| + window_event_targeting_helper_.CreatePrimaryTree(
|
| + gfx::Rect(0, 0, 200, 200), gfx::Rect(0, 0, 50, 50));
|
| +
|
| + ASSERT_EQ(embed_window1->parent(), embed_window2->parent());
|
| + embed_window1->set_event_targeting_policy(
|
| + mojom::EventTargetingPolicy::TARGET_AND_DESCENDANTS);
|
| + embed_window2->set_event_targeting_policy(
|
| + mojom::EventTargetingPolicy::TARGET_AND_DESCENDANTS);
|
| + embed_window1->SetPredefinedCursor(mojom::Cursor::IBEAM);
|
| + embed_window2->SetPredefinedCursor(mojom::Cursor::CROSS);
|
| + DispatchEventAndAckImmediately(CreateMouseMoveEvent(5, 5));
|
| + // Cursor should match that of top-most window, which is |embed_window2|.
|
| + EXPECT_EQ(mojom::Cursor::CROSS, cursor_id());
|
| + // Move |embed_window1| on top, cursor should now match it.
|
| + embed_window1->parent()->StackChildAtTop(embed_window1);
|
| + EXPECT_EQ(mojom::Cursor::IBEAM, cursor_id());
|
| +}
|
| +
|
| +// Assertions around moving cursor between trees with roots.
|
| +TEST_F(WindowTreeTest, CursorMultipleTrees) {
|
| + // Setup two trees parented to the root with the same bounds.
|
| + ServerWindow* embed_window1 =
|
| + window_event_targeting_helper_.CreatePrimaryTree(
|
| + gfx::Rect(0, 0, 200, 200), gfx::Rect(0, 0, 10, 10));
|
| + ServerWindow* embed_window2 =
|
| + window_event_targeting_helper_.CreatePrimaryTree(
|
| + gfx::Rect(0, 0, 200, 200), gfx::Rect(20, 20, 20, 20));
|
| + embed_window1->set_event_targeting_policy(
|
| + mojom::EventTargetingPolicy::TARGET_AND_DESCENDANTS);
|
| + embed_window2->set_event_targeting_policy(
|
| + mojom::EventTargetingPolicy::TARGET_AND_DESCENDANTS);
|
| + embed_window2->parent()->set_event_targeting_policy(
|
| + mojom::EventTargetingPolicy::TARGET_AND_DESCENDANTS);
|
| + embed_window1->SetPredefinedCursor(mojom::Cursor::IBEAM);
|
| + embed_window2->SetPredefinedCursor(mojom::Cursor::CROSS);
|
| + embed_window1->parent()->SetPredefinedCursor(mojom::Cursor::COPY);
|
| +
|
| + // Create a child of |embed_window1|.
|
| + ServerWindow* embed_window1_child = NewWindowInTreeWithParent(
|
| + window_server()->GetTreeWithRoot(embed_window1), embed_window1);
|
| + ASSERT_TRUE(embed_window1_child);
|
| + embed_window1_child->SetBounds(gfx::Rect(0, 0, 10, 10));
|
| + embed_window1_child->SetVisible(true);
|
| +
|
| + // Move mouse into |embed_window1|.
|
| + DispatchEventAndAckImmediately(CreateMouseMoveEvent(5, 5));
|
| EXPECT_EQ(mojom::Cursor::IBEAM, cursor_id());
|
| +
|
| + // Move mouse into |embed_window2|.
|
| + DispatchEventAndAckImmediately(CreateMouseMoveEvent(25, 25));
|
| + EXPECT_EQ(mojom::Cursor::CROSS, cursor_id());
|
| +
|
| + // Move mouse into area between, which should use cursor set on parent.
|
| + DispatchEventAndAckImmediately(CreateMouseMoveEvent(15, 15));
|
| + EXPECT_EQ(mojom::Cursor::COPY, cursor_id());
|
| }
|
|
|
| TEST_F(WindowTreeTest, EventAck) {
|
|
|