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

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

Issue 2611773002: Removes code using mus client lib (Closed)
Patch Set: dont run on linux Created 3 years, 11 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/mus/window_tree_host_mus.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 ui::Window* GetWindowAtScreenPoint(const gfx::Point& point) {
31 return test::WindowManagerConnectionTestApi(connection())
32 .GetUiWindowAtScreenPoint(point);
33 }
34
35 private:
36 base::MessageLoop message_loop_;
37 ScopedViewsTestHelper helper_;
38
39 DISALLOW_COPY_AND_ASSIGN(WindowManagerConnectionTest);
40 };
41
42 TEST_F(WindowManagerConnectionTest, GetWindowAtScreenPointRecurse) {
43 ui::Window* one = connection()->client()->NewTopLevelWindow(nullptr);
44 one->SetBounds(gfx::Rect(0, 0, 100, 100));
45 one->SetVisible(true);
46
47 std::vector<display::Display> displays =
48 display::Screen::GetScreen()->GetAllDisplays();
49 ASSERT_GE(displays.size(), 1u);
50 ui::WindowPrivate(one).LocalSetDisplay(displays[0].id());
51
52 ui::Window* two = connection()->client()->NewWindow();
53 one->AddChild(two);
54 two->SetBounds(gfx::Rect(10, 10, 80, 80));
55 two->SetVisible(true);
56
57 // Ensure that we recurse down to the second window.
58 EXPECT_EQ(two, GetWindowAtScreenPoint(gfx::Point(50, 50)));
59 }
60
61 TEST_F(WindowManagerConnectionTest, GetWindowAtScreenPointRecurseButIgnore) {
62 ui::Window* one = connection()->client()->NewTopLevelWindow(nullptr);
63 one->SetBounds(gfx::Rect(0, 0, 100, 100));
64 one->SetVisible(true);
65
66 std::vector<display::Display> displays =
67 display::Screen::GetScreen()->GetAllDisplays();
68 ASSERT_GE(displays.size(), 1u);
69 ui::WindowPrivate(one).LocalSetDisplay(displays[0].id());
70
71 ui::Window* two = connection()->client()->NewWindow();
72 one->AddChild(two);
73 two->SetBounds(gfx::Rect(5, 5, 10, 10));
74 two->SetVisible(true);
75
76 // We'll recurse down, but we'll use the parent anyway because the children
77 // don't match the bounds.
78 EXPECT_EQ(one, GetWindowAtScreenPoint(gfx::Point(50, 50)));
79 }
80
81 TEST_F(WindowManagerConnectionTest, GetWindowAtScreenPointDisplayOffset) {
82 ui::Window* one = connection()->client()->NewTopLevelWindow(nullptr);
83 one->SetBounds(gfx::Rect(5, 5, 5, 5));
84 one->SetVisible(true);
85
86 std::vector<display::Display> displays =
87 display::Screen::GetScreen()->GetAllDisplays();
88 ASSERT_GE(displays.size(), 1u);
89 ui::WindowPrivate(one).LocalSetDisplay(displays[0].id());
90
91 // Make the first display offset by 50.
92 test::WindowManagerConnectionTestApi api(connection());
93 display::Display display(
94 *api.screen()->display_list().FindDisplayById(displays[0].id()));
95 display.set_bounds(gfx::Rect(44, 44, 50, 50));
96 api.screen()->display_list().UpdateDisplay(display);
97
98 EXPECT_EQ(one, GetWindowAtScreenPoint(gfx::Point(50, 50)));
99 }
100
101 TEST_F(WindowManagerConnectionTest, IgnoresHiddenWindows) {
102 // Hide the one window.
103 ui::Window* one = connection()->client()->NewTopLevelWindow(nullptr);
104 one->SetBounds(gfx::Rect(0, 0, 100, 100));
105 one->SetVisible(false);
106
107 std::vector<display::Display> displays =
108 display::Screen::GetScreen()->GetAllDisplays();
109 ASSERT_GE(displays.size(), 1u);
110 ui::WindowPrivate(one).LocalSetDisplay(displays[0].id());
111
112 EXPECT_EQ(nullptr, GetWindowAtScreenPoint(gfx::Point(50, 50)));
113 }
114
115 } // namespace
116 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/mus/window_manager_connection.cc ('k') | ui/views/mus/window_tree_host_mus.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698