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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
content / browser / webrtc / webrtc_media_recorder_browsertest.cc [blame]
// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/command_line.h"
#include "base/strings/stringprintf.h"
#include "build/build_config.h"
#include "content/browser/webrtc/webrtc_content_browsertest_base.h"
#include "content/public/common/content_switches.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/content_browser_test_utils.h"
#include "media/base/media_switches.h"
namespace {
static const char kMediaRecorderHtmlFile[] = "/media/mediarecorder_test.html";
static struct EncodingParameters {
bool disable_accelerator;
std::string mime_type;
} const kEncodingParameters[] = {
{true, "video/webm;codecs=VP8"},
{true, "video/webm;codecs=VP9"},
{false, ""}, // Instructs the platform to choose any accelerated codec.
{false, "video/webm;codecs=VP8"},
{false, "video/webm;codecs=VP9"},
};
static const EncodingParameters kProprietaryEncodingParameters[] = {
{true, "video/x-matroska;codecs=AVC1"},
{false, "video/x-matroska;codecs=AVC1"},
};
} // namespace
namespace content {
// This class tests the recording of a media stream.
class WebRtcMediaRecorderTest
: public WebRtcContentBrowserTestBase,
public testing::WithParamInterface<struct EncodingParameters> {
public:
void SetUpCommandLine(base::CommandLine* command_line) override {
WebRtcContentBrowserTestBase::SetUpCommandLine(command_line);
AppendUseFakeUIForMediaStreamFlag();
command_line->AppendSwitch(switches::kUseFakeDeviceForMediaStream);
if (GetParam().disable_accelerator) {
command_line->AppendSwitch(switches::kDisableAcceleratedVideoEncode);
}
}
};
// TODO(crbug/361123384): Re-enable.
#if BUILDFLAG(IS_ANDROID)
#define MAYBE_Start DISABLED_Start
#else
#define MAYBE_Start Start
#endif
IN_PROC_BROWSER_TEST_P(WebRtcMediaRecorderTest, MAYBE_Start) {
MakeTypicalCall("testStartAndRecorderState();", kMediaRecorderHtmlFile);
}
IN_PROC_BROWSER_TEST_P(WebRtcMediaRecorderTest, StartAndStop) {
MakeTypicalCall("testStartStopAndRecorderState();", kMediaRecorderHtmlFile);
}
#if BUILDFLAG(IS_MAC) && defined(ARCH_CPU_ARM64)
// https://crbug.com/1222675
#define MAYBE_StartAndDataAvailable DISABLED_StartAndDataAvailable
#else
#define MAYBE_StartAndDataAvailable StartAndDataAvailable
#endif
IN_PROC_BROWSER_TEST_P(WebRtcMediaRecorderTest, MAYBE_StartAndDataAvailable) {
MakeTypicalCall(base::StringPrintf("testStartAndDataAvailable(\"%s\");",
GetParam().mime_type.c_str()),
kMediaRecorderHtmlFile);
}
// TODO(crbug.com/40559669): It seems to be flaky on Android. More details in
// the bug.
#if BUILDFLAG(IS_ANDROID)
#define MAYBE_StartWithTimeSlice DISABLED_StartWithTimeSlice
#else
#define MAYBE_StartWithTimeSlice StartWithTimeSlice
#endif
IN_PROC_BROWSER_TEST_P(WebRtcMediaRecorderTest, MAYBE_StartWithTimeSlice) {
MakeTypicalCall(base::StringPrintf("testStartWithTimeSlice(\"%s\");",
GetParam().mime_type.c_str()),
kMediaRecorderHtmlFile);
}
IN_PROC_BROWSER_TEST_P(WebRtcMediaRecorderTest, Resume) {
MakeTypicalCall("testResumeAndRecorderState();", kMediaRecorderHtmlFile);
}
IN_PROC_BROWSER_TEST_P(WebRtcMediaRecorderTest, NoResumeWhenRecorderInactive) {
MakeTypicalCall("testIllegalResumeThrowsDOMError();", kMediaRecorderHtmlFile);
}
// TODO(crbug.com/40903193): Seems the test is not working quite well on
// android-12l-x64-dbg-tests.
#if (BUILDFLAG(IS_MAC) && defined(ARCH_CPU_ARM64)) || BUILDFLAG(IS_ANDROID)
// https://crbug.com/1222675
#define MAYBE_ResumeAndDataAvailable DISABLED_ResumeAndDataAvailable
#else
#define MAYBE_ResumeAndDataAvailable ResumeAndDataAvailable
#endif
IN_PROC_BROWSER_TEST_P(WebRtcMediaRecorderTest, MAYBE_ResumeAndDataAvailable) {
MakeTypicalCall(base::StringPrintf("testResumeAndDataAvailable(\"%s\");",
GetParam().mime_type.c_str()),
kMediaRecorderHtmlFile);
}
IN_PROC_BROWSER_TEST_P(WebRtcMediaRecorderTest, Pause) {
MakeTypicalCall("testPauseAndRecorderState();", kMediaRecorderHtmlFile);
}
// TODO(crbug.com/40450139): Flaky on TSAN bots.
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
#define MAYBE_PauseStop DISABLED_PauseStop
#else
#define MAYBE_PauseStop PauseStop
#endif
IN_PROC_BROWSER_TEST_P(WebRtcMediaRecorderTest, MAYBE_PauseStop) {
MakeTypicalCall("testPauseStopAndRecorderState();", kMediaRecorderHtmlFile);
}
IN_PROC_BROWSER_TEST_P(WebRtcMediaRecorderTest,
PausePreventsDataavailableFromBeingFired) {
MakeTypicalCall("testPausePreventsDataavailableFromBeingFired();",
kMediaRecorderHtmlFile);
}
// TODO (crbug.com/736268): Flaky on Linux TSan bots.
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
#define MAYBE_IllegalPauseThrowsDOMError DISABLED_IllegalPauseThrowsDOMError
#else
#define MAYBE_IllegalPauseThrowsDOMError IllegalPauseThrowsDOMError
#endif
IN_PROC_BROWSER_TEST_P(WebRtcMediaRecorderTest,
MAYBE_IllegalPauseThrowsDOMError) {
MakeTypicalCall("testIllegalPauseThrowsDOMError();", kMediaRecorderHtmlFile);
}
#if BUILDFLAG(IS_MAC) && defined(ARCH_CPU_ARM64)
// https://crbug.com/1222675
#define MAYBE_TwoChannelAudioRecording DISABLED_TwoChannelAudioRecording
#else
#define MAYBE_TwoChannelAudioRecording TwoChannelAudioRecording
#endif
IN_PROC_BROWSER_TEST_P(WebRtcMediaRecorderTest,
MAYBE_TwoChannelAudioRecording) {
MakeTypicalCall("testTwoChannelAudio();", kMediaRecorderHtmlFile);
}
IN_PROC_BROWSER_TEST_P(WebRtcMediaRecorderTest, RecordWithTransparency) {
MakeTypicalCall(base::StringPrintf("testRecordWithTransparency(\"%s\");",
GetParam().mime_type.c_str()),
kMediaRecorderHtmlFile);
}
IN_PROC_BROWSER_TEST_P(WebRtcMediaRecorderTest,
IllegalStartWhileRecordingThrowsDOMError) {
MakeTypicalCall("testIllegalStartInRecordingStateThrowsDOMError();",
kMediaRecorderHtmlFile);
}
IN_PROC_BROWSER_TEST_P(WebRtcMediaRecorderTest,
IllegalStartWhilePausedThrowsDOMError) {
MakeTypicalCall("testIllegalStartInPausedStateThrowsDOMError();",
kMediaRecorderHtmlFile);
}
// Flaky on Linux Tsan (crbug.com/736268)
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
#define MAYBE_IllegalRequestDataThrowsDOMError \
DISABLED_IllegalRequestDataThrowsDOMError
#else
#define MAYBE_IllegalRequestDataThrowsDOMError IllegalRequestDataThrowsDOMError
#endif
IN_PROC_BROWSER_TEST_P(WebRtcMediaRecorderTest,
MAYBE_IllegalRequestDataThrowsDOMError) {
MakeTypicalCall("testIllegalRequestDataThrowsDOMError();",
kMediaRecorderHtmlFile);
}
#if BUILDFLAG(IS_ANDROID)
// These tests are flakily timing out on emulators (https://crbug.com/716691)
// and/or under Android ASAN (https://crbug.com/693565);
#define MAYBE_PeerConnection DISABLED_PeerConnection
#elif (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)) && \
defined(THREAD_SANITIZER)
// Flaky on Linux TSan, https://crbug.com/694373.
#define MAYBE_PeerConnection DISABLED_PeerConnection
#elif BUILDFLAG(IS_WIN) && !defined(NDEBUG)
// Fails on Win7 debug, https://crbug.com/703844.
#define MAYBE_PeerConnection DISABLED_PeerConnection
#elif BUILDFLAG(IS_MAC) && defined(ARCH_CPU_ARM64)
// Fails on Mac/Arm, https://crbug.com/1222675
#define MAYBE_PeerConnection DISABLED_PeerConnection
#elif BUILDFLAG(IS_FUCHSIA) && defined(ARCH_CPU_X86_64)
// Flaky on Fuchsia-x64, https://crbug.com/1408820
#define MAYBE_PeerConnection DISABLED_PeerConnection
#else
#define MAYBE_PeerConnection PeerConnection
#endif
IN_PROC_BROWSER_TEST_P(WebRtcMediaRecorderTest, MAYBE_PeerConnection) {
MakeTypicalCall(base::StringPrintf("testRecordRemotePeerConnection(\"%s\");",
GetParam().mime_type.c_str()),
kMediaRecorderHtmlFile);
}
// Flaky on Linux Tsan (crbug.com/736268)
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
#define MAYBE_AddingTrackToMediaStreamFiresErrorEvent \
DISABLED_AddingTrackToMediaStreamFiresErrorEvent
#elif BUILDFLAG(IS_ANDROID)
// Flaky on Android (crbug.com/1174634).
#define MAYBE_AddingTrackToMediaStreamFiresErrorEvent \
DISABLED_AddingTrackToMediaStreamFiresErrorEvent
#else
#define MAYBE_AddingTrackToMediaStreamFiresErrorEvent \
AddingTrackToMediaStreamFiresErrorEvent
#endif
IN_PROC_BROWSER_TEST_P(WebRtcMediaRecorderTest,
MAYBE_AddingTrackToMediaStreamFiresErrorEvent) {
MakeTypicalCall("testAddingTrackToMediaStreamFiresErrorEvent();",
kMediaRecorderHtmlFile);
}
IN_PROC_BROWSER_TEST_P(WebRtcMediaRecorderTest,
RemovingTrackFromMediaStreamFiresErrorEvent) {
MakeTypicalCall("testRemovingTrackFromMediaStreamFiresErrorEvent();",
kMediaRecorderHtmlFile);
}
INSTANTIATE_TEST_SUITE_P(OpenCodec,
WebRtcMediaRecorderTest,
testing::ValuesIn(kEncodingParameters));
#if BUILDFLAG(USE_PROPRIETARY_CODECS)
INSTANTIATE_TEST_SUITE_P(ProprietaryCodec,
WebRtcMediaRecorderTest,
testing::ValuesIn(kProprietaryEncodingParameters));
#endif // BUILDFLAG(USE_PROPRIETARY_CODECS)
} // namespace content