chromium/chrome/browser/ui/views/overlay/video_overlay_window_views_unittest.cc

// Copyright 2020 The Chromium Authors
// 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/overlay/video_overlay_window_views.h"

#include <memory>
#include <utility>

#include "base/containers/contains.h"
#include "base/memory/raw_ptr.h"
#include "base/test/mock_callback.h"
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/picture_in_picture/auto_pip_setting_overlay_view.h"
#include "chrome/browser/picture_in_picture/picture_in_picture_occlusion_tracker.h"
#include "chrome/browser/picture_in_picture/picture_in_picture_window_manager.h"
#include "chrome/browser/ui/views/overlay/back_to_tab_button.h"
#include "chrome/browser/ui/views/overlay/close_image_button.h"
#include "chrome/browser/ui/views/overlay/minimize_button.h"
#include "chrome/browser/ui/views/overlay/simple_overlay_window_image_button.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/views/chrome_views_test_base.h"
#include "content/public/browser/overlay_window.h"
#include "content/public/browser/video_picture_in_picture_window_controller.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/test_web_contents_factory.h"
#include "media/base/media_switches.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "ui/compositor/layer.h"
#include "ui/display/test/test_screen.h"
#include "ui/events/base_event_utils.h"
#include "ui/events/event.h"
#include "ui/events/test/event_generator.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/vector2d.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/test/button_test_api.h"
#include "ui/views/test/views_test_base.h"
#include "ui/views/widget/widget_utils.h"

namespace {

constexpr gfx::Size kMinWindowSize(200, 100);

// Reported minimum bubble size for the setting view.  The pip window should be
// larger than this when the setting view is shown.
constexpr gfx::Size kBubbleSize(300, 200);

// Size that's big enough to accommodate a `kBubbleSize`-sized bubble without
// being further adjusted upwards for margin.
constexpr gfx::Size kSizeBigEnoughForBubble(400, 300);

}  // namespace

_;
Return;

// Mock of AutoPipSettingOverlayView. Used for injection during tests.
class MockOverlayView : public AutoPipSettingOverlayView {};

class TestVideoPictureInPictureWindowController
    : public content::VideoPictureInPictureWindowController {};

class VideoOverlayWindowViewsTest : public ChromeViewsTestBase {};

TEST_F(VideoOverlayWindowViewsTest, InitialWindowSize_Square) {}

TEST_F(VideoOverlayWindowViewsTest, InitialWindowSize_Horizontal) {}

TEST_F(VideoOverlayWindowViewsTest, InitialWindowSize_Vertical) {}

TEST_F(VideoOverlayWindowViewsTest, Letterboxing) {}

TEST_F(VideoOverlayWindowViewsTest, Pillarboxing) {}

TEST_F(VideoOverlayWindowViewsTest, Pillarboxing_Square) {}

TEST_F(VideoOverlayWindowViewsTest, ApproximateAspectRatio_Horizontal) {}

TEST_F(VideoOverlayWindowViewsTest, ApproximateAspectRatio_Vertical) {}

TEST_F(VideoOverlayWindowViewsTest, UpdateMaximumSize) {}

TEST_F(VideoOverlayWindowViewsTest, IgnoreInvalidMaximumSize) {}

// Tests that Next Track button bounds are updated right away when window
// controls are hidden.
TEST_F(VideoOverlayWindowViewsTest, NextTrackButtonAddedWhenControlsHidden) {}

// Tests that Previous Track button bounds are updated right away when window
// controls are hidden.
TEST_F(VideoOverlayWindowViewsTest,
       PreviousTrackButtonAddedWhenControlsHidden) {}

TEST_F(VideoOverlayWindowViewsTest, UpdateNaturalSizeDoesNotMoveWindow) {}

// Tests that the OverlayWindowFrameView does not accept events so they can
// propagate to the overlay.
TEST_F(VideoOverlayWindowViewsTest, HitTestFrameView) {}

#if !BUILDFLAG(IS_CHROMEOS_LACROS)
// With pillarboxing, the close button doesn't cover the video area. Make sure
// hovering the button doesn't get handled like normal mouse exit events
// causing the controls to hide.
// TODO(http://crbug/1509791): Fix and re-enable.
TEST_F(VideoOverlayWindowViewsTest, DISABLED_NoMouseExitWithinWindowBounds) {}

#endif  // !BUILDFLAG(IS_CHROMEOS_LACROS)

TEST_F(VideoOverlayWindowViewsTest, ShowControlsOnFocus) {}

TEST_F(VideoOverlayWindowViewsTest, OnlyPauseOnCloseWhenPauseIsAvailable) {}

TEST_F(VideoOverlayWindowViewsTest, PauseOnWidgetCloseWhenPauseAvailable) {}

TEST_F(VideoOverlayWindowViewsTest,
       DontPauseOnWidgetCloseWhenPauseNotAvailable) {}

TEST_F(VideoOverlayWindowViewsTest, SmallDisplayWorkAreaDoesNotCrash) {}

// TODO(http://crbug/1509791): Fix and re-enable.
TEST_F(VideoOverlayWindowViewsTest, DISABLED_ControlsAreHiddenDuringMove) {}

TEST_F(VideoOverlayWindowViewsTest,
       ControlsAreHiddenDuringMove_MultipleUpdates) {}

TEST_F(VideoOverlayWindowViewsTest, OverlayViewIsSizedCorrectly) {}

TEST_F(VideoOverlayWindowViewsTest, OverlayViewCanBeClicked) {}

TEST_F(VideoOverlayWindowViewsTest, OverlayWindowBlocksInput) {}

TEST_F(VideoOverlayWindowViewsTest, OverlayWindowFitsInMinimumSize) {}

TEST_F(VideoOverlayWindowViewsTest, OverlayWindowStopsBlockingInput) {}

TEST_F(VideoOverlayWindowViewsTest, IsTrackedByTheOcclusionObserver) {}

class VideoOverlayWindowViewsWith2024UITest
    : public VideoOverlayWindowViewsTest {};

TEST_F(VideoOverlayWindowViewsWith2024UITest,
       MinimizeButtonClosesWithoutPausing) {}

TEST_F(VideoOverlayWindowViewsWith2024UITest, ShowsBackToTabImageButton) {}