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

Side by Side Diff: content/browser/websockets/websocket_manager_unittest.cc

Issue 2589663003: mojo:: Rename mojo::GetProxy() to mojo::MakeRequest() (Closed)
Patch Set: Rebase Created 4 years 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 | « content/browser/web_contents/web_contents_impl.cc ('k') | content/child/child_thread_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <algorithm> 5 #include <algorithm>
6 #include <memory> 6 #include <memory>
7 #include <vector> 7 #include <vector>
8 8
9 #include "content/browser/websockets/websocket_manager.h" 9 #include "content/browser/websockets/websocket_manager.h"
10 #include "content/public/test/test_browser_thread_bundle.h" 10 #include "content/public/test/test_browser_thread_bundle.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 class WebSocketManagerTest : public ::testing::Test { 91 class WebSocketManagerTest : public ::testing::Test {
92 public: 92 public:
93 WebSocketManagerTest() 93 WebSocketManagerTest()
94 : thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP) { 94 : thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP) {
95 websocket_manager_.reset(new TestWebSocketManager()); 95 websocket_manager_.reset(new TestWebSocketManager());
96 } 96 }
97 97
98 void AddMultipleChannels(int number_of_channels) { 98 void AddMultipleChannels(int number_of_channels) {
99 for (int i = 0; i < number_of_channels; ++i) { 99 for (int i = 0; i < number_of_channels; ++i) {
100 blink::mojom::WebSocketPtr websocket; 100 blink::mojom::WebSocketPtr websocket;
101 websocket_manager_->DoCreateWebSocket(mojo::GetProxy(&websocket)); 101 websocket_manager_->DoCreateWebSocket(mojo::MakeRequest(&websocket));
102 } 102 }
103 } 103 }
104 104
105 void AddAndCancelMultipleChannels(int number_of_channels) { 105 void AddAndCancelMultipleChannels(int number_of_channels) {
106 for (int i = 0; i < number_of_channels; ++i) { 106 for (int i = 0; i < number_of_channels; ++i) {
107 blink::mojom::WebSocketPtr websocket; 107 blink::mojom::WebSocketPtr websocket;
108 websocket_manager_->DoCreateWebSocket(mojo::GetProxy(&websocket)); 108 websocket_manager_->DoCreateWebSocket(mojo::MakeRequest(&websocket));
109 websocket_manager_->sockets().back()->SimulateConnectionError(); 109 websocket_manager_->sockets().back()->SimulateConnectionError();
110 } 110 }
111 } 111 }
112 112
113 TestWebSocketManager* websocket_manager() { return websocket_manager_.get(); } 113 TestWebSocketManager* websocket_manager() { return websocket_manager_.get(); }
114 114
115 private: 115 private:
116 TestBrowserThreadBundle thread_bundle_; 116 TestBrowserThreadBundle thread_bundle_;
117 std::unique_ptr<TestWebSocketManager> websocket_manager_; 117 std::unique_ptr<TestWebSocketManager> websocket_manager_;
118 }; 118 };
119 119
120 TEST_F(WebSocketManagerTest, Construct) { 120 TEST_F(WebSocketManagerTest, Construct) {
121 // Do nothing. 121 // Do nothing.
122 } 122 }
123 123
124 TEST_F(WebSocketManagerTest, CreateWebSocket) { 124 TEST_F(WebSocketManagerTest, CreateWebSocket) {
125 blink::mojom::WebSocketPtr websocket; 125 blink::mojom::WebSocketPtr websocket;
126 126
127 websocket_manager()->DoCreateWebSocket(mojo::GetProxy(&websocket)); 127 websocket_manager()->DoCreateWebSocket(mojo::MakeRequest(&websocket));
128 128
129 EXPECT_EQ(1U, websocket_manager()->sockets().size()); 129 EXPECT_EQ(1U, websocket_manager()->sockets().size());
130 } 130 }
131 131
132 TEST_F(WebSocketManagerTest, SendFrameButNotConnectedYet) { 132 TEST_F(WebSocketManagerTest, SendFrameButNotConnectedYet) {
133 blink::mojom::WebSocketPtr websocket; 133 blink::mojom::WebSocketPtr websocket;
134 134
135 websocket_manager()->DoCreateWebSocket(mojo::GetProxy(&websocket)); 135 websocket_manager()->DoCreateWebSocket(mojo::MakeRequest(&websocket));
136 136
137 // This should not crash. 137 // This should not crash.
138 mojo::Array<uint8_t> data; 138 mojo::Array<uint8_t> data;
139 websocket->SendFrame( 139 websocket->SendFrame(
140 true, blink::mojom::WebSocketMessageType::TEXT, std::move(data)); 140 true, blink::mojom::WebSocketMessageType::TEXT, std::move(data));
141 } 141 }
142 142
143 TEST_F(WebSocketManagerTest, DelayFor4thPendingConnectionIsZero) { 143 TEST_F(WebSocketManagerTest, DelayFor4thPendingConnectionIsZero) {
144 AddMultipleChannels(4); 144 AddMultipleChannels(4);
145 145
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 239
240 AddMultipleChannels(1); 240 AddMultipleChannels(1);
241 241
242 EXPECT_EQ(1, websocket_manager()->num_pending_connections()); 242 EXPECT_EQ(1, websocket_manager()->num_pending_connections());
243 EXPECT_EQ(255, websocket_manager()->num_failed_connections()); 243 EXPECT_EQ(255, websocket_manager()->num_failed_connections());
244 EXPECT_EQ(0, websocket_manager()->num_succeeded_connections()); 244 EXPECT_EQ(0, websocket_manager()->num_succeeded_connections());
245 } 245 }
246 246
247 } // namespace 247 } // namespace
248 } // namespace content 248 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.cc ('k') | content/child/child_thread_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698