Skip to content

Commit

Permalink
Fix the MediaDrmBridgeTest on android builds without Widevine support
Browse files Browse the repository at this point in the history
Some K+ android system doesn't have Widevine support, this change fix the test expectation on those systems.

Review URL: https://codereview.chromium.org/1055933005

Cr-Commit-Position: refs/heads/master@{#325688}
  • Loading branch information
qinmin authored and Commit bot committed Apr 17, 2015
1 parent d90f17b commit f186e22
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions media/base/android/media_drm_bridge_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@

namespace media {

#define EXPECT_TRUE_IF_AVAILABLE(a) \
do { \
if (!MediaDrmBridge::IsAvailable()) { \
VLOG(0) << "MediaDrm not supported on device."; \
EXPECT_FALSE(a); \
} else { \
EXPECT_TRUE(a); \
} \
#define EXPECT_TRUE_IF_WIDEVINE_AVAILABLE(a) \
do { \
if (!MediaDrmBridge::IsKeySystemSupported(kWidevineKeySystem)) { \
VLOG(0) << "Widevine not supported on device."; \
EXPECT_FALSE(a); \
} else { \
EXPECT_TRUE(a); \
} \
} while (0)

const char kAudioMp4[] = "audio/mp4";
Expand All @@ -42,21 +42,20 @@ static bool IsKeySystemSupportedWithType(
}

TEST(MediaDrmBridgeTest, IsKeySystemSupported_Widevine) {
EXPECT_TRUE_IF_AVAILABLE(
MediaDrmBridge::IsKeySystemSupported(kWidevineKeySystem));

// TODO(xhwang): Enable when b/13564917 is fixed.
// EXPECT_TRUE_IF_AVAILABLE(
// IsKeySystemSupportedWithType(kWidevineKeySystem, kAudioMp4));
EXPECT_TRUE_IF_AVAILABLE(
EXPECT_TRUE_IF_WIDEVINE_AVAILABLE(
IsKeySystemSupportedWithType(kWidevineKeySystem, kVideoMp4));

if (base::android::BuildInfo::GetInstance()->sdk_int() <= 19) {
EXPECT_FALSE(IsKeySystemSupportedWithType(kWidevineKeySystem, kAudioWebM));
EXPECT_FALSE(IsKeySystemSupportedWithType(kWidevineKeySystem, kVideoWebM));
} else {
EXPECT_TRUE(IsKeySystemSupportedWithType(kWidevineKeySystem, kAudioWebM));
EXPECT_TRUE(IsKeySystemSupportedWithType(kWidevineKeySystem, kVideoWebM));
EXPECT_TRUE_IF_WIDEVINE_AVAILABLE(
IsKeySystemSupportedWithType(kWidevineKeySystem, kAudioWebM));
EXPECT_TRUE_IF_WIDEVINE_AVAILABLE(
IsKeySystemSupportedWithType(kWidevineKeySystem, kVideoWebM));
}

EXPECT_FALSE(IsKeySystemSupportedWithType(kWidevineKeySystem, "unknown"));
Expand All @@ -77,7 +76,7 @@ TEST(MediaDrmBridgeTest, IsKeySystemSupported_InvalidKeySystem) {
}

TEST(MediaDrmBridgeTest, CreateWithoutSessionSupport_Widevine) {
EXPECT_TRUE_IF_AVAILABLE(
EXPECT_TRUE_IF_WIDEVINE_AVAILABLE(
MediaDrmBridge::CreateWithoutSessionSupport(kWidevineKeySystem));
}

Expand All @@ -89,7 +88,7 @@ TEST(MediaDrmBridgeTest, CreateWithoutSessionSupport_InvalidKeySystem) {
TEST(MediaDrmBridgeTest, SetSecurityLevel_Widevine) {
scoped_ptr<MediaDrmBridge> media_drm_bridge =
MediaDrmBridge::CreateWithoutSessionSupport(kWidevineKeySystem);
EXPECT_TRUE_IF_AVAILABLE(media_drm_bridge);
EXPECT_TRUE_IF_WIDEVINE_AVAILABLE(media_drm_bridge);
if (!media_drm_bridge)
return;

Expand Down

0 comments on commit f186e22

Please sign in to comment.