ehmaldonado | b6d4bca | 2016-07-21 11:47:15 | [diff] [blame] | 1 | // Copyright (c) 2016 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/command_line.h" |
| 6 | #include "base/files/file_util.h" |
| 7 | #include "base/threading/platform_thread.h" |
| 8 | #include "build/build_config.h" |
| 9 | #include "content/browser/web_contents/web_contents_impl.h" |
mcasas | 6b8c0c8 | 2016-07-29 23:04:35 | [diff] [blame] | 10 | #include "content/browser/webrtc/webrtc_content_browsertest_base.h" |
ehmaldonado | b6d4bca | 2016-07-21 11:47:15 | [diff] [blame] | 11 | #include "content/public/common/content_switches.h" |
| 12 | #include "content/public/common/webrtc_ip_handling_policy.h" |
| 13 | #include "content/public/test/browser_test_utils.h" |
| 14 | #include "content/public/test/content_browser_test_utils.h" |
| 15 | #include "content/public/test/test_utils.h" |
ehmaldonado | b6d4bca | 2016-07-21 11:47:15 | [diff] [blame] | 16 | #include "media/audio/audio_manager.h" |
| 17 | #include "media/base/media_switches.h" |
| 18 | #include "net/test/embedded_test_server/embedded_test_server.h" |
| 19 | |
| 20 | namespace content { |
| 21 | |
| 22 | #if defined(OS_ANDROID) && defined(ADDRESS_SANITIZER) |
| 23 | // Renderer crashes under Android ASAN: https://crbug.com/408496. |
ehmaldonado | 0e18dfb | 2016-08-03 11:09:44 | [diff] [blame] | 24 | #define MAYBE_WebRtcDataBrowserTest DISABLED_WebRtcDataBrowserTest |
ehmaldonado | b6d4bca | 2016-07-21 11:47:15 | [diff] [blame] | 25 | #else |
ehmaldonado | 0e18dfb | 2016-08-03 11:09:44 | [diff] [blame] | 26 | #define MAYBE_WebRtcDataBrowserTest WebRtcDataBrowserTest |
ehmaldonado | b6d4bca | 2016-07-21 11:47:15 | [diff] [blame] | 27 | #endif |
| 28 | |
| 29 | // This class tests the scenario when permission to access mic or camera is |
| 30 | // granted. |
mcasas | 41f5b70 | 2016-08-03 20:19:41 | [diff] [blame] | 31 | class MAYBE_WebRtcDataBrowserTest : public WebRtcContentBrowserTestBase { |
ehmaldonado | b6d4bca | 2016-07-21 11:47:15 | [diff] [blame] | 32 | public: |
ehmaldonado | 0e18dfb | 2016-08-03 11:09:44 | [diff] [blame] | 33 | MAYBE_WebRtcDataBrowserTest() {} |
| 34 | ~MAYBE_WebRtcDataBrowserTest() override {} |
ehmaldonado | b6d4bca | 2016-07-21 11:47:15 | [diff] [blame] | 35 | |
| 36 | void SetUpCommandLine(base::CommandLine* command_line) override { |
mcasas | 41f5b70 | 2016-08-03 20:19:41 | [diff] [blame] | 37 | WebRtcContentBrowserTestBase::SetUpCommandLine(command_line); |
ehmaldonado | b6d4bca | 2016-07-21 11:47:15 | [diff] [blame] | 38 | // Automatically grant device permission. |
| 39 | AppendUseFakeUIForMediaStreamFlag(); |
| 40 | } |
| 41 | |
| 42 | protected: |
| 43 | // Convenience function since most peerconnection-call.html tests just load |
| 44 | // the page, kick off some javascript and wait for the title to change to OK. |
| 45 | void MakeTypicalPeerConnectionCall(const std::string& javascript) { |
| 46 | MakeTypicalCall(javascript, "/media/peerconnection-call-data.html"); |
| 47 | } |
| 48 | }; |
| 49 | |
ehmaldonado | 0e18dfb | 2016-08-03 11:09:44 | [diff] [blame] | 50 | IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcDataBrowserTest, CanSetupLegacyCall) { |
ehmaldonado | b6d4bca | 2016-07-21 11:47:15 | [diff] [blame] | 51 | MakeTypicalPeerConnectionCall("callWithLegacySdp();"); |
| 52 | } |
| 53 | |
| 54 | // This test will make a PeerConnection-based call and test an unreliable text |
| 55 | // dataChannel. |
| 56 | // TODO(mallinath) - Remove this test after rtp based data channel is disabled. |
ehmaldonado | 0e18dfb | 2016-08-03 11:09:44 | [diff] [blame] | 57 | IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcDataBrowserTest, CallWithDataOnly) { |
ehmaldonado | b6d4bca | 2016-07-21 11:47:15 | [diff] [blame] | 58 | MakeTypicalPeerConnectionCall("callWithDataOnly();"); |
| 59 | } |
| 60 | |
| 61 | #if defined(MEMORY_SANITIZER) |
| 62 | // Fails under MemorySanitizer: http://crbug.com/405951 |
| 63 | #define MAYBE_CallWithSctpDataOnly DISABLED_CallWithSctpDataOnly |
| 64 | #else |
| 65 | #define MAYBE_CallWithSctpDataOnly CallWithSctpDataOnly |
| 66 | #endif |
ehmaldonado | 0e18dfb | 2016-08-03 11:09:44 | [diff] [blame] | 67 | IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcDataBrowserTest, |
ehmaldonado | b6d4bca | 2016-07-21 11:47:15 | [diff] [blame] | 68 | MAYBE_CallWithSctpDataOnly) { |
| 69 | MakeTypicalPeerConnectionCall("callWithSctpDataOnly();"); |
| 70 | } |
| 71 | |
| 72 | // This test will make a PeerConnection-based call and test an unreliable text |
| 73 | // dataChannel and audio and video tracks. |
| 74 | // TODO(mallinath) - Remove this test after rtp based data channel is disabled. |
ehmaldonado | 0e18dfb | 2016-08-03 11:09:44 | [diff] [blame] | 75 | IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcDataBrowserTest, CallWithDataAndMedia) { |
ehmaldonado | b6d4bca | 2016-07-21 11:47:15 | [diff] [blame] | 76 | MakeTypicalPeerConnectionCall("callWithDataAndMedia();"); |
| 77 | } |
| 78 | |
| 79 | |
| 80 | #if defined(MEMORY_SANITIZER) |
| 81 | // Fails under MemorySanitizer: http://crbug.com/405951 |
| 82 | #define MAYBE_CallWithSctpDataAndMedia DISABLED_CallWithSctpDataAndMedia |
| 83 | #else |
| 84 | #define MAYBE_CallWithSctpDataAndMedia CallWithSctpDataAndMedia |
| 85 | #endif |
ehmaldonado | 0e18dfb | 2016-08-03 11:09:44 | [diff] [blame] | 86 | IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcDataBrowserTest, |
ehmaldonado | b6d4bca | 2016-07-21 11:47:15 | [diff] [blame] | 87 | MAYBE_CallWithSctpDataAndMedia) { |
| 88 | MakeTypicalPeerConnectionCall("callWithSctpDataAndMedia();"); |
| 89 | } |
| 90 | |
| 91 | // This test will make a PeerConnection-based call and test an unreliable text |
| 92 | // dataChannel and later add an audio and video track. |
| 93 | // Doesn't work, therefore disabled: https://crbug.com/293252. |
ehmaldonado | 0e18dfb | 2016-08-03 11:09:44 | [diff] [blame] | 94 | IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcDataBrowserTest, |
ehmaldonado | b6d4bca | 2016-07-21 11:47:15 | [diff] [blame] | 95 | DISABLED_CallWithDataAndLaterAddMedia) { |
| 96 | MakeTypicalPeerConnectionCall("callWithDataAndLaterAddMedia();"); |
| 97 | } |
| 98 | |
| 99 | } // namespace content |