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

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: Got rid of unnecessary include. 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
« no previous file with comments | « net/base/dns_query.cc ('k') | net/base/dns_response_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..cd8ce0017dbc3fe08f37aa5c2181877e5808a235 100644
--- a/net/base/dns_query_unittest.cc
+++ b/net/base/dns_query_unittest.cc
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/rand_util.h"
#include "net/base/dns_query.h"
+
+#include "base/bind.h"
+#include "base/rand_util.h"
#include "net/base/dns_util.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -45,8 +47,9 @@ namespace net {
TEST(DnsQueryTest, ConstructorTest) {
std::string kHostnameDns("\003www\006google\003com", 16);
+ 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 +81,9 @@ TEST(DnsQueryTest, ConstructorTest) {
TEST(DnsQueryTest, CloneTest) {
std::string kHostnameDns("\003www\006google\003com", 16);
+ 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 +94,14 @@ TEST(DnsQueryTest, CloneTest) {
TEST(DnsQueryTest, RandomIdTest) {
std::string kHostnameDns("\003www\006google\003com", 16);
+ 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)
« no previous file with comments | « net/base/dns_query.cc ('k') | net/base/dns_response_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698