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

Unified Diff: net/base/async_host_resolver_unittest.cc

Issue 7466031: AsyncHostResolver: integrated HostCache, temporarily, until we have RR cache. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed copyright year. Created 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/async_host_resolver.cc ('k') | net/base/host_cache.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/async_host_resolver_unittest.cc
diff --git a/net/base/async_host_resolver_unittest.cc b/net/base/async_host_resolver_unittest.cc
index 0e9298140f492d9202b35695093ad569024ef0e0..8f1a3961233efb31bf23df97e29be70b4c1bb0dd 100644
--- a/net/base/async_host_resolver_unittest.cc
+++ b/net/base/async_host_resolver_unittest.cc
@@ -7,6 +7,7 @@
#include "base/bind.h"
#include "base/scoped_ptr.h"
#include "net/base/dns_test_util.h"
+#include "net/base/host_cache.h"
#include "net/base/net_log.h"
#include "net/base/rand_callback.h"
#include "net/base/sys_addrinfo.h"
@@ -71,7 +72,6 @@ class AsyncHostResolverTest : public testing::Test {
kT3IpAddresses + arraysize(kT3IpAddresses)),
test_prng_(std::deque<int>(
transaction_ids, transaction_ids + arraysize(transaction_ids))) {
-
rand_int_cb_ = base::Bind(&TestPrng::GetNext,
base::Unretained(&test_prng_));
// AF_INET only for now.
@@ -132,7 +132,7 @@ class AsyncHostResolverTest : public testing::Test {
resolver_.reset(
new AsyncHostResolver(
dns_server, kMaxTransactions, kMaxPendingRequests, rand_int_cb_,
- &factory_, NULL));
+ HostCache::CreateDefaultCache(), &factory_, NULL));
}
protected:
@@ -177,12 +177,28 @@ TEST_F(AsyncHostResolverTest, IPv6LiteralLookup) {
EXPECT_EQ(ERR_NAME_NOT_RESOLVED, rv);
}
-TEST_F(AsyncHostResolverTest, CachedOnlyLookup) {
+TEST_F(AsyncHostResolverTest, CachedLookup) {
info0_.set_only_use_cached_response(true);
- int rv = resolver_->Resolve(info0_, &addrlist0_, &callback0_, NULL,
+ int rv = resolver_->Resolve(info0_, &addrlist0_, NULL, NULL,
BoundNetLog());
- // When caching is added, this should succeed.
EXPECT_EQ(ERR_NAME_NOT_RESOLVED, rv);
+
+ // Cache the result of |info0_| lookup.
+ info0_.set_only_use_cached_response(false);
+ rv = resolver_->Resolve(info0_, &addrlist0_, &callback0_, NULL,
+ BoundNetLog());
+ EXPECT_EQ(ERR_IO_PENDING, rv);
+ rv = callback0_.WaitForResult();
+ EXPECT_EQ(OK, rv);
+ VerifyAddressList(ip_addresses0_, kPortNum, addrlist0_);
+
+ // Now lookup |info0_| from cache only, store results in |addrlist1_|,
+ // should succeed synchronously.
+ info0_.set_only_use_cached_response(true);
+ rv = resolver_->Resolve(info0_, &addrlist1_, NULL, NULL,
+ BoundNetLog());
+ EXPECT_EQ(OK, rv);
+ VerifyAddressList(ip_addresses0_, kPortNum, addrlist1_);
}
TEST_F(AsyncHostResolverTest, InvalidHostNameLookup) {
« no previous file with comments | « net/base/async_host_resolver.cc ('k') | net/base/host_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698