chromium/chrome/browser/ui/views/frame/picture_in_picture_browser_frame_view_interactive_uitest.cc

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

#include <optional>

#include "base/memory/raw_ptr.h"
#include "base/strings/strcat.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/media/webrtc/webrtc_browsertest_base.h"
#include "chrome/browser/picture_in_picture/auto_picture_in_picture_tab_helper.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/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/frame/picture_in_picture_browser_frame_view.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/document_picture_in_picture_window_controller.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/isolated_world_ids.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/media_start_stop_observer.h"
#include "media/base/media_switches.h"
#include "net/dns/mock_host_resolver.h"
#include "third_party/blink/public/common/features.h"
#include "ui/events/test/event_generator.h"
#include "ui/gfx/animation/animation_test_api.h"
#include "ui/views/widget/widget_utils.h"

#if BUILDFLAG(IS_LINUX)
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/themes/theme_service_factory.h"
#include "ui/linux/fake_linux_ui.h"
#include "ui/linux/linux_ui_getter.h"
#endif

namespace {

WithParamInterface;

// Contains all expectations associated with animations at a given point in
// time.
struct ExpectationsAtTimeDelta {};

struct AnimationTimingTestCase {};

AnimationTimingTest;

constexpr base::TimeDelta kFirstAnimationInterval =;
constexpr base::TimeDelta kSecondAnimationInterval =;
constexpr base::TimeDelta kThirdAnimationInterval =;
constexpr base::TimeDelta kFourthAnimationInterval =;
constexpr base::TimeDelta kFifthAnimationInterval =;
constexpr base::TimeDelta kAnimationDuration =;

const base::FilePath::CharType kPictureInPictureDocumentPipPage[] =);
const base::FilePath::CharType kCameraPage[] =);

class AnimationWaiter {};

class PictureInPictureBrowserFrameViewTest : public WebRtcTestBase,
                                             public AnimationTimingTest {};

#if BUILDFLAG(IS_WIN)
// Document PIP is not supported in LACROS.
// TODO(jazzhsu): Fix test on MAC and Wayland. Test currently not working on
// those platforms because if we send mouse move event outside of the pip window
// in ui_test_utils::SendMouseMoveSync, the pip window will not receive the
// event.
#define MAYBE_TitleActivation
#else
#define MAYBE_TitleActivation
#endif
IN_PROC_BROWSER_TEST_F(PictureInPictureBrowserFrameViewTest,
                       MAYBE_TitleActivation) {}

#if RESIZE_DOCUMENT_PICTURE_IN_PICTURE_TO_DIALOG
IN_PROC_BROWSER_TEST_F(PictureInPictureBrowserFrameViewTest,
                       ResizesToFitChildDialogs) {}

IN_PROC_BROWSER_TEST_F(PictureInPictureBrowserFrameViewTest,
                       RespectsUserLocationChangesAfterChildDialogCloses) {}

IN_PROC_BROWSER_TEST_F(PictureInPictureBrowserFrameViewTest,
                       RespectsUserBoundsChangesAfterChildDialogCloses) {}

#endif  // RESIZE_DOCUMENT_PICTURE_IN_PICTURE_TO_DIALOG

IN_PROC_BROWSER_TEST_F(PictureInPictureBrowserFrameViewTest,
                       TitleActivatesWithOverlayView) {}

IN_PROC_BROWSER_TEST_F(PictureInPictureBrowserFrameViewTest,
                       IsTrackedByTheOcclusionObserver) {}

IN_PROC_BROWSER_TEST_F(PictureInPictureBrowserFrameViewTest,
                       WindowTitleUsesOpenersTitle) {}

#if BUILDFLAG(IS_LINUX)

class FakeLinuxUiGetter : public ui::LinuxUiGetter {};

class PictureInPictureBrowserFrameViewLinuxNoClientNativeDecorationsTest
    : public PictureInPictureBrowserFrameViewTest {};

// Regression test for https://crbug.com/325459394:
// PiP should not crash if the Linux native theme does not draw client-side
// frame decorations.
IN_PROC_BROWSER_TEST_F(
    PictureInPictureBrowserFrameViewLinuxNoClientNativeDecorationsTest,
    DoesNotCrash) {}

#endif

IN_PROC_BROWSER_TEST_F(PictureInPictureBrowserFrameViewTest,
                       RespectsDisallowReturnToOpenerWhenDefault) {}

IN_PROC_BROWSER_TEST_F(PictureInPictureBrowserFrameViewTest,
                       RespectsDisallowReturnToOpenerWhenTrue) {}

IN_PROC_BROWSER_TEST_F(PictureInPictureBrowserFrameViewTest,
                       RespectsDisallowReturnToOpenerWhenFalse) {}

IN_PROC_BROWSER_TEST_P(PictureInPictureBrowserFrameViewTest,
                       TestAnimationTiming) {}

INSTANTIATE_TEST_SUITE_P(
    AnimationTimingTestSuiteInstantiation,
    PictureInPictureBrowserFrameViewTest,
    testing::ValuesIn<AnimationTimingTestCase>({};

}  // namespace