| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/bindings/RuntimeCallStats.h" | 5 #include "platform/bindings/RuntimeCallStats.h" |
| 6 | 6 |
| 7 #include "platform/RuntimeEnabledFeatures.h" | 7 #include "platform/RuntimeEnabledFeatures.h" |
| 8 #include "platform/wtf/CurrentTime.h" | 8 #include "platform/wtf/CurrentTime.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| 11 namespace blink { | 11 namespace blink { |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 TimeTicks ticks_; | 15 TimeTicks ticks_; |
| 16 | 16 |
| 17 void AdvanceClock(int milliseconds) { | 17 void AdvanceClock(int milliseconds) { |
| 18 ticks_ += TimeDelta::FromMilliseconds(milliseconds); | 18 ticks_ += TimeDelta::FromMilliseconds(milliseconds); |
| 19 } | 19 } |
| 20 | 20 |
| 21 RuntimeCallStats::CounterId test_counter_1_id = | 21 RuntimeCallStats::CounterId test_counter_1_id = |
| 22 RuntimeCallStats::CounterId::kTestCounter1; | 22 RuntimeCallStats::CounterId::kTestCounter1; |
| 23 RuntimeCallStats::CounterId test_counter_2_id = | 23 RuntimeCallStats::CounterId test_counter_2_id = |
| 24 RuntimeCallStats::CounterId::kTestCounter2; | 24 RuntimeCallStats::CounterId::kTestCounter2; |
| 25 | 25 |
| 26 } // namespace | 26 } // namespace |
| 27 | 27 |
| 28 class RuntimeCallStatsTest : public testing::Test { | 28 class RuntimeCallStatsTest : public ::testing::Test { |
| 29 public: | 29 public: |
| 30 void SetUp() override { | 30 void SetUp() override { |
| 31 // Add one millisecond because RuntimeCallTimer uses |start_ticks_| = | 31 // Add one millisecond because RuntimeCallTimer uses |start_ticks_| = |
| 32 // TimeTicks() to represent that the timer is not running. | 32 // TimeTicks() to represent that the timer is not running. |
| 33 ticks_ = WTF::TimeTicks() + TimeDelta::FromMilliseconds(1); | 33 ticks_ = WTF::TimeTicks() + TimeDelta::FromMilliseconds(1); |
| 34 original_time_function_ = | 34 original_time_function_ = |
| 35 SetTimeFunctionsForTesting([] { return ticks_.InSeconds(); }); | 35 SetTimeFunctionsForTesting([] { return ticks_.InSeconds(); }); |
| 36 } | 36 } |
| 37 | 37 |
| 38 void TearDown() override { | 38 void TearDown() override { |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 RUNTIME_CALL_TIMER_SCOPE_WITH_OPTIONAL_RCS(scope, &stats, | 319 RUNTIME_CALL_TIMER_SCOPE_WITH_OPTIONAL_RCS(scope, &stats, |
| 320 test_counter_1_id); | 320 test_counter_1_id); |
| 321 AdvanceClock(25); | 321 AdvanceClock(25); |
| 322 } | 322 } |
| 323 | 323 |
| 324 EXPECT_EQ(1ul, counter->GetCount()); | 324 EXPECT_EQ(1ul, counter->GetCount()); |
| 325 EXPECT_EQ(25, counter->GetTime().InMilliseconds()); | 325 EXPECT_EQ(25, counter->GetTime().InMilliseconds()); |
| 326 } | 326 } |
| 327 | 327 |
| 328 } // namespace blink | 328 } // namespace blink |
| OLD | NEW |