OLD | NEW |
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/spawned_test_server/spawned_test_server.h" | 18 #include "net/test/embedded_test_server/embedded_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 } | 26 } |
27 | 27 |
28 MediaBrowserTest::~MediaBrowserTest() { | 28 MediaBrowserTest::~MediaBrowserTest() { |
29 } | 29 } |
30 | 30 |
31 void MediaBrowserTest::RunMediaTestPage(const std::string& html_page, | 31 void MediaBrowserTest::RunMediaTestPage(const std::string& html_page, |
32 const base::StringPairs& query_params, | 32 const base::StringPairs& query_params, |
33 const std::string& expected_title, | 33 const std::string& expected_title, |
34 bool http) { | 34 bool http) { |
35 GURL gurl; | 35 GURL gurl; |
36 std::string query = media::GetURLQueryString(query_params); | 36 std::string query = media::GetURLQueryString(query_params); |
37 scoped_ptr<net::SpawnedTestServer> http_test_server; | 37 scoped_ptr<net::EmbeddedTestServer> http_test_server; |
38 if (http) { | 38 if (http) { |
39 DVLOG(0) << base::TimeFormatTimeOfDayWithMilliseconds(base::Time::Now()) | 39 DVLOG(0) << base::TimeFormatTimeOfDayWithMilliseconds(base::Time::Now()) |
40 << " Starting HTTP server"; | 40 << " Starting HTTP server"; |
41 http_test_server.reset( | 41 http_test_server.reset(new net::EmbeddedTestServer); |
42 new net::SpawnedTestServer(net::SpawnedTestServer::TYPE_HTTP, | 42 http_test_server->ServeFilesFromSourceDirectory(media::GetTestDataPath()); |
43 net::SpawnedTestServer::kLocalhost, | |
44 media::GetTestDataPath())); | |
45 CHECK(http_test_server->Start()); | 43 CHECK(http_test_server->Start()); |
46 gurl = http_test_server->GetURL("files/" + html_page + "?" + query); | 44 gurl = http_test_server->GetURL("/" + html_page + "?" + query); |
47 } else { | 45 } else { |
48 gurl = content::GetFileUrlWithQuery(media::GetTestDataFilePath(html_page), | 46 gurl = content::GetFileUrlWithQuery(media::GetTestDataFilePath(html_page), |
49 query); | 47 query); |
50 } | 48 } |
51 std::string final_title = RunTest(gurl, expected_title); | 49 std::string final_title = RunTest(gurl, expected_title); |
52 EXPECT_EQ(expected_title, final_title); | 50 EXPECT_EQ(expected_title, final_title); |
53 } | 51 } |
54 | 52 |
55 std::string MediaBrowserTest::RunTest(const GURL& gurl, | 53 std::string MediaBrowserTest::RunTest(const GURL& gurl, |
56 const std::string& expected_title) { | 54 const std::string& expected_title) { |
(...skipping 20 matching lines...) Expand all Loading... |
77 base::ProcessId plugin_pid) { | 75 base::ProcessId plugin_pid) { |
78 DVLOG(0) << "Plugin crashed: " << plugin_path.value(); | 76 DVLOG(0) << "Plugin crashed: " << plugin_path.value(); |
79 if (ignore_plugin_crash_) | 77 if (ignore_plugin_crash_) |
80 return; | 78 return; |
81 ADD_FAILURE() << "Failing test due to plugin crash."; | 79 ADD_FAILURE() << "Failing test due to plugin crash."; |
82 } | 80 } |
83 | 81 |
84 void MediaBrowserTest::IgnorePluginCrash() { | 82 void MediaBrowserTest::IgnorePluginCrash() { |
85 ignore_plugin_crash_ = true; | 83 ignore_plugin_crash_ = true; |
86 } | 84 } |
87 | |
OLD | NEW |