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 #include "chrome/browser/policy/logging_work_scheduler.h" | 5 #include "chrome/browser/policy/logging_work_scheduler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 // Configure the first scheduler to fire at 0, 30, 60, 90, 120. | 82 // Configure the first scheduler to fire at 0, 30, 60, 90, 120. |
83 count1_ = 4; | 83 count1_ = 4; |
84 delay1_ = 30; | 84 delay1_ = 30; |
85 | 85 |
86 // Configure the first scheduler to fire at 0, 40, 80, 120. | 86 // Configure the first scheduler to fire at 0, 40, 80, 120. |
87 count2_ = 3; | 87 count2_ = 3; |
88 delay2_ = 40; | 88 delay2_ = 40; |
89 | 89 |
90 Callback1(); | 90 Callback1(); |
91 Callback2(); | 91 Callback2(); |
92 loop_.RunAllPending(); | 92 loop_.RunUntilIdle(); |
93 | 93 |
94 std::vector<int64> events; | 94 std::vector<int64> events; |
95 logger_->Swap(&events); | 95 logger_->Swap(&events); |
96 | 96 |
97 EXPECT_EQ(9u, events.size()); | 97 EXPECT_EQ(9u, events.size()); |
98 EXPECT_EQ(0, events[0]); | 98 EXPECT_EQ(0, events[0]); |
99 EXPECT_EQ(0, events[1]); | 99 EXPECT_EQ(0, events[1]); |
100 EXPECT_EQ(30, events[2]); | 100 EXPECT_EQ(30, events[2]); |
101 EXPECT_EQ(40, events[3]); | 101 EXPECT_EQ(40, events[3]); |
102 EXPECT_EQ(60, events[4]); | 102 EXPECT_EQ(60, events[4]); |
103 EXPECT_EQ(80, events[5]); | 103 EXPECT_EQ(80, events[5]); |
104 EXPECT_EQ(90, events[6]); | 104 EXPECT_EQ(90, events[6]); |
105 EXPECT_EQ(120, events[7]); | 105 EXPECT_EQ(120, events[7]); |
106 EXPECT_EQ(120, events[8]); | 106 EXPECT_EQ(120, events[8]); |
107 | 107 |
108 EXPECT_EQ(0, EventLogger::CountEvents(events, 0, 0)); | 108 EXPECT_EQ(0, EventLogger::CountEvents(events, 0, 0)); |
109 EXPECT_EQ(2, EventLogger::CountEvents(events, 0, 1)); | 109 EXPECT_EQ(2, EventLogger::CountEvents(events, 0, 1)); |
110 EXPECT_EQ(4, EventLogger::CountEvents(events, 30, 51)); | 110 EXPECT_EQ(4, EventLogger::CountEvents(events, 30, 51)); |
111 EXPECT_EQ(7, EventLogger::CountEvents(events, 0, 120)); | 111 EXPECT_EQ(7, EventLogger::CountEvents(events, 0, 120)); |
112 EXPECT_EQ(7, EventLogger::CountEvents(events, 1, 120)); | 112 EXPECT_EQ(7, EventLogger::CountEvents(events, 1, 120)); |
113 } | 113 } |
114 | 114 |
115 } // namespace policy | 115 } // namespace policy |
OLD | NEW |