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

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

Issue 930413003: MediaDrm: Only apply Widevine security levels to the Widevine key system. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add creation and SetSecurityLevel tests. Created 5 years, 10 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
« 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/android/build_info.h" 5 #include "base/android/build_info.h"
6 #include "base/basictypes.h" 6 #include "base/basictypes.h"
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "media/base/android/media_drm_bridge.h" 8 #include "media/base/android/media_drm_bridge.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 16 matching lines...) Expand all
27 const char kAudioWebM[] = "audio/webm"; 27 const char kAudioWebM[] = "audio/webm";
28 const char kVideoWebM[] = "video/webm"; 28 const char kVideoWebM[] = "video/webm";
29 const char kInvalidKeySystem[] = "invalid.keysystem"; 29 const char kInvalidKeySystem[] = "invalid.keysystem";
30 const MediaDrmBridge::SecurityLevel kLNone = 30 const MediaDrmBridge::SecurityLevel kLNone =
31 MediaDrmBridge::SECURITY_LEVEL_NONE; 31 MediaDrmBridge::SECURITY_LEVEL_NONE;
32 const MediaDrmBridge::SecurityLevel kL1 = MediaDrmBridge::SECURITY_LEVEL_1; 32 const MediaDrmBridge::SecurityLevel kL1 = MediaDrmBridge::SECURITY_LEVEL_1;
33 const MediaDrmBridge::SecurityLevel kL3 = MediaDrmBridge::SECURITY_LEVEL_3; 33 const MediaDrmBridge::SecurityLevel kL3 = MediaDrmBridge::SECURITY_LEVEL_3;
34 34
35 // Helper functions to avoid typing "MediaDrmBridge::" in tests. 35 // Helper functions to avoid typing "MediaDrmBridge::" in tests.
36 36
37 static bool IsKeySystemSupported(const std::string& key_system) {
38 return MediaDrmBridge::IsKeySystemSupported(key_system);
39 }
40
41 static bool IsKeySystemSupportedWithType( 37 static bool IsKeySystemSupportedWithType(
42 const std::string& key_system, 38 const std::string& key_system,
43 const std::string& container_mime_type) { 39 const std::string& container_mime_type) {
44 return MediaDrmBridge::IsKeySystemSupportedWithType(key_system, 40 return MediaDrmBridge::IsKeySystemSupportedWithType(key_system,
45 container_mime_type); 41 container_mime_type);
46 } 42 }
47 43
48 static bool IsSecurityLevelSupported(
49 const std::string& key_system,
50 MediaDrmBridge::SecurityLevel security_level) {
51 return MediaDrmBridge::IsSecurityLevelSupported(key_system, security_level);
52 }
53
54 TEST(MediaDrmBridgeTest, IsSecurityLevelSupported_Widevine) {
55 EXPECT_FALSE(IsSecurityLevelSupported(kWidevineKeySystem, kLNone));
56 // We test "L3" fully. But for "L1" we don't check the result as it depends on
57 // whether the test device supports "L1".
58 EXPECT_TRUE_IF_AVAILABLE(IsSecurityLevelSupported(kWidevineKeySystem, kL3));
59 IsSecurityLevelSupported(kWidevineKeySystem, kL1);
60 }
61
62 // Invalid keysytem is NOT supported regardless whether MediaDrm is available.
63 TEST(MediaDrmBridgeTest, IsSecurityLevelSupported_InvalidKeySystem) {
64 EXPECT_FALSE(IsSecurityLevelSupported(kInvalidKeySystem, kLNone));
65 EXPECT_FALSE(IsSecurityLevelSupported(kInvalidKeySystem, kL1));
66 EXPECT_FALSE(IsSecurityLevelSupported(kInvalidKeySystem, kL3));
67 }
68
69 TEST(MediaDrmBridgeTest, IsKeySystemSupported_Widevine) { 44 TEST(MediaDrmBridgeTest, IsKeySystemSupported_Widevine) {
70 EXPECT_TRUE_IF_AVAILABLE(IsKeySystemSupported(kWidevineKeySystem)); 45 EXPECT_TRUE_IF_AVAILABLE(
46 MediaDrmBridge::IsKeySystemSupported(kWidevineKeySystem));
71 47
72 // TODO(xhwang): Enable when b/13564917 is fixed. 48 // TODO(xhwang): Enable when b/13564917 is fixed.
73 // EXPECT_TRUE_IF_AVAILABLE( 49 // EXPECT_TRUE_IF_AVAILABLE(
74 // IsKeySystemSupportedWithType(kWidevineKeySystem, kAudioMp4)); 50 // IsKeySystemSupportedWithType(kWidevineKeySystem, kAudioMp4));
75 EXPECT_TRUE_IF_AVAILABLE( 51 EXPECT_TRUE_IF_AVAILABLE(
76 IsKeySystemSupportedWithType(kWidevineKeySystem, kVideoMp4)); 52 IsKeySystemSupportedWithType(kWidevineKeySystem, kVideoMp4));
77 53
78 if (base::android::BuildInfo::GetInstance()->sdk_int() <= 19) { 54 if (base::android::BuildInfo::GetInstance()->sdk_int() <= 19) {
79 EXPECT_FALSE(IsKeySystemSupportedWithType(kWidevineKeySystem, kAudioWebM)); 55 EXPECT_FALSE(IsKeySystemSupportedWithType(kWidevineKeySystem, kAudioWebM));
80 EXPECT_FALSE(IsKeySystemSupportedWithType(kWidevineKeySystem, kVideoWebM)); 56 EXPECT_FALSE(IsKeySystemSupportedWithType(kWidevineKeySystem, kVideoWebM));
81 } else { 57 } else {
82 EXPECT_TRUE(IsKeySystemSupportedWithType(kWidevineKeySystem, kAudioWebM)); 58 EXPECT_TRUE(IsKeySystemSupportedWithType(kWidevineKeySystem, kAudioWebM));
83 EXPECT_TRUE(IsKeySystemSupportedWithType(kWidevineKeySystem, kVideoWebM)); 59 EXPECT_TRUE(IsKeySystemSupportedWithType(kWidevineKeySystem, kVideoWebM));
84 } 60 }
85 61
86 EXPECT_FALSE(IsKeySystemSupportedWithType(kWidevineKeySystem, "unknown")); 62 EXPECT_FALSE(IsKeySystemSupportedWithType(kWidevineKeySystem, "unknown"));
87 EXPECT_FALSE(IsKeySystemSupportedWithType(kWidevineKeySystem, "video/avi")); 63 EXPECT_FALSE(IsKeySystemSupportedWithType(kWidevineKeySystem, "video/avi"));
88 EXPECT_FALSE(IsKeySystemSupportedWithType(kWidevineKeySystem, "audio/mp3")); 64 EXPECT_FALSE(IsKeySystemSupportedWithType(kWidevineKeySystem, "audio/mp3"));
89 } 65 }
90 66
91 // Invalid keysytem is NOT supported regardless whether MediaDrm is available. 67 // Invalid key system is NOT supported regardless whether MediaDrm is available.
92 TEST(MediaDrmBridgeTest, IsKeySystemSupported_InvalidKeySystem) { 68 TEST(MediaDrmBridgeTest, IsKeySystemSupported_InvalidKeySystem) {
93 EXPECT_FALSE(IsKeySystemSupported(kInvalidKeySystem)); 69 EXPECT_FALSE(MediaDrmBridge::IsKeySystemSupported(kInvalidKeySystem));
94 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, kAudioMp4)); 70 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, kAudioMp4));
95 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, kVideoMp4)); 71 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, kVideoMp4));
96 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, kAudioWebM)); 72 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, kAudioWebM));
97 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, kVideoWebM)); 73 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, kVideoWebM));
98 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, "unknown")); 74 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, "unknown"));
99 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, "video/avi")); 75 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, "video/avi"));
100 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, "audio/mp3")); 76 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, "audio/mp3"));
101 } 77 }
102 78
79 TEST(MediaDrmBridgeTest, CreateWithoutSessionSupport_Widevine) {
ddorwin 2015/02/18 18:11:50 These two tests are new. Note: CreateWithoutSessi
80 EXPECT_TRUE_IF_AVAILABLE(
81 MediaDrmBridge::CreateWithoutSessionSupport(kWidevineKeySystem));
82 }
83
84 // Invalid key system is NOT supported regardless whether MediaDrm is available.
85 TEST(MediaDrmBridgeTest, CreateWithoutSessionSupport_InvalidKeySystem) {
86 EXPECT_FALSE(MediaDrmBridge::CreateWithoutSessionSupport(kInvalidKeySystem));
87 }
88
89 TEST(MediaDrmBridgeTest, SetSecurityLevel_Widevine) {
ddorwin 2015/02/18 18:11:51 This test covers the only remaining useful part of
90 scoped_ptr<MediaDrmBridge> media_drm_bridge =
91 MediaDrmBridge::CreateWithoutSessionSupport(kWidevineKeySystem);
92 EXPECT_TRUE_IF_AVAILABLE(media_drm_bridge);
93 if (!media_drm_bridge)
94 return;
95
96 EXPECT_FALSE(media_drm_bridge->SetSecurityLevel(kLNone));
97 // We test "L3" fully. But for "L1" we don't check the result as it depends on
98 // whether the test device supports "L1".
99 EXPECT_TRUE(media_drm_bridge->SetSecurityLevel(kL3));
qinmin 2015/02/18 17:53:03 have you tested this on ICS devices?
ddorwin 2015/02/18 18:11:50 ICS devices should exit at line 94, right? This is
qinmin 2015/02/18 21:32:51 I see. Sorry i missed that.
100 media_drm_bridge->SetSecurityLevel(kL1);
101 }
102
103 } // namespace media 103 } // 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