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

Unified Diff: net/base/socket_performance_watcher_unittest.cc

Issue 1376473003: Notify NQE of TCP RTT values (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed rsleevi comments Created 4 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
Index: net/base/socket_performance_watcher_unittest.cc
diff --git a/net/base/socket_performance_watcher_unittest.cc b/net/base/socket_performance_watcher_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a70a34a72d03c0606ad77d5cb123a8d4f27d9ee3
--- /dev/null
+++ b/net/base/socket_performance_watcher_unittest.cc
@@ -0,0 +1,68 @@
+// Copyright 2016 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/base/socket_performance_watcher.h"
+
+#include <stddef.h>
+
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/time/time.h"
+#include "net/base/socket_performance_watcher_factory.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace net {
+
+namespace {
+
+class TestSocketPerformanceWatcherFactory
+ : public SocketPerformanceWatcherFactory {
+ public:
+ TestSocketPerformanceWatcherFactory() : rtt_notification_received_count_(0) {}
+
+ ~TestSocketPerformanceWatcherFactory() override {}
+
+ // SocketPerformanceWatcherFactory implementation:
+ scoped_ptr<SocketPerformanceWatcher> CreateSocketPerformanceWatcher(
+ const Protocol protocol) override {
+ return scoped_ptr<SocketPerformanceWatcher>(
+ new SocketPerformanceWatcher(protocol, this));
+ }
+
+ void OnUpdatedRTTAvailable(const Protocol protocol,
+ const base::TimeDelta& rtt) override {
+ rtt_notification_received_count_++;
+ }
+
+ void OnWatcherReset() override {}
+
+ size_t rtt_notification_received_count() const {
+ return rtt_notification_received_count_;
+ }
+
+ private:
+ size_t rtt_notification_received_count_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestSocketPerformanceWatcherFactory);
+};
+
+// Tests if SocketPerformanceWatcher computes CanNotifyRTT() correctly.
Ryan Sleevi 2016/03/04 01:38:38 Out of date comment (CanNotifyRTT)
tbansal1 2016/03/04 02:37:54 Done.
+// TODO(tbansal): crbug.com/590300: Tighten up this test once CanNotifyRTT() is
+// tuned.
+TEST(SocketPerformanceWatcherTest, TestCanNotifyRTT) {
+ TestSocketPerformanceWatcherFactory socket_performance_watcher_factory;
+ scoped_ptr<SocketPerformanceWatcher> watcher =
+ socket_performance_watcher_factory.CreateSocketPerformanceWatcher(
+ SocketPerformanceWatcherFactory::PROTOCOL_TCP);
+ watcher->OnUpdatedRTTAvailable(base::TimeDelta::FromSeconds(1));
+ EXPECT_EQ(
+ 1u, socket_performance_watcher_factory.rtt_notification_received_count());
+ EXPECT_FALSE(watcher->ShouldNotifyUpdatedRTT());
+ watcher->Reset();
+ EXPECT_TRUE(watcher->ShouldNotifyUpdatedRTT());
+}
+
+} // namespace
+
+} // namespace net

Powered by Google App Engine
This is Rietveld 408576698