| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/test/webrtc_content_browsertest_base.h" | 5 #include "content/test/webrtc_content_browsertest_base.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "content/public/common/content_switches.h" | 10 #include "content/public/common/content_switches.h" |
| 11 #include "content/public/test/browser_test_utils.h" | 11 #include "content/public/test/browser_test_utils.h" |
| 12 #include "content/public/test/content_browser_test_utils.h" | 12 #include "content/public/test/content_browser_test_utils.h" |
| 13 #include "content/shell/browser/shell.h" | 13 #include "content/shell/browser/shell.h" |
| 14 #include "media/base/media_switches.h" | 14 #include "media/base/media_switches.h" |
| 15 | 15 |
| 16 #if defined(OS_CHROMEOS) |
| 17 #include "chromeos/audio/cras_audio_handler.h" |
| 18 #endif |
| 19 |
| 16 namespace content { | 20 namespace content { |
| 17 | 21 |
| 18 void WebRtcContentBrowserTest::SetUpCommandLine(CommandLine* command_line) { | 22 void WebRtcContentBrowserTest::SetUpCommandLine(CommandLine* command_line) { |
| 19 // We need fake devices in this test since we want to run on naked VMs. We | 23 // We need fake devices in this test since we want to run on naked VMs. We |
| 20 // assume these switches are set by default in content_browsertests. | 24 // assume these switches are set by default in content_browsertests. |
| 21 ASSERT_TRUE(CommandLine::ForCurrentProcess()->HasSwitch( | 25 ASSERT_TRUE(CommandLine::ForCurrentProcess()->HasSwitch( |
| 22 switches::kUseFakeDeviceForMediaStream)); | 26 switches::kUseFakeDeviceForMediaStream)); |
| 23 ASSERT_TRUE(CommandLine::ForCurrentProcess()->HasSwitch( | 27 ASSERT_TRUE(CommandLine::ForCurrentProcess()->HasSwitch( |
| 24 switches::kUseFakeUIForMediaStream)); | 28 switches::kUseFakeUIForMediaStream)); |
| 25 | 29 |
| 26 // Always include loopback interface in network list, in case the test device | 30 // Always include loopback interface in network list, in case the test device |
| 27 // doesn't have other interfaces available. | 31 // doesn't have other interfaces available. |
| 28 CommandLine::ForCurrentProcess()->AppendSwitch( | 32 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 29 switches::kAllowLoopbackInPeerConnection); | 33 switches::kAllowLoopbackInPeerConnection); |
| 30 } | 34 } |
| 31 | 35 |
| 32 void WebRtcContentBrowserTest::SetUp() { | 36 void WebRtcContentBrowserTest::SetUp() { |
| 33 EnablePixelOutput(); | 37 EnablePixelOutput(); |
| 38 #if defined(OS_CHROMEOS) |
| 39 chromeos::CrasAudioHandler::InitializeForTesting(); |
| 40 #endif |
| 34 ContentBrowserTest::SetUp(); | 41 ContentBrowserTest::SetUp(); |
| 35 } | 42 } |
| 36 | 43 |
| 44 void WebRtcContentBrowserTest::TearDown() { |
| 45 ContentBrowserTest::TearDown(); |
| 46 #if defined(OS_CHROMEOS) |
| 47 chromeos::CrasAudioHandler::Shutdown(); |
| 48 #endif |
| 49 } |
| 50 |
| 37 // Executes |javascript|. The script is required to use | 51 // Executes |javascript|. The script is required to use |
| 38 // window.domAutomationController.send to send a string value back to here. | 52 // window.domAutomationController.send to send a string value back to here. |
| 39 std::string WebRtcContentBrowserTest::ExecuteJavascriptAndReturnResult( | 53 std::string WebRtcContentBrowserTest::ExecuteJavascriptAndReturnResult( |
| 40 const std::string& javascript) { | 54 const std::string& javascript) { |
| 41 std::string result; | 55 std::string result; |
| 42 EXPECT_TRUE(ExecuteScriptAndExtractString(shell()->web_contents(), | 56 EXPECT_TRUE(ExecuteScriptAndExtractString(shell()->web_contents(), |
| 43 javascript, | 57 javascript, |
| 44 &result)); | 58 &result)); |
| 45 return result; | 59 return result; |
| 46 } | 60 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 77 | 91 |
| 78 void WebRtcContentBrowserTest::DisableOpusIfOnAndroid() { | 92 void WebRtcContentBrowserTest::DisableOpusIfOnAndroid() { |
| 79 #if defined(OS_ANDROID) | 93 #if defined(OS_ANDROID) |
| 80 // Always force iSAC 16K on Android for now (Opus is broken). | 94 // Always force iSAC 16K on Android for now (Opus is broken). |
| 81 EXPECT_EQ("isac-forced", | 95 EXPECT_EQ("isac-forced", |
| 82 ExecuteJavascriptAndReturnResult("forceIsac16KInSdp();")); | 96 ExecuteJavascriptAndReturnResult("forceIsac16KInSdp();")); |
| 83 #endif | 97 #endif |
| 84 } | 98 } |
| 85 | 99 |
| 86 } // namespace content | 100 } // namespace content |
| OLD | NEW |