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

Side by Side Diff: components/mus/ws/test_utils.cc

Issue 2072343002: Changes how window manager obtains WindowTree from mus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: include Created 4 years, 6 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 | « components/mus/ws/test_utils.h ('k') | components/mus/ws/user_display_manager.cc » ('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 "components/mus/ws/test_utils.h" 5 #include "components/mus/ws/test_utils.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "cc/output/copy_output_request.h" 8 #include "cc/output/copy_output_request.h"
9 #include "components/mus/surfaces/surfaces_state.h" 9 #include "components/mus/surfaces/surfaces_state.h"
10 #include "components/mus/ws/display_binding.h" 10 #include "components/mus/ws/display_binding.h"
11 #include "components/mus/ws/display_manager.h"
11 #include "components/mus/ws/server_window_surface_manager_test_api.h" 12 #include "components/mus/ws/server_window_surface_manager_test_api.h"
12 #include "components/mus/ws/window_manager_access_policy.h" 13 #include "components/mus/ws/window_manager_access_policy.h"
13 #include "components/mus/ws/window_manager_factory_service.h" 14 #include "components/mus/ws/window_manager_window_tree_factory.h"
14 #include "services/shell/public/interfaces/connector.mojom.h" 15 #include "services/shell/public/interfaces/connector.mojom.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 17
17 namespace mus { 18 namespace mus {
18 namespace ws { 19 namespace ws {
19 namespace test { 20 namespace test {
20 namespace { 21 namespace {
21 22
22 // ----------------------------------------------------------------------------- 23 // -----------------------------------------------------------------------------
23 // Empty implementation of PlatformDisplay. 24 // Empty implementation of PlatformDisplay.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 // Used the id of the client in the upper bits to simplify things. 69 // Used the id of the client in the upper bits to simplify things.
69 const ClientWindowId client_id = 70 const ClientWindowId client_id =
70 ClientWindowId(WindowIdToTransportId(WindowId(tree->id(), id))); 71 ClientWindowId(WindowIdToTransportId(WindowId(tree->id(), id)));
71 if (!tree->GetWindowByClientId(client_id)) 72 if (!tree->GetWindowByClientId(client_id))
72 return client_id; 73 return client_id;
73 } 74 }
74 } 75 }
75 76
76 } // namespace 77 } // namespace
77 78
78 // WindowManagerFactoryRegistryTestApi ---------------------------------------- 79 // WindowManagerWindowTreeFactorySetTestApi ------------------------------------
79 80
80 WindowManagerFactoryRegistryTestApi::WindowManagerFactoryRegistryTestApi( 81 WindowManagerWindowTreeFactorySetTestApi::
81 WindowManagerFactoryRegistry* registry) 82 WindowManagerWindowTreeFactorySetTestApi(
82 : registry_(registry) {} 83 WindowManagerWindowTreeFactorySet*
84 window_manager_window_tree_factory_set)
85 : window_manager_window_tree_factory_set_(
86 window_manager_window_tree_factory_set) {}
83 87
84 WindowManagerFactoryRegistryTestApi::~WindowManagerFactoryRegistryTestApi() {} 88 WindowManagerWindowTreeFactorySetTestApi::
89 ~WindowManagerWindowTreeFactorySetTestApi() {}
85 90
86 void WindowManagerFactoryRegistryTestApi::AddService( 91 void WindowManagerWindowTreeFactorySetTestApi::Add(const UserId& user_id) {
87 const UserId& user_id, 92 WindowManagerWindowTreeFactory* factory =
88 mojom::WindowManagerFactory* factory) { 93 window_manager_window_tree_factory_set_->Add(user_id, nullptr);
89 std::unique_ptr<WindowManagerFactoryService> service_ptr( 94 factory->CreateWindowTree(nullptr, nullptr);
90 new WindowManagerFactoryService(registry_, user_id));
91 WindowManagerFactoryService* service = service_ptr.get();
92 registry_->AddServiceImpl(std::move(service_ptr));
93 service->SetWindowManagerFactoryImpl(factory);
94 } 95 }
95 96
96 // TestPlatformDisplayFactory ------------------------------------------------- 97 // TestPlatformDisplayFactory -------------------------------------------------
97 98
98 TestPlatformDisplayFactory::TestPlatformDisplayFactory( 99 TestPlatformDisplayFactory::TestPlatformDisplayFactory(
99 int32_t* cursor_id_storage) 100 int32_t* cursor_id_storage)
100 : cursor_id_storage_(cursor_id_storage) {} 101 : cursor_id_storage_(cursor_id_storage) {}
101 102
102 TestPlatformDisplayFactory::~TestPlatformDisplayFactory() {} 103 TestPlatformDisplayFactory::~TestPlatformDisplayFactory() {}
103 104
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 *window = child1; 436 *window = child1;
436 } 437 }
437 438
438 void WindowEventTargetingHelper::SetTaskRunner( 439 void WindowEventTargetingHelper::SetTaskRunner(
439 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { 440 scoped_refptr<base::SingleThreadTaskRunner> task_runner) {
440 message_loop_.SetTaskRunner(task_runner); 441 message_loop_.SetTaskRunner(task_runner);
441 } 442 }
442 443
443 // ---------------------------------------------------------------------------- 444 // ----------------------------------------------------------------------------
444 445
445 TestWindowManagerFactory::TestWindowManagerFactory() {}
446
447 TestWindowManagerFactory::~TestWindowManagerFactory() {}
448
449 void TestWindowManagerFactory::CreateWindowManager(
450 mus::mojom::DisplayPtr display,
451 mus::mojom::WindowTreeClientRequest client) {}
452
453 // ----------------------------------------------------------------------------
454
455 ServerWindow* FirstRoot(WindowTree* tree) { 446 ServerWindow* FirstRoot(WindowTree* tree) {
456 return tree->roots().size() == 1u 447 return tree->roots().size() == 1u
457 ? tree->GetWindow((*tree->roots().begin())->id()) 448 ? tree->GetWindow((*tree->roots().begin())->id())
458 : nullptr; 449 : nullptr;
459 } 450 }
460 451
461 ClientWindowId FirstRootId(WindowTree* tree) { 452 ClientWindowId FirstRootId(WindowTree* tree) {
462 ServerWindow* first_root = FirstRoot(tree); 453 ServerWindow* first_root = FirstRoot(tree);
463 return first_root ? ClientWindowIdForWindow(tree, first_root) 454 return first_root ? ClientWindowIdForWindow(tree, first_root)
464 : ClientWindowId(); 455 : ClientWindowId();
465 } 456 }
466 457
467 ClientWindowId ClientWindowIdForWindow(WindowTree* tree, 458 ClientWindowId ClientWindowIdForWindow(WindowTree* tree,
468 const ServerWindow* window) { 459 const ServerWindow* window) {
469 ClientWindowId client_window_id; 460 ClientWindowId client_window_id;
470 // If window isn't known we'll return 0, which should then error out. 461 // If window isn't known we'll return 0, which should then error out.
471 tree->IsWindowKnown(window, &client_window_id); 462 tree->IsWindowKnown(window, &client_window_id);
472 return client_window_id; 463 return client_window_id;
473 } 464 }
474 465
475 ServerWindow* NewWindowInTree(WindowTree* tree, ClientWindowId* client_id) { 466 ServerWindow* NewWindowInTree(WindowTree* tree, ClientWindowId* client_id) {
476 ServerWindow* parent = FirstRoot(tree); 467 return NewWindowInTreeWithParent(tree, FirstRoot(tree), client_id);
468 }
469
470 ServerWindow* NewWindowInTreeWithParent(WindowTree* tree,
471 ServerWindow* parent,
472 ClientWindowId* client_id) {
477 if (!parent) 473 if (!parent)
478 return nullptr; 474 return nullptr;
479 ClientWindowId parent_client_id; 475 ClientWindowId parent_client_id;
480 if (!tree->IsWindowKnown(parent, &parent_client_id)) 476 if (!tree->IsWindowKnown(parent, &parent_client_id))
481 return nullptr; 477 return nullptr;
482 ClientWindowId client_window_id = NextUnusedClientWindowId(tree); 478 ClientWindowId client_window_id = NextUnusedClientWindowId(tree);
483 if (!tree->NewWindow(client_window_id, ServerWindow::Properties())) 479 if (!tree->NewWindow(client_window_id, ServerWindow::Properties()))
484 return nullptr; 480 return nullptr;
485 if (!tree->SetWindowVisibility(client_window_id, true)) 481 if (!tree->SetWindowVisibility(client_window_id, true))
486 return nullptr; 482 return nullptr;
487 if (!tree->AddWindow(parent_client_id, client_window_id)) 483 if (!tree->AddWindow(parent_client_id, client_window_id))
488 return nullptr; 484 return nullptr;
489 *client_id = client_window_id; 485 *client_id = client_window_id;
490 return tree->GetWindowByClientId(client_window_id); 486 return tree->GetWindowByClientId(client_window_id);
491 } 487 }
492 488
493 } // namespace test 489 } // namespace test
494 } // namespace ws 490 } // namespace ws
495 } // namespace mus 491 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/ws/test_utils.h ('k') | components/mus/ws/user_display_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698