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

Unified Diff: content/browser/media/encrypted_media_browsertest.cc

Issue 2543623003: media: Allow config change between clear and encrypted streams (Closed)
Patch Set: media: Allow config change between clear and encrypted streams Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/media/encrypted_media_browsertest.cc
diff --git a/content/browser/media/encrypted_media_browsertest.cc b/content/browser/media/encrypted_media_browsertest.cc
index 066b81111c60f1861b6651607450d747d2d33c55..3c9b0c99ee46854a4e25eed72cd64d34ab1f64ff 100644
--- a/content/browser/media/encrypted_media_browsertest.cc
+++ b/content/browser/media/encrypted_media_browsertest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/command_line.h"
+#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/win/windows_version.h"
#include "build/build_config.h"
@@ -26,6 +27,8 @@
#define SUPPORTS_EXTERNAL_CLEAR_KEY_IN_CONTENT_SHELL
#endif
+namespace content {
+
// Available key systems.
const char kClearKeyKeySystem[] = "org.w3.clearkey";
@@ -48,20 +51,24 @@ const char kEmeNotSupportedError[] = "NOTSUPPORTEDERROR";
const char kDefaultEmePlayer[] = "eme_player.html";
// The type of video src used to load media.
-enum SrcType {
- SRC,
- MSE
+enum class SrcType { SRC, MSE };
+
+// Must be in sync with CONFIG_CHANGE_TYPE in eme_player_js/global.js
+enum class ConfigChangeType {
+ CLEAR_TO_CLEAR = 0,
+ CLEAR_TO_ENCRYPTED = 1,
+ ENCRYPTED_TO_CLEAR = 2,
+ ENCRYPTED_TO_ENCRYPTED = 3,
};
-namespace content {
-
// Tests encrypted media playback with a combination of parameters:
// - char*: Key system name.
// - SrcType: The type of video src used to load media, MSE or SRC.
// It is okay to run this test as a non-parameterized test, in this case,
// GetParam() should not be called.
-class EncryptedMediaTest : public content::MediaBrowserTest,
- public testing::WithParamInterface<std::tr1::tuple<const char*, SrcType> > {
+class EncryptedMediaTest : public MediaBrowserTest,
+ public testing::WithParamInterface<
+ std::tr1::tuple<const char*, SrcType>> {
public:
// Can only be used in parameterized (*_P) tests.
const std::string CurrentKeySystem() {
@@ -86,11 +93,19 @@ class EncryptedMediaTest : public content::MediaBrowserTest,
CurrentSourceType(), kEnded);
}
- void TestConfigChange() {
+ void TestConfigChange(ConfigChangeType config_change_type,
+ const std::string& expectation = kEnded) {
+ if (CurrentSourceType() != SrcType::MSE) {
+ DVLOG(0) << "Config change only happens when using MSE.";
+ return;
+ }
+
base::StringPairs query_params;
query_params.push_back(std::make_pair("keySystem", CurrentKeySystem()));
- query_params.push_back(std::make_pair("runEncrypted", "1"));
- RunMediaTestPage("mse_config_change.html", query_params, kEnded, true);
+ query_params.push_back(std::make_pair(
+ "configChangeType",
+ base::IntToString(static_cast<int>(config_change_type))));
+ RunMediaTestPage("mse_config_change.html", query_params, expectation, true);
}
void RunEncryptedMediaTest(const std::string& html_page,
@@ -103,7 +118,7 @@ class EncryptedMediaTest : public content::MediaBrowserTest,
query_params.push_back(std::make_pair("mediaFile", media_file));
query_params.push_back(std::make_pair("mediaType", media_type));
query_params.push_back(std::make_pair("keySystem", key_system));
- if (src_type == MSE)
+ if (src_type == SrcType::MSE)
query_params.push_back(std::make_pair("useMSE", "1"));
RunMediaTestPage(html_page, query_params, expectation, true);
}
@@ -141,22 +156,26 @@ class EncryptedMediaTest : public content::MediaBrowserTest,
using ::testing::Combine;
using ::testing::Values;
-INSTANTIATE_TEST_CASE_P(SRC_ClearKey, EncryptedMediaTest,
- Combine(Values(kClearKeyKeySystem), Values(SRC)));
+INSTANTIATE_TEST_CASE_P(SRC_ClearKey,
+ EncryptedMediaTest,
+ Combine(Values(kClearKeyKeySystem),
+ Values(SrcType::SRC)));
-INSTANTIATE_TEST_CASE_P(MSE_ClearKey, EncryptedMediaTest,
- Combine(Values(kClearKeyKeySystem), Values(MSE)));
+INSTANTIATE_TEST_CASE_P(MSE_ClearKey,
+ EncryptedMediaTest,
+ Combine(Values(kClearKeyKeySystem),
+ Values(SrcType::MSE)));
#if defined(SUPPORTS_EXTERNAL_CLEAR_KEY_IN_CONTENT_SHELL)
INSTANTIATE_TEST_CASE_P(SRC_ExternalClearKey,
EncryptedMediaTest,
Combine(Values(kExternalClearKeyKeySystem),
- Values(SRC)));
+ Values(SrcType::SRC)));
INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKey,
EncryptedMediaTest,
Combine(Values(kExternalClearKeyKeySystem),
- Values(MSE)));
+ Values(SrcType::MSE)));
#endif
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_WebM) {
@@ -214,8 +233,25 @@ IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoClearAudio_WebM_Opus) {
TestSimplePlayback("bear-320x240-opus-av_enc-v.webm", kWebMOpusAudioVP9Video);
}
-IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, ConfigChangeVideo) {
- TestConfigChange();
+// Strictly speaking this is not an "encrypted" media test. Keep it here for
+// completeness.
+IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, ConfigChangeVideo_ClearToClear) {
+ TestConfigChange(ConfigChangeType::CLEAR_TO_CLEAR);
+}
+
+// TODO(xhwang): Support switching from clear to encrypted and fix the test
+// expectation. See http://crbug.com/597443
+IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, ConfigChangeVideo_ClearToEncrypted) {
+ TestConfigChange(ConfigChangeType::CLEAR_TO_ENCRYPTED, kError);
+}
+
+IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, ConfigChangeVideo_EncryptedToClear) {
+ TestConfigChange(ConfigChangeType::ENCRYPTED_TO_CLEAR);
+}
+
+IN_PROC_BROWSER_TEST_P(EncryptedMediaTest,
+ ConfigChangeVideo_EncryptedToEncrypted) {
+ TestConfigChange(ConfigChangeType::ENCRYPTED_TO_ENCRYPTED);
}
IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, FrameSizeChangeVideo) {
@@ -224,7 +260,7 @@ IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, FrameSizeChangeVideo) {
IN_PROC_BROWSER_TEST_F(EncryptedMediaTest, UnknownKeySystemThrowsException) {
RunEncryptedMediaTest(kDefaultEmePlayer, "bear-a_enc-a.webm",
- kWebMVorbisAudioOnly, "com.example.foo", MSE,
+ kWebMVorbisAudioOnly, "com.example.foo", SrcType::MSE,
kEmeNotSupportedError);
}

Powered by Google App Engine
This is Rietveld 408576698