| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Test of classes in tracked_time.cc | 5 // Test of classes in tracked_time.cc |
| 6 | 6 |
| 7 #include <stdint.h> |
| 8 |
| 7 #include "base/profiler/tracked_time.h" | 9 #include "base/profiler/tracked_time.h" |
| 8 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| 9 #include "base/tracked_objects.h" | 11 #include "base/tracked_objects.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 13 |
| 12 namespace tracked_objects { | 14 namespace tracked_objects { |
| 13 | 15 |
| 14 TEST(TrackedTimeTest, TrackedTimerMilliseconds) { | 16 TEST(TrackedTimeTest, TrackedTimerMilliseconds) { |
| 15 // First make sure we basicallly transfer simple milliseconds values as | 17 // First make sure we basicallly transfer simple milliseconds values as |
| 16 // expected. Most critically, things should not become null. | 18 // expected. Most critically, things should not become null. |
| 17 int32 kSomeMilliseconds = 243; // Some example times. | 19 int32_t kSomeMilliseconds = 243; // Some example times. |
| 18 int64 kReallyBigMilliseconds = (1LL << 35) + kSomeMilliseconds; | 20 int64_t kReallyBigMilliseconds = (1LL << 35) + kSomeMilliseconds; |
| 19 | 21 |
| 20 TrackedTime some = TrackedTime() + | 22 TrackedTime some = TrackedTime() + |
| 21 Duration::FromMilliseconds(kSomeMilliseconds); | 23 Duration::FromMilliseconds(kSomeMilliseconds); |
| 22 EXPECT_EQ(kSomeMilliseconds, (some - TrackedTime()).InMilliseconds()); | 24 EXPECT_EQ(kSomeMilliseconds, (some - TrackedTime()).InMilliseconds()); |
| 23 EXPECT_FALSE(some.is_null()); | 25 EXPECT_FALSE(some.is_null()); |
| 24 | 26 |
| 25 // Now create a big time, to check that it is wrapped modulo 2^32. | 27 // Now create a big time, to check that it is wrapped modulo 2^32. |
| 26 base::TimeTicks big = base::TimeTicks() + | 28 base::TimeTicks big = base::TimeTicks() + |
| 27 base::TimeDelta::FromMilliseconds(kReallyBigMilliseconds); | 29 base::TimeDelta::FromMilliseconds(kReallyBigMilliseconds); |
| 28 EXPECT_EQ(kReallyBigMilliseconds, (big - base::TimeTicks()).InMilliseconds()); | 30 EXPECT_EQ(kReallyBigMilliseconds, (big - base::TimeTicks()).InMilliseconds()); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 EXPECT_FALSE(ticks_after.is_null()); | 96 EXPECT_FALSE(ticks_after.is_null()); |
| 95 | 97 |
| 96 // Now make sure that we bracketed our tracked time nicely. | 98 // Now make sure that we bracketed our tracked time nicely. |
| 97 Duration before = now - TrackedTime(ticks_before); | 99 Duration before = now - TrackedTime(ticks_before); |
| 98 EXPECT_LE(0, before.InMilliseconds()); | 100 EXPECT_LE(0, before.InMilliseconds()); |
| 99 Duration after = now - TrackedTime(ticks_after); | 101 Duration after = now - TrackedTime(ticks_after); |
| 100 EXPECT_GE(0, after.InMilliseconds()); | 102 EXPECT_GE(0, after.InMilliseconds()); |
| 101 } | 103 } |
| 102 | 104 |
| 103 } // namespace tracked_objects | 105 } // namespace tracked_objects |
| OLD | NEW |