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

Side by Side 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, 9 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "net/base/socket_performance_watcher.h"
6
7 #include <stddef.h>
8
9 #include "base/macros.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/time/time.h"
12 #include "net/base/socket_performance_watcher_factory.h"
13 #include "testing/gtest/include/gtest/gtest.h"
14
15 namespace net {
16
17 namespace {
18
19 class TestSocketPerformanceWatcherFactory
20 : public SocketPerformanceWatcherFactory {
21 public:
22 TestSocketPerformanceWatcherFactory() : rtt_notification_received_count_(0) {}
23
24 ~TestSocketPerformanceWatcherFactory() override {}
25
26 // SocketPerformanceWatcherFactory implementation:
27 scoped_ptr<SocketPerformanceWatcher> CreateSocketPerformanceWatcher(
28 const Protocol protocol) override {
29 return scoped_ptr<SocketPerformanceWatcher>(
30 new SocketPerformanceWatcher(protocol, this));
31 }
32
33 void OnUpdatedRTTAvailable(const Protocol protocol,
34 const base::TimeDelta& rtt) override {
35 rtt_notification_received_count_++;
36 }
37
38 void OnWatcherReset() override {}
39
40 size_t rtt_notification_received_count() const {
41 return rtt_notification_received_count_;
42 }
43
44 private:
45 size_t rtt_notification_received_count_;
46
47 DISALLOW_COPY_AND_ASSIGN(TestSocketPerformanceWatcherFactory);
48 };
49
50 // 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.
51 // TODO(tbansal): crbug.com/590300: Tighten up this test once CanNotifyRTT() is
52 // tuned.
53 TEST(SocketPerformanceWatcherTest, TestCanNotifyRTT) {
54 TestSocketPerformanceWatcherFactory socket_performance_watcher_factory;
55 scoped_ptr<SocketPerformanceWatcher> watcher =
56 socket_performance_watcher_factory.CreateSocketPerformanceWatcher(
57 SocketPerformanceWatcherFactory::PROTOCOL_TCP);
58 watcher->OnUpdatedRTTAvailable(base::TimeDelta::FromSeconds(1));
59 EXPECT_EQ(
60 1u, socket_performance_watcher_factory.rtt_notification_received_count());
61 EXPECT_FALSE(watcher->ShouldNotifyUpdatedRTT());
62 watcher->Reset();
63 EXPECT_TRUE(watcher->ShouldNotifyUpdatedRTT());
64 }
65
66 } // namespace
67
68 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698