| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
| 7 #include "base/threading/platform_thread.h" | 7 #include "base/threading/platform_thread.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "content/browser/web_contents/web_contents_impl.h" | 9 #include "content/browser/web_contents/web_contents_impl.h" |
| 10 #include "content/browser/webrtc/webrtc_content_browsertest_base.h" | 10 #include "content/browser/webrtc/webrtc_content_browsertest_base.h" |
| 11 #include "content/public/common/content_switches.h" | 11 #include "content/public/common/content_switches.h" |
| 12 #include "content/public/common/webrtc_ip_handling_policy.h" | 12 #include "content/public/common/webrtc_ip_handling_policy.h" |
| 13 #include "content/public/test/browser_test_utils.h" | 13 #include "content/public/test/browser_test_utils.h" |
| 14 #include "content/public/test/content_browser_test_utils.h" | 14 #include "content/public/test/content_browser_test_utils.h" |
| 15 #include "content/public/test/test_utils.h" | 15 #include "content/public/test/test_utils.h" |
| 16 #include "media/audio/audio_manager.h" | 16 #include "media/audio/audio_manager.h" |
| 17 #include "media/base/media_switches.h" | 17 #include "media/base/media_switches.h" |
| 18 #include "net/test/embedded_test_server/embedded_test_server.h" | 18 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 19 | 19 |
| 20 namespace content { | 20 namespace content { |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 const char kPeerConnectionHtml[] = "/media/peerconnection-call.html"; | 23 const char kPeerConnectionHtml[] = "/media/peerconnection-call.html"; |
| 24 } // namespace | 24 } // namespace |
| 25 | 25 |
| 26 // Disable these test cases for Android since in some bots, there exists only | 26 // Disable these test cases for Android since in some bots, there exists only |
| 27 // the loopback interface. | 27 // the loopback interface. |
| 28 #if defined(OS_ANDROID) | 28 #if defined(OS_ANDROID) |
| 29 #define MAYBE_WebRtcBrowserIPPermissionGrantedTest \ | 29 #define MAYBE_WebRtcIPPermissionGrantedTest \ |
| 30 DISABLED_WebRtcBrowserIPPermissionGrantedTest | 30 DISABLED_WebRtcIPPermissionGrantedTest |
| 31 #define MAYBE_WebRtcBrowserIPPermissionDeniedTest \ | 31 #define MAYBE_WebRtcIPPermissionDeniedTest DISABLED_WebRtcIPPermissionDeniedTest |
| 32 DISABLED_WebRtcBrowserIPPermissionDeniedTest | 32 #define MAYBE_WebRtcIPPolicyPublicAndPrivateInterfacesTest \ |
| 33 #define MAYBE_WebRtcBrowserIPPolicyPublicAndPrivateInterfacesTest \ | 33 DISABLED_WebRtcIPPolicyPublicAndPrivateInterfacesTest |
| 34 DISABLED_WebRtcBrowserIPPolicyPublicAndPrivateInterfacesTest | 34 #define MAYBE_WebRtcIPPolicyPublicInterfaceOnlyTest \ |
| 35 #define MAYBE_WebRtcBrowserIPPolicyPublicInterfaceOnlyTest \ | 35 DISABLED_WebRtcIPPolicyPublicInterfaceOnlyTest |
| 36 DISABLED_WebRtcBrowserIPPolicyPublicInterfaceOnlyTest | 36 #define MAYBE_WebRtcIPPolicyDisableUdpTest DISABLED_WebRtcIPPolicyDisableUdpTest |
| 37 #define MAYBE_WebRtcBrowserIPPolicyDisableUdpTest \ | |
| 38 DISABLED_WebRtcBrowserIPPolicyDisableUdpTest | |
| 39 #else | 37 #else |
| 40 #define MAYBE_WebRtcBrowserIPPermissionGrantedTest \ | 38 #define MAYBE_WebRtcIPPermissionGrantedTest WebRtcIPPermissionGrantedTest |
| 41 WebRtcBrowserIPPermissionGrantedTest | 39 #define MAYBE_WebRtcIPPermissionDeniedTest WebRtcIPPermissionDeniedTest |
| 42 #define MAYBE_WebRtcBrowserIPPermissionDeniedTest \ | 40 #define MAYBE_WebRtcIPPolicyPublicAndPrivateInterfacesTest \ |
| 43 WebRtcBrowserIPPermissionDeniedTest | 41 WebRtcIPPolicyPublicAndPrivateInterfacesTest |
| 44 #define MAYBE_WebRtcBrowserIPPolicyPublicAndPrivateInterfacesTest \ | 42 #define MAYBE_WebRtcIPPolicyPublicInterfaceOnlyTest \ |
| 45 WebRtcBrowserIPPolicyPublicAndPrivateInterfacesTest | 43 WebRtcIPPolicyPublicInterfaceOnlyTest |
| 46 #define MAYBE_WebRtcBrowserIPPolicyPublicInterfaceOnlyTest \ | 44 #define MAYBE_WebRtcIPPolicyDisableUdpTest WebRtcIPPolicyDisableUdpTest |
| 47 WebRtcBrowserIPPolicyPublicInterfaceOnlyTest | |
| 48 #define MAYBE_WebRtcBrowserIPPolicyDisableUdpTest \ | |
| 49 WebRtcBrowserIPPolicyDisableUdpTest | |
| 50 #endif | 45 #endif |
| 51 | 46 |
| 52 // This class tests the scenario when permission to access mic or camera is | 47 // This class tests the scenario when permission to access mic or camera is |
| 53 // denied. | 48 // denied. |
| 54 class MAYBE_WebRtcBrowserIPPermissionGrantedTest | 49 class MAYBE_WebRtcIPPermissionGrantedTest |
| 55 : public WebRtcContentBrowserTest { | 50 : public WebRtcContentBrowserTestBase { |
| 56 public: | 51 public: |
| 57 MAYBE_WebRtcBrowserIPPermissionGrantedTest() {} | 52 MAYBE_WebRtcIPPermissionGrantedTest() {} |
| 58 ~MAYBE_WebRtcBrowserIPPermissionGrantedTest() override {} | 53 ~MAYBE_WebRtcIPPermissionGrantedTest() override {} |
| 59 | 54 |
| 60 void SetUpCommandLine(base::CommandLine* command_line) override { | 55 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 61 WebRtcContentBrowserTest::SetUpCommandLine(command_line); | 56 WebRtcContentBrowserTestBase::SetUpCommandLine(command_line); |
| 62 AppendUseFakeUIForMediaStreamFlag(); | 57 AppendUseFakeUIForMediaStreamFlag(); |
| 63 command_line->AppendSwitchASCII(switches::kForceWebRtcIPHandlingPolicy, | 58 command_line->AppendSwitchASCII(switches::kForceWebRtcIPHandlingPolicy, |
| 64 kWebRTCIPHandlingDefault); | 59 kWebRTCIPHandlingDefault); |
| 65 } | 60 } |
| 66 }; | 61 }; |
| 67 | 62 |
| 68 // Loopback interface is the non-default private interface. Test that when | 63 // Loopback interface is the non-default private interface. Test that when |
| 69 // device permission is granted, we should have loopback candidates. | 64 // device permission is granted, we should have loopback candidates. |
| 70 IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcBrowserIPPermissionGrantedTest, | 65 IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcIPPermissionGrantedTest, |
| 71 GatherLocalCandidates) { | 66 GatherLocalCandidates) { |
| 72 MakeTypicalCall("callWithDevicePermissionGranted();", kPeerConnectionHtml); | 67 MakeTypicalCall("callWithDevicePermissionGranted();", kPeerConnectionHtml); |
| 73 } | 68 } |
| 74 | 69 |
| 75 // This class tests the scenario when permission to access mic or camera is | 70 // This class tests the scenario when permission to access mic or camera is |
| 76 // denied. | 71 // denied. |
| 77 class MAYBE_WebRtcBrowserIPPermissionDeniedTest | 72 class MAYBE_WebRtcIPPermissionDeniedTest : public WebRtcContentBrowserTestBase { |
| 78 : public WebRtcContentBrowserTest { | |
| 79 public: | 73 public: |
| 80 MAYBE_WebRtcBrowserIPPermissionDeniedTest() {} | 74 MAYBE_WebRtcIPPermissionDeniedTest() {} |
| 81 ~MAYBE_WebRtcBrowserIPPermissionDeniedTest() override {} | 75 ~MAYBE_WebRtcIPPermissionDeniedTest() override {} |
| 82 | 76 |
| 83 void SetUpCommandLine(base::CommandLine* command_line) override { | 77 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 84 WebRtcContentBrowserTest::SetUpCommandLine(command_line); | 78 WebRtcContentBrowserTestBase::SetUpCommandLine(command_line); |
| 85 command_line->AppendSwitchASCII(switches::kForceWebRtcIPHandlingPolicy, | 79 command_line->AppendSwitchASCII(switches::kForceWebRtcIPHandlingPolicy, |
| 86 kWebRTCIPHandlingDefault); | 80 kWebRTCIPHandlingDefault); |
| 87 } | 81 } |
| 88 }; | 82 }; |
| 89 | 83 |
| 90 // Test that when device permission is denied, only non-default interfaces are | 84 // Test that when device permission is denied, only non-default interfaces are |
| 91 // gathered even if the policy is "default". | 85 // gathered even if the policy is "default". |
| 92 IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcBrowserIPPermissionDeniedTest, | 86 IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcIPPermissionDeniedTest, |
| 93 GatherLocalCandidates) { | 87 GatherLocalCandidates) { |
| 94 MakeTypicalCall("callAndExpectNonLoopbackCandidates();", kPeerConnectionHtml); | 88 MakeTypicalCall("callAndExpectNonLoopbackCandidates();", kPeerConnectionHtml); |
| 95 } | 89 } |
| 96 | 90 |
| 97 // This class tests the scenario when ip handling policy is set to "public and | 91 // This class tests the scenario when ip handling policy is set to "public and |
| 98 // private interfaces", the non-default private candidate is not gathered. | 92 // private interfaces", the non-default private candidate is not gathered. |
| 99 class MAYBE_WebRtcBrowserIPPolicyPublicAndPrivateInterfacesTest | 93 class MAYBE_WebRtcIPPolicyPublicAndPrivateInterfacesTest |
| 100 : public WebRtcContentBrowserTest { | 94 : public WebRtcContentBrowserTestBase { |
| 101 public: | 95 public: |
| 102 MAYBE_WebRtcBrowserIPPolicyPublicAndPrivateInterfacesTest() {} | 96 MAYBE_WebRtcIPPolicyPublicAndPrivateInterfacesTest() {} |
| 103 ~MAYBE_WebRtcBrowserIPPolicyPublicAndPrivateInterfacesTest() override {} | 97 ~MAYBE_WebRtcIPPolicyPublicAndPrivateInterfacesTest() override {} |
| 104 | 98 |
| 105 void SetUpCommandLine(base::CommandLine* command_line) override { | 99 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 106 WebRtcContentBrowserTest::SetUpCommandLine(command_line); | 100 WebRtcContentBrowserTestBase::SetUpCommandLine(command_line); |
| 107 AppendUseFakeUIForMediaStreamFlag(); | 101 AppendUseFakeUIForMediaStreamFlag(); |
| 108 command_line->AppendSwitchASCII( | 102 command_line->AppendSwitchASCII( |
| 109 switches::kForceWebRtcIPHandlingPolicy, | 103 switches::kForceWebRtcIPHandlingPolicy, |
| 110 kWebRTCIPHandlingDefaultPublicAndPrivateInterfaces); | 104 kWebRTCIPHandlingDefaultPublicAndPrivateInterfaces); |
| 111 } | 105 } |
| 112 }; | 106 }; |
| 113 | 107 |
| 114 IN_PROC_BROWSER_TEST_F( | 108 IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcIPPolicyPublicAndPrivateInterfacesTest, |
| 115 MAYBE_WebRtcBrowserIPPolicyPublicAndPrivateInterfacesTest, | 109 GatherLocalCandidates) { |
| 116 GatherLocalCandidates) { | |
| 117 MakeTypicalCall("callAndExpectNonLoopbackCandidates();", kPeerConnectionHtml); | 110 MakeTypicalCall("callAndExpectNonLoopbackCandidates();", kPeerConnectionHtml); |
| 118 } | 111 } |
| 119 | 112 |
| 120 // This class tests the scenario when ip handling policy is set to "public | 113 // This class tests the scenario when ip handling policy is set to "public |
| 121 // interface only", there is no candidate gathered as there is no stun server | 114 // interface only", there is no candidate gathered as there is no stun server |
| 122 // specified. | 115 // specified. |
| 123 class MAYBE_WebRtcBrowserIPPolicyPublicInterfaceOnlyTest | 116 class MAYBE_WebRtcIPPolicyPublicInterfaceOnlyTest |
| 124 : public WebRtcContentBrowserTest { | 117 : public WebRtcContentBrowserTestBase { |
| 125 public: | 118 public: |
| 126 MAYBE_WebRtcBrowserIPPolicyPublicInterfaceOnlyTest() {} | 119 MAYBE_WebRtcIPPolicyPublicInterfaceOnlyTest() {} |
| 127 ~MAYBE_WebRtcBrowserIPPolicyPublicInterfaceOnlyTest() override {} | 120 ~MAYBE_WebRtcIPPolicyPublicInterfaceOnlyTest() override {} |
| 128 | 121 |
| 129 void SetUpCommandLine(base::CommandLine* command_line) override { | 122 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 130 WebRtcContentBrowserTest::SetUpCommandLine(command_line); | 123 WebRtcContentBrowserTestBase::SetUpCommandLine(command_line); |
| 131 AppendUseFakeUIForMediaStreamFlag(); | 124 AppendUseFakeUIForMediaStreamFlag(); |
| 132 command_line->AppendSwitchASCII( | 125 command_line->AppendSwitchASCII( |
| 133 switches::kForceWebRtcIPHandlingPolicy, | 126 switches::kForceWebRtcIPHandlingPolicy, |
| 134 kWebRTCIPHandlingDefaultPublicInterfaceOnly); | 127 kWebRTCIPHandlingDefaultPublicInterfaceOnly); |
| 135 } | 128 } |
| 136 }; | 129 }; |
| 137 | 130 |
| 138 IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcBrowserIPPolicyPublicInterfaceOnlyTest, | 131 IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcIPPolicyPublicInterfaceOnlyTest, |
| 139 GatherLocalCandidates) { | 132 GatherLocalCandidates) { |
| 140 MakeTypicalCall("callWithNoCandidateExpected();", kPeerConnectionHtml); | 133 MakeTypicalCall("callWithNoCandidateExpected();", kPeerConnectionHtml); |
| 141 } | 134 } |
| 142 | 135 |
| 143 // This class tests the scenario when ip handling policy is set to "disable | 136 // This class tests the scenario when ip handling policy is set to "disable |
| 144 // non-proxied udp", there is no candidate gathered as there is no stun server | 137 // non-proxied udp", there is no candidate gathered as there is no stun server |
| 145 // specified. | 138 // specified. |
| 146 class MAYBE_WebRtcBrowserIPPolicyDisableUdpTest | 139 class MAYBE_WebRtcIPPolicyDisableUdpTest : public WebRtcContentBrowserTestBase { |
| 147 : public WebRtcContentBrowserTest { | |
| 148 public: | 140 public: |
| 149 MAYBE_WebRtcBrowserIPPolicyDisableUdpTest() {} | 141 MAYBE_WebRtcIPPolicyDisableUdpTest() {} |
| 150 ~MAYBE_WebRtcBrowserIPPolicyDisableUdpTest() override {} | 142 ~MAYBE_WebRtcIPPolicyDisableUdpTest() override {} |
| 151 | 143 |
| 152 void SetUpCommandLine(base::CommandLine* command_line) override { | 144 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 153 WebRtcContentBrowserTest::SetUpCommandLine(command_line); | 145 WebRtcContentBrowserTestBase::SetUpCommandLine(command_line); |
| 154 AppendUseFakeUIForMediaStreamFlag(); | 146 AppendUseFakeUIForMediaStreamFlag(); |
| 155 command_line->AppendSwitchASCII(switches::kForceWebRtcIPHandlingPolicy, | 147 command_line->AppendSwitchASCII(switches::kForceWebRtcIPHandlingPolicy, |
| 156 kWebRTCIPHandlingDisableNonProxiedUdp); | 148 kWebRTCIPHandlingDisableNonProxiedUdp); |
| 157 } | 149 } |
| 158 }; | 150 }; |
| 159 | 151 |
| 160 IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcBrowserIPPolicyDisableUdpTest, | 152 IN_PROC_BROWSER_TEST_F(MAYBE_WebRtcIPPolicyDisableUdpTest, |
| 161 GatherLocalCandidates) { | 153 GatherLocalCandidates) { |
| 162 MakeTypicalCall("callWithNoCandidateExpected();", kPeerConnectionHtml); | 154 MakeTypicalCall("callWithNoCandidateExpected();", kPeerConnectionHtml); |
| 163 } | 155 } |
| 164 | 156 |
| 165 } // namespace content | 157 } // namespace content |
| OLD | NEW |