Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/logging.h" | 6 #include "base/logging.h" |
| 7 #include "media/base/android/media_drm_bridge.h" | 7 #include "media/base/android/media_drm_bridge.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. | 10 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. |
| 11 | 11 |
| 12 namespace media { | 12 namespace media { |
| 13 | 13 |
| 14 #define EXPECT_TRUE_IF_AVAILABLE(a) \ | 14 #define EXPECT_TRUE_IF_AVAILABLE(a) \ |
| 15 do { \ | 15 do { \ |
| 16 if (!MediaDrmBridge::IsAvailable()) { \ | 16 if (!MediaDrmBridge::IsAvailable()) { \ |
| 17 VLOG(0) << "MediaDrm not supported on device."; \ | 17 VLOG(0) << "MediaDrm not supported on device."; \ |
| 18 EXPECT_FALSE(a); \ | 18 EXPECT_FALSE(a); \ |
| 19 } else { \ | 19 } else { \ |
| 20 EXPECT_TRUE(a); \ | 20 EXPECT_TRUE(a); \ |
| 21 } \ | 21 } \ |
| 22 } while (0) | 22 } while (0) |
| 23 | 23 |
| 24 const char kAudioMp4[] = "audio/mp4"; | 24 const char kAudioMp4[] = "audio/mp4"; |
| 25 const char kVideoMp4[] = "video/mp4"; | 25 const char kVideoMp4[] = "video/mp4"; |
| 26 const char kAudioWebM[] = "audio/webm"; | 26 const char kAudioWebM[] = "audio/webm"; |
| 27 const char kVideoWebM[] = "video/webm"; | 27 const char kVideoWebM[] = "video/webm"; |
| 28 const char kInvalidKeySystem[] = "invalid.keysystem"; | 28 const char kInvalidKeySystem[] = "invalid.keysystem"; |
| 29 const char kAcmeKeySystem[] = "com.acme.keysystem"; | |
|
xhwang
2014/05/15 15:10:29
s/acme/foo or example to make it more obvious?
ycheo (away)
2014/05/16 04:53:38
Done.
| |
| 30 const uint8 kWidevineUuid[16] = { | |
| 31 0xED, 0xEF, 0x8B, 0xA9, 0x79, 0xD6, 0x4A, 0xCE, | |
| 32 0xA3, 0xC8, 0x27, 0xDC, 0xD5, 0x1D, 0x21, 0xED }; | |
| 29 const MediaDrmBridge::SecurityLevel kLNone = | 33 const MediaDrmBridge::SecurityLevel kLNone = |
| 30 MediaDrmBridge::SECURITY_LEVEL_NONE; | 34 MediaDrmBridge::SECURITY_LEVEL_NONE; |
| 31 const MediaDrmBridge::SecurityLevel kL1 = MediaDrmBridge::SECURITY_LEVEL_1; | 35 const MediaDrmBridge::SecurityLevel kL1 = MediaDrmBridge::SECURITY_LEVEL_1; |
| 32 const MediaDrmBridge::SecurityLevel kL3 = MediaDrmBridge::SECURITY_LEVEL_3; | 36 const MediaDrmBridge::SecurityLevel kL3 = MediaDrmBridge::SECURITY_LEVEL_3; |
| 33 | 37 |
| 34 // Helper functions to avoid typing "MediaDrmBridge::" in tests. | 38 // Helper functions to avoid typing "MediaDrmBridge::" in tests. |
| 35 | 39 |
| 36 static bool IsKeySystemSupported(const std::string& key_system) { | 40 static bool IsKeySystemSupported(const std::string& key_system) { |
| 37 return MediaDrmBridge::IsKeySystemSupported(key_system); | 41 return MediaDrmBridge::IsKeySystemSupported(key_system); |
| 38 } | 42 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 86 EXPECT_FALSE(IsKeySystemSupported(kInvalidKeySystem)); | 90 EXPECT_FALSE(IsKeySystemSupported(kInvalidKeySystem)); |
| 87 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, kAudioMp4)); | 91 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, kAudioMp4)); |
| 88 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, kVideoMp4)); | 92 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, kVideoMp4)); |
| 89 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, kAudioWebM)); | 93 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, kAudioWebM)); |
| 90 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, kVideoWebM)); | 94 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, kVideoWebM)); |
| 91 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, "unknown")); | 95 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, "unknown")); |
| 92 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, "video/avi")); | 96 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, "video/avi")); |
| 93 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, "audio/mp3")); | 97 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, "audio/mp3")); |
| 94 } | 98 } |
| 95 | 99 |
| 100 TEST(MediaDrmBridgeTest, AddNewKeySystemName) { | |
| 101 EXPECT_FALSE(IsKeySystemSupported(kAcmeKeySystem)); | |
| 102 | |
| 103 MediaDrmBridge::AddKeySystem(kAcmeKeySystem, | |
| 104 // Use WV uuid, because it is the only MediaDrm we can guarentee | |
|
xhwang
2014/05/15 15:10:29
s/uuid/UUID
s/MediaDrm/key system
ycheo (away)
2014/05/16 04:53:38
Done.
| |
| 105 // that it is installed in the target device. | |
|
xhwang
2014/05/15 15:10:29
nit: target/test
ycheo (away)
2014/05/16 04:53:38
Done.
| |
| 106 std::vector<uint8>(kWidevineUuid, | |
| 107 kWidevineUuid + arraysize(kWidevineUuid))); | |
| 108 | |
| 109 EXPECT_TRUE_IF_AVAILABLE(IsKeySystemSupported(kAcmeKeySystem)); | |
| 110 EXPECT_TRUE_IF_AVAILABLE( | |
| 111 IsKeySystemSupportedWithType(kAcmeKeySystem, kVideoMp4)); | |
| 112 } | |
| 113 | |
| 114 TEST(MediaDrmBridgeTest, ShouldNotOverwriteExistingKeySystem) { | |
| 115 EXPECT_TRUE_IF_AVAILABLE(IsKeySystemSupported(kWidevineKeySystem)); | |
| 116 | |
| 117 // Add WV keysystem again with the invalid uuid. | |
| 118 MediaDrmBridge::AddKeySystem(kWidevineKeySystem, std::vector<uint8>(16, 99)); | |
| 119 | |
| 120 EXPECT_TRUE_IF_AVAILABLE(IsKeySystemSupported(kWidevineKeySystem)); | |
| 121 } | |
| 122 | |
| 96 } // namespace media | 123 } // namespace media |
| OLD | NEW |