Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(809)

Unified Diff: third_party/WebKit/Source/web/tests/ActiveConnectionThrottlingTest.cpp

Issue 2692013002: [scheduler] Plumb information about active webrtc connections to scheduler (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/modules/peerconnection/RTCPeerConnection.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « third_party/WebKit/Source/modules/peerconnection/RTCPeerConnection.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698