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

Side by Side Diff: chrome/browser/media_uitest.cc

Issue 9959028: Convert the media and audio UI test to a browser_test. browser_tests are sharded and run quicker, a… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 8 months 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/audio_layout_uitest.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/basictypes.h"
6 #include "base/file_path.h"
7 #include "base/stringprintf.h"
8 #include "base/string_util.h"
9 #include "base/test/test_timeouts.h"
10 #include "base/threading/platform_thread.h"
11 #include "chrome/common/chrome_switches.h"
12 #include "chrome/test/base/test_launcher_utils.h"
13 #include "chrome/test/ui/ui_layout_test.h"
14 #include "chrome/test/ui/ui_test.h"
15 #include "net/base/net_util.h"
16 #include "ui/gfx/gl/gl_implementation.h"
17
18 class MediaTest : public UITest {
19 protected:
20 void PlayMedia(const char* tag, const char* media_file) {
21 FilePath test_file(test_data_directory_);
22 test_file = test_file.AppendASCII("media/player.html");
23
24 GURL player_gurl = net::FilePathToFileURL(test_file);
25 std::string url = base::StringPrintf(
26 "%s?%s=%s", player_gurl.spec().c_str(), tag, media_file);
27
28 NavigateToURL(GURL(url));
29
30 // Allow the media file to be loaded.
31 const std::wstring kPlaying = L"PLAYING";
32 const std::wstring kFailed = L"FAILED";
33 const std::wstring kError = L"ERROR";
34 const base::TimeDelta kSleepInterval =
35 base::TimeDelta::FromMilliseconds(250);
36 const int kNumIntervals =
37 TestTimeouts::action_timeout() / kSleepInterval;
38 for (int i = 0; i < kNumIntervals; ++i) {
39 const std::wstring& title = GetActiveTabTitle();
40 if (title == kPlaying || title == kFailed ||
41 StartsWith(title, kError, true))
42 break;
43 base::PlatformThread::Sleep(kSleepInterval);
44 }
45
46 EXPECT_EQ(kPlaying, GetActiveTabTitle());
47 }
48
49 void PlayAudio(const char* url) {
50 PlayMedia("audio", url);
51 }
52
53 void PlayVideo(const char* url) {
54 PlayMedia("video", url);
55 }
56 };
57
58 #if defined(OS_MACOSX)
59 // http://crbug.com/88834 - VideoBearTheora, VideoBearWav and VideoBearWebm
60 // are flaky on Mac.
61 #define MAYBE_VideoBearTheora DISABLED_VideoBearTheora
62 #define MAYBE_VideoBearWavPcm DISABLED_VideoBearWavPcm
63 #define MAYBE_VideoBearWebm DISABLED_VideoBearWebm
64 #else
65 #define MAYBE_VideoBearTheora VideoBearTheora
66 #define MAYBE_VideoBearWavPcm VideoBearWavPcm
67 #define MAYBE_VideoBearWebm VideoBearWebm
68 #endif
69
70 TEST_F(MediaTest, MAYBE_VideoBearTheora) {
71 PlayVideo("bear.ogv");
72 }
73
74 TEST_F(MediaTest, VideoBearSilentTheora) {
75 PlayVideo("bear_silent.ogv");
76 }
77
78 TEST_F(MediaTest, MAYBE_VideoBearWebm) {
79 PlayVideo("bear.webm");
80 }
81
82 TEST_F(MediaTest, VideoBearSilentWebm) {
83 PlayVideo("bear_silent.webm");
84 }
85
86 #if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS)
87 TEST_F(MediaTest, VideoBearMp4) {
88 PlayVideo("bear.mp4");
89 }
90
91 TEST_F(MediaTest, VideoBearSilentMp4) {
92 PlayVideo("bear_silent.mp4");
93 }
94 #endif
95
96 #if defined(OS_CHROMEOS)
97 #if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS)
98 TEST_F(MediaTest, VideoBearAviMp3Mpeg4) {
99 PlayVideo("bear_mpeg4_mp3.avi");
100 }
101
102 TEST_F(MediaTest, VideoBearAviMp3Divx) {
103 PlayVideo("bear_divx_mp3.avi");
104 }
105
106 TEST_F(MediaTest, VideoBear3gpAacH264) {
107 PlayVideo("bear_h264_aac.3gp");
108 }
109
110 TEST_F(MediaTest, VideoBear3gpAmrnbMpeg4) {
111 PlayVideo("bear_mpeg4_amrnb.3gp");
112 }
113
114 // TODO(ihf): Enable these audio codecs for CrOS.
115 // TEST_F(MediaTest, VideoBearWavAlaw) {
116 // PlayVideo("bear_alaw.wav");
117 // }
118 // TEST_F(MediaTest, VideoBearWavGsmms) {
119 // PlayVideo("bear_gsmms.wav");
120 // }
121
122 TEST_F(MediaTest, VideoBearWavMulaw) {
123 PlayVideo("bear_mulaw.wav");
124 }
125
126 TEST_F(MediaTest, VideoBearFlac) {
127 PlayVideo("bear.flac");
128 }
129 #endif
130 #endif
131
132 TEST_F(MediaTest, MAYBE_VideoBearWavPcm) {
133 PlayVideo("bear_pcm.wav");
134 }
135
136 TEST_F(UILayoutTest, MediaUILayoutTest) {
137 static const char* kResources[] = {
138 "content",
139 "media-file.js",
140 "media-fullscreen.js",
141 "video-paint-test.js",
142 "video-played.js",
143 "video-test.js",
144 };
145
146 static const char* kMediaTests[] = {
147 "video-autoplay.html",
148 // "video-loop.html", disabled due to 52887.
149 "video-no-autoplay.html",
150 // TODO(sergeyu): Add more tests here.
151 };
152
153 FilePath test_dir;
154 FilePath media_test_dir;
155 media_test_dir = media_test_dir.AppendASCII("media");
156 InitializeForLayoutTest(test_dir, media_test_dir, kNoHttpPort);
157
158 // Copy resources first.
159 for (size_t i = 0; i < arraysize(kResources); ++i)
160 AddResourceForLayoutTest(
161 test_dir, media_test_dir.AppendASCII(kResources[i]));
162
163 for (size_t i = 0; i < arraysize(kMediaTests); ++i)
164 RunLayoutTest(kMediaTests[i], kNoHttpPort);
165 }
OLDNEW
« no previous file with comments | « chrome/browser/audio_layout_uitest.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698