| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/mus/ws/window_tree.h" |
| 6 |
| 5 #include <stdint.h> | 7 #include <stdint.h> |
| 6 | 8 |
| 7 #include <string> | 9 #include <string> |
| 8 #include <vector> | 10 #include <vector> |
| 9 | 11 |
| 10 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ptr_util.h" |
| 11 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 12 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
| 13 #include "components/mus/common/types.h" | 16 #include "components/mus/common/types.h" |
| 14 #include "components/mus/common/util.h" | 17 #include "components/mus/common/util.h" |
| 15 #include "components/mus/public/interfaces/window_tree.mojom.h" | 18 #include "components/mus/public/interfaces/window_tree.mojom.h" |
| 16 #include "components/mus/surfaces/surfaces_state.h" | 19 #include "components/mus/surfaces/surfaces_state.h" |
| 17 #include "components/mus/ws/default_access_policy.h" | 20 #include "components/mus/ws/default_access_policy.h" |
| 18 #include "components/mus/ws/display_binding.h" | 21 #include "components/mus/ws/display_binding.h" |
| 19 #include "components/mus/ws/ids.h" | 22 #include "components/mus/ws/ids.h" |
| 20 #include "components/mus/ws/platform_display.h" | 23 #include "components/mus/ws/platform_display.h" |
| 21 #include "components/mus/ws/platform_display_factory.h" | 24 #include "components/mus/ws/platform_display_factory.h" |
| 22 #include "components/mus/ws/platform_display_init_params.h" | 25 #include "components/mus/ws/platform_display_init_params.h" |
| 23 #include "components/mus/ws/server_window.h" | 26 #include "components/mus/ws/server_window.h" |
| 24 #include "components/mus/ws/server_window_surface_manager_test_api.h" | 27 #include "components/mus/ws/server_window_surface_manager_test_api.h" |
| 25 #include "components/mus/ws/test_change_tracker.h" | 28 #include "components/mus/ws/test_change_tracker.h" |
| 26 #include "components/mus/ws/test_server_window_delegate.h" | 29 #include "components/mus/ws/test_server_window_delegate.h" |
| 27 #include "components/mus/ws/test_utils.h" | 30 #include "components/mus/ws/test_utils.h" |
| 28 #include "components/mus/ws/window_manager_access_policy.h" | 31 #include "components/mus/ws/window_manager_access_policy.h" |
| 29 #include "components/mus/ws/window_server.h" | 32 #include "components/mus/ws/window_server.h" |
| 30 #include "components/mus/ws/window_server_delegate.h" | 33 #include "components/mus/ws/window_server_delegate.h" |
| 31 #include "components/mus/ws/window_tree.h" | |
| 32 #include "components/mus/ws/window_tree_binding.h" | 34 #include "components/mus/ws/window_tree_binding.h" |
| 33 #include "mojo/converters/geometry/geometry_type_converters.h" | 35 #include "mojo/converters/geometry/geometry_type_converters.h" |
| 34 #include "services/shell/public/interfaces/connector.mojom.h" | 36 #include "services/shell/public/interfaces/connector.mojom.h" |
| 35 #include "testing/gtest/include/gtest/gtest.h" | 37 #include "testing/gtest/include/gtest/gtest.h" |
| 36 #include "ui/events/event.h" | 38 #include "ui/events/event.h" |
| 37 #include "ui/events/event_utils.h" | 39 #include "ui/events/event_utils.h" |
| 38 #include "ui/gfx/geometry/rect.h" | 40 #include "ui/gfx/geometry/rect.h" |
| 39 | 41 |
| 40 namespace mus { | 42 namespace mus { |
| 41 namespace ws { | 43 namespace ws { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 // Creates a new window from wm_tree() and embeds a new connection in | 143 // Creates a new window from wm_tree() and embeds a new connection in |
| 142 // it. | 144 // it. |
| 143 void SetupEventTargeting(TestWindowTreeClient** out_client, | 145 void SetupEventTargeting(TestWindowTreeClient** out_client, |
| 144 WindowTree** window_tree, | 146 WindowTree** window_tree, |
| 145 ServerWindow** window); | 147 ServerWindow** window); |
| 146 | 148 |
| 147 // Creates a new tree as the specified user. This does what creation via | 149 // Creates a new tree as the specified user. This does what creation via |
| 148 // a WindowTreeFactory does. | 150 // a WindowTreeFactory does. |
| 149 WindowTree* CreateNewTree(const UserId& user_id, | 151 WindowTree* CreateNewTree(const UserId& user_id, |
| 150 TestWindowTreeBinding** binding) { | 152 TestWindowTreeBinding** binding) { |
| 151 WindowTree* tree = new WindowTree(window_server_.get(), user_id, nullptr, | 153 WindowTree* tree = |
| 152 make_scoped_ptr(new DefaultAccessPolicy)); | 154 new WindowTree(window_server_.get(), user_id, nullptr, |
| 155 base::WrapUnique(new DefaultAccessPolicy)); |
| 153 *binding = new TestWindowTreeBinding(tree); | 156 *binding = new TestWindowTreeBinding(tree); |
| 154 window_server_->AddTree(make_scoped_ptr(tree), make_scoped_ptr(*binding), | 157 window_server_->AddTree(base::WrapUnique(tree), base::WrapUnique(*binding), |
| 155 nullptr); | 158 nullptr); |
| 156 return tree; | 159 return tree; |
| 157 } | 160 } |
| 158 | 161 |
| 159 protected: | 162 protected: |
| 160 // testing::Test: | 163 // testing::Test: |
| 161 void SetUp() override { | 164 void SetUp() override { |
| 162 PlatformDisplay::set_factory_for_testing(&platform_display_factory_); | 165 PlatformDisplay::set_factory_for_testing(&platform_display_factory_); |
| 163 window_server_.reset(new WindowServer(&delegate_, surfaces_state_)); | 166 window_server_.reset(new WindowServer(&delegate_, surfaces_state_)); |
| 164 PlatformDisplayInitParams display_init_params; | 167 PlatformDisplayInitParams display_init_params; |
| 165 display_init_params.surfaces_state = surfaces_state_; | 168 display_init_params.surfaces_state = surfaces_state_; |
| 166 display_ = new Display(window_server_.get(), display_init_params); | 169 display_ = new Display(window_server_.get(), display_init_params); |
| 167 display_binding_ = new TestDisplayBinding(display_, window_server_.get()); | 170 display_binding_ = new TestDisplayBinding(display_, window_server_.get()); |
| 168 display_->Init(make_scoped_ptr(display_binding_)); | 171 display_->Init(base::WrapUnique(display_binding_)); |
| 169 wm_client_ = delegate_.last_client(); | 172 wm_client_ = delegate_.last_client(); |
| 170 } | 173 } |
| 171 | 174 |
| 172 protected: | 175 protected: |
| 173 // TestWindowTreeClient that is used for the WM connection. | 176 // TestWindowTreeClient that is used for the WM connection. |
| 174 TestWindowTreeClient* wm_client_; | 177 TestWindowTreeClient* wm_client_; |
| 175 int32_t cursor_id_; | 178 int32_t cursor_id_; |
| 176 TestPlatformDisplayFactory platform_display_factory_; | 179 TestPlatformDisplayFactory platform_display_factory_; |
| 177 TestWindowServerDelegate delegate_; | 180 TestWindowServerDelegate delegate_; |
| 178 // Owned by WindowServer. | 181 // Owned by WindowServer. |
| 179 TestDisplayBinding* display_binding_; | 182 TestDisplayBinding* display_binding_; |
| 180 Display* display_ = nullptr; | 183 Display* display_ = nullptr; |
| 181 scoped_refptr<SurfacesState> surfaces_state_; | 184 scoped_refptr<SurfacesState> surfaces_state_; |
| 182 scoped_ptr<WindowServer> window_server_; | 185 std::unique_ptr<WindowServer> window_server_; |
| 183 base::MessageLoop message_loop_; | 186 base::MessageLoop message_loop_; |
| 184 | 187 |
| 185 DISALLOW_COPY_AND_ASSIGN(WindowTreeTest); | 188 DISALLOW_COPY_AND_ASSIGN(WindowTreeTest); |
| 186 }; | 189 }; |
| 187 | 190 |
| 188 // Creates a new window in wm_tree(), adds it to the root, embeds a | 191 // Creates a new window in wm_tree(), adds it to the root, embeds a |
| 189 // new client in the window and creates a child of said window. |window| is | 192 // new client in the window and creates a child of said window. |window| is |
| 190 // set to the child of |window_tree| that is created. | 193 // set to the child of |window_tree| that is created. |
| 191 void WindowTreeTest::SetupEventTargeting(TestWindowTreeClient** out_client, | 194 void WindowTreeTest::SetupEventTargeting(TestWindowTreeClient** out_client, |
| 192 WindowTree** window_tree, | 195 WindowTree** window_tree, |
| (...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 872 ASSERT_NE(new_opacity, unknown_window.opacity()); | 875 ASSERT_NE(new_opacity, unknown_window.opacity()); |
| 873 | 876 |
| 874 EXPECT_FALSE(tree->SetWindowOpacity( | 877 EXPECT_FALSE(tree->SetWindowOpacity( |
| 875 ClientWindowId(WindowIdToTransportId(window_id)), new_opacity)); | 878 ClientWindowId(WindowIdToTransportId(window_id)), new_opacity)); |
| 876 EXPECT_NE(new_opacity, unknown_window.opacity()); | 879 EXPECT_NE(new_opacity, unknown_window.opacity()); |
| 877 } | 880 } |
| 878 | 881 |
| 879 } // namespace test | 882 } // namespace test |
| 880 } // namespace ws | 883 } // namespace ws |
| 881 } // namespace mus | 884 } // namespace mus |
| OLD | NEW |