Commit da320a9f authored by Michael Spang's avatar Michael Spang Committed by Commit Bot

X11Window: Avoid size hack for tests

The default configuration of TestScreen is to create one display and one
WindowTreeHost with the same size.

X11 is now incompatible with this requirement as of b14e13fd ("Reland
"X11 and Ozone: DWTHPlatform handles Show/Hide/Max/Restore/Full"").

Several aura tests are only passing currently due to another bug in
DisplayList::UpdateDisplay, which prevents X11Window from
seeing the current display size and enforcing the constraint.

Other tests only work because TestScreen resizes the display to match
the WindowTreeHost /after/ X11Window deletes the last row and column.
i.e., X11Window tries to adjust the size to not match the display,
and then TestScreen re-adjusts the display to match the window. This
behavior is not convergent and causes small changes in initialization
order to affect the dimensions of test windows.

This hack should likely be removed altogether and the bug it's addressing
fixed another way, but for now disable it in the test harness because it
is blocking other changes such as a fix for the UpdateDisplay bug noted
above.

Bug: 1019015

Change-Id: I79e830b9c35df3df29dc8af50ac424076682d180
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1889294
Commit-Queue: Michael Spang <spang@chromium.org>
Reviewed-by: default avatarMichael Spang <spang@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarThomas Anderson <thomasanderson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710955}
parent 7e1ba06d
...@@ -20,50 +20,26 @@ ...@@ -20,50 +20,26 @@
namespace aura { namespace aura {
namespace {
gfx::Rect ScaleRect(const gfx::Rect& rect_in_pixels, float scale) {
gfx::RectF rect_in_dip(rect_in_pixels);
gfx::Transform transform;
transform.Scale(scale, scale);
transform.TransformRectReverse(&rect_in_dip);
return gfx::ToEnclosingRect(rect_in_dip);
}
gfx::Rect TransformRect(const gfx::Rect& rect_in_pixels,
const gfx::Transform& transform,
float device_scale_factor) {
gfx::RectF new_bounds =
gfx::ScaleRect(gfx::RectF(rect_in_pixels), 1.0f / device_scale_factor);
transform.TransformRect(&new_bounds);
return gfx::ToEnclosingRect(new_bounds);
}
} // namespace
using WindowTreeHostTest = test::AuraTestBase; using WindowTreeHostTest = test::AuraTestBase;
TEST_F(WindowTreeHostTest, DPIWindowSize) { TEST_F(WindowTreeHostTest, DPIWindowSize) {
gfx::Rect starting_bounds = host()->GetBoundsInPixels(); gfx::Rect starting_bounds(0, 0, 800, 600);
EXPECT_EQ(starting_bounds.size(), host()->compositor()->size()); EXPECT_EQ(starting_bounds.size(), host()->compositor()->size());
EXPECT_EQ(starting_bounds, host()->GetBoundsInPixels());
EXPECT_EQ(starting_bounds, root_window()->bounds()); EXPECT_EQ(starting_bounds, root_window()->bounds());
float device_scale_factor = 1.5; test_screen()->SetDeviceScaleFactor(1.5f);
test_screen()->SetDeviceScaleFactor(device_scale_factor);
EXPECT_EQ(starting_bounds, host()->GetBoundsInPixels()); EXPECT_EQ(starting_bounds, host()->GetBoundsInPixels());
// Size should be rounded up after scaling. // Size should be rounded up after scaling.
gfx::Rect rect_in_dip = ScaleRect(starting_bounds, device_scale_factor); EXPECT_EQ(gfx::Rect(0, 0, 534, 400), root_window()->bounds());
EXPECT_EQ(rect_in_dip, root_window()->bounds());
gfx::Transform transform; gfx::Transform transform;
transform.Translate(0, 1.1f); transform.Translate(0, 1.1f);
host()->SetRootTransform(transform); host()->SetRootTransform(transform);
gfx::Rect transformed_rect = EXPECT_EQ(gfx::Rect(0, 1, 534, 401), root_window()->bounds());
TransformRect(starting_bounds, transform, device_scale_factor);
EXPECT_EQ(transformed_rect, root_window()->bounds());
EXPECT_EQ(starting_bounds, host()->GetBoundsInPixels()); EXPECT_EQ(starting_bounds, host()->GetBoundsInPixels());
EXPECT_EQ(transformed_rect, root_window()->bounds()); EXPECT_EQ(gfx::Rect(0, 1, 534, 401), root_window()->bounds());
} }
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
......
...@@ -23,6 +23,7 @@ jumbo_component("x11") { ...@@ -23,6 +23,7 @@ jumbo_component("x11") {
"//ui/events/platform/x11", "//ui/events/platform/x11",
"//ui/gfx/x", "//ui/gfx/x",
"//ui/platform_window", "//ui/platform_window",
"//ui/platform_window/common",
"//ui/platform_window/platform_window_handler", "//ui/platform_window/platform_window_handler",
] ]
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "ui/events/platform/platform_event_source.h" #include "ui/events/platform/platform_event_source.h"
#include "ui/events/platform/x11/x11_event_source.h" #include "ui/events/platform/x11/x11_event_source.h"
#include "ui/gfx/x/x11.h" #include "ui/gfx/x/x11.h"
#include "ui/platform_window/common/platform_window_defaults.h"
#include "ui/platform_window/platform_window_delegate_linux.h" #include "ui/platform_window/platform_window_delegate_linux.h"
#include "ui/platform_window/x11/x11_window_manager.h" #include "ui/platform_window/x11/x11_window_manager.h"
...@@ -617,7 +618,7 @@ gfx::Size X11Window::AdjustSizeForDisplay( ...@@ -617,7 +618,7 @@ gfx::Size X11Window::AdjustSizeForDisplay(
return requested_size_in_pixels; return requested_size_in_pixels;
#else #else
auto* screen = display::Screen::GetScreen(); auto* screen = display::Screen::GetScreen();
if (screen) { if (screen && !UseTestConfigForPlatformWindows()) {
std::vector<display::Display> displays = screen->GetAllDisplays(); std::vector<display::Display> displays = screen->GetAllDisplays();
// Compare against all monitor sizes. The window manager can move the window // Compare against all monitor sizes. The window manager can move the window
// to whichever monitor it wants. // to whichever monitor it wants.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment