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

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

Issue 2823513002: [Clank] Load origin id before create MediaDrmBridge (Closed)
Patch Set: Rebase + Nit Created 3 years, 5 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') | media/base/android/media_drm_storage_bridge.h » ('j') | 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 <memory> 5 #include <memory>
6 6
7 #include "base/android/build_info.h" 7 #include "base/android/build_info.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/run_loop.h"
12 #include "media/base/android/media_drm_bridge.h" 13 #include "media/base/android/media_drm_bridge.h"
13 #include "media/base/provision_fetcher.h" 14 #include "media/base/provision_fetcher.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 16
16 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. 17 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
17 18
18 namespace media { 19 namespace media {
19 20
20 #define EXPECT_TRUE_IF_WIDEVINE_AVAILABLE(a) \ 21 #define EXPECT_TRUE_IF_WIDEVINE_AVAILABLE(a) \
21 do { \ 22 do { \
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 static std::unique_ptr<ProvisionFetcher> Create() { 54 static std::unique_ptr<ProvisionFetcher> Create() {
54 return base::WrapUnique(new MockProvisionFetcher); 55 return base::WrapUnique(new MockProvisionFetcher);
55 } 56 }
56 57
57 // ProvisionFetcher implementation. 58 // ProvisionFetcher implementation.
58 void Retrieve(const std::string& default_url, 59 void Retrieve(const std::string& default_url,
59 const std::string& request_data, 60 const std::string& request_data,
60 const ResponseCB& response_cb) override {} 61 const ResponseCB& response_cb) override {}
61 }; 62 };
62 63
64 void CheckMediaDrmBridge(bool expect_success,
65 scoped_refptr<MediaDrmBridge> media_drm_bridge) {
66 if (expect_success) {
67 EXPECT_TRUE_IF_WIDEVINE_AVAILABLE(media_drm_bridge);
68 } else {
69 EXPECT_FALSE(media_drm_bridge);
70 }
71 }
72
63 } // namespace (anonymous) 73 } // namespace (anonymous)
64 74
65 TEST(MediaDrmBridgeTest, IsKeySystemSupported_Widevine) { 75 TEST(MediaDrmBridgeTest, IsKeySystemSupported_Widevine) {
66 // TODO(xhwang): Enable when b/13564917 is fixed. 76 // TODO(xhwang): Enable when b/13564917 is fixed.
67 // EXPECT_TRUE_IF_AVAILABLE( 77 // EXPECT_TRUE_IF_AVAILABLE(
68 // IsKeySystemSupportedWithType(kWidevineKeySystem, kAudioMp4)); 78 // IsKeySystemSupportedWithType(kWidevineKeySystem, kAudioMp4));
69 EXPECT_TRUE_IF_WIDEVINE_AVAILABLE( 79 EXPECT_TRUE_IF_WIDEVINE_AVAILABLE(
70 IsKeySystemSupportedWithType(kWidevineKeySystem, kVideoMp4)); 80 IsKeySystemSupportedWithType(kWidevineKeySystem, kVideoMp4));
71 81
72 if (base::android::BuildInfo::GetInstance()->sdk_int() <= 19) { 82 if (base::android::BuildInfo::GetInstance()->sdk_int() <= 19) {
(...skipping 18 matching lines...) Expand all
91 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, kVideoMp4)); 101 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, kVideoMp4));
92 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, kAudioWebM)); 102 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, kAudioWebM));
93 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, kVideoWebM)); 103 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, kVideoWebM));
94 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, "unknown")); 104 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, "unknown"));
95 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, "video/avi")); 105 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, "video/avi"));
96 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, "audio/mp3")); 106 EXPECT_FALSE(IsKeySystemSupportedWithType(kInvalidKeySystem, "audio/mp3"));
97 } 107 }
98 108
99 TEST(MediaDrmBridgeTest, CreateWithoutSessionSupport_Widevine) { 109 TEST(MediaDrmBridgeTest, CreateWithoutSessionSupport_Widevine) {
100 base::MessageLoop message_loop_; 110 base::MessageLoop message_loop_;
101 EXPECT_TRUE_IF_WIDEVINE_AVAILABLE(MediaDrmBridge::CreateWithoutSessionSupport( 111 MediaDrmBridge::CreateWithoutSessionSupport(
102 kWidevineKeySystem, kDefault, base::Bind(&MockProvisionFetcher::Create))); 112 kWidevineKeySystem, kDefault, base::Bind(&MockProvisionFetcher::Create),
113 base::BindOnce(&CheckMediaDrmBridge, true));
114
115 base::RunLoop().RunUntilIdle();
103 } 116 }
104 117
105 // Invalid key system is NOT supported regardless whether MediaDrm is available. 118 // Invalid key system is NOT supported regardless whether MediaDrm is available.
106 TEST(MediaDrmBridgeTest, CreateWithoutSessionSupport_InvalidKeySystem) { 119 TEST(MediaDrmBridgeTest, CreateWithoutSessionSupport_InvalidKeySystem) {
107 base::MessageLoop message_loop_; 120 base::MessageLoop message_loop_;
108 EXPECT_FALSE(MediaDrmBridge::CreateWithoutSessionSupport( 121 MediaDrmBridge::CreateWithoutSessionSupport(
109 kInvalidKeySystem, kDefault, base::Bind(&MockProvisionFetcher::Create))); 122 kInvalidKeySystem, kDefault, base::Bind(&MockProvisionFetcher::Create),
123 base::BindOnce(&CheckMediaDrmBridge, false));
124
125 base::RunLoop().RunUntilIdle();
110 } 126 }
111 127
112 TEST(MediaDrmBridgeTest, CreateWithSecurityLevel_Widevine) { 128 TEST(MediaDrmBridgeTest, CreateWithSecurityLevel_Widevine) {
113 base::MessageLoop message_loop_; 129 base::MessageLoop message_loop_;
114 130
115 // We test "L3" fully. But for "L1" we don't check the result as it depends on 131 // We test "L3" fully. But for "L1" we don't check the result as it depends on
116 // whether the test device supports "L1". 132 // whether the test device supports "L1".
117 EXPECT_TRUE_IF_WIDEVINE_AVAILABLE(MediaDrmBridge::CreateWithoutSessionSupport( 133 MediaDrmBridge::CreateWithoutSessionSupport(
118 kWidevineKeySystem, kL3, base::Bind(&MockProvisionFetcher::Create))); 134 kWidevineKeySystem, kL3, base::Bind(&MockProvisionFetcher::Create),
135 base::BindOnce(&CheckMediaDrmBridge, true));
119 136
120 MediaDrmBridge::CreateWithoutSessionSupport( 137 MediaDrmBridge::CreateWithoutSessionSupport(
121 kWidevineKeySystem, kL1, base::Bind(&MockProvisionFetcher::Create)); 138 kWidevineKeySystem, kL1, base::Bind(&MockProvisionFetcher::Create),
139 base::BindOnce([](scoped_refptr<MediaDrmBridge>) {}));
140
141 base::RunLoop().RunUntilIdle();
122 } 142 }
123 143
124 } // namespace media 144 } // namespace media
OLDNEW
« no previous file with comments | « media/base/android/media_drm_bridge.cc ('k') | media/base/android/media_drm_storage_bridge.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698