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

Side by Side Diff: net/dns/host_resolver_impl_unittest.cc

Issue 2315613002: Extracted NetLog class's inner enum types into their own enum classes and (Closed)
Patch Set: Ran "git cl format" on code. Much formatting ensued. Created 4 years, 3 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
« no previous file with comments | « net/dns/host_resolver_impl.cc ('k') | net/filter/filter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/dns/host_resolver_impl.h" 5 #include "net/dns/host_resolver_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <tuple> 10 #include <tuple>
(...skipping 14 matching lines...) Expand all
25 #include "base/synchronization/lock.h" 25 #include "base/synchronization/lock.h"
26 #include "base/test/test_timeouts.h" 26 #include "base/test/test_timeouts.h"
27 #include "base/threading/thread_task_runner_handle.h" 27 #include "base/threading/thread_task_runner_handle.h"
28 #include "base/time/time.h" 28 #include "base/time/time.h"
29 #include "net/base/address_list.h" 29 #include "net/base/address_list.h"
30 #include "net/base/ip_address.h" 30 #include "net/base/ip_address.h"
31 #include "net/base/net_errors.h" 31 #include "net/base/net_errors.h"
32 #include "net/dns/dns_client.h" 32 #include "net/dns/dns_client.h"
33 #include "net/dns/dns_test_util.h" 33 #include "net/dns/dns_test_util.h"
34 #include "net/dns/mock_host_resolver.h" 34 #include "net/dns/mock_host_resolver.h"
35 #include "net/log/net_log_event_type.h"
36 #include "net/log/net_log_source_type.h"
35 #include "net/log/test_net_log.h" 37 #include "net/log/test_net_log.h"
36 #include "net/test/gtest_util.h" 38 #include "net/test/gtest_util.h"
37 #include "testing/gmock/include/gmock/gmock.h" 39 #include "testing/gmock/include/gmock/gmock.h"
38 #include "testing/gtest/include/gtest/gtest.h" 40 #include "testing/gtest/include/gtest/gtest.h"
39 41
40 using net::test::IsError; 42 using net::test::IsError;
41 using net::test::IsOk; 43 using net::test::IsOk;
42 44
43 namespace net { 45 namespace net {
44 46
(...skipping 1483 matching lines...) Expand 10 before | Expand all | Expand 10 after
1528 EXPECT_THAT(request->WaitForResult(), IsOk()); 1530 EXPECT_THAT(request->WaitForResult(), IsOk());
1529 } 1531 }
1530 1532
1531 TEST_F(HostResolverImplTest, IsIPv6Reachable) { 1533 TEST_F(HostResolverImplTest, IsIPv6Reachable) {
1532 // The real HostResolverImpl is needed since TestHostResolverImpl will 1534 // The real HostResolverImpl is needed since TestHostResolverImpl will
1533 // bypass the IPv6 reachability tests. 1535 // bypass the IPv6 reachability tests.
1534 resolver_.reset(new HostResolverImpl(DefaultOptions(), nullptr)); 1536 resolver_.reset(new HostResolverImpl(DefaultOptions(), nullptr));
1535 1537
1536 // Verify that two consecutive calls return the same value. 1538 // Verify that two consecutive calls return the same value.
1537 TestNetLog net_log; 1539 TestNetLog net_log;
1538 BoundNetLog bound_net_log = BoundNetLog::Make(&net_log, NetLog::SOURCE_NONE); 1540 BoundNetLog bound_net_log =
1541 BoundNetLog::Make(&net_log, NetLogSourceType::NONE);
1539 bool result1 = IsIPv6Reachable(bound_net_log); 1542 bool result1 = IsIPv6Reachable(bound_net_log);
1540 bool result2 = IsIPv6Reachable(bound_net_log); 1543 bool result2 = IsIPv6Reachable(bound_net_log);
1541 EXPECT_EQ(result1, result2); 1544 EXPECT_EQ(result1, result2);
1542 1545
1543 // Filter reachability check events and verify that there are two of them. 1546 // Filter reachability check events and verify that there are two of them.
1544 TestNetLogEntry::List event_list; 1547 TestNetLogEntry::List event_list;
1545 net_log.GetEntries(&event_list); 1548 net_log.GetEntries(&event_list);
1546 TestNetLogEntry::List probe_event_list; 1549 TestNetLogEntry::List probe_event_list;
1547 for (const auto& event : event_list) { 1550 for (const auto& event : event_list) {
1548 if (event.type == NetLog::TYPE_HOST_RESOLVER_IMPL_IPV6_REACHABILITY_CHECK) { 1551 if (event.type ==
1552 NetLogEventType::HOST_RESOLVER_IMPL_IPV6_REACHABILITY_CHECK) {
1549 probe_event_list.push_back(event); 1553 probe_event_list.push_back(event);
1550 } 1554 }
1551 } 1555 }
1552 ASSERT_EQ(2U, probe_event_list.size()); 1556 ASSERT_EQ(2U, probe_event_list.size());
1553 1557
1554 // Verify that the first request was not cached and the second one was. 1558 // Verify that the first request was not cached and the second one was.
1555 bool cached; 1559 bool cached;
1556 EXPECT_TRUE(probe_event_list[0].GetBooleanValue("cached", &cached)); 1560 EXPECT_TRUE(probe_event_list[0].GetBooleanValue("cached", &cached));
1557 EXPECT_FALSE(cached); 1561 EXPECT_FALSE(cached);
1558 EXPECT_TRUE(probe_event_list[1].GetBooleanValue("cached", &cached)); 1562 EXPECT_TRUE(probe_event_list[1].GetBooleanValue("cached", &cached));
(...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after
2451 EXPECT_EQ(1, count2); 2455 EXPECT_EQ(1, count2);
2452 2456
2453 // Make another request to make sure both callbacks were cleared. 2457 // Make another request to make sure both callbacks were cleared.
2454 req = CreateRequest("just.testing", 80); 2458 req = CreateRequest("just.testing", 80);
2455 EXPECT_THAT(req->Resolve(), IsOk()); 2459 EXPECT_THAT(req->Resolve(), IsOk());
2456 EXPECT_EQ(2, count1); 2460 EXPECT_EQ(2, count1);
2457 EXPECT_EQ(1, count2); 2461 EXPECT_EQ(1, count2);
2458 } 2462 }
2459 2463
2460 } // namespace net 2464 } // namespace net
OLDNEW
« no previous file with comments | « net/dns/host_resolver_impl.cc ('k') | net/filter/filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698