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

Unified Diff: net/base/dns_query_unittest.cc

Issue 7276014: DnsQuery: changed raw function pointer to callback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: net/base/dns_query_unittest.cc
diff --git a/net/base/dns_query_unittest.cc b/net/base/dns_query_unittest.cc
index 124be07d063b52ea64886e6e8becad49780fd60a..92c7ad8eb95fd0c2dd4793f8bdb24a9dd74e0eaf 100644
--- a/net/base/dns_query_unittest.cc
+++ b/net/base/dns_query_unittest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/bind.h"
#include "base/rand_util.h"
#include "net/base/dns_query.h"
willchan no longer on Chromium 2011/06/28 09:58:23 This header should go first.
agayev 2011/06/28 14:37:24 Done.
#include "net/base/dns_util.h"
@@ -45,8 +46,9 @@ namespace net {
TEST(DnsQueryTest, ConstructorTest) {
std::string kHostnameDns("\003www\006google\003com", 16);
+ base::RandIntCallback rand_int_cb = base::Bind(&base::RandInt);
- DnsQuery q1(kHostnameDns, kDNS_A, base::RandUint64);
+ DnsQuery q1(kHostnameDns, kDNS_A, rand_int_cb);
EXPECT_EQ(kDNS_A, q1.qtype());
uint8 id_hi = q1.id() >> 8, id_lo = q1.id() & 0xff;
@@ -78,8 +80,9 @@ TEST(DnsQueryTest, ConstructorTest) {
TEST(DnsQueryTest, CloneTest) {
std::string kHostnameDns("\003www\006google\003com", 16);
+ base::RandIntCallback rand_int_cb = base::Bind(&base::RandInt);
- DnsQuery q1(kHostnameDns, kDNS_A, base::RandUint64);
+ DnsQuery q1(kHostnameDns, kDNS_A, rand_int_cb);
scoped_ptr<DnsQuery> q2(q1.CloneWithNewId());
EXPECT_EQ(q1.io_buffer()->size(), q2->io_buffer()->size());
EXPECT_EQ(q1.qtype(), q2->qtype());
@@ -90,13 +93,14 @@ TEST(DnsQueryTest, CloneTest) {
TEST(DnsQueryTest, RandomIdTest) {
std::string kHostnameDns("\003www\006google\003com", 16);
+ base::RandIntCallback rand_int_cb = base::Bind(&base::RandInt);
// Since id fields are 16-bit values, we iterate to reduce the
// probability of collision, to avoid a flaky test.
bool ids_are_random = false;
for (int i = 0; i < 1000; ++i) {
- DnsQuery q1(kHostnameDns, kDNS_A, base::RandUint64);
- DnsQuery q2(kHostnameDns, kDNS_A, base::RandUint64);
+ DnsQuery q1(kHostnameDns, kDNS_A, rand_int_cb);
+ DnsQuery q2(kHostnameDns, kDNS_A, rand_int_cb);
scoped_ptr<DnsQuery> q3(q1.CloneWithNewId());
ids_are_random = q1.id () != q2.id() && q1.id() != q3->id();
if (ids_are_random)

Powered by Google App Engine
This is Rietveld 408576698