Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2014 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/network_activity_monitor.h" | |
| 6 | |
| 7 #include "testing/gtest/include/gtest/gtest.h" | |
| 8 | |
| 9 namespace net { | |
| 10 | |
| 11 namespace test { | |
| 12 | |
| 13 class NetworkActivityMonitorPeer { | |
| 14 public: | |
| 15 static NetworkActivityMonitor* CreateMonitor() { | |
| 16 return new NetworkActivityMonitor(); | |
| 17 } | |
| 18 }; | |
| 19 | |
| 20 TEST(NetworkActivityMontiorTest, GetInstance) { | |
| 21 NetworkActivityMonitor* monitor = NetworkActivityMonitor::GetInstance(); | |
| 22 EXPECT_TRUE(monitor != NULL); | |
| 23 EXPECT_TRUE(monitor == NetworkActivityMonitor::GetInstance()); | |
| 24 } | |
| 25 | |
| 26 TEST(NetworkActivityMontiorTest, BytesRead) { | |
| 27 NetworkActivityMonitor* monitor = NetworkActivityMonitorPeer::CreateMonitor(); | |
| 28 EXPECT_EQ(0u, monitor->GetBytesRead()); | |
| 29 uint64 delta = 12345; | |
| 30 monitor->AddBytesRead(delta); | |
| 31 EXPECT_EQ(delta, monitor->GetBytesRead()); | |
| 32 } | |
| 33 | |
| 34 TEST(NetworkActivityMontiorTest, BytesWritten) { | |
| 35 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.
| |
| 36 EXPECT_EQ(0u, monitor->GetBytesWritten()); | |
| 37 uint64 delta = 12345; | |
| 38 monitor->AddBytesWritten(delta); | |
| 39 EXPECT_EQ(delta, monitor->GetBytesWritten()); | |
| 40 } | |
| 41 | |
| 42 } // namespace test | |
| 43 | |
| 44 } // namespace net | |
| OLD | NEW |