ceftests: Merge ViewsWindowTest fixes to M129 (see #3188)

This commit is contained in:
Marshall Greenblatt 2024-09-30 13:36:52 -04:00
parent fda35ba29a
commit e52707f8c9
1 changed files with 36 additions and 11 deletions

View File

@ -145,11 +145,36 @@ void WindowCreateMaximizedImpl(CefRefPtr<CefWaitableEvent> event) {
TestWindowDelegate::RunTest(event, std::move(config));
}
#if defined(OS_MAC)
void WindowFullscreenCreationComplete(CefRefPtr<CefWindow> window,
size_t count) {
EXPECT_FALSE(window->IsMinimized());
EXPECT_EQ(window->IsFullscreen(), window->IsMaximized());
if (window->IsFullscreen()) {
EXPECT_EQ(1U, count);
window->SetFullscreen(false);
} else {
EXPECT_EQ(2U, count);
// End the test by closing the Window.
window->Close();
}
}
#endif
void WindowCreateFullscreenImpl(CefRefPtr<CefWaitableEvent> event) {
auto config = std::make_unique<TestWindowDelegate::Config>();
config->initial_show_state = CEF_SHOW_STATE_FULLSCREEN;
config->on_window_created =
base::BindOnce(RunWindowShow, config->initial_show_state);
#if defined(OS_MAC)
// On macOS, destroying a fullscreen window can take a long time.
// To prevent the next test from starting before the window is fully closed,
// we need to exit fullscreen mode before closing the window.
config->on_window_fullscreen_transition_complete =
base::BindRepeating(WindowFullscreenCreationComplete);
config->close_window = false;
#endif
TestWindowDelegate::RunTest(event, std::move(config));
}
@ -215,9 +240,9 @@ void CreateBoxLayout(CefRefPtr<CefWindow> parent) {
// The children should each take up 50% of the client area.
ExpectCloseRects(CefRect(0, 0, kWSize, kWSize / 2), panel_child1->GetBounds(),
2);
3);
ExpectCloseRects(CefRect(0, kWSize / 2, kWSize, kWSize / 2),
panel_child2->GetBounds(), 2);
panel_child2->GetBounds(), 3);
}
void RunWindowLayoutAndCoords(CefRefPtr<CefWindow> window) {
@ -242,7 +267,7 @@ void RunWindowLayoutAndCoords(CefRefPtr<CefWindow> window) {
EXPECT_TRUE(view2->ConvertPointToScreen(point));
ExpectClosePoints(CefPoint(client_bounds_in_screen.x,
client_bounds_in_screen.y + kWSize / 2),
point, 1);
point, 3);
// Test view from screen coordinate conversions.
point = CefPoint(client_bounds_in_screen.x, client_bounds_in_screen.y);
@ -251,7 +276,7 @@ void RunWindowLayoutAndCoords(CefRefPtr<CefWindow> window) {
point = CefPoint(client_bounds_in_screen.x,
client_bounds_in_screen.y + kWSize / 2);
EXPECT_TRUE(view2->ConvertPointFromScreen(point));
ExpectClosePoints(CefPoint(0, 0), point, 1);
ExpectClosePoints(CefPoint(0, 0), point, 3);
// Test view to window coordinate conversions.
point = CefPoint(0, 0);
@ -259,7 +284,7 @@ void RunWindowLayoutAndCoords(CefRefPtr<CefWindow> window) {
EXPECT_EQ(CefPoint(0, 0), point);
point = CefPoint(0, 0);
EXPECT_TRUE(view2->ConvertPointToWindow(point));
ExpectClosePoints(CefPoint(0, kWSize / 2), point, 1);
ExpectClosePoints(CefPoint(0, kWSize / 2), point, 3);
// Test view from window coordinate conversions.
point = CefPoint(0, 0);
@ -267,23 +292,23 @@ void RunWindowLayoutAndCoords(CefRefPtr<CefWindow> window) {
EXPECT_EQ(CefPoint(0, 0), point);
point = CefPoint(0, kWSize / 2);
EXPECT_TRUE(view2->ConvertPointFromWindow(point));
ExpectClosePoints(CefPoint(0, 0), point, 1);
ExpectClosePoints(CefPoint(0, 0), point, 3);
// Test view to view coordinate conversions.
point = CefPoint(0, 0);
EXPECT_TRUE(view1->ConvertPointToView(view2, point));
ExpectClosePoints(CefPoint(0, -kWSize / 2), point, 1);
ExpectClosePoints(CefPoint(0, -kWSize / 2), point, 3);
point = CefPoint(0, 0);
EXPECT_TRUE(view2->ConvertPointToView(view1, point));
ExpectClosePoints(CefPoint(0, kWSize / 2), point, 1);
ExpectClosePoints(CefPoint(0, kWSize / 2), point, 3);
// Test view from view coordinate conversions.
point = CefPoint(0, -kWSize / 2);
EXPECT_TRUE(view1->ConvertPointFromView(view2, point));
ExpectClosePoints(CefPoint(0, 0), point, 1);
ExpectClosePoints(CefPoint(0, 0), point, 3);
point = CefPoint(0, kWSize / 2);
EXPECT_TRUE(view2->ConvertPointFromView(view1, point));
ExpectClosePoints(CefPoint(0, 0), point, 1);
ExpectClosePoints(CefPoint(0, 0), point, 3);
CefRefPtr<CefDisplay> display = window->GetDisplay();
EXPECT_TRUE(display.get());
@ -299,7 +324,7 @@ void RunWindowLayoutAndCoords(CefRefPtr<CefWindow> window) {
point = CefPoint(client_bounds_in_screen.x, client_bounds_in_screen.y);
const auto pixels = CefDisplay::ConvertScreenPointToPixels(point);
const auto dip = CefDisplay::ConvertScreenPointFromPixels(pixels);
EXPECT_EQ(point, dip);
ExpectClosePoints(point, dip, 1);
}
void WindowLayoutAndCoordsImpl(CefRefPtr<CefWaitableEvent> event) {