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

Side by Side Diff: net/proxy/proxy_resolver_v8_tracing_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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/proxy/proxy_resolver_v8_tracing.h" 5 #include "net/proxy/proxy_resolver_v8_tracing.h"
6 6
7 #include "base/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "base/synchronization/waitable_event.h" 14 #include "base/synchronization/waitable_event.h"
15 #include "base/threading/platform_thread.h" 15 #include "base/threading/platform_thread.h"
16 #include "base/values.h" 16 #include "base/values.h"
17 #include "net/base/net_errors.h" 17 #include "net/base/net_errors.h"
18 #include "net/base/test_completion_callback.h" 18 #include "net/base/test_completion_callback.h"
19 #include "net/dns/host_cache.h" 19 #include "net/dns/host_cache.h"
20 #include "net/dns/mock_host_resolver.h" 20 #include "net/dns/mock_host_resolver.h"
21 #include "net/log/captured_net_log_entry.h"
21 #include "net/log/net_log.h" 22 #include "net/log/net_log.h"
22 #include "net/log/net_log_unittest.h" 23 #include "net/log/net_log_unittest.h"
24 #include "net/log/test_net_log.h"
23 #include "net/proxy/proxy_info.h" 25 #include "net/proxy/proxy_info.h"
24 #include "net/proxy/proxy_resolver_error_observer.h" 26 #include "net/proxy/proxy_resolver_error_observer.h"
25 #include "testing/gtest/include/gtest/gtest.h" 27 #include "testing/gtest/include/gtest/gtest.h"
26 #include "url/gurl.h" 28 #include "url/gurl.h"
27 29
28 namespace net { 30 namespace net {
29 31
30 namespace { 32 namespace {
31 33
32 class ProxyResolverV8TracingTest : public testing::Test { 34 class ProxyResolverV8TracingTest : public testing::Test {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 EXPECT_EQ(ERR_IO_PENDING, rv); 147 EXPECT_EQ(ERR_IO_PENDING, rv);
146 EXPECT_EQ(ERR_PAC_SCRIPT_FAILED, callback.WaitForResult()); 148 EXPECT_EQ(ERR_PAC_SCRIPT_FAILED, callback.WaitForResult());
147 149
148 EXPECT_EQ(0u, host_resolver.num_resolve()); 150 EXPECT_EQ(0u, host_resolver.num_resolve());
149 151
150 EXPECT_EQ("Error: line 5: Uncaught TypeError: Cannot read property 'split' " 152 EXPECT_EQ("Error: line 5: Uncaught TypeError: Cannot read property 'split' "
151 "of null\n", error_observer->GetOutput()); 153 "of null\n", error_observer->GetOutput());
152 154
153 // Check the NetLogs -- there was 1 alert and 1 javascript error, and they 155 // Check the NetLogs -- there was 1 alert and 1 javascript error, and they
154 // were output to both the global log, and per-request log. 156 // were output to both the global log, and per-request log.
155 TestNetLog::CapturedEntryList entries_list[2]; 157 CapturedNetLogEntry::List entries_list[2];
156 log.GetEntries(&entries_list[0]); 158 log.GetEntries(&entries_list[0]);
157 request_log.GetEntries(&entries_list[1]); 159 request_log.GetEntries(&entries_list[1]);
158 160
159 for (size_t list_i = 0; list_i < arraysize(entries_list); list_i++) { 161 for (size_t list_i = 0; list_i < arraysize(entries_list); list_i++) {
160 const TestNetLog::CapturedEntryList& entries = entries_list[list_i]; 162 const CapturedNetLogEntry::List& entries = entries_list[list_i];
161 EXPECT_EQ(2u, entries.size()); 163 EXPECT_EQ(2u, entries.size());
162 EXPECT_TRUE( 164 EXPECT_TRUE(
163 LogContainsEvent(entries, 0, NetLog::TYPE_PAC_JAVASCRIPT_ALERT, 165 LogContainsEvent(entries, 0, NetLog::TYPE_PAC_JAVASCRIPT_ALERT,
164 NetLog::PHASE_NONE)); 166 NetLog::PHASE_NONE));
165 EXPECT_TRUE( 167 EXPECT_TRUE(
166 LogContainsEvent(entries, 1, NetLog::TYPE_PAC_JAVASCRIPT_ERROR, 168 LogContainsEvent(entries, 1, NetLog::TYPE_PAC_JAVASCRIPT_ERROR,
167 NetLog::PHASE_NONE)); 169 NetLog::PHASE_NONE));
168 170
169 EXPECT_EQ("{\"message\":\"Prepare to DIE!\"}", entries[0].GetParamsJson()); 171 EXPECT_EQ("{\"message\":\"Prepare to DIE!\"}", entries[0].GetParamsJson());
170 EXPECT_EQ("{\"line_number\":5,\"message\":\"Uncaught TypeError: Cannot " 172 EXPECT_EQ("{\"line_number\":5,\"message\":\"Uncaught TypeError: Cannot "
(...skipping 28 matching lines...) Expand all
199 // Iteration3 runs in blocking mode and completes 201 // Iteration3 runs in blocking mode and completes
200 EXPECT_EQ("foo:3", proxy_info.proxy_server().ToURI()); 202 EXPECT_EQ("foo:3", proxy_info.proxy_server().ToURI());
201 203
202 EXPECT_EQ(1u, host_resolver.num_resolve()); 204 EXPECT_EQ(1u, host_resolver.num_resolve());
203 205
204 // No errors. 206 // No errors.
205 EXPECT_EQ("", error_observer->GetOutput()); 207 EXPECT_EQ("", error_observer->GetOutput());
206 208
207 // Check the NetLogs -- the script generated 50 alerts, which were mirrored 209 // Check the NetLogs -- the script generated 50 alerts, which were mirrored
208 // to both the global and per-request logs. 210 // to both the global and per-request logs.
209 TestNetLog::CapturedEntryList entries_list[2]; 211 CapturedNetLogEntry::List entries_list[2];
210 log.GetEntries(&entries_list[0]); 212 log.GetEntries(&entries_list[0]);
211 request_log.GetEntries(&entries_list[1]); 213 request_log.GetEntries(&entries_list[1]);
212 214
213 for (size_t list_i = 0; list_i < arraysize(entries_list); list_i++) { 215 for (size_t list_i = 0; list_i < arraysize(entries_list); list_i++) {
214 const TestNetLog::CapturedEntryList& entries = entries_list[list_i]; 216 const CapturedNetLogEntry::List& entries = entries_list[list_i];
215 EXPECT_EQ(50u, entries.size()); 217 EXPECT_EQ(50u, entries.size());
216 for (size_t i = 0; i < entries.size(); ++i) { 218 for (size_t i = 0; i < entries.size(); ++i) {
217 ASSERT_TRUE( 219 ASSERT_TRUE(
218 LogContainsEvent(entries, i, NetLog::TYPE_PAC_JAVASCRIPT_ALERT, 220 LogContainsEvent(entries, i, NetLog::TYPE_PAC_JAVASCRIPT_ALERT,
219 NetLog::PHASE_NONE)); 221 NetLog::PHASE_NONE));
220 } 222 }
221 } 223 }
222 } 224 }
223 225
224 // Verify that buffered alerts cannot grow unboundedly, even when the message is 226 // Verify that buffered alerts cannot grow unboundedly, even when the message is
(...skipping 22 matching lines...) Expand all
247 249
248 EXPECT_EQ("foo:3", proxy_info.proxy_server().ToURI()); 250 EXPECT_EQ("foo:3", proxy_info.proxy_server().ToURI());
249 251
250 EXPECT_EQ(1u, host_resolver.num_resolve()); 252 EXPECT_EQ(1u, host_resolver.num_resolve());
251 253
252 // No errors. 254 // No errors.
253 EXPECT_EQ("", error_observer->GetOutput()); 255 EXPECT_EQ("", error_observer->GetOutput());
254 256
255 // Check the NetLogs -- the script generated 50 alerts, which were mirrored 257 // Check the NetLogs -- the script generated 50 alerts, which were mirrored
256 // to both the global and per-request logs. 258 // to both the global and per-request logs.
257 TestNetLog::CapturedEntryList entries_list[2]; 259 CapturedNetLogEntry::List entries_list[2];
258 log.GetEntries(&entries_list[0]); 260 log.GetEntries(&entries_list[0]);
259 request_log.GetEntries(&entries_list[1]); 261 request_log.GetEntries(&entries_list[1]);
260 262
261 for (size_t list_i = 0; list_i < arraysize(entries_list); list_i++) { 263 for (size_t list_i = 0; list_i < arraysize(entries_list); list_i++) {
262 const TestNetLog::CapturedEntryList& entries = entries_list[list_i]; 264 const CapturedNetLogEntry::List& entries = entries_list[list_i];
263 EXPECT_EQ(1000u, entries.size()); 265 EXPECT_EQ(1000u, entries.size());
264 for (size_t i = 0; i < entries.size(); ++i) { 266 for (size_t i = 0; i < entries.size(); ++i) {
265 ASSERT_TRUE( 267 ASSERT_TRUE(
266 LogContainsEvent(entries, i, NetLog::TYPE_PAC_JAVASCRIPT_ALERT, 268 LogContainsEvent(entries, i, NetLog::TYPE_PAC_JAVASCRIPT_ALERT,
267 NetLog::PHASE_NONE)); 269 NetLog::PHASE_NONE));
268 } 270 }
269 } 271 }
270 } 272 }
271 273
272 // This test runs a PAC script that issues a sequence of DNS resolves. The test 274 // This test runs a PAC script that issues a sequence of DNS resolves. The test
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 "166.155.144.44" // dnsResolve('host1') 327 "166.155.144.44" // dnsResolve('host1')
326 ":99"; 328 ":99";
327 329
328 EXPECT_EQ(kExpectedResult, proxy_info.proxy_server().ToURI()); 330 EXPECT_EQ(kExpectedResult, proxy_info.proxy_server().ToURI());
329 331
330 // No errors. 332 // No errors.
331 EXPECT_EQ("", error_observer->GetOutput()); 333 EXPECT_EQ("", error_observer->GetOutput());
332 334
333 // Check the NetLogs -- the script generated 1 alert, mirrored to both 335 // Check the NetLogs -- the script generated 1 alert, mirrored to both
334 // the per-request and global logs. 336 // the per-request and global logs.
335 TestNetLog::CapturedEntryList entries_list[2]; 337 CapturedNetLogEntry::List entries_list[2];
336 log.GetEntries(&entries_list[0]); 338 log.GetEntries(&entries_list[0]);
337 request_log.GetEntries(&entries_list[1]); 339 request_log.GetEntries(&entries_list[1]);
338 340
339 for (size_t list_i = 0; list_i < arraysize(entries_list); list_i++) { 341 for (size_t list_i = 0; list_i < arraysize(entries_list); list_i++) {
340 const TestNetLog::CapturedEntryList& entries = entries_list[list_i]; 342 const CapturedNetLogEntry::List& entries = entries_list[list_i];
341 EXPECT_EQ(1u, entries.size()); 343 EXPECT_EQ(1u, entries.size());
342 EXPECT_TRUE( 344 EXPECT_TRUE(
343 LogContainsEvent(entries, 0, NetLog::TYPE_PAC_JAVASCRIPT_ALERT, 345 LogContainsEvent(entries, 0, NetLog::TYPE_PAC_JAVASCRIPT_ALERT,
344 NetLog::PHASE_NONE)); 346 NetLog::PHASE_NONE));
345 EXPECT_EQ("{\"message\":\"iteration: 7\"}", entries[0].GetParamsJson()); 347 EXPECT_EQ("{\"message\":\"iteration: 7\"}", entries[0].GetParamsJson());
346 } 348 }
347 } 349 }
348 350
349 // This test runs a PAC script that does "myIpAddress()" followed by 351 // This test runs a PAC script that does "myIpAddress()" followed by
350 // "dnsResolve()". This requires 2 restarts. However once the HostResolver's 352 // "dnsResolve()". This requires 2 restarts. However once the HostResolver's
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 EXPECT_EQ(3u, host_resolver.num_resolve()); 436 EXPECT_EQ(3u, host_resolver.num_resolve());
435 437
436 EXPECT_EQ("166.155.144.11-133.199.111.4:100", 438 EXPECT_EQ("166.155.144.11-133.199.111.4:100",
437 proxy_info.proxy_server().ToURI()); 439 proxy_info.proxy_server().ToURI());
438 440
439 // No errors. 441 // No errors.
440 EXPECT_EQ("", error_observer->GetOutput()); 442 EXPECT_EQ("", error_observer->GetOutput());
441 443
442 // Check the NetLogs -- the script generated 1 alert, mirrored to both 444 // Check the NetLogs -- the script generated 1 alert, mirrored to both
443 // the per-request and global logs. 445 // the per-request and global logs.
444 TestNetLog::CapturedEntryList entries_list[2]; 446 CapturedNetLogEntry::List entries_list[2];
445 log.GetEntries(&entries_list[0]); 447 log.GetEntries(&entries_list[0]);
446 request_log.GetEntries(&entries_list[1]); 448 request_log.GetEntries(&entries_list[1]);
447 449
448 for (size_t list_i = 0; list_i < arraysize(entries_list); list_i++) { 450 for (size_t list_i = 0; list_i < arraysize(entries_list); list_i++) {
449 const TestNetLog::CapturedEntryList& entries = entries_list[list_i]; 451 const CapturedNetLogEntry::List& entries = entries_list[list_i];
450 EXPECT_EQ(1u, entries.size()); 452 EXPECT_EQ(1u, entries.size());
451 EXPECT_TRUE( 453 EXPECT_TRUE(
452 LogContainsEvent(entries, 0, NetLog::TYPE_PAC_JAVASCRIPT_ALERT, 454 LogContainsEvent(entries, 0, NetLog::TYPE_PAC_JAVASCRIPT_ALERT,
453 NetLog::PHASE_NONE)); 455 NetLog::PHASE_NONE));
454 EXPECT_EQ("{\"message\":\"iteration: 4\"}", entries[0].GetParamsJson()); 456 EXPECT_EQ("{\"message\":\"iteration: 4\"}", entries[0].GetParamsJson());
455 } 457 }
456 } 458 }
457 459
458 // This test runs a weird PAC script that was designed to defeat the DNS tracing 460 // This test runs a weird PAC script that was designed to defeat the DNS tracing
459 // optimization. The proxy resolver should detect the inconsistency and 461 // optimization. The proxy resolver should detect the inconsistency and
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 609
608 // Fetched host1 and host2 again, since the ones done during initialization 610 // Fetched host1 and host2 again, since the ones done during initialization
609 // should not have been cached. 611 // should not have been cached.
610 EXPECT_EQ(4u, host_resolver.num_resolve()); 612 EXPECT_EQ(4u, host_resolver.num_resolve());
611 613
612 EXPECT_EQ("91.13.12.1-91.13.12.2-145.88.13.3-137.89.8.45:99", 614 EXPECT_EQ("91.13.12.1-91.13.12.2-145.88.13.3-137.89.8.45:99",
613 proxy_info.proxy_server().ToURI()); 615 proxy_info.proxy_server().ToURI());
614 616
615 // Check the NetLogs -- the script generated 2 alerts during initialization. 617 // Check the NetLogs -- the script generated 2 alerts during initialization.
616 EXPECT_EQ(0u, request_log.GetSize()); 618 EXPECT_EQ(0u, request_log.GetSize());
617 TestNetLog::CapturedEntryList entries; 619 CapturedNetLogEntry::List entries;
618 log.GetEntries(&entries); 620 log.GetEntries(&entries);
619 621
620 ASSERT_EQ(2u, entries.size()); 622 ASSERT_EQ(2u, entries.size());
621 EXPECT_TRUE( 623 EXPECT_TRUE(
622 LogContainsEvent(entries, 0, NetLog::TYPE_PAC_JAVASCRIPT_ALERT, 624 LogContainsEvent(entries, 0, NetLog::TYPE_PAC_JAVASCRIPT_ALERT,
623 NetLog::PHASE_NONE)); 625 NetLog::PHASE_NONE));
624 EXPECT_TRUE( 626 EXPECT_TRUE(
625 LogContainsEvent(entries, 1, NetLog::TYPE_PAC_JAVASCRIPT_ALERT, 627 LogContainsEvent(entries, 1, NetLog::TYPE_PAC_JAVASCRIPT_ALERT,
626 NetLog::PHASE_NONE)); 628 NetLog::PHASE_NONE));
627 629
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 proxy_uri.substr(0, proxy_uri.find(':') + 1)); 1091 proxy_uri.substr(0, proxy_uri.find(':') + 1));
1090 } else { 1092 } else {
1091 NOTREACHED(); 1093 NOTREACHED();
1092 } 1094 }
1093 } 1095 }
1094 } 1096 }
1095 1097
1096 } // namespace 1098 } // namespace
1097 1099
1098 } // namespace net 1100 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698