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

Side by Side Diff: chrome/browser/media/media_browsertest.cc

Issue 1461583003: Revert media_browsertest migration back to SpawnedTestServer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 | « chrome/browser/media/media_browsertest.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/media/media_browsertest.h" 5 #include "chrome/browser/media/media_browsertest.h"
6 6
7 #include "base/i18n/time_formatting.h" 7 #include "base/i18n/time_formatting.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/tabs/tab_strip_model.h" 11 #include "chrome/browser/ui/tabs/tab_strip_model.h"
12 #include "chrome/test/base/ui_test_utils.h" 12 #include "chrome/test/base/ui_test_utils.h"
13 #include "content/public/browser/navigation_controller.h" 13 #include "content/public/browser/navigation_controller.h"
14 #include "content/public/browser/navigation_entry.h" 14 #include "content/public/browser/navigation_entry.h"
15 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
16 #include "content/public/test/browser_test_utils.h" 16 #include "content/public/test/browser_test_utils.h"
17 #include "media/base/test_data_util.h" 17 #include "media/base/test_data_util.h"
18 #include "net/test/embedded_test_server/embedded_test_server.h" 18 #include "net/test/spawned_test_server/spawned_test_server.h"
19 19
20 // Common test results. 20 // Common test results.
21 const char MediaBrowserTest::kEnded[] = "ENDED"; 21 const char MediaBrowserTest::kEnded[] = "ENDED";
22 const char MediaBrowserTest::kError[] = "ERROR"; 22 const char MediaBrowserTest::kError[] = "ERROR";
23 const char MediaBrowserTest::kFailed[] = "FAILED"; 23 const char MediaBrowserTest::kFailed[] = "FAILED";
24 24
25 MediaBrowserTest::MediaBrowserTest() : ignore_plugin_crash_(false) { 25 MediaBrowserTest::MediaBrowserTest() : ignore_plugin_crash_(false) {}
26 }
27 26
28 MediaBrowserTest::~MediaBrowserTest() { 27 MediaBrowserTest::~MediaBrowserTest() {}
29 }
30 28
31 void MediaBrowserTest::RunMediaTestPage(const std::string& html_page, 29 void MediaBrowserTest::RunMediaTestPage(const std::string& html_page,
32 const base::StringPairs& query_params, 30 const base::StringPairs& query_params,
33 const std::string& expected_title, 31 const std::string& expected_title,
34 bool http) { 32 bool http) {
35 GURL gurl; 33 GURL gurl;
36 std::string query = media::GetURLQueryString(query_params); 34 std::string query = media::GetURLQueryString(query_params);
37 scoped_ptr<net::EmbeddedTestServer> http_test_server; 35 scoped_ptr<net::SpawnedTestServer> http_test_server;
38 if (http) { 36 if (http) {
39 DVLOG(0) << base::TimeFormatTimeOfDayWithMilliseconds(base::Time::Now()) 37 DVLOG(0) << base::TimeFormatTimeOfDayWithMilliseconds(base::Time::Now())
40 << " Starting HTTP server"; 38 << " Starting HTTP server";
41 http_test_server.reset(new net::EmbeddedTestServer); 39 http_test_server.reset(new net::SpawnedTestServer(
42 http_test_server->ServeFilesFromSourceDirectory(media::GetTestDataPath()); 40 net::SpawnedTestServer::TYPE_HTTP, net::SpawnedTestServer::kLocalhost,
41 media::GetTestDataPath()));
43 CHECK(http_test_server->Start()); 42 CHECK(http_test_server->Start());
44 gurl = http_test_server->GetURL("/" + html_page + "?" + query); 43 gurl = http_test_server->GetURL("files/" + html_page + "?" + query);
45 } else { 44 } else {
46 gurl = content::GetFileUrlWithQuery(media::GetTestDataFilePath(html_page), 45 gurl = content::GetFileUrlWithQuery(media::GetTestDataFilePath(html_page),
47 query); 46 query);
48 } 47 }
49 std::string final_title = RunTest(gurl, expected_title); 48 std::string final_title = RunTest(gurl, expected_title);
50 EXPECT_EQ(expected_title, final_title); 49 EXPECT_EQ(expected_title, final_title);
51 } 50 }
52 51
53 std::string MediaBrowserTest::RunTest(const GURL& gurl, 52 std::string MediaBrowserTest::RunTest(const GURL& gurl,
54 const std::string& expected_title) { 53 const std::string& expected_title) {
(...skipping 20 matching lines...) Expand all
75 base::ProcessId plugin_pid) { 74 base::ProcessId plugin_pid) {
76 DVLOG(0) << "Plugin crashed: " << plugin_path.value(); 75 DVLOG(0) << "Plugin crashed: " << plugin_path.value();
77 if (ignore_plugin_crash_) 76 if (ignore_plugin_crash_)
78 return; 77 return;
79 ADD_FAILURE() << "Failing test due to plugin crash."; 78 ADD_FAILURE() << "Failing test due to plugin crash.";
80 } 79 }
81 80
82 void MediaBrowserTest::IgnorePluginCrash() { 81 void MediaBrowserTest::IgnorePluginCrash() {
83 ignore_plugin_crash_ = true; 82 ignore_plugin_crash_ = true;
84 } 83 }
OLDNEW
« no previous file with comments | « chrome/browser/media/media_browsertest.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698