Commit 43dc520f authored by Alice Boxhall's avatar Alice Boxhall Committed by Commit Bot

Revert "X11Window: Avoid size hack for tests"

This reverts commit da320a9f.

Reason for revert: Unfortunately this seems to be causing a CI failure: 
https://logs.chromium.org/logs/chromium/buildbucket/cr-buildbucket.appspot.com/8898137098615237856/+/steps/aura_unittests/0/logs/Deterministic_failure:_WindowTreeHostTest.DPIWindowSize__status_FAILURE_/0

Original change's description:
> 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: Michael Spang <spang@chromium.org>
> Reviewed-by: Scott Violet <sky@chromium.org>
> Reviewed-by: Thomas Anderson <thomasanderson@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#710955}

TBR=sky@chromium.org,spang@chromium.org,thomasanderson@chromium.org,msisov@igalia.com

Change-Id: I1177d258e4957dc1f216e18c6df95067f7cbb0ed
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1019015
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1890458Reviewed-by: default avatarAlice Boxhall <aboxhall@chromium.org>
Commit-Queue: Alice Boxhall <aboxhall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#711094}
parent ed064683
......@@ -20,26 +20,50 @@
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;
TEST_F(WindowTreeHostTest, DPIWindowSize) {
gfx::Rect starting_bounds(0, 0, 800, 600);
gfx::Rect starting_bounds = host()->GetBoundsInPixels();
EXPECT_EQ(starting_bounds.size(), host()->compositor()->size());
EXPECT_EQ(starting_bounds, host()->GetBoundsInPixels());
EXPECT_EQ(starting_bounds, root_window()->bounds());
test_screen()->SetDeviceScaleFactor(1.5f);
float device_scale_factor = 1.5;
test_screen()->SetDeviceScaleFactor(device_scale_factor);
EXPECT_EQ(starting_bounds, host()->GetBoundsInPixels());
// Size should be rounded up after scaling.
EXPECT_EQ(gfx::Rect(0, 0, 534, 400), root_window()->bounds());
gfx::Rect rect_in_dip = ScaleRect(starting_bounds, device_scale_factor);
EXPECT_EQ(rect_in_dip, root_window()->bounds());
gfx::Transform transform;
transform.Translate(0, 1.1f);
host()->SetRootTransform(transform);
EXPECT_EQ(gfx::Rect(0, 1, 534, 401), root_window()->bounds());
gfx::Rect transformed_rect =
TransformRect(starting_bounds, transform, device_scale_factor);
EXPECT_EQ(transformed_rect, root_window()->bounds());
EXPECT_EQ(starting_bounds, host()->GetBoundsInPixels());
EXPECT_EQ(gfx::Rect(0, 1, 534, 401), root_window()->bounds());
EXPECT_EQ(transformed_rect, root_window()->bounds());
}
#if defined(OS_CHROMEOS)
......
......@@ -23,7 +23,6 @@ jumbo_component("x11") {
"//ui/events/platform/x11",
"//ui/gfx/x",
"//ui/platform_window",
"//ui/platform_window/common",
"//ui/platform_window/platform_window_handler",
]
......
......@@ -15,7 +15,6 @@
#include "ui/events/platform/platform_event_source.h"
#include "ui/events/platform/x11/x11_event_source.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/x11/x11_window_manager.h"
......@@ -618,7 +617,7 @@ gfx::Size X11Window::AdjustSizeForDisplay(
return requested_size_in_pixels;
#else
auto* screen = display::Screen::GetScreen();
if (screen && !UseTestConfigForPlatformWindows()) {
if (screen) {
std::vector<display::Display> displays = screen->GetAllDisplays();
// Compare against all monitor sizes. The window manager can move the window
// 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