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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/mus/window_manager_connection_unittest.cc
diff --git a/ui/views/mus/window_manager_connection_unittest.cc b/ui/views/mus/window_manager_connection_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..40e2858e014b8eb8e3cea77bbd878e4da87171ef
--- /dev/null
+++ b/ui/views/mus/window_manager_connection_unittest.cc
@@ -0,0 +1,113 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/views/mus/window_manager_connection.h"
+
+#include "base/message_loop/message_loop.h"
+#include "services/ui/public/cpp/window.h"
+#include "services/ui/public/cpp/window_private.h"
+#include "services/ui/public/cpp/window_tree_client.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/views/mus/screen_mus.h"
+#include "ui/views/mus/test_utils.h"
+#include "ui/views/test/scoped_views_test_helper.h"
+
+namespace views {
+namespace {
+
+class WindowManagerConnectionTest : public testing::Test {
+ public:
+ WindowManagerConnectionTest() : message_loop_(base::MessageLoop::TYPE_UI) {}
+ ~WindowManagerConnectionTest() override {}
+
+ WindowManagerConnection* connection() {
+ return WindowManagerConnection::Get();
+ }
+
+ ScreenMusDelegate* screen_mus_delegate() { return connection(); }
+
+ private:
+ base::MessageLoop message_loop_;
+ ScopedViewsTestHelper helper_;
+
+ DISALLOW_COPY_AND_ASSIGN(WindowManagerConnectionTest);
+};
+
+TEST_F(WindowManagerConnectionTest, GetWindowAtScreenPointRecurse) {
+ ui::Window* one = connection()->client()->NewTopLevelWindow(nullptr);
+ one->SetBounds(gfx::Rect(0, 0, 100, 100));
+ one->SetVisible(true);
+
+ std::vector<display::Display> displays =
+ display::Screen::GetScreen()->GetAllDisplays();
+ ASSERT_GE(displays.size(), 1u);
+ ui::WindowPrivate(one).LocalSetDisplay(displays[0].id());
+
+ ui::Window* two = connection()->client()->NewWindow();
+ one->AddChild(two);
+ two->SetBounds(gfx::Rect(10, 10, 80, 80));
+ two->SetVisible(true);
+
+ // Ensure that we recurse down to the second window.
+ EXPECT_EQ(two,
+ screen_mus_delegate()->GetWindowAtScreenPoint(gfx::Point(50, 50)));
+}
+
+TEST_F(WindowManagerConnectionTest, GetWindowAtScreenPointRecurseButIgnore) {
+ ui::Window* one = connection()->client()->NewTopLevelWindow(nullptr);
+ one->SetBounds(gfx::Rect(0, 0, 100, 100));
+ one->SetVisible(true);
+
+ std::vector<display::Display> displays =
+ display::Screen::GetScreen()->GetAllDisplays();
+ ASSERT_GE(displays.size(), 1u);
+ ui::WindowPrivate(one).LocalSetDisplay(displays[0].id());
+
+ ui::Window* two = connection()->client()->NewWindow();
+ one->AddChild(two);
+ two->SetBounds(gfx::Rect(5, 5, 10, 10));
+ two->SetVisible(true);
+
+ // We'll recurse down, but we'll use the parent anyway because the children
+ // don't match the bounds.
+ EXPECT_EQ(one,
+ screen_mus_delegate()->GetWindowAtScreenPoint(gfx::Point(50, 50)));
+}
+
+TEST_F(WindowManagerConnectionTest, GetWindowAtScreenPointDisplayOffset) {
+ ui::Window* one = connection()->client()->NewTopLevelWindow(nullptr);
+ one->SetBounds(gfx::Rect(5, 5, 5, 5));
+ one->SetVisible(true);
+
+ std::vector<display::Display> displays =
+ display::Screen::GetScreen()->GetAllDisplays();
+ ASSERT_GE(displays.size(), 1u);
+ ui::WindowPrivate(one).LocalSetDisplay(displays[0].id());
+
+ // Make the first display offset by 50.
+ test::WindowManagerConnectionTestApi api(connection());
+ api.screen()->display_list()->FindDisplayById(displays[0].id())->
+ set_bounds(gfx::Rect(44, 44, 50, 50));
+
+ EXPECT_EQ(one,
+ screen_mus_delegate()->GetWindowAtScreenPoint(gfx::Point(50, 50)));
+}
+
+TEST_F(WindowManagerConnectionTest, IgnoresHiddenWindows) {
+ // Hide the one window.
+ ui::Window* one = connection()->client()->NewTopLevelWindow(nullptr);
+ one->SetBounds(gfx::Rect(0, 0, 100, 100));
+ one->SetVisible(false);
+
+ std::vector<display::Display> displays =
+ display::Screen::GetScreen()->GetAllDisplays();
+ ASSERT_GE(displays.size(), 1u);
+ ui::WindowPrivate(one).LocalSetDisplay(displays[0].id());
+
+ EXPECT_EQ(nullptr,
+ screen_mus_delegate()->GetWindowAtScreenPoint(gfx::Point(50, 50)));
+}
+
+} // namespace
+} // namespace views
« 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