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

Side by Side Diff: chrome/browser/local_discovery/local_domain_resolver_unittest.cc

Issue 2797293002: Use ScopedTaskEnvironment instead of MessageLoop in chrome unit tests. (Closed)
Patch Set: Created 3 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 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/test/scoped_task_environment.h"
10 #include "base/threading/thread_task_runner_handle.h" 11 #include "base/threading/thread_task_runner_handle.h"
11 #include "chrome/browser/local_discovery/service_discovery_client_impl.h" 12 #include "chrome/browser/local_discovery/service_discovery_client_impl.h"
12 #include "net/dns/mdns_client_impl.h" 13 #include "net/dns/mdns_client_impl.h"
13 #include "net/dns/mock_mdns_socket_factory.h" 14 #include "net/dns/mock_mdns_socket_factory.h"
14 #include "testing/gmock/include/gmock/gmock.h" 15 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 17
17 using ::testing::_; 18 using ::testing::_;
18 19
19 namespace local_discovery { 20 namespace local_discovery {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 callback.Cancel(); 94 callback.Cancel();
94 } 95 }
95 96
96 MOCK_METHOD3(AddressCallbackInternal, 97 MOCK_METHOD3(AddressCallbackInternal,
97 void(bool resolved, 98 void(bool resolved,
98 std::string address_ipv4, 99 std::string address_ipv4,
99 std::string address_ipv6)); 100 std::string address_ipv6));
100 101
101 net::MockMDnsSocketFactory socket_factory_; 102 net::MockMDnsSocketFactory socket_factory_;
102 net::MDnsClientImpl mdns_client_; 103 net::MDnsClientImpl mdns_client_;
103 base::MessageLoop message_loop_; 104 base::test::ScopedTaskEnvironment scoped_task_environment_;
104 }; 105 };
105 106
106 TEST_F(LocalDomainResolverTest, ResolveDomainA) { 107 TEST_F(LocalDomainResolverTest, ResolveDomainA) {
107 LocalDomainResolverImpl resolver( 108 LocalDomainResolverImpl resolver(
108 "myhello.local", net::ADDRESS_FAMILY_IPV4, 109 "myhello.local", net::ADDRESS_FAMILY_IPV4,
109 base::Bind(&LocalDomainResolverTest::AddressCallback, 110 base::Bind(&LocalDomainResolverTest::AddressCallback,
110 base::Unretained(this)), &mdns_client_); 111 base::Unretained(this)), &mdns_client_);
111 112
112 EXPECT_CALL(socket_factory_, OnSendTo(_)).Times(2); // Twice per query 113 EXPECT_CALL(socket_factory_, OnSendTo(_)).Times(2); // Twice per query
113 114
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 resolver.Start(); 180 resolver.Start();
180 181
181 EXPECT_CALL(*this, AddressCallbackInternal(false, "", "")); 182 EXPECT_CALL(*this, AddressCallbackInternal(false, "", ""));
182 183
183 RunFor(base::TimeDelta::FromSeconds(4)); 184 RunFor(base::TimeDelta::FromSeconds(4));
184 } 185 }
185 186
186 } // namespace 187 } // namespace
187 188
188 } // namespace local_discovery 189 } // namespace local_discovery
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698