OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <memory> | 5 #include <memory> |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 | 298 |
299 std::string value; | 299 std::string value; |
300 int net_error; | 300 int net_error; |
301 std::string push_url_1 = | 301 std::string push_url_1 = |
302 base::StringPrintf("https://%s%s", kTestServerHost, "/kitten-1.jpg"); | 302 base::StringPrintf("https://%s%s", kTestServerHost, "/kitten-1.jpg"); |
303 std::string push_url_2 = | 303 std::string push_url_2 = |
304 base::StringPrintf("https://%s%s", kTestServerHost, "/favicon.ico"); | 304 base::StringPrintf("https://%s%s", kTestServerHost, "/favicon.ico"); |
305 | 305 |
306 EXPECT_TRUE(entries[0].GetStringValue("push_url", &value)); | 306 EXPECT_TRUE(entries[0].GetStringValue("push_url", &value)); |
307 EXPECT_EQ(value, push_url_1); | 307 EXPECT_EQ(value, push_url_1); |
308 EXPECT_TRUE(entries[1].GetStringValue("push_url", &value)); | 308 // No net error code for this lookup transaction, the push is found. |
| 309 EXPECT_FALSE(entries[1].GetIntegerValue("net_error", &net_error)); |
| 310 |
| 311 EXPECT_TRUE(entries[2].GetStringValue("push_url", &value)); |
309 EXPECT_EQ(value, push_url_2); | 312 EXPECT_EQ(value, push_url_2); |
310 // Net error code -400 is found for this lookup transaction, the push is not | 313 // Net error code -400 is found for this lookup transaction, the push is not |
311 // found in the cache. | 314 // found in the cache. |
312 EXPECT_TRUE(entries[2].GetIntegerValue("net_error", &net_error)); | 315 EXPECT_TRUE(entries[3].GetIntegerValue("net_error", &net_error)); |
313 EXPECT_EQ(net_error, -400); | 316 EXPECT_EQ(net_error, -400); |
314 // No net error code for this lookup transaction, the push is found. | |
315 EXPECT_FALSE(entries[3].GetIntegerValue("net_error", &net_error)); | |
316 | 317 |
317 // Verify the reset error count received on the server side. | 318 // Verify the reset error count received on the server side. |
318 EXPECT_LE(1u, GetRstErrorCountReceivedByServer(QUIC_STREAM_CANCELLED)); | 319 EXPECT_LE(1u, GetRstErrorCountReceivedByServer(QUIC_STREAM_CANCELLED)); |
319 } | 320 } |
320 | 321 |
321 TEST_F(URLRequestQuicTest, CancelPushIfCached2) { | 322 TEST_F(URLRequestQuicTest, CancelPushIfCached2) { |
322 base::RunLoop run_loop; | 323 base::RunLoop run_loop; |
323 Init(); | 324 Init(); |
324 | 325 |
325 // Send a request to the pushed url: /kitten-1.jpg to pull the resource into | 326 // Send a request to the pushed url: /kitten-1.jpg to pull the resource into |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 | 385 |
385 std::string value; | 386 std::string value; |
386 int net_error; | 387 int net_error; |
387 std::string push_url_1 = | 388 std::string push_url_1 = |
388 base::StringPrintf("https://%s%s", kTestServerHost, "/kitten-1.jpg"); | 389 base::StringPrintf("https://%s%s", kTestServerHost, "/kitten-1.jpg"); |
389 std::string push_url_2 = | 390 std::string push_url_2 = |
390 base::StringPrintf("https://%s%s", kTestServerHost, "/favicon.ico"); | 391 base::StringPrintf("https://%s%s", kTestServerHost, "/favicon.ico"); |
391 | 392 |
392 EXPECT_TRUE(entries[0].GetStringValue("push_url", &value)); | 393 EXPECT_TRUE(entries[0].GetStringValue("push_url", &value)); |
393 EXPECT_EQ(value, push_url_1); | 394 EXPECT_EQ(value, push_url_1); |
| 395 // No net error code for this lookup transaction, the push is found. |
| 396 EXPECT_FALSE(entries[1].GetIntegerValue("net_error", &net_error)); |
394 | 397 |
395 EXPECT_TRUE(entries[1].GetStringValue("push_url", &value)); | 398 EXPECT_TRUE(entries[2].GetStringValue("push_url", &value)); |
396 EXPECT_EQ(value, push_url_2); | 399 EXPECT_EQ(value, push_url_2); |
397 | |
398 // No net error code for this lookup transaction, the push is found. | |
399 EXPECT_FALSE(entries[2].GetIntegerValue("net_error", &net_error)); | |
400 | |
401 // No net error code for this lookup transaction, the push is found. | 400 // No net error code for this lookup transaction, the push is found. |
402 EXPECT_FALSE(entries[3].GetIntegerValue("net_error", &net_error)); | 401 EXPECT_FALSE(entries[3].GetIntegerValue("net_error", &net_error)); |
403 | 402 |
404 // Verify the reset error count received on the server side. | 403 // Verify the reset error count received on the server side. |
405 EXPECT_LE(2u, GetRstErrorCountReceivedByServer(QUIC_STREAM_CANCELLED)); | 404 EXPECT_LE(2u, GetRstErrorCountReceivedByServer(QUIC_STREAM_CANCELLED)); |
406 } | 405 } |
407 | 406 |
408 TEST_F(URLRequestQuicTest, DoNotCancelPushIfNotFoundInCache) { | 407 TEST_F(URLRequestQuicTest, DoNotCancelPushIfNotFoundInCache) { |
409 base::RunLoop run_loop; | 408 base::RunLoop run_loop; |
410 Init(); | 409 Init(); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 ASSERT_TRUE(request2->is_pending()); | 477 ASSERT_TRUE(request2->is_pending()); |
479 run_loop.Run(); | 478 run_loop.Run(); |
480 | 479 |
481 EXPECT_TRUE(request->status().is_success()); | 480 EXPECT_TRUE(request->status().is_success()); |
482 EXPECT_TRUE(request2->status().is_success()); | 481 EXPECT_TRUE(request2->status().is_success()); |
483 EXPECT_EQ(kHelloBodyValue, delegate.data_received()); | 482 EXPECT_EQ(kHelloBodyValue, delegate.data_received()); |
484 EXPECT_EQ(kHelloBodyValue, delegate2.data_received()); | 483 EXPECT_EQ(kHelloBodyValue, delegate2.data_received()); |
485 } | 484 } |
486 | 485 |
487 } // namespace net | 486 } // namespace net |
OLD | NEW |