mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
chrome: Standardize fullscreen transition behavor/callbacks (fixes #3571)
Use the same code path for all fullscreen transitions so that Chrome UI updates correctly. All user-initiated fullscreen transitions now result in CefWindowDelegate::OnWindowFullscreenTransition callbacks.
This commit is contained in:
@@ -277,12 +277,18 @@ void ViewsWindow::SetFavicon(CefRefPtr<CefImage> image) {
|
||||
|
||||
void ViewsWindow::SetFullscreen(bool fullscreen) {
|
||||
CEF_REQUIRE_UI_THREAD();
|
||||
if (window_) {
|
||||
// Hide the top controls while in full-screen mode.
|
||||
if (with_controls_) {
|
||||
ShowTopControls(!fullscreen);
|
||||
}
|
||||
|
||||
// For Chrome runtime we ignore this notification from
|
||||
// ClientHandler::OnFullscreenModeChange(). Chrome runtime will trigger
|
||||
// the fullscreen change internally and then call
|
||||
// OnWindowFullscreenTransition().
|
||||
if (MainContext::Get()->UseChromeRuntime()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// For Alloy runtime we need to explicitly trigger the fullscreen change.
|
||||
if (window_) {
|
||||
// Results in a call to OnWindowFullscreenTransition().
|
||||
window_->SetFullscreen(fullscreen);
|
||||
}
|
||||
}
|
||||
@@ -404,10 +410,12 @@ bool ViewsWindow::GetWindowRestorePreferences(
|
||||
show_state = CEF_SHOW_STATE_NORMAL;
|
||||
if (window_->IsMinimized()) {
|
||||
show_state = CEF_SHOW_STATE_MINIMIZED;
|
||||
} else if (window_->IsFullscreen()) {
|
||||
// On MacOS, IsMaximized() will also return true for fullscreen, so check
|
||||
// IsFullscreen() first.
|
||||
show_state = CEF_SHOW_STATE_FULLSCREEN;
|
||||
} else if (window_->IsMaximized()) {
|
||||
show_state = CEF_SHOW_STATE_MAXIMIZED;
|
||||
} else if (window_->IsFullscreen()) {
|
||||
show_state = CEF_SHOW_STATE_FULLSCREEN;
|
||||
}
|
||||
|
||||
if (show_state == CEF_SHOW_STATE_NORMAL) {
|
||||
@@ -626,6 +634,25 @@ bool ViewsWindow::OnKeyEvent(CefRefPtr<CefTextfield> textfield,
|
||||
return false;
|
||||
}
|
||||
|
||||
void ViewsWindow::OnWindowFullscreenTransition(CefRefPtr<CefWindow> window,
|
||||
bool is_completed) {
|
||||
#if defined(OS_MAC)
|
||||
// On MacOS we get two asynchronous callbacks, and we want to change the UI on
|
||||
// |is_completed=false| (e.g. when the fullscreen transition begins).
|
||||
const bool should_change = !is_completed;
|
||||
#else
|
||||
// On other platforms we only get a single synchronous callback with
|
||||
// |is_completed=true|.
|
||||
DCHECK(is_completed);
|
||||
const bool should_change = true;
|
||||
#endif
|
||||
|
||||
// Hide the top controls while in fullscreen mode.
|
||||
if (should_change && with_controls_) {
|
||||
ShowTopControls(!window->IsFullscreen());
|
||||
}
|
||||
}
|
||||
|
||||
void ViewsWindow::OnWindowCreated(CefRefPtr<CefWindow> window) {
|
||||
CEF_REQUIRE_UI_THREAD();
|
||||
DCHECK(browser_view_);
|
||||
|
@@ -188,6 +188,8 @@ class ViewsWindow : public CefBrowserViewDelegate,
|
||||
bool OnAccelerator(CefRefPtr<CefWindow> window, int command_id) override;
|
||||
bool OnKeyEvent(CefRefPtr<CefWindow> window,
|
||||
const CefKeyEvent& event) override;
|
||||
void OnWindowFullscreenTransition(CefRefPtr<CefWindow> window,
|
||||
bool is_completed) override;
|
||||
|
||||
// CefViewDelegate methods:
|
||||
CefSize GetPreferredSize(CefRefPtr<CefView> view) override;
|
||||
|
@@ -35,6 +35,7 @@ const char kMessagePositionName[] = "WindowTest.Position";
|
||||
const char kMessageMinimizeName[] = "WindowTest.Minimize";
|
||||
const char kMessageMaximizeName[] = "WindowTest.Maximize";
|
||||
const char kMessageRestoreName[] = "WindowTest.Restore";
|
||||
const char kMessageFullscreenName[] = "WindowTest.Fullscreen";
|
||||
const char kMessageTitlebarHeightName[] = "WindowTest.TitlebarHeight";
|
||||
|
||||
// Create the appropriate platform test runner object.
|
||||
@@ -109,6 +110,8 @@ class Handler : public CefMessageRouterBrowserSide::Handler {
|
||||
runner_->Maximize(browser);
|
||||
} else if (message_name == kMessageRestoreName) {
|
||||
runner_->Restore(browser);
|
||||
} else if (message_name == kMessageFullscreenName) {
|
||||
runner_->Fullscreen(browser);
|
||||
} else if (message_name.find(kMessageTitlebarHeightName) == 0) {
|
||||
const auto height = ParseHeight(message_name);
|
||||
runner_->SetTitleBarHeight(browser, height);
|
||||
|
@@ -36,6 +36,10 @@ void WindowTestRunner::ModifyBounds(const CefRect& display, CefRect& window) {
|
||||
}
|
||||
}
|
||||
|
||||
void WindowTestRunner::Fullscreen(CefRefPtr<CefBrowser> browser) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
void WindowTestRunner::SetTitleBarHeight(CefRefPtr<CefBrowser> browser,
|
||||
const std::optional<float>& height) {
|
||||
NOTIMPLEMENTED();
|
||||
|
@@ -27,6 +27,7 @@ class WindowTestRunner {
|
||||
virtual void Minimize(CefRefPtr<CefBrowser> browser) = 0;
|
||||
virtual void Maximize(CefRefPtr<CefBrowser> browser) = 0;
|
||||
virtual void Restore(CefRefPtr<CefBrowser> browser) = 0;
|
||||
virtual void Fullscreen(CefRefPtr<CefBrowser> browser);
|
||||
|
||||
// Fit |window| inside |display|. Coordinates are relative to the upper-left
|
||||
// corner of the display.
|
||||
|
@@ -69,6 +69,17 @@ void WindowTestRunnerViews::Restore(CefRefPtr<CefBrowser> browser) {
|
||||
GetWindow(browser)->Restore();
|
||||
}
|
||||
|
||||
void WindowTestRunnerViews::Fullscreen(CefRefPtr<CefBrowser> browser) {
|
||||
auto window = GetWindow(browser);
|
||||
|
||||
// Results in a call to ViewsWindow::OnWindowFullscreenTransition().
|
||||
if (window->IsFullscreen()) {
|
||||
window->SetFullscreen(false);
|
||||
} else {
|
||||
window->SetFullscreen(true);
|
||||
}
|
||||
}
|
||||
|
||||
void WindowTestRunnerViews::SetTitleBarHeight(
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
const std::optional<float>& height) {
|
||||
|
@@ -24,6 +24,7 @@ class WindowTestRunnerViews : public WindowTestRunner {
|
||||
void Minimize(CefRefPtr<CefBrowser> browser) override;
|
||||
void Maximize(CefRefPtr<CefBrowser> browser) override;
|
||||
void Restore(CefRefPtr<CefBrowser> browser) override;
|
||||
void Fullscreen(CefRefPtr<CefBrowser> browser) override;
|
||||
void SetTitleBarHeight(CefRefPtr<CefBrowser> browser,
|
||||
const std::optional<float>& height) override;
|
||||
};
|
||||
|
@@ -38,6 +38,10 @@ function restore() {
|
||||
setTimeout(function() { send_message('Restore'); }, 1000);
|
||||
}
|
||||
|
||||
function fullscreen() {
|
||||
send_message('Fullscreen');
|
||||
}
|
||||
|
||||
function position() {
|
||||
var x = parseInt(document.getElementById('x').value);
|
||||
var y = parseInt(document.getElementById('y').value);
|
||||
@@ -64,6 +68,7 @@ Click a button to perform the associated window action.
|
||||
<br/><input type="button" onclick="minimize();" value="Minimize">
|
||||
<br/><input type="button" onclick="maximize();" value="Maximize">
|
||||
<br/><input type="button" onclick="restore();" value="Restore"> (minimizes and then restores the window as topmost)
|
||||
<br/><input type="button" onclick="fullscreen();" value="Toggle Fullscreen"> (works with Views)
|
||||
<br/><input type="button" onclick="position();" value="Set Position">
|
||||
X: <input type="text" size="4" id="x" value="200">
|
||||
Y: <input type="text" size="4" id="y" value="100">
|
||||
|
@@ -23,6 +23,11 @@ namespace {
|
||||
// Test timeout in MS.
|
||||
const int kTestTimeout = 5000;
|
||||
|
||||
#if defined(OS_MAC)
|
||||
// Match the value in view_util_mac.mm.
|
||||
constexpr float kDefaultTitleBarHeight = 30;
|
||||
#endif
|
||||
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
@@ -33,8 +38,8 @@ void TestWindowDelegate::RunTest(CefRefPtr<CefWaitableEvent> event,
|
||||
std::unique_ptr<Config> config) {
|
||||
CefSize window_size{config->window_size, config->window_size};
|
||||
|
||||
#if defined(OS_WIN)
|
||||
if (!config->frameless) {
|
||||
#if defined(OS_WIN)
|
||||
// Expand the client area size to full window size based on the default
|
||||
// frame window style. AdjustWindowRect expects pixel coordinates, so
|
||||
// perform the necessary conversions.
|
||||
@@ -53,8 +58,11 @@ void TestWindowDelegate::RunTest(CefRefPtr<CefWaitableEvent> event,
|
||||
{rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top},
|
||||
scale_factor);
|
||||
window_size = {scaled_rect.width, scaled_rect.height};
|
||||
#elif defined(OS_MAC)
|
||||
// Expand client area size to include the default titlebar height.
|
||||
window_size.height += kDefaultTitleBarHeight;
|
||||
#endif
|
||||
}
|
||||
#endif // defined(OS_WIN)
|
||||
|
||||
CefWindow::CreateTopLevelWindow(
|
||||
new TestWindowDelegate(event, std::move(config), window_size));
|
||||
@@ -67,14 +75,8 @@ void TestWindowDelegate::OnWindowCreated(CefRefPtr<CefWindow> window) {
|
||||
EXPECT_TRUE(window->IsValid());
|
||||
EXPECT_FALSE(window->IsClosed());
|
||||
|
||||
EXPECT_FALSE(window->IsVisible());
|
||||
EXPECT_FALSE(window->IsDrawn());
|
||||
|
||||
EXPECT_FALSE(window->IsActive());
|
||||
EXPECT_FALSE(window->IsAlwaysOnTop());
|
||||
EXPECT_FALSE(window->IsMaximized());
|
||||
EXPECT_FALSE(window->IsMinimized());
|
||||
EXPECT_FALSE(window->IsFullscreen());
|
||||
|
||||
const char* title = "ViewsTest";
|
||||
window->SetTitle(title);
|
||||
@@ -95,26 +97,36 @@ void TestWindowDelegate::OnWindowCreated(CefRefPtr<CefWindow> window) {
|
||||
EXPECT_FALSE(got_get_preferred_size_);
|
||||
}
|
||||
|
||||
CefRect client_bounds = window->GetBounds();
|
||||
if (!config_->window_origin.IsEmpty()) {
|
||||
EXPECT_EQ(config_->window_origin.x, client_bounds.x);
|
||||
EXPECT_EQ(config_->window_origin.y, client_bounds.y);
|
||||
} else {
|
||||
// Default origin is the upper-left corner of the display's work area.
|
||||
auto work_area = display->GetWorkArea();
|
||||
EXPECT_NEAR(work_area.x, client_bounds.x, 1);
|
||||
EXPECT_NEAR(work_area.y, client_bounds.y, 1);
|
||||
}
|
||||
// Expectations for the default |initial_show_state| value.
|
||||
if (config_->initial_show_state == CEF_SHOW_STATE_NORMAL) {
|
||||
EXPECT_FALSE(window->IsVisible());
|
||||
EXPECT_FALSE(window->IsDrawn());
|
||||
|
||||
if (config_->frameless) {
|
||||
EXPECT_NEAR(config_->window_size, client_bounds.width, 2);
|
||||
EXPECT_NEAR(config_->window_size, client_bounds.height, 2);
|
||||
} else {
|
||||
// Client area bounds calculation might have off-by-one errors on Windows
|
||||
// due to non-client frame size being calculated internally in pixels and
|
||||
// then converted to DIPs. See https://crbug.com/602692.
|
||||
EXPECT_NEAR(client_bounds.width, window_size_.width, 2);
|
||||
EXPECT_NEAR(client_bounds.height, window_size_.height, 2);
|
||||
EXPECT_FALSE(window->IsMaximized());
|
||||
EXPECT_FALSE(window->IsMinimized());
|
||||
EXPECT_FALSE(window->IsFullscreen());
|
||||
|
||||
CefRect client_bounds = window->GetBounds();
|
||||
if (!config_->window_origin.IsEmpty()) {
|
||||
EXPECT_EQ(config_->window_origin.x, client_bounds.x);
|
||||
EXPECT_EQ(config_->window_origin.y, client_bounds.y);
|
||||
} else {
|
||||
// Default origin is the upper-left corner of the display's work area.
|
||||
auto work_area = display->GetWorkArea();
|
||||
EXPECT_NEAR(work_area.x, client_bounds.x, 1);
|
||||
EXPECT_NEAR(work_area.y, client_bounds.y, 1);
|
||||
}
|
||||
|
||||
if (config_->frameless) {
|
||||
EXPECT_NEAR(config_->window_size, client_bounds.width, 2);
|
||||
EXPECT_NEAR(config_->window_size, client_bounds.height, 2);
|
||||
} else {
|
||||
// Client area bounds calculation might have off-by-one errors on Windows
|
||||
// due to non-client frame size being calculated internally in pixels and
|
||||
// then converted to DIPs. See https://crbug.com/602692.
|
||||
EXPECT_NEAR(client_bounds.width, window_size_.width, 2);
|
||||
EXPECT_NEAR(client_bounds.height, window_size_.height, 2);
|
||||
}
|
||||
}
|
||||
|
||||
// Run the callback.
|
||||
@@ -158,6 +170,41 @@ void TestWindowDelegate::OnWindowDestroyed(CefRefPtr<CefWindow> window) {
|
||||
weak_ptr_factory_.InvalidateWeakPtrs();
|
||||
}
|
||||
|
||||
void TestWindowDelegate::OnWindowFullscreenTransition(
|
||||
CefRefPtr<CefWindow> window,
|
||||
bool is_completed) {
|
||||
EXPECT_TRUE(window->IsSame(window_));
|
||||
|
||||
EXPECT_TRUE(window->IsValid());
|
||||
EXPECT_FALSE(window->IsClosed());
|
||||
EXPECT_TRUE(window->IsVisible());
|
||||
EXPECT_TRUE(window->IsDrawn());
|
||||
|
||||
fullscreen_transition_callback_count_++;
|
||||
|
||||
#if defined(OS_MAC)
|
||||
// Two callbacks on MacOS.
|
||||
EXPECT_EQ(is_completed ? 2U : 1U, fullscreen_transition_callback_count_);
|
||||
#else
|
||||
// Single callback on other platforms.
|
||||
EXPECT_TRUE(is_completed);
|
||||
EXPECT_EQ(1U, fullscreen_transition_callback_count_);
|
||||
#endif
|
||||
|
||||
if (is_completed) {
|
||||
fullscreen_transition_complete_count_++;
|
||||
|
||||
// Reset intermediate state.
|
||||
fullscreen_transition_callback_count_ = 0;
|
||||
|
||||
// Run the callback.
|
||||
if (!config_->on_window_fullscreen_transition_complete.is_null()) {
|
||||
config_->on_window_fullscreen_transition_complete.Run(
|
||||
window, fullscreen_transition_complete_count_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool TestWindowDelegate::IsFrameless(CefRefPtr<CefWindow> window) {
|
||||
return config_->frameless;
|
||||
}
|
||||
@@ -173,6 +220,11 @@ CefRect TestWindowDelegate::GetInitialBounds(CefRefPtr<CefWindow> window) {
|
||||
return CefRect();
|
||||
}
|
||||
|
||||
cef_show_state_t TestWindowDelegate::GetInitialShowState(
|
||||
CefRefPtr<CefWindow> window) {
|
||||
return config_->initial_show_state;
|
||||
}
|
||||
|
||||
CefSize TestWindowDelegate::GetPreferredSize(CefRefPtr<CefView> view) {
|
||||
got_get_preferred_size_ = true;
|
||||
return window_size_;
|
||||
|
@@ -20,6 +20,8 @@ class TestWindowDelegate : public CefWindowDelegate {
|
||||
base::OnceCallback<void(CefRefPtr<CefWindow>)>;
|
||||
using OnWindowDestroyedCallback =
|
||||
base::OnceCallback<void(CefRefPtr<CefWindow>)>;
|
||||
using OnWindowFullscreenTransitionCompleteCallback =
|
||||
base::RepeatingCallback<void(CefRefPtr<CefWindow>, size_t /*count*/)>;
|
||||
using OnAcceleratorCallback =
|
||||
base::RepeatingCallback<bool(CefRefPtr<CefWindow>, int)>;
|
||||
using OnKeyEventCallback =
|
||||
@@ -28,12 +30,15 @@ class TestWindowDelegate : public CefWindowDelegate {
|
||||
struct Config {
|
||||
OnWindowCreatedCallback on_window_created;
|
||||
OnWindowDestroyedCallback on_window_destroyed;
|
||||
OnWindowFullscreenTransitionCompleteCallback
|
||||
on_window_fullscreen_transition_complete;
|
||||
OnAcceleratorCallback on_accelerator;
|
||||
OnKeyEventCallback on_key_event;
|
||||
bool frameless = false;
|
||||
bool close_window = true;
|
||||
int window_size = kWSize;
|
||||
CefPoint window_origin = {};
|
||||
cef_show_state_t initial_show_state = CEF_SHOW_STATE_NORMAL;
|
||||
};
|
||||
|
||||
// Creates a Window with a new TestWindowDelegate instance and executes
|
||||
@@ -48,8 +53,11 @@ class TestWindowDelegate : public CefWindowDelegate {
|
||||
// CefWindowDelegate methods:
|
||||
void OnWindowCreated(CefRefPtr<CefWindow> window) override;
|
||||
void OnWindowDestroyed(CefRefPtr<CefWindow> window) override;
|
||||
void OnWindowFullscreenTransition(CefRefPtr<CefWindow> window,
|
||||
bool is_completed) override;
|
||||
bool IsFrameless(CefRefPtr<CefWindow> window) override;
|
||||
CefRect GetInitialBounds(CefRefPtr<CefWindow> window) override;
|
||||
cef_show_state_t GetInitialShowState(CefRefPtr<CefWindow> window) override;
|
||||
CefSize GetPreferredSize(CefRefPtr<CefView> view) override;
|
||||
bool OnAccelerator(CefRefPtr<CefWindow> window, int command_id) override;
|
||||
bool OnKeyEvent(CefRefPtr<CefWindow> window,
|
||||
@@ -73,6 +81,9 @@ class TestWindowDelegate : public CefWindowDelegate {
|
||||
bool got_get_initial_bounds_ = false;
|
||||
bool got_get_preferred_size_ = false;
|
||||
|
||||
size_t fullscreen_transition_callback_count_ = 0;
|
||||
size_t fullscreen_transition_complete_count_ = 0;
|
||||
|
||||
// Must be the last member.
|
||||
base::WeakPtrFactory<TestWindowDelegate> weak_ptr_factory_;
|
||||
|
||||
|
@@ -36,6 +36,13 @@ void ExpectCloseRects(const CefRect& expected,
|
||||
EXPECT_LE(abs(expected.height - actual.height), allowed_deviance);
|
||||
}
|
||||
|
||||
void ExpectClosePoints(const CefPoint& expected,
|
||||
const CefPoint& actual,
|
||||
int allowed_deviance) {
|
||||
EXPECT_LE(abs(expected.x - actual.x), allowed_deviance);
|
||||
EXPECT_LE(abs(expected.y - actual.y), allowed_deviance);
|
||||
}
|
||||
|
||||
void WindowCreateImpl(CefRefPtr<CefWaitableEvent> event) {
|
||||
auto config = std::make_unique<TestWindowDelegate::Config>();
|
||||
TestWindowDelegate::RunTest(event, std::move(config));
|
||||
@@ -47,23 +54,106 @@ void WindowCreateFramelessImpl(CefRefPtr<CefWaitableEvent> event) {
|
||||
TestWindowDelegate::RunTest(event, std::move(config));
|
||||
}
|
||||
|
||||
void RunWindowShow(CefRefPtr<CefWindow> window) {
|
||||
EXPECT_FALSE(window->IsVisible());
|
||||
EXPECT_FALSE(window->IsDrawn());
|
||||
window->Show();
|
||||
EXPECT_TRUE(window->IsVisible());
|
||||
EXPECT_TRUE(window->IsDrawn());
|
||||
void RunWindowShow(cef_show_state_t initial_show_state,
|
||||
CefRefPtr<CefWindow> window) {
|
||||
#if defined(OS_MAC)
|
||||
if (initial_show_state == CEF_SHOW_STATE_FULLSCREEN) {
|
||||
// On MacOS, starting in fullscreen mode also shows the window on creation.
|
||||
EXPECT_TRUE(window->IsVisible());
|
||||
EXPECT_TRUE(window->IsDrawn());
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
EXPECT_FALSE(window->IsVisible());
|
||||
EXPECT_FALSE(window->IsDrawn());
|
||||
window->Show();
|
||||
}
|
||||
|
||||
if (initial_show_state == CEF_SHOW_STATE_MINIMIZED) {
|
||||
#if !defined(OS_MAC)
|
||||
// This result is a bit unexpected, but I guess the platform considers a
|
||||
// window to be visible even when it's minimized.
|
||||
EXPECT_TRUE(window->IsVisible());
|
||||
EXPECT_TRUE(window->IsDrawn());
|
||||
#else
|
||||
EXPECT_FALSE(window->IsVisible());
|
||||
EXPECT_FALSE(window->IsDrawn());
|
||||
#endif
|
||||
} else {
|
||||
EXPECT_TRUE(window->IsVisible());
|
||||
EXPECT_TRUE(window->IsDrawn());
|
||||
}
|
||||
|
||||
switch (initial_show_state) {
|
||||
case CEF_SHOW_STATE_NORMAL:
|
||||
EXPECT_FALSE(window->IsMaximized());
|
||||
EXPECT_FALSE(window->IsMinimized());
|
||||
EXPECT_FALSE(window->IsFullscreen());
|
||||
break;
|
||||
case CEF_SHOW_STATE_MINIMIZED:
|
||||
EXPECT_FALSE(window->IsMaximized());
|
||||
#if defined(OS_WIN)
|
||||
// On MacOS, IsMinimized() state isn't reliable in this callback due to a
|
||||
// timing issue between NativeWidgetMac::Minimize requesting the minimize
|
||||
// state change (before this callback) and
|
||||
// NativeWidgetMacNSWindowHost::OnWindowMiniaturizedChanged indicating the
|
||||
// completed state change (after this callback).
|
||||
// On Linux, there's likely a similar timing issue.
|
||||
EXPECT_TRUE(window->IsMinimized());
|
||||
#endif
|
||||
EXPECT_FALSE(window->IsFullscreen());
|
||||
break;
|
||||
case CEF_SHOW_STATE_MAXIMIZED:
|
||||
#if !defined(OS_LINUX)
|
||||
// On Linux, there's likely a similar timing issue.
|
||||
EXPECT_TRUE(window->IsMaximized());
|
||||
#endif
|
||||
EXPECT_FALSE(window->IsMinimized());
|
||||
EXPECT_FALSE(window->IsFullscreen());
|
||||
break;
|
||||
case CEF_SHOW_STATE_FULLSCREEN:
|
||||
EXPECT_FALSE(window->IsMaximized());
|
||||
EXPECT_FALSE(window->IsMinimized());
|
||||
EXPECT_TRUE(window->IsFullscreen());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void WindowCreateWithOriginImpl(CefRefPtr<CefWaitableEvent> event) {
|
||||
auto config = std::make_unique<TestWindowDelegate::Config>();
|
||||
config->window_origin = {100, 200};
|
||||
config->on_window_created = base::BindOnce(RunWindowShow);
|
||||
config->on_window_created =
|
||||
base::BindOnce(RunWindowShow, config->initial_show_state);
|
||||
TestWindowDelegate::RunTest(event, std::move(config));
|
||||
}
|
||||
|
||||
void RunWindowShowHide(CefRefPtr<CefWindow> window) {
|
||||
RunWindowShow(window);
|
||||
void WindowCreateMinimizedImpl(CefRefPtr<CefWaitableEvent> event) {
|
||||
auto config = std::make_unique<TestWindowDelegate::Config>();
|
||||
config->initial_show_state = CEF_SHOW_STATE_MINIMIZED;
|
||||
config->on_window_created =
|
||||
base::BindOnce(RunWindowShow, config->initial_show_state);
|
||||
TestWindowDelegate::RunTest(event, std::move(config));
|
||||
}
|
||||
|
||||
void WindowCreateMaximizedImpl(CefRefPtr<CefWaitableEvent> event) {
|
||||
auto config = std::make_unique<TestWindowDelegate::Config>();
|
||||
config->initial_show_state = CEF_SHOW_STATE_MAXIMIZED;
|
||||
config->on_window_created =
|
||||
base::BindOnce(RunWindowShow, config->initial_show_state);
|
||||
TestWindowDelegate::RunTest(event, std::move(config));
|
||||
}
|
||||
|
||||
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);
|
||||
TestWindowDelegate::RunTest(event, std::move(config));
|
||||
}
|
||||
|
||||
void RunWindowShowHide(cef_show_state_t initial_show_state,
|
||||
CefRefPtr<CefWindow> window) {
|
||||
RunWindowShow(initial_show_state, window);
|
||||
window->Hide();
|
||||
EXPECT_FALSE(window->IsVisible());
|
||||
EXPECT_FALSE(window->IsDrawn());
|
||||
@@ -71,13 +161,15 @@ void RunWindowShowHide(CefRefPtr<CefWindow> window) {
|
||||
|
||||
void WindowShowHideImpl(CefRefPtr<CefWaitableEvent> event) {
|
||||
auto config = std::make_unique<TestWindowDelegate::Config>();
|
||||
config->on_window_created = base::BindOnce(RunWindowShowHide);
|
||||
config->on_window_created =
|
||||
base::BindOnce(RunWindowShowHide, config->initial_show_state);
|
||||
TestWindowDelegate::RunTest(event, std::move(config));
|
||||
}
|
||||
|
||||
void WindowShowHideFramelessImpl(CefRefPtr<CefWaitableEvent> event) {
|
||||
auto config = std::make_unique<TestWindowDelegate::Config>();
|
||||
config->on_window_created = base::BindOnce(RunWindowShowHide);
|
||||
config->on_window_created =
|
||||
base::BindOnce(RunWindowShowHide, config->initial_show_state);
|
||||
config->frameless = true;
|
||||
TestWindowDelegate::RunTest(event, std::move(config));
|
||||
}
|
||||
@@ -146,9 +238,9 @@ void RunWindowLayoutAndCoords(CefRefPtr<CefWindow> window) {
|
||||
point);
|
||||
point = CefPoint(0, 0);
|
||||
EXPECT_TRUE(view2->ConvertPointToScreen(point));
|
||||
EXPECT_EQ(CefPoint(client_bounds_in_screen.x,
|
||||
client_bounds_in_screen.y + kWSize / 2),
|
||||
point);
|
||||
ExpectClosePoints(CefPoint(client_bounds_in_screen.x,
|
||||
client_bounds_in_screen.y + kWSize / 2),
|
||||
point, 1);
|
||||
|
||||
// Test view from screen coordinate conversions.
|
||||
point = CefPoint(client_bounds_in_screen.x, client_bounds_in_screen.y);
|
||||
@@ -157,7 +249,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));
|
||||
EXPECT_EQ(CefPoint(0, 0), point);
|
||||
ExpectClosePoints(CefPoint(0, 0), point, 1);
|
||||
|
||||
// Test view to window coordinate conversions.
|
||||
point = CefPoint(0, 0);
|
||||
@@ -165,7 +257,7 @@ void RunWindowLayoutAndCoords(CefRefPtr<CefWindow> window) {
|
||||
EXPECT_EQ(CefPoint(0, 0), point);
|
||||
point = CefPoint(0, 0);
|
||||
EXPECT_TRUE(view2->ConvertPointToWindow(point));
|
||||
EXPECT_EQ(CefPoint(0, kWSize / 2), point);
|
||||
ExpectClosePoints(CefPoint(0, kWSize / 2), point, 1);
|
||||
|
||||
// Test view from window coordinate conversions.
|
||||
point = CefPoint(0, 0);
|
||||
@@ -173,23 +265,23 @@ void RunWindowLayoutAndCoords(CefRefPtr<CefWindow> window) {
|
||||
EXPECT_EQ(CefPoint(0, 0), point);
|
||||
point = CefPoint(0, kWSize / 2);
|
||||
EXPECT_TRUE(view2->ConvertPointFromWindow(point));
|
||||
EXPECT_EQ(CefPoint(0, 0), point);
|
||||
ExpectClosePoints(CefPoint(0, 0), point, 1);
|
||||
|
||||
// Test view to view coordinate conversions.
|
||||
point = CefPoint(0, 0);
|
||||
EXPECT_TRUE(view1->ConvertPointToView(view2, point));
|
||||
EXPECT_EQ(CefPoint(0, -kWSize / 2), point);
|
||||
ExpectClosePoints(CefPoint(0, -kWSize / 2), point, 1);
|
||||
point = CefPoint(0, 0);
|
||||
EXPECT_TRUE(view2->ConvertPointToView(view1, point));
|
||||
EXPECT_EQ(CefPoint(0, kWSize / 2), point);
|
||||
ExpectClosePoints(CefPoint(0, kWSize / 2), point, 1);
|
||||
|
||||
// Test view from view coordinate conversions.
|
||||
point = CefPoint(0, -kWSize / 2);
|
||||
EXPECT_TRUE(view1->ConvertPointFromView(view2, point));
|
||||
EXPECT_EQ(CefPoint(0, 0), point);
|
||||
ExpectClosePoints(CefPoint(0, 0), point, 1);
|
||||
point = CefPoint(0, kWSize / 2);
|
||||
EXPECT_TRUE(view2->ConvertPointFromView(view1, point));
|
||||
EXPECT_EQ(CefPoint(0, 0), point);
|
||||
ExpectClosePoints(CefPoint(0, 0), point, 1);
|
||||
|
||||
CefRefPtr<CefDisplay> display = window->GetDisplay();
|
||||
EXPECT_TRUE(display.get());
|
||||
@@ -198,8 +290,8 @@ void RunWindowLayoutAndCoords(CefRefPtr<CefWindow> window) {
|
||||
point = CefPoint(client_bounds_in_screen.x, client_bounds_in_screen.y);
|
||||
display->ConvertPointToPixels(point);
|
||||
display->ConvertPointFromPixels(point);
|
||||
EXPECT_EQ(CefPoint(client_bounds_in_screen.x, client_bounds_in_screen.y),
|
||||
point);
|
||||
ExpectClosePoints(
|
||||
CefPoint(client_bounds_in_screen.x, client_bounds_in_screen.y), point, 1);
|
||||
|
||||
// We don't know what the pixel values will be, but they should be reversable.
|
||||
point = CefPoint(client_bounds_in_screen.x, client_bounds_in_screen.y);
|
||||
@@ -278,10 +370,15 @@ void VerifyMinimize(CefRefPtr<CefWindow> window) {
|
||||
EXPECT_FALSE(window->IsMaximized());
|
||||
EXPECT_FALSE(window->IsFullscreen());
|
||||
|
||||
#if defined(OS_WIN)
|
||||
// This result is a bit unexpected, but I guess the platform considers a
|
||||
// window to be visible even when it's minimized.
|
||||
EXPECT_TRUE(window->IsVisible());
|
||||
EXPECT_TRUE(window->IsDrawn());
|
||||
#else
|
||||
EXPECT_FALSE(window->IsVisible());
|
||||
EXPECT_FALSE(window->IsDrawn());
|
||||
#endif
|
||||
|
||||
window->Restore();
|
||||
CefPostDelayedTask(TID_UI, base::BindOnce(VerifyRestore, window),
|
||||
@@ -316,28 +413,26 @@ void WindowMinimizeFramelessImpl(CefRefPtr<CefWaitableEvent> event) {
|
||||
config->close_window = false;
|
||||
TestWindowDelegate::RunTest(event, std::move(config));
|
||||
}
|
||||
|
||||
void VerifyFullscreenExit(CefRefPtr<CefWindow> window) {
|
||||
void WindowFullscreenTransitionComplete(CefRefPtr<CefWindow> window,
|
||||
size_t count) {
|
||||
EXPECT_FALSE(window->IsMinimized());
|
||||
|
||||
#if defined(OS_MAC)
|
||||
// On MacOS, IsMaximized() returns true when IsFullscreen() returns true.
|
||||
EXPECT_EQ(window->IsFullscreen(), window->IsMaximized());
|
||||
#else
|
||||
EXPECT_FALSE(window->IsMaximized());
|
||||
EXPECT_FALSE(window->IsFullscreen());
|
||||
EXPECT_TRUE(window->IsVisible());
|
||||
EXPECT_TRUE(window->IsDrawn());
|
||||
#endif
|
||||
|
||||
// End the test by closing the Window.
|
||||
window->Close();
|
||||
}
|
||||
if (window->IsFullscreen()) {
|
||||
EXPECT_EQ(1U, count);
|
||||
window->SetFullscreen(false);
|
||||
} else {
|
||||
EXPECT_EQ(2U, count);
|
||||
|
||||
void VerifyFullscreen(CefRefPtr<CefWindow> window) {
|
||||
EXPECT_FALSE(window->IsMinimized());
|
||||
EXPECT_FALSE(window->IsMaximized());
|
||||
EXPECT_TRUE(window->IsFullscreen());
|
||||
EXPECT_TRUE(window->IsVisible());
|
||||
EXPECT_TRUE(window->IsDrawn());
|
||||
|
||||
window->SetFullscreen(false);
|
||||
CefPostDelayedTask(TID_UI, base::BindOnce(VerifyFullscreenExit, window),
|
||||
kStateDelayMS);
|
||||
// End the test by closing the Window.
|
||||
window->Close();
|
||||
}
|
||||
}
|
||||
|
||||
void RunWindowFullscreen(CefRefPtr<CefWindow> window) {
|
||||
@@ -350,13 +445,13 @@ void RunWindowFullscreen(CefRefPtr<CefWindow> window) {
|
||||
EXPECT_TRUE(window->IsDrawn());
|
||||
|
||||
window->SetFullscreen(true);
|
||||
CefPostDelayedTask(TID_UI, base::BindOnce(VerifyFullscreen, window),
|
||||
kStateDelayMS);
|
||||
}
|
||||
|
||||
void WindowFullscreenImpl(CefRefPtr<CefWaitableEvent> event) {
|
||||
auto config = std::make_unique<TestWindowDelegate::Config>();
|
||||
config->on_window_created = base::BindOnce(RunWindowFullscreen);
|
||||
config->on_window_fullscreen_transition_complete =
|
||||
base::BindRepeating(WindowFullscreenTransitionComplete);
|
||||
config->close_window = false;
|
||||
TestWindowDelegate::RunTest(event, std::move(config));
|
||||
}
|
||||
@@ -364,6 +459,8 @@ void WindowFullscreenImpl(CefRefPtr<CefWaitableEvent> event) {
|
||||
void WindowFullscreenFramelessImpl(CefRefPtr<CefWaitableEvent> event) {
|
||||
auto config = std::make_unique<TestWindowDelegate::Config>();
|
||||
config->on_window_created = base::BindOnce(RunWindowFullscreen);
|
||||
config->on_window_fullscreen_transition_complete =
|
||||
base::BindRepeating(WindowFullscreenTransitionComplete);
|
||||
config->frameless = true;
|
||||
config->close_window = false;
|
||||
TestWindowDelegate::RunTest(event, std::move(config));
|
||||
@@ -505,6 +602,9 @@ void WindowAcceleratorImpl(CefRefPtr<CefWaitableEvent> event) {
|
||||
WINDOW_TEST_ASYNC(WindowCreate)
|
||||
WINDOW_TEST_ASYNC(WindowCreateFrameless)
|
||||
WINDOW_TEST_ASYNC(WindowCreateWithOrigin)
|
||||
WINDOW_TEST_ASYNC(WindowCreateMinimized)
|
||||
WINDOW_TEST_ASYNC(WindowCreateMaximized)
|
||||
WINDOW_TEST_ASYNC(WindowCreateFullscreen)
|
||||
WINDOW_TEST_ASYNC(WindowShowHide)
|
||||
WINDOW_TEST_ASYNC(WindowShowHideFrameless)
|
||||
WINDOW_TEST_ASYNC(WindowLayoutAndCoords)
|
||||
|
Reference in New Issue
Block a user