#include "content/public/browser/media_session.h"
#include <optional>
#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/functional/callback_helpers.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/synchronization/lock.h"
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "content/browser/renderer_host/render_frame_host_impl.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/common/content_features.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/content_browser_test.h"
#include "content/public/test/content_browser_test_utils.h"
#include "content/public/test/media_start_stop_observer.h"
#include "content/public/test/test_media_session_client.h"
#include "content/public/test/test_utils.h"
#include "content/shell/browser/shell.h"
#include "media/base/media_switches.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/http_request.h"
#include "services/media_session/public/cpp/features.h"
#include "services/media_session/public/cpp/test/audio_focus_test_util.h"
#include "services/media_session/public/cpp/test/mock_media_session.h"
namespace {
int hidden_metadata_placeholder_thumbnail_size = …;
}
namespace content {
namespace {
const char kMediaSessionImageTestURL[] = …;
const char kMediaSessionImageTestPageVideoElement[] = …;
const char kMediaSessionTestImagePath[] = …;
class MediaImageGetterHelper { … };
class MediaSessionBrowserTestBase : public ContentBrowserTest { … };
class MediaSessionBrowserTest : public MediaSessionBrowserTestBase { … };
class MediaSessionBrowserTestWithoutInternalMediaSession
: public MediaSessionBrowserTestBase { … };
}
IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTestWithoutInternalMediaSession,
MediaSessionNoOpWhenDisabled) { … }
IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest, SimplePlayPause) { … }
IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest, MultiplePlayersPlayPause) { … }
#if BUILDFLAG(IS_MAC)
#define MAYBE_WebContents_Muted …
#else
#define MAYBE_WebContents_Muted …
#endif
IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest, MAYBE_WebContents_Muted) { … }
#if !BUILDFLAG(IS_ANDROID)
IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest, MultipleTabsPlayPause) { … }
#endif
IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest, GetMediaImageBitmap) { … }
#if BUILDFLAG(IS_CHROMEOS)
IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest, HideMediaMetadataImageInCrOS) {
client_.SetShouldHideMetadata(true);
ASSERT_TRUE(embedded_test_server()->Start());
MediaSession* media_session =
SetupMediaImageTest(false);
ASSERT_NE(nullptr, media_session);
MediaImageGetterHelper helper(media_session, CreateTestImageWithSize(1), 0,
10);
helper.Wait();
EXPECT_EQ(hidden_metadata_placeholder_thumbnail_size,
helper.bitmap().width());
EXPECT_EQ(hidden_metadata_placeholder_thumbnail_size,
helper.bitmap().height());
EXPECT_FALSE(WasURLVisited(GetTestImageURL()));
}
#else
IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest,
DontHideMediaMetadataImageInNonCrOS) { … }
#endif
IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest,
GetMediaImageBitmap_ImageTooSmall) { … }
IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest,
GetMediaImageBitmap_ImageTooSmall_BeforeDownload) { … }
IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest,
GetMediaImageBitmap_InvalidImage) { … }
IN_PROC_BROWSER_TEST_F(MediaSessionBrowserTest, ChangeMediaElementDocument) { … }
}