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

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

Issue 230843004: Reland r262568 "Encrypted Media: Check container mime type in MediaDrmBridge". (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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
« no previous file with comments | « media/base/android/media_drm_bridge.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
(...skipping 13 matching lines...) Expand all
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 MediaDrmBridge::SecurityLevel kLNone = 29 const MediaDrmBridge::SecurityLevel kLNone =
30 MediaDrmBridge::SECURITY_LEVEL_NONE; 30 MediaDrmBridge::SECURITY_LEVEL_NONE;
31 const MediaDrmBridge::SecurityLevel kL1 = MediaDrmBridge::SECURITY_LEVEL_1; 31 const MediaDrmBridge::SecurityLevel kL1 = MediaDrmBridge::SECURITY_LEVEL_1;
32 const MediaDrmBridge::SecurityLevel kL3 = MediaDrmBridge::SECURITY_LEVEL_3; 32 const MediaDrmBridge::SecurityLevel kL3 = MediaDrmBridge::SECURITY_LEVEL_3;
33 33
34 // Helper functions to avoid typing "MediaDrmBridge::" in tests.
35
36 static bool IsKeySystemSupported(const std::string& key_system) {
37 return MediaDrmBridge::IsKeySystemSupported(key_system);
38 }
39
34 static bool IsKeySystemSupportedWithType( 40 static bool IsKeySystemSupportedWithType(
35 const std::string& key_system, 41 const std::string& key_system,
36 const std::string& container_mime_type) { 42 const std::string& container_mime_type) {
37 return MediaDrmBridge::IsKeySystemSupportedWithType(key_system, 43 return MediaDrmBridge::IsKeySystemSupportedWithType(key_system,
38 container_mime_type); 44 container_mime_type);
39 } 45 }
40 46
41 static bool IsSecurityLevelSupported( 47 static bool IsSecurityLevelSupported(
42 const std::string& key_system, 48 const std::string& key_system,
43 MediaDrmBridge::SecurityLevel security_level) { 49 MediaDrmBridge::SecurityLevel security_level) {
44 return MediaDrmBridge::IsSecurityLevelSupported(key_system, security_level); 50 return MediaDrmBridge::IsSecurityLevelSupported(key_system, security_level);
45 } 51 }
46 52
47 TEST(MediaDrmBridgeTest, IsSecurityLevelSupported_Widevine) { 53 TEST(MediaDrmBridgeTest, IsSecurityLevelSupported_Widevine) {
48 EXPECT_FALSE(IsSecurityLevelSupported(kWidevineKeySystem, kLNone)); 54 EXPECT_FALSE(IsSecurityLevelSupported(kWidevineKeySystem, kLNone));
49 // We test "L3" fully. But for "L1" we don't check the result as it depends on 55 // We test "L3" fully. But for "L1" we don't check the result as it depends on
50 // whether the test device supports "L1". 56 // whether the test device supports "L1".
51 EXPECT_TRUE_IF_AVAILABLE(IsSecurityLevelSupported(kWidevineKeySystem, kL3)); 57 EXPECT_TRUE_IF_AVAILABLE(IsSecurityLevelSupported(kWidevineKeySystem, kL3));
52 IsSecurityLevelSupported(kWidevineKeySystem, kL1); 58 IsSecurityLevelSupported(kWidevineKeySystem, kL1);
53 } 59 }
54 60
55 // Invalid keysytem is NOT supported regardless whether MediaDrm is available. 61 // Invalid keysytem is NOT supported regardless whether MediaDrm is available.
56 TEST(MediaDrmBridgeTest, IsSecurityLevelSupported_InvalidKeySystem) { 62 TEST(MediaDrmBridgeTest, IsSecurityLevelSupported_InvalidKeySystem) {
57 EXPECT_FALSE(IsSecurityLevelSupported(kInvalidKeySystem, kLNone)); 63 EXPECT_FALSE(IsSecurityLevelSupported(kInvalidKeySystem, kLNone));
58 EXPECT_FALSE(IsSecurityLevelSupported(kInvalidKeySystem, kL1)); 64 EXPECT_FALSE(IsSecurityLevelSupported(kInvalidKeySystem, kL1));
59 EXPECT_FALSE(IsSecurityLevelSupported(kInvalidKeySystem, kL3)); 65 EXPECT_FALSE(IsSecurityLevelSupported(kInvalidKeySystem, kL3));
60 } 66 }
61 67
62 TEST(MediaDrmBridgeTest, IsTypeSupported_Widevine) { 68 TEST(MediaDrmBridgeTest, IsKeySystemSupported_Widevine) {
63 EXPECT_TRUE_IF_AVAILABLE( 69 EXPECT_TRUE_IF_AVAILABLE(IsKeySystemSupported(kWidevineKeySystem));
64 IsKeySystemSupportedWithType(kWidevineKeySystem, kAudioMp4)); 70
71 // TODO(xhwang): Enable when b/13564917 is fixed.
72 // EXPECT_TRUE_IF_AVAILABLE(
73 // IsKeySystemSupportedWithType(kWidevineKeySystem, kAudioMp4));
65 EXPECT_TRUE_IF_AVAILABLE( 74 EXPECT_TRUE_IF_AVAILABLE(
66 IsKeySystemSupportedWithType(kWidevineKeySystem, kVideoMp4)); 75 IsKeySystemSupportedWithType(kWidevineKeySystem, kVideoMp4));
67 76
68 // TODO(xhwang): MediaDrmBridge.IsKeySystemSupportedWithType() doesn't check 77 EXPECT_FALSE(IsKeySystemSupportedWithType(kWidevineKeySystem, kAudioWebM));
69 // the container type. Fix IsKeySystemSupportedWithType() and update this test 78 EXPECT_FALSE(IsKeySystemSupportedWithType(kWidevineKeySystem, kVideoWebM));
70 // as necessary. See: http://crbug.com/350481 79 EXPECT_FALSE(IsKeySystemSupportedWithType(kWidevineKeySystem, "unknown"));
71 EXPECT_TRUE_IF_AVAILABLE( 80 EXPECT_FALSE(IsKeySystemSupportedWithType(kWidevineKeySystem, "video/avi"));
72 IsKeySystemSupportedWithType(kWidevineKeySystem, kAudioWebM)); 81 EXPECT_FALSE(IsKeySystemSupportedWithType(kWidevineKeySystem, "audio/mp3"));
73 EXPECT_TRUE_IF_AVAILABLE(
74 IsKeySystemSupportedWithType(kWidevineKeySystem, kVideoWebM));
75 } 82 }
76 83
77 // Invalid keysytem is NOT supported regardless whether MediaDrm is available. 84 // Invalid keysytem is NOT supported regardless whether MediaDrm is available.
78 TEST(MediaDrmBridgeTest, IsTypeSupported_InvalidKeySystem) { 85 TEST(MediaDrmBridgeTest, IsKeySystemSupported_InvalidKeySystem) {
79 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, "")); 86 EXPECT_FALSE(IsKeySystemSupported(kInvalidKeySystem));
87 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, kAudioMp4));
80 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, kVideoMp4)); 88 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, kVideoMp4));
89 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, kAudioWebM));
81 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, kVideoWebM)); 90 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, kVideoWebM));
91 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, "unknown"));
92 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, "video/avi"));
93 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, "audio/mp3"));
82 } 94 }
83 95
84 } // namespace media 96 } // namespace media
OLDNEW
« no previous file with comments | « 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