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

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

Issue 2095053003: Merge M52: "When HLS redirects are encountered recreate WebMediaPlayer." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: Created 4 years, 6 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
« no previous file with comments | « content/browser/media/media_browsertest.cc ('k') | content/content_tests.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/media/media_redirect_browsertest.cc
diff --git a/content/browser/media/media_redirect_browsertest.cc b/content/browser/media/media_redirect_browsertest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2b7a4390fbe92f8831ad2c13b7f1aaa036b90c3f
--- /dev/null
+++ b/content/browser/media/media_redirect_browsertest.cc
@@ -0,0 +1,67 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "build/build_config.h"
+#include "content/browser/media/media_browsertest.h"
+#include "content/public/test/browser_test_utils.h"
+#include "content/public/test/content_browser_test_utils.h"
+#include "media/base/test_data_util.h"
+#include "net/test/embedded_test_server/embedded_test_server.h"
+#include "net/test/embedded_test_server/http_request.h"
+#include "net/test/embedded_test_server/http_response.h"
+
+namespace content {
+
+// Tests that WebMediaPlayer implementations choose the right playback engine
+// for content even when the playback extension is not known upfront.
+class MediaRedirectTest : public MediaBrowserTest {
+ public:
+ void RunRedirectTest(const std::string& media_file) {
+ std::unique_ptr<net::EmbeddedTestServer> http_test_server(
+ new net::EmbeddedTestServer());
+ http_test_server->ServeFilesFromSourceDirectory(media::GetTestDataPath());
+ CHECK(http_test_server->Start());
+
+ const GURL player_url =
+ http_test_server->GetURL("/player.html?video=" + kHiddenPath);
+ const GURL dest_url = http_test_server->GetURL("/" + media_file);
+
+ http_test_server->RegisterRequestHandler(
+ base::Bind(&MediaRedirectTest::RedirectResponseHandler,
+ base::Unretained(this), dest_url));
+
+ // Run the normal media playback test.
+ EXPECT_EQ(kEnded, RunTest(player_url, kEnded));
+ }
+
+ std::unique_ptr<net::test_server::HttpResponse> RedirectResponseHandler(
+ const GURL& dest_url,
+ const net::test_server::HttpRequest& request) {
+ if (!base::StartsWith(request.relative_url, "/" + kHiddenPath,
+ base::CompareCase::SENSITIVE)) {
+ return std::unique_ptr<net::test_server::HttpResponse>();
+ }
+
+ std::unique_ptr<net::test_server::BasicHttpResponse> http_response(
+ new net::test_server::BasicHttpResponse);
+ http_response->set_code(net::HTTP_TEMPORARY_REDIRECT);
+ http_response->AddCustomHeader("Location", dest_url.spec());
+ return std::move(http_response);
+ }
+
+ private:
+ const std::string kHiddenPath = "hidden_redirect";
+};
+
+IN_PROC_BROWSER_TEST_F(MediaRedirectTest, CanPlayHiddenWebm) {
+ RunRedirectTest("bear.webm");
+}
+
+#if defined(OS_ANDROID) && defined(USE_PROPRIETARY_CODECS)
+IN_PROC_BROWSER_TEST_F(MediaRedirectTest, CanPlayHiddenHls) {
+ RunRedirectTest("bear.m3u8");
+}
+#endif
+
+} // namespace content
« no previous file with comments | « content/browser/media/media_browsertest.cc ('k') | content/content_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698