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

Side by Side Diff: ash/mus/test/wm_test_helper.cc

Issue 2318223003: mash: Migrate wallpaper controllers to ash/common. (Closed)
Patch Set: Fix nit. Created 4 years, 3 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 | « ash/mus/test/wm_test_helper.h ('k') | ash/mus/window_manager.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 "ash/mus/test/wm_test_helper.h" 5 #include "ash/mus/test/wm_test_helper.h"
6 6
7 #include "ash/common/material_design/material_design_controller.h" 7 #include "ash/common/material_design/material_design_controller.h"
8 #include "ash/common/test/material_design_controller_test_api.h" 8 #include "ash/common/test/material_design_controller_test_api.h"
9 #include "ash/mus/root_window_controller.h" 9 #include "ash/mus/root_window_controller.h"
10 #include "ash/mus/test/wm_test_screen.h" 10 #include "ash/mus/test/wm_test_screen.h"
11 #include "ash/mus/window_manager.h" 11 #include "ash/mus/window_manager.h"
12 #include "ash/mus/window_manager_application.h" 12 #include "ash/mus/window_manager_application.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
15 #include "base/test/sequenced_worker_pool_owner.h"
15 #include "services/ui/public/cpp/property_type_converters.h" 16 #include "services/ui/public/cpp/property_type_converters.h"
16 #include "services/ui/public/cpp/tests/window_tree_client_private.h" 17 #include "services/ui/public/cpp/tests/window_tree_client_private.h"
17 #include "services/ui/public/cpp/window_tree_client.h" 18 #include "services/ui/public/cpp/window_tree_client.h"
18 #include "ui/base/material_design/material_design_controller.h" 19 #include "ui/base/material_design/material_design_controller.h"
19 #include "ui/base/test/material_design_controller_test_api.h" 20 #include "ui/base/test/material_design_controller_test_api.h"
20 #include "ui/display/display.h" 21 #include "ui/display/display.h"
21 22
22 namespace ash { 23 namespace ash {
23 namespace mus { 24 namespace mus {
24 25
25 WmTestHelper::WmTestHelper() {} 26 WmTestHelper::WmTestHelper() {}
26 27
27 WmTestHelper::~WmTestHelper() { 28 WmTestHelper::~WmTestHelper() {
28 // Needs to be destroyed before material design. 29 // Needs to be destroyed before material design.
29 window_manager_app_.reset(); 30 window_manager_app_.reset();
30 31
32 base::RunLoop().RunUntilIdle();
33 blocking_pool_owner_.reset();
34 base::RunLoop().RunUntilIdle();
35
31 ash::test::MaterialDesignControllerTestAPI::Uninitialize(); 36 ash::test::MaterialDesignControllerTestAPI::Uninitialize();
32 ui::test::MaterialDesignControllerTestAPI::Uninitialize(); 37 ui::test::MaterialDesignControllerTestAPI::Uninitialize();
33 } 38 }
34 39
35 void WmTestHelper::Init() { 40 void WmTestHelper::Init() {
36 ui::MaterialDesignController::Initialize(); 41 ui::MaterialDesignController::Initialize();
37 ash::MaterialDesignController::Initialize(); 42 ash::MaterialDesignController::Initialize();
38 43
39 window_manager_app_ = base::MakeUnique<WindowManagerApplication>(); 44 window_manager_app_ = base::MakeUnique<WindowManagerApplication>();
40 45
41 message_loop_.reset(new base::MessageLoopForUI()); 46 message_loop_.reset(new base::MessageLoopForUI());
47
48 const size_t kMaxNumberThreads = 3u; // Matches that of content.
49 const char kThreadNamePrefix[] = "MashBlockingForTesting";
50 blocking_pool_owner_ = base::MakeUnique<base::SequencedWorkerPoolOwner>(
51 kMaxNumberThreads, kThreadNamePrefix);
52
42 window_manager_app_->window_manager_.reset(new WindowManager(nullptr)); 53 window_manager_app_->window_manager_.reset(new WindowManager(nullptr));
43 screen_ = new WmTestScreen; 54 screen_ = new WmTestScreen;
44 window_manager_app_->window_manager_->screen_.reset(screen_); 55 window_manager_app_->window_manager_->screen_.reset(screen_);
45 56
46 // Need an id other than kInvalidDisplayID so the Display is considered valid. 57 // Need an id other than kInvalidDisplayID so the Display is considered valid.
47 display::Display display(1); 58 display::Display display(1);
48 const gfx::Rect display_bounds(0, 0, 800, 600); 59 const gfx::Rect display_bounds(0, 0, 800, 600);
49 display.set_bounds(display_bounds); 60 display.set_bounds(display_bounds);
50 // Offset the height slightly to give a different work area. -20 is arbitrary, 61 // Offset the height slightly to give a different work area. -20 is arbitrary,
51 // it could be anything. 62 // it could be anything.
52 const gfx::Rect work_area(0, 0, display_bounds.width(), 63 const gfx::Rect work_area(0, 0, display_bounds.width(),
53 display_bounds.height() - 20); 64 display_bounds.height() - 20);
54 display.set_work_area(work_area); 65 display.set_work_area(work_area);
55 window_tree_client_setup_.InitForWindowManager( 66 window_tree_client_setup_.InitForWindowManager(
56 window_manager_app_->window_manager_.get(), 67 window_manager_app_->window_manager_.get(),
57 window_manager_app_->window_manager_.get(), display); 68 window_manager_app_->window_manager_.get(), display);
58 69
59 window_manager_app_->InitWindowManager( 70 window_manager_app_->InitWindowManager(
60 window_tree_client_setup_.OwnWindowTreeClient()); 71 window_tree_client_setup_.OwnWindowTreeClient(),
72 blocking_pool_owner_->pool());
61 ui::WindowTreeClient* window_tree_client = 73 ui::WindowTreeClient* window_tree_client =
62 window_manager_app_->window_manager()->window_tree_client(); 74 window_manager_app_->window_manager()->window_tree_client();
63 75
64 screen_->display_list()->AddDisplay(display, 76 screen_->display_list()->AddDisplay(display,
65 display::DisplayList::Type::PRIMARY); 77 display::DisplayList::Type::PRIMARY);
66 78
67 ui::WindowTreeClientPrivate(window_tree_client) 79 ui::WindowTreeClientPrivate(window_tree_client)
68 .CallWmNewDisplayAdded(display); 80 .CallWmNewDisplayAdded(display);
69 } 81 }
70 82
71 } // namespace mus 83 } // namespace mus
72 } // namespace ash 84 } // namespace ash
OLDNEW
« no previous file with comments | « ash/mus/test/wm_test_helper.h ('k') | ash/mus/window_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698