| 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 22 matching lines...) Expand all Loading... |
| 33 mojom::Cursor* cursor_storage) | 33 mojom::Cursor* cursor_storage) |
| 34 : id_(id), | 34 : id_(id), |
| 35 is_primary_(is_primary), | 35 is_primary_(is_primary), |
| 36 cursor_storage_(cursor_storage) { | 36 cursor_storage_(cursor_storage) { |
| 37 display_metrics_.bounds = gfx::Rect(0, 0, 400, 300); | 37 display_metrics_.bounds = gfx::Rect(0, 0, 400, 300); |
| 38 display_metrics_.device_scale_factor = 1.f; | 38 display_metrics_.device_scale_factor = 1.f; |
| 39 } | 39 } |
| 40 ~TestPlatformDisplay() override {} | 40 ~TestPlatformDisplay() override {} |
| 41 | 41 |
| 42 // PlatformDisplay: | 42 // PlatformDisplay: |
| 43 void Init(PlatformDisplayDelegate* delegate) override {} | 43 void Init(PlatformDisplayDelegate* delegate) override { |
| 44 delegate->OnAcceleratedWidgetAvailable(); |
| 45 } |
| 44 int64_t GetId() const override { return id_; } | 46 int64_t GetId() const override { return id_; } |
| 45 void SetViewportSize(const gfx::Size& size) override {} | 47 void SetViewportSize(const gfx::Size& size) override {} |
| 46 void SetTitle(const base::string16& title) override {} | 48 void SetTitle(const base::string16& title) override {} |
| 47 void SetCapture() override {} | 49 void SetCapture() override {} |
| 48 void ReleaseCapture() override {} | 50 void ReleaseCapture() override {} |
| 49 void SetCursorById(mojom::Cursor cursor) override { | 51 void SetCursorById(mojom::Cursor cursor) override { |
| 50 *cursor_storage_ = cursor; | 52 *cursor_storage_ = cursor; |
| 51 } | 53 } |
| 52 void UpdateTextInputState(const ui::TextInputState& state) override {} | 54 void UpdateTextInputState(const ui::TextInputState& state) override {} |
| 53 void SetImeVisibility(bool visible) override {} | 55 void SetImeVisibility(bool visible) override {} |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 | 94 |
| 93 const int64_t TestPlatformDisplayFactory::kFirstDisplayId = 1; | 95 const int64_t TestPlatformDisplayFactory::kFirstDisplayId = 1; |
| 94 | 96 |
| 95 TestPlatformDisplayFactory::TestPlatformDisplayFactory( | 97 TestPlatformDisplayFactory::TestPlatformDisplayFactory( |
| 96 mojom::Cursor* cursor_storage) | 98 mojom::Cursor* cursor_storage) |
| 97 : cursor_storage_(cursor_storage), | 99 : cursor_storage_(cursor_storage), |
| 98 next_display_id_(kFirstDisplayId) {} | 100 next_display_id_(kFirstDisplayId) {} |
| 99 | 101 |
| 100 TestPlatformDisplayFactory::~TestPlatformDisplayFactory() {} | 102 TestPlatformDisplayFactory::~TestPlatformDisplayFactory() {} |
| 101 | 103 |
| 102 PlatformDisplay* TestPlatformDisplayFactory::CreatePlatformDisplay() { | 104 std::unique_ptr<PlatformDisplay> |
| 105 TestPlatformDisplayFactory::CreatePlatformDisplay() { |
| 103 bool is_primary = (next_display_id_ == kFirstDisplayId); | 106 bool is_primary = (next_display_id_ == kFirstDisplayId); |
| 104 return new TestPlatformDisplay(next_display_id_++, is_primary, | 107 return base::MakeUnique<TestPlatformDisplay>(next_display_id_++, is_primary, |
| 105 cursor_storage_); | 108 cursor_storage_); |
| 106 } | 109 } |
| 107 | 110 |
| 108 // TestFrameGeneratorDelegate ------------------------------------------------- | 111 // TestFrameGeneratorDelegate ------------------------------------------------- |
| 109 | 112 |
| 110 TestFrameGeneratorDelegate::TestFrameGeneratorDelegate() {} | 113 TestFrameGeneratorDelegate::TestFrameGeneratorDelegate() {} |
| 111 | 114 |
| 112 TestFrameGeneratorDelegate::~TestFrameGeneratorDelegate() {} | 115 TestFrameGeneratorDelegate::~TestFrameGeneratorDelegate() {} |
| 113 | 116 |
| 114 bool TestFrameGeneratorDelegate::IsInHighContrastMode() { | 117 bool TestFrameGeneratorDelegate::IsInHighContrastMode() { |
| 115 return false; | 118 return false; |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 void TestWindowServerDelegate::CreateDisplays(int num_displays) { | 408 void TestWindowServerDelegate::CreateDisplays(int num_displays) { |
| 406 DCHECK_GT(num_displays, 0); | 409 DCHECK_GT(num_displays, 0); |
| 407 DCHECK(window_server_); | 410 DCHECK(window_server_); |
| 408 | 411 |
| 409 for (int i = 0; i < num_displays; ++i) | 412 for (int i = 0; i < num_displays; ++i) |
| 410 AddDisplay(); | 413 AddDisplay(); |
| 411 } | 414 } |
| 412 | 415 |
| 413 Display* TestWindowServerDelegate::AddDisplay() { | 416 Display* TestWindowServerDelegate::AddDisplay() { |
| 414 // Display manages its own lifetime. | 417 // Display manages its own lifetime. |
| 415 Display* display = new Display(window_server_, PlatformDisplayInitParams()); | 418 Display* display = new Display(window_server_); |
| 416 display->Init(nullptr); | 419 display->Init(PlatformDisplayInitParams(), nullptr); |
| 417 return display; | 420 return display; |
| 418 } | 421 } |
| 419 | 422 |
| 420 void TestWindowServerDelegate::StartDisplayInit() {} | 423 void TestWindowServerDelegate::StartDisplayInit() {} |
| 421 | 424 |
| 422 void TestWindowServerDelegate::OnNoMoreDisplays() { | 425 void TestWindowServerDelegate::OnNoMoreDisplays() { |
| 423 got_on_no_more_displays_ = true; | 426 got_on_no_more_displays_ = true; |
| 424 } | 427 } |
| 425 | 428 |
| 426 std::unique_ptr<WindowTreeBinding> | 429 std::unique_ptr<WindowTreeBinding> |
| (...skipping 23 matching lines...) Expand all Loading... |
| 450 window_server_delegate_.set_window_server(window_server_.get()); | 453 window_server_delegate_.set_window_server(window_server_.get()); |
| 451 } | 454 } |
| 452 | 455 |
| 453 WindowServerTestHelper::~WindowServerTestHelper() { | 456 WindowServerTestHelper::~WindowServerTestHelper() { |
| 454 // Destroy |window_server_| while the message-loop is still alive. | 457 // Destroy |window_server_| while the message-loop is still alive. |
| 455 window_server_.reset(); | 458 window_server_.reset(); |
| 456 } | 459 } |
| 457 | 460 |
| 458 // WindowEventTargetingHelper ------------------------------------------------ | 461 // WindowEventTargetingHelper ------------------------------------------------ |
| 459 | 462 |
| 460 WindowEventTargetingHelper::WindowEventTargetingHelper() | 463 WindowEventTargetingHelper::WindowEventTargetingHelper() { |
| 461 : wm_client_(nullptr), display_binding_(nullptr), display_(nullptr) { | 464 display_ = new Display(window_server()); |
| 462 PlatformDisplayInitParams display_init_params; | |
| 463 display_ = new Display(window_server(), display_init_params); | |
| 464 display_binding_ = new TestDisplayBinding(window_server()); | 465 display_binding_ = new TestDisplayBinding(window_server()); |
| 465 display_->Init(base::WrapUnique(display_binding_)); | 466 display_->Init(PlatformDisplayInitParams(), |
| 467 base::WrapUnique(display_binding_)); |
| 466 wm_client_ = ws_test_helper_.window_server_delegate()->last_client(); | 468 wm_client_ = ws_test_helper_.window_server_delegate()->last_client(); |
| 467 wm_client_->tracker()->changes()->clear(); | 469 wm_client_->tracker()->changes()->clear(); |
| 468 } | 470 } |
| 469 | 471 |
| 470 WindowEventTargetingHelper::~WindowEventTargetingHelper() {} | 472 WindowEventTargetingHelper::~WindowEventTargetingHelper() {} |
| 471 | 473 |
| 472 ServerWindow* WindowEventTargetingHelper::CreatePrimaryTree( | 474 ServerWindow* WindowEventTargetingHelper::CreatePrimaryTree( |
| 473 const gfx::Rect& root_window_bounds, | 475 const gfx::Rect& root_window_bounds, |
| 474 const gfx::Rect& window_bounds) { | 476 const gfx::Rect& window_bounds) { |
| 475 WindowTree* wm_tree = window_server()->GetTreeWithId(1); | 477 WindowTree* wm_tree = window_server()->GetTreeWithId(1); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 return nullptr; | 580 return nullptr; |
| 579 if (!tree->AddWindow(parent_client_id, client_window_id)) | 581 if (!tree->AddWindow(parent_client_id, client_window_id)) |
| 580 return nullptr; | 582 return nullptr; |
| 581 *client_id = client_window_id; | 583 *client_id = client_window_id; |
| 582 return tree->GetWindowByClientId(client_window_id); | 584 return tree->GetWindowByClientId(client_window_id); |
| 583 } | 585 } |
| 584 | 586 |
| 585 } // namespace test | 587 } // namespace test |
| 586 } // namespace ws | 588 } // namespace ws |
| 587 } // namespace ui | 589 } // namespace ui |
| OLD | NEW |