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

Side by Side Diff: ui/views/mus/window_manager_connection_unittest.cc

Issue 2392063003: mus: Use TooltipManagerAura in NativeWidgetMus. (Closed)
Patch Set: Add comment Created 4 years, 2 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
« no previous file with comments | « ui/views/mus/window_manager_connection.cc ('k') | ui/views/widget/tooltip_manager_aura.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ui/views/mus/window_manager_connection.h"
6
7 #include "base/message_loop/message_loop.h"
8 #include "services/ui/public/cpp/window.h"
9 #include "services/ui/public/cpp/window_private.h"
10 #include "services/ui/public/cpp/window_tree_client.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "ui/views/mus/screen_mus.h"
13 #include "ui/views/mus/test_utils.h"
14 #include "ui/views/test/scoped_views_test_helper.h"
15
16 namespace views {
17 namespace {
18
19 class WindowManagerConnectionTest : public testing::Test {
20 public:
21 WindowManagerConnectionTest() : message_loop_(base::MessageLoop::TYPE_UI) {}
22 ~WindowManagerConnectionTest() override {}
23
24 WindowManagerConnection* connection() {
25 return WindowManagerConnection::Get();
26 }
27
28 ScreenMusDelegate* screen_mus_delegate() { return connection(); }
29
30 private:
31 base::MessageLoop message_loop_;
32 ScopedViewsTestHelper helper_;
33
34 DISALLOW_COPY_AND_ASSIGN(WindowManagerConnectionTest);
35 };
36
37 TEST_F(WindowManagerConnectionTest, GetWindowAtScreenPointRecurse) {
38 ui::Window* one = connection()->client()->NewTopLevelWindow(nullptr);
39 one->SetBounds(gfx::Rect(0, 0, 100, 100));
40 one->SetVisible(true);
41
42 std::vector<display::Display> displays =
43 display::Screen::GetScreen()->GetAllDisplays();
44 ASSERT_GE(displays.size(), 1u);
45 ui::WindowPrivate(one).LocalSetDisplay(displays[0].id());
46
47 ui::Window* two = connection()->client()->NewWindow();
48 one->AddChild(two);
49 two->SetBounds(gfx::Rect(10, 10, 80, 80));
50 two->SetVisible(true);
51
52 // Ensure that we recurse down to the second window.
53 EXPECT_EQ(two,
54 screen_mus_delegate()->GetWindowAtScreenPoint(gfx::Point(50, 50)));
55 }
56
57 TEST_F(WindowManagerConnectionTest, GetWindowAtScreenPointRecurseButIgnore) {
58 ui::Window* one = connection()->client()->NewTopLevelWindow(nullptr);
59 one->SetBounds(gfx::Rect(0, 0, 100, 100));
60 one->SetVisible(true);
61
62 std::vector<display::Display> displays =
63 display::Screen::GetScreen()->GetAllDisplays();
64 ASSERT_GE(displays.size(), 1u);
65 ui::WindowPrivate(one).LocalSetDisplay(displays[0].id());
66
67 ui::Window* two = connection()->client()->NewWindow();
68 one->AddChild(two);
69 two->SetBounds(gfx::Rect(5, 5, 10, 10));
70 two->SetVisible(true);
71
72 // We'll recurse down, but we'll use the parent anyway because the children
73 // don't match the bounds.
74 EXPECT_EQ(one,
75 screen_mus_delegate()->GetWindowAtScreenPoint(gfx::Point(50, 50)));
76 }
77
78 TEST_F(WindowManagerConnectionTest, GetWindowAtScreenPointDisplayOffset) {
79 ui::Window* one = connection()->client()->NewTopLevelWindow(nullptr);
80 one->SetBounds(gfx::Rect(5, 5, 5, 5));
81 one->SetVisible(true);
82
83 std::vector<display::Display> displays =
84 display::Screen::GetScreen()->GetAllDisplays();
85 ASSERT_GE(displays.size(), 1u);
86 ui::WindowPrivate(one).LocalSetDisplay(displays[0].id());
87
88 // Make the first display offset by 50.
89 test::WindowManagerConnectionTestApi api(connection());
90 api.screen()->display_list()->FindDisplayById(displays[0].id())->
91 set_bounds(gfx::Rect(44, 44, 50, 50));
92
93 EXPECT_EQ(one,
94 screen_mus_delegate()->GetWindowAtScreenPoint(gfx::Point(50, 50)));
95 }
96
97 TEST_F(WindowManagerConnectionTest, IgnoresHiddenWindows) {
98 // Hide the one window.
99 ui::Window* one = connection()->client()->NewTopLevelWindow(nullptr);
100 one->SetBounds(gfx::Rect(0, 0, 100, 100));
101 one->SetVisible(false);
102
103 std::vector<display::Display> displays =
104 display::Screen::GetScreen()->GetAllDisplays();
105 ASSERT_GE(displays.size(), 1u);
106 ui::WindowPrivate(one).LocalSetDisplay(displays[0].id());
107
108 EXPECT_EQ(nullptr,
109 screen_mus_delegate()->GetWindowAtScreenPoint(gfx::Point(50, 50)));
110 }
111
112 } // namespace
113 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/mus/window_manager_connection.cc ('k') | ui/views/widget/tooltip_manager_aura.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698