Index: blimp/net/blimp_connection_statistics_unittest.cc |
diff --git a/blimp/net/blimp_connection_statistics_unittest.cc b/blimp/net/blimp_connection_statistics_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..46d896850644a95e53f852995877e283e65644e2 |
--- /dev/null |
+++ b/blimp/net/blimp_connection_statistics_unittest.cc |
@@ -0,0 +1,50 @@ |
+// 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 <blimp/net/blimp_connection_statistics.h> |
Kevin M
2016/05/20 01:02:04
No angle brackets for non-standard headers
shaktisahu
2016/05/22 22:36:57
Done.
|
+#include "base/bind.h" |
+#include "base/message_loop/message_loop.h" |
+#include "base/run_loop.h" |
+#include "base/threading/thread.h" |
+#include "testing/gmock/include/gmock/gmock.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+using testing::_; |
+ |
+namespace blimp { |
+ |
+class BlimpConnectionStatisticsTest : public testing::Test { |
+ public: |
+ BlimpConnectionStatisticsTest() |
+ : stats_(new BlimpConnectionStatistics(message_loop_.task_runner())) {} |
+ |
+ ~BlimpConnectionStatisticsTest() override {} |
+ |
+ MOCK_METHOD1(UpdateDebugInfoCallback, |
+ void(BlimpConnectionStatistics::StatisticsMap)); |
+ |
+ protected: |
+ base::MessageLoop message_loop_; |
+ std::unique_ptr<BlimpConnectionStatistics> stats_; |
Kevin M
2016/05/20 01:02:04
DISALLOW_COPY_AND_ASSIGN()
shaktisahu
2016/05/22 22:36:57
Done.
|
+}; |
+ |
+TEST_F(BlimpConnectionStatisticsTest, AddStatsAndVerify) { |
+ stats_->Add(BlimpConnectionStatistics::BYTES_SENT, 10); |
+ stats_->Add(BlimpConnectionStatistics::BYTES_SENT, 20); |
+ stats_->Add(BlimpConnectionStatistics::BYTES_RECEIVED, 5); |
+ stats_->Increment(BlimpConnectionStatistics::COMMIT); |
+ base::RunLoop().RunUntilIdle(); |
+ |
+ BlimpConnectionStatistics::StatisticsMap map; |
+ map[BlimpConnectionStatistics::BYTES_SENT] = 30; |
+ map[BlimpConnectionStatistics::BYTES_RECEIVED] = 5; |
+ map[BlimpConnectionStatistics::COMMIT] = 1; |
+ |
+ EXPECT_CALL(*this, UpdateDebugInfoCallback(map)); |
+ stats_->GetDebugInfo( |
+ base::Bind(&BlimpConnectionStatisticsTest::UpdateDebugInfoCallback, |
+ base::Unretained(this))); |
+} |
+ |
+} // namespace blimp |