#include <stddef.h>
#include <memory>
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/run_loop.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/test_message_loop.h"
#include "base/types/cxx23_to_underlying.h"
#include "build/build_config.h"
#include "components/ukm/test_ukm_recorder.h"
#include "media/cdm/clear_key_cdm_common.h"
#include "media/mojo/services/media_metrics_provider.h"
#include "media/mojo/services/watch_time_recorder.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
UkmEntry;
namespace media {
constexpr char kTestOrigin[] = …;
class MediaMetricsProviderTest : public testing::Test { … };
#define EXPECT_UKM …
#define EXPECT_NO_UKM …
#define EXPECT_HAS_UKM …
TEST_F(MediaMetricsProviderTest, TestUkm) { … }
TEST_F(MediaMetricsProviderTest, TestUkmMediaStream) { … }
TEST_F(MediaMetricsProviderTest, TestPipelineUMA) { … }
TEST_F(MediaMetricsProviderTest, TestPipelineUMAMediaStream) { … }
TEST_F(MediaMetricsProviderTest, TestPipelineUMANoAudioWithEme) { … }
TEST_F(MediaMetricsProviderTest, TestPipelineUMADecoderFallback) { … }
TEST_F(MediaMetricsProviderTest, TestPipelineUMARendererType) { … }
#if BUILDFLAG(IS_ANDROID)
TEST_F(MediaMetricsProviderTest, TestPipelineUMAMediaDrmSoftwareSecure) {
base::HistogramTester histogram_tester;
Initialize(false, false, false, kTestOrigin, mojom::MediaURLScheme::kHttps);
provider_->SetAudioPipelineInfo(
{false, false, AudioDecoderType::kMojo, EncryptionType::kClear});
provider_->SetVideoPipelineInfo({false, false, VideoDecoderType::kMediaCodec,
EncryptionType::kEncrypted});
provider_->SetIsEME();
provider_->SetHasVideo(VideoCodec::kVP9);
provider_->SetHasAudio(AudioCodec::kVorbis);
provider_->SetHasPlayed();
provider_->SetHaveEnough();
provider_.reset();
base::RunLoop().RunUntilIdle();
histogram_tester.ExpectBucketCount(
"Media.PipelineStatus.AudioVideo.VP9.MediaDrm.SoftwareSecure",
PIPELINE_OK, 1);
}
TEST_F(MediaMetricsProviderTest, TestPipelineUMAMediaDrmHardwareSecure) {
base::HistogramTester histogram_tester;
Initialize(false, false, false, kTestOrigin, mojom::MediaURLScheme::kHttps);
provider_->SetAudioPipelineInfo(
{false, false, AudioDecoderType::kMojo, EncryptionType::kClear});
provider_->SetVideoPipelineInfo({false, false, VideoDecoderType::kMediaCodec,
EncryptionType::kEncrypted});
provider_->SetIsEME();
provider_->SetIsHardwareSecure();
provider_->SetHasVideo(VideoCodec::kVP9);
provider_->SetHasAudio(AudioCodec::kVorbis);
provider_->SetHasPlayed();
provider_->SetHaveEnough();
provider_.reset();
base::RunLoop().RunUntilIdle();
histogram_tester.ExpectBucketCount(
"Media.PipelineStatus.AudioVideo.VP9.MediaDrm.HardwareSecure",
PIPELINE_OK, 1);
}
#endif
#undef EXPECT_UKM
#undef EXPECT_NO_UKM
#undef EXPECT_HAS_UKM
}