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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/modules/peerconnection/RTCPeerConnection.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "platform/testing/TestingPlatformSupport.h"
6 #include "public/platform/WebRTCError.h"
7 #include "public/platform/WebRTCPeerConnectionHandler.h"
8 #include "public/platform/WebRTCSessionDescription.h"
5 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
6 #include "third_party/WebKit/public/platform/WebViewScheduler.h" 10 #include "third_party/WebKit/public/platform/WebViewScheduler.h"
7 #include "web/WebViewImpl.h" 11 #include "web/WebViewImpl.h"
8 #include "web/tests/sim/SimRequest.h" 12 #include "web/tests/sim/SimRequest.h"
9 #include "web/tests/sim/SimTest.h" 13 #include "web/tests/sim/SimTest.h"
10 14
11 using testing::_; 15 using testing::_;
12 16
13 namespace blink { 17 namespace blink {
14 18
15 class ActiveConnectionThrottlingTest : public SimTest {}; 19 class ActiveConnectionThrottlingTest : public SimTest {};
16 20
17 TEST_F(ActiveConnectionThrottlingTest, WebSocketStopsThrottling) { 21 TEST_F(ActiveConnectionThrottlingTest, WebSocketStopsThrottling) {
18 SimRequest mainResource("https://example.com/", "text/html"); 22 SimRequest mainResource("https://example.com/", "text/html");
19 23
20 loadURL("https://example.com/"); 24 loadURL("https://example.com/");
21 25
22 EXPECT_FALSE(webView().scheduler()->hasActiveConnectionForTest()); 26 EXPECT_FALSE(webView().scheduler()->hasActiveConnectionForTest());
23 27
24 mainResource.complete( 28 mainResource.complete(
25 "(<script>" 29 "(<script>"
26 " var socket = new WebSocket(\"ws://www.example.com/websocket\");" 30 " var socket = new WebSocket(\"ws://www.example.com/websocket\");"
27 "</script>)"); 31 "</script>)");
28 32
29 EXPECT_TRUE(webView().scheduler()->hasActiveConnectionForTest()); 33 EXPECT_TRUE(webView().scheduler()->hasActiveConnectionForTest());
30 } 34 }
31 35
36 namespace {
37
38 class MockWebRTCPeerConnectionHandler : public WebRTCPeerConnectionHandler {
39 public:
40 MockWebRTCPeerConnectionHandler() {}
41 ~MockWebRTCPeerConnectionHandler() override {}
42
43 bool initialize(const WebRTCConfiguration&,
44 const WebMediaConstraints&) override {
45 return true;
46 }
47
48 void createOffer(const WebRTCSessionDescriptionRequest&,
49 const WebMediaConstraints&) override {}
50 void createOffer(const WebRTCSessionDescriptionRequest&,
51 const WebRTCOfferOptions&) override {}
52 void createAnswer(const WebRTCSessionDescriptionRequest&,
53 const WebMediaConstraints&) override {}
54 void createAnswer(const WebRTCSessionDescriptionRequest&,
55 const WebRTCAnswerOptions&) override {}
56 void setLocalDescription(const WebRTCVoidRequest&,
57 const WebRTCSessionDescription&) override {}
58 void setRemoteDescription(const WebRTCVoidRequest&,
59 const WebRTCSessionDescription&) override {}
60 WebRTCSessionDescription localDescription() override {
61 return WebRTCSessionDescription();
62 }
63 WebRTCSessionDescription remoteDescription() override {
64 return WebRTCSessionDescription();
65 }
66 WebRTCErrorType setConfiguration(const WebRTCConfiguration&) override {
67 return WebRTCErrorType::kNone;
68 }
69 bool addStream(const WebMediaStream&, const WebMediaConstraints&) override {
70 return true;
71 }
72 void removeStream(const WebMediaStream&) override {}
73 void getStats(const WebRTCStatsRequest&) override {}
74 void getStats(std::unique_ptr<WebRTCStatsReportCallback>) override {}
75 WebRTCDataChannelHandler* createDataChannel(
76 const WebString& label,
77 const WebRTCDataChannelInit&) override {
78 return nullptr;
79 }
80 WebRTCDTMFSenderHandler* createDTMFSender(
81 const WebMediaStreamTrack&) override {
82 return nullptr;
83 }
84 void stop() override {}
85 };
86
87 class TestingPlatformSupportWithWebRTC : public TestingPlatformSupport {
88 public:
89 blink::WebRTCPeerConnectionHandler* createRTCPeerConnectionHandler(
90 blink::WebRTCPeerConnectionHandlerClient*) override {
91 return new MockWebRTCPeerConnectionHandler();
92 }
93 };
94
95 } // namespace
96
97 TEST_F(ActiveConnectionThrottlingTest, WebRTCStopsThrottling) {
98 ScopedTestingPlatformSupport<TestingPlatformSupportWithWebRTC> platform;
99
100 SimRequest mainResource("https://example.com/", "text/html");
101
102 loadURL("https://example.com/");
103
104 EXPECT_FALSE(webView().scheduler()->hasActiveConnectionForTest());
105
106 mainResource.complete(
107 "(<script>"
108 " var data_channel = new RTCPeerConnection();"
109 "</script>)");
110
111 EXPECT_TRUE(webView().scheduler()->hasActiveConnectionForTest());
112 }
113
32 } // namespace blink 114 } // namespace blink
OLDNEW
« 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