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

Side by Side Diff: services/ui/ws/test_utils.cc

Issue 2497303002: Fix ws::Display initialization order. (Closed)
Patch Set: Fix method name. Created 4 years, 1 month 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
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 "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
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
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
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::OnNoMoreDisplays() { 423 void TestWindowServerDelegate::OnNoMoreDisplays() {
421 got_on_no_more_displays_ = true; 424 got_on_no_more_displays_ = true;
422 } 425 }
423 426
424 std::unique_ptr<WindowTreeBinding> 427 std::unique_ptr<WindowTreeBinding>
425 TestWindowServerDelegate::CreateWindowTreeBinding( 428 TestWindowServerDelegate::CreateWindowTreeBinding(
426 BindingType type, 429 BindingType type,
(...skipping 21 matching lines...) Expand all
448 window_server_delegate_.set_window_server(window_server_.get()); 451 window_server_delegate_.set_window_server(window_server_.get());
449 } 452 }
450 453
451 WindowServerTestHelper::~WindowServerTestHelper() { 454 WindowServerTestHelper::~WindowServerTestHelper() {
452 // Destroy |window_server_| while the message-loop is still alive. 455 // Destroy |window_server_| while the message-loop is still alive.
453 window_server_.reset(); 456 window_server_.reset();
454 } 457 }
455 458
456 // WindowEventTargetingHelper ------------------------------------------------ 459 // WindowEventTargetingHelper ------------------------------------------------
457 460
458 WindowEventTargetingHelper::WindowEventTargetingHelper() 461 WindowEventTargetingHelper::WindowEventTargetingHelper() {
459 : wm_client_(nullptr), display_binding_(nullptr), display_(nullptr) { 462 display_ = new Display(window_server());
460 PlatformDisplayInitParams display_init_params;
461 display_ = new Display(window_server(), display_init_params);
462 display_binding_ = new TestDisplayBinding(window_server()); 463 display_binding_ = new TestDisplayBinding(window_server());
463 display_->Init(base::WrapUnique(display_binding_)); 464 display_->Init(PlatformDisplayInitParams(),
465 base::WrapUnique(display_binding_));
464 wm_client_ = ws_test_helper_.window_server_delegate()->last_client(); 466 wm_client_ = ws_test_helper_.window_server_delegate()->last_client();
465 wm_client_->tracker()->changes()->clear(); 467 wm_client_->tracker()->changes()->clear();
466 } 468 }
467 469
468 WindowEventTargetingHelper::~WindowEventTargetingHelper() {} 470 WindowEventTargetingHelper::~WindowEventTargetingHelper() {}
469 471
470 ServerWindow* WindowEventTargetingHelper::CreatePrimaryTree( 472 ServerWindow* WindowEventTargetingHelper::CreatePrimaryTree(
471 const gfx::Rect& root_window_bounds, 473 const gfx::Rect& root_window_bounds,
472 const gfx::Rect& window_bounds) { 474 const gfx::Rect& window_bounds) {
473 WindowTree* wm_tree = window_server()->GetTreeWithId(1); 475 WindowTree* wm_tree = window_server()->GetTreeWithId(1);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 return nullptr; 578 return nullptr;
577 if (!tree->AddWindow(parent_client_id, client_window_id)) 579 if (!tree->AddWindow(parent_client_id, client_window_id))
578 return nullptr; 580 return nullptr;
579 *client_id = client_window_id; 581 *client_id = client_window_id;
580 return tree->GetWindowByClientId(client_window_id); 582 return tree->GetWindowByClientId(client_window_id);
581 } 583 }
582 584
583 } // namespace test 585 } // namespace test
584 } // namespace ws 586 } // namespace ws
585 } // namespace ui 587 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698