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

Side by Side 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, 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 | « content/browser/media/media_browsertest.cc ('k') | content/content_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "build/build_config.h"
6 #include "content/browser/media/media_browsertest.h"
7 #include "content/public/test/browser_test_utils.h"
8 #include "content/public/test/content_browser_test_utils.h"
9 #include "media/base/test_data_util.h"
10 #include "net/test/embedded_test_server/embedded_test_server.h"
11 #include "net/test/embedded_test_server/http_request.h"
12 #include "net/test/embedded_test_server/http_response.h"
13
14 namespace content {
15
16 // Tests that WebMediaPlayer implementations choose the right playback engine
17 // for content even when the playback extension is not known upfront.
18 class MediaRedirectTest : public MediaBrowserTest {
19 public:
20 void RunRedirectTest(const std::string& media_file) {
21 std::unique_ptr<net::EmbeddedTestServer> http_test_server(
22 new net::EmbeddedTestServer());
23 http_test_server->ServeFilesFromSourceDirectory(media::GetTestDataPath());
24 CHECK(http_test_server->Start());
25
26 const GURL player_url =
27 http_test_server->GetURL("/player.html?video=" + kHiddenPath);
28 const GURL dest_url = http_test_server->GetURL("/" + media_file);
29
30 http_test_server->RegisterRequestHandler(
31 base::Bind(&MediaRedirectTest::RedirectResponseHandler,
32 base::Unretained(this), dest_url));
33
34 // Run the normal media playback test.
35 EXPECT_EQ(kEnded, RunTest(player_url, kEnded));
36 }
37
38 std::unique_ptr<net::test_server::HttpResponse> RedirectResponseHandler(
39 const GURL& dest_url,
40 const net::test_server::HttpRequest& request) {
41 if (!base::StartsWith(request.relative_url, "/" + kHiddenPath,
42 base::CompareCase::SENSITIVE)) {
43 return std::unique_ptr<net::test_server::HttpResponse>();
44 }
45
46 std::unique_ptr<net::test_server::BasicHttpResponse> http_response(
47 new net::test_server::BasicHttpResponse);
48 http_response->set_code(net::HTTP_TEMPORARY_REDIRECT);
49 http_response->AddCustomHeader("Location", dest_url.spec());
50 return std::move(http_response);
51 }
52
53 private:
54 const std::string kHiddenPath = "hidden_redirect";
55 };
56
57 IN_PROC_BROWSER_TEST_F(MediaRedirectTest, CanPlayHiddenWebm) {
58 RunRedirectTest("bear.webm");
59 }
60
61 #if defined(OS_ANDROID) && defined(USE_PROPRIETARY_CODECS)
62 IN_PROC_BROWSER_TEST_F(MediaRedirectTest, CanPlayHiddenHls) {
63 RunRedirectTest("bear.m3u8");
64 }
65 #endif
66
67 } // namespace content
OLDNEW
« 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