| // Copyright 2019 The Chromium 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 "chrome/browser/ui/views/frame/browser_frame.h" |
| |
| #include "build/build_config.h" |
| #include "chrome/browser/devtools/devtools_window_testing.h" |
| #include "chrome/browser/ui/browser.h" |
| #include "chrome/browser/ui/browser_window.h" |
| #include "chrome/browser/ui/views/chrome_views_delegate.h" |
| #include "chrome/browser/ui/web_applications/test/web_app_browsertest_util.h" |
| #include "chrome/browser/web_applications/test/web_app_install_test_utils.h" |
| #include "chrome/browser/web_applications/web_app_install_info.h" |
| #include "chrome/test/base/in_process_browser_test.h" |
| #include "chrome/test/base/ui_test_utils.h" |
| #include "content/public/browser/invalidate_type.h" |
| #include "content/public/test/browser_test.h" |
| #include "content/public/test/browser_test_utils.h" |
| #include "ui/views/views_delegate.h" |
| |
| class BrowserFrameBoundsChecker : public ChromeViewsDelegate { |
| public: |
| BrowserFrameBoundsChecker() {} |
| |
| void OnBeforeWidgetInit( |
| views::Widget::InitParams* params, |
| views::internal::NativeWidgetDelegate* delegate) override { |
| ChromeViewsDelegate::OnBeforeWidgetInit(params, delegate); |
| if (params->name == "BrowserFrame") |
| EXPECT_FALSE(params->bounds.IsEmpty()); |
| } |
| }; |
| |
| class BrowserFrameTest : public InProcessBrowserTest { |
| public: |
| BrowserFrameTest() |
| : InProcessBrowserTest(std::make_unique<BrowserFrameBoundsChecker>()) {} |
| }; |
| |
| // Verifies that the tools are loaded with initial bounds. |
| IN_PROC_BROWSER_TEST_F(BrowserFrameTest, DevToolsHasBoundsOnOpen) { |
| // Open undocked tools. |
| DevToolsWindow* devtools_ = |
| DevToolsWindowTesting::OpenDevToolsWindowSync(browser(), false); |
| DevToolsWindowTesting::CloseDevToolsWindowSync(devtools_); |
| } |
| |
| // Verifies that the web app is loaded with initial bounds. |
| IN_PROC_BROWSER_TEST_F(BrowserFrameTest, WebAppsHasBoundsOnOpen) { |
| auto web_app_info = std::make_unique<WebAppInstallInfo>(); |
| web_app_info->start_url = GURL("http://example.org/"); |
| web_app::AppId app_id = web_app::test::InstallWebApp(browser()->profile(), |
| std::move(web_app_info)); |
| |
| Browser* app_browser = |
| web_app::LaunchWebAppBrowser(browser()->profile(), app_id); |
| ASSERT_TRUE(app_browser->is_type_app()); |
| app_browser->window()->Close(); |
| } |