| OLD | NEW |
| 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 "services/ui/ws/test_utils.h" | 5 #include "services/ui/ws/test_utils.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "cc/output/copy_output_request.h" | 10 #include "cc/output/copy_output_request.h" |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 } | 196 } |
| 197 | 197 |
| 198 // TestDisplayBinding --------------------------------------------------------- | 198 // TestDisplayBinding --------------------------------------------------------- |
| 199 | 199 |
| 200 WindowTree* TestDisplayBinding::CreateWindowTree(ServerWindow* root) { | 200 WindowTree* TestDisplayBinding::CreateWindowTree(ServerWindow* root) { |
| 201 const uint32_t embed_flags = 0; | 201 const uint32_t embed_flags = 0; |
| 202 WindowTree* tree = window_server_->EmbedAtWindow( | 202 WindowTree* tree = window_server_->EmbedAtWindow( |
| 203 root, service_manager::mojom::kRootUserID, | 203 root, service_manager::mojom::kRootUserID, |
| 204 ui::mojom::WindowTreeClientPtr(), embed_flags, | 204 ui::mojom::WindowTreeClientPtr(), embed_flags, |
| 205 base::WrapUnique(new WindowManagerAccessPolicy)); | 205 base::WrapUnique(new WindowManagerAccessPolicy)); |
| 206 tree->ConfigureWindowManager(); | 206 tree->ConfigureWindowManager(automatically_create_display_roots_); |
| 207 return tree; | 207 return tree; |
| 208 } | 208 } |
| 209 | 209 |
| 210 // TestWindowManager ---------------------------------------------------------- | 210 // TestWindowManager ---------------------------------------------------------- |
| 211 | 211 |
| 212 TestWindowManager::TestWindowManager() {} |
| 213 |
| 214 TestWindowManager::~TestWindowManager() {} |
| 215 |
| 216 void TestWindowManager::OnConnect(uint16_t client_id) { |
| 217 connect_count_++; |
| 218 } |
| 219 |
| 220 void TestWindowManager::WmNewDisplayAdded( |
| 221 const display::Display& display, |
| 222 ui::mojom::WindowDataPtr root, |
| 223 bool drawn, |
| 224 const cc::FrameSinkId& frame_sink_id, |
| 225 const base::Optional<cc::LocalSurfaceId>& local_surface_id) { |
| 226 display_added_count_++; |
| 227 } |
| 228 |
| 212 void TestWindowManager::WmDisplayRemoved(int64_t display_id) { | 229 void TestWindowManager::WmDisplayRemoved(int64_t display_id) { |
| 213 got_display_removed_ = true; | 230 got_display_removed_ = true; |
| 214 display_removed_id_ = display_id; | 231 display_removed_id_ = display_id; |
| 215 } | 232 } |
| 216 | 233 |
| 217 void TestWindowManager::WmSetModalType(uint32_t window_id, ui::ModalType type) { | 234 void TestWindowManager::WmSetModalType(uint32_t window_id, ui::ModalType type) { |
| 218 on_set_modal_type_called_ = true; | 235 on_set_modal_type_called_ = true; |
| 219 } | 236 } |
| 220 | 237 |
| 221 void TestWindowManager::WmCreateTopLevelWindow( | 238 void TestWindowManager::WmCreateTopLevelWindow( |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 window_server_delegate_.set_window_server(window_server_.get()); | 536 window_server_delegate_.set_window_server(window_server_.get()); |
| 520 } | 537 } |
| 521 | 538 |
| 522 WindowServerTestHelper::~WindowServerTestHelper() { | 539 WindowServerTestHelper::~WindowServerTestHelper() { |
| 523 // Destroy |window_server_| while the message-loop is still alive. | 540 // Destroy |window_server_| while the message-loop is still alive. |
| 524 window_server_.reset(); | 541 window_server_.reset(); |
| 525 } | 542 } |
| 526 | 543 |
| 527 // WindowEventTargetingHelper ------------------------------------------------ | 544 // WindowEventTargetingHelper ------------------------------------------------ |
| 528 | 545 |
| 529 WindowEventTargetingHelper::WindowEventTargetingHelper() { | 546 WindowEventTargetingHelper::WindowEventTargetingHelper( |
| 547 bool automatically_create_display_roots) { |
| 530 display_ = new Display(window_server()); | 548 display_ = new Display(window_server()); |
| 531 display_binding_ = new TestDisplayBinding(window_server()); | 549 display_binding_ = new TestDisplayBinding(window_server(), |
| 550 automatically_create_display_roots); |
| 532 display_->Init(display::ViewportMetrics(), | 551 display_->Init(display::ViewportMetrics(), |
| 533 base::WrapUnique(display_binding_)); | 552 base::WrapUnique(display_binding_)); |
| 534 wm_client_ = ws_test_helper_.window_server_delegate()->last_client(); | 553 wm_client_ = ws_test_helper_.window_server_delegate()->last_client(); |
| 535 wm_client_->tracker()->changes()->clear(); | 554 wm_client_->tracker()->changes()->clear(); |
| 536 } | 555 } |
| 537 | 556 |
| 538 WindowEventTargetingHelper::~WindowEventTargetingHelper() {} | 557 WindowEventTargetingHelper::~WindowEventTargetingHelper() {} |
| 539 | 558 |
| 540 ServerWindow* WindowEventTargetingHelper::CreatePrimaryTree( | 559 ServerWindow* WindowEventTargetingHelper::CreatePrimaryTree( |
| 541 const gfx::Rect& root_window_bounds, | 560 const gfx::Rect& root_window_bounds, |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 *window = child1; | 615 *window = child1; |
| 597 } | 616 } |
| 598 | 617 |
| 599 void WindowEventTargetingHelper::SetTaskRunner( | 618 void WindowEventTargetingHelper::SetTaskRunner( |
| 600 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { | 619 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { |
| 601 base::MessageLoop::current()->SetTaskRunner(task_runner); | 620 base::MessageLoop::current()->SetTaskRunner(task_runner); |
| 602 } | 621 } |
| 603 | 622 |
| 604 // ---------------------------------------------------------------------------- | 623 // ---------------------------------------------------------------------------- |
| 605 | 624 |
| 606 void AddWindowManager(WindowServer* window_server, const UserId& user_id) { | 625 void AddWindowManager(WindowServer* window_server, |
| 626 const UserId& user_id, |
| 627 bool automatically_create_display_roots) { |
| 607 window_server->window_manager_window_tree_factory_set() | 628 window_server->window_manager_window_tree_factory_set() |
| 608 ->Add(user_id, nullptr) | 629 ->Add(user_id, nullptr) |
| 609 ->CreateWindowTree(nullptr, nullptr); | 630 ->CreateWindowTree(nullptr, nullptr, automatically_create_display_roots); |
| 610 } | 631 } |
| 611 | 632 |
| 612 display::Display MakeDisplay(int origin_x, | 633 display::Display MakeDisplay(int origin_x, |
| 613 int origin_y, | 634 int origin_y, |
| 614 int width_pixels, | 635 int width_pixels, |
| 615 int height_pixels, | 636 int height_pixels, |
| 616 float scale_factor) { | 637 float scale_factor) { |
| 617 gfx::Size scaled_size = gfx::ConvertSizeToDIP( | 638 gfx::Size scaled_size = gfx::ConvertSizeToDIP( |
| 618 scale_factor, gfx::Size(width_pixels, height_pixels)); | 639 scale_factor, gfx::Size(width_pixels, height_pixels)); |
| 619 gfx::Rect bounds(gfx::Point(origin_x, origin_y), scaled_size); | 640 gfx::Rect bounds(gfx::Point(origin_x, origin_y), scaled_size); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 if (!tree->AddWindow(parent_client_id, client_window_id)) | 686 if (!tree->AddWindow(parent_client_id, client_window_id)) |
| 666 return nullptr; | 687 return nullptr; |
| 667 if (client_id) | 688 if (client_id) |
| 668 *client_id = client_window_id; | 689 *client_id = client_window_id; |
| 669 return tree->GetWindowByClientId(client_window_id); | 690 return tree->GetWindowByClientId(client_window_id); |
| 670 } | 691 } |
| 671 | 692 |
| 672 } // namespace test | 693 } // namespace test |
| 673 } // namespace ws | 694 } // namespace ws |
| 674 } // namespace ui | 695 } // namespace ui |
| OLD | NEW |