[headless] Delete obsolete --window-size C++ tests
These tests are replaced by JS --window-size tests added with http://crrev.com/c/6553983. Change-Id: Idfab2f3f8a00eb4dde6a60aa75e1814fbaff2fd9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6554565 Reviewed-by: Andrey Kosyakov <caseq@chromium.org> Auto-Submit: Peter Kvitek <kvitekp@chromium.org> Commit-Queue: Andrey Kosyakov <caseq@chromium.org> Cr-Commit-Position: refs/heads/main@{#1461105}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
bb0d5428be
commit
896e5027f2
@ -130,23 +130,6 @@ void HeadlessModeBrowserTestWithStartWindowMode::SetUpCommandLine(
|
||||
}
|
||||
}
|
||||
|
||||
void HeadlessModeBrowserTestWithWindowSize::SetUpCommandLine(
|
||||
base::CommandLine* command_line) {
|
||||
HeadlessModeBrowserTest::SetUpCommandLine(command_line);
|
||||
command_line->AppendSwitchASCII(
|
||||
::switches::kWindowSize,
|
||||
base::StringPrintf("%u,%u", kWindowSize.width(), kWindowSize.height()));
|
||||
}
|
||||
|
||||
void HeadlessModeBrowserTestWithWindowSizeAndScale::SetUpCommandLine(
|
||||
base::CommandLine* command_line) {
|
||||
HeadlessModeBrowserTest::SetUpCommandLine(command_line);
|
||||
command_line->AppendSwitchASCII(
|
||||
::switches::kWindowSize,
|
||||
base::StringPrintf("%u,%u", kWindowSize.width(), kWindowSize.height()));
|
||||
command_line->AppendSwitchASCII(::switches::kForceDeviceScaleFactor, "1.5");
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
// Miscellaneous tests -------------------------------------------------------
|
||||
|
@ -65,27 +65,6 @@ class HeadlessModeBrowserTestWithStartWindowMode
|
||||
// Toggles browser fullscreen mode synchronously.
|
||||
void ToggleFullscreenModeSync(Browser* browser);
|
||||
|
||||
class HeadlessModeBrowserTestWithWindowSize : public HeadlessModeBrowserTest {
|
||||
public:
|
||||
static constexpr gfx::Size kWindowSize = {4096, 2160};
|
||||
|
||||
HeadlessModeBrowserTestWithWindowSize() = default;
|
||||
~HeadlessModeBrowserTestWithWindowSize() override = default;
|
||||
|
||||
void SetUpCommandLine(base::CommandLine* command_line) override;
|
||||
};
|
||||
|
||||
class HeadlessModeBrowserTestWithWindowSizeAndScale
|
||||
: public HeadlessModeBrowserTest {
|
||||
public:
|
||||
static constexpr gfx::Size kWindowSize = {800, 600};
|
||||
|
||||
HeadlessModeBrowserTestWithWindowSizeAndScale() = default;
|
||||
~HeadlessModeBrowserTestWithWindowSizeAndScale() override = default;
|
||||
|
||||
void SetUpCommandLine(base::CommandLine* command_line) override;
|
||||
};
|
||||
|
||||
} // namespace headless
|
||||
|
||||
#endif // CHROME_BROWSER_HEADLESS_HEADLESS_MODE_BROWSERTEST_H_
|
||||
|
@ -90,44 +90,6 @@ IN_PROC_BROWSER_TEST_P(HeadlessModeBrowserTestWithStartWindowMode,
|
||||
EXPECT_TRUE(browser()->window()->IsVisible());
|
||||
}
|
||||
|
||||
IN_PROC_BROWSER_TEST_F(HeadlessModeBrowserTestWithWindowSize, LargeWindowSize) {
|
||||
ui::PlatformWindow* platform_window = GetPlatformWindow(browser());
|
||||
|
||||
// Expect the platform window size to be the same as the requested window
|
||||
// size because Ozone/headless is not clamping the platform window dimensions
|
||||
// to the screen size which in this case is default 800x600 pixels.
|
||||
gfx::Rect pixel_bounds = platform_window->GetBoundsInPixels();
|
||||
EXPECT_EQ(pixel_bounds.width(), kWindowSize.width());
|
||||
EXPECT_EQ(pixel_bounds.height(), kWindowSize.height());
|
||||
|
||||
// Expect the reported browser window size to be the same as the requested
|
||||
// window size.
|
||||
gfx::Rect bounds = browser()->window()->GetBounds();
|
||||
EXPECT_EQ(bounds.size(), kWindowSize);
|
||||
}
|
||||
|
||||
IN_PROC_BROWSER_TEST_F(HeadlessModeBrowserTestWithWindowSizeAndScale,
|
||||
WindowSizeWithScale) {
|
||||
ui::PlatformWindow* platform_window = GetPlatformWindow(browser());
|
||||
|
||||
// Expect the platform window size in pixels to be larger than the requested
|
||||
// window size due to scaling.
|
||||
gfx::Rect pixel_bounds = platform_window->GetBoundsInPixels();
|
||||
EXPECT_GT(pixel_bounds.width(), kWindowSize.width());
|
||||
EXPECT_GT(pixel_bounds.height(), kWindowSize.height());
|
||||
|
||||
// Expect the platform window size in DIPs to be the same as the requested
|
||||
// window size despite the scaling.
|
||||
gfx::Rect dip_bounds = platform_window->GetBoundsInDIP();
|
||||
EXPECT_EQ(dip_bounds.width(), kWindowSize.width());
|
||||
EXPECT_EQ(dip_bounds.height(), kWindowSize.height());
|
||||
|
||||
// Expect the reported browser window size to be the same as the requested
|
||||
// window size despite the scaling.
|
||||
gfx::Rect bounds = browser()->window()->GetBounds();
|
||||
EXPECT_EQ(bounds.size(), kWindowSize);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
} // namespace headless
|
||||
|
@ -137,40 +137,6 @@ IN_PROC_BROWSER_TEST_F(HeadlessModeBrowserTest,
|
||||
EXPECT_FALSE(ns_window.visible);
|
||||
}
|
||||
|
||||
IN_PROC_BROWSER_TEST_F(HeadlessModeBrowserTestWithWindowSize, LargeWindowSize) {
|
||||
gfx::NativeWindow native_window = browser()->window()->GetNativeWindow();
|
||||
NSWindow* ns_window = native_window.GetNativeNSWindow();
|
||||
|
||||
// Expect the platform window size to be the same as the requested window
|
||||
// size.
|
||||
NSRect frame_rect = [ns_window frame];
|
||||
EXPECT_EQ(NSWidth(frame_rect), kWindowSize.width());
|
||||
EXPECT_EQ(NSHeight(frame_rect), kWindowSize.height());
|
||||
|
||||
// Expect the reported browser window size to be the same as the requested
|
||||
// window size.
|
||||
gfx::Rect bounds = browser()->window()->GetBounds();
|
||||
EXPECT_EQ(bounds.size(), kWindowSize);
|
||||
}
|
||||
|
||||
IN_PROC_BROWSER_TEST_F(HeadlessModeBrowserTestWithWindowSizeAndScale,
|
||||
WindowSizeWithScale) {
|
||||
gfx::NativeWindow native_window = browser()->window()->GetNativeWindow();
|
||||
NSWindow* ns_window = native_window.GetNativeNSWindow();
|
||||
|
||||
// Expect the platform window size to be the same as the requested window size
|
||||
// due to scaling because Mac does not appear to support device scaling at
|
||||
// this time.
|
||||
NSRect frame_rect = [ns_window frame];
|
||||
EXPECT_EQ(NSWidth(frame_rect), kWindowSize.width());
|
||||
EXPECT_EQ(NSHeight(frame_rect), kWindowSize.height());
|
||||
|
||||
// Expect the reported browser window size to be the same as the requested
|
||||
// window size.
|
||||
gfx::Rect bounds = browser()->window()->GetBounds();
|
||||
EXPECT_EQ(bounds.size(), kWindowSize);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
} // namespace headless
|
||||
|
@ -188,46 +188,6 @@ IN_PROC_BROWSER_TEST_F(HeadlessModeBrowserTest,
|
||||
EXPECT_FALSE(::IsWindowVisible(desktop_window_hwnd));
|
||||
}
|
||||
|
||||
IN_PROC_BROWSER_TEST_F(HeadlessModeBrowserTestWithWindowSize, LargeWindowSize) {
|
||||
DesktopWindowTreeHostWinWrapper* desktop_window_tree_host =
|
||||
static_cast<DesktopWindowTreeHostWinWrapper*>(
|
||||
browser()->window()->GetNativeWindow()->GetHost());
|
||||
HWND desktop_window_hwnd = desktop_window_tree_host->GetHWND();
|
||||
|
||||
// Expect the platform window size to be smaller than the requested window
|
||||
// size due to Windows clamping the window dimensions to the monitor work
|
||||
// area.
|
||||
RECT platform_window_rect;
|
||||
CHECK(::GetWindowRect(desktop_window_hwnd, &platform_window_rect));
|
||||
EXPECT_LT(gfx::Rect(platform_window_rect).width(), kWindowSize.width());
|
||||
EXPECT_LT(gfx::Rect(platform_window_rect).height(), kWindowSize.height());
|
||||
|
||||
// Expect the reported browser window size to be the same as the requested
|
||||
// window size.
|
||||
gfx::Rect bounds = browser()->window()->GetBounds();
|
||||
EXPECT_EQ(bounds.size(), kWindowSize);
|
||||
}
|
||||
|
||||
IN_PROC_BROWSER_TEST_F(HeadlessModeBrowserTestWithWindowSizeAndScale,
|
||||
WindowSizeWithScale) {
|
||||
DesktopWindowTreeHostWinWrapper* desktop_window_tree_host =
|
||||
static_cast<DesktopWindowTreeHostWinWrapper*>(
|
||||
browser()->window()->GetNativeWindow()->GetHost());
|
||||
HWND desktop_window_hwnd = desktop_window_tree_host->GetHWND();
|
||||
|
||||
// Expect the platform window size to be larger than the requested window size
|
||||
// due to scaling.
|
||||
RECT platform_window_rect;
|
||||
CHECK(::GetWindowRect(desktop_window_hwnd, &platform_window_rect));
|
||||
EXPECT_GT(gfx::Rect(platform_window_rect).width(), kWindowSize.width());
|
||||
EXPECT_GT(gfx::Rect(platform_window_rect).height(), kWindowSize.height());
|
||||
|
||||
// Expect the reported browser window size to be the same as the requested
|
||||
// window size.
|
||||
gfx::Rect bounds = browser()->window()->GetBounds();
|
||||
EXPECT_EQ(bounds.size(), kWindowSize);
|
||||
}
|
||||
|
||||
// display::win::ScreenWinHeadless tests -------------------------------------
|
||||
|
||||
class HeadlessModeBrowserTestWithScreenInfo : public HeadlessModeBrowserTest {
|
||||
|
@ -368,44 +368,6 @@ IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest, DefaultSizes) {
|
||||
DictHasValue("result.result.value", expected_height));
|
||||
}
|
||||
|
||||
class HeadlessBrowserWindowSizeTest : public HeadlessBrowserTest {
|
||||
public:
|
||||
static constexpr gfx::Size kWindowSize = {1920, 1080};
|
||||
|
||||
void SetUpCommandLine(base::CommandLine* command_line) override {
|
||||
HeadlessBrowserTest::SetUpCommandLine(command_line);
|
||||
command_line->AppendSwitchASCII(
|
||||
switches::kWindowSize,
|
||||
base::StringPrintf("%u,%u", kWindowSize.width(), kWindowSize.height()));
|
||||
}
|
||||
};
|
||||
|
||||
IN_PROC_BROWSER_TEST_F(HeadlessBrowserWindowSizeTest, WindowSize) {
|
||||
HeadlessBrowserContext* browser_context =
|
||||
browser()->CreateBrowserContextBuilder().Build();
|
||||
|
||||
HeadlessWebContents* web_contents =
|
||||
browser_context->CreateWebContentsBuilder().Build();
|
||||
|
||||
const int expected_width = kWindowSize.width();
|
||||
const int expected_height = kWindowSize.height();
|
||||
|
||||
EXPECT_THAT(EvaluateScript(web_contents, "screen.width"),
|
||||
DictHasValue("result.result.value", expected_width));
|
||||
EXPECT_THAT(EvaluateScript(web_contents, "screen.height"),
|
||||
DictHasValue("result.result.value", expected_height));
|
||||
|
||||
EXPECT_THAT(EvaluateScript(web_contents, "window.outerWidth"),
|
||||
DictHasValue("result.result.value", expected_width));
|
||||
EXPECT_THAT(EvaluateScript(web_contents, "window.outerHeight"),
|
||||
DictHasValue("result.result.value", expected_height));
|
||||
|
||||
EXPECT_THAT(EvaluateScript(web_contents, "window.innerWidth"),
|
||||
DictHasValue("result.result.value", expected_width));
|
||||
EXPECT_THAT(EvaluateScript(web_contents, "window.innerHeight"),
|
||||
DictHasValue("result.result.value", expected_height));
|
||||
}
|
||||
|
||||
// TODO(skyostil): This test currently relies on being able to run a shell
|
||||
// script.
|
||||
#if BUILDFLAG(IS_POSIX)
|
||||
|
Reference in New Issue
Block a user