chromium/third_party/blink/renderer/modules/media_controls/media_controls_impl_test.cc

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

#include "third_party/blink/renderer/modules/media_controls/media_controls_impl.h"

#include <limits>
#include <memory>

#include "base/test/metrics/histogram_tester.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/input/web_mouse_event.h"
#include "third_party/blink/public/mojom/input/focus_type.mojom-blink.h"
#include "third_party/blink/public/platform/modules/remoteplayback/web_remote_playback_client.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_gc_controller.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_pointer_event_init.h"
#include "third_party/blink/renderer/core/css/css_property_value_set.h"
#include "third_party/blink/renderer/core/css/document_style_environment_variables.h"
#include "third_party/blink/renderer/core/css/style_engine.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/document_parser.h"
#include "third_party/blink/renderer/core/dom/dom_token_list.h"
#include "third_party/blink/renderer/core/dom/element_traversal.h"
#include "third_party/blink/renderer/core/dom/events/event.h"
#include "third_party/blink/renderer/core/dom/node_computed_style.h"
#include "third_party/blink/renderer/core/dom/shadow_root.h"
#include "third_party/blink/renderer/core/dom/text.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/geometry/dom_rect.h"
#include "third_party/blink/renderer/core/html/media/html_media_element.h"
#include "third_party/blink/renderer/core/html/media/html_video_element.h"
#include "third_party/blink/renderer/core/html/shadow/shadow_element_names.h"
#include "third_party/blink/renderer/core/html_names.h"
#include "third_party/blink/renderer/core/input/event_handler.h"
#include "third_party/blink/renderer/core/layout/layout_object.h"
#include "third_party/blink/renderer/core/loader/empty_clients.h"
#include "third_party/blink/renderer/core/testing/page_test_base.h"
#include "third_party/blink/renderer/modules/media_controls/elements/media_control_cast_button_element.h"
#include "third_party/blink/renderer/modules/media_controls/elements/media_control_current_time_display_element.h"
#include "third_party/blink/renderer/modules/media_controls/elements/media_control_download_button_element.h"
#include "third_party/blink/renderer/modules/media_controls/elements/media_control_fullscreen_button_element.h"
#include "third_party/blink/renderer/modules/media_controls/elements/media_control_mute_button_element.h"
#include "third_party/blink/renderer/modules/media_controls/elements/media_control_overflow_menu_button_element.h"
#include "third_party/blink/renderer/modules/media_controls/elements/media_control_overflow_menu_list_element.h"
#include "third_party/blink/renderer/modules/media_controls/elements/media_control_play_button_element.h"
#include "third_party/blink/renderer/modules/media_controls/elements/media_control_playback_speed_button_element.h"
#include "third_party/blink/renderer/modules/media_controls/elements/media_control_remaining_time_display_element.h"
#include "third_party/blink/renderer/modules/media_controls/elements/media_control_timeline_element.h"
#include "third_party/blink/renderer/modules/media_controls/elements/media_control_volume_slider_element.h"
#include "third_party/blink/renderer/modules/remoteplayback/remote_playback.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/heap/thread_state.h"
#include "third_party/blink/renderer/platform/testing/empty_web_media_player.h"
#include "third_party/blink/renderer/platform/testing/runtime_enabled_features_test_helpers.h"
#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h"
#include "third_party/blink/renderer/platform/web_test_support.h"
#include "ui/display/mojom/screen_orientation.mojom-blink.h"
#include "ui/display/screen_info.h"

// The MediaTimelineWidths histogram suffix expected to be encountered in these
// tests.
#define TIMELINE_W

