cef/tests/unittests/views/test_window_delegate.h

65 lines
2.2 KiB
C
Raw Normal View History

Implement Views framework on Windows and Linux (issue #1749). - Add Views header files in a new include/views directory. - Add initial top-level window (CefWindow), control (CefBrowserView, CefLabelButton, CefMenuButton, CefPanel, CefScrollView, CefTextfield) and layout (CefBoxLayout, CefFlowLayout) support. See libcef/browser/views/view_impl.h comments for implementation details. - Add Views example usage in cefclient and cefsimple and Views unit tests in cef_unittests. Pass the `--use-views` command-line flag to cefclient, cefsimple and cef_unittests to run using the Views framework instead of platform APIs. For cefclient and cefsimple this will create the browser window and all related functionality using the Views framework. For cef_unittests this will run all tests (except OSR tests) in a Views-based browser window. Views- specific unit tests (`--gtest_filter=Views*`) will be run even if the the `--use-views` flag is not specified. - Pass the `--hide-frame` command-line flag to cefclient to demo a frameless Views-based browser window. - Pass the `--hide-controls` command-line flag to cefclient to demo a browser window without top controls. This also works in non-Views mode. - Pass the `--enable-high-dpi-support` command-line flag to cef_unittests on Windows to test high-DPI support on a display that supports it. - Add CefImage for reading/writing image file formats. - Add CefBrowser::DownloadImage() for downloading image URLs as a CefImage representation. This is primarily for loading favicons. - Add CefMenuModel::CreateMenuModel() and CefMenuModelDelegate for creating custom menus. This is primarily for use with CefMenuButton. - Add CefBrowser::TryCloseBrowser() helper for closing a browser. Also improve related documentation in cef_life_span_handler.h. - Rename cef_page_range_t to cef_range_t. It is now also used by CefTextfield. - Remove CefLifeSpanHandler::RunModal() which is never called. - Add draggable regions example to cefclient.
2016-01-19 21:09:01 +01:00
// Copyright (c) 2016 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#include "include/views/cef_window.h"
#include "include/views/cef_window_delegate.h"
#include "base/callback.h"
#include "base/memory/weak_ptr.h"
#include "base/synchronization/waitable_event.h"
class TestWindowDelegate : public CefWindowDelegate {
public:
// Default window size.
static const int kWSize;
// Test execution callback.
typedef base::Callback<void(CefRefPtr<CefWindow>)> WindowTest;
// Creates a Window with a new TestWindowDelegate instance and executes
// |window_test| after the Window is created. |event| will be signaled once
// the Window is closed. If |frameless| is true the Window will be created
// without a frame. If |close_window| is true the Window will be closed
// immediately after |window_test| returns. Otherwise, the caller is
// responsible for closing the Window passed to |window_test|.
static void RunTest(base::WaitableEvent* event,
const WindowTest& window_test,
bool frameless = false,
bool close_window = true,
int window_size = kWSize);
// CefWindowDelegate methods:
void OnWindowCreated(CefRefPtr<CefWindow> window) override;
void OnWindowDestroyed(CefRefPtr<CefWindow> window) override;
bool IsFrameless(CefRefPtr<CefWindow> window) override;
CefSize GetPreferredSize(CefRefPtr<CefView> view) override;
private:
TestWindowDelegate(base::WaitableEvent* event,
const WindowTest& window_test,
bool frameless,
bool close_window,
int window_size);
~TestWindowDelegate() override;
void OnCloseWindow();
void OnTimeoutWindow();
base::WaitableEvent* event_;
WindowTest window_test_;
bool frameless_;
bool close_window_;
int window_size_;
CefRefPtr<CefWindow> window_;
bool got_get_preferred_size_ = false;
// Must be the last member.
base::WeakPtrFactory<TestWindowDelegate> weak_ptr_factory_;
IMPLEMENT_REFCOUNTING(TestWindowDelegate);
DISALLOW_COPY_AND_ASSIGN(TestWindowDelegate);
};