Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(261)

Side by Side Diff: media/base/android/media_drm_bridge_unittest.cc

Issue 284183003: Add MediaDrmBridge::AddKeySystemUuidMapping(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed reviewers' comments. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 kFooKeySystem[] = "com.foo.keysystem";
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
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, AddNewKeySystemMapping) {
101 EXPECT_FALSE(IsKeySystemSupported(kFooKeySystem));
102
103 // Use WV UUID for foo, because it is the only key system we can guarentee
104 // that it is installed in the test device.
105 std::vector<uint8> foo_uuid(kWidevineUuid,
106 kWidevineUuid + arraysize(kWidevineUuid));
107 MediaDrmBridge::AddKeySystemUuidMapping(kFooKeySystem, foo_uuid);
108
109 EXPECT_TRUE_IF_AVAILABLE(IsKeySystemSupported(kFooKeySystem));
110 EXPECT_TRUE_IF_AVAILABLE(
111 IsKeySystemSupportedWithType(kFooKeySystem, kVideoMp4));
112 }
113
114 TEST(MediaDrmBridgeTest, ShouldNotOverwriteExistingKeySystem) {
115 EXPECT_TRUE_IF_AVAILABLE(IsKeySystemSupported(kWidevineKeySystem));
116 std::vector<uint8> invalid_uuid = std::vector<uint8>(16, 99);
117 #if DCHECK_IS_ON
118 ASSERT_DEATH({
119 MediaDrmBridge::AddKeySystemUuidMapping(kWidevineKeySystem, invalid_uuid);
120 }, "");
121 #else
122 // Try to add WV keysystem with the invalid UUID.
123 MediaDrmBridge::AddKeySystemUuidMapping(kWidevineKeySystem, invalid_uuid);
124
125 EXPECT_TRUE_IF_AVAILABLE(IsKeySystemSupported(kWidevineKeySystem));
126 #endif
127 }
128
96 } // namespace media 129 } // namespace media
OLDNEW
« media/base/android/media_drm_bridge.cc ('K') | « media/base/android/media_drm_bridge.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698