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

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

Issue 2916823002: Move Mus into chrome's process when running with --mus.
Patch Set: Removing debug include. Created 3 years, 5 months 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
« no previous file with comments | « services/ui/ws/test_utils.h ('k') | services/ui/ws/threaded_image_cursors.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "cc/output/copy_output_request.h" 11 #include "cc/output/copy_output_request.h"
12 #include "gpu/ipc/client/gpu_channel_host.h" 12 #include "gpu/ipc/client/gpu_channel_host.h"
13 #include "services/service_manager/public/interfaces/connector.mojom.h" 13 #include "services/service_manager/public/interfaces/connector.mojom.h"
14 #include "services/ui/common/image_cursors_set.h"
14 #include "services/ui/public/interfaces/cursor/cursor.mojom.h" 15 #include "services/ui/public/interfaces/cursor/cursor.mojom.h"
15 #include "services/ui/ws/display_binding.h" 16 #include "services/ui/ws/display_binding.h"
16 #include "services/ui/ws/display_creation_config.h" 17 #include "services/ui/ws/display_creation_config.h"
17 #include "services/ui/ws/display_manager.h" 18 #include "services/ui/ws/display_manager.h"
18 #include "services/ui/ws/frame_sink_manager_client_binding.h" 19 #include "services/ui/ws/frame_sink_manager_client_binding.h"
19 #include "services/ui/ws/gpu_host.h" 20 #include "services/ui/ws/gpu_host.h"
21 #include "services/ui/ws/threaded_image_cursors.h"
22 #include "services/ui/ws/threaded_image_cursors_factory.h"
20 #include "services/ui/ws/window_manager_access_policy.h" 23 #include "services/ui/ws/window_manager_access_policy.h"
21 #include "services/ui/ws/window_manager_window_tree_factory.h" 24 #include "services/ui/ws/window_manager_window_tree_factory.h"
22 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
23 #include "ui/base/cursor/cursor.h" 26 #include "ui/base/cursor/cursor.h"
24 #include "ui/gfx/geometry/dip_util.h" 27 #include "ui/gfx/geometry/dip_util.h"
25 28
26 namespace ui { 29 namespace ui {
27 namespace ws { 30 namespace ws {
28 namespace test { 31 namespace test {
29 namespace { 32 namespace {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 display::ViewportMetrics MakeViewportMetrics(const display::Display& display) { 85 display::ViewportMetrics MakeViewportMetrics(const display::Display& display) {
83 gfx::Size pixel_size = gfx::ConvertSizeToPixel(display.device_scale_factor(), 86 gfx::Size pixel_size = gfx::ConvertSizeToPixel(display.device_scale_factor(),
84 display.bounds().size()); 87 display.bounds().size());
85 88
86 display::ViewportMetrics metrics; 89 display::ViewportMetrics metrics;
87 metrics.bounds_in_pixels.set_size(pixel_size); 90 metrics.bounds_in_pixels.set_size(pixel_size);
88 metrics.device_scale_factor = display.device_scale_factor(); 91 metrics.device_scale_factor = display.device_scale_factor();
89 return metrics; 92 return metrics;
90 } 93 }
91 94
95 class TestThreadedImageCursorsFactory : public ThreadedImageCursorsFactory {
96 public:
97 TestThreadedImageCursorsFactory() {}
98 ~TestThreadedImageCursorsFactory() override {}
99
100 // ThreadedImageCursorsFactory:
101 std::unique_ptr<ThreadedImageCursors> CreateCursors() override {
102 if (!resource_runner_) {
103 resource_runner_ = base::ThreadTaskRunnerHandle::Get();
104 image_cursors_set_ = base::MakeUnique<ui::ImageCursorsSet>();
105 }
106 return base::MakeUnique<ws::ThreadedImageCursors>(
107 resource_runner_, image_cursors_set_->GetWeakPtr());
108 }
109
110 private:
111 scoped_refptr<base::SingleThreadTaskRunner> resource_runner_;
112 std::unique_ptr<ui::ImageCursorsSet> image_cursors_set_;
113
114 DISALLOW_COPY_AND_ASSIGN(TestThreadedImageCursorsFactory);
115 };
116
92 } // namespace 117 } // namespace
93 118
94 // TestScreenManager ------------------------------------------------- 119 // TestScreenManager -------------------------------------------------
95 120
96 TestScreenManager::TestScreenManager() {} 121 TestScreenManager::TestScreenManager() {}
97 122
98 TestScreenManager::~TestScreenManager() { 123 TestScreenManager::~TestScreenManager() {
99 display::Screen::SetScreenInstance(nullptr); 124 display::Screen::SetScreenInstance(nullptr);
100 } 125 }
101 126
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 } 527 }
503 528
504 mojom::WindowTreeClient* TestWindowTreeBinding::CreateClientForShutdown() { 529 mojom::WindowTreeClient* TestWindowTreeBinding::CreateClientForShutdown() {
505 DCHECK(!client_after_reset_); 530 DCHECK(!client_after_reset_);
506 client_after_reset_ = base::MakeUnique<TestWindowTreeClient>(); 531 client_after_reset_ = base::MakeUnique<TestWindowTreeClient>();
507 return client_after_reset_.get(); 532 return client_after_reset_.get();
508 } 533 }
509 534
510 // TestWindowServerDelegate ---------------------------------------------- 535 // TestWindowServerDelegate ----------------------------------------------
511 536
512 TestWindowServerDelegate::TestWindowServerDelegate() {} 537 TestWindowServerDelegate::TestWindowServerDelegate()
538 : threaded_image_cursors_factory_(
539 base::MakeUnique<TestThreadedImageCursorsFactory>()) {}
513 TestWindowServerDelegate::~TestWindowServerDelegate() {} 540 TestWindowServerDelegate::~TestWindowServerDelegate() {}
514 541
515 void TestWindowServerDelegate::StartDisplayInit() {} 542 void TestWindowServerDelegate::StartDisplayInit() {}
516 543
517 void TestWindowServerDelegate::OnNoMoreDisplays() { 544 void TestWindowServerDelegate::OnNoMoreDisplays() {
518 got_on_no_more_displays_ = true; 545 got_on_no_more_displays_ = true;
519 } 546 }
520 547
521 std::unique_ptr<WindowTreeBinding> 548 std::unique_ptr<WindowTreeBinding>
522 TestWindowServerDelegate::CreateWindowTreeBinding( 549 TestWindowServerDelegate::CreateWindowTreeBinding(
(...skipping 16 matching lines...) Expand all
539 bool automatically_create_display_roots) { 566 bool automatically_create_display_roots) {
540 if (window_server_->display_creation_config() != 567 if (window_server_->display_creation_config() !=
541 DisplayCreationConfig::UNKNOWN) { 568 DisplayCreationConfig::UNKNOWN) {
542 return; 569 return;
543 } 570 }
544 window_server_->SetDisplayCreationConfig( 571 window_server_->SetDisplayCreationConfig(
545 automatically_create_display_roots ? DisplayCreationConfig::AUTOMATIC 572 automatically_create_display_roots ? DisplayCreationConfig::AUTOMATIC
546 : DisplayCreationConfig::MANUAL); 573 : DisplayCreationConfig::MANUAL);
547 } 574 }
548 575
576 ThreadedImageCursorsFactory*
577 TestWindowServerDelegate::GetThreadedImageCursorsFactory() {
578 return threaded_image_cursors_factory_.get();
579 }
580
549 // WindowServerTestHelper --------------------------------------------------- 581 // WindowServerTestHelper ---------------------------------------------------
550 582
551 WindowServerTestHelper::WindowServerTestHelper() 583 WindowServerTestHelper::WindowServerTestHelper()
552 : cursor_(ui::CursorType::kNull), platform_display_factory_(&cursor_) { 584 : cursor_(ui::CursorType::kNull), platform_display_factory_(&cursor_) {
553 // Some tests create their own message loop, for example to add a task runner. 585 // Some tests create their own message loop, for example to add a task runner.
554 if (!base::MessageLoop::current()) 586 if (!base::MessageLoop::current())
555 message_loop_ = base::MakeUnique<base::MessageLoop>(); 587 message_loop_ = base::MakeUnique<base::MessageLoop>();
556 PlatformDisplay::set_factory_for_testing(&platform_display_factory_); 588 PlatformDisplay::set_factory_for_testing(&platform_display_factory_);
557 window_server_ = base::MakeUnique<WindowServer>(&window_server_delegate_); 589 window_server_ = base::MakeUnique<WindowServer>(&window_server_delegate_);
558 // TODO(staraz): Replace DefaultGpuHost and FrameSinkManagerClientBinding with 590 // TODO(staraz): Replace DefaultGpuHost and FrameSinkManagerClientBinding with
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 if (!tree->AddWindow(parent_client_id, client_window_id)) 786 if (!tree->AddWindow(parent_client_id, client_window_id))
755 return nullptr; 787 return nullptr;
756 if (client_id) 788 if (client_id)
757 *client_id = client_window_id; 789 *client_id = client_window_id;
758 return tree->GetWindowByClientId(client_window_id); 790 return tree->GetWindowByClientId(client_window_id);
759 } 791 }
760 792
761 } // namespace test 793 } // namespace test
762 } // namespace ws 794 } // namespace ws
763 } // namespace ui 795 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/test_utils.h ('k') | services/ui/ws/threaded_image_cursors.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698