OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/string16.h" | 6 #include "base/string16.h" |
7 #include "base/stringprintf.h" | 7 #include "base/stringprintf.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/ui/browser.h" | |
11 #include "chrome/browser/ui/browser_tabstrip.h" | |
12 #include "chrome/test/base/ui_test_utils.h" | |
13 #include "content/public/test/browser_test_utils.h" | 10 #include "content/public/test/browser_test_utils.h" |
| 11 #include "content/shell/shell.h" |
14 #include "content/test/layout_browsertest.h" | 12 #include "content/test/layout_browsertest.h" |
| 13 #include "content/test/content_browser_test_utils.h" |
15 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
16 | 15 |
17 class MediaTest : public InProcessBrowserTest { | 16 class MediaTest : public content::ContentBrowserTest { |
18 protected: | 17 protected: |
19 GURL GetTestURL(const char* tag, const char* media_file) { | 18 GURL GetTestURL(const char* tag, const char* media_file) { |
20 FilePath test_file_path = ui_test_utils::GetTestFilePath( | 19 FilePath test_file_path = content::GetTestFilePath("media", "player.html"); |
21 FilePath(FILE_PATH_LITERAL("media")), | |
22 FilePath(FILE_PATH_LITERAL("player.html"))); | |
23 std::string query = base::StringPrintf("%s=%s", tag, media_file); | 20 std::string query = base::StringPrintf("%s=%s", tag, media_file); |
24 return ui_test_utils::GetFileUrlWithQuery(test_file_path, query); | 21 return content::GetFileUrlWithQuery(test_file_path, query); |
25 } | 22 } |
26 | 23 |
27 void PlayMedia(const char* tag, const char* media_file) { | 24 void PlayMedia(const char* tag, const char* media_file) { |
28 GURL player_gurl = GetTestURL(tag, media_file); | 25 GURL player_gurl = GetTestURL(tag, media_file); |
29 | 26 |
30 // Allow the media file to be loaded. | 27 // Allow the media file to be loaded. |
31 const string16 kPlaying = ASCIIToUTF16("PLAYING"); | 28 const string16 kPlaying = ASCIIToUTF16("PLAYING"); |
32 const string16 kFailed = ASCIIToUTF16("FAILED"); | 29 const string16 kFailed = ASCIIToUTF16("FAILED"); |
33 const string16 kError = ASCIIToUTF16("ERROR"); | 30 const string16 kError = ASCIIToUTF16("ERROR"); |
34 content::TitleWatcher title_watcher( | 31 content::TitleWatcher title_watcher(shell()->web_contents(), kPlaying); |
35 chrome::GetActiveWebContents(browser()), kPlaying); | |
36 title_watcher.AlsoWaitForTitle(kFailed); | 32 title_watcher.AlsoWaitForTitle(kFailed); |
37 title_watcher.AlsoWaitForTitle(kError); | 33 title_watcher.AlsoWaitForTitle(kError); |
38 | 34 |
39 ui_test_utils::NavigateToURL(browser(), player_gurl); | 35 content::NavigateToURL(shell(), player_gurl); |
40 | 36 |
41 string16 final_title = title_watcher.WaitAndGetTitle(); | 37 string16 final_title = title_watcher.WaitAndGetTitle(); |
42 EXPECT_EQ(kPlaying, final_title); | 38 EXPECT_EQ(kPlaying, final_title); |
43 } | 39 } |
44 | 40 |
45 void PlayAudio(const char* url) { | 41 void PlayAudio(const char* url) { |
46 PlayMedia("audio", url); | 42 PlayMedia("audio", url); |
47 } | 43 } |
48 | 44 |
49 void PlayVideo(const char* url) { | 45 void PlayVideo(const char* url) { |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 } | 146 } |
151 | 147 |
152 // TODO(dalecurtis): Disabled because loop is flaky. http://crbug.com/134021 | 148 // TODO(dalecurtis): Disabled because loop is flaky. http://crbug.com/134021 |
153 // IN_PROC_BROWSER_TEST_F(MediaLayoutTest, VideoLoopTest) { | 149 // IN_PROC_BROWSER_TEST_F(MediaLayoutTest, VideoLoopTest) { |
154 // RunLayoutTest("video-loop.html"); | 150 // RunLayoutTest("video-loop.html"); |
155 // } | 151 // } |
156 | 152 |
157 IN_PROC_BROWSER_TEST_F(MediaLayoutTest, VideoNoAutoplayTest) { | 153 IN_PROC_BROWSER_TEST_F(MediaLayoutTest, VideoNoAutoplayTest) { |
158 RunLayoutTest("video-no-autoplay.html"); | 154 RunLayoutTest("video-no-autoplay.html"); |
159 } | 155 } |
OLD | NEW |