| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 public: | 163 public: |
| 164 KeySystemConfigSelectorTest() | 164 KeySystemConfigSelectorTest() |
| 165 : key_systems_(new FakeKeySystems()), | 165 : key_systems_(new FakeKeySystems()), |
| 166 media_permission_(new FakeMediaPermission()) {} | 166 media_permission_(new FakeMediaPermission()) {} |
| 167 | 167 |
| 168 void SelectConfig() { | 168 void SelectConfig() { |
| 169 media_permission_->requests = 0; | 169 media_permission_->requests = 0; |
| 170 succeeded_count_ = 0; | 170 succeeded_count_ = 0; |
| 171 not_supported_count_ = 0; | 171 not_supported_count_ = 0; |
| 172 KeySystemConfigSelector(key_systems_.get(), media_permission_.get()) | 172 KeySystemConfigSelector(key_systems_.get(), media_permission_.get()) |
| 173 .SelectConfig(key_system_, configs_, security_origin_, | 173 .SelectConfig(key_system_, configs_, security_origin_, false, |
| 174 base::Bind(&KeySystemConfigSelectorTest::OnSucceeded, | 174 base::Bind(&KeySystemConfigSelectorTest::OnSucceeded, |
| 175 base::Unretained(this)), | 175 base::Unretained(this)), |
| 176 base::Bind(&KeySystemConfigSelectorTest::OnNotSupported, | 176 base::Bind(&KeySystemConfigSelectorTest::OnNotSupported, |
| 177 base::Unretained(this))); | 177 base::Unretained(this))); |
| 178 } | 178 } |
| 179 | 179 |
| 180 bool SelectConfigReturnsConfig() { | 180 bool SelectConfigReturnsConfig() { |
| 181 SelectConfig(); | 181 SelectConfig(); |
| 182 EXPECT_EQ(0, media_permission_->requests); | 182 EXPECT_EQ(0, media_permission_->requests); |
| 183 EXPECT_EQ(1, succeeded_count_); | 183 EXPECT_EQ(1, succeeded_count_); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 202 } | 202 } |
| 203 | 203 |
| 204 bool SelectConfigRequestsPermissionAndReturnsError() { | 204 bool SelectConfigRequestsPermissionAndReturnsError() { |
| 205 SelectConfig(); | 205 SelectConfig(); |
| 206 EXPECT_EQ(1, media_permission_->requests); | 206 EXPECT_EQ(1, media_permission_->requests); |
| 207 EXPECT_EQ(0, succeeded_count_); | 207 EXPECT_EQ(0, succeeded_count_); |
| 208 EXPECT_EQ(1, not_supported_count_); | 208 EXPECT_EQ(1, not_supported_count_); |
| 209 return (media_permission_->requests != 0 && not_supported_count_ != 0); | 209 return (media_permission_->requests != 0 && not_supported_count_ != 0); |
| 210 } | 210 } |
| 211 | 211 |
| 212 void OnSucceeded(const blink::WebMediaKeySystemConfiguration& result) { | 212 void OnSucceeded(const blink::WebMediaKeySystemConfiguration& result, |
| 213 bool are_secure_codecs_required) { |
| 213 succeeded_count_++; | 214 succeeded_count_++; |
| 214 config_ = result; | 215 config_ = result; |
| 215 } | 216 } |
| 216 | 217 |
| 217 void OnNotSupported(const blink::WebString&) { not_supported_count_++; } | 218 void OnNotSupported(const blink::WebString&) { not_supported_count_++; } |
| 218 | 219 |
| 219 scoped_ptr<FakeKeySystems> key_systems_; | 220 scoped_ptr<FakeKeySystems> key_systems_; |
| 220 scoped_ptr<FakeMediaPermission> media_permission_; | 221 scoped_ptr<FakeMediaPermission> media_permission_; |
| 221 | 222 |
| 222 // Held values for the call to SelectConfig(). | 223 // Held values for the call to SelectConfig(). |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 757 | 758 |
| 758 blink::WebMediaKeySystemConfiguration config2; | 759 blink::WebMediaKeySystemConfiguration config2; |
| 759 config2.label = "b"; | 760 config2.label = "b"; |
| 760 configs_.push_back(config2); | 761 configs_.push_back(config2); |
| 761 | 762 |
| 762 ASSERT_TRUE(SelectConfigRequestsPermissionAndReturnsConfig()); | 763 ASSERT_TRUE(SelectConfigRequestsPermissionAndReturnsConfig()); |
| 763 ASSERT_EQ("b", config_.label); | 764 ASSERT_EQ("b", config_.label); |
| 764 } | 765 } |
| 765 | 766 |
| 766 } // namespace media | 767 } // namespace media |
| OLD | NEW |