OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chromeos/network/host_resolver_impl_chromeos.h" | 5 #include "chromeos/network/host_resolver_impl_chromeos.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 base::Bind(&HostResolverImplChromeOSTest::InitializeHostResolver, | 61 base::Bind(&HostResolverImplChromeOSTest::InitializeHostResolver, |
62 base::Unretained(this))); | 62 base::Unretained(this))); |
63 io_message_loop_.RunUntilIdle(); | 63 io_message_loop_.RunUntilIdle(); |
64 | 64 |
65 // Run the main message loop to create the network observer and initialize | 65 // Run the main message loop to create the network observer and initialize |
66 // the ip address values. | 66 // the ip address values. |
67 base::RunLoop().RunUntilIdle(); | 67 base::RunLoop().RunUntilIdle(); |
68 } | 68 } |
69 | 69 |
70 virtual void TearDown() OVERRIDE { | 70 virtual void TearDown() OVERRIDE { |
71 host_resolver_.reset(); | |
72 network_state_handler_.reset(); | 71 network_state_handler_.reset(); |
73 chromeos::DBusThreadManager::Shutdown(); | 72 chromeos::DBusThreadManager::Shutdown(); |
74 } | 73 } |
75 | 74 |
76 protected: | 75 protected: |
77 // Run from main (UI) message loop, calls Resolve on IO message loop. | 76 // Run from main (UI) message loop, calls Resolve on IO message loop. |
78 int CallResolve(net::HostResolver::RequestInfo& info) { | 77 int CallResolve(net::HostResolver::RequestInfo& info) { |
79 io_message_loop_.PostTask( | 78 io_message_loop_.PostTask( |
80 FROM_HERE, | 79 FROM_HERE, |
81 base::Bind(&HostResolverImplChromeOSTest::Resolve, | 80 base::Bind(&HostResolverImplChromeOSTest::Resolve, |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 EXPECT_EQ(expected, addresses_[0].ToString()); | 163 EXPECT_EQ(expected, addresses_[0].ToString()); |
165 | 164 |
166 info.set_address_family(net::ADDRESS_FAMILY_IPV6); | 165 info.set_address_family(net::ADDRESS_FAMILY_IPV6); |
167 EXPECT_EQ(net::OK, CallResolve(info)); | 166 EXPECT_EQ(net::OK, CallResolve(info)); |
168 ASSERT_EQ(2u, addresses_.size()); | 167 ASSERT_EQ(2u, addresses_.size()); |
169 expected = base::StringPrintf("[%s]:%d", kTestIPv6Address, 0); | 168 expected = base::StringPrintf("[%s]:%d", kTestIPv6Address, 0); |
170 EXPECT_EQ(expected, addresses_[0].ToString()); | 169 EXPECT_EQ(expected, addresses_[0].ToString()); |
171 expected = base::StringPrintf("%s:%d", kTestIPv4Address, 0); | 170 expected = base::StringPrintf("%s:%d", kTestIPv4Address, 0); |
172 EXPECT_EQ(expected, addresses_[1].ToString()); | 171 EXPECT_EQ(expected, addresses_[1].ToString()); |
173 } | 172 } |
OLD | NEW |