| Index: ui/aura/test/test_screen.cc
|
| diff --git a/ui/aura/test/test_screen.cc b/ui/aura/test/test_screen.cc
|
| index 4bfb697e9b33be7fd4d9a54d8eef3eff32a8e14b..20e13827be9c676f365512df73404b00ee4766dc 100644
|
| --- a/ui/aura/test/test_screen.cc
|
| +++ b/ui/aura/test/test_screen.cc
|
| @@ -14,7 +14,6 @@
|
| #include "ui/aura/window_event_dispatcher.h"
|
| #include "ui/aura/window_tree_host.h"
|
| #include "ui/base/ime/input_method.h"
|
| -#include "ui/display/screen.h"
|
| #include "ui/gfx/geometry/rect_conversions.h"
|
| #include "ui/gfx/geometry/size_conversions.h"
|
| #include "ui/gfx/native_widget_types.h"
|
| @@ -40,16 +39,16 @@ TestScreen* TestScreen::Create(const gfx::Size& size,
|
| window_tree_client);
|
| }
|
|
|
| -TestScreen::~TestScreen() {
|
| -}
|
| +TestScreen::~TestScreen() {}
|
|
|
| WindowTreeHost* TestScreen::CreateHostForPrimaryDisplay() {
|
| DCHECK(!host_);
|
| if (window_tree_client_) {
|
| host_ = WindowTreeClientPrivate(window_tree_client_)
|
| - .CallWmNewDisplayAdded(display_);
|
| + .CallWmNewDisplayAdded(GetPrimaryDisplay());
|
| } else {
|
| - host_ = WindowTreeHost::Create(gfx::Rect(display_.GetSizeInPixel()));
|
| + host_ =
|
| + WindowTreeHost::Create(gfx::Rect(GetPrimaryDisplay().GetSizeInPixel()));
|
| }
|
| // Some tests don't correctly manage window focus/activation states.
|
| // Makes sure InputMethod is default focused so that IME basics can work.
|
| @@ -60,56 +59,60 @@ WindowTreeHost* TestScreen::CreateHostForPrimaryDisplay() {
|
| }
|
|
|
| void TestScreen::SetDeviceScaleFactor(float device_scale_factor) {
|
| - gfx::Rect bounds_in_pixel(display_.GetSizeInPixel());
|
| - display_.SetScaleAndBounds(device_scale_factor, bounds_in_pixel);
|
| + display::Display display(GetPrimaryDisplay());
|
| + gfx::Rect bounds_in_pixel(display.GetSizeInPixel());
|
| + display.SetScaleAndBounds(device_scale_factor, bounds_in_pixel);
|
| + display_list().UpdateDisplay(display);
|
| host_->OnHostResized(bounds_in_pixel.size());
|
| }
|
|
|
| void TestScreen::SetDisplayRotation(display::Display::Rotation rotation) {
|
| - gfx::Rect bounds_in_pixel(display_.GetSizeInPixel());
|
| + display::Display display(GetPrimaryDisplay());
|
| + gfx::Rect bounds_in_pixel(display.GetSizeInPixel());
|
| gfx::Rect new_bounds(bounds_in_pixel);
|
| - if (IsRotationPortrait(rotation) != IsRotationPortrait(display_.rotation())) {
|
| + if (IsRotationPortrait(rotation) != IsRotationPortrait(display.rotation())) {
|
| new_bounds.set_width(bounds_in_pixel.height());
|
| new_bounds.set_height(bounds_in_pixel.width());
|
| }
|
| - display_.set_rotation(rotation);
|
| - display_.SetScaleAndBounds(display_.device_scale_factor(), new_bounds);
|
| + display.set_rotation(rotation);
|
| + display.SetScaleAndBounds(display.device_scale_factor(), new_bounds);
|
| + display_list().UpdateDisplay(display);
|
| host_->SetRootTransform(GetRotationTransform() * GetUIScaleTransform());
|
| }
|
|
|
| void TestScreen::SetUIScale(float ui_scale) {
|
| ui_scale_ = ui_scale;
|
| - gfx::Rect bounds_in_pixel(display_.GetSizeInPixel());
|
| + display::Display display(GetPrimaryDisplay());
|
| + gfx::Rect bounds_in_pixel(display.GetSizeInPixel());
|
| gfx::Rect new_bounds = gfx::ToNearestRect(
|
| gfx::ScaleRect(gfx::RectF(bounds_in_pixel), 1.0f / ui_scale));
|
| - display_.SetScaleAndBounds(display_.device_scale_factor(), new_bounds);
|
| + display.SetScaleAndBounds(display.device_scale_factor(), new_bounds);
|
| + display_list().UpdateDisplay(display);
|
| host_->SetRootTransform(GetRotationTransform() * GetUIScaleTransform());
|
| }
|
|
|
| void TestScreen::SetWorkAreaInsets(const gfx::Insets& insets) {
|
| - display_.UpdateWorkAreaFromInsets(insets);
|
| -}
|
| -
|
| -display::Display TestScreen::GetPrimaryDisplay() const {
|
| - return display_;
|
| + display::Display display(GetPrimaryDisplay());
|
| + display.UpdateWorkAreaFromInsets(insets);
|
| + display_list().UpdateDisplay(display);
|
| }
|
|
|
| gfx::Transform TestScreen::GetRotationTransform() const {
|
| gfx::Transform rotate;
|
| - switch (display_.rotation()) {
|
| + display::Display display(GetPrimaryDisplay());
|
| + switch (display.rotation()) {
|
| case display::Display::ROTATE_0:
|
| break;
|
| case display::Display::ROTATE_90:
|
| - rotate.Translate(display_.bounds().height(), 0);
|
| + rotate.Translate(display.bounds().height(), 0);
|
| rotate.Rotate(90);
|
| break;
|
| case display::Display::ROTATE_270:
|
| - rotate.Translate(0, display_.bounds().width());
|
| + rotate.Translate(0, display.bounds().width());
|
| rotate.Rotate(270);
|
| break;
|
| case display::Display::ROTATE_180:
|
| - rotate.Translate(display_.bounds().width(),
|
| - display_.bounds().height());
|
| + rotate.Translate(display.bounds().width(), display.bounds().height());
|
| rotate.Rotate(180);
|
| break;
|
| }
|
| @@ -126,8 +129,10 @@ gfx::Transform TestScreen::GetUIScaleTransform() const {
|
| void TestScreen::OnWindowBoundsChanged(
|
| Window* window, const gfx::Rect& old_bounds, const gfx::Rect& new_bounds) {
|
| DCHECK_EQ(host_->window(), window);
|
| - display_.SetSize(gfx::ScaleToFlooredSize(new_bounds.size(),
|
| - display_.device_scale_factor()));
|
| + display::Display display(GetPrimaryDisplay());
|
| + display.SetSize(gfx::ScaleToFlooredSize(new_bounds.size(),
|
| + display.device_scale_factor()));
|
| + display_list().UpdateDisplay(display);
|
| }
|
|
|
| void TestScreen::OnWindowDestroying(Window* window) {
|
| @@ -149,39 +154,18 @@ gfx::NativeWindow TestScreen::GetWindowAtScreenPoint(const gfx::Point& point) {
|
| return host_->window()->GetTopWindowContainingPoint(point);
|
| }
|
|
|
| -int TestScreen::GetNumDisplays() const {
|
| - return 1;
|
| -}
|
| -
|
| -std::vector<display::Display> TestScreen::GetAllDisplays() const {
|
| - return std::vector<display::Display>(1, display_);
|
| -}
|
| -
|
| display::Display TestScreen::GetDisplayNearestWindow(
|
| gfx::NativeWindow window) const {
|
| - return display_;
|
| + return GetPrimaryDisplay();
|
| }
|
|
|
| -display::Display TestScreen::GetDisplayNearestPoint(
|
| - const gfx::Point& point) const {
|
| - return display_;
|
| -}
|
| -
|
| -display::Display TestScreen::GetDisplayMatching(
|
| - const gfx::Rect& match_rect) const {
|
| - return display_;
|
| -}
|
| -
|
| -void TestScreen::AddObserver(display::DisplayObserver* observer) {}
|
| -
|
| -void TestScreen::RemoveObserver(display::DisplayObserver* observer) {}
|
| -
|
| TestScreen::TestScreen(const gfx::Rect& screen_bounds,
|
| WindowTreeClient* window_tree_client)
|
| : host_(nullptr), ui_scale_(1.0f), window_tree_client_(window_tree_client) {
|
| static int64_t synthesized_display_id = 2000;
|
| - display_.set_id(synthesized_display_id++);
|
| - display_.SetScaleAndBounds(1.0f, screen_bounds);
|
| + display::Display display(synthesized_display_id++);
|
| + display.SetScaleAndBounds(1.0f, screen_bounds);
|
| + ProcessDisplayChanged(display, true /* is_primary */);
|
| }
|
|
|
| } // namespace aura
|
|
|