| 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/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 "base/message_loop/message_loop.h" |
| 8 #include "media/base/android/media_drm_bridge.h" | 9 #include "media/base/android/media_drm_bridge.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 11 |
| 11 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. | 12 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. |
| 12 | 13 |
| 13 namespace media { | 14 namespace media { |
| 14 | 15 |
| 15 #define EXPECT_TRUE_IF_WIDEVINE_AVAILABLE(a) \ | 16 #define EXPECT_TRUE_IF_WIDEVINE_AVAILABLE(a) \ |
| 16 do { \ | 17 do { \ |
| 17 if (!MediaDrmBridge::IsKeySystemSupported(kWidevineKeySystem)) { \ | 18 if (!MediaDrmBridge::IsKeySystemSupported(kWidevineKeySystem)) { \ |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, kAudioMp4)); | 70 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, kAudioMp4)); |
| 70 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, kVideoMp4)); | 71 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, kVideoMp4)); |
| 71 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, kAudioWebM)); | 72 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, kAudioWebM)); |
| 72 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, kVideoWebM)); | 73 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, kVideoWebM)); |
| 73 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, "unknown")); | 74 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, "unknown")); |
| 74 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, "video/avi")); | 75 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, "video/avi")); |
| 75 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, "audio/mp3")); | 76 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, "audio/mp3")); |
| 76 } | 77 } |
| 77 | 78 |
| 78 TEST(MediaDrmBridgeTest, CreateWithoutSessionSupport_Widevine) { | 79 TEST(MediaDrmBridgeTest, CreateWithoutSessionSupport_Widevine) { |
| 80 base::MessageLoop message_loop_; |
| 79 EXPECT_TRUE_IF_WIDEVINE_AVAILABLE( | 81 EXPECT_TRUE_IF_WIDEVINE_AVAILABLE( |
| 80 MediaDrmBridge::CreateWithoutSessionSupport(kWidevineKeySystem)); | 82 MediaDrmBridge::CreateWithoutSessionSupport(kWidevineKeySystem)); |
| 81 } | 83 } |
| 82 | 84 |
| 83 // Invalid key system is NOT supported regardless whether MediaDrm is available. | 85 // Invalid key system is NOT supported regardless whether MediaDrm is available. |
| 84 TEST(MediaDrmBridgeTest, CreateWithoutSessionSupport_InvalidKeySystem) { | 86 TEST(MediaDrmBridgeTest, CreateWithoutSessionSupport_InvalidKeySystem) { |
| 87 base::MessageLoop message_loop_; |
| 85 EXPECT_FALSE(MediaDrmBridge::CreateWithoutSessionSupport(kInvalidKeySystem)); | 88 EXPECT_FALSE(MediaDrmBridge::CreateWithoutSessionSupport(kInvalidKeySystem)); |
| 86 } | 89 } |
| 87 | 90 |
| 88 TEST(MediaDrmBridgeTest, SetSecurityLevel_Widevine) { | 91 TEST(MediaDrmBridgeTest, SetSecurityLevel_Widevine) { |
| 89 scoped_ptr<MediaDrmBridge> media_drm_bridge = | 92 base::MessageLoop message_loop_; |
| 93 scoped_ptr<MediaDrmBridge, BrowserCdmDeleter> media_drm_bridge = |
| 90 MediaDrmBridge::CreateWithoutSessionSupport(kWidevineKeySystem); | 94 MediaDrmBridge::CreateWithoutSessionSupport(kWidevineKeySystem); |
| 91 EXPECT_TRUE_IF_WIDEVINE_AVAILABLE(media_drm_bridge); | 95 EXPECT_TRUE_IF_WIDEVINE_AVAILABLE(media_drm_bridge); |
| 92 if (!media_drm_bridge) | 96 if (!media_drm_bridge) |
| 93 return; | 97 return; |
| 94 | 98 |
| 95 EXPECT_FALSE(media_drm_bridge->SetSecurityLevel(kLNone)); | 99 EXPECT_FALSE(media_drm_bridge->SetSecurityLevel(kLNone)); |
| 96 // We test "L3" fully. But for "L1" we don't check the result as it depends on | 100 // We test "L3" fully. But for "L1" we don't check the result as it depends on |
| 97 // whether the test device supports "L1". | 101 // whether the test device supports "L1". |
| 98 EXPECT_TRUE(media_drm_bridge->SetSecurityLevel(kL3)); | 102 EXPECT_TRUE(media_drm_bridge->SetSecurityLevel(kL3)); |
| 99 media_drm_bridge->SetSecurityLevel(kL1); | 103 media_drm_bridge->SetSecurityLevel(kL1); |
| 100 } | 104 } |
| 101 | 105 |
| 102 } // namespace media | 106 } // namespace media |
| OLD | NEW |