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

Side by Side Diff: net/socket/websocket_transport_client_socket_pool_unittest.cc

Issue 1932363003: Remove net::IPAddressNumber. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 | « net/socket/transport_client_socket_pool_unittest.cc ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "net/socket/websocket_transport_client_socket_pool.h" 5 #include "net/socket/websocket_transport_client_socket_pool.h"
6 6
7 #include <queue> 7 #include <queue>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 callback.callback(), &pool, BoundNetLog()); 537 callback.callback(), &pool, BoundNetLog());
538 EXPECT_EQ(ERR_IO_PENDING, rv); 538 EXPECT_EQ(ERR_IO_PENDING, rv);
539 EXPECT_FALSE(handle.is_initialized()); 539 EXPECT_FALSE(handle.is_initialized());
540 EXPECT_FALSE(handle.socket()); 540 EXPECT_FALSE(handle.socket());
541 541
542 EXPECT_EQ(OK, callback.WaitForResult()); 542 EXPECT_EQ(OK, callback.WaitForResult());
543 EXPECT_TRUE(handle.is_initialized()); 543 EXPECT_TRUE(handle.is_initialized());
544 EXPECT_TRUE(handle.socket()); 544 EXPECT_TRUE(handle.socket());
545 IPEndPoint endpoint; 545 IPEndPoint endpoint;
546 handle.socket()->GetLocalAddress(&endpoint); 546 handle.socket()->GetLocalAddress(&endpoint);
547 EXPECT_EQ(kIPv4AddressSize, endpoint.address().size()); 547 EXPECT_TRUE(endpoint.address().IsIPv4());
548 EXPECT_EQ(2, client_socket_factory_.allocation_count()); 548 EXPECT_EQ(2, client_socket_factory_.allocation_count());
549 } 549 }
550 550
551 // Test the case of the IPv6 address being slow, thus falling back to trying to 551 // Test the case of the IPv6 address being slow, thus falling back to trying to
552 // connect to the IPv4 address, but having the connect to the IPv6 address 552 // connect to the IPv4 address, but having the connect to the IPv6 address
553 // finish first. 553 // finish first.
554 TEST_F(WebSocketTransportClientSocketPoolTest, 554 TEST_F(WebSocketTransportClientSocketPoolTest,
555 IPv6FallbackSocketIPv6FinishesFirst) { 555 IPv6FallbackSocketIPv6FinishesFirst) {
556 WebSocketTransportClientSocketPool pool(kMaxSockets, 556 WebSocketTransportClientSocketPool pool(kMaxSockets,
557 kMaxSocketsPerGroup, 557 kMaxSocketsPerGroup,
(...skipping 22 matching lines...) Expand all
580 callback.callback(), &pool, BoundNetLog()); 580 callback.callback(), &pool, BoundNetLog());
581 EXPECT_EQ(ERR_IO_PENDING, rv); 581 EXPECT_EQ(ERR_IO_PENDING, rv);
582 EXPECT_FALSE(handle.is_initialized()); 582 EXPECT_FALSE(handle.is_initialized());
583 EXPECT_FALSE(handle.socket()); 583 EXPECT_FALSE(handle.socket());
584 584
585 EXPECT_EQ(OK, callback.WaitForResult()); 585 EXPECT_EQ(OK, callback.WaitForResult());
586 EXPECT_TRUE(handle.is_initialized()); 586 EXPECT_TRUE(handle.is_initialized());
587 EXPECT_TRUE(handle.socket()); 587 EXPECT_TRUE(handle.socket());
588 IPEndPoint endpoint; 588 IPEndPoint endpoint;
589 handle.socket()->GetLocalAddress(&endpoint); 589 handle.socket()->GetLocalAddress(&endpoint);
590 EXPECT_EQ(kIPv6AddressSize, endpoint.address().size()); 590 EXPECT_TRUE(endpoint.address().IsIPv6());
591 EXPECT_EQ(2, client_socket_factory_.allocation_count()); 591 EXPECT_EQ(2, client_socket_factory_.allocation_count());
592 } 592 }
593 593
594 TEST_F(WebSocketTransportClientSocketPoolTest, 594 TEST_F(WebSocketTransportClientSocketPoolTest,
595 IPv6NoIPv4AddressesToFallbackTo) { 595 IPv6NoIPv4AddressesToFallbackTo) {
596 WebSocketTransportClientSocketPool pool(kMaxSockets, 596 WebSocketTransportClientSocketPool pool(kMaxSockets,
597 kMaxSocketsPerGroup, 597 kMaxSocketsPerGroup,
598 host_resolver_.get(), 598 host_resolver_.get(),
599 &client_socket_factory_, 599 &client_socket_factory_,
600 NULL); 600 NULL);
(...skipping 12 matching lines...) Expand all
613 callback.callback(), &pool, BoundNetLog()); 613 callback.callback(), &pool, BoundNetLog());
614 EXPECT_EQ(ERR_IO_PENDING, rv); 614 EXPECT_EQ(ERR_IO_PENDING, rv);
615 EXPECT_FALSE(handle.is_initialized()); 615 EXPECT_FALSE(handle.is_initialized());
616 EXPECT_FALSE(handle.socket()); 616 EXPECT_FALSE(handle.socket());
617 617
618 EXPECT_EQ(OK, callback.WaitForResult()); 618 EXPECT_EQ(OK, callback.WaitForResult());
619 EXPECT_TRUE(handle.is_initialized()); 619 EXPECT_TRUE(handle.is_initialized());
620 EXPECT_TRUE(handle.socket()); 620 EXPECT_TRUE(handle.socket());
621 IPEndPoint endpoint; 621 IPEndPoint endpoint;
622 handle.socket()->GetLocalAddress(&endpoint); 622 handle.socket()->GetLocalAddress(&endpoint);
623 EXPECT_EQ(kIPv6AddressSize, endpoint.address().size()); 623 EXPECT_TRUE(endpoint.address().IsIPv6());
624 EXPECT_EQ(1, client_socket_factory_.allocation_count()); 624 EXPECT_EQ(1, client_socket_factory_.allocation_count());
625 } 625 }
626 626
627 TEST_F(WebSocketTransportClientSocketPoolTest, IPv4HasNoFallback) { 627 TEST_F(WebSocketTransportClientSocketPoolTest, IPv4HasNoFallback) {
628 WebSocketTransportClientSocketPool pool(kMaxSockets, 628 WebSocketTransportClientSocketPool pool(kMaxSockets,
629 kMaxSocketsPerGroup, 629 kMaxSocketsPerGroup,
630 host_resolver_.get(), 630 host_resolver_.get(),
631 &client_socket_factory_, 631 &client_socket_factory_,
632 NULL); 632 NULL);
633 633
(...skipping 10 matching lines...) Expand all
644 callback.callback(), &pool, BoundNetLog()); 644 callback.callback(), &pool, BoundNetLog());
645 EXPECT_EQ(ERR_IO_PENDING, rv); 645 EXPECT_EQ(ERR_IO_PENDING, rv);
646 EXPECT_FALSE(handle.is_initialized()); 646 EXPECT_FALSE(handle.is_initialized());
647 EXPECT_FALSE(handle.socket()); 647 EXPECT_FALSE(handle.socket());
648 648
649 EXPECT_EQ(OK, callback.WaitForResult()); 649 EXPECT_EQ(OK, callback.WaitForResult());
650 EXPECT_TRUE(handle.is_initialized()); 650 EXPECT_TRUE(handle.is_initialized());
651 EXPECT_TRUE(handle.socket()); 651 EXPECT_TRUE(handle.socket());
652 IPEndPoint endpoint; 652 IPEndPoint endpoint;
653 handle.socket()->GetLocalAddress(&endpoint); 653 handle.socket()->GetLocalAddress(&endpoint);
654 EXPECT_EQ(kIPv4AddressSize, endpoint.address().size()); 654 EXPECT_TRUE(endpoint.address().IsIPv4());
655 EXPECT_EQ(1, client_socket_factory_.allocation_count()); 655 EXPECT_EQ(1, client_socket_factory_.allocation_count());
656 } 656 }
657 657
658 // If all IPv6 addresses fail to connect synchronously, then IPv4 connections 658 // If all IPv6 addresses fail to connect synchronously, then IPv4 connections
659 // proceeed immediately. 659 // proceeed immediately.
660 TEST_F(WebSocketTransportClientSocketPoolTest, IPv6InstantFail) { 660 TEST_F(WebSocketTransportClientSocketPoolTest, IPv6InstantFail) {
661 WebSocketTransportClientSocketPool pool(kMaxSockets, 661 WebSocketTransportClientSocketPool pool(kMaxSockets,
662 kMaxSocketsPerGroup, 662 kMaxSocketsPerGroup,
663 host_resolver_.get(), 663 host_resolver_.get(),
664 &client_socket_factory_, 664 &client_socket_factory_,
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
1094 EXPECT_EQ(OK, request(1)->WaitForResult()); 1094 EXPECT_EQ(OK, request(1)->WaitForResult());
1095 // Third socket should still be waiting for endpoint. 1095 // Third socket should still be waiting for endpoint.
1096 ASSERT_FALSE(request(2)->handle()->is_initialized()); 1096 ASSERT_FALSE(request(2)->handle()->is_initialized());
1097 EXPECT_EQ(LOAD_STATE_WAITING_FOR_AVAILABLE_SOCKET, 1097 EXPECT_EQ(LOAD_STATE_WAITING_FOR_AVAILABLE_SOCKET,
1098 request(2)->handle()->GetLoadState()); 1098 request(2)->handle()->GetLoadState());
1099 } 1099 }
1100 1100
1101 } // namespace 1101 } // namespace
1102 1102
1103 } // namespace net 1103 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/transport_client_socket_pool_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698