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

Unified Diff: net/nqe/socket_watcher_unittest.cc

Issue 2690113004: Throttle Socket watcher RTT notifications from QUIC (Closed)
Patch Set: Rebased, rch comments Created 3 years, 10 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/nqe/socket_watcher_factory.cc ('k') | net/quic/chromium/quic_connection_logger.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/nqe/socket_watcher_unittest.cc
diff --git a/net/nqe/socket_watcher_unittest.cc b/net/nqe/socket_watcher_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e2eab8f6d37e5cca6b6d2523420dc25731e69428
--- /dev/null
+++ b/net/nqe/socket_watcher_unittest.cc
@@ -0,0 +1,57 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/nqe/socket_watcher.h"
+
+#include "base/bind.h"
+#include "base/test/simple_test_tick_clock.h"
+#include "base/threading/thread_task_runner_handle.h"
+#include "base/time/time.h"
+#include "net/socket/socket_performance_watcher.h"
+#include "net/socket/socket_performance_watcher_factory.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace net {
+
+namespace nqe {
+
+namespace internal {
+
+namespace {
+
+void OnUpdatedRTTAvailable(SocketPerformanceWatcherFactory::Protocol protocol,
+ const base::TimeDelta& rtt) {}
+
+// Verify that the buffer size is never exceeded.
+TEST(NetworkQualitySocketWatcherTest, NotificationsThrottled) {
+ base::SimpleTestTickClock tick_clock;
+ tick_clock.SetNowTicks(base::TimeTicks::Now());
+
+ SocketWatcher socket_watcher(SocketPerformanceWatcherFactory::PROTOCOL_QUIC,
+ base::TimeDelta::FromMilliseconds(2000),
+ base::ThreadTaskRunnerHandle::Get(),
+ base::Bind(OnUpdatedRTTAvailable), &tick_clock);
+
+ EXPECT_TRUE(socket_watcher.ShouldNotifyUpdatedRTT());
+ socket_watcher.OnUpdatedRTTAvailable(base::TimeDelta::FromSeconds(10));
+
+ EXPECT_FALSE(socket_watcher.ShouldNotifyUpdatedRTT());
+
+ tick_clock.Advance(base::TimeDelta::FromMilliseconds(1000));
+ // Minimum interval between consecutive notifications is 2000 msec.
+ EXPECT_FALSE(socket_watcher.ShouldNotifyUpdatedRTT());
+
+ // Advance the clock by 1000 msec more so that the current time is at least
+ // 2000 msec more than the last time |socket_watcher| received a notification.
+ tick_clock.Advance(base::TimeDelta::FromMilliseconds(1000));
+ EXPECT_TRUE(socket_watcher.ShouldNotifyUpdatedRTT());
+}
+
+} // namespace
+
+} // namespace internal
+
+} // namespace nqe
+
+} // namespace net
« no previous file with comments | « net/nqe/socket_watcher_factory.cc ('k') | net/quic/chromium/quic_connection_logger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698