1 // Copyright (c) 2016 The Chromium Embedded Framework Authors. All rights
2 // reserved. Use of this source code is governed by a BSD-style license that
3 // can be found in the LICENSE file.
4
5 #include "tests/cefclient/browser/window_test_runner_views.h"
6
7 #include "include/views/cef_browser_view.h"
8 #include "include/views/cef_display.h"
9 #include "include/views/cef_window.h"
10 #include "include/wrapper/cef_helpers.h"
11
12 namespace client {
13 namespace window_test {
14
15 namespace {
16
GetWindow(CefRefPtr<CefBrowser> browser)17 CefRefPtr<CefWindow> GetWindow(CefRefPtr<CefBrowser> browser) {
18 CEF_REQUIRE_UI_THREAD();
19 DCHECK(browser->GetHost()->HasView());
20
21 CefRefPtr<CefBrowserView> browser_view =
22 CefBrowserView::GetForBrowser(browser);
23 DCHECK(browser_view.get());
24
25 CefRefPtr<CefWindow> window = browser_view->GetWindow();
26 DCHECK(window.get());
27 return window;
28 }
29
30 } // namespace
31
WindowTestRunnerViews()32 WindowTestRunnerViews::WindowTestRunnerViews() {}
33
SetPos(CefRefPtr<CefBrowser> browser,int x,int y,int width,int height)34 void WindowTestRunnerViews::SetPos(CefRefPtr<CefBrowser> browser,
35 int x,
36 int y,
37 int width,
38 int height) {
39 CefRefPtr<CefWindow> window = GetWindow(browser);
40
41 CefRect window_bounds(x, y, width, height);
42 ModifyBounds(window->GetDisplay()->GetWorkArea(), window_bounds);
43
44 window->SetBounds(window_bounds);
45 }
46
Minimize(CefRefPtr<CefBrowser> browser)47 void WindowTestRunnerViews::Minimize(CefRefPtr<CefBrowser> browser) {
48 GetWindow(browser)->Minimize();
49 }
50
Maximize(CefRefPtr<CefBrowser> browser)51 void WindowTestRunnerViews::Maximize(CefRefPtr<CefBrowser> browser) {
52 GetWindow(browser)->Maximize();
53 }
54
Restore(CefRefPtr<CefBrowser> browser)55 void WindowTestRunnerViews::Restore(CefRefPtr<CefBrowser> browser) {
56 GetWindow(browser)->Restore();
57 }
58
59 } // namespace window_test
60 } // namespace client
61