Skip to content

Commit

Permalink
[nplb] Refine MinimumSupport test failure message (youtube#904)
Browse files Browse the repository at this point in the history
Modifies SbMediaCanPlayMimeAndKeySystem.MinimumSupport to print the
tested mime and key system params on failure.

b/290978805

Change-Id: Id0cf9af1ab290372da2f747ce669ac819fa2506a
  • Loading branch information
osagie98 authored Aug 17, 2023
1 parent 8dcfc80 commit 93fca3c
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions starboard/nplb/media_can_play_mime_and_key_system_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,21 @@ DeviceType GetDeviceType() {
return kDeviceTypeFHD;
}

testing::AssertionResult IsMimeAndKeySystemSupported(std::string param,
std::string key_system) {
SbMediaSupportType support_type =
SbMediaCanPlayMimeAndKeySystem(param.c_str(), key_system.c_str());
if (support_type == kSbMediaSupportTypeProbably) {
return testing::AssertionSuccess();
}

return testing::AssertionFailure()
<< "SbMediaCanPlayMimeAndKeySystem(\"" << param << "\", \""
<< key_system << "\") returns " << support_type
<< ". It should return kSbMediaSupportTypeProbably ("
<< kSbMediaSupportTypeProbably << ").";
}

TEST(SbMediaCanPlayMimeAndKeySystem, SunnyDay) {
// Vp9
SbMediaCanPlayMimeAndKeySystem(
Expand Down Expand Up @@ -292,20 +307,20 @@ TEST(SbMediaCanPlayMimeAndKeySystem, MinimumSupport) {
mime_params = params_fhd;
}

const char* key_system = "";
for (auto& param : mime_params) {
SbMediaSupportType support = SbMediaCanPlayMimeAndKeySystem(param, "");
EXPECT_TRUE(support == kSbMediaSupportTypeProbably);
EXPECT_TRUE(IsMimeAndKeySystemSupported(param, key_system));
}

// AAC-LC
SbMediaSupportType result = SbMediaCanPlayMimeAndKeySystem(
"audio/mp4; codecs=\"mp4a.40.2\"; channels=2; bitrate=256000;", "");
ASSERT_EQ(result, kSbMediaSupportTypeProbably);
ASSERT_TRUE(IsMimeAndKeySystemSupported(
"audio/mp4; codecs=\"mp4a.40.2\"; channels=2; bitrate=256000",
key_system));

// HE-AAC
result = SbMediaCanPlayMimeAndKeySystem(
"audio/mp4; codecs=\"mp4a.40.5\"; channels=2; bitrate=48000;", "");
ASSERT_EQ(result, kSbMediaSupportTypeProbably);
ASSERT_TRUE(IsMimeAndKeySystemSupported(
"audio/mp4; codecs=\"mp4a.40.5\"; channels=2; bitrate=48000",
key_system));
}

TEST(SbMediaCanPlayMimeAndKeySystem, AnySupportedKeySystems) {
Expand Down

0 comments on commit 93fca3c

Please sign in to comment.