| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/quic/test_tools/simulator/quic_endpoint.h" | 5 #include "net/quic/test_tools/simulator/quic_endpoint.h" |
| 6 | 6 |
| 7 #include "net/quic/platform/api/quic_ptr_util.h" | 7 #include "net/quic/platform/api/quic_ptr_util.h" |
| 8 #include "net/quic/platform/api/quic_test.h" | 8 #include "net/quic/platform/api/quic_test.h" |
| 9 #include "net/quic/test_tools/quic_connection_peer.h" | 9 #include "net/quic/test_tools/quic_connection_peer.h" |
| 10 #include "net/quic/test_tools/quic_test_utils.h" | 10 #include "net/quic/test_tools/quic_test_utils.h" |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 EXPECT_EQ(1024u * 1024u, endpoint_a.bytes_transferred()); | 140 EXPECT_EQ(1024u * 1024u, endpoint_a.bytes_transferred()); |
| 141 EXPECT_EQ(1024u * 1024u, endpoint_b.bytes_transferred()); | 141 EXPECT_EQ(1024u * 1024u, endpoint_b.bytes_transferred()); |
| 142 EXPECT_EQ(1024u * 1024u, endpoint_a.bytes_received()); | 142 EXPECT_EQ(1024u * 1024u, endpoint_a.bytes_received()); |
| 143 EXPECT_EQ(1024u * 1024u, endpoint_b.bytes_received()); | 143 EXPECT_EQ(1024u * 1024u, endpoint_b.bytes_received()); |
| 144 EXPECT_FALSE(endpoint_a.wrong_data_received()); | 144 EXPECT_FALSE(endpoint_a.wrong_data_received()); |
| 145 EXPECT_FALSE(endpoint_b.wrong_data_received()); | 145 EXPECT_FALSE(endpoint_b.wrong_data_received()); |
| 146 } | 146 } |
| 147 | 147 |
| 148 // Simulate three hosts trying to send data to a fourth one simultaneously. | 148 // Simulate three hosts trying to send data to a fourth one simultaneously. |
| 149 TEST_F(QuicEndpointTest, Competition) { | 149 TEST_F(QuicEndpointTest, Competition) { |
| 150 simulator_.set_enable_random_delays(true); | |
| 151 | |
| 152 auto endpoint_a = QuicMakeUnique<QuicEndpoint>( | 150 auto endpoint_a = QuicMakeUnique<QuicEndpoint>( |
| 153 &simulator_, "Endpoint A", "Endpoint D (A)", Perspective::IS_CLIENT, 42); | 151 &simulator_, "Endpoint A", "Endpoint D (A)", Perspective::IS_CLIENT, 42); |
| 154 auto endpoint_b = QuicMakeUnique<QuicEndpoint>( | 152 auto endpoint_b = QuicMakeUnique<QuicEndpoint>( |
| 155 &simulator_, "Endpoint B", "Endpoint D (B)", Perspective::IS_CLIENT, 43); | 153 &simulator_, "Endpoint B", "Endpoint D (B)", Perspective::IS_CLIENT, 43); |
| 156 auto endpoint_c = QuicMakeUnique<QuicEndpoint>( | 154 auto endpoint_c = QuicMakeUnique<QuicEndpoint>( |
| 157 &simulator_, "Endpoint C", "Endpoint D (C)", Perspective::IS_CLIENT, 44); | 155 &simulator_, "Endpoint C", "Endpoint D (C)", Perspective::IS_CLIENT, 44); |
| 158 auto endpoint_d_a = QuicMakeUnique<QuicEndpoint>( | 156 auto endpoint_d_a = QuicMakeUnique<QuicEndpoint>( |
| 159 &simulator_, "Endpoint D (A)", "Endpoint A", Perspective::IS_SERVER, | 157 &simulator_, "Endpoint D (A)", "Endpoint A", Perspective::IS_SERVER, |
| 160 GetPeerInMemoryConnectionId(42)); | 158 GetPeerInMemoryConnectionId(42)); |
| 161 auto endpoint_d_b = QuicMakeUnique<QuicEndpoint>( | 159 auto endpoint_d_b = QuicMakeUnique<QuicEndpoint>( |
| (...skipping 26 matching lines...) Expand all Loading... |
| 188 } | 186 } |
| 189 for (QuicEndpoint* endpoint : | 187 for (QuicEndpoint* endpoint : |
| 190 {endpoint_d_a.get(), endpoint_d_b.get(), endpoint_d_c.get()}) { | 188 {endpoint_d_a.get(), endpoint_d_b.get(), endpoint_d_c.get()}) { |
| 191 EXPECT_EQ(2u * 1024u * 1024u, endpoint->bytes_received()); | 189 EXPECT_EQ(2u * 1024u * 1024u, endpoint->bytes_received()); |
| 192 EXPECT_FALSE(endpoint->wrong_data_received()); | 190 EXPECT_FALSE(endpoint->wrong_data_received()); |
| 193 } | 191 } |
| 194 } | 192 } |
| 195 | 193 |
| 196 } // namespace simulator | 194 } // namespace simulator |
| 197 } // namespace net | 195 } // namespace net |
| OLD | NEW |