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