chromium/third_party/blink/renderer/core/html/media/html_media_element_test.cc

// Copyright 2016 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/core/html/media/html_media_element.h"

#include "base/run_loop.h"
#include "base/test/gtest_util.h"
#include "media/base/media_content_type.h"
#include "media/base/media_switches.h"
#include "media/mojo/mojom/media_player.mojom-blink.h"
#include "services/media_session/public/mojom/media_session.mojom-blink.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/mojom/autoplay/autoplay.mojom-blink.h"
#include "third_party/blink/public/platform/web_media_player.h"
#include "third_party/blink/public/platform/web_media_player_source.h"
#include "third_party/blink/renderer/core/css/css_default_style_sheets.h"
#include "third_party/blink/renderer/core/dom/dom_implementation.h"
#include "third_party/blink/renderer/core/dom/element.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.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/fullscreen/fullscreen.h"
#include "third_party/blink/renderer/core/html/html_document.h"
#include "third_party/blink/renderer/core/html/media/html_audio_element.h"
#include "third_party/blink/renderer/core/html/media/html_video_element.h"
#include "third_party/blink/renderer/core/html/media/media_error.h"
#include "third_party/blink/renderer/core/html/media/media_video_visibility_tracker.h"
#include "third_party/blink/renderer/core/html/time_ranges.h"
#include "third_party/blink/renderer/core/html/track/audio_track_list.h"
#include "third_party/blink/renderer/core/html/track/video_track_list.h"
#include "third_party/blink/renderer/core/loader/empty_clients.h"
#include "third_party/blink/renderer/core/testing/dummy_page_holder.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/heap/thread_state_scopes.h"
#include "third_party/blink/renderer/platform/network/network_state_notifier.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/task_environment.h"
#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
#include "ui/gfx/geometry/size.h"

_;
AnyNumber;
NanSensitiveDoubleEq;
Return;

