Chromium Code Reviews| Index: net/base/network_activity_monitor_unittest.cc |
| diff --git a/net/base/network_activity_monitor_unittest.cc b/net/base/network_activity_monitor_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d70da1f2a8d71ff545cbdf26219f127300d3d8bb |
| --- /dev/null |
| +++ b/net/base/network_activity_monitor_unittest.cc |
| @@ -0,0 +1,44 @@ |
| +// Copyright (c) 2014 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/network_activity_monitor.h" |
| + |
| +#include "testing/gtest/include/gtest/gtest.h" |
| + |
| +namespace net { |
| + |
| +namespace test { |
| + |
| +class NetworkActivityMonitorPeer { |
| + public: |
| + static NetworkActivityMonitor* CreateMonitor() { |
| + return new NetworkActivityMonitor(); |
| + } |
| +}; |
| + |
| +TEST(NetworkActivityMontiorTest, GetInstance) { |
| + NetworkActivityMonitor* monitor = NetworkActivityMonitor::GetInstance(); |
| + EXPECT_TRUE(monitor != NULL); |
| + EXPECT_TRUE(monitor == NetworkActivityMonitor::GetInstance()); |
| +} |
| + |
| +TEST(NetworkActivityMontiorTest, BytesRead) { |
| + NetworkActivityMonitor* monitor = NetworkActivityMonitorPeer::CreateMonitor(); |
| + EXPECT_EQ(0u, monitor->GetBytesRead()); |
| + uint64 delta = 12345; |
| + monitor->AddBytesRead(delta); |
| + EXPECT_EQ(delta, monitor->GetBytesRead()); |
| +} |
| + |
| +TEST(NetworkActivityMontiorTest, BytesWritten) { |
| + NetworkActivityMonitor* monitor = NetworkActivityMonitorPeer::CreateMonitor(); |
|
eroman
2014/11/13 22:18:39
I suggest also adding a test that posts tasks to a
Ryan Hamilton
2014/11/13 23:38:18
Done.
|
| + EXPECT_EQ(0u, monitor->GetBytesWritten()); |
| + uint64 delta = 12345; |
| + monitor->AddBytesWritten(delta); |
| + EXPECT_EQ(delta, monitor->GetBytesWritten()); |
| +} |
| + |
| +} // namespace test |
| + |
| +} // namespace net |