diff --git a/tests/ceftests/views/window_unittest.cc b/tests/ceftests/views/window_unittest.cc index d2dbac857..24e9ccf26 100644 --- a/tests/ceftests/views/window_unittest.cc +++ b/tests/ceftests/views/window_unittest.cc @@ -145,11 +145,36 @@ void WindowCreateMaximizedImpl(CefRefPtr event) { TestWindowDelegate::RunTest(event, std::move(config)); } +#if defined(OS_MAC) +void WindowFullscreenCreationComplete(CefRefPtr 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 event) { auto config = std::make_unique(); 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 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 window) { @@ -242,7 +267,7 @@ void RunWindowLayoutAndCoords(CefRefPtr 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 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 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 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 display = window->GetDisplay(); EXPECT_TRUE(display.get()); @@ -299,7 +324,7 @@ void RunWindowLayoutAndCoords(CefRefPtr 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 event) {