namespace blink {

namespace {

class FakeChromeClient : public EmptyChromeClient {};

class MockWebMediaPlayerForImpl : public EmptyWebMediaPlayer {};

class StubLocalFrameClientForImpl : public EmptyLocalFrameClient {};

Element* GetElementByShadowPseudoId(Node& root_node,
                                    const char* shadow_pseudo_id) {}

bool IsElementVisible(Element& element) {}

void SimulateTransitionEnd(Element& element) {}

// This must match MediaControlDownloadButtonElement::DownloadActionMetrics.
enum DownloadActionMetrics {};

}  // namespace

class MediaControlsImplTest : public PageTestBase,
                              private ScopedMediaCastOverlayButtonForTest {};

void MediaControlsImplTest::MouseDownAt(gfx::PointF pos) {}

void MediaControlsImplTest::MouseMoveTo(gfx::PointF pos) {}

void MediaControlsImplTest::MouseUpAt(gfx::PointF pos) {}

void MediaControlsImplTest::GestureTapAt(gfx::PointF pos) {}

void MediaControlsImplTest::GestureDoubleTapAt(gfx::PointF pos) {}

TEST_F(MediaControlsImplTest, HideAndShow) {}

TEST_F(MediaControlsImplTest, Reset) {}

TEST_F(MediaControlsImplTest, HideAndReset) {}

TEST_F(MediaControlsImplTest, ResetDoesNotTriggerInitialLayout) {}

TEST_F(MediaControlsImplTest, CastButtonRequiresRoute) {}

TEST_F(MediaControlsImplTest, CastButtonDisableRemotePlaybackAttr) {}

TEST_F(MediaControlsImplTest, CastOverlayDefault) {}

TEST_F(MediaControlsImplTest, CastOverlayDisabled) {}

TEST_F(MediaControlsImplTest, CastOverlayDisableRemotePlaybackAttr) {}

TEST_F(MediaControlsImplTest, CastOverlayMediaControlsDisabled) {}

TEST_F(MediaControlsImplTest, CastOverlayDisabledMediaControlsDisabled) {}

TEST_F(MediaControlsImplTest, CastOverlayDisabledAutoplayMuted) {}

TEST_F(MediaControlsImplTest, CastButtonVisibilityDependsOnControlslistAttr) {}

TEST_F(MediaControlsImplTest, KeepControlsVisibleIfOverflowListVisible) {}

TEST_F(MediaControlsImplTest, DownloadButtonDisplayed) {}

TEST_F(MediaControlsImplTest, DownloadButtonNotDisplayedEmptyUrl) {}

TEST_F(MediaControlsImplTest, DownloadButtonNotDisplayedInfiniteDuration) {}

TEST_F(MediaControlsImplTest, DownloadButtonNotDisplayedHLS) {}

TEST_F(MediaControlsImplTest,
       DownloadButtonVisibilityDependsOnControlslistAttr) {}

TEST_F(MediaControlsImplTest,
       FullscreenButtonDisabledDependsOnControlslistAttr) {}

TEST_F(MediaControlsImplTest,
       PlaybackSpeedButtonVisibilityDependsOnControlslistAttr) {}

TEST_F(MediaControlsImplTest, TimelineSeekToRoundedEnd) {}

TEST_F(MediaControlsImplTest, TimelineImmediatelyUpdatesCurrentTime) {}

TEST_F(MediaControlsImplTest, TimeIndicatorsUpdatedOnSeeking) {}

TEST_F(MediaControlsImplTest, TimeIsCorrectlyFormatted) {}

namespace {

class MediaControlsImplTestWithMockScheduler : public MediaControlsImplTest {};

}  // namespace

TEST_F(MediaControlsImplTestWithMockScheduler, SeekingShowsControls) {}

TEST_F(MediaControlsImplTestWithMockScheduler,
       SeekingDoesNotShowControlsWhenNoControlsAttr) {}

TEST_F(MediaControlsImplTestWithMockScheduler,
       ControlsRemainVisibleDuringKeyboardInteraction) {}

TEST_F(MediaControlsImplTestWithMockScheduler,
       ControlsHideAfterFocusedAndMouseMovement) {}

TEST_F(MediaControlsImplTestWithMockScheduler,
       ControlsHideAfterFocusedAndMouseMoveout) {}

TEST_F(MediaControlsImplTestWithMockScheduler, CursorHidesWhenControlsHide) {}

TEST_F(MediaControlsImplTestWithMockScheduler, AccessibleFocusShowsControls) {}

TEST_F(MediaControlsImplTest,
       RemovingFromDocumentRemovesListenersAndCallbacks) {}

TEST_F(MediaControlsImplTest,
       RemovingFromDocumentWhenResettingSrcAllowsReclamation) {}

TEST_F(MediaControlsImplTest,
       ReInsertingInDocumentRestoresListenersAndCallbacks) {}

TEST_F(MediaControlsImplTest, InitialInfinityDurationHidesDurationField) {}

TEST_F(MediaControlsImplTest, InfinityDurationChangeHidesDurationField) {}

TEST_F(MediaControlsImplTestWithMockScheduler,
       ShowVolumeSliderAfterHoverTimerFired) {}

TEST_F(MediaControlsImplTestWithMockScheduler,
       VolumeSliderBehaviorWhenFocused) {}

TEST_F(MediaControlsImplTestWithMockScheduler,
       VolumeSliderDoesNotOpenWithoutAudio) {}

TEST_F(MediaControlsImplTest, CastOverlayDefaultHidesOnTimer) {}

TEST_F(MediaControlsImplTest, CastOverlayShowsOnSomeEvents) {}

TEST_F(MediaControlsImplTest, isConnected) {}

TEST_F(MediaControlsImplTest, ControlsShouldUseSafeAreaInsets) {}

TEST_F(MediaControlsImplTest, MediaControlsDisabledWithNoSource) {}

TEST_F(MediaControlsImplTest, DoubleTouchChangesTime) {}

TEST_F(MediaControlsImplTest, DoubleTouchChangesTimeWhenZoomed) {}

TEST_F(MediaControlsImplTest, HideControlsDefersStyleCalculationOnPlaying) {}

TEST_F(MediaControlsImplTest, HideControlsDefersStyleCalculationOnWaiting) {}

TEST_F(MediaControlsImplTest, CheckStateOnPlayingForFutureData) {}

TEST_F(MediaControlsImplTest, OverflowMenuInPaintContainment) {}

}  // namespace blink