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

Side by Side Diff: components/mus/ws/cursor_unittest.cc

Issue 2089023002: Promotes remaining global window manager state into WindowManagerState (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: override Created 4 years, 5 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 | « components/mus/ws/BUILD.gn ('k') | components/mus/ws/display.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "components/mus/common/types.h" 11 #include "components/mus/common/types.h"
12 #include "components/mus/common/util.h" 12 #include "components/mus/common/util.h"
13 #include "components/mus/public/interfaces/window_tree.mojom.h" 13 #include "components/mus/public/interfaces/window_tree.mojom.h"
14 #include "components/mus/surfaces/surfaces_state.h" 14 #include "components/mus/surfaces/surfaces_state.h"
15 #include "components/mus/ws/display_manager.h" 15 #include "components/mus/ws/display_manager.h"
16 #include "components/mus/ws/ids.h" 16 #include "components/mus/ws/ids.h"
17 #include "components/mus/ws/platform_display.h" 17 #include "components/mus/ws/platform_display.h"
18 #include "components/mus/ws/platform_display_factory.h" 18 #include "components/mus/ws/platform_display_factory.h"
19 #include "components/mus/ws/server_window.h" 19 #include "components/mus/ws/server_window.h"
20 #include "components/mus/ws/server_window_surface_manager_test_api.h" 20 #include "components/mus/ws/server_window_surface_manager_test_api.h"
21 #include "components/mus/ws/test_utils.h" 21 #include "components/mus/ws/test_utils.h"
22 #include "components/mus/ws/window_manager_display_root.h"
22 #include "components/mus/ws/window_manager_state.h" 23 #include "components/mus/ws/window_manager_state.h"
23 #include "components/mus/ws/window_server.h" 24 #include "components/mus/ws/window_server.h"
24 #include "components/mus/ws/window_server_delegate.h" 25 #include "components/mus/ws/window_server_delegate.h"
25 #include "components/mus/ws/window_tree.h" 26 #include "components/mus/ws/window_tree.h"
26 #include "components/mus/ws/window_tree_binding.h" 27 #include "components/mus/ws/window_tree_binding.h"
27 #include "testing/gtest/include/gtest/gtest.h" 28 #include "testing/gtest/include/gtest/gtest.h"
28 #include "ui/events/event.h" 29 #include "ui/events/event.h"
29 #include "ui/gfx/geometry/rect.h" 30 #include "ui/gfx/geometry/rect.h"
30 31
31 namespace mus { 32 namespace mus {
(...skipping 22 matching lines...) Expand all
54 WindowManagerWindowTreeFactorySetTestApi( 55 WindowManagerWindowTreeFactorySetTestApi(
55 window_server_->window_manager_window_tree_factory_set()) 56 window_server_->window_manager_window_tree_factory_set())
56 .Add(kTestId1); 57 .Add(kTestId1);
57 window_server_->user_id_tracker()->SetActiveUserId(kTestId1); 58 window_server_->user_id_tracker()->SetActiveUserId(kTestId1);
58 } 59 }
59 60
60 ServerWindow* GetRoot() { 61 ServerWindow* GetRoot() {
61 DisplayManager* display_manager = window_server_->display_manager(); 62 DisplayManager* display_manager = window_server_->display_manager();
62 // ASSERT_EQ(1u, display_manager->displays().size()); 63 // ASSERT_EQ(1u, display_manager->displays().size());
63 Display* display = *display_manager->displays().begin(); 64 Display* display = *display_manager->displays().begin();
64 WindowManagerState* state = display->GetWindowManagerStateForUser(kTestId1); 65 return display->GetWindowManagerDisplayRootForUser(kTestId1)->root();
65 return state->root();
66 } 66 }
67 67
68 // Create a 30x30 window where the outer 10 pixels is non-client. 68 // Create a 30x30 window where the outer 10 pixels is non-client.
69 ServerWindow* BuildServerWindow() { 69 ServerWindow* BuildServerWindow() {
70 DisplayManager* display_manager = window_server_->display_manager(); 70 DisplayManager* display_manager = window_server_->display_manager();
71 Display* display = *display_manager->displays().begin(); 71 Display* display = *display_manager->displays().begin();
72 WindowManagerState* active_wms = display->GetActiveWindowManagerState(); 72 WindowManagerDisplayRoot* active_display_root =
73 WindowTree* tree = active_wms->tree(); 73 display->GetActiveWindowManagerDisplayRoot();
74 WindowTree* tree =
75 active_display_root->window_manager_state()->window_tree();
74 ClientWindowId child_window_id; 76 ClientWindowId child_window_id;
75 if (!NewWindowInTree(tree, &child_window_id)) 77 if (!NewWindowInTree(tree, &child_window_id))
76 return nullptr; 78 return nullptr;
77 79
78 ServerWindow* w = tree->GetWindowByClientId(child_window_id); 80 ServerWindow* w = tree->GetWindowByClientId(child_window_id);
79 w->SetBounds(gfx::Rect(10, 10, 30, 30)); 81 w->SetBounds(gfx::Rect(10, 10, 30, 30));
80 w->SetClientArea(gfx::Insets(10, 10), std::vector<gfx::Rect>()); 82 w->SetClientArea(gfx::Insets(10, 10), std::vector<gfx::Rect>());
81 w->SetVisible(true); 83 w->SetVisible(true);
82 84
83 ServerWindowSurfaceManagerTestApi test_api(w->GetOrCreateSurfaceManager()); 85 ServerWindowSurfaceManagerTestApi test_api(w->GetOrCreateSurfaceManager());
84 test_api.CreateEmptyDefaultSurface(); 86 test_api.CreateEmptyDefaultSurface();
85 87
86 return w; 88 return w;
87 } 89 }
88 90
89 void MoveCursorTo(const gfx::Point& p) { 91 void MoveCursorTo(const gfx::Point& p) {
90 DisplayManager* display_manager = window_server_->display_manager(); 92 DisplayManager* display_manager = window_server_->display_manager();
91 ASSERT_EQ(1u, display_manager->displays().size()); 93 ASSERT_EQ(1u, display_manager->displays().size());
92 Display* display = *display_manager->displays().begin(); 94 Display* display = *display_manager->displays().begin();
93 WindowManagerState* active_wms = display->GetActiveWindowManagerState(); 95 WindowManagerDisplayRoot* active_display_root =
94 ASSERT_TRUE(active_wms); 96 display->GetActiveWindowManagerDisplayRoot();
97 ASSERT_TRUE(active_display_root);
95 static_cast<PlatformDisplayDelegate*>(display)->OnEvent(ui::PointerEvent( 98 static_cast<PlatformDisplayDelegate*>(display)->OnEvent(ui::PointerEvent(
96 ui::MouseEvent(ui::ET_MOUSE_MOVED, p, p, base::TimeTicks(), 0, 0))); 99 ui::MouseEvent(ui::ET_MOUSE_MOVED, p, p, base::TimeTicks(), 0, 0)));
97 active_wms->OnEventAck(active_wms->tree(), mojom::EventResult::HANDLED); 100 WindowManagerState* wms = active_display_root->window_manager_state();
101 wms->OnEventAck(wms->window_tree(), mojom::EventResult::HANDLED);
98 } 102 }
99 103
100 protected: 104 protected:
101 int32_t cursor_id_; 105 int32_t cursor_id_;
102 TestPlatformDisplayFactory platform_display_factory_; 106 TestPlatformDisplayFactory platform_display_factory_;
103 TestWindowServerDelegate window_server_delegate_; 107 TestWindowServerDelegate window_server_delegate_;
104 std::unique_ptr<WindowServer> window_server_; 108 std::unique_ptr<WindowServer> window_server_;
105 base::MessageLoop message_loop_; 109 base::MessageLoop message_loop_;
106 110
107 private: 111 private:
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 MoveCursorTo(gfx::Point(15, 15)); 188 MoveCursorTo(gfx::Point(15, 15));
185 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, mojom::Cursor(cursor_id_)); 189 EXPECT_EQ(mojom::Cursor::EAST_RESIZE, mojom::Cursor(cursor_id_));
186 190
187 win->SetBounds(gfx::Rect(0, 0, 30, 30)); 191 win->SetBounds(gfx::Rect(0, 0, 30, 30));
188 EXPECT_EQ(mojom::Cursor::IBEAM, mojom::Cursor(cursor_id_)); 192 EXPECT_EQ(mojom::Cursor::IBEAM, mojom::Cursor(cursor_id_));
189 } 193 }
190 194
191 } // namespace test 195 } // namespace test
192 } // namespace ws 196 } // namespace ws
193 } // namespace mus 197 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/ws/BUILD.gn ('k') | components/mus/ws/display.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698