| OLD | NEW |
| 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/common/test/test_system_tray_delegate.h" | 9 #include "ash/common/test/test_system_tray_delegate.h" |
| 10 #include "ash/common/test/wm_shell_test_api.h" | 10 #include "ash/common/test/wm_shell_test_api.h" |
| 11 #include "ash/common/wm_shell.h" | 11 #include "ash/common/wm_shell.h" |
| 12 #include "ash/mus/root_window_controller.h" | 12 #include "ash/common/wm_window.h" |
| 13 #include "ash/mus/screen_mus.h" | 13 #include "ash/mus/screen_mus.h" |
| 14 #include "ash/mus/window_manager.h" | 14 #include "ash/mus/window_manager.h" |
| 15 #include "ash/mus/window_manager_application.h" | 15 #include "ash/mus/window_manager_application.h" |
| 16 #include "base/memory/ptr_util.h" | 16 #include "base/memory/ptr_util.h" |
| 17 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
| 18 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
| 19 #include "base/strings/string_split.h" | 19 #include "base/strings/string_split.h" |
| 20 #include "base/test/sequenced_worker_pool_owner.h" | 20 #include "base/test/sequenced_worker_pool_owner.h" |
| 21 #include "services/ui/public/cpp/property_type_converters.h" | 21 #include "services/ui/public/cpp/property_type_converters.h" |
| 22 #include "ui/aura/mus/window_tree_client.h" | 22 #include "ui/aura/mus/window_tree_client.h" |
| 23 #include "ui/aura/test/env_test_helper.h" | 23 #include "ui/aura/test/env_test_helper.h" |
| 24 #include "ui/aura/test/mus/window_tree_client_private.h" | 24 #include "ui/aura/test/mus/window_tree_client_private.h" |
| 25 #include "ui/aura/window.h" | 25 #include "ui/aura/window.h" |
| 26 #include "ui/base/material_design/material_design_controller.h" | 26 #include "ui/base/material_design/material_design_controller.h" |
| 27 #include "ui/base/test/material_design_controller_test_api.h" | 27 #include "ui/base/test/material_design_controller_test_api.h" |
| 28 #include "ui/display/display.h" | 28 #include "ui/display/display.h" |
| 29 #include "ui/display/display_list.h" | 29 #include "ui/display/display_list.h" |
| 30 #include "ui/display/screen_base.h" | 30 #include "ui/display/screen_base.h" |
| 31 #include "ui/views/test/test_views_delegate.h" | 31 #include "ui/views/test/test_views_delegate.h" |
| 32 | 32 |
| 33 namespace ash { | 33 namespace ash { |
| 34 namespace mus { | 34 namespace mus { |
| 35 namespace { | 35 namespace { |
| 36 | 36 |
| 37 bool CompareByDisplayId(const RootWindowController* root1, | 37 bool CompareByDisplayId(RootWindowController* root1, |
| 38 const RootWindowController* root2) { | 38 RootWindowController* root2) { |
| 39 return root1->display().id() < root2->display().id(); | 39 return root1->GetWindow()->GetDisplayNearestWindow().id() < |
| 40 root2->GetWindow()->GetDisplayNearestWindow().id(); |
| 40 } | 41 } |
| 41 | 42 |
| 42 // TODO(sky): at some point this needs to support everything in DisplayInfo, | 43 // TODO(sky): at some point this needs to support everything in DisplayInfo, |
| 43 // for now just the bare minimum, which is [x+y-]wxh. | 44 // for now just the bare minimum, which is [x+y-]wxh. |
| 44 gfx::Rect ParseDisplayBounds(const std::string& spec) { | 45 gfx::Rect ParseDisplayBounds(const std::string& spec) { |
| 45 gfx::Rect bounds; | 46 gfx::Rect bounds; |
| 46 const std::vector<std::string> parts = | 47 const std::vector<std::string> parts = |
| 47 base::SplitString(spec, "-", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 48 base::SplitString(spec, "-", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 48 std::string size_spec; | 49 std::string size_spec; |
| 49 if (parts.size() == 2u) { | 50 if (parts.size() == 2u) { |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 window_tree_client_private_->CallWmNewDisplayAdded(display); | 169 window_tree_client_private_->CallWmNewDisplayAdded(display); |
| 169 return GetRootsOrderedByDisplayId().back(); | 170 return GetRootsOrderedByDisplayId().back(); |
| 170 } | 171 } |
| 171 | 172 |
| 172 void WmTestHelper::UpdateDisplay(RootWindowController* root_window_controller, | 173 void WmTestHelper::UpdateDisplay(RootWindowController* root_window_controller, |
| 173 const std::string& display_spec, | 174 const std::string& display_spec, |
| 174 int* next_x) { | 175 int* next_x) { |
| 175 gfx::Rect bounds = ParseDisplayBounds(display_spec); | 176 gfx::Rect bounds = ParseDisplayBounds(display_spec); |
| 176 bounds.set_x(*next_x); | 177 bounds.set_x(*next_x); |
| 177 *next_x += bounds.size().width(); | 178 *next_x += bounds.size().width(); |
| 178 gfx::Insets work_area_insets = | 179 display::Display updated_display = |
| 179 root_window_controller->display_.GetWorkAreaInsets(); | 180 root_window_controller->GetWindow()->GetDisplayNearestWindow(); |
| 180 root_window_controller->display_.set_bounds(bounds); | 181 gfx::Insets work_area_insets = updated_display.GetWorkAreaInsets(); |
| 181 root_window_controller->display_.UpdateWorkAreaFromInsets(work_area_insets); | 182 updated_display.set_bounds(bounds); |
| 182 root_window_controller->root()->SetBounds(gfx::Rect(bounds.size())); | 183 updated_display.UpdateWorkAreaFromInsets(work_area_insets); |
| 184 root_window_controller->GetWindow()->SetBounds(gfx::Rect(bounds.size())); |
| 183 ScreenMus* screen = window_manager_app_->window_manager()->screen_.get(); | 185 ScreenMus* screen = window_manager_app_->window_manager()->screen_.get(); |
| 184 const bool is_primary = screen->display_list().FindDisplayById( | 186 const bool is_primary = |
| 185 root_window_controller->display().id()) == | 187 screen->display_list().FindDisplayById(updated_display.id()) == |
| 186 screen->display_list().GetPrimaryDisplayIterator(); | 188 screen->display_list().GetPrimaryDisplayIterator(); |
| 187 screen->display_list().UpdateDisplay( | 189 screen->display_list().UpdateDisplay( |
| 188 root_window_controller->display(), | 190 updated_display, is_primary ? display::DisplayList::Type::PRIMARY |
| 189 is_primary ? display::DisplayList::Type::PRIMARY | 191 : display::DisplayList::Type::NOT_PRIMARY); |
| 190 : display::DisplayList::Type::NOT_PRIMARY); | |
| 191 } | 192 } |
| 192 | 193 |
| 193 } // namespace mus | 194 } // namespace mus |
| 194 } // namespace ash | 195 } // namespace ash |
| OLD | NEW |