chromium/chrome/browser/picture_in_picture/auto_pip_setting_overlay_view_unittest.cc

// Copyright 2023 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/picture_in_picture/auto_pip_setting_overlay_view.h"

#include <memory>
#include <utility>

#include "base/memory/raw_ptr.h"
#include "base/test/mock_callback.h"
#include "chrome/browser/ui/color/chrome_color_id.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/layer_animator.h"
#include "ui/compositor/scoped_animation_duration_scale_mode.h"
#include "ui/events/test/event_generator.h"
#include "ui/views/test/views_test_base.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_observer.h"
#include "ui/views/widget/widget_utils.h"

namespace {

class MockWidgetObserver : public views::WidgetObserver {};

}  // namespace

class AutoPipSettingOverlayViewTest : public views::ViewsTestBase {};

TEST_F(AutoPipSettingOverlayViewTest, TestViewInitialization) {}

TEST_F(AutoPipSettingOverlayViewTest, TestBackgroundLayerAnimation) {}

TEST_F(AutoPipSettingOverlayViewTest, TestWantsEvent) {}

TEST_F(AutoPipSettingOverlayViewTest,
       TestOverlayViewDoesNotHaveFocusForDocumentPip) {}

TEST_F(AutoPipSettingOverlayViewTest,
       TestOverlayViewDoesNotHaveFocusForVideoPip) {}

#if BUILDFLAG(IS_MAC)
// Ensure that bubbles requested for Document Picture-in-Picture windows are
// shown not shown before an 180Ms delay, on Mac.
TEST_F(AutoPipSettingOverlayViewTest,
       TestOverlayViewNotShownBeforeDelayForDocumentPip) {
  // Initially bubble should not be shown.
  setting_overlay()->ShowBubble(anchor_view_widget()->GetNativeView());
  EXPECT_FALSE(
      setting_overlay()->get_view_for_testing()->GetWidget()->IsVisible());

  // Bubble should not be shown before an 180Ms delay. This is to ensure that
  // the Mac window animation has completed, before we show the permission
  // prompt.
  task_environment()->FastForwardBy(base::Milliseconds(179));
  EXPECT_FALSE(
      setting_overlay()->get_view_for_testing()->GetWidget()->IsVisible());
}
#endif  // BUILDFLAG(IS_MAC)

// Ensure that bubbles requested for Document Picture-in-Picture windows are
// shown after the scrim animation.
TEST_F(AutoPipSettingOverlayViewTest, TestOverlayViewShownWithDelay) {}

TEST_F(AutoPipSettingOverlayViewTest, TestDeletingOverlayClosesBubble) {}

namespace {

class TestAutoPipSettingOverlayViewDelegate
    : public AutoPipSettingOverlayView::Delegate {};

}  // namespace

TEST_F(AutoPipSettingOverlayViewTest, TestAutoPipSettingOverlayViewDelegate) {}