| Index: third_party/WebKit/Source/web/tests/ActiveConnectionThrottlingTest.cpp
|
| diff --git a/third_party/WebKit/Source/web/tests/ActiveConnectionThrottlingTest.cpp b/third_party/WebKit/Source/web/tests/ActiveConnectionThrottlingTest.cpp
|
| index 96488cd940e44f2ceb373d9120dada9512455a3e..78c35bb5e2315a9e3767b031bd058b590e9f663c 100644
|
| --- a/third_party/WebKit/Source/web/tests/ActiveConnectionThrottlingTest.cpp
|
| +++ b/third_party/WebKit/Source/web/tests/ActiveConnectionThrottlingTest.cpp
|
| @@ -2,6 +2,10 @@
|
| // Use of this source code if governed by a BSD-style license that can be
|
| // found in LICENSE file.
|
|
|
| +#include "platform/testing/TestingPlatformSupport.h"
|
| +#include "public/platform/WebRTCError.h"
|
| +#include "public/platform/WebRTCPeerConnectionHandler.h"
|
| +#include "public/platform/WebRTCSessionDescription.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| #include "third_party/WebKit/public/platform/WebViewScheduler.h"
|
| #include "web/WebViewImpl.h"
|
| @@ -29,4 +33,82 @@ TEST_F(ActiveConnectionThrottlingTest, WebSocketStopsThrottling) {
|
| EXPECT_TRUE(webView().scheduler()->hasActiveConnectionForTest());
|
| }
|
|
|
| +namespace {
|
| +
|
| +class MockWebRTCPeerConnectionHandler : public WebRTCPeerConnectionHandler {
|
| + public:
|
| + MockWebRTCPeerConnectionHandler() {}
|
| + ~MockWebRTCPeerConnectionHandler() override {}
|
| +
|
| + bool initialize(const WebRTCConfiguration&,
|
| + const WebMediaConstraints&) override {
|
| + return true;
|
| + }
|
| +
|
| + void createOffer(const WebRTCSessionDescriptionRequest&,
|
| + const WebMediaConstraints&) override {}
|
| + void createOffer(const WebRTCSessionDescriptionRequest&,
|
| + const WebRTCOfferOptions&) override {}
|
| + void createAnswer(const WebRTCSessionDescriptionRequest&,
|
| + const WebMediaConstraints&) override {}
|
| + void createAnswer(const WebRTCSessionDescriptionRequest&,
|
| + const WebRTCAnswerOptions&) override {}
|
| + void setLocalDescription(const WebRTCVoidRequest&,
|
| + const WebRTCSessionDescription&) override {}
|
| + void setRemoteDescription(const WebRTCVoidRequest&,
|
| + const WebRTCSessionDescription&) override {}
|
| + WebRTCSessionDescription localDescription() override {
|
| + return WebRTCSessionDescription();
|
| + }
|
| + WebRTCSessionDescription remoteDescription() override {
|
| + return WebRTCSessionDescription();
|
| + }
|
| + WebRTCErrorType setConfiguration(const WebRTCConfiguration&) override {
|
| + return WebRTCErrorType::kNone;
|
| + }
|
| + bool addStream(const WebMediaStream&, const WebMediaConstraints&) override {
|
| + return true;
|
| + }
|
| + void removeStream(const WebMediaStream&) override {}
|
| + void getStats(const WebRTCStatsRequest&) override {}
|
| + void getStats(std::unique_ptr<WebRTCStatsReportCallback>) override {}
|
| + WebRTCDataChannelHandler* createDataChannel(
|
| + const WebString& label,
|
| + const WebRTCDataChannelInit&) override {
|
| + return nullptr;
|
| + }
|
| + WebRTCDTMFSenderHandler* createDTMFSender(
|
| + const WebMediaStreamTrack&) override {
|
| + return nullptr;
|
| + }
|
| + void stop() override {}
|
| +};
|
| +
|
| +class TestingPlatformSupportWithWebRTC : public TestingPlatformSupport {
|
| + public:
|
| + blink::WebRTCPeerConnectionHandler* createRTCPeerConnectionHandler(
|
| + blink::WebRTCPeerConnectionHandlerClient*) override {
|
| + return new MockWebRTCPeerConnectionHandler();
|
| + }
|
| +};
|
| +
|
| +} // namespace
|
| +
|
| +TEST_F(ActiveConnectionThrottlingTest, WebRTCStopsThrottling) {
|
| + ScopedTestingPlatformSupport<TestingPlatformSupportWithWebRTC> platform;
|
| +
|
| + SimRequest mainResource("https://example.com/", "text/html");
|
| +
|
| + loadURL("https://example.com/");
|
| +
|
| + EXPECT_FALSE(webView().scheduler()->hasActiveConnectionForTest());
|
| +
|
| + mainResource.complete(
|
| + "(<script>"
|
| + " var data_channel = new RTCPeerConnection();"
|
| + "</script>)");
|
| +
|
| + EXPECT_TRUE(webView().scheduler()->hasActiveConnectionForTest());
|
| +}
|
| +
|
| } // namespace blink
|
|
|