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

Side by Side Diff: net/http/http_network_transaction_unittest.cc

Issue 1109473003: Get rid of TestNetLog::CapturedEntry[List] typedefs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/http/http_network_transaction.h" 5 #include "net/http/http_network_transaction.h"
6 6
7 #include <math.h> // ceil 7 #include <math.h> // ceil
8 #include <stdarg.h> 8 #include <stdarg.h>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #include "net/http/http_basic_state.h" 43 #include "net/http/http_basic_state.h"
44 #include "net/http/http_basic_stream.h" 44 #include "net/http/http_basic_stream.h"
45 #include "net/http/http_network_session.h" 45 #include "net/http/http_network_session.h"
46 #include "net/http/http_network_session_peer.h" 46 #include "net/http/http_network_session_peer.h"
47 #include "net/http/http_request_headers.h" 47 #include "net/http/http_request_headers.h"
48 #include "net/http/http_server_properties_impl.h" 48 #include "net/http/http_server_properties_impl.h"
49 #include "net/http/http_stream.h" 49 #include "net/http/http_stream.h"
50 #include "net/http/http_stream_factory.h" 50 #include "net/http/http_stream_factory.h"
51 #include "net/http/http_stream_parser.h" 51 #include "net/http/http_stream_parser.h"
52 #include "net/http/http_transaction_test_util.h" 52 #include "net/http/http_transaction_test_util.h"
53 #include "net/log/captured_net_log_entry.h"
53 #include "net/log/net_log.h" 54 #include "net/log/net_log.h"
54 #include "net/log/net_log_unittest.h" 55 #include "net/log/net_log_unittest.h"
55 #include "net/log/test_net_log.h" 56 #include "net/log/test_net_log.h"
56 #include "net/proxy/mock_proxy_resolver.h" 57 #include "net/proxy/mock_proxy_resolver.h"
57 #include "net/proxy/proxy_config_service_fixed.h" 58 #include "net/proxy/proxy_config_service_fixed.h"
58 #include "net/proxy/proxy_info.h" 59 #include "net/proxy/proxy_info.h"
59 #include "net/proxy/proxy_resolver.h" 60 #include "net/proxy/proxy_resolver.h"
60 #include "net/proxy/proxy_service.h" 61 #include "net/proxy/proxy_service.h"
61 #include "net/socket/client_socket_factory.h" 62 #include "net/socket/client_socket_factory.h"
62 #include "net/socket/client_socket_pool_manager.h" 63 #include "net/socket/client_socket_pool_manager.h"
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 return out; 348 return out;
348 } 349 }
349 out.status_line = response->headers->GetStatusLine(); 350 out.status_line = response->headers->GetStatusLine();
350 351
351 EXPECT_EQ("127.0.0.1", response->socket_address.host()); 352 EXPECT_EQ("127.0.0.1", response->socket_address.host());
352 EXPECT_EQ(80, response->socket_address.port()); 353 EXPECT_EQ(80, response->socket_address.port());
353 354
354 rv = ReadTransaction(trans.get(), &out.response_data); 355 rv = ReadTransaction(trans.get(), &out.response_data);
355 EXPECT_EQ(OK, rv); 356 EXPECT_EQ(OK, rv);
356 357
357 TestNetLog::CapturedEntryList entries; 358 CapturedNetLogEntry::List entries;
358 log.GetEntries(&entries); 359 log.GetEntries(&entries);
359 size_t pos = ExpectLogContainsSomewhere( 360 size_t pos = ExpectLogContainsSomewhere(
360 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST_HEADERS, 361 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST_HEADERS,
361 NetLog::PHASE_NONE); 362 NetLog::PHASE_NONE);
362 ExpectLogContainsSomewhere( 363 ExpectLogContainsSomewhere(
363 entries, pos, 364 entries, pos,
364 NetLog::TYPE_HTTP_TRANSACTION_READ_RESPONSE_HEADERS, 365 NetLog::TYPE_HTTP_TRANSACTION_READ_RESPONSE_HEADERS,
365 NetLog::PHASE_NONE); 366 NetLog::PHASE_NONE);
366 367
367 std::string line; 368 std::string line;
(...skipping 2073 matching lines...) Expand 10 before | Expand all | Expand 10 after
2441 TestCompletionCallback callback1; 2442 TestCompletionCallback callback1;
2442 2443
2443 scoped_ptr<HttpTransaction> trans( 2444 scoped_ptr<HttpTransaction> trans(
2444 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 2445 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
2445 2446
2446 int rv = trans->Start(&request, callback1.callback(), log.bound()); 2447 int rv = trans->Start(&request, callback1.callback(), log.bound());
2447 EXPECT_EQ(ERR_IO_PENDING, rv); 2448 EXPECT_EQ(ERR_IO_PENDING, rv);
2448 2449
2449 rv = callback1.WaitForResult(); 2450 rv = callback1.WaitForResult();
2450 EXPECT_EQ(OK, rv); 2451 EXPECT_EQ(OK, rv);
2451 TestNetLog::CapturedEntryList entries; 2452 CapturedNetLogEntry::List entries;
2452 log.GetEntries(&entries); 2453 log.GetEntries(&entries);
2453 size_t pos = ExpectLogContainsSomewhere( 2454 size_t pos = ExpectLogContainsSomewhere(
2454 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, 2455 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS,
2455 NetLog::PHASE_NONE); 2456 NetLog::PHASE_NONE);
2456 ExpectLogContainsSomewhere( 2457 ExpectLogContainsSomewhere(
2457 entries, pos, NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, 2458 entries, pos, NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS,
2458 NetLog::PHASE_NONE); 2459 NetLog::PHASE_NONE);
2459 2460
2460 const HttpResponseInfo* response = trans->GetResponseInfo(); 2461 const HttpResponseInfo* response = trans->GetResponseInfo();
2461 ASSERT_TRUE(response != NULL); 2462 ASSERT_TRUE(response != NULL);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
2560 TestCompletionCallback callback1; 2561 TestCompletionCallback callback1;
2561 2562
2562 scoped_ptr<HttpTransaction> trans( 2563 scoped_ptr<HttpTransaction> trans(
2563 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 2564 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
2564 2565
2565 int rv = trans->Start(&request, callback1.callback(), log.bound()); 2566 int rv = trans->Start(&request, callback1.callback(), log.bound());
2566 EXPECT_EQ(ERR_IO_PENDING, rv); 2567 EXPECT_EQ(ERR_IO_PENDING, rv);
2567 2568
2568 rv = callback1.WaitForResult(); 2569 rv = callback1.WaitForResult();
2569 EXPECT_EQ(OK, rv); 2570 EXPECT_EQ(OK, rv);
2570 TestNetLog::CapturedEntryList entries; 2571 CapturedNetLogEntry::List entries;
2571 log.GetEntries(&entries); 2572 log.GetEntries(&entries);
2572 size_t pos = ExpectLogContainsSomewhere( 2573 size_t pos = ExpectLogContainsSomewhere(
2573 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, 2574 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS,
2574 NetLog::PHASE_NONE); 2575 NetLog::PHASE_NONE);
2575 ExpectLogContainsSomewhere( 2576 ExpectLogContainsSomewhere(
2576 entries, pos, 2577 entries, pos,
2577 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, 2578 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS,
2578 NetLog::PHASE_NONE); 2579 NetLog::PHASE_NONE);
2579 2580
2580 const HttpResponseInfo* response = trans->GetResponseInfo(); 2581 const HttpResponseInfo* response = trans->GetResponseInfo();
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
2676 data_writes1, arraysize(data_writes1)); 2677 data_writes1, arraysize(data_writes1));
2677 session_deps_.socket_factory->AddSocketDataProvider(&data1); 2678 session_deps_.socket_factory->AddSocketDataProvider(&data1);
2678 2679
2679 TestCompletionCallback callback1; 2680 TestCompletionCallback callback1;
2680 2681
2681 int rv = trans->Start(&request, callback1.callback(), log.bound()); 2682 int rv = trans->Start(&request, callback1.callback(), log.bound());
2682 EXPECT_EQ(ERR_IO_PENDING, rv); 2683 EXPECT_EQ(ERR_IO_PENDING, rv);
2683 2684
2684 rv = callback1.WaitForResult(); 2685 rv = callback1.WaitForResult();
2685 EXPECT_EQ(OK, rv); 2686 EXPECT_EQ(OK, rv);
2686 TestNetLog::CapturedEntryList entries; 2687 CapturedNetLogEntry::List entries;
2687 log.GetEntries(&entries); 2688 log.GetEntries(&entries);
2688 size_t pos = ExpectLogContainsSomewhere( 2689 size_t pos = ExpectLogContainsSomewhere(
2689 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, 2690 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS,
2690 NetLog::PHASE_NONE); 2691 NetLog::PHASE_NONE);
2691 ExpectLogContainsSomewhere( 2692 ExpectLogContainsSomewhere(
2692 entries, pos, NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, 2693 entries, pos, NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS,
2693 NetLog::PHASE_NONE); 2694 NetLog::PHASE_NONE);
2694 2695
2695 const HttpResponseInfo* response = trans->GetResponseInfo(); 2696 const HttpResponseInfo* response = trans->GetResponseInfo();
2696 ASSERT_TRUE(response); 2697 ASSERT_TRUE(response);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
2781 data_writes1, arraysize(data_writes1)); 2782 data_writes1, arraysize(data_writes1));
2782 session_deps_.socket_factory->AddSocketDataProvider(&data1); 2783 session_deps_.socket_factory->AddSocketDataProvider(&data1);
2783 2784
2784 TestCompletionCallback callback1; 2785 TestCompletionCallback callback1;
2785 2786
2786 int rv = trans->Start(&request, callback1.callback(), log.bound()); 2787 int rv = trans->Start(&request, callback1.callback(), log.bound());
2787 EXPECT_EQ(ERR_IO_PENDING, rv); 2788 EXPECT_EQ(ERR_IO_PENDING, rv);
2788 2789
2789 rv = callback1.WaitForResult(); 2790 rv = callback1.WaitForResult();
2790 EXPECT_EQ(OK, rv); 2791 EXPECT_EQ(OK, rv);
2791 TestNetLog::CapturedEntryList entries; 2792 CapturedNetLogEntry::List entries;
2792 log.GetEntries(&entries); 2793 log.GetEntries(&entries);
2793 size_t pos = ExpectLogContainsSomewhere( 2794 size_t pos = ExpectLogContainsSomewhere(
2794 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, 2795 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS,
2795 NetLog::PHASE_NONE); 2796 NetLog::PHASE_NONE);
2796 ExpectLogContainsSomewhere( 2797 ExpectLogContainsSomewhere(
2797 entries, pos, 2798 entries, pos,
2798 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, 2799 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS,
2799 NetLog::PHASE_NONE); 2800 NetLog::PHASE_NONE);
2800 2801
2801 const HttpResponseInfo* response = trans->GetResponseInfo(); 2802 const HttpResponseInfo* response = trans->GetResponseInfo();
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
3044 TestCompletionCallback callback1; 3045 TestCompletionCallback callback1;
3045 3046
3046 scoped_ptr<HttpTransaction> trans( 3047 scoped_ptr<HttpTransaction> trans(
3047 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 3048 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
3048 3049
3049 int rv = trans->Start(&request, callback1.callback(), log.bound()); 3050 int rv = trans->Start(&request, callback1.callback(), log.bound());
3050 EXPECT_EQ(ERR_IO_PENDING, rv); 3051 EXPECT_EQ(ERR_IO_PENDING, rv);
3051 3052
3052 rv = callback1.WaitForResult(); 3053 rv = callback1.WaitForResult();
3053 EXPECT_EQ(ERR_UNEXPECTED_PROXY_AUTH, rv); 3054 EXPECT_EQ(ERR_UNEXPECTED_PROXY_AUTH, rv);
3054 TestNetLog::CapturedEntryList entries; 3055 CapturedNetLogEntry::List entries;
3055 log.GetEntries(&entries); 3056 log.GetEntries(&entries);
3056 size_t pos = ExpectLogContainsSomewhere( 3057 size_t pos = ExpectLogContainsSomewhere(
3057 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, 3058 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS,
3058 NetLog::PHASE_NONE); 3059 NetLog::PHASE_NONE);
3059 ExpectLogContainsSomewhere( 3060 ExpectLogContainsSomewhere(
3060 entries, pos, 3061 entries, pos,
3061 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, 3062 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS,
3062 NetLog::PHASE_NONE); 3063 NetLog::PHASE_NONE);
3063 } 3064 }
3064 3065
(...skipping 3769 matching lines...) Expand 10 before | Expand all | Expand 10 after
6834 TestCompletionCallback callback1; 6835 TestCompletionCallback callback1;
6835 6836
6836 scoped_ptr<HttpTransaction> trans( 6837 scoped_ptr<HttpTransaction> trans(
6837 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 6838 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
6838 6839
6839 int rv = trans->Start(&request, callback1.callback(), log.bound()); 6840 int rv = trans->Start(&request, callback1.callback(), log.bound());
6840 EXPECT_EQ(ERR_IO_PENDING, rv); 6841 EXPECT_EQ(ERR_IO_PENDING, rv);
6841 6842
6842 rv = callback1.WaitForResult(); 6843 rv = callback1.WaitForResult();
6843 EXPECT_EQ(OK, rv); 6844 EXPECT_EQ(OK, rv);
6844 TestNetLog::CapturedEntryList entries; 6845 CapturedNetLogEntry::List entries;
6845 log.GetEntries(&entries); 6846 log.GetEntries(&entries);
6846 size_t pos = ExpectLogContainsSomewhere( 6847 size_t pos = ExpectLogContainsSomewhere(
6847 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, 6848 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS,
6848 NetLog::PHASE_NONE); 6849 NetLog::PHASE_NONE);
6849 ExpectLogContainsSomewhere( 6850 ExpectLogContainsSomewhere(
6850 entries, pos, 6851 entries, pos,
6851 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, 6852 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS,
6852 NetLog::PHASE_NONE); 6853 NetLog::PHASE_NONE);
6853 6854
6854 const HttpResponseInfo* response = trans->GetResponseInfo(); 6855 const HttpResponseInfo* response = trans->GetResponseInfo();
(...skipping 4043 matching lines...) Expand 10 before | Expand all | Expand 10 after
10898 TestCompletionCallback callback1; 10899 TestCompletionCallback callback1;
10899 10900
10900 scoped_ptr<HttpTransaction> trans( 10901 scoped_ptr<HttpTransaction> trans(
10901 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 10902 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
10902 10903
10903 int rv = trans->Start(&request, callback1.callback(), log.bound()); 10904 int rv = trans->Start(&request, callback1.callback(), log.bound());
10904 EXPECT_EQ(ERR_IO_PENDING, rv); 10905 EXPECT_EQ(ERR_IO_PENDING, rv);
10905 10906
10906 rv = callback1.WaitForResult(); 10907 rv = callback1.WaitForResult();
10907 EXPECT_EQ(OK, rv); 10908 EXPECT_EQ(OK, rv);
10908 TestNetLog::CapturedEntryList entries; 10909 CapturedNetLogEntry::List entries;
10909 log.GetEntries(&entries); 10910 log.GetEntries(&entries);
10910 size_t pos = ExpectLogContainsSomewhere( 10911 size_t pos = ExpectLogContainsSomewhere(
10911 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, 10912 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS,
10912 NetLog::PHASE_NONE); 10913 NetLog::PHASE_NONE);
10913 ExpectLogContainsSomewhere( 10914 ExpectLogContainsSomewhere(
10914 entries, pos, 10915 entries, pos,
10915 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, 10916 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS,
10916 NetLog::PHASE_NONE); 10917 NetLog::PHASE_NONE);
10917 10918
10918 const HttpResponseInfo* response = trans->GetResponseInfo(); 10919 const HttpResponseInfo* response = trans->GetResponseInfo();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
10972 TestCompletionCallback callback1; 10973 TestCompletionCallback callback1;
10973 10974
10974 scoped_ptr<HttpTransaction> trans( 10975 scoped_ptr<HttpTransaction> trans(
10975 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 10976 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
10976 10977
10977 int rv = trans->Start(&request, callback1.callback(), log.bound()); 10978 int rv = trans->Start(&request, callback1.callback(), log.bound());
10978 EXPECT_EQ(ERR_IO_PENDING, rv); 10979 EXPECT_EQ(ERR_IO_PENDING, rv);
10979 10980
10980 rv = callback1.WaitForResult(); 10981 rv = callback1.WaitForResult();
10981 EXPECT_EQ(ERR_EMPTY_RESPONSE, rv); 10982 EXPECT_EQ(ERR_EMPTY_RESPONSE, rv);
10982 TestNetLog::CapturedEntryList entries; 10983 CapturedNetLogEntry::List entries;
10983 log.GetEntries(&entries); 10984 log.GetEntries(&entries);
10984 size_t pos = ExpectLogContainsSomewhere( 10985 size_t pos = ExpectLogContainsSomewhere(
10985 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS, 10986 entries, 0, NetLog::TYPE_HTTP_TRANSACTION_SEND_TUNNEL_HEADERS,
10986 NetLog::PHASE_NONE); 10987 NetLog::PHASE_NONE);
10987 ExpectLogContainsSomewhere( 10988 ExpectLogContainsSomewhere(
10988 entries, pos, 10989 entries, pos,
10989 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS, 10990 NetLog::TYPE_HTTP_TRANSACTION_READ_TUNNEL_RESPONSE_HEADERS,
10990 NetLog::PHASE_NONE); 10991 NetLog::PHASE_NONE);
10991 } 10992 }
10992 10993
(...skipping 2886 matching lines...) Expand 10 before | Expand all | Expand 10 after
13879 ASSERT_TRUE(response); 13880 ASSERT_TRUE(response);
13880 ASSERT_TRUE(response->headers.get()); 13881 ASSERT_TRUE(response->headers.get());
13881 13882
13882 EXPECT_EQ(101, response->headers->response_code()); 13883 EXPECT_EQ(101, response->headers->response_code());
13883 13884
13884 trans.reset(); 13885 trans.reset();
13885 session->CloseAllConnections(); 13886 session->CloseAllConnections();
13886 } 13887 }
13887 13888
13888 } // namespace net 13889 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698