| 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 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 DCHECK(!client_after_reset_); | 413 DCHECK(!client_after_reset_); |
| 414 client_after_reset_ = base::MakeUnique<TestWindowTreeClient>(); | 414 client_after_reset_ = base::MakeUnique<TestWindowTreeClient>(); |
| 415 return client_after_reset_.get(); | 415 return client_after_reset_.get(); |
| 416 } | 416 } |
| 417 | 417 |
| 418 // TestWindowServerDelegate ---------------------------------------------- | 418 // TestWindowServerDelegate ---------------------------------------------- |
| 419 | 419 |
| 420 TestWindowServerDelegate::TestWindowServerDelegate() {} | 420 TestWindowServerDelegate::TestWindowServerDelegate() {} |
| 421 TestWindowServerDelegate::~TestWindowServerDelegate() {} | 421 TestWindowServerDelegate::~TestWindowServerDelegate() {} |
| 422 | 422 |
| 423 void TestWindowServerDelegate::CreateDisplays(int num_displays) { |
| 424 DCHECK_GT(num_displays, 0); |
| 425 DCHECK(window_server_); |
| 426 |
| 427 for (int i = 0; i < num_displays; ++i) |
| 428 AddDisplay(); |
| 429 } |
| 430 |
| 423 Display* TestWindowServerDelegate::AddDisplay() { | 431 Display* TestWindowServerDelegate::AddDisplay() { |
| 424 // Display manages its own lifetime. | 432 // Display manages its own lifetime. |
| 425 Display* display = new Display(window_server_, PlatformDisplayInitParams()); | 433 Display* display = new Display(window_server_, PlatformDisplayInitParams()); |
| 426 display->Init(nullptr); | 434 display->Init(nullptr); |
| 427 return display; | 435 return display; |
| 428 } | 436 } |
| 429 | 437 |
| 430 void TestWindowServerDelegate::OnNoMoreDisplays() { | 438 void TestWindowServerDelegate::OnNoMoreDisplays() { |
| 431 got_on_no_more_displays_ = true; | 439 got_on_no_more_displays_ = true; |
| 432 } | 440 } |
| 433 | 441 |
| 434 std::unique_ptr<WindowTreeBinding> | 442 std::unique_ptr<WindowTreeBinding> |
| 435 TestWindowServerDelegate::CreateWindowTreeBinding( | 443 TestWindowServerDelegate::CreateWindowTreeBinding( |
| 436 BindingType type, | 444 BindingType type, |
| 437 ws::WindowServer* window_server, | 445 ws::WindowServer* window_server, |
| 438 ws::WindowTree* tree, | 446 ws::WindowTree* tree, |
| 439 mojom::WindowTreeRequest* tree_request, | 447 mojom::WindowTreeRequest* tree_request, |
| 440 mojom::WindowTreeClientPtr* client) { | 448 mojom::WindowTreeClientPtr* client) { |
| 441 std::unique_ptr<TestWindowTreeBinding> binding = | 449 std::unique_ptr<TestWindowTreeBinding> binding = |
| 442 base::MakeUnique<TestWindowTreeBinding>(tree); | 450 base::MakeUnique<TestWindowTreeBinding>(tree); |
| 443 bindings_.push_back(binding.get()); | 451 bindings_.push_back(binding.get()); |
| 444 return std::move(binding); | 452 return std::move(binding); |
| 445 } | 453 } |
| 446 | 454 |
| 447 void TestWindowServerDelegate::CreateDefaultDisplays() { | |
| 448 DCHECK(num_displays_to_create_); | |
| 449 DCHECK(window_server_); | |
| 450 | |
| 451 for (int i = 0; i < num_displays_to_create_; ++i) | |
| 452 AddDisplay(); | |
| 453 } | |
| 454 | |
| 455 bool TestWindowServerDelegate::IsTestConfig() const { | 455 bool TestWindowServerDelegate::IsTestConfig() const { |
| 456 return true; | 456 return true; |
| 457 } | 457 } |
| 458 | 458 |
| 459 // WindowServerTestHelper --------------------------------------------------- | 459 // WindowServerTestHelper --------------------------------------------------- |
| 460 | 460 |
| 461 WindowServerTestHelper::WindowServerTestHelper() | 461 WindowServerTestHelper::WindowServerTestHelper() |
| 462 : cursor_id_(mojom::Cursor::CURSOR_NULL), | 462 : cursor_id_(mojom::Cursor::CURSOR_NULL), |
| 463 platform_display_factory_(&cursor_id_) { | 463 platform_display_factory_(&cursor_id_) { |
| 464 PlatformDisplay::set_factory_for_testing(&platform_display_factory_); | 464 PlatformDisplay::set_factory_for_testing(&platform_display_factory_); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 return nullptr; | 588 return nullptr; |
| 589 if (!tree->AddWindow(parent_client_id, client_window_id)) | 589 if (!tree->AddWindow(parent_client_id, client_window_id)) |
| 590 return nullptr; | 590 return nullptr; |
| 591 *client_id = client_window_id; | 591 *client_id = client_window_id; |
| 592 return tree->GetWindowByClientId(client_window_id); | 592 return tree->GetWindowByClientId(client_window_id); |
| 593 } | 593 } |
| 594 | 594 |
| 595 } // namespace test | 595 } // namespace test |
| 596 } // namespace ws | 596 } // namespace ws |
| 597 } // namespace ui | 597 } // namespace ui |
| OLD | NEW |