namespace blink {

namespace {

enum class TestURLScheme {};

AtomicString SrcSchemeToURL(TestURLScheme scheme) {}

class MockWebMediaPlayer : public EmptyWebMediaPlayer {};

class WebMediaStubLocalFrameClient : public EmptyLocalFrameClient {};

class FullscreenMockChromeClient : public EmptyChromeClient {};

// Helper class to mock `RequestVisibility` callbacks.
class RequestVisibilityWaiter {};

// Helper class that provides an implementation of the MediaPlayerObserver mojo
// interface to allow checking that messages sent over mojo are received with
// the right values in the other end.
class TestMediaPlayerObserver final
    : public media::mojom::blink::MediaPlayerObserver {};

class TestMediaPlayerHost final : public media::mojom::blink::MediaPlayerHost {};

enum class MediaTestParam {};

}  // namespace

class HTMLMediaElementTest : public testing::TestWithParam<MediaTestParam> {};

INSTANTIATE_TEST_SUITE_P();
INSTANTIATE_TEST_SUITE_P();

TEST_P(HTMLMediaElementTest, effectiveMediaVolume) {}

TEST_P(HTMLMediaElementTest, preloadType) {}

TEST_P(HTMLMediaElementTest, CouldPlayIfEnoughDataRespondsToPlay) {}

TEST_P(HTMLMediaElementTest, CouldPlayIfEnoughDataRespondsToEnded) {}

TEST_P(HTMLMediaElementTest, CouldPlayIfEnoughDataRespondsToError) {}

TEST_P(HTMLMediaElementTest, SetLatencyHint) {}

TEST_P(HTMLMediaElementTest, CouldPlayIfEnoughDataInfiniteStreamNeverEnds) {}

TEST_P(HTMLMediaElementTest, AutoplayInitiated_DocumentActivation_Low_Gesture) {}

TEST_P(HTMLMediaElementTest,
       AutoplayInitiated_DocumentActivation_High_Gesture) {}

TEST_P(HTMLMediaElementTest,
       AutoplayInitiated_DocumentActivation_High_NoGesture) {}

TEST_P(HTMLMediaElementTest, AutoplayInitiated_GestureRequired_Gesture) {}

TEST_P(HTMLMediaElementTest, AutoplayInitiated_NoGestureRequired_Gesture) {}

TEST_P(HTMLMediaElementTest, AutoplayInitiated_NoGestureRequired_NoGesture) {}

TEST_P(HTMLMediaElementTest,
       DeferredMediaPlayerLoadDoesNotDelayWindowLoadEvent) {}

TEST_P(HTMLMediaElementTest, ImmediateMediaPlayerLoadDoesDelayWindowLoadEvent) {}

TEST_P(HTMLMediaElementTest, DefaultTracksAreEnabled) {}

// Ensure a visibility observer is created for lazy loading.
TEST_P(HTMLMediaElementTest, VisibilityObserverCreatedForLazyLoad) {}

TEST_P(HTMLMediaElementTest, DomInteractive) {}

TEST_P(HTMLMediaElementTest, ContextFrozen) {}

TEST_P(HTMLMediaElementTest, GcMarkingNoAllocWebTimeRanges) {}

// Reproduce crbug.com/970150
TEST_P(HTMLMediaElementTest, GcMarkingNoAllocHasActivity) {}

TEST_P(HTMLMediaElementTest, CapturesRedirectedSrc) {}

TEST_P(HTMLMediaElementTest, EmptyRedirectedSrcUsesOriginal) {}

TEST_P(HTMLMediaElementTest, NoPendingActivityAfterCurrentData) {}

TEST_P(HTMLMediaElementTest, OnTimeUpdate_DurationChange) {}

TEST_P(HTMLMediaElementTest, OnTimeUpdate_PlayPauseSetRate) {}

TEST_P(HTMLMediaElementTest, OnTimeUpdate_ReadyState) {}

TEST_P(HTMLMediaElementTest, OnTimeUpdate_Seeking) {}

TEST_P(HTMLMediaElementTest, ShowPosterFlag_InitiallyTrue) {}

TEST_P(HTMLMediaElementTest, ShowPosterFlag_FalseAfterPlay) {}

TEST_P(HTMLMediaElementTest, ShowPosterFlag_FalseAfterSeek) {}

TEST_P(HTMLMediaElementTest, ShowPosterFlag_FalseAfterAutoPlay) {}

TEST_P(HTMLMediaElementTest, ShowPosterFlag_FalseAfterPlayBeforeReady) {}

TEST_P(HTMLMediaElementTest, SendMediaPlayingToObserver) {}

TEST_P(HTMLMediaElementTest, SendMediaPausedToObserver) {}

TEST_P(HTMLMediaElementTest, SendMutedStatusChangeToObserver) {}

TEST_P(HTMLMediaElementTest, SendMediaMetadataChangedToObserver) {}

TEST_P(HTMLMediaElementTest, SendMediaSizeChangeToObserver) {}

TEST_P(HTMLMediaElementTest, SendRemotePlaybackMetadataChangeToObserver) {}

TEST_P(HTMLMediaElementTest, SendUseAudioServiceChangedToObserver) {}

TEST_P(HTMLMediaElementTest,
       ControlsVisibilityUserChoiceOverridesControlsAttr) {}

TEST_P(HTMLMediaElementTest,
       MediaShouldShowAllControlsDependsOnControlslistAttr) {}

TEST_P(HTMLMediaElementTest,
       DestroyMediaPlayerWhenSwitchingSameOriginDocumentsIfReuseIsNotEnabled) {}

TEST_P(
    HTMLMediaElementTest,
    DestroyMediaPlayerWhenSwitchingDifferentOriginDocumentsIfReuseIsNotEnabled) {}

TEST_P(
    HTMLMediaElementTest,
    DoNotDestroyMediaPlayerWhenSwitchingSameOriginDocumentsIfReuseIsEnabled) {}

TEST_P(
    HTMLMediaElementTest,
    DestroyMediaPlayerWhenSwitchingSameOriginDocumentsIfNewDocumentIsNotInPictureInPicture) {}

TEST_P(
    HTMLMediaElementTest,
    DestroyMediaPlayerWhenSwitchingSameOriginDocumentsIfFirstDocumentIsInPictureInPicture) {}

TEST_P(
    HTMLMediaElementTest,
    DestroyMediaPlayerWhenSwitchingSameOriginDocumentsIfNotOpenerPipRelation) {}

TEST_P(
    HTMLMediaElementTest,
    DestroyMediaPlayerWhenSwitchingDifferentOriginDocumentsIfReuseIsEnabled) {}

TEST_P(HTMLMediaElementTest,
       DestroyMediaPlayerWhenUnloadingOpenerIfReuseIsEnabled) {}

TEST_P(HTMLMediaElementTest,
       CreateMediaPlayerAfterMovingElementUsesOpenerFrameIfReuseIsEnabled) {}

TEST_P(HTMLMediaElementTest,
       CreateMediaPlayerAfterMovingElementUsesNewFrameIfReuseIsNotEnabled) {}

TEST_P(HTMLMediaElementTest, PlayedWithoutUserActivation) {}

TEST_P(HTMLMediaElementTest, PlayedWithUserActivation) {}

TEST_P(HTMLMediaElementTest, PlayedWithUserActivationBeforeLoad) {}

TEST_P(HTMLMediaElementTest, CanFreezeWithoutMediaPlayerAttached) {}

TEST_P(HTMLMediaElementTest, CanFreezeWithMediaPlayerAttached) {}

TEST_P(HTMLMediaElementTest, MoveToAnotherDocument) {}

TEST_P(HTMLMediaElementTest, LoadingFailsAfterContextDestruction) {}

TEST_P(HTMLMediaElementTest, VideoVisibilityTrackerDetachedOnPause) {}

TEST_P(HTMLMediaElementTest, VideoVisibilityTrackerDetachedOnEnded) {}

TEST_P(HTMLMediaElementTest, VideoVisibilityTrackerDetachedOnContextDestroyed) {}

TEST_P(HTMLMediaElementTest, VideoVisibilityTrackerDetachedOnRemovedFrom) {}

TEST_P(HTMLMediaElementTest,
       VideoVisibilityTrackerDetachedOnWebMediaPlayerCleared) {}

TEST_P(HTMLMediaElementTest,
       VideoVisibilityTrackerInsertingPlayingVideoReusesTracker) {}

TEST_P(HTMLMediaElementTest,
       VideoVisibilityTrackerStatusUpdatedOnVideoEnterAndExitFullscreen) {}

TEST_P(HTMLMediaElementTest,
       VideoVisibilityTrackerStatusUpdatedOnAnyElementEnterAndExitFullscreen) {}

TEST_P(HTMLMediaElementTest,
       VideoVisibilityTrackerDetachedOnEnterFullscreenAfterVideoPauseThenPlay) {}

TEST_P(
    HTMLMediaElementTest,
    VideoVisibilityTrackerDetachedOnEntereFullscreenAfterInsertingPlayingVideo) {}

TEST_P(
    HTMLMediaElementTest,
    VideoVisibilityTrackerFullScreenEventListenerRemovedOnDidMoveToNewDocument) {}

TEST_P(HTMLMediaElementTest,
       VideoVisibilityTrackerFullScreenEventListenerRemovedOnRemovedFrom) {}

TEST_P(HTMLMediaElementTest,
       RequestVisibilityReturnsFalseWhenTrackerDoesNotExist) {}

TEST_P(HTMLMediaElementTest,
       RequestVisibilityReturnsFalseWhenTrackerIsNotAttached) {}

}  // namespace blink