chromium/chrome/browser/window_management/window_management_browsertest.cc

// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/strings/string_util.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/permissions/permission_request_manager.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_switches.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/default_handlers.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "third_party/blink/public/common/switches.h"
#include "ui/display/screen_base.h"
#include "ui/display/test/test_screen.h"

#if BUILDFLAG(IS_MAC)
#include "content/browser/renderer_host/test_render_widget_host_view_mac_factory.h"
#endif

#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "ash/shell.h"
#include "ui/display/test/display_manager_test_api.h"  // nogncheck
#endif  // BUILDFLAG(IS_CHROMEOS_ASH)

// Fake screen that allows tests to dynamically override the "current" display
// for a window or view even if the underlying OS does not signal a screen
// change.
class FakeScreen : public display::ScreenBase {};

// TODO(crbug.com/40111905): Windows downcasts Screen to ScreenWin and fails.
#if BUILDFLAG(IS_WIN)
#define MAYBE_WindowManagementTest
#else
#define MAYBE_WindowManagementTest
#endif

class MAYBE_WindowManagementTest : public InProcessBrowserTest {};

IN_PROC_BROWSER_TEST_F(MAYBE_WindowManagementTest, OnScreensChangeEvent) {}

// Test that the oncurrentscreenchange handler fires correctly for screen
// changes and property updates.  It also verifies that window.screen.onchange
// also fires in the same scenarios.  (This is not true in all cases, e.g.
// isInternal changing, but is true for width/height tests here.)
IN_PROC_BROWSER_TEST_F(MAYBE_WindowManagementTest, OnCurrentScreenChangeEvent) {}

// Test that onchange events for individual screens in the screen list are
// supported.
IN_PROC_BROWSER_TEST_F(MAYBE_WindowManagementTest, ScreenDetailedOnChange) {}

// Tests that the old alias for window-management throws an error.
// See: https://chromestatus.com/feature/5137018030391296
IN_PROC_BROWSER_TEST_F(MAYBE_WindowManagementTest, WindowPlacementAliasFails) {}