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

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: 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
« net/dns/dns_session.cc ('K') | « 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..ad587c11ccb509bdce9599201637e9033995b597 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
+TEST_F(DnsSessionTest, HistogramTimeoutNormal) {
+ Initialize(2);
+ // Calculated timeout must be within 10ms of config timeout.
szym 2013/07/25 22:47:24 Put comments on expectations just before TEST_F.
mef 2013/07/26 11:27:07 Done.
+ base::TimeDelta timeoutDelta = session_->NextTimeout(0, 0) - config_.timeout;
+ EXPECT_LT(timeoutDelta.InMilliseconds(), 10);
+}
+
+TEST_F(DnsSessionTest, HistogramTimeoutShort) {
+ config_.timeout = base::TimeDelta::FromMilliseconds(15);
+ Initialize(2);
+ // Calculated timeout must be within 10ms of config timeout.
+ base::TimeDelta timeoutDelta = session_->NextTimeout(0, 0) - config_.timeout;
+ EXPECT_LT(timeoutDelta.InMilliseconds(), 10);
+}
+
+TEST_F(DnsSessionTest, HistogramTimeoutLong) {
+ config_.timeout = base::TimeDelta::FromSeconds(15);
+ Initialize(2);
+ // Long timeout must be honored exactly.
+ base::TimeDelta timeout = session_->NextTimeout(0, 0);
+ EXPECT_EQ(config_.timeout.InMilliseconds(), timeout.InMilliseconds());
+}
+
+} // namespace
} // namespace net
« net/dns/dns_session.cc ('K') | « net/dns/dns_session.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698