OLD | NEW |
---|---|
(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 <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.
| |
6 #include "base/bind.h" | |
7 #include "base/message_loop/message_loop.h" | |
8 #include "base/run_loop.h" | |
9 #include "base/threading/thread.h" | |
10 #include "testing/gmock/include/gmock/gmock.h" | |
11 #include "testing/gtest/include/gtest/gtest.h" | |
12 | |
13 using testing::_; | |
14 | |
15 namespace blimp { | |
16 | |
17 class BlimpConnectionStatisticsTest : public testing::Test { | |
18 public: | |
19 BlimpConnectionStatisticsTest() | |
20 : stats_(new BlimpConnectionStatistics(message_loop_.task_runner())) {} | |
21 | |
22 ~BlimpConnectionStatisticsTest() override {} | |
23 | |
24 MOCK_METHOD1(UpdateDebugInfoCallback, | |
25 void(BlimpConnectionStatistics::StatisticsMap)); | |
26 | |
27 protected: | |
28 base::MessageLoop message_loop_; | |
29 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.
| |
30 }; | |
31 | |
32 TEST_F(BlimpConnectionStatisticsTest, AddStatsAndVerify) { | |
33 stats_->Add(BlimpConnectionStatistics::BYTES_SENT, 10); | |
34 stats_->Add(BlimpConnectionStatistics::BYTES_SENT, 20); | |
35 stats_->Add(BlimpConnectionStatistics::BYTES_RECEIVED, 5); | |
36 stats_->Increment(BlimpConnectionStatistics::COMMIT); | |
37 base::RunLoop().RunUntilIdle(); | |
38 | |
39 BlimpConnectionStatistics::StatisticsMap map; | |
40 map[BlimpConnectionStatistics::BYTES_SENT] = 30; | |
41 map[BlimpConnectionStatistics::BYTES_RECEIVED] = 5; | |
42 map[BlimpConnectionStatistics::COMMIT] = 1; | |
43 | |
44 EXPECT_CALL(*this, UpdateDebugInfoCallback(map)); | |
45 stats_->GetDebugInfo( | |
46 base::Bind(&BlimpConnectionStatisticsTest::UpdateDebugInfoCallback, | |
47 base::Unretained(this))); | |
48 } | |
49 | |
50 } // namespace blimp | |
OLD | NEW |