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 "base/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "content/public/browser/web_contents.h" | 8 #include "content/public/browser/web_contents.h" |
9 #include "content/public/common/content_paths.h" | 9 #include "content/public/common/content_paths.h" |
10 #include "content/public/test/browser_test_utils.h" | 10 #include "content/public/test/browser_test_utils.h" |
11 #include "content/shell/browser/shell.h" | 11 #include "content/shell/browser/shell.h" |
12 #include "content/test/content_browser_test.h" | 12 #include "content/test/content_browser_test.h" |
13 #include "content/test/content_browser_test_utils.h" | 13 #include "content/test/content_browser_test_utils.h" |
14 #include "grit/content_resources.h" | 14 #include "grit/content_resources.h" |
| 15 #include "grit/webui_resources.h" |
15 #include "net/base/net_util.h" | 16 #include "net/base/net_util.h" |
16 | 17 |
17 namespace content { | 18 namespace content { |
18 | 19 |
19 class WebUIResourceBrowserTest : public ContentBrowserTest { | 20 class WebUIResourceBrowserTest : public ContentBrowserTest { |
20 public: | 21 public: |
21 WebUIResourceBrowserTest() {} | 22 WebUIResourceBrowserTest() {} |
22 virtual ~WebUIResourceBrowserTest() {} | 23 virtual ~WebUIResourceBrowserTest() {} |
23 | 24 |
24 // Runs all test functions in |file|, waiting for them to complete. | 25 // Runs all test functions in |file|, waiting for them to complete. |
25 void RunTest(const base::FilePath& file) { | 26 void RunTest(const base::FilePath& file) { |
26 ASSERT_TRUE(PathExists(file)); | 27 ASSERT_TRUE(PathExists(file)); |
27 NavigateToURL(shell(), net::FilePathToFileURL(file)); | 28 NavigateToURL(shell(), net::FilePathToFileURL(file)); |
28 | 29 |
29 RenderViewHost* rvh = shell()->web_contents()->GetRenderViewHost(); | 30 RenderViewHost* rvh = shell()->web_contents()->GetRenderViewHost(); |
30 ASSERT_TRUE(rvh); | 31 ASSERT_TRUE(rvh); |
31 EXPECT_TRUE(ExecuteWebUIResourceTest(rvh, include_libraries_)); | 32 EXPECT_TRUE(ExecuteWebUIResourceTest(rvh, include_libraries_)); |
32 } | 33 } |
33 | 34 |
34 void RunMediaInternalsTest(const base::FilePath::CharType* file) { | 35 void RunMediaInternalsTest(const base::FilePath::CharType* file) { |
| 36 AddLibrary(IDR_WEBUI_JS_CR); |
35 AddLibrary(IDR_MEDIA_INTERNALS_NEW_JS); | 37 AddLibrary(IDR_MEDIA_INTERNALS_NEW_JS); |
36 | 38 |
37 base::FilePath path; | 39 base::FilePath path; |
38 PathService::Get(DIR_TEST_DATA, &path); | 40 PathService::Get(DIR_TEST_DATA, &path); |
39 RunTest(path.Append(FILE_PATH_LITERAL("media")) | 41 RunTest(path.Append(FILE_PATH_LITERAL("media")) |
40 .Append(FILE_PATH_LITERAL("webui")) | 42 .Append(FILE_PATH_LITERAL("webui")) |
41 .Append(file)); | 43 .Append(file)); |
42 } | 44 } |
43 | 45 |
44 // Queues the library corresponding to |resource_id| for injection into the | 46 // Queues the library corresponding to |resource_id| for injection into the |
(...skipping 17 matching lines...) Expand all Loading... |
62 | 64 |
63 IN_PROC_BROWSER_TEST_F(WebUIResourceBrowserTest, MediaInternals_PlayerInfo) { | 65 IN_PROC_BROWSER_TEST_F(WebUIResourceBrowserTest, MediaInternals_PlayerInfo) { |
64 RunMediaInternalsTest(FILE_PATH_LITERAL("player_info_test.html")); | 66 RunMediaInternalsTest(FILE_PATH_LITERAL("player_info_test.html")); |
65 } | 67 } |
66 | 68 |
67 IN_PROC_BROWSER_TEST_F(WebUIResourceBrowserTest, MediaInternals_Manager) { | 69 IN_PROC_BROWSER_TEST_F(WebUIResourceBrowserTest, MediaInternals_Manager) { |
68 RunMediaInternalsTest(FILE_PATH_LITERAL("manager_test.html")); | 70 RunMediaInternalsTest(FILE_PATH_LITERAL("manager_test.html")); |
69 } | 71 } |
70 | 72 |
71 } // namespace content | 73 } // namespace content |
OLD | NEW |