| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code if governed by a BSD-style license that can be | 2 // Use of this source code if governed by a BSD-style license that can be |
| 3 // found in LICENSE file. | 3 // found in LICENSE file. |
| 4 | 4 |
| 5 #include "core/exported/WebViewBase.h" | 5 #include "core/exported/WebViewBase.h" |
| 6 #include "platform/scheduler/renderer/web_view_scheduler.h" | 6 #include "platform/scheduler/renderer/web_view_scheduler.h" |
| 7 #include "platform/testing/TestingPlatformSupport.h" | 7 #include "platform/testing/TestingPlatformSupport.h" |
| 8 #include "platform/wtf/PtrUtil.h" |
| 8 #include "public/platform/WebRTCError.h" | 9 #include "public/platform/WebRTCError.h" |
| 9 #include "public/platform/WebRTCPeerConnectionHandler.h" | 10 #include "public/platform/WebRTCPeerConnectionHandler.h" |
| 10 #include "public/platform/WebRTCRtpReceiver.h" | 11 #include "public/platform/WebRTCRtpReceiver.h" |
| 11 #include "public/platform/WebRTCSessionDescription.h" | 12 #include "public/platform/WebRTCSessionDescription.h" |
| 12 #include "public/web/WebScriptSource.h" | 13 #include "public/web/WebScriptSource.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "web/WebLocalFrameImpl.h" | 15 #include "web/WebLocalFrameImpl.h" |
| 15 #include "web/tests/sim/SimRequest.h" | 16 #include "web/tests/sim/SimRequest.h" |
| 16 #include "web/tests/sim/SimTest.h" | 17 #include "web/tests/sim/SimTest.h" |
| 17 | 18 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 } | 91 } |
| 91 WebRTCDTMFSenderHandler* CreateDTMFSender( | 92 WebRTCDTMFSenderHandler* CreateDTMFSender( |
| 92 const WebMediaStreamTrack&) override { | 93 const WebMediaStreamTrack&) override { |
| 93 return nullptr; | 94 return nullptr; |
| 94 } | 95 } |
| 95 void Stop() override {} | 96 void Stop() override {} |
| 96 }; | 97 }; |
| 97 | 98 |
| 98 class TestingPlatformSupportWithWebRTC : public TestingPlatformSupport { | 99 class TestingPlatformSupportWithWebRTC : public TestingPlatformSupport { |
| 99 public: | 100 public: |
| 100 blink::WebRTCPeerConnectionHandler* CreateRTCPeerConnectionHandler( | 101 std::unique_ptr<blink::WebRTCPeerConnectionHandler> |
| 102 CreateRTCPeerConnectionHandler( |
| 101 blink::WebRTCPeerConnectionHandlerClient*) override { | 103 blink::WebRTCPeerConnectionHandlerClient*) override { |
| 102 return new MockWebRTCPeerConnectionHandler(); | 104 return WTF::MakeUnique<MockWebRTCPeerConnectionHandler>(); |
| 103 } | 105 } |
| 104 }; | 106 }; |
| 105 | 107 |
| 106 } // namespace | 108 } // namespace |
| 107 | 109 |
| 108 TEST_F(ActiveConnectionThrottlingTest, WebRTCStopsThrottling) { | 110 TEST_F(ActiveConnectionThrottlingTest, WebRTCStopsThrottling) { |
| 109 ScopedTestingPlatformSupport<TestingPlatformSupportWithWebRTC> platform; | 111 ScopedTestingPlatformSupport<TestingPlatformSupportWithWebRTC> platform; |
| 110 | 112 |
| 111 SimRequest main_resource("https://example.com/", "text/html"); | 113 SimRequest main_resource("https://example.com/", "text/html"); |
| 112 | 114 |
| 113 LoadURL("https://example.com/"); | 115 LoadURL("https://example.com/"); |
| 114 | 116 |
| 115 EXPECT_FALSE(WebView().Scheduler()->HasActiveConnectionForTest()); | 117 EXPECT_FALSE(WebView().Scheduler()->HasActiveConnectionForTest()); |
| 116 | 118 |
| 117 main_resource.Complete( | 119 main_resource.Complete( |
| 118 "(<script>" | 120 "(<script>" |
| 119 " var data_channel = new RTCPeerConnection();" | 121 " var data_channel = new RTCPeerConnection();" |
| 120 "</script>)"); | 122 "</script>)"); |
| 121 | 123 |
| 122 EXPECT_TRUE(WebView().Scheduler()->HasActiveConnectionForTest()); | 124 EXPECT_TRUE(WebView().Scheduler()->HasActiveConnectionForTest()); |
| 123 | 125 |
| 124 MainFrame().ExecuteScript(WebString("data_channel.close();")); | 126 MainFrame().ExecuteScript(WebString("data_channel.close();")); |
| 125 | 127 |
| 126 EXPECT_FALSE(WebView().Scheduler()->HasActiveConnectionForTest()); | 128 EXPECT_FALSE(WebView().Scheduler()->HasActiveConnectionForTest()); |
| 127 } | 129 } |
| 128 | 130 |
| 129 } // namespace blink | 131 } // namespace blink |
| OLD | NEW |