| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/profiler/tracked_time.h" | 7 #include "base/profiler/tracked_time.h" |
| 8 #include "base/time.h" | 8 #include "base/time.h" |
| 9 #include "base/tracked_objects.h" | 9 #include "base/tracked_objects.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 } | 74 } |
| 75 | 75 |
| 76 TEST(TrackedTimeTest, TrackedTimerDisabled) { | 76 TEST(TrackedTimeTest, TrackedTimerDisabled) { |
| 77 // Check to be sure disabling the collection of data induces a null time | 77 // Check to be sure disabling the collection of data induces a null time |
| 78 // (which we know will return much faster). | 78 // (which we know will return much faster). |
| 79 if (!ThreadData::InitializeAndSetTrackingStatus(false)) | 79 if (!ThreadData::InitializeAndSetTrackingStatus(false)) |
| 80 return; | 80 return; |
| 81 // Since we disabled tracking, we should get a null response. | 81 // Since we disabled tracking, we should get a null response. |
| 82 TrackedTime track_now = ThreadData::Now(); | 82 TrackedTime track_now = ThreadData::Now(); |
| 83 EXPECT_TRUE(track_now.is_null()); | 83 EXPECT_TRUE(track_now.is_null()); |
| 84 track_now = ThreadData::NowForStartOfRun(); | 84 track_now = ThreadData::NowForStartOfRun(NULL); |
| 85 EXPECT_TRUE(track_now.is_null()); | 85 EXPECT_TRUE(track_now.is_null()); |
| 86 track_now = ThreadData::NowForEndOfRun(); | 86 track_now = ThreadData::NowForEndOfRun(); |
| 87 EXPECT_TRUE(track_now.is_null()); | 87 EXPECT_TRUE(track_now.is_null()); |
| 88 } | 88 } |
| 89 | 89 |
| 90 TEST(TrackedTimeTest, TrackedTimerEnabled) { | 90 TEST(TrackedTimeTest, TrackedTimerEnabled) { |
| 91 if (!ThreadData::InitializeAndSetTrackingStatus(true)) | 91 if (!ThreadData::InitializeAndSetTrackingStatus(true)) |
| 92 return; | 92 return; |
| 93 // Make sure that when we enable tracking, we get a real timer result. | 93 // Make sure that when we enable tracking, we get a real timer result. |
| 94 | 94 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 106 EXPECT_FALSE(ticks_after.is_null()); | 106 EXPECT_FALSE(ticks_after.is_null()); |
| 107 | 107 |
| 108 // Now make sure that we bracketed our tracked time nicely. | 108 // Now make sure that we bracketed our tracked time nicely. |
| 109 Duration before = now - TrackedTime(ticks_before); | 109 Duration before = now - TrackedTime(ticks_before); |
| 110 EXPECT_LE(0, before.InMilliseconds()); | 110 EXPECT_LE(0, before.InMilliseconds()); |
| 111 Duration after = now - TrackedTime(ticks_after); | 111 Duration after = now - TrackedTime(ticks_after); |
| 112 EXPECT_GE(0, after.InMilliseconds()); | 112 EXPECT_GE(0, after.InMilliseconds()); |
| 113 } | 113 } |
| 114 | 114 |
| 115 } // namespace tracked_objects | 115 } // namespace tracked_objects |
| OLD | NEW |