Chromium Code Reviews| 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..9ef787878dd7fbbfbc269b12b9974eb32f50b822 |
| --- /dev/null |
| +++ b/blimp/net/blimp_connection_statistics_unittest.cc |
| @@ -0,0 +1,42 @@ |
| +// 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 "base/bind.h" |
|
Kevin M
2016/05/24 01:02:01
Not used
shaktisahu
2016/05/24 21:02:45
Done.
|
| +#include "base/macros.h" |
| +#include "base/message_loop/message_loop.h" |
|
Kevin M
2016/05/24 01:02:01
Not used
shaktisahu
2016/05/24 21:02:45
Done.
|
| +#include "base/run_loop.h" |
|
Kevin M
2016/05/24 01:02:01
Not used
|
| +#include "base/threading/thread.h" |
|
Kevin M
2016/05/24 01:02:01
Not used
|
| +#include "blimp/net/blimp_connection_statistics.h" |
| +#include "testing/gmock/include/gmock/gmock.h" |
|
Kevin M
2016/05/24 01:02:01
Not used
shaktisahu
2016/05/24 21:02:45
Done.
|
| +#include "testing/gtest/include/gtest/gtest.h" |
| + |
| +using testing::_; |
| + |
| +namespace blimp { |
| + |
| +class BlimpConnectionStatisticsTest : public testing::Test { |
| + public: |
| + BlimpConnectionStatisticsTest() : stats_(new BlimpConnectionStatistics) {} |
| + |
| + ~BlimpConnectionStatisticsTest() override {} |
| + |
| + protected: |
| + std::unique_ptr<BlimpConnectionStatistics> stats_; |
|
Kevin M
2016/05/24 01:02:01
YOu can make this a regular field - no need to mak
shaktisahu
2016/05/24 21:02:45
Done.
|
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(BlimpConnectionStatisticsTest); |
| +}; |
| + |
| +TEST_F(BlimpConnectionStatisticsTest, AddStatsAndVerify) { |
|
Kevin M
2016/05/24 01:02:01
Also verify zeroes beforehand
shaktisahu
2016/05/24 21:02:45
Done.
|
| + stats_->Add(BlimpConnectionStatistics::BYTES_SENT, 10); |
| + stats_->Add(BlimpConnectionStatistics::BYTES_SENT, 20); |
| + stats_->Add(BlimpConnectionStatistics::BYTES_RECEIVED, 5); |
| + stats_->Add(BlimpConnectionStatistics::COMMIT, 1); |
| + |
| + DCHECK_EQ(30, stats_->Get(BlimpConnectionStatistics::BYTES_SENT)); |
| + DCHECK_EQ(5, stats_->Get(BlimpConnectionStatistics::BYTES_RECEIVED)); |
| + DCHECK_EQ(1, stats_->Get(BlimpConnectionStatistics::COMMIT)); |
| +} |
| + |
| +} // namespace blimp |