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

Side by Side Diff: ui/aura/mus/window_tree_client_unittest.cc

Issue 2696873002: Change OnWindowInputEvent to use display_id to find the host and update event root_location in WS. (Closed)
Patch Set: helper function Created 3 years, 10 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 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 "ui/aura/mus/window_tree_client.h" 5 #include "ui/aura/mus/window_tree_client.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "mojo/public/cpp/bindings/map.h" 14 #include "mojo/public/cpp/bindings/map.h"
15 #include "services/ui/public/cpp/property_type_converters.h" 15 #include "services/ui/public/cpp/property_type_converters.h"
16 #include "services/ui/public/interfaces/window_manager.mojom.h" 16 #include "services/ui/public/interfaces/window_manager.mojom.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 #include "ui/aura/client/aura_constants.h" 18 #include "ui/aura/client/aura_constants.h"
19 #include "ui/aura/client/capture_client.h" 19 #include "ui/aura/client/capture_client.h"
20 #include "ui/aura/client/capture_client_observer.h" 20 #include "ui/aura/client/capture_client_observer.h"
21 #include "ui/aura/client/default_capture_client.h" 21 #include "ui/aura/client/default_capture_client.h"
22 #include "ui/aura/client/focus_client.h" 22 #include "ui/aura/client/focus_client.h"
23 #include "ui/aura/client/transient_window_client.h" 23 #include "ui/aura/client/transient_window_client.h"
24 #include "ui/aura/mus/capture_synchronizer.h" 24 #include "ui/aura/mus/capture_synchronizer.h"
25 #include "ui/aura/mus/mus_types.h"
25 #include "ui/aura/mus/property_converter.h" 26 #include "ui/aura/mus/property_converter.h"
26 #include "ui/aura/mus/window_mus.h" 27 #include "ui/aura/mus/window_mus.h"
27 #include "ui/aura/mus/window_tree_client_delegate.h" 28 #include "ui/aura/mus/window_tree_client_delegate.h"
28 #include "ui/aura/mus/window_tree_client_observer.h" 29 #include "ui/aura/mus/window_tree_client_observer.h"
29 #include "ui/aura/mus/window_tree_host_mus.h" 30 #include "ui/aura/mus/window_tree_host_mus.h"
30 #include "ui/aura/test/aura_mus_test_base.h" 31 #include "ui/aura/test/aura_mus_test_base.h"
31 #include "ui/aura/test/mus/test_window_tree.h" 32 #include "ui/aura/test/mus/test_window_tree.h"
32 #include "ui/aura/test/mus/window_tree_client_private.h" 33 #include "ui/aura/test/mus/window_tree_client_private.h"
33 #include "ui/aura/test/test_window_delegate.h" 34 #include "ui/aura/test/test_window_delegate.h"
34 #include "ui/aura/window.h" 35 #include "ui/aura/window.h"
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 EXPECT_TRUE(window_tree()->WasEventAcked( 551 EXPECT_TRUE(window_tree()->WasEventAcked(
551 InputEventBasicTestWindowDelegate::kEventId)); 552 InputEventBasicTestWindowDelegate::kEventId));
552 EXPECT_EQ(ui::mojom::EventResult::HANDLED, 553 EXPECT_EQ(ui::mojom::EventResult::HANDLED,
553 window_tree()->GetEventResult( 554 window_tree()->GetEventResult(
554 InputEventBasicTestWindowDelegate::kEventId)); 555 InputEventBasicTestWindowDelegate::kEventId));
555 EXPECT_TRUE(window_delegate.got_move()); 556 EXPECT_TRUE(window_delegate.got_move());
556 EXPECT_FALSE(window_delegate.was_acked()); 557 EXPECT_FALSE(window_delegate.was_acked());
557 EXPECT_EQ(event_location_in_child, window_delegate.last_event_location()); 558 EXPECT_EQ(event_location_in_child, window_delegate.last_event_location());
558 } 559 }
559 560
561 TEST_F(WindowTreeClientClientTest, InputEventNoWindow) {
562 InputEventBasicTestWindowDelegate window_delegate(window_tree());
563 WindowTreeHostMus window_tree_host(window_tree_client_impl());
564 Window* top_level = window_tree_host.window();
565 const gfx::Rect bounds(0, 0, 100, 100);
566 window_tree_host.SetBoundsInPixels(bounds);
567 window_tree_host.InitHost();
568 window_tree_host.Show();
569 EXPECT_EQ(bounds, top_level->bounds());
570 EXPECT_EQ(bounds, window_tree_host.GetBoundsInPixels());
571 Window child(&window_delegate);
572 child.Init(ui::LAYER_NOT_DRAWN);
573 top_level->AddChild(&child);
574 child.SetBounds(gfx::Rect(10, 10, 100, 100));
575 child.Show();
576 EXPECT_FALSE(window_delegate.got_move());
577 EXPECT_FALSE(window_delegate.was_acked());
578 const gfx::Point event_location_in_child(20, 30);
579 std::unique_ptr<ui::Event> ui_event(
580 new ui::MouseEvent(ui::ET_MOUSE_MOVED, event_location_in_child,
581 gfx::Point(), ui::EventTimeForNow(), ui::EF_NONE, 0));
582 window_tree_client()->OnWindowInputEvent(
583 InputEventBasicTestWindowDelegate::kEventId, kInvalidServerId,
584 window_tree_host.display_id(), ui::Event::Clone(*ui_event.get()), 0);
585 // WindowTreeClient::OnWindowInputEvent cannot find a target window with
586 // kInvalidServerId but should fall back to use the display_id to find the
587 // window_tree_host for event dispatching. child should still get the event.
588 EXPECT_TRUE(window_tree()->WasEventAcked(
589 InputEventBasicTestWindowDelegate::kEventId));
590 EXPECT_EQ(ui::mojom::EventResult::HANDLED,
591 window_tree()->GetEventResult(
592 InputEventBasicTestWindowDelegate::kEventId));
593 EXPECT_TRUE(window_delegate.got_move());
594 EXPECT_FALSE(window_delegate.was_acked());
595 EXPECT_EQ(gfx::Point(10, 20), window_delegate.last_event_location());
596 }
597
560 class WindowTreeClientPointerObserverTest : public WindowTreeClientClientTest { 598 class WindowTreeClientPointerObserverTest : public WindowTreeClientClientTest {
561 public: 599 public:
562 WindowTreeClientPointerObserverTest() {} 600 WindowTreeClientPointerObserverTest() {}
563 ~WindowTreeClientPointerObserverTest() override {} 601 ~WindowTreeClientPointerObserverTest() override {}
564 602
565 void DeleteLastEventObserved() { last_event_observed_.reset(); } 603 void DeleteLastEventObserved() { last_event_observed_.reset(); }
566 const ui::PointerEvent* last_event_observed() const { 604 const ui::PointerEvent* last_event_observed() const {
567 return last_event_observed_.get(); 605 return last_event_observed_.get();
568 } 606 }
569 607
(...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after
1616 // Delegate received the event in Dips. 1654 // Delegate received the event in Dips.
1617 const ui::PointerEvent* last_event = last_event_observed(); 1655 const ui::PointerEvent* last_event = last_event_observed();
1618 ASSERT_TRUE(last_event); 1656 ASSERT_TRUE(last_event);
1619 EXPECT_EQ(gfx::ConvertPointToDIP(2.0f, location_pixels), 1657 EXPECT_EQ(gfx::ConvertPointToDIP(2.0f, location_pixels),
1620 last_event->location()); 1658 last_event->location());
1621 EXPECT_EQ(gfx::ConvertPointToDIP(2.0f, root_location_pixels), 1659 EXPECT_EQ(gfx::ConvertPointToDIP(2.0f, root_location_pixels),
1622 last_event->root_location()); 1660 last_event->root_location());
1623 } 1661 }
1624 1662
1625 } // namespace aura 1663 } // namespace aura
OLDNEW
« ui/aura/mus/window_tree_client.cc ('K') | « ui/aura/mus/window_tree_client.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698