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/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
9 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 9 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
10 #include "chrome/test/base/ui_test_utils.h" | 10 #include "chrome/test/base/ui_test_utils.h" |
11 #include "content/public/browser/navigation_controller.h" | 11 #include "content/public/browser/navigation_controller.h" |
12 #include "content/public/browser/navigation_entry.h" | 12 #include "content/public/browser/navigation_entry.h" |
13 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
14 #include "content/public/test/browser_test_utils.h" | 14 #include "content/public/test/browser_test_utils.h" |
| 15 #include "media/base/test_data_util.h" |
| 16 #include "net/test/spawned_test_server/spawned_test_server.h" |
15 | 17 |
16 // Common test results. | 18 // Common test results. |
17 const char MediaBrowserTest::kEnded[] = "ENDED"; | 19 const char MediaBrowserTest::kEnded[] = "ENDED"; |
18 const char MediaBrowserTest::kError[] = "ERROR"; | 20 const char MediaBrowserTest::kError[] = "ERROR"; |
19 const char MediaBrowserTest::kFailed[] = "FAILED"; | 21 const char MediaBrowserTest::kFailed[] = "FAILED"; |
20 const char MediaBrowserTest::kPluginCrashed[] = "PLUGIN_CRASHED"; | 22 const char MediaBrowserTest::kPluginCrashed[] = "PLUGIN_CRASHED"; |
21 | 23 |
22 MediaBrowserTest::MediaBrowserTest() : ignore_plugin_crash_(false) { | 24 MediaBrowserTest::MediaBrowserTest() : ignore_plugin_crash_(false) { |
23 } | 25 } |
24 | 26 |
25 MediaBrowserTest::~MediaBrowserTest() { | 27 MediaBrowserTest::~MediaBrowserTest() { |
26 } | 28 } |
27 | 29 |
28 void MediaBrowserTest::RunMediaTestPage(const std::string& html_page, | 30 void MediaBrowserTest::RunMediaTestPage(const std::string& html_page, |
29 const media::QueryParams& query_params, | 31 const media::QueryParams& query_params, |
30 const std::string& expected_title, | 32 const std::string& expected_title, |
31 bool http) { | 33 bool http) { |
32 GURL gurl; | 34 GURL gurl; |
33 std::string query = media::GetURLQueryString(query_params); | 35 std::string query = media::GetURLQueryString(query_params); |
34 scoped_ptr<net::SpawnedTestServer> http_test_server; | 36 scoped_ptr<net::SpawnedTestServer> http_test_server; |
35 if (http) { | 37 if (http) { |
36 http_test_server = media::StartMediaHttpTestServer(); | 38 http_test_server.reset( |
| 39 new net::SpawnedTestServer(net::SpawnedTestServer::TYPE_HTTP, |
| 40 net::SpawnedTestServer::kLocalhost, |
| 41 media::GetTestDataPath())); |
| 42 CHECK(http_test_server->Start()); |
37 gurl = http_test_server->GetURL("files/" + html_page + "?" + query); | 43 gurl = http_test_server->GetURL("files/" + html_page + "?" + query); |
38 } else { | 44 } else { |
39 gurl = content::GetFileUrlWithQuery(media::GetTestDataFilePath(html_page), | 45 gurl = content::GetFileUrlWithQuery(media::GetTestDataFilePath(html_page), |
40 query); | 46 query); |
41 } | 47 } |
42 std::string final_title = RunTest(gurl, expected_title); | 48 std::string final_title = RunTest(gurl, expected_title); |
43 EXPECT_EQ(expected_title, final_title); | 49 EXPECT_EQ(expected_title, final_title); |
44 } | 50 } |
45 | 51 |
46 std::string MediaBrowserTest::RunTest(const GURL& gurl, | 52 std::string MediaBrowserTest::RunTest(const GURL& gurl, |
(...skipping 25 matching lines...) Expand all Loading... |
72 // Update document title to quit TitleWatcher early. | 78 // Update document title to quit TitleWatcher early. |
73 web_contents()->GetController().GetActiveEntry() | 79 web_contents()->GetController().GetActiveEntry() |
74 ->SetTitle(base::ASCIIToUTF16(kPluginCrashed)); | 80 ->SetTitle(base::ASCIIToUTF16(kPluginCrashed)); |
75 ADD_FAILURE() << "Failing test due to plugin crash."; | 81 ADD_FAILURE() << "Failing test due to plugin crash."; |
76 } | 82 } |
77 | 83 |
78 void MediaBrowserTest::IgnorePluginCrash() { | 84 void MediaBrowserTest::IgnorePluginCrash() { |
79 ignore_plugin_crash_ = true; | 85 ignore_plugin_crash_ = true; |
80 } | 86 } |
81 | 87 |
OLD | NEW |