OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 #include "net/socket/tcp_client_socket.h" | 37 #include "net/socket/tcp_client_socket.h" |
38 #include "testing/gtest/include/gtest/gtest.h" | 38 #include "testing/gtest/include/gtest/gtest.h" |
39 | 39 |
40 namespace mojo { | 40 namespace mojo { |
41 namespace { | 41 namespace { |
42 | 42 |
43 const int kMaxExpectedResponseLength = 2048; | 43 const int kMaxExpectedResponseLength = 2048; |
44 | 44 |
45 NetAddressPtr GetLocalHostWithAnyPort() { | 45 NetAddressPtr GetLocalHostWithAnyPort() { |
46 NetAddressPtr addr(NetAddress::New()); | 46 NetAddressPtr addr(NetAddress::New()); |
47 addr->family = NET_ADDRESS_FAMILY_IPV4; | 47 addr->family = NetAddressFamily::IPV4; |
48 addr->ipv4 = NetAddressIPv4::New(); | 48 addr->ipv4 = NetAddressIPv4::New(); |
49 addr->ipv4->port = 0; | 49 addr->ipv4->port = 0; |
50 addr->ipv4->addr.resize(4); | 50 addr->ipv4->addr.resize(4); |
51 addr->ipv4->addr[0] = 127; | 51 addr->ipv4->addr[0] = 127; |
52 addr->ipv4->addr[1] = 0; | 52 addr->ipv4->addr[1] = 0; |
53 addr->ipv4->addr[2] = 0; | 53 addr->ipv4->addr[2] = 0; |
54 addr->ipv4->addr[3] = 1; | 54 addr->ipv4->addr[3] = 1; |
55 | 55 |
56 return addr; | 56 return addr; |
57 } | 57 } |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 | 372 |
373 void DidReceiveFlowControl(int64_t quota) override {} | 373 void DidReceiveFlowControl(int64_t quota) override {} |
374 | 374 |
375 void DidFail(const String& message) override {} | 375 void DidFail(const String& message) override {} |
376 | 376 |
377 void DidClose(bool was_clean, uint16_t code, const String& reason) override {} | 377 void DidClose(bool was_clean, uint16_t code, const String& reason) override {} |
378 | 378 |
379 void OnFinishedWritingSendStream(uint32_t num_bytes, const char* buffer) { | 379 void OnFinishedWritingSendStream(uint32_t num_bytes, const char* buffer) { |
380 EXPECT_TRUE(buffer); | 380 EXPECT_TRUE(buffer); |
381 | 381 |
382 web_socket_->Send(true, WebSocket::MESSAGE_TYPE_TEXT, num_bytes); | 382 web_socket_->Send(true, WebSocket::MessageType::TEXT, num_bytes); |
383 } | 383 } |
384 | 384 |
385 void OnFinishedReadingReceiveStream(uint32_t num_bytes, const char* data) { | 385 void OnFinishedReadingReceiveStream(uint32_t num_bytes, const char* data) { |
386 EXPECT_TRUE(data); | 386 EXPECT_TRUE(data); |
387 | 387 |
388 received_messages_.push_back(std::string(data, num_bytes)); | 388 received_messages_.push_back(std::string(data, num_bytes)); |
389 if (run_loop_ && received_messages_.size() >= wait_for_message_count_) { | 389 if (run_loop_ && received_messages_.size() >= wait_for_message_count_) { |
390 wait_for_message_count_ = 0; | 390 wait_for_message_count_ = 0; |
391 run_loop_->Quit(); | 391 run_loop_->Quit(); |
392 } | 392 } |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
691 | 691 |
692 socket_1.Send("How do"); | 692 socket_1.Send("How do"); |
693 socket_1.Send("you do?"); | 693 socket_1.Send("you do?"); |
694 | 694 |
695 socket_0.WaitForMessage(2); | 695 socket_0.WaitForMessage(2); |
696 EXPECT_EQ("How do", socket_0.received_messages()[0]); | 696 EXPECT_EQ("How do", socket_0.received_messages()[0]); |
697 EXPECT_EQ("you do?", socket_0.received_messages()[1]); | 697 EXPECT_EQ("you do?", socket_0.received_messages()[1]); |
698 } | 698 } |
699 | 699 |
700 } // namespace mojo | 700 } // namespace mojo |
OLD | NEW |