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 <limits> | |
6 | |
7 #include "base/at_exit.h" | |
8 #include "base/macros.h" | |
9 #include "blimp/net/blimp_stats.h" | |
10 #include "testing/gtest/include/gtest/gtest.h" | |
11 | |
12 namespace blimp { | |
13 | |
14 class BlimpStatsTest : public testing::Test { | |
15 public: | |
16 BlimpStatsTest() {} | |
17 ~BlimpStatsTest() override {} | |
18 | |
19 private: | |
20 base::ShadowingAtExitManager at_exit_manager_; | |
21 | |
22 DISALLOW_COPY_AND_ASSIGN(BlimpStatsTest); | |
23 }; | |
24 | |
25 TEST_F(BlimpStatsTest, AddStatsAndVerify) { | |
26 EXPECT_EQ(0, BlimpStats::GetInstance()->Get(BlimpStats::BYTES_SENT)); | |
27 EXPECT_EQ(0, BlimpStats::GetInstance()->Get(BlimpStats::BYTES_RECEIVED)); | |
28 EXPECT_EQ(0, BlimpStats::GetInstance()->Get(BlimpStats::COMMIT)); | |
29 | |
30 BlimpStats::GetInstance()->Add(BlimpStats::BYTES_SENT, 10); | |
31 BlimpStats::GetInstance()->Add(BlimpStats::BYTES_SENT, 20); | |
32 BlimpStats::GetInstance()->Add(BlimpStats::BYTES_RECEIVED, 5); | |
33 BlimpStats::GetInstance()->Add(BlimpStats::COMMIT, 1); | |
34 | |
35 EXPECT_EQ(30, BlimpStats::GetInstance()->Get(BlimpStats::BYTES_SENT)); | |
36 EXPECT_EQ(5, BlimpStats::GetInstance()->Get(BlimpStats::BYTES_RECEIVED)); | |
37 EXPECT_EQ(1, BlimpStats::GetInstance()->Get(BlimpStats::COMMIT)); | |
38 } | |
39 | |
40 } // namespace blimp | |
OLD | NEW |