diff options
-rw-r--r-- | net/base/host_resolver_impl_unittest.cc | 44 | ||||
-rw-r--r-- | net/base/load_log_unittest.cc | 44 | ||||
-rw-r--r-- | net/base/load_log_unittest.h | 75 | ||||
-rw-r--r-- | net/flip/flip_network_transaction_unittest.cc | 5 | ||||
-rw-r--r-- | net/http/http_cache_unittest.cc | 64 | ||||
-rw-r--r-- | net/proxy/init_proxy_resolver_unittest.cc | 77 | ||||
-rw-r--r-- | net/proxy/proxy_resolver_v8_unittest.cc | 24 | ||||
-rw-r--r-- | net/proxy/proxy_service_unittest.cc | 27 | ||||
-rw-r--r-- | net/socket/client_socket_pool_base_unittest.cc | 122 | ||||
-rw-r--r-- | net/socket/socks5_client_socket_unittest.cc | 33 | ||||
-rw-r--r-- | net/socket/socks_client_socket_unittest.cc | 42 | ||||
-rw-r--r-- | net/socket/ssl_client_socket_unittest.cc | 36 | ||||
-rw-r--r-- | net/socket/tcp_client_socket_unittest.cc | 12 | ||||
-rw-r--r-- | net/socket_stream/socket_stream_unittest.cc | 11 | ||||
-rw-r--r-- | net/url_request/url_request_unittest.cc | 24 |
15 files changed, 310 insertions, 330 deletions
diff --git a/net/base/host_resolver_impl_unittest.cc b/net/base/host_resolver_impl_unittest.cc index 68bd8a6..c2cd1b5 100644 --- a/net/base/host_resolver_impl_unittest.cc +++ b/net/base/host_resolver_impl_unittest.cc @@ -194,10 +194,8 @@ TEST_F(HostResolverImplTest, SynchronousLookup) { EXPECT_EQ(OK, err); EXPECT_EQ(2u, log->entries().size()); - ExpectLogContains(log, 0, LoadLog::TYPE_HOST_RESOLVER_IMPL, - LoadLog::PHASE_BEGIN); - ExpectLogContains(log, 1, LoadLog::TYPE_HOST_RESOLVER_IMPL, - LoadLog::PHASE_END); + EXPECT_TRUE(LogContainsBeginEvent(*log, 0, LoadLog::TYPE_HOST_RESOLVER_IMPL)); + EXPECT_TRUE(LogContainsEndEvent(*log, 1, LoadLog::TYPE_HOST_RESOLVER_IMPL)); const struct addrinfo* ainfo = adrlist.head(); EXPECT_EQ(static_cast<addrinfo*>(NULL), ainfo->ai_next); @@ -226,8 +224,7 @@ TEST_F(HostResolverImplTest, AsynchronousLookup) { EXPECT_EQ(ERR_IO_PENDING, err); EXPECT_EQ(1u, log->entries().size()); - ExpectLogContains(log, 0, LoadLog::TYPE_HOST_RESOLVER_IMPL, - LoadLog::PHASE_BEGIN); + EXPECT_TRUE(LogContainsBeginEvent(*log, 0, LoadLog::TYPE_HOST_RESOLVER_IMPL)); MessageLoop::current()->Run(); @@ -235,8 +232,7 @@ TEST_F(HostResolverImplTest, AsynchronousLookup) { ASSERT_EQ(OK, callback_result_); EXPECT_EQ(2u, log->entries().size()); - ExpectLogContains(log, 1, LoadLog::TYPE_HOST_RESOLVER_IMPL, - LoadLog::PHASE_END); + EXPECT_TRUE(LogContainsEndEvent(*log, 1, LoadLog::TYPE_HOST_RESOLVER_IMPL)); const struct addrinfo* ainfo = adrlist.head(); EXPECT_EQ(static_cast<addrinfo*>(NULL), ainfo->ai_next); @@ -273,11 +269,10 @@ TEST_F(HostResolverImplTest, CanceledAsynchronousLookup) { resolver_proc->Signal(); EXPECT_EQ(3u, log->entries().size()); - ExpectLogContains(log, 0, LoadLog::TYPE_HOST_RESOLVER_IMPL, - LoadLog::PHASE_BEGIN); - ExpectLogContains(log, 1, LoadLog::TYPE_CANCELLED, LoadLog::PHASE_NONE); - ExpectLogContains(log, 2, LoadLog::TYPE_HOST_RESOLVER_IMPL, - LoadLog::PHASE_END); + EXPECT_TRUE(LogContainsBeginEvent(*log, 0, LoadLog::TYPE_HOST_RESOLVER_IMPL)); + EXPECT_TRUE(LogContainsEvent( + *log, 1, LoadLog::TYPE_CANCELLED, LoadLog::PHASE_NONE)); + EXPECT_TRUE(LogContainsEndEvent(*log, 2, LoadLog::TYPE_HOST_RESOLVER_IMPL)); EXPECT_FALSE(callback_called_); } @@ -827,18 +822,17 @@ TEST_F(HostResolverImplTest, Observers) { EXPECT_EQ(OK, rv); EXPECT_EQ(6u, log->entries().size()); - ExpectLogContains(log, 0, LoadLog::TYPE_HOST_RESOLVER_IMPL, - LoadLog::PHASE_BEGIN); - ExpectLogContains(log, 1, LoadLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONSTART, - LoadLog::PHASE_BEGIN); - ExpectLogContains(log, 2, LoadLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONSTART, - LoadLog::PHASE_END); - ExpectLogContains(log, 3, LoadLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONFINISH, - LoadLog::PHASE_BEGIN); - ExpectLogContains(log, 4, LoadLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONFINISH, - LoadLog::PHASE_END); - ExpectLogContains(log, 5, LoadLog::TYPE_HOST_RESOLVER_IMPL, - LoadLog::PHASE_END); + EXPECT_TRUE(LogContainsBeginEvent(*log, 0, LoadLog::TYPE_HOST_RESOLVER_IMPL)); + EXPECT_TRUE(LogContainsBeginEvent( + *log, 1, LoadLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONSTART)); + EXPECT_TRUE(LogContainsEndEvent( + *log, 2, LoadLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONSTART)); + EXPECT_TRUE(LogContainsBeginEvent( + *log, 3, LoadLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONFINISH)); + EXPECT_TRUE(LogContainsEndEvent( + *log, 4, LoadLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONFINISH)); + EXPECT_TRUE(LogContainsEndEvent( + *log, 5, LoadLog::TYPE_HOST_RESOLVER_IMPL)); EXPECT_EQ(1U, observer.start_log.size()); EXPECT_EQ(1U, observer.finish_log.size()); diff --git a/net/base/load_log_unittest.cc b/net/base/load_log_unittest.cc index d3f5ed5..c55cf9b 100644 --- a/net/base/load_log_unittest.cc +++ b/net/base/load_log_unittest.cc @@ -41,15 +41,16 @@ TEST(LoadLogTest, Basic) { EXPECT_EQ(3u, log->entries().size()); EXPECT_EQ(0u, log->num_entries_truncated()); - ExpectLogContains(log, 0, MakeTime(0), LoadLog::TYPE_HOST_RESOLVER_IMPL, - LoadLog::PHASE_BEGIN); + EXPECT_TRUE(LogContainsEventAtTime( + *log, 0, MakeTime(0), LoadLog::TYPE_HOST_RESOLVER_IMPL, + LoadLog::PHASE_BEGIN)); - ExpectLogContains(log, 1, MakeTime(2), LoadLog::TYPE_CANCELLED, - LoadLog::PHASE_NONE); + EXPECT_TRUE(LogContainsEventAtTime( + *log, 1, MakeTime(2), LoadLog::TYPE_CANCELLED, LoadLog::PHASE_NONE)); - ExpectLogContains(log, 2, MakeTime(11), - LoadLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONSTART, - LoadLog::PHASE_END); + EXPECT_TRUE(LogContainsEventAtTime( + *log, 2, MakeTime(11), LoadLog::TYPE_HOST_RESOLVER_IMPL_OBSERVER_ONSTART, + LoadLog::PHASE_END)); } // Test that the log's size is strictly bounded. @@ -68,9 +69,8 @@ TEST(LoadLogTest, Truncation) { EXPECT_EQ(0u, log->num_entries_truncated()); // Check the last entry. - ExpectLogContains(log, 9, MakeTime(9), - LoadLog::TYPE_CANCELLED, - LoadLog::PHASE_NONE); + EXPECT_TRUE(LogContainsEventAtTime( + *log, 9, MakeTime(9), LoadLog::TYPE_CANCELLED, LoadLog::PHASE_NONE)); // Add three entries while maxed out (will cause truncation) log->Add(LoadLog::Entry(MakeTime(0), @@ -87,9 +87,8 @@ TEST(LoadLogTest, Truncation) { EXPECT_EQ(3u, log->num_entries_truncated()); // Check the last entry -- it should be the final entry we added. - ExpectLogContains(log, 9, MakeTime(2), - LoadLog::TYPE_CANCELLED, - LoadLog::PHASE_NONE); + EXPECT_TRUE(LogContainsEventAtTime( + *log, 9, MakeTime(2), LoadLog::TYPE_CANCELLED, LoadLog::PHASE_NONE)); } TEST(LoadLogTest, Append) { @@ -117,14 +116,17 @@ TEST(LoadLogTest, Append) { EXPECT_EQ(3u, log1->entries().size()); EXPECT_EQ(0u, log1->num_entries_truncated()); - ExpectLogContains(log1, 0, MakeTime(0), LoadLog::TYPE_HOST_RESOLVER_IMPL, - LoadLog::PHASE_BEGIN); + EXPECT_TRUE(LogContainsEventAtTime( + *log1, 0, MakeTime(0), LoadLog::TYPE_HOST_RESOLVER_IMPL, + LoadLog::PHASE_BEGIN)); - ExpectLogContains(log1, 1, MakeTime(3), LoadLog::TYPE_CANCELLED, - LoadLog::PHASE_NONE); + EXPECT_TRUE(LogContainsEventAtTime( + *log1, 1, MakeTime(3), LoadLog::TYPE_CANCELLED, + LoadLog::PHASE_NONE)); - ExpectLogContains(log1, 2, MakeTime(9), LoadLog::TYPE_HOST_RESOLVER_IMPL, - LoadLog::PHASE_END); + EXPECT_TRUE(LogContainsEventAtTime( + *log1, 2, MakeTime(9), LoadLog::TYPE_HOST_RESOLVER_IMPL, + LoadLog::PHASE_END)); } TEST(LoadLogTest, AppendWithTruncation) { @@ -152,8 +154,8 @@ TEST(LoadLogTest, AppendWithTruncation) { EXPECT_EQ(2u, log1->num_entries_truncated()); // Combined log should end with the final entry of log2. - ExpectLogContains(log1, 9, MakeTime(10), LoadLog::TYPE_CANCELLED, - LoadLog::PHASE_NONE); + EXPECT_TRUE(LogContainsEventAtTime( + *log1, 9, MakeTime(10), LoadLog::TYPE_CANCELLED, LoadLog::PHASE_NONE)); } TEST(LoadLogTest, EventTypeToString) { diff --git a/net/base/load_log_unittest.h b/net/base/load_log_unittest.h index ea9a37d..1efbd46b 100644 --- a/net/base/load_log_unittest.h +++ b/net/base/load_log_unittest.h @@ -18,36 +18,11 @@ inline base::TimeTicks MakeTime(int t) { return ticks; } -// Call gtest's EXPECT_* to verify that |log| contains the specified entry -// at index |i|. -inline void ExpectLogContains(const LoadLog* log, - size_t i, - base::TimeTicks expected_time, - LoadLog::EventType expected_event, - LoadLog::EventPhase expected_phase) { - ASSERT_LT(i, log->entries().size()); - const LoadLog::Entry& entry = log->entries()[i]; - EXPECT_EQ(LoadLog::Entry::TYPE_EVENT, entry.type); - EXPECT_TRUE(expected_time == entry.time); - EXPECT_EQ(expected_event, entry.event.type); - EXPECT_EQ(expected_phase, entry.event.phase); -} - -// Same as above, but without an expectation for the timestamp. -inline void ExpectLogContains(const LoadLog* log, - size_t i, - LoadLog::EventType expected_event, - LoadLog::EventPhase expected_phase) { - ASSERT_LT(i, log->entries().size()); - const LoadLog::Entry& entry = log->entries()[i]; - EXPECT_EQ(LoadLog::Entry::TYPE_EVENT, entry.type); - EXPECT_EQ(expected_event, entry.event.type); - EXPECT_EQ(expected_phase, entry.event.phase); -} - -inline ::testing::AssertionResult LogContains( +inline ::testing::AssertionResult LogContainsEventHelper( const LoadLog& log, int i, // Negative indices are reverse indices. + const base::TimeTicks& expected_time, + bool check_time, LoadLog::EventType expected_event, LoadLog::EventPhase expected_phase) { // Negative indices are reverse indices. @@ -69,9 +44,53 @@ inline ::testing::AssertionResult LogContains( << "Actual phase: " << entry.event.phase << ". Expected phase: " << expected_phase << "."; } + if (check_time) { + if (expected_time != entry.time) { + return ::testing::AssertionFailure() + << "Actual time: " << entry.time.ToInternalValue() + << ". Expected time: " << expected_time.ToInternalValue() + << "."; + } + } return ::testing::AssertionSuccess(); } +inline ::testing::AssertionResult LogContainsEventAtTime( + const LoadLog& log, + int i, // Negative indices are reverse indices. + const base::TimeTicks& expected_time, + LoadLog::EventType expected_event, + LoadLog::EventPhase expected_phase) { + return LogContainsEventHelper(log, i, expected_time, true, + expected_event, expected_phase); +} + +// Version without timestamp. +inline ::testing::AssertionResult LogContainsEvent( + const LoadLog& log, + int i, // Negative indices are reverse indices. + LoadLog::EventType expected_event, + LoadLog::EventPhase expected_phase) { + return LogContainsEventHelper(log, i, base::TimeTicks(), false, + expected_event, expected_phase); +} + +// Version for PHASE_BEGIN (and no timestamp). +inline ::testing::AssertionResult LogContainsBeginEvent( + const LoadLog& log, + int i, // Negative indices are reverse indices. + LoadLog::EventType expected_event) { + return LogContainsEvent(log, i, expected_event, LoadLog::PHASE_BEGIN); +} + +// Version for PHASE_END (and no timestamp). +inline ::testing::AssertionResult LogContainsEndEvent( + const LoadLog& log, + int i, // Negative indices are reverse indices. + LoadLog::EventType expected_event) { + return LogContainsEvent(log, i, expected_event, LoadLog::PHASE_END); +} + // Expect that the log contains an event, but don't care about where // as long as the index where it is found is greater than min_index. // Returns the position where the event was found. diff --git a/net/flip/flip_network_transaction_unittest.cc b/net/flip/flip_network_transaction_unittest.cc index 1abcdc3..47c54c2 100644 --- a/net/flip/flip_network_transaction_unittest.cc +++ b/net/flip/flip_network_transaction_unittest.cc @@ -1053,9 +1053,8 @@ TEST_F(FlipNetworkTransactionTest, LoadLog) { EXPECT_LT(0u, log->entries().size()); int pos = 0; // We know the first event at position 0. - net::ExpectLogContains(log, 0, - net::LoadLog::TYPE_FLIP_TRANSACTION_INIT_CONNECTION, - net::LoadLog::PHASE_BEGIN); + EXPECT_TRUE(net::LogContainsBeginEvent( + *log, 0, net::LoadLog::TYPE_FLIP_TRANSACTION_INIT_CONNECTION)); // For the rest of the events, allow additional events in the middle, // but expect these to be logged in order. pos = net::ExpectLogContainsSomewhere(log, 0, diff --git a/net/http/http_cache_unittest.cc b/net/http/http_cache_unittest.cc index 764d1fd..15ac1aa 100644 --- a/net/http/http_cache_unittest.cc +++ b/net/http/http_cache_unittest.cc @@ -905,14 +905,14 @@ TEST(HttpCache, SimpleGETNoDiskCache) { // Check that the LoadLog was filled as expected. // (We attempted to both Open and Create entries, but both failed). EXPECT_EQ(4u, log->entries().size()); - net::ExpectLogContains(log, 0, net::LoadLog::TYPE_HTTP_CACHE_OPEN_ENTRY, - net::LoadLog::PHASE_BEGIN); - net::ExpectLogContains(log, 1, net::LoadLog::TYPE_HTTP_CACHE_OPEN_ENTRY, - net::LoadLog::PHASE_END); - net::ExpectLogContains(log, 2, net::LoadLog::TYPE_HTTP_CACHE_CREATE_ENTRY, - net::LoadLog::PHASE_BEGIN); - net::ExpectLogContains(log, 3, net::LoadLog::TYPE_HTTP_CACHE_CREATE_ENTRY, - net::LoadLog::PHASE_END); + EXPECT_TRUE(net::LogContainsBeginEvent( + *log, 0, net::LoadLog::TYPE_HTTP_CACHE_OPEN_ENTRY)); + EXPECT_TRUE(net::LogContainsEndEvent( + *log, 1, net::LoadLog::TYPE_HTTP_CACHE_OPEN_ENTRY)); + EXPECT_TRUE(net::LogContainsBeginEvent( + *log, 2, net::LoadLog::TYPE_HTTP_CACHE_CREATE_ENTRY)); + EXPECT_TRUE(net::LogContainsEndEvent( + *log, 3, net::LoadLog::TYPE_HTTP_CACHE_CREATE_ENTRY)); EXPECT_EQ(1, cache.network_layer()->transaction_count()); EXPECT_EQ(0, cache.disk_cache()->open_count()); @@ -988,18 +988,18 @@ TEST(HttpCache, SimpleGET_LoadOnlyFromCache_Hit) { // Check that the LoadLog was filled as expected. EXPECT_EQ(6u, log->entries().size()); - net::ExpectLogContains(log, 0, net::LoadLog::TYPE_HTTP_CACHE_OPEN_ENTRY, - net::LoadLog::PHASE_BEGIN); - net::ExpectLogContains(log, 1, net::LoadLog::TYPE_HTTP_CACHE_OPEN_ENTRY, - net::LoadLog::PHASE_END); - net::ExpectLogContains(log, 2, net::LoadLog::TYPE_HTTP_CACHE_CREATE_ENTRY, - net::LoadLog::PHASE_BEGIN); - net::ExpectLogContains(log, 3, net::LoadLog::TYPE_HTTP_CACHE_CREATE_ENTRY, - net::LoadLog::PHASE_END); - net::ExpectLogContains(log, 4, net::LoadLog::TYPE_HTTP_CACHE_WAITING, - net::LoadLog::PHASE_BEGIN); - net::ExpectLogContains(log, 5, net::LoadLog::TYPE_HTTP_CACHE_WAITING, - net::LoadLog::PHASE_END); + EXPECT_TRUE(net::LogContainsBeginEvent( + *log, 0, net::LoadLog::TYPE_HTTP_CACHE_OPEN_ENTRY)); + EXPECT_TRUE(net::LogContainsEndEvent( + *log, 1, net::LoadLog::TYPE_HTTP_CACHE_OPEN_ENTRY)); + EXPECT_TRUE(net::LogContainsBeginEvent( + *log, 2, net::LoadLog::TYPE_HTTP_CACHE_CREATE_ENTRY)); + EXPECT_TRUE(net::LogContainsEndEvent( + *log, 3, net::LoadLog::TYPE_HTTP_CACHE_CREATE_ENTRY)); + EXPECT_TRUE(net::LogContainsBeginEvent( + *log, 4, net::LoadLog::TYPE_HTTP_CACHE_WAITING)); + EXPECT_TRUE(net::LogContainsEndEvent( + *log, 5, net::LoadLog::TYPE_HTTP_CACHE_WAITING)); // force this transaction to read from the cache MockTransaction transaction(kSimpleGET_Transaction); @@ -1011,18 +1011,18 @@ TEST(HttpCache, SimpleGET_LoadOnlyFromCache_Hit) { // Check that the LoadLog was filled as expected. EXPECT_EQ(6u, log->entries().size()); - net::ExpectLogContains(log, 0, net::LoadLog::TYPE_HTTP_CACHE_OPEN_ENTRY, - net::LoadLog::PHASE_BEGIN); - net::ExpectLogContains(log, 1, net::LoadLog::TYPE_HTTP_CACHE_OPEN_ENTRY, - net::LoadLog::PHASE_END); - net::ExpectLogContains(log, 2, net::LoadLog::TYPE_HTTP_CACHE_WAITING, - net::LoadLog::PHASE_BEGIN); - net::ExpectLogContains(log, 3, net::LoadLog::TYPE_HTTP_CACHE_WAITING, - net::LoadLog::PHASE_END); - net::ExpectLogContains(log, 4, net::LoadLog::TYPE_HTTP_CACHE_READ_INFO, - net::LoadLog::PHASE_BEGIN); - net::ExpectLogContains(log, 5, net::LoadLog::TYPE_HTTP_CACHE_READ_INFO, - net::LoadLog::PHASE_END); + EXPECT_TRUE(net::LogContainsBeginEvent( + *log, 0, net::LoadLog::TYPE_HTTP_CACHE_OPEN_ENTRY)); + EXPECT_TRUE(net::LogContainsEndEvent( + *log, 1, net::LoadLog::TYPE_HTTP_CACHE_OPEN_ENTRY)); + EXPECT_TRUE(net::LogContainsBeginEvent( + *log, 2, net::LoadLog::TYPE_HTTP_CACHE_WAITING)); + EXPECT_TRUE(net::LogContainsEndEvent( + *log, 3, net::LoadLog::TYPE_HTTP_CACHE_WAITING)); + EXPECT_TRUE(net::LogContainsBeginEvent( + *log, 4, net::LoadLog::TYPE_HTTP_CACHE_READ_INFO)); + EXPECT_TRUE(net::LogContainsEndEvent( + *log, 5, net::LoadLog::TYPE_HTTP_CACHE_READ_INFO)); EXPECT_EQ(1, cache.network_layer()->transaction_count()); EXPECT_EQ(1, cache.disk_cache()->open_count()); diff --git a/net/proxy/init_proxy_resolver_unittest.cc b/net/proxy/init_proxy_resolver_unittest.cc index 16af01a..46b8b79 100644 --- a/net/proxy/init_proxy_resolver_unittest.cc +++ b/net/proxy/init_proxy_resolver_unittest.cc @@ -179,18 +179,17 @@ TEST(InitProxyResolverTest, CustomPacSucceeds) { // Check the LoadLog was filled correctly. EXPECT_EQ(9u, log->entries().size()); - ExpectLogContains(log, 0, LoadLog::TYPE_INIT_PROXY_RESOLVER, - LoadLog::PHASE_BEGIN); - ExpectLogContains(log, 1, LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT, - LoadLog::PHASE_BEGIN); - ExpectLogContains(log, 4, LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT, - LoadLog::PHASE_END); - ExpectLogContains(log, 5, LoadLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT, - LoadLog::PHASE_BEGIN); - ExpectLogContains(log, 7, LoadLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT, - LoadLog::PHASE_END); - ExpectLogContains(log, 8, LoadLog::TYPE_INIT_PROXY_RESOLVER, - LoadLog::PHASE_END); + EXPECT_TRUE(LogContainsBeginEvent( + *log, 0, LoadLog::TYPE_INIT_PROXY_RESOLVER)); + EXPECT_TRUE(LogContainsBeginEvent( + *log, 1, LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT)); + EXPECT_TRUE(LogContainsEndEvent( + *log, 4, LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT)); + EXPECT_TRUE(LogContainsBeginEvent( + *log, 5, LoadLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT)); + EXPECT_TRUE(LogContainsEndEvent( + *log, 7, LoadLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT)); + EXPECT_TRUE(LogContainsEndEvent(*log, 8, LoadLog::TYPE_INIT_PROXY_RESOLVER)); } // Fail downloading the custom PAC script. @@ -212,14 +211,13 @@ TEST(InitProxyResolverTest, CustomPacFails1) { // Check the LoadLog was filled correctly. EXPECT_EQ(6u, log->entries().size()); - ExpectLogContains(log, 0, LoadLog::TYPE_INIT_PROXY_RESOLVER, - LoadLog::PHASE_BEGIN); - ExpectLogContains(log, 1, LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT, - LoadLog::PHASE_BEGIN); - ExpectLogContains(log, 4, LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT, - LoadLog::PHASE_END); - ExpectLogContains(log, 5, LoadLog::TYPE_INIT_PROXY_RESOLVER, - LoadLog::PHASE_END); + EXPECT_TRUE(LogContainsBeginEvent( + *log, 0, LoadLog::TYPE_INIT_PROXY_RESOLVER)); + EXPECT_TRUE(LogContainsBeginEvent( + *log, 1, LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT)); + EXPECT_TRUE(LogContainsEndEvent( + *log, 4, LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT)); + EXPECT_TRUE(LogContainsEndEvent(*log, 5, LoadLog::TYPE_INIT_PROXY_RESOLVER)); } // Fail parsing the custom PAC script. @@ -312,26 +310,25 @@ TEST(InitProxyResolverTest, AutodetectFailCustomSuccess2) { // (Note that the Fetch and Set states are repeated since both WPAD and custom // PAC scripts are tried). EXPECT_EQ(17u, log->entries().size()); - ExpectLogContains(log, 0, LoadLog::TYPE_INIT_PROXY_RESOLVER, - LoadLog::PHASE_BEGIN); - ExpectLogContains(log, 1, LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT, - LoadLog::PHASE_BEGIN); - ExpectLogContains(log, 4, LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT, - LoadLog::PHASE_END); - ExpectLogContains(log, 5, LoadLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT, - LoadLog::PHASE_BEGIN); - ExpectLogContains(log, 7, LoadLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT, - LoadLog::PHASE_END); - ExpectLogContains(log, 9, LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT, - LoadLog::PHASE_BEGIN); - ExpectLogContains(log, 12, LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT, - LoadLog::PHASE_END); - ExpectLogContains(log, 13, LoadLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT, - LoadLog::PHASE_BEGIN); - ExpectLogContains(log, 15, LoadLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT, - LoadLog::PHASE_END); - ExpectLogContains(log, 16, LoadLog::TYPE_INIT_PROXY_RESOLVER, - LoadLog::PHASE_END); + EXPECT_TRUE(LogContainsBeginEvent( + *log, 0, LoadLog::TYPE_INIT_PROXY_RESOLVER)); + EXPECT_TRUE(LogContainsBeginEvent( + *log, 1, LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT)); + EXPECT_TRUE(LogContainsEndEvent( + *log, 4, LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT)); + EXPECT_TRUE(LogContainsBeginEvent( + *log, 5, LoadLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT)); + EXPECT_TRUE(LogContainsEndEvent( + *log, 7, LoadLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT)); + EXPECT_TRUE(LogContainsBeginEvent( + *log, 9, LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT)); + EXPECT_TRUE(LogContainsEndEvent( + *log, 12, LoadLog::TYPE_INIT_PROXY_RESOLVER_FETCH_PAC_SCRIPT)); + EXPECT_TRUE(LogContainsBeginEvent( + *log, 13, LoadLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT)); + EXPECT_TRUE(LogContainsEndEvent( + *log, 15, LoadLog::TYPE_INIT_PROXY_RESOLVER_SET_PAC_SCRIPT)); + EXPECT_TRUE(LogContainsEndEvent(*log, 16, LoadLog::TYPE_INIT_PROXY_RESOLVER)); } // Fails at WPAD (downloading), and fails at custom PAC (downloading). diff --git a/net/proxy/proxy_resolver_v8_unittest.cc b/net/proxy/proxy_resolver_v8_unittest.cc index 4d1c1b8..ee536b0 100644 --- a/net/proxy/proxy_resolver_v8_unittest.cc +++ b/net/proxy/proxy_resolver_v8_unittest.cc @@ -435,18 +435,18 @@ TEST(ProxyResolverV8Test, LoadLog) { // isInNet() and isResolvable(). EXPECT_EQ(6u, log->entries().size()); - ExpectLogContains(log, 0, LoadLog::TYPE_PROXY_RESOLVER_V8_MY_IP_ADDRESS, - LoadLog::PHASE_BEGIN); - ExpectLogContains(log, 1, LoadLog::TYPE_PROXY_RESOLVER_V8_MY_IP_ADDRESS, - LoadLog::PHASE_END); - ExpectLogContains(log, 2, LoadLog::TYPE_PROXY_RESOLVER_V8_DNS_RESOLVE, - LoadLog::PHASE_BEGIN); - ExpectLogContains(log, 3, LoadLog::TYPE_PROXY_RESOLVER_V8_DNS_RESOLVE, - LoadLog::PHASE_END); - ExpectLogContains(log, 4, LoadLog::TYPE_PROXY_RESOLVER_V8_DNS_RESOLVE, - LoadLog::PHASE_BEGIN); - ExpectLogContains(log, 5, LoadLog::TYPE_PROXY_RESOLVER_V8_DNS_RESOLVE, - LoadLog::PHASE_END); + EXPECT_TRUE(LogContainsBeginEvent( + *log, 0, LoadLog::TYPE_PROXY_RESOLVER_V8_MY_IP_ADDRESS)); + EXPECT_TRUE(LogContainsEndEvent( + *log, 1, LoadLog::TYPE_PROXY_RESOLVER_V8_MY_IP_ADDRESS)); + EXPECT_TRUE(LogContainsBeginEvent( + *log, 2, LoadLog::TYPE_PROXY_RESOLVER_V8_DNS_RESOLVE)); + EXPECT_TRUE(LogContainsEndEvent( + *log, 3, LoadLog::TYPE_PROXY_RESOLVER_V8_DNS_RESOLVE)); + EXPECT_TRUE(LogContainsBeginEvent( + *log, 4, LoadLog::TYPE_PROXY_RESOLVER_V8_DNS_RESOLVE)); + EXPECT_TRUE(LogContainsEndEvent( + *log, 5, LoadLog::TYPE_PROXY_RESOLVER_V8_DNS_RESOLVE)); } // Try loading a PAC script that ends with a comment and has no terminal diff --git a/net/proxy/proxy_service_unittest.cc b/net/proxy/proxy_service_unittest.cc index 0178dbe..0a026a0 100644 --- a/net/proxy/proxy_service_unittest.cc +++ b/net/proxy/proxy_service_unittest.cc @@ -108,8 +108,8 @@ TEST(ProxyServiceTest, Direct) { // Check the LoadLog was filled correctly. EXPECT_EQ(5u, log->entries().size()); - ExpectLogContains(log, 0, LoadLog::TYPE_PROXY_SERVICE, LoadLog::PHASE_BEGIN); - ExpectLogContains(log, 4, LoadLog::TYPE_PROXY_SERVICE, LoadLog::PHASE_END); + EXPECT_TRUE(LogContainsBeginEvent(*log, 0, LoadLog::TYPE_PROXY_SERVICE)); + EXPECT_TRUE(LogContainsEndEvent(*log, 4, LoadLog::TYPE_PROXY_SERVICE)); } TEST(ProxyServiceTest, PAC) { @@ -147,12 +147,12 @@ TEST(ProxyServiceTest, PAC) { // Check the LoadLog was filled correctly. EXPECT_EQ(7u, log->entries().size()); - ExpectLogContains(log, 0, LoadLog::TYPE_PROXY_SERVICE, LoadLog::PHASE_BEGIN); - ExpectLogContains(log, 3, LoadLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC, - LoadLog::PHASE_BEGIN); - ExpectLogContains(log, 4, LoadLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC, - LoadLog::PHASE_END); - ExpectLogContains(log, 6, LoadLog::TYPE_PROXY_SERVICE, LoadLog::PHASE_END); + EXPECT_TRUE(LogContainsBeginEvent(*log, 0, LoadLog::TYPE_PROXY_SERVICE)); + EXPECT_TRUE(LogContainsBeginEvent( + *log, 3, LoadLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC)); + EXPECT_TRUE(LogContainsEndEvent( + *log, 4, LoadLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC)); + EXPECT_TRUE(LogContainsEndEvent(*log, 6, LoadLog::TYPE_PROXY_SERVICE)); } // Test that the proxy resolver does not see the URL's username/password @@ -1267,13 +1267,14 @@ TEST(ProxyServiceTest, CancelWhilePACFetching) { // Check the LoadLog for request 1 (which was cancelled) got filled properly. EXPECT_EQ(6u, log1->entries().size()); - ExpectLogContains(log1, 0, LoadLog::TYPE_PROXY_SERVICE, LoadLog::PHASE_BEGIN); - ExpectLogContains(log1, 3, LoadLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC, - LoadLog::PHASE_BEGIN); + EXPECT_TRUE(LogContainsBeginEvent(*log1, 0, LoadLog::TYPE_PROXY_SERVICE)); + EXPECT_TRUE(LogContainsBeginEvent( + *log1, 3, LoadLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC)); // Note that TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC is never completed before // the cancellation occured. - ExpectLogContains(log1, 4, LoadLog::TYPE_CANCELLED, LoadLog::PHASE_NONE); - ExpectLogContains(log1, 5, LoadLog::TYPE_PROXY_SERVICE, LoadLog::PHASE_END); + EXPECT_TRUE(LogContainsEvent( + *log1, 4, LoadLog::TYPE_CANCELLED, LoadLog::PHASE_NONE)); + EXPECT_TRUE(LogContainsEndEvent(*log1, 5, LoadLog::TYPE_PROXY_SERVICE)); } // Test that if auto-detect fails, we fall-back to the custom pac. diff --git a/net/socket/client_socket_pool_base_unittest.cc b/net/socket/client_socket_pool_base_unittest.cc index 495a7f2..d4c510f8 100644 --- a/net/socket/client_socket_pool_base_unittest.cc +++ b/net/socket/client_socket_pool_base_unittest.cc @@ -484,12 +484,13 @@ TEST_F(ClientSocketPoolBaseTest, ConnectJob_TimedOut) { EXPECT_EQ(ERR_TIMED_OUT, delegate.WaitForResult()); EXPECT_EQ(3u, log->entries().size()); - ExpectLogContains(log, 0, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB, - LoadLog::PHASE_BEGIN); - ExpectLogContains(log, 1, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB_TIMED_OUT, - LoadLog::PHASE_NONE); - ExpectLogContains(log, 2, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB, - LoadLog::PHASE_END); + EXPECT_TRUE(LogContainsBeginEvent( + *log, 0, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB)); + EXPECT_TRUE(LogContainsEvent( + *log, 1, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB_TIMED_OUT, + LoadLog::PHASE_NONE)); + EXPECT_TRUE(LogContainsEndEvent( + *log, 2, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB)); } TEST_F(ClientSocketPoolBaseTest, BasicSynchronous) { @@ -505,12 +506,12 @@ TEST_F(ClientSocketPoolBaseTest, BasicSynchronous) { handle.Reset(); EXPECT_EQ(4u, log->entries().size()); - ExpectLogContains(log, 0, LoadLog::TYPE_SOCKET_POOL, LoadLog::PHASE_BEGIN); - ExpectLogContains(log, 1, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB, - LoadLog::PHASE_BEGIN); - ExpectLogContains(log, 2, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB, - LoadLog::PHASE_END); - ExpectLogContains(log, 3, LoadLog::TYPE_SOCKET_POOL, LoadLog::PHASE_END); + EXPECT_TRUE(LogContainsBeginEvent(*log, 0, LoadLog::TYPE_SOCKET_POOL)); + EXPECT_TRUE(LogContainsBeginEvent( + *log, 1, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB)); + EXPECT_TRUE(LogContainsEndEvent( + *log, 2, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB)); + EXPECT_TRUE(LogContainsEndEvent(*log, 3, LoadLog::TYPE_SOCKET_POOL)); } TEST_F(ClientSocketPoolBaseTest, InitConnectionFailure) { @@ -524,12 +525,12 @@ TEST_F(ClientSocketPoolBaseTest, InitConnectionFailure) { pool_.get(), log)); EXPECT_EQ(4u, log->entries().size()); - ExpectLogContains(log, 0, LoadLog::TYPE_SOCKET_POOL, LoadLog::PHASE_BEGIN); - ExpectLogContains(log, 1, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB, - LoadLog::PHASE_BEGIN); - ExpectLogContains(log, 2, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB, - LoadLog::PHASE_END); - ExpectLogContains(log, 3, LoadLog::TYPE_SOCKET_POOL, LoadLog::PHASE_END); + EXPECT_TRUE(LogContainsBeginEvent(*log, 0, LoadLog::TYPE_SOCKET_POOL)); + EXPECT_TRUE(LogContainsBeginEvent( + *log, 1, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB)); + EXPECT_TRUE(LogContainsEndEvent( + *log, 2, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB)); + EXPECT_TRUE(LogContainsEndEvent(*log, 3, LoadLog::TYPE_SOCKET_POOL)); } TEST_F(ClientSocketPoolBaseTest, TotalLimit) { @@ -1125,19 +1126,17 @@ TEST_F(ClientSocketPoolBaseTest, BasicAsynchronous) { req.handle()->Reset(); EXPECT_EQ(6u, log->entries().size()); - EXPECT_TRUE(LogContains( - *log, 0, LoadLog::TYPE_SOCKET_POOL, LoadLog::PHASE_BEGIN)); - EXPECT_TRUE(LogContains( - *log, 1, LoadLog::TYPE_SOCKET_POOL_WAITING_IN_QUEUE, - LoadLog::PHASE_BEGIN)); - EXPECT_TRUE(LogContains( - *log, 2, LoadLog::TYPE_SOCKET_POOL_WAITING_IN_QUEUE, LoadLog::PHASE_END)); - EXPECT_TRUE(LogContains( - *log, 3, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB, LoadLog::PHASE_BEGIN)); - EXPECT_TRUE(LogContains( - *log, 4, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB, LoadLog::PHASE_END)); - EXPECT_TRUE(LogContains( - *log, 5, LoadLog::TYPE_SOCKET_POOL, LoadLog::PHASE_END)); + EXPECT_TRUE(LogContainsBeginEvent(*log, 0, LoadLog::TYPE_SOCKET_POOL)); + EXPECT_TRUE(LogContainsBeginEvent( + *log, 1, LoadLog::TYPE_SOCKET_POOL_WAITING_IN_QUEUE)); + EXPECT_TRUE(LogContainsEndEvent( + *log, 2, LoadLog::TYPE_SOCKET_POOL_WAITING_IN_QUEUE)); + EXPECT_TRUE(LogContainsBeginEvent( + *log, 3, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB)); + EXPECT_TRUE(LogContainsEndEvent( + *log, 4, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB)); + EXPECT_TRUE(LogContainsEndEvent( + *log, 5, LoadLog::TYPE_SOCKET_POOL)); } TEST_F(ClientSocketPoolBaseTest, @@ -1154,16 +1153,16 @@ TEST_F(ClientSocketPoolBaseTest, EXPECT_EQ(ERR_CONNECTION_FAILED, req.WaitForResult()); EXPECT_EQ(6u, log->entries().size()); - ExpectLogContains(log, 0, LoadLog::TYPE_SOCKET_POOL, LoadLog::PHASE_BEGIN); - ExpectLogContains(log, 1, LoadLog::TYPE_SOCKET_POOL_WAITING_IN_QUEUE, - LoadLog::PHASE_BEGIN); - ExpectLogContains(log, 2, LoadLog::TYPE_SOCKET_POOL_WAITING_IN_QUEUE, - LoadLog::PHASE_END); - ExpectLogContains(log, 3, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB, - LoadLog::PHASE_BEGIN); - ExpectLogContains(log, 4, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB, - LoadLog::PHASE_END); - ExpectLogContains(log, 5, LoadLog::TYPE_SOCKET_POOL, LoadLog::PHASE_END); + EXPECT_TRUE(LogContainsBeginEvent(*log, 0, LoadLog::TYPE_SOCKET_POOL)); + EXPECT_TRUE(LogContainsBeginEvent( + *log, 1, LoadLog::TYPE_SOCKET_POOL_WAITING_IN_QUEUE)); + EXPECT_TRUE(LogContainsEndEvent( + *log, 2, LoadLog::TYPE_SOCKET_POOL_WAITING_IN_QUEUE)); + EXPECT_TRUE(LogContainsBeginEvent( + *log, 3, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB)); + EXPECT_TRUE(LogContainsEndEvent( + *log, 4, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB)); + EXPECT_TRUE(LogContainsEndEvent(*log, 5, LoadLog::TYPE_SOCKET_POOL)); } TEST_F(ClientSocketPoolBaseTest, TwoRequestsCancelOne) { @@ -1185,35 +1184,36 @@ TEST_F(ClientSocketPoolBaseTest, TwoRequestsCancelOne) { req.handle()->Reset(); EXPECT_EQ(5u, log1->entries().size()); - ExpectLogContains(log1, 0, LoadLog::TYPE_SOCKET_POOL, LoadLog::PHASE_BEGIN); - ExpectLogContains(log1, 1, LoadLog::TYPE_SOCKET_POOL_WAITING_IN_QUEUE, - LoadLog::PHASE_BEGIN); - ExpectLogContains(log1, 2, LoadLog::TYPE_SOCKET_POOL_WAITING_IN_QUEUE, - LoadLog::PHASE_END); - ExpectLogContains(log1, 3, LoadLog::TYPE_CANCELLED, LoadLog::PHASE_NONE); - ExpectLogContains(log1, 4, LoadLog::TYPE_SOCKET_POOL, LoadLog::PHASE_END); + EXPECT_TRUE(LogContainsBeginEvent(*log1, 0, LoadLog::TYPE_SOCKET_POOL)); + EXPECT_TRUE(LogContainsBeginEvent( + *log1, 1, LoadLog::TYPE_SOCKET_POOL_WAITING_IN_QUEUE)); + EXPECT_TRUE(LogContainsEndEvent( + *log1, 2, LoadLog::TYPE_SOCKET_POOL_WAITING_IN_QUEUE)); + EXPECT_TRUE(LogContainsEvent( + *log1, 3, LoadLog::TYPE_CANCELLED, LoadLog::PHASE_NONE)); + EXPECT_TRUE(LogContainsEndEvent(*log1, 4, LoadLog::TYPE_SOCKET_POOL)); // At this point, request 2 is just waiting for the connect job to finish. EXPECT_EQ(2u, log2->entries().size()); - ExpectLogContains(log2, 0, LoadLog::TYPE_SOCKET_POOL, LoadLog::PHASE_BEGIN); - ExpectLogContains(log2, 1, LoadLog::TYPE_SOCKET_POOL_WAITING_IN_QUEUE, - LoadLog::PHASE_BEGIN); + EXPECT_TRUE(LogContainsBeginEvent(*log2, 0, LoadLog::TYPE_SOCKET_POOL)); + EXPECT_TRUE(LogContainsBeginEvent( + *log2, 1, LoadLog::TYPE_SOCKET_POOL_WAITING_IN_QUEUE)); EXPECT_EQ(OK, req2.WaitForResult()); req2.handle()->Reset(); // Now request 2 has actually finished. EXPECT_EQ(6u, log2->entries().size()); - ExpectLogContains(log2, 0, LoadLog::TYPE_SOCKET_POOL, LoadLog::PHASE_BEGIN); - ExpectLogContains(log2, 1, LoadLog::TYPE_SOCKET_POOL_WAITING_IN_QUEUE, - LoadLog::PHASE_BEGIN); - ExpectLogContains(log1, 2, LoadLog::TYPE_SOCKET_POOL_WAITING_IN_QUEUE, - LoadLog::PHASE_END); - ExpectLogContains(log2, 3, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB, - LoadLog::PHASE_BEGIN); - ExpectLogContains(log2, 4, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB, - LoadLog::PHASE_END); - ExpectLogContains(log2, 5, LoadLog::TYPE_SOCKET_POOL, LoadLog::PHASE_END); + EXPECT_TRUE(LogContainsBeginEvent(*log2, 0, LoadLog::TYPE_SOCKET_POOL)); + EXPECT_TRUE(LogContainsBeginEvent( + *log2, 1, LoadLog::TYPE_SOCKET_POOL_WAITING_IN_QUEUE)); + EXPECT_TRUE(LogContainsEndEvent( + *log1, 2, LoadLog::TYPE_SOCKET_POOL_WAITING_IN_QUEUE)); + EXPECT_TRUE(LogContainsBeginEvent( + *log2, 3, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB)); + EXPECT_TRUE(LogContainsEndEvent( + *log2, 4, LoadLog::TYPE_SOCKET_POOL_CONNECT_JOB)); + EXPECT_TRUE(LogContainsEndEvent(*log2, 5, LoadLog::TYPE_SOCKET_POOL)); } diff --git a/net/socket/socks5_client_socket_unittest.cc b/net/socket/socks5_client_socket_unittest.cc index ac7ff5a..b4eb2cf 100644 --- a/net/socket/socks5_client_socket_unittest.cc +++ b/net/socket/socks5_client_socket_unittest.cc @@ -125,15 +125,13 @@ TEST_F(SOCKS5ClientSocketTest, CompleteHandshake) { int rv = user_sock_->Connect(&callback_, log); EXPECT_EQ(ERR_IO_PENDING, rv); EXPECT_FALSE(user_sock_->IsConnected()); - EXPECT_TRUE( - LogContains(*log, 0, LoadLog::TYPE_SOCKS5_CONNECT, LoadLog::PHASE_BEGIN)); + EXPECT_TRUE(LogContainsBeginEvent(*log, 0, LoadLog::TYPE_SOCKS5_CONNECT)); rv = callback_.WaitForResult(); EXPECT_EQ(OK, rv); EXPECT_TRUE(user_sock_->IsConnected()); - EXPECT_TRUE(LogContains( - *log, -1, LoadLog::TYPE_SOCKS5_CONNECT, LoadLog::PHASE_END)); + EXPECT_TRUE(LogContainsEndEvent(*log, -1, LoadLog::TYPE_SOCKS5_CONNECT)); scoped_refptr<IOBuffer> buffer = new IOBuffer(payload_write.size()); memcpy(buffer->data(), payload_write.data(), payload_write.size()); @@ -238,13 +236,11 @@ TEST_F(SOCKS5ClientSocketTest, PartialReadWrites) { scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded)); int rv = user_sock_->Connect(&callback_, log); EXPECT_EQ(ERR_IO_PENDING, rv); - EXPECT_TRUE(LogContains( - *log, 0, LoadLog::TYPE_SOCKS5_CONNECT, LoadLog::PHASE_BEGIN)); + EXPECT_TRUE(LogContainsBeginEvent(*log, 0, LoadLog::TYPE_SOCKS5_CONNECT)); rv = callback_.WaitForResult(); EXPECT_EQ(OK, rv); EXPECT_TRUE(user_sock_->IsConnected()); - EXPECT_TRUE(LogContains( - *log, -1, LoadLog::TYPE_SOCKS5_CONNECT, LoadLog::PHASE_END)); + EXPECT_TRUE(LogContainsEndEvent(*log, -1, LoadLog::TYPE_SOCKS5_CONNECT)); } // Test for partial greet response read @@ -262,13 +258,11 @@ TEST_F(SOCKS5ClientSocketTest, PartialReadWrites) { scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded)); int rv = user_sock_->Connect(&callback_, log); EXPECT_EQ(ERR_IO_PENDING, rv); - EXPECT_TRUE(LogContains( - *log, 0, LoadLog::TYPE_SOCKS5_CONNECT, LoadLog::PHASE_BEGIN)); + EXPECT_TRUE(LogContainsBeginEvent(*log, 0, LoadLog::TYPE_SOCKS5_CONNECT)); rv = callback_.WaitForResult(); EXPECT_EQ(OK, rv); EXPECT_TRUE(user_sock_->IsConnected()); - EXPECT_TRUE(LogContains( - *log, -1, LoadLog::TYPE_SOCKS5_CONNECT, LoadLog::PHASE_END)); + EXPECT_TRUE(LogContainsEndEvent(*log, -1, LoadLog::TYPE_SOCKS5_CONNECT)); } // Test for partial handshake request write. @@ -287,13 +281,11 @@ TEST_F(SOCKS5ClientSocketTest, PartialReadWrites) { scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded)); int rv = user_sock_->Connect(&callback_, log); EXPECT_EQ(ERR_IO_PENDING, rv); - EXPECT_TRUE(LogContains( - *log, 0, LoadLog::TYPE_SOCKS5_CONNECT, LoadLog::PHASE_BEGIN)); + EXPECT_TRUE(LogContainsBeginEvent(*log, 0, LoadLog::TYPE_SOCKS5_CONNECT)); rv = callback_.WaitForResult(); EXPECT_EQ(OK, rv); EXPECT_TRUE(user_sock_->IsConnected()); - EXPECT_TRUE(LogContains( - *log, -1, LoadLog::TYPE_SOCKS5_CONNECT, LoadLog::PHASE_END)); + EXPECT_TRUE(LogContainsEndEvent(*log, -1, LoadLog::TYPE_SOCKS5_CONNECT)); } // Test for partial handshake response read @@ -306,20 +298,19 @@ TEST_F(SOCKS5ClientSocketTest, PartialReadWrites) { MockRead data_reads[] = { MockRead(true, kSOCKS5GreetResponse, arraysize(kSOCKS5GreetResponse)), MockRead(true, kSOCKS5OkResponse, kSplitPoint), - MockRead(true, kSOCKS5OkResponse + kSplitPoint, arraysize(kSOCKS5OkResponse) - kSplitPoint) + MockRead(true, kSOCKS5OkResponse + kSplitPoint, + arraysize(kSOCKS5OkResponse) - kSplitPoint) }; user_sock_.reset(BuildMockSocket(data_reads, data_writes, hostname, 80)); scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded)); int rv = user_sock_->Connect(&callback_, log); EXPECT_EQ(ERR_IO_PENDING, rv); - EXPECT_TRUE(LogContains( - *log, 0, LoadLog::TYPE_SOCKS5_CONNECT, LoadLog::PHASE_BEGIN)); + EXPECT_TRUE(LogContainsBeginEvent(*log, 0, LoadLog::TYPE_SOCKS5_CONNECT)); rv = callback_.WaitForResult(); EXPECT_EQ(OK, rv); EXPECT_TRUE(user_sock_->IsConnected()); - EXPECT_TRUE(LogContains( - *log, -1, LoadLog::TYPE_SOCKS5_CONNECT, LoadLog::PHASE_END)); + EXPECT_TRUE(LogContainsEndEvent(*log, -1, LoadLog::TYPE_SOCKS5_CONNECT)); } } diff --git a/net/socket/socks_client_socket_unittest.cc b/net/socket/socks_client_socket_unittest.cc index 6cf450e..2b4bf58 100644 --- a/net/socket/socks_client_socket_unittest.cc +++ b/net/socket/socks_client_socket_unittest.cc @@ -139,15 +139,14 @@ TEST_F(SOCKSClientSocketTest, CompleteHandshake) { int rv = user_sock_->Connect(&callback_, log); EXPECT_EQ(ERR_IO_PENDING, rv); EXPECT_TRUE( - LogContains(*log, 0, LoadLog::TYPE_SOCKS_CONNECT, LoadLog::PHASE_BEGIN)); + LogContainsBeginEvent(*log, 0, LoadLog::TYPE_SOCKS_CONNECT)); EXPECT_FALSE(user_sock_->IsConnected()); rv = callback_.WaitForResult(); EXPECT_EQ(OK, rv); EXPECT_TRUE(user_sock_->IsConnected()); EXPECT_EQ(SOCKSClientSocket::kSOCKS4, user_sock_->socks_version_); - EXPECT_TRUE(LogContains( - *log, -1, LoadLog::TYPE_SOCKS_CONNECT, LoadLog::PHASE_END)); + EXPECT_TRUE(LogContainsEndEvent(*log, -1, LoadLog::TYPE_SOCKS_CONNECT)); scoped_refptr<IOBuffer> buffer = new IOBuffer(payload_write.size()); memcpy(buffer->data(), payload_write.data(), payload_write.size()); @@ -201,14 +200,12 @@ TEST_F(SOCKSClientSocketTest, HandshakeFailures) { int rv = user_sock_->Connect(&callback_, log); EXPECT_EQ(ERR_IO_PENDING, rv); - EXPECT_TRUE(LogContains( - *log, 0, LoadLog::TYPE_SOCKS_CONNECT, LoadLog::PHASE_BEGIN)); + EXPECT_TRUE(LogContainsBeginEvent(*log, 0, LoadLog::TYPE_SOCKS_CONNECT)); rv = callback_.WaitForResult(); EXPECT_EQ(tests[i].fail_code, rv); EXPECT_FALSE(user_sock_->IsConnected()); EXPECT_TRUE(tcp_sock_->IsConnected()); - EXPECT_TRUE(LogContains( - *log, -1, LoadLog::TYPE_SOCKS_CONNECT, LoadLog::PHASE_END)); + EXPECT_TRUE(LogContainsEndEvent(*log, -1, LoadLog::TYPE_SOCKS_CONNECT)); } } @@ -230,13 +227,12 @@ TEST_F(SOCKSClientSocketTest, PartialServerReads) { int rv = user_sock_->Connect(&callback_, log); EXPECT_EQ(ERR_IO_PENDING, rv); - EXPECT_TRUE(LogContains( - *log, 0, LoadLog::TYPE_SOCKS_CONNECT, LoadLog::PHASE_BEGIN)); + EXPECT_TRUE(LogContainsBeginEvent( + *log, 0, LoadLog::TYPE_SOCKS_CONNECT)); rv = callback_.WaitForResult(); EXPECT_EQ(OK, rv); EXPECT_TRUE(user_sock_->IsConnected()); - EXPECT_TRUE(LogContains( - *log, -1, LoadLog::TYPE_SOCKS_CONNECT, LoadLog::PHASE_END)); + EXPECT_TRUE(LogContainsEndEvent(*log, -1, LoadLog::TYPE_SOCKS_CONNECT)); } // Tests scenario when the client sends the handshake request in @@ -261,13 +257,11 @@ TEST_F(SOCKSClientSocketTest, PartialClientWrites) { int rv = user_sock_->Connect(&callback_, log); EXPECT_EQ(ERR_IO_PENDING, rv); - EXPECT_TRUE(LogContains( - *log, 0, LoadLog::TYPE_SOCKS_CONNECT, LoadLog::PHASE_BEGIN)); + EXPECT_TRUE(LogContainsBeginEvent(*log, 0, LoadLog::TYPE_SOCKS_CONNECT)); rv = callback_.WaitForResult(); EXPECT_EQ(OK, rv); EXPECT_TRUE(user_sock_->IsConnected()); - EXPECT_TRUE(LogContains( - *log, -1, LoadLog::TYPE_SOCKS_CONNECT, LoadLog::PHASE_END)); + EXPECT_TRUE(LogContainsEndEvent(*log, -1, LoadLog::TYPE_SOCKS_CONNECT)); } // Tests the case when the server sends a smaller sized handshake data @@ -286,13 +280,11 @@ TEST_F(SOCKSClientSocketTest, FailedSocketRead) { int rv = user_sock_->Connect(&callback_, log); EXPECT_EQ(ERR_IO_PENDING, rv); - EXPECT_TRUE(LogContains( - *log, 0, LoadLog::TYPE_SOCKS_CONNECT, LoadLog::PHASE_BEGIN)); + EXPECT_TRUE(LogContainsBeginEvent(*log, 0, LoadLog::TYPE_SOCKS_CONNECT)); rv = callback_.WaitForResult(); EXPECT_EQ(ERR_CONNECTION_CLOSED, rv); EXPECT_FALSE(user_sock_->IsConnected()); - EXPECT_TRUE(LogContains( - *log, -1, LoadLog::TYPE_SOCKS_CONNECT, LoadLog::PHASE_END)); + EXPECT_TRUE(LogContainsEndEvent(*log, -1, LoadLog::TYPE_SOCKS_CONNECT)); } // Tries to connect to an unknown DNS and on failure should revert to SOCKS4A. @@ -316,14 +308,12 @@ TEST_F(SOCKSClientSocketTest, SOCKS4AFailedDNS) { int rv = user_sock_->Connect(&callback_, log); EXPECT_EQ(ERR_IO_PENDING, rv); - EXPECT_TRUE(LogContains( - *log, 0, LoadLog::TYPE_SOCKS_CONNECT, LoadLog::PHASE_BEGIN)); + EXPECT_TRUE(LogContainsBeginEvent(*log, 0, LoadLog::TYPE_SOCKS_CONNECT)); rv = callback_.WaitForResult(); EXPECT_EQ(OK, rv); EXPECT_TRUE(user_sock_->IsConnected()); EXPECT_EQ(SOCKSClientSocket::kSOCKS4a, user_sock_->socks_version_); - EXPECT_TRUE(LogContains( - *log, -1, LoadLog::TYPE_SOCKS_CONNECT, LoadLog::PHASE_END)); + EXPECT_TRUE(LogContainsEndEvent(*log, -1, LoadLog::TYPE_SOCKS_CONNECT)); } // Tries to connect to a domain that resolves to IPv6. @@ -348,14 +338,12 @@ TEST_F(SOCKSClientSocketTest, SOCKS4AIfDomainInIPv6) { int rv = user_sock_->Connect(&callback_, log); EXPECT_EQ(ERR_IO_PENDING, rv); - EXPECT_TRUE(LogContains( - *log, 0, LoadLog::TYPE_SOCKS_CONNECT, LoadLog::PHASE_BEGIN)); + EXPECT_TRUE(LogContainsBeginEvent(*log, 0, LoadLog::TYPE_SOCKS_CONNECT)); rv = callback_.WaitForResult(); EXPECT_EQ(OK, rv); EXPECT_TRUE(user_sock_->IsConnected()); EXPECT_EQ(SOCKSClientSocket::kSOCKS4a, user_sock_->socks_version_); - EXPECT_TRUE(LogContains( - *log, -1, LoadLog::TYPE_SOCKS_CONNECT, LoadLog::PHASE_END)); + EXPECT_TRUE(LogContainsEndEvent(*log, -1, LoadLog::TYPE_SOCKS_CONNECT)); } // Calls Disconnect() while a host resolve is in progress. The outstanding host diff --git a/net/socket/ssl_client_socket_unittest.cc b/net/socket/ssl_client_socket_unittest.cc index 2fca322..a3556dc 100644 --- a/net/socket/ssl_client_socket_unittest.cc +++ b/net/socket/ssl_client_socket_unittest.cc @@ -82,21 +82,21 @@ TEST_F(SSLClientSocketTest, Connect) { scoped_refptr<net::LoadLog> log(new net::LoadLog(net::LoadLog::kUnbounded)); rv = sock->Connect(&callback, log); - EXPECT_TRUE(net::LogContains( - *log, 0, net::LoadLog::TYPE_SSL_CONNECT, net::LoadLog::PHASE_BEGIN)); + EXPECT_TRUE(net::LogContainsBeginEvent( + *log, 0, net::LoadLog::TYPE_SSL_CONNECT)); if (rv != net::OK) { ASSERT_EQ(net::ERR_IO_PENDING, rv); EXPECT_FALSE(sock->IsConnected()); - EXPECT_FALSE(net::LogContains( - *log, -1, net::LoadLog::TYPE_SSL_CONNECT, net::LoadLog::PHASE_END)); + EXPECT_FALSE(net::LogContainsEndEvent( + *log, -1, net::LoadLog::TYPE_SSL_CONNECT)); rv = callback.WaitForResult(); EXPECT_EQ(net::OK, rv); } EXPECT_TRUE(sock->IsConnected()); - EXPECT_TRUE(net::LogContains( - *log, -1, net::LoadLog::TYPE_SSL_CONNECT, net::LoadLog::PHASE_END)); + EXPECT_TRUE(net::LogContainsEndEvent( + *log, -1, net::LoadLog::TYPE_SSL_CONNECT)); sock->Disconnect(); EXPECT_FALSE(sock->IsConnected()); @@ -126,13 +126,13 @@ TEST_F(SSLClientSocketTest, ConnectExpired) { scoped_refptr<net::LoadLog> log(new net::LoadLog(net::LoadLog::kUnbounded)); rv = sock->Connect(&callback, log); - EXPECT_TRUE(net::LogContains( - *log, 0, net::LoadLog::TYPE_SSL_CONNECT, net::LoadLog::PHASE_BEGIN)); + EXPECT_TRUE(net::LogContainsBeginEvent( + *log, 0, net::LoadLog::TYPE_SSL_CONNECT)); if (rv != net::OK) { ASSERT_EQ(net::ERR_IO_PENDING, rv); EXPECT_FALSE(sock->IsConnected()); - EXPECT_FALSE(net::LogContains( - *log, -1, net::LoadLog::TYPE_SSL_CONNECT, net::LoadLog::PHASE_END)); + EXPECT_FALSE(net::LogContainsEndEvent( + *log, -1, net::LoadLog::TYPE_SSL_CONNECT)); rv = callback.WaitForResult(); EXPECT_EQ(net::ERR_CERT_DATE_INVALID, rv); @@ -142,8 +142,8 @@ TEST_F(SSLClientSocketTest, ConnectExpired) { // the socket when it encounters an error, whereas other implementations // leave it connected. - EXPECT_TRUE(net::LogContains( - *log, -1, net::LoadLog::TYPE_SSL_CONNECT, net::LoadLog::PHASE_END)); + EXPECT_TRUE(net::LogContainsEndEvent( + *log, -1, net::LoadLog::TYPE_SSL_CONNECT)); } TEST_F(SSLClientSocketTest, ConnectMismatched) { @@ -171,13 +171,13 @@ TEST_F(SSLClientSocketTest, ConnectMismatched) { scoped_refptr<net::LoadLog> log(new net::LoadLog(net::LoadLog::kUnbounded)); rv = sock->Connect(&callback, log); - EXPECT_TRUE(net::LogContains( - *log, 0, net::LoadLog::TYPE_SSL_CONNECT, net::LoadLog::PHASE_BEGIN)); + EXPECT_TRUE(net::LogContainsBeginEvent( + *log, 0, net::LoadLog::TYPE_SSL_CONNECT)); if (rv != net::ERR_CERT_COMMON_NAME_INVALID) { ASSERT_EQ(net::ERR_IO_PENDING, rv); EXPECT_FALSE(sock->IsConnected()); - EXPECT_FALSE(net::LogContains( - *log, -1, net::LoadLog::TYPE_SSL_CONNECT, net::LoadLog::PHASE_END)); + EXPECT_FALSE(net::LogContainsEndEvent( + *log, -1, net::LoadLog::TYPE_SSL_CONNECT)); rv = callback.WaitForResult(); EXPECT_EQ(net::ERR_CERT_COMMON_NAME_INVALID, rv); @@ -187,8 +187,8 @@ TEST_F(SSLClientSocketTest, ConnectMismatched) { // the socket when it encounters an error, whereas other implementations // leave it connected. - EXPECT_TRUE(net::LogContains( - *log, -1, net::LoadLog::TYPE_SSL_CONNECT, net::LoadLog::PHASE_END)); + EXPECT_TRUE(net::LogContainsEndEvent( + *log, -1, net::LoadLog::TYPE_SSL_CONNECT)); } // TODO(wtc): Add unit tests for IsConnectedAndIdle: diff --git a/net/socket/tcp_client_socket_unittest.cc b/net/socket/tcp_client_socket_unittest.cc index d797e05..eebdc9f 100644 --- a/net/socket/tcp_client_socket_unittest.cc +++ b/net/socket/tcp_client_socket_unittest.cc @@ -101,20 +101,20 @@ TEST_F(TCPClientSocketTest, Connect) { scoped_refptr<LoadLog> log(new LoadLog(LoadLog::kUnbounded)); int rv = sock_->Connect(&callback, log); - EXPECT_TRUE(net::LogContains( - *log, 0, net::LoadLog::TYPE_TCP_CONNECT, net::LoadLog::PHASE_BEGIN)); + EXPECT_TRUE(net::LogContainsBeginEvent( + *log, 0, net::LoadLog::TYPE_TCP_CONNECT)); if (rv != OK) { ASSERT_EQ(rv, ERR_IO_PENDING); - EXPECT_FALSE(net::LogContains( - *log, -1, net::LoadLog::TYPE_TCP_CONNECT, net::LoadLog::PHASE_END)); + EXPECT_FALSE(net::LogContainsEndEvent( + *log, -1, net::LoadLog::TYPE_TCP_CONNECT)); rv = callback.WaitForResult(); EXPECT_EQ(rv, OK); } EXPECT_TRUE(sock_->IsConnected()); - EXPECT_TRUE(net::LogContains( - *log, -1, net::LoadLog::TYPE_TCP_CONNECT, net::LoadLog::PHASE_END)); + EXPECT_TRUE(net::LogContainsEndEvent( + *log, -1, net::LoadLog::TYPE_TCP_CONNECT)); sock_->Disconnect(); EXPECT_FALSE(sock_->IsConnected()); diff --git a/net/socket_stream/socket_stream_unittest.cc b/net/socket_stream/socket_stream_unittest.cc index fc9cac2..76d59e9 100644 --- a/net/socket_stream/socket_stream_unittest.cc +++ b/net/socket_stream/socket_stream_unittest.cc @@ -210,13 +210,10 @@ TEST_F(SocketStreamTest, BasicAuthProxy) { // The first and last entries of the LoadLog should be for // SOCKET_STREAM_CONNECT. - ExpectLogContains(socket_stream->load_log(), 0, - LoadLog::TYPE_SOCKET_STREAM_CONNECT, - LoadLog::PHASE_BEGIN); - ExpectLogContains(socket_stream->load_log(), - socket_stream->load_log()->entries().size() - 1, - LoadLog::TYPE_SOCKET_STREAM_CONNECT, - LoadLog::PHASE_END); + EXPECT_TRUE(LogContainsBeginEvent( + *socket_stream->load_log(), 0, LoadLog::TYPE_SOCKET_STREAM_CONNECT)); + EXPECT_TRUE(LogContainsEndEvent( + *socket_stream->load_log(), -1, LoadLog::TYPE_SOCKET_STREAM_CONNECT)); } } // namespace net diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc index 1adeb0c..48cfd35 100644 --- a/net/url_request/url_request_unittest.cc +++ b/net/url_request/url_request_unittest.cc @@ -218,22 +218,14 @@ TEST_F(URLRequestTestHTTP, GetTest_NoCache) { // The first part of the log will be for URL_REQUEST_START. // After that, there should be an HTTP_TRANSACTION_READ_BODY - EXPECT_TRUE( - net::LogContains(*r.load_log(), 0, - net::LoadLog::TYPE_URL_REQUEST_START, - net::LoadLog::PHASE_BEGIN)); - EXPECT_TRUE( - net::LogContains(*r.load_log(), -3, - net::LoadLog::TYPE_URL_REQUEST_START, - net::LoadLog::PHASE_END)); - EXPECT_TRUE( - net::LogContains(*r.load_log(), -2, - net::LoadLog::TYPE_HTTP_TRANSACTION_READ_BODY, - net::LoadLog::PHASE_BEGIN)); - EXPECT_TRUE( - net::LogContains(*r.load_log(), -1, - net::LoadLog::TYPE_HTTP_TRANSACTION_READ_BODY, - net::LoadLog::PHASE_END)); + EXPECT_TRUE(net::LogContainsBeginEvent( + *r.load_log(), 0, net::LoadLog::TYPE_URL_REQUEST_START)); + EXPECT_TRUE(net::LogContainsEndEvent( + *r.load_log(), -3, net::LoadLog::TYPE_URL_REQUEST_START)); + EXPECT_TRUE(net::LogContainsBeginEvent( + *r.load_log(), -2, net::LoadLog::TYPE_HTTP_TRANSACTION_READ_BODY)); + EXPECT_TRUE(net::LogContainsEndEvent( + *r.load_log(), -1, net::LoadLog::TYPE_HTTP_TRANSACTION_READ_BODY)); } } |