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

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

Issue 2109503009: Refactor net tests to use GMock matchers for checking net::Error results (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert changes to contents.txt files Created 4 years, 5 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) 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/dns_transaction.h" 5 #include "net/dns/dns_transaction.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <limits> 9 #include <limits>
10 #include <memory> 10 #include <memory>
11 #include <utility> 11 #include <utility>
12 12
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/ptr_util.h" 15 #include "base/memory/ptr_util.h"
16 #include "base/rand_util.h" 16 #include "base/rand_util.h"
17 #include "base/run_loop.h" 17 #include "base/run_loop.h"
18 #include "base/sys_byteorder.h" 18 #include "base/sys_byteorder.h"
19 #include "base/test/test_timeouts.h" 19 #include "base/test/test_timeouts.h"
20 #include "net/base/ip_address.h" 20 #include "net/base/ip_address.h"
21 #include "net/dns/dns_protocol.h" 21 #include "net/dns/dns_protocol.h"
22 #include "net/dns/dns_query.h" 22 #include "net/dns/dns_query.h"
23 #include "net/dns/dns_response.h" 23 #include "net/dns/dns_response.h"
24 #include "net/dns/dns_session.h" 24 #include "net/dns/dns_session.h"
25 #include "net/dns/dns_test_util.h" 25 #include "net/dns/dns_test_util.h"
26 #include "net/dns/dns_util.h" 26 #include "net/dns/dns_util.h"
27 #include "net/log/net_log.h" 27 #include "net/log/net_log.h"
28 #include "net/socket/socket_test_util.h" 28 #include "net/socket/socket_test_util.h"
29 #include "net/test/gtest_util.h"
30 #include "testing/gmock/include/gmock/gmock.h"
29 #include "testing/gtest/include/gtest/gtest.h" 31 #include "testing/gtest/include/gtest/gtest.h"
30 32
33 using net::test::IsOk;
34
31 namespace net { 35 namespace net {
32 36
33 namespace { 37 namespace {
34 38
35 std::string DomainFromDot(const base::StringPiece& dotted) { 39 std::string DomainFromDot(const base::StringPiece& dotted) {
36 std::string out; 40 std::string out;
37 EXPECT_TRUE(DNSDomainFromDot(dotted, &out)); 41 EXPECT_TRUE(DNSDomainFromDot(dotted, &out));
38 return out; 42 return out;
39 } 43 }
40 44
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 if (cancel_in_callback_) { 278 if (cancel_in_callback_) {
275 Cancel(); 279 Cancel();
276 return; 280 return;
277 } 281 }
278 282
279 // Tell MessageLoop to quit now, in case any ASSERT_* fails. 283 // Tell MessageLoop to quit now, in case any ASSERT_* fails.
280 if (quit_in_callback_) 284 if (quit_in_callback_)
281 base::MessageLoop::current()->QuitWhenIdle(); 285 base::MessageLoop::current()->QuitWhenIdle();
282 286
283 if (expected_answer_count_ >= 0) { 287 if (expected_answer_count_ >= 0) {
284 ASSERT_EQ(OK, rv); 288 ASSERT_THAT(rv, IsOk());
285 ASSERT_TRUE(response != NULL); 289 ASSERT_TRUE(response != NULL);
286 EXPECT_EQ(static_cast<unsigned>(expected_answer_count_), 290 EXPECT_EQ(static_cast<unsigned>(expected_answer_count_),
287 response->answer_count()); 291 response->answer_count());
288 EXPECT_EQ(qtype_, response->qtype()); 292 EXPECT_EQ(qtype_, response->qtype());
289 293
290 DnsRecordParser parser = response->Parser(); 294 DnsRecordParser parser = response->Parser();
291 DnsResourceRecord record; 295 DnsResourceRecord record;
292 for (int i = 0; i < expected_answer_count_; ++i) { 296 for (int i = 0; i < expected_answer_count_; ++i) {
293 EXPECT_TRUE(parser.ReadRecord(&record)); 297 EXPECT_TRUE(parser.ReadRecord(&record));
294 } 298 }
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 config_.timeout = TestTimeouts::tiny_timeout(); 998 config_.timeout = TestTimeouts::tiny_timeout();
995 ConfigureFactory(); 999 ConfigureFactory();
996 1000
997 TransactionHelper helper0(".", dns_protocol::kTypeA, ERR_INVALID_ARGUMENT); 1001 TransactionHelper helper0(".", dns_protocol::kTypeA, ERR_INVALID_ARGUMENT);
998 EXPECT_TRUE(helper0.Run(transaction_factory_.get())); 1002 EXPECT_TRUE(helper0.Run(transaction_factory_.get()));
999 } 1003 }
1000 1004
1001 } // namespace 1005 } // namespace
1002 1006
1003 } // namespace net 1007 } // namespace net
OLDNEW
« no previous file with comments | « net/disk_cache/simple/simple_index_file_unittest.cc ('k') | net/dns/host_resolver_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698