mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-17 04:30:46 +01:00
Windows: Fix ViewsWindowTest failures due to incorrect client area size (fixes issue #2775)
These tests expect the window's client area size to be (kWSize, kWSize). Use ::AdjustWindowRect to offset TestWindowDelegate's preferred size so that the client area size is correct after the OS internally applies frame insets during ::CreateWindow. To test: Run `ceftests.exe --gtest_filter=ViewsWindowTest.Window*`. All tests should pass.
This commit is contained in:
parent
e7b66aa43a
commit
88ecf49549
@ -11,6 +11,10 @@
|
|||||||
#include "tests/ceftests/thread_helper.h"
|
#include "tests/ceftests/thread_helper.h"
|
||||||
#include "tests/gtest/include/gtest/gtest.h"
|
#include "tests/gtest/include/gtest/gtest.h"
|
||||||
|
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
// Test timeout in MS.
|
// Test timeout in MS.
|
||||||
@ -24,7 +28,21 @@ const int TestWindowDelegate::kWSize = 400;
|
|||||||
// static
|
// static
|
||||||
void TestWindowDelegate::RunTest(CefRefPtr<CefWaitableEvent> event,
|
void TestWindowDelegate::RunTest(CefRefPtr<CefWaitableEvent> event,
|
||||||
const Config& config) {
|
const Config& config) {
|
||||||
CefWindow::CreateTopLevelWindow(new TestWindowDelegate(event, config));
|
#if defined(OS_WIN)
|
||||||
|
RECT rect = {0, 0, config.window_size, config.window_size};
|
||||||
|
if (!config.frameless) {
|
||||||
|
// The size value is for the client area. Calculate the whole window size
|
||||||
|
// based on the default frame window style.
|
||||||
|
AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
|
||||||
|
false /* has_menu */);
|
||||||
|
}
|
||||||
|
CefSize window_size = CefSize(rect.right - rect.left, rect.bottom - rect.top);
|
||||||
|
#else
|
||||||
|
CefSize window_size = CefSize(config.window_size, config.window_size);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
CefWindow::CreateTopLevelWindow(
|
||||||
|
new TestWindowDelegate(event, config, window_size));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestWindowDelegate::OnWindowCreated(CefRefPtr<CefWindow> window) {
|
void TestWindowDelegate::OnWindowCreated(CefRefPtr<CefWindow> window) {
|
||||||
@ -62,8 +80,8 @@ void TestWindowDelegate::OnWindowCreated(CefRefPtr<CefWindow> window) {
|
|||||||
// Client area bounds calculation might have off-by-one errors on Windows
|
// Client area bounds calculation might have off-by-one errors on Windows
|
||||||
// due to non-client frame size being calculated internally in pixels and
|
// due to non-client frame size being calculated internally in pixels and
|
||||||
// then converted to DIPs. See http://crbug.com/602692.
|
// then converted to DIPs. See http://crbug.com/602692.
|
||||||
EXPECT_TRUE(abs(client_bounds.width - config_.window_size) <= 1);
|
EXPECT_TRUE(abs(client_bounds.width - window_size_.width) <= 1);
|
||||||
EXPECT_TRUE(abs(client_bounds.height - config_.window_size) <= 1);
|
EXPECT_TRUE(abs(client_bounds.height - window_size_.height) <= 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run the callback.
|
// Run the callback.
|
||||||
@ -108,7 +126,7 @@ bool TestWindowDelegate::IsFrameless(CefRefPtr<CefWindow> window) {
|
|||||||
|
|
||||||
CefSize TestWindowDelegate::GetPreferredSize(CefRefPtr<CefView> view) {
|
CefSize TestWindowDelegate::GetPreferredSize(CefRefPtr<CefView> view) {
|
||||||
got_get_preferred_size_ = true;
|
got_get_preferred_size_ = true;
|
||||||
return CefSize(config_.window_size, config_.window_size);
|
return window_size_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TestWindowDelegate::OnAccelerator(CefRefPtr<CefWindow> window,
|
bool TestWindowDelegate::OnAccelerator(CefRefPtr<CefWindow> window,
|
||||||
@ -126,8 +144,12 @@ bool TestWindowDelegate::OnKeyEvent(CefRefPtr<CefWindow> window,
|
|||||||
}
|
}
|
||||||
|
|
||||||
TestWindowDelegate::TestWindowDelegate(CefRefPtr<CefWaitableEvent> event,
|
TestWindowDelegate::TestWindowDelegate(CefRefPtr<CefWaitableEvent> event,
|
||||||
const Config& config)
|
const Config& config,
|
||||||
: event_(event), config_(config), weak_ptr_factory_(this) {}
|
const CefSize& window_size)
|
||||||
|
: event_(event),
|
||||||
|
config_(config),
|
||||||
|
window_size_(window_size),
|
||||||
|
weak_ptr_factory_(this) {}
|
||||||
|
|
||||||
TestWindowDelegate::~TestWindowDelegate() {
|
TestWindowDelegate::~TestWindowDelegate() {
|
||||||
// Complete the test (signal the event) asynchronously so objects on the call
|
// Complete the test (signal the event) asynchronously so objects on the call
|
||||||
|
@ -48,14 +48,17 @@ class TestWindowDelegate : public CefWindowDelegate {
|
|||||||
const CefKeyEvent& event) override;
|
const CefKeyEvent& event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TestWindowDelegate(CefRefPtr<CefWaitableEvent> event, const Config& config);
|
TestWindowDelegate(CefRefPtr<CefWaitableEvent> event,
|
||||||
|
const Config& config,
|
||||||
|
const CefSize& window_size);
|
||||||
~TestWindowDelegate() override;
|
~TestWindowDelegate() override;
|
||||||
|
|
||||||
void OnCloseWindow();
|
void OnCloseWindow();
|
||||||
void OnTimeoutWindow();
|
void OnTimeoutWindow();
|
||||||
|
|
||||||
CefRefPtr<CefWaitableEvent> event_;
|
CefRefPtr<CefWaitableEvent> event_;
|
||||||
Config config_;
|
const Config config_;
|
||||||
|
const CefSize window_size_;
|
||||||
|
|
||||||
CefRefPtr<CefWindow> window_;
|
CefRefPtr<CefWindow> window_;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user