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

Side by Side Diff: ash/test/ash_test_helper.cc

Issue 2908333003: [mus+ash] Removes WmWindow from ash (app_list, frame, metrics, session, system, wallpaper) (Closed)
Patch Set: [mus ash] Removes WmWindow from ash (rebase, nits and cleanup of use of ResizeHandleWindowTargeter) Created 3 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 | « ash/test/ash_test_base.cc ('k') | ash/test/test_shell_delegate.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/test/ash_test_helper.h" 5 #include "ash/test/ash_test_helper.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 9
10 #include "ash/accelerators/accelerator_controller_delegate_aura.h" 10 #include "ash/accelerators/accelerator_controller_delegate_aura.h"
11 #include "ash/ash_switches.h" 11 #include "ash/ash_switches.h"
12 #include "ash/aura/shell_port_classic.h" 12 #include "ash/aura/shell_port_classic.h"
13 #include "ash/mus/bridge/shell_port_mash.h" 13 #include "ash/mus/bridge/shell_port_mash.h"
14 #include "ash/mus/screen_mus.h" 14 #include "ash/mus/screen_mus.h"
15 #include "ash/mus/window_manager.h" 15 #include "ash/mus/window_manager.h"
16 #include "ash/mus/window_manager_application.h" 16 #include "ash/mus/window_manager_application.h"
17 #include "ash/public/cpp/config.h" 17 #include "ash/public/cpp/config.h"
18 #include "ash/shell.h" 18 #include "ash/shell.h"
19 #include "ash/shell_init_params.h" 19 #include "ash/shell_init_params.h"
20 #include "ash/shell_port.h" 20 #include "ash/shell_port.h"
21 #include "ash/system/screen_layout_observer.h" 21 #include "ash/system/screen_layout_observer.h"
22 #include "ash/test/ash_test_environment.h" 22 #include "ash/test/ash_test_environment.h"
23 #include "ash/test/ash_test_views_delegate.h" 23 #include "ash/test/ash_test_views_delegate.h"
24 #include "ash/test/display_configuration_controller_test_api.h" 24 #include "ash/test/display_configuration_controller_test_api.h"
25 #include "ash/test/test_screenshot_delegate.h" 25 #include "ash/test/test_screenshot_delegate.h"
26 #include "ash/test/test_shell_delegate.h" 26 #include "ash/test/test_shell_delegate.h"
27 #include "ash/test/test_system_tray_delegate.h" 27 #include "ash/test/test_system_tray_delegate.h"
28 #include "ash/wm_window.h"
29 #include "base/memory/ptr_util.h" 28 #include "base/memory/ptr_util.h"
30 #include "base/run_loop.h" 29 #include "base/run_loop.h"
31 #include "base/strings/string_split.h" 30 #include "base/strings/string_split.h"
32 #include "base/test/sequenced_worker_pool_owner.h" 31 #include "base/test/sequenced_worker_pool_owner.h"
33 #include "chromeos/audio/cras_audio_handler.h" 32 #include "chromeos/audio/cras_audio_handler.h"
34 #include "chromeos/cryptohome/system_salt_getter.h" 33 #include "chromeos/cryptohome/system_salt_getter.h"
35 #include "chromeos/dbus/dbus_thread_manager.h" 34 #include "chromeos/dbus/dbus_thread_manager.h"
36 #include "chromeos/network/network_handler.h" 35 #include "chromeos/network/network_handler.h"
37 #include "device/bluetooth/bluetooth_adapter_factory.h" 36 #include "device/bluetooth/bluetooth_adapter_factory.h"
38 #include "device/bluetooth/dbus/bluez_dbus_manager.h" 37 #include "device/bluetooth/dbus/bluez_dbus_manager.h"
39 #include "services/ui/public/cpp/input_devices/input_device_client.h" 38 #include "services/ui/public/cpp/input_devices/input_device_client.h"
40 #include "ui/aura/env.h" 39 #include "ui/aura/env.h"
41 #include "ui/aura/input_state_lookup.h" 40 #include "ui/aura/input_state_lookup.h"
42 #include "ui/aura/mus/window_tree_client.h" 41 #include "ui/aura/mus/window_tree_client.h"
43 #include "ui/aura/test/env_test_helper.h" 42 #include "ui/aura/test/env_test_helper.h"
44 #include "ui/aura/test/event_generator_delegate_aura.h" 43 #include "ui/aura/test/event_generator_delegate_aura.h"
45 #include "ui/aura/test/mus/window_tree_client_private.h" 44 #include "ui/aura/test/mus/window_tree_client_private.h"
46 #include "ui/base/ime/input_method_initializer.h" 45 #include "ui/base/ime/input_method_initializer.h"
47 #include "ui/base/material_design/material_design_controller.h" 46 #include "ui/base/material_design/material_design_controller.h"
48 #include "ui/base/platform_window_defaults.h" 47 #include "ui/base/platform_window_defaults.h"
49 #include "ui/base/test/material_design_controller_test_api.h" 48 #include "ui/base/test/material_design_controller_test_api.h"
50 #include "ui/compositor/scoped_animation_duration_scale_mode.h" 49 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
51 #include "ui/compositor/test/context_factories_for_test.h" 50 #include "ui/compositor/test/context_factories_for_test.h"
51 #include "ui/display/display.h"
52 #include "ui/display/display_switches.h" 52 #include "ui/display/display_switches.h"
53 #include "ui/display/manager/display_manager.h" 53 #include "ui/display/manager/display_manager.h"
54 #include "ui/display/manager/managed_display_info.h" 54 #include "ui/display/manager/managed_display_info.h"
55 #include "ui/display/screen.h"
55 #include "ui/display/test/display_manager_test_api.h" 56 #include "ui/display/test/display_manager_test_api.h"
56 #include "ui/message_center/message_center.h" 57 #include "ui/message_center/message_center.h"
57 #include "ui/wm/core/capture_controller.h" 58 #include "ui/wm/core/capture_controller.h"
58 #include "ui/wm/core/cursor_manager.h" 59 #include "ui/wm/core/cursor_manager.h"
59 #include "ui/wm/core/wm_state.h" 60 #include "ui/wm/core/wm_state.h"
60 61
61 using display::ManagedDisplayInfo; 62 using display::ManagedDisplayInfo;
62 63
63 namespace ash { 64 namespace ash {
64 namespace test { 65 namespace test {
65 namespace { 66 namespace {
66 67
68 const display::Display GetDisplayNearestWindow(aura::Window* window) {
69 return display::Screen::GetScreen()->GetDisplayNearestWindow(window);
70 }
71
67 bool CompareByDisplayId(RootWindowController* root1, 72 bool CompareByDisplayId(RootWindowController* root1,
68 RootWindowController* root2) { 73 RootWindowController* root2) {
69 return root1->GetWindow()->GetDisplayNearestWindow().id() < 74 return GetDisplayNearestWindow(root1->GetRootWindow()).id() <
70 root2->GetWindow()->GetDisplayNearestWindow().id(); 75 GetDisplayNearestWindow(root2->GetRootWindow()).id();
71 } 76 }
72 77
73 } // namespace 78 } // namespace
74 79
75 // static 80 // static
76 Config AshTestHelper::config_ = Config::CLASSIC; 81 Config AshTestHelper::config_ = Config::CLASSIC;
77 82
78 AshTestHelper::AshTestHelper(AshTestEnvironment* ash_test_environment) 83 AshTestHelper::AshTestHelper(AshTestEnvironment* ash_test_environment)
79 : ash_test_environment_(ash_test_environment), 84 : ash_test_environment_(ash_test_environment),
80 test_shell_delegate_(nullptr), 85 test_shell_delegate_(nullptr),
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 } 312 }
308 } 313 }
309 314
310 display::Display AshTestHelper::GetSecondaryDisplay() { 315 display::Display AshTestHelper::GetSecondaryDisplay() {
311 if (config_ != Config::MASH) 316 if (config_ != Config::MASH)
312 return Shell::Get()->display_manager()->GetSecondaryDisplay(); 317 return Shell::Get()->display_manager()->GetSecondaryDisplay();
313 318
314 std::vector<RootWindowController*> roots = GetRootsOrderedByDisplayId(); 319 std::vector<RootWindowController*> roots = GetRootsOrderedByDisplayId();
315 CHECK_LE(2U, roots.size()); 320 CHECK_LE(2U, roots.size());
316 return roots.size() < 2 ? display::Display() 321 return roots.size() < 2 ? display::Display()
317 : roots[1]->GetWindow()->GetDisplayNearestWindow(); 322 : GetDisplayNearestWindow(roots[1]->GetRootWindow());
318 } 323 }
319 324
320 void AshTestHelper::CreateMashWindowManager() { 325 void AshTestHelper::CreateMashWindowManager() {
321 CHECK(config_ != Config::CLASSIC); 326 CHECK(config_ != Config::CLASSIC);
322 const bool show_primary_root_on_connect = false; 327 const bool show_primary_root_on_connect = false;
323 window_manager_app_ = base::MakeUnique<mus::WindowManagerApplication>( 328 window_manager_app_ = base::MakeUnique<mus::WindowManagerApplication>(
324 show_primary_root_on_connect); 329 show_primary_root_on_connect);
325 330
326 window_manager_app_->window_manager_.reset( 331 window_manager_app_->window_manager_.reset(
327 new mus::WindowManager(nullptr, config_, show_primary_root_on_connect)); 332 new mus::WindowManager(nullptr, config_, show_primary_root_on_connect));
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 394
390 void AshTestHelper::UpdateDisplay(RootWindowController* root_window_controller, 395 void AshTestHelper::UpdateDisplay(RootWindowController* root_window_controller,
391 const std::string& display_spec, 396 const std::string& display_spec,
392 int* next_x) { 397 int* next_x) {
393 ManagedDisplayInfo display_info = 398 ManagedDisplayInfo display_info =
394 ManagedDisplayInfo::CreateFromSpec(display_spec); 399 ManagedDisplayInfo::CreateFromSpec(display_spec);
395 gfx::Rect bounds = display_info.bounds_in_native(); 400 gfx::Rect bounds = display_info.bounds_in_native();
396 bounds.set_x(*next_x); 401 bounds.set_x(*next_x);
397 *next_x += bounds.size().width(); 402 *next_x += bounds.size().width();
398 display::Display updated_display = 403 display::Display updated_display =
399 root_window_controller->GetWindow()->GetDisplayNearestWindow(); 404 GetDisplayNearestWindow(root_window_controller->GetRootWindow());
400 gfx::Insets work_area_insets = updated_display.GetWorkAreaInsets(); 405 gfx::Insets work_area_insets = updated_display.GetWorkAreaInsets();
401 updated_display.set_bounds(bounds); 406 updated_display.set_bounds(bounds);
402 updated_display.UpdateWorkAreaFromInsets(work_area_insets); 407 updated_display.UpdateWorkAreaFromInsets(work_area_insets);
403 updated_display.set_device_scale_factor(display_info.device_scale_factor()); 408 updated_display.set_device_scale_factor(display_info.device_scale_factor());
404 window_manager_app_->window_manager()->OnWmDisplayModified(updated_display); 409 window_manager_app_->window_manager()->OnWmDisplayModified(updated_display);
405 } 410 }
406 411
407 std::vector<RootWindowController*> AshTestHelper::GetRootsOrderedByDisplayId() { 412 std::vector<RootWindowController*> AshTestHelper::GetRootsOrderedByDisplayId() {
408 std::set<RootWindowController*> roots = 413 std::set<RootWindowController*> roots =
409 window_manager_app_->window_manager()->GetRootWindowControllers(); 414 window_manager_app_->window_manager()->GetRootWindowControllers();
410 std::vector<RootWindowController*> ordered_roots; 415 std::vector<RootWindowController*> ordered_roots;
411 ordered_roots.insert(ordered_roots.begin(), roots.begin(), roots.end()); 416 ordered_roots.insert(ordered_roots.begin(), roots.begin(), roots.end());
412 std::sort(ordered_roots.begin(), ordered_roots.end(), &CompareByDisplayId); 417 std::sort(ordered_roots.begin(), ordered_roots.end(), &CompareByDisplayId);
413 return ordered_roots; 418 return ordered_roots;
414 } 419 }
415 420
416 } // namespace test 421 } // namespace test
417 } // namespace ash 422 } // namespace ash
OLDNEW
« no previous file with comments | « ash/test/ash_test_base.cc ('k') | ash/test/test_shell_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698