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

Side by Side Diff: net/url_request/url_request_quic_unittest.cc

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

Powered by Google App Engine
This is Rietveld 408576698