1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "app/gfx/gl/gl_implementation.h"
#include "base/basictypes.h"
#include "base/file_path.h"
#include "base/string_util.h"
#include "base/test/test_timeouts.h"
#include "base/threading/platform_thread.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/test_launcher_utils.h"
#include "chrome/test/ui/ui_layout_test.h"
#include "chrome/test/ui/ui_test.h"
#include "net/base/net_util.h"
class MediaTest : public UITest {
protected:
virtual void SetUp() {
EXPECT_TRUE(test_launcher_utils::OverrideGLImplementation(
&launch_arguments_,
gfx::kGLImplementationOSMesaName));
#if defined(OS_MACOSX)
// Accelerated compositing does not work with OSMesa. AcceleratedSurface
// assumes GL contexts are native.
launch_arguments_.AppendSwitch(switches::kDisableAcceleratedCompositing);
#endif
UITest::SetUp();
}
void PlayMedia(const char* tag, const char* media_file) {
FilePath test_file(test_data_directory_);
test_file = test_file.AppendASCII("media/player.html");
GURL player_gurl = net::FilePathToFileURL(test_file);
std::string url = StringPrintf("%s?%s=%s",
player_gurl.spec().c_str(),
tag,
media_file);
NavigateToURL(GURL(url));
// Allow the media file to be loaded.
const std::wstring kPlaying = L"PLAYING";
const std::wstring kFailed = L"FAILED";
const std::wstring kError = L"ERROR";
for (int i = 0; i < 10; ++i) {
base::PlatformThread::Sleep(TestTimeouts::action_timeout_ms());
const std::wstring& title = GetActiveTabTitle();
if (title == kPlaying || title == kFailed ||
StartsWith(title, kError, true))
break;
}
EXPECT_EQ(kPlaying, GetActiveTabTitle());
}
void PlayAudio(const char* url) {
PlayMedia("audio", url);
}
void PlayVideo(const char* url) {
PlayMedia("video", url);
}
};
#if defined(OS_LINUX) || defined(OS_WIN)
// Test appears to be fine on linux, but let's first change to flaky and
// see how that goes.
// http://crbug.com/56364
#define MediaUILayoutTest FLAKY_MediaUILayoutTest
#endif
TEST_F(MediaTest, VideoBearTheora) {
PlayVideo("bear.ogv");
}
TEST_F(MediaTest, VideoBearSilentTheora) {
PlayVideo("bear_silent.ogv");
}
TEST_F(MediaTest, VideoBearWebm) {
PlayVideo("bear.webm");
}
TEST_F(MediaTest, VideoBearSilentWebm) {
PlayVideo("bear_silent.webm");
}
#if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS)
TEST_F(MediaTest, VideoBearMp4) {
PlayVideo("bear.mp4");
}
TEST_F(MediaTest, VideoBearSilentMp4) {
PlayVideo("bear_silent.mp4");
}
#endif
TEST_F(MediaTest, VideoBearWav) {
PlayVideo("bear.wav");
}
TEST_F(UILayoutTest, MediaUILayoutTest) {
static const char* kResources[] = {
"content",
"media-file.js",
"media-fullscreen.js",
"video-paint-test.js",
"video-played.js",
"video-test.js",
};
static const char* kMediaTests[] = {
"video-autoplay.html",
// "video-loop.html", disabled due to 52887.
"video-no-autoplay.html",
// TODO(sergeyu): Add more tests here.
};
FilePath test_dir;
FilePath media_test_dir;
media_test_dir = media_test_dir.AppendASCII("media");
InitializeForLayoutTest(test_dir, media_test_dir, kNoHttpPort);
// Copy resources first.
for (size_t i = 0; i < arraysize(kResources); ++i)
AddResourceForLayoutTest(
test_dir, media_test_dir.AppendASCII(kResources[i]));
for (size_t i = 0; i < arraysize(kMediaTests); ++i)
RunLayoutTest(kMediaTests[i], kNoHttpPort);
}
|