| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 TaskQueue queue(kQueueName); | 95 TaskQueue queue(kQueueName); |
| 96 | 96 |
| 97 queue.PostTask( | 97 queue.PostTask( |
| 98 [&event, &queue]() { queue.PostTask([&event]() { event.Set(); }); }); | 98 [&event, &queue]() { queue.PostTask([&event]() { event.Set(); }); }); |
| 99 EXPECT_TRUE(event.Wait(1000)); | 99 EXPECT_TRUE(event.Wait(1000)); |
| 100 } | 100 } |
| 101 | 101 |
| 102 TEST(TaskQueueTest, PostDelayed) { | 102 TEST(TaskQueueTest, PostDelayed) { |
| 103 static const char kQueueName[] = "PostDelayed"; | 103 static const char kQueueName[] = "PostDelayed"; |
| 104 Event event(false, false); | 104 Event event(false, false); |
| 105 TaskQueue queue(kQueueName); | 105 TaskQueue queue(kQueueName, TaskQueue::Priority::HIGH); |
| 106 | 106 |
| 107 uint32_t start = Time(); | 107 uint32_t start = Time(); |
| 108 queue.PostDelayedTask(Bind(&CheckCurrent, kQueueName, &event, &queue), 100); | 108 queue.PostDelayedTask(Bind(&CheckCurrent, kQueueName, &event, &queue), 100); |
| 109 EXPECT_TRUE(event.Wait(1000)); | 109 EXPECT_TRUE(event.Wait(1000)); |
| 110 uint32_t end = Time(); | 110 uint32_t end = Time(); |
| 111 // These tests are a little relaxed due to how "powerful" our test bots can | 111 // These tests are a little relaxed due to how "powerful" our test bots can |
| 112 // be. Most recently we've seen windows bots fire the callback after 94-99ms, | 112 // be. Most recently we've seen windows bots fire the callback after 94-99ms, |
| 113 // which is why we have a little bit of leeway backwards as well. | 113 // which is why we have a little bit of leeway backwards as well. |
| 114 EXPECT_GE(end - start, 90u); | 114 EXPECT_GE(end - start, 90u); |
| 115 EXPECT_NEAR(end - start, 190u, 100u); // Accept 90-290. | 115 EXPECT_NEAR(end - start, 190u, 100u); // Accept 90-290. |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 queue.PostTask(NewClosure([&tasks_executed]() { ++tasks_executed; }, | 275 queue.PostTask(NewClosure([&tasks_executed]() { ++tasks_executed; }, |
| 276 [&tasks_cleaned_up]() { ++tasks_cleaned_up; })); | 276 [&tasks_cleaned_up]() { ++tasks_cleaned_up; })); |
| 277 event.Set(); // Unblock the first task. | 277 event.Set(); // Unblock the first task. |
| 278 } | 278 } |
| 279 | 279 |
| 280 EXPECT_GE(tasks_cleaned_up, tasks_executed); | 280 EXPECT_GE(tasks_cleaned_up, tasks_executed); |
| 281 EXPECT_EQ(kTaskCount, tasks_cleaned_up); | 281 EXPECT_EQ(kTaskCount, tasks_cleaned_up); |
| 282 } | 282 } |
| 283 | 283 |
| 284 } // namespace rtc | 284 } // namespace rtc |
| OLD | NEW |