summaryrefslogtreecommitdiffstats
path: root/chromium/content/browser/media/webrtc_browsertest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/content/browser/media/webrtc_browsertest.cc')
-rw-r--r--chromium/content/browser/media/webrtc_browsertest.cc678
1 files changed, 262 insertions, 416 deletions
diff --git a/chromium/content/browser/media/webrtc_browsertest.cc b/chromium/content/browser/media/webrtc_browsertest.cc
index 47847a7d53b..f5bb216ead0 100644
--- a/chromium/content/browser/media/webrtc_browsertest.cc
+++ b/chromium/content/browser/media/webrtc_browsertest.cc
@@ -3,234 +3,133 @@
// found in the LICENSE file.
#include "base/command_line.h"
-#include "base/debug/trace_event_impl.h"
-#include "base/json/json_reader.h"
+#include "base/file_util.h"
+#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
-#include "base/strings/utf_string_conversions.h"
+#include "base/threading/platform_thread.h"
#include "base/values.h"
+#include "content/browser/media/webrtc_internals.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/common/content_switches.h"
#include "content/public/test/browser_test_utils.h"
+#include "content/public/test/content_browser_test_utils.h"
+#include "content/public/test/test_utils.h"
#include "content/shell/browser/shell.h"
-#include "content/test/content_browser_test.h"
-#include "content/test/content_browser_test_utils.h"
+#include "content/test/webrtc_content_browsertest_base.h"
#include "media/audio/audio_manager.h"
+#include "media/base/media_switches.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
-#include "testing/perf/perf_test.h"
#if defined(OS_WIN)
#include "base/win/windows_version.h"
#endif
-const char kForceIsac16K[] =
-#ifdef OS_ANDROID
- // The default audio codec, Opus, doesn't work on Android.
- "true";
+#if defined (OS_ANDROID) || defined(THREAD_SANITIZER)
+// Just do the bare minimum of audio checking on Android and under TSAN since
+// it's a bit sensitive to device performance.
+static const char kUseLenientAudioChecking[] = "true";
#else
- "false";
+static const char kUseLenientAudioChecking[] = "false";
#endif
-namespace {
-
-static const char kGetUserMediaAndStop[] = "getUserMediaAndStop";
-static const char kGetUserMediaAndWaitAndStop[] = "getUserMediaAndWaitAndStop";
-static const char kGetUserMediaAndAnalyseAndStop[] =
- "getUserMediaAndAnalyseAndStop";
-
-std::string GenerateGetUserMediaCall(const char* function_name,
- int min_width,
- int max_width,
- int min_height,
- int max_height,
- int min_frame_rate,
- int max_frame_rate) {
- return base::StringPrintf(
- "%s({video: {mandatory: {minWidth: %d, maxWidth: %d, "
- "minHeight: %d, maxHeight: %d, minFrameRate: %d, maxFrameRate: %d}, "
- "optional: []}});",
- function_name,
- min_width,
- max_width,
- min_height,
- max_height,
- min_frame_rate,
- max_frame_rate);
-}
-}
-
namespace content {
-class WebrtcBrowserTest: public ContentBrowserTest {
+class WebRtcBrowserTest : public WebRtcContentBrowserTest,
+ public testing::WithParamInterface<bool> {
public:
- WebrtcBrowserTest() {}
- virtual ~WebrtcBrowserTest() {}
+ WebRtcBrowserTest() {}
+ virtual ~WebRtcBrowserTest() {}
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
- // We need fake devices in this test since we want to run on naked VMs. We
- // assume these switches are set by default in content_browsertests.
- ASSERT_TRUE(CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kUseFakeDeviceForMediaStream));
- ASSERT_TRUE(CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kUseFakeUIForMediaStream));
+ WebRtcContentBrowserTest::SetUpCommandLine(command_line);
- // The video playback will not work without a GPU, so force its use here.
- // This may not be available on all VMs though.
- command_line->AppendSwitch(switches::kUseGpuInTests);
+ bool enable_audio_track_processing = GetParam();
+ if (!enable_audio_track_processing)
+ command_line->AppendSwitch(switches::kDisableAudioTrackProcessing);
}
- void DumpChromeTraceCallback(
- const scoped_refptr<base::RefCountedString>& events,
- bool has_more_events) {
- // Convert the dump output into a correct JSON List.
- std::string contents = "[" + events->data() + "]";
-
- int error_code;
- std::string error_message;
- scoped_ptr<base::Value> value(
- base::JSONReader::ReadAndReturnError(contents,
- base::JSON_ALLOW_TRAILING_COMMAS,
- &error_code,
- &error_message));
-
- ASSERT_TRUE(value.get() != NULL) << error_message;
- EXPECT_EQ(value->GetType(), base::Value::TYPE_LIST);
-
- base::ListValue* values;
- ASSERT_TRUE(value->GetAsList(&values));
-
- int duration_ns = 0;
- std::string samples_duration;
- double timestamp_ns = 0.0;
- double previous_timestamp_ns = 0.0;
- std::string samples_interarrival_ns;
- for (ListValue::iterator it = values->begin(); it != values->end(); ++it) {
- const DictionaryValue* dict;
- EXPECT_TRUE((*it)->GetAsDictionary(&dict));
-
- if (dict->GetInteger("dur", &duration_ns))
- samples_duration.append(base::StringPrintf("%d,", duration_ns));
- if (dict->GetDouble("ts", &timestamp_ns)) {
- if (previous_timestamp_ns) {
- samples_interarrival_ns.append(
- base::StringPrintf("%f,", timestamp_ns - previous_timestamp_ns));
- }
- previous_timestamp_ns = timestamp_ns;
- }
- }
- ASSERT_GT(samples_duration.size(), 0u)
- << "Could not collect any samples during test, this is bad";
- perf_test::PrintResultList("video_capture",
- "",
- "sample_duration",
- samples_duration,
- "ns",
- true);
- perf_test::PrintResultList("video_capture",
- "",
- "interarrival_time",
- samples_interarrival_ns,
- "ns",
- true);
- }
+ // Convenience function since most peerconnection-call.html tests just load
+ // the page, kick off some javascript and wait for the title to change to OK.
+ void MakeTypicalPeerConnectionCall(const std::string& javascript) {
+ ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
- protected:
- bool ExecuteJavascript(const std::string& javascript) {
- return ExecuteScript(shell()->web_contents(), javascript);
- }
+ GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
+ NavigateToURL(shell(), url);
- void ExpectTitle(const std::string& expected_title) const {
- base::string16 expected_title16(ASCIIToUTF16(expected_title));
- TitleWatcher title_watcher(shell()->web_contents(), expected_title16);
- EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle());
+ DisableOpusIfOnAndroid();
+ ExecuteJavascriptAndWaitForOk(javascript);
}
-};
-
-// These tests will all make a getUserMedia call with different constraints and
-// see that the success callback is called. If the error callback is called or
-// none of the callbacks are called the tests will simply time out and fail.
-IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, GetVideoStreamAndStop) {
- ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
-
- GURL url(embedded_test_server()->GetURL("/media/getusermedia.html"));
- NavigateToURL(shell(), url);
-
- EXPECT_TRUE(ExecuteJavascript(
- base::StringPrintf("%s({video: true});", kGetUserMediaAndStop)));
-
- ExpectTitle("OK");
-}
-
-IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, GetAudioAndVideoStreamAndStop) {
- ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
-
- GURL url(embedded_test_server()->GetURL("/media/getusermedia.html"));
- NavigateToURL(shell(), url);
-
- EXPECT_TRUE(ExecuteJavascript(base::StringPrintf(
- "%s({video: true, audio: true});", kGetUserMediaAndStop)));
- ExpectTitle("OK");
-}
-
-IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, GetAudioAndVideoStreamAndClone) {
- ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
+ // Convenience method for making calls that detect if audio os playing (which
+ // has some special prerequisites, such that there needs to be an audio output
+ // device on the executing machine).
+ void MakeAudioDetectingPeerConnectionCall(const std::string& javascript) {
+ if (!media::AudioManager::Get()->HasAudioOutputDevices()) {
+ // Bots with no output devices will force the audio code into a state
+ // where it doesn't manage to set either the low or high latency path.
+ // This test will compute useless values in that case, so skip running on
+ // such bots (see crbug.com/326338).
+ LOG(INFO) << "Missing output devices: skipping test...";
+ return;
+ }
- GURL url(embedded_test_server()->GetURL("/media/getusermedia.html"));
- NavigateToURL(shell(), url);
+ ASSERT_TRUE(CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kUseFakeDeviceForMediaStream))
+ << "Must run with fake devices since the test will explicitly look "
+ << "for the fake device signal.";
- EXPECT_TRUE(ExecuteJavascript("getUserMediaAndClone();"));
+ MakeTypicalPeerConnectionCall(javascript);
+ }
- ExpectTitle("OK");
-}
+ void DisableOpusIfOnAndroid() {
+#if defined(OS_ANDROID)
+ // Always force iSAC 16K on Android for now (Opus is broken).
+ EXPECT_EQ("isac-forced",
+ ExecuteJavascriptAndReturnResult("forceIsac16KInSdp();"));
+#endif
+ }
+};
+static const bool kRunTestsWithFlag[] = { false, true };
+INSTANTIATE_TEST_CASE_P(WebRtcBrowserTests,
+ WebRtcBrowserTest,
+ testing::ValuesIn(kRunTestsWithFlag));
#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
// Timing out on ARM linux bot: http://crbug.com/238490
-#define MAYBE_CanSetupVideoCall DISABLED_CanSetupVideoCall
+#define MAYBE_CanSetupDefaultVideoCall DISABLED_CanSetupDefaultVideoCall
#else
-#define MAYBE_CanSetupVideoCall CanSetupVideoCall
+#define MAYBE_CanSetupDefaultVideoCall CanSetupDefaultVideoCall
#endif
// These tests will make a complete PeerConnection-based call and verify that
// video is playing for the call.
-IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MAYBE_CanSetupVideoCall) {
- ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
-
- GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
- NavigateToURL(shell(), url);
+IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, MAYBE_CanSetupDefaultVideoCall) {
+ MakeTypicalPeerConnectionCall(
+ "callAndExpectResolution({video: true}, 640, 480);");
+}
- EXPECT_TRUE(ExecuteJavascript("call({video: true});"));
- ExpectTitle("OK");
+IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, CanSetupVideoCallWith1To1AspecRatio) {
+ const std::string javascript =
+ "callAndExpectResolution({video: {mandatory: {minWidth: 320,"
+ " maxWidth: 320, minHeight: 320, maxHeight: 320}}}, 320, 320);";
+ MakeTypicalPeerConnectionCall(javascript);
}
-// This test will make a simple getUserMedia page, verify that video is playing
-// in a simple local <video>, and for a couple of seconds, collect some
-// performance traces.
-IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, TracePerformanceDuringGetUserMedia) {
- ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
+IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest,
+ CanSetupVideoCallWith16To9AspecRatio) {
+ const std::string javascript =
+ "callAndExpectResolution({video: {mandatory: {minWidth: 640,"
+ " maxWidth: 640, minAspectRatio: 1.777}}}, 640, 360);";
+ MakeTypicalPeerConnectionCall(javascript);
+}
- GURL url(embedded_test_server()->GetURL("/media/getusermedia.html"));
- NavigateToURL(shell(), url);
- // Put getUserMedia to work and let it run for a couple of seconds.
- EXPECT_TRUE(ExecuteJavascript(base::StringPrintf(
- "%s({video: true}, 10);", kGetUserMediaAndWaitAndStop)));
-
- // Make sure the stream is up and running, then start collecting traces.
- ExpectTitle("Running...");
- base::debug::TraceLog* trace_log = base::debug::TraceLog::GetInstance();
- trace_log->SetEnabled(base::debug::CategoryFilter("video"),
- base::debug::TraceLog::ENABLE_SAMPLING);
- // Check that we are indeed recording.
- EXPECT_EQ(trace_log->GetNumTracesRecorded(), 1);
-
- // Wait until the page title changes to "OK". Do not sleep() here since that
- // would stop both this code and the browser underneath.
- ExpectTitle("OK");
-
- // Note that we need to stop the trace recording before flushing the data.
- trace_log->SetDisabled();
- trace_log->Flush(base::Bind(&WebrtcBrowserTest::DumpChromeTraceCallback,
- base::Unretained(this)));
+IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest,
+ CanSetupVideoCallWith4To3AspecRatio) {
+ const std::string javascript =
+ "callAndExpectResolution({video: {mandatory: {minWidth: 960,"
+ "maxAspectRatio: 1.333}}}, 960, 720);";
+ MakeTypicalPeerConnectionCall(javascript);
}
#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
@@ -240,83 +139,73 @@ IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, TracePerformanceDuringGetUserMedia) {
#define MAYBE_CanSetupAudioAndVideoCall CanSetupAudioAndVideoCall
#endif
-IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MAYBE_CanSetupAudioAndVideoCall) {
- ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
-
- GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
- NavigateToURL(shell(), url);
-
- EXPECT_TRUE(ExecuteJavascript("call({video: true, audio: true});"));
- ExpectTitle("OK");
+IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, MAYBE_CanSetupAudioAndVideoCall) {
+ MakeTypicalPeerConnectionCall("call({video: true, audio: true});");
}
-IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MANUAL_CanSetupCallAndSendDtmf) {
- ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
-
- GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
- NavigateToURL(shell(), url);
-
- EXPECT_TRUE(
- ExecuteJavascript("callAndSendDtmf('123,abc');"));
+IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, MANUAL_CanSetupCallAndSendDtmf) {
+ MakeTypicalPeerConnectionCall("callAndSendDtmf(\'123,abc\');");
}
-IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest,
+// TODO(phoglund): this test fails because the peer connection state will be
+// stable in the second negotiation round rather than have-local-offer.
+// http://crbug.com/293125.
+IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest,
DISABLED_CanMakeEmptyCallThenAddStreamsAndRenegotiate) {
- ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
-
- GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
- NavigateToURL(shell(), url);
-
const char* kJavascript =
"callEmptyThenAddOneStreamAndRenegotiate({video: true, audio: true});";
- EXPECT_TRUE(ExecuteJavascript(kJavascript));
- ExpectTitle("OK");
+ MakeTypicalPeerConnectionCall(kJavascript);
}
// Below 2 test will make a complete PeerConnection-based call between pc1 and
// pc2, and then use the remote stream to setup a call between pc3 and pc4, and
// then verify that video is received on pc3 and pc4.
+// The stream sent from pc3 to pc4 is the stream received on pc1.
+// The stream sent from pc4 to pc3 is cloned from stream the stream received
+// on pc2.
// Flaky on win xp. http://crbug.com/304775
#if defined(OS_WIN)
#define MAYBE_CanForwardRemoteStream DISABLED_CanForwardRemoteStream
#define MAYBE_CanForwardRemoteStream720p DISABLED_CanForwardRemoteStream720p
#else
#define MAYBE_CanForwardRemoteStream CanForwardRemoteStream
+// Flaky on TSAN v2. http://crbug.com/373637
+#if defined(THREAD_SANITIZER)
+#define MAYBE_CanForwardRemoteStream720p DISABLED_CanForwardRemoteStream720p
+#else
#define MAYBE_CanForwardRemoteStream720p CanForwardRemoteStream720p
#endif
-IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MAYBE_CanForwardRemoteStream) {
- ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
-
- GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
- NavigateToURL(shell(), url);
-
- EXPECT_TRUE(ExecuteJavascript(
- "callAndForwardRemoteStream({video: true, audio: true});"));
- ExpectTitle("OK");
+#endif
+IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, MAYBE_CanForwardRemoteStream) {
+#if defined (OS_ANDROID)
+ // This test fails on Nexus 5 devices.
+ // TODO(henrika): see http://crbug.com/362437 and http://crbug.com/359389
+ // for details.
+ CommandLine::ForCurrentProcess()->AppendSwitch(
+ switches::kDisableWebRtcHWDecoding);
+#endif
+ MakeTypicalPeerConnectionCall(
+ "callAndForwardRemoteStream({video: true, audio: false});");
}
-IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MAYBE_CanForwardRemoteStream720p) {
- ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
-
- GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
- NavigateToURL(shell(), url);
-
- const std::string cmd = GenerateGetUserMediaCall("callAndForwardRemoteStream",
- 1280, 1280,
- 720, 720, 30, 30);
- EXPECT_TRUE(ExecuteJavascript(cmd));
- ExpectTitle("OK");
+IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, MAYBE_CanForwardRemoteStream720p) {
+#if defined (OS_ANDROID)
+ // This test fails on Nexus 5 devices.
+ // TODO(henrika): see http://crbug.com/362437 and http://crbug.com/359389
+ // for details.
+ CommandLine::ForCurrentProcess()->AppendSwitch(
+ switches::kDisableWebRtcHWDecoding);
+#endif
+ const std::string javascript = GenerateGetUserMediaCall(
+ "callAndForwardRemoteStream", 1280, 1280, 720, 720, 10, 30);
+ MakeTypicalPeerConnectionCall(javascript);
}
// This test will make a complete PeerConnection-based call but remove the
// MSID and bundle attribute from the initial offer to verify that
// video is playing for the call even if the initiating client don't support
// MSID. http://tools.ietf.org/html/draft-alvestrand-rtcweb-msid-02
-#if defined(OS_WIN) && defined(USE_AURA)
-// Disabled for win7_aura, see http://crbug.com/235089.
-#define MAYBE_CanSetupAudioAndVideoCallWithoutMsidAndBundle\
- DISABLED_CanSetupAudioAndVideoCallWithoutMsidAndBundle
-#elif defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
// Timing out on ARM linux, see http://crbug.com/240373
#define MAYBE_CanSetupAudioAndVideoCallWithoutMsidAndBundle\
DISABLED_CanSetupAudioAndVideoCallWithoutMsidAndBundle
@@ -324,85 +213,51 @@ IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MAYBE_CanForwardRemoteStream720p) {
#define MAYBE_CanSetupAudioAndVideoCallWithoutMsidAndBundle\
CanSetupAudioAndVideoCallWithoutMsidAndBundle
#endif
-IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest,
+IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest,
MAYBE_CanSetupAudioAndVideoCallWithoutMsidAndBundle) {
- ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
-
- GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
- NavigateToURL(shell(), url);
-
- EXPECT_TRUE(ExecuteJavascript("callWithoutMsidAndBundle();"));
- ExpectTitle("OK");
+ MakeTypicalPeerConnectionCall("callWithoutMsidAndBundle();");
}
// This test will modify the SDP offer to an unsupported codec, which should
// cause SetLocalDescription to fail.
-IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest,
- NegotiateUnsupportedVideoCodec) {
- ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
-
- GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
- NavigateToURL(shell(), url);
-
- EXPECT_TRUE(ExecuteJavascript("negotiateUnsupportedVideoCodec();"));
- ExpectTitle("OK");
+IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, NegotiateUnsupportedVideoCodec) {
+ MakeTypicalPeerConnectionCall("negotiateUnsupportedVideoCodec();");
}
// This test will modify the SDP offer to use no encryption, which should
// cause SetLocalDescription to fail.
-IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, NegotiateNonCryptoCall) {
- ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
-
- GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
- NavigateToURL(shell(), url);
+IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, NegotiateNonCryptoCall) {
+ MakeTypicalPeerConnectionCall("negotiateNonCryptoCall();");
+}
- EXPECT_TRUE(ExecuteJavascript("negotiateNonCryptoCall();"));
- ExpectTitle("OK");
+// This test can negotiate an SDP offer that includes a b=AS:xx to control
+// the bandwidth for audio and video
+IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, NegotiateOfferWithBLine) {
+ MakeTypicalPeerConnectionCall("negotiateOfferWithBLine();");
}
// This test will make a complete PeerConnection-based call using legacy SDP
// settings: GIce, external SDES, and no BUNDLE.
-#if defined(OS_WIN) && defined(USE_AURA)
-// Disabled for win7_aura, see http://crbug.com/235089.
-#define MAYBE_CanSetupLegacyCall DISABLED_CanSetupLegacyCall
-#elif defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
// Timing out on ARM linux, see http://crbug.com/240373
#define MAYBE_CanSetupLegacyCall DISABLED_CanSetupLegacyCall
#else
#define MAYBE_CanSetupLegacyCall CanSetupLegacyCall
#endif
-IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MAYBE_CanSetupLegacyCall) {
- ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
-
- GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
- NavigateToURL(shell(), url);
-
- EXPECT_TRUE(ExecuteJavascript("callWithLegacySdp();"));
- ExpectTitle("OK");
+IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, MAYBE_CanSetupLegacyCall) {
+ MakeTypicalPeerConnectionCall("callWithLegacySdp();");
}
// This test will make a PeerConnection-based call and test an unreliable text
// dataChannel.
// TODO(mallinath) - Remove this test after rtp based data channel is disabled.
-IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, CallWithDataOnly) {
- ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
-
- GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
- NavigateToURL(shell(), url);
-
- EXPECT_TRUE(ExecuteJavascript("callWithDataOnly();"));
- ExpectTitle("OK");
+IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, CallWithDataOnly) {
+ MakeTypicalPeerConnectionCall("callWithDataOnly();");
}
-IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, CallWithSctpDataOnly) {
- ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
-
- GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
- NavigateToURL(shell(), url);
-
- EXPECT_TRUE(ExecuteJavascript("callWithSctpDataOnly();"));
- ExpectTitle("OK");
+IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, CallWithSctpDataOnly) {
+ MakeTypicalPeerConnectionCall("callWithSctpDataOnly();");
}
#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
@@ -415,14 +270,8 @@ IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, CallWithSctpDataOnly) {
// This test will make a PeerConnection-based call and test an unreliable text
// dataChannel and audio and video tracks.
// TODO(mallinath) - Remove this test after rtp based data channel is disabled.
-IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MAYBE_CallWithDataAndMedia) {
- ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
-
- GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
- NavigateToURL(shell(), url);
-
- EXPECT_TRUE(ExecuteJavascript("callWithDataAndMedia();"));
- ExpectTitle("OK");
+IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, DISABLED_CallWithDataAndMedia) {
+ MakeTypicalPeerConnectionCall("callWithDataAndMedia();");
}
@@ -433,15 +282,9 @@ IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MAYBE_CallWithDataAndMedia) {
#define MAYBE_CallWithSctpDataAndMedia CallWithSctpDataAndMedia
#endif
-IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest,
+IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest,
MAYBE_CallWithSctpDataAndMedia) {
- ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
-
- GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
- NavigateToURL(shell(), url);
-
- EXPECT_TRUE(ExecuteJavascript("callWithSctpDataAndMedia();"));
- ExpectTitle("OK");
+ MakeTypicalPeerConnectionCall("callWithSctpDataAndMedia();");
}
#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
@@ -454,14 +297,8 @@ IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest,
// This test will make a PeerConnection-based call and test an unreliable text
// dataChannel and later add an audio and video track.
-IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MAYBE_CallWithDataAndLaterAddMedia) {
- ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
-
- GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
- NavigateToURL(shell(), url);
-
- EXPECT_TRUE(ExecuteJavascript("callWithDataAndLaterAddMedia();"));
- ExpectTitle("OK");
+IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, MAYBE_CallWithDataAndLaterAddMedia) {
+ MakeTypicalPeerConnectionCall("callWithDataAndLaterAddMedia();");
}
#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
@@ -474,14 +311,8 @@ IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MAYBE_CallWithDataAndLaterAddMedia) {
// This test will make a PeerConnection-based call and send a new Video
// MediaStream that has been created based on a MediaStream created with
// getUserMedia.
-IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MAYBE_CallWithNewVideoMediaStream) {
- ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
-
- GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
- NavigateToURL(shell(), url);
-
- EXPECT_TRUE(ExecuteJavascript("callWithNewVideoMediaStream();"));
- ExpectTitle("OK");
+IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, MAYBE_CallWithNewVideoMediaStream) {
+ MakeTypicalPeerConnectionCall("callWithNewVideoMediaStream();");
}
// This test will make a PeerConnection-based call and send a new Video
@@ -490,132 +321,147 @@ IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MAYBE_CallWithNewVideoMediaStream) {
// AudioTrack is added instead.
// TODO(phoglund): This test is manual since not all buildbots has an audio
// input.
-IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MANUAL_CallAndModifyStream) {
- ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
+IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, MANUAL_CallAndModifyStream) {
+ MakeTypicalPeerConnectionCall(
+ "callWithNewVideoMediaStreamLaterSwitchToAudio();");
+}
- GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
- NavigateToURL(shell(), url);
+IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, AddTwoMediaStreamsToOnePC) {
+ MakeTypicalPeerConnectionCall("addTwoMediaStreamsToOneConnection();");
+}
- EXPECT_TRUE(
- ExecuteJavascript("callWithNewVideoMediaStreamLaterSwitchToAudio();"));
- ExpectTitle("OK");
+IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest,
+ EstablishAudioVideoCallAndEnsureAudioIsPlaying) {
+ MakeAudioDetectingPeerConnectionCall(base::StringPrintf(
+ "callAndEnsureAudioIsPlaying(%s, {audio:true, video:true});",
+ kUseLenientAudioChecking));
}
-// This test calls getUserMedia in sequence with different constraints.
-IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, TestGetUserMediaConstraints) {
- ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
+IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest,
+ EstablishAudioOnlyCallAndEnsureAudioIsPlaying) {
+ MakeAudioDetectingPeerConnectionCall(base::StringPrintf(
+ "callAndEnsureAudioIsPlaying(%s, {audio:true});",
+ kUseLenientAudioChecking));
+}
- GURL url(embedded_test_server()->GetURL("/media/getusermedia.html"));
-
- std::vector<std::string> list_of_get_user_media_calls;
- list_of_get_user_media_calls.push_back(GenerateGetUserMediaCall(
- kGetUserMediaAndStop, 320, 320, 180, 180, 30, 30));
- list_of_get_user_media_calls.push_back(GenerateGetUserMediaCall(
- kGetUserMediaAndStop, 320, 320, 240, 240, 30, 30));
- list_of_get_user_media_calls.push_back(GenerateGetUserMediaCall(
- kGetUserMediaAndStop, 640, 640, 360, 360, 30, 30));
- list_of_get_user_media_calls.push_back(GenerateGetUserMediaCall(
- kGetUserMediaAndStop, 640, 640, 480, 480, 30, 30));
- list_of_get_user_media_calls.push_back(GenerateGetUserMediaCall(
- kGetUserMediaAndStop, 960, 960, 720, 720, 30, 30));
- list_of_get_user_media_calls.push_back(GenerateGetUserMediaCall(
- kGetUserMediaAndStop, 1280, 1280, 720, 720, 30, 30));
- list_of_get_user_media_calls.push_back(GenerateGetUserMediaCall(
- kGetUserMediaAndStop, 1920, 1920, 1080, 1080, 30, 30));
-
- for (std::vector<std::string>::iterator const_iterator =
- list_of_get_user_media_calls.begin();
- const_iterator != list_of_get_user_media_calls.end();
- ++const_iterator) {
- DVLOG(1) << "Calling getUserMedia: " << *const_iterator;
- NavigateToURL(shell(), url);
- EXPECT_TRUE(ExecuteJavascript(*const_iterator));
- ExpectTitle("OK");
- }
+IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest,
+ EstablishAudioVideoCallAndVerifyMutingWorks) {
+ MakeAudioDetectingPeerConnectionCall(base::StringPrintf(
+ "callAndEnsureAudioTrackMutingWorks(%s);", kUseLenientAudioChecking));
}
-// This test calls getUserMedia and checks for aspect ratio behavior.
-IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, TestGetUserMediaAspectRatio) {
- ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
+// Flaky on TSAN v2: http://crbug.com/373637
+#if defined(THREAD_SANITIZER)
+#define MAYBE_EstablishAudioVideoCallAndVerifyUnmutingWorks\
+ DISABLED_EstablishAudioVideoCallAndVerifyUnmutingWorks
+#else
+#define MAYBE_EstablishAudioVideoCallAndVerifyUnmutingWorks\
+ EstablishAudioVideoCallAndVerifyUnmutingWorks
+#endif
+IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest,
+ MAYBE_EstablishAudioVideoCallAndVerifyUnmutingWorks) {
+ MakeAudioDetectingPeerConnectionCall(base::StringPrintf(
+ "callAndEnsureAudioTrackUnmutingWorks(%s);", kUseLenientAudioChecking));
+}
- GURL url(embedded_test_server()->GetURL("/media/getusermedia.html"));
+IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, CallAndVerifyVideoMutingWorks) {
+ MakeTypicalPeerConnectionCall("callAndEnsureVideoTrackMutingWorks();");
+}
+
+#if defined(OS_WIN)
+#define IntToStringType base::IntToString16
+#else
+#define IntToStringType base::IntToString
+#endif
- std::string constraints_4_3 = GenerateGetUserMediaCall(
- kGetUserMediaAndAnalyseAndStop, 640, 640, 480, 480, 30, 30);
- std::string constraints_16_9 = GenerateGetUserMediaCall(
- kGetUserMediaAndAnalyseAndStop, 640, 640, 360, 360, 30, 30);
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
+// Timing out on ARM linux bot: http://crbug.com/238490
+#define MAYBE_CallWithAecDump DISABLED_CallWithAecDump
+#else
+#define MAYBE_CallWithAecDump CallWithAecDump
+#endif
- // TODO(mcasas): add more aspect ratios, in particular 16:10 crbug.com/275594.
+// This tests will make a complete PeerConnection-based call, verify that
+// video is playing for the call, and verify that a non-empty AEC dump file
+// exists. The AEC dump is enabled through webrtc-internals. The HTML and
+// Javascript is bypassed since it would trigger a file picker dialog. Instead,
+// the dialog callback FileSelected() is invoked directly. In fact, there's
+// never a webrtc-internals page opened at all since that's not needed.
+IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, MAYBE_CallWithAecDump) {
+ ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
- NavigateToURL(shell(), url);
- EXPECT_TRUE(ExecuteJavascript(constraints_4_3));
- ExpectTitle("4:3 letterbox");
+ // We must navigate somewhere first so that the render process is created.
+ NavigateToURL(shell(), GURL(""));
- NavigateToURL(shell(), url);
- EXPECT_TRUE(ExecuteJavascript(constraints_16_9));
- ExpectTitle("16:9 letterbox");
-}
+ base::FilePath dump_file;
+ ASSERT_TRUE(CreateTemporaryFile(&dump_file));
-IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, AddTwoMediaStreamsToOnePC) {
- ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
+ // This fakes the behavior of another open tab with webrtc-internals, and
+ // enabling AEC dump in that tab.
+ WebRTCInternals::GetInstance()->FileSelected(dump_file, -1, NULL);
GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
NavigateToURL(shell(), url);
-
- EXPECT_TRUE(
- ExecuteJavascript("addTwoMediaStreamsToOneConnection();"));
- ExpectTitle("OK");
+ DisableOpusIfOnAndroid();
+ ExecuteJavascriptAndWaitForOk("call({video: true, audio: true});");
+
+ // Get the ID for the render process host. There should only be one.
+ RenderProcessHost::iterator it(
+ content::RenderProcessHost::AllHostsIterator());
+ int render_process_host_id = it.GetCurrentValue()->GetID();
+ EXPECT_GE(render_process_host_id, 0);
+
+ // Add file extensions that we expect to be added.
+ static const int kExpectedConsumerId = 0;
+ dump_file = dump_file.AddExtension(IntToStringType(render_process_host_id))
+ .AddExtension(IntToStringType(kExpectedConsumerId));
+
+ EXPECT_TRUE(base::PathExists(dump_file));
+ int64 file_size = 0;
+ EXPECT_TRUE(base::GetFileSize(dump_file, &file_size));
+ EXPECT_GT(file_size, 0);
+
+ base::DeleteFile(dump_file, false);
}
-IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest,
- EstablishAudioVideoCallAndMeasureOutputLevel) {
- if (!media::AudioManager::Get()->HasAudioOutputDevices()) {
- // Bots with no output devices will force the audio code into a different
- // path where it doesn't manage to set either the low or high latency path.
- // This test will compute useless values in that case, so skip running on
- // such bots (see crbug.com/326338).
- LOG(INFO) << "Missing output devices: skipping test...";
- return;
- }
+// TODO(grunell): Add test for multiple dumps when re-use of
+// MediaStreamAudioProcessor in AudioCapturer has been removed.
- ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
- ASSERT_TRUE(CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kUseFakeDeviceForMediaStream))
- << "Must run with fake devices since the test will explicitly look "
- << "for the fake device signal.";
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
+// Timing out on ARM linux bot: http://crbug.com/238490
+#define MAYBE_CallWithAecDumpEnabledThenDisabled DISABLED_CallWithAecDumpEnabledThenDisabled
+#else
+#define MAYBE_CallWithAecDumpEnabledThenDisabled CallWithAecDumpEnabledThenDisabled
+#endif
- GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
- NavigateToURL(shell(), url);
+// As above, but enable and disable dump before starting a call. The file should
+// be created, but should be empty.
+IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest,
+ MAYBE_CallWithAecDumpEnabledThenDisabled) {
+ ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
- EXPECT_TRUE(ExecuteJavascript(
- base::StringPrintf("callAndEnsureAudioIsPlaying(%s);", kForceIsac16K)));
- ExpectTitle("OK");
-}
+ // We must navigate somewhere first so that the render process is created.
+ NavigateToURL(shell(), GURL(""));
-IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest,
- EstablishAudioVideoCallAndVerifyMutingWorks) {
- if (!media::AudioManager::Get()->HasAudioOutputDevices()) {
- // Bots with no output devices will force the audio code into a different
- // path where it doesn't manage to set either the low or high latency path.
- // This test will compute useless values in that case, so skip running on
- // such bots (see crbug.com/326338).
- LOG(INFO) << "Missing output devices: skipping test...";
- return;
- }
+ base::FilePath dump_file;
+ ASSERT_TRUE(CreateTemporaryFile(&dump_file));
- ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
- ASSERT_TRUE(CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kUseFakeDeviceForMediaStream))
- << "Must run with fake devices since the test will explicitly look "
- << "for the fake device signal.";
+ // This fakes the behavior of another open tab with webrtc-internals, and
+ // enabling AEC dump in that tab, then disabling it.
+ WebRTCInternals::GetInstance()->FileSelected(dump_file, -1, NULL);
+ WebRTCInternals::GetInstance()->DisableAecDump();
GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html"));
NavigateToURL(shell(), url);
+ DisableOpusIfOnAndroid();
+ ExecuteJavascriptAndWaitForOk("call({video: true, audio: true});");
+
+ EXPECT_TRUE(base::PathExists(dump_file));
+ int64 file_size = 0;
+ EXPECT_TRUE(base::GetFileSize(dump_file, &file_size));
+ EXPECT_EQ(0, file_size);
- EXPECT_TRUE(ExecuteJavascript(
- base::StringPrintf("callAndEnsureAudioMutingWorks(%s);",
- kForceIsac16K)));
- ExpectTitle("OK");
+ base::DeleteFile(dump_file, false);
}
} // namespace content