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

Unified Diff: net/dns/dns_session_unittest.cc

Issue 20482002: Use Histogram algorithm to calculate DNS timeout. Honor DnsConfig timeout if it exceeds 5s. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moved unit test comments. Created 7 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/dns/dns_session.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/dns/dns_session_unittest.cc
diff --git a/net/dns/dns_session_unittest.cc b/net/dns/dns_session_unittest.cc
index d0a12f2636fdd2e0f92dae9fcfd4695089627ddb..46627069f66e8e36866bae74eb4a55a6cb945f1c 100644
--- a/net/dns/dns_session_unittest.cc
+++ b/net/dns/dns_session_unittest.cc
@@ -220,6 +220,29 @@ TEST_F(DnsSessionTest, AllocateFree) {
EXPECT_TRUE(NoMoreEvents());
}
-} // namespace
+// Expect default calculated timeout to be within 10ms of in DnsConfig.
+TEST_F(DnsSessionTest, HistogramTimeoutNormal) {
+ Initialize(2);
+ base::TimeDelta timeoutDelta = session_->NextTimeout(0, 0) - config_.timeout;
+ EXPECT_LT(timeoutDelta.InMilliseconds(), 10);
+}
+
+// Expect short calculated timeout to be within 10ms of in DnsConfig.
+TEST_F(DnsSessionTest, HistogramTimeoutShort) {
+ config_.timeout = base::TimeDelta::FromMilliseconds(15);
+ Initialize(2);
+ base::TimeDelta timeoutDelta = session_->NextTimeout(0, 0) - config_.timeout;
+ EXPECT_LT(timeoutDelta.InMilliseconds(), 10);
+}
+
+// Expect long calculated timeout to be equal to one in DnsConfig.
+TEST_F(DnsSessionTest, HistogramTimeoutLong) {
+ config_.timeout = base::TimeDelta::FromSeconds(15);
+ Initialize(2);
+ base::TimeDelta timeout = session_->NextTimeout(0, 0);
+ EXPECT_EQ(config_.timeout.InMilliseconds(), timeout.InMilliseconds());
+}
+
+} // namespace
} // namespace net
« no previous file with comments | « net/dns/dns_session.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698