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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 | 73 |
74 TEST(TaskQueueTest, PostLambda) { | 74 TEST(TaskQueueTest, PostLambda) { |
75 static const char kQueueName[] = "PostLambda"; | 75 static const char kQueueName[] = "PostLambda"; |
76 Event event(false, false); | 76 Event event(false, false); |
77 TaskQueue queue(kQueueName); | 77 TaskQueue queue(kQueueName); |
78 | 78 |
79 queue.PostTask([&event]() { event.Set(); }); | 79 queue.PostTask([&event]() { event.Set(); }); |
80 EXPECT_TRUE(event.Wait(1000)); | 80 EXPECT_TRUE(event.Wait(1000)); |
81 } | 81 } |
82 | 82 |
| 83 TEST(TaskQueueTest, PostDelayedZero) { |
| 84 static const char kQueueName[] = "PostDelayedZero"; |
| 85 Event event(false, false); |
| 86 TaskQueue queue(kQueueName); |
| 87 |
| 88 queue.PostDelayedTask([&event]() { event.Set(); }, 0); |
| 89 EXPECT_TRUE(event.Wait(1000)); |
| 90 } |
| 91 |
83 TEST(TaskQueueTest, PostFromQueue) { | 92 TEST(TaskQueueTest, PostFromQueue) { |
84 static const char kQueueName[] = "PostFromQueue"; | 93 static const char kQueueName[] = "PostFromQueue"; |
85 Event event(false, false); | 94 Event event(false, false); |
86 TaskQueue queue(kQueueName); | 95 TaskQueue queue(kQueueName); |
87 | 96 |
88 queue.PostTask( | 97 queue.PostTask( |
89 [&event, &queue]() { queue.PostTask([&event]() { event.Set(); }); }); | 98 [&event, &queue]() { queue.PostTask([&event]() { event.Set(); }); }); |
90 EXPECT_TRUE(event.Wait(1000)); | 99 EXPECT_TRUE(event.Wait(1000)); |
91 } | 100 } |
92 | 101 |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 queue.PostTask(NewClosure([&tasks_executed]() { ++tasks_executed; }, | 275 queue.PostTask(NewClosure([&tasks_executed]() { ++tasks_executed; }, |
267 [&tasks_cleaned_up]() { ++tasks_cleaned_up; })); | 276 [&tasks_cleaned_up]() { ++tasks_cleaned_up; })); |
268 event.Set(); // Unblock the first task. | 277 event.Set(); // Unblock the first task. |
269 } | 278 } |
270 | 279 |
271 EXPECT_GE(tasks_cleaned_up, tasks_executed); | 280 EXPECT_GE(tasks_cleaned_up, tasks_executed); |
272 EXPECT_EQ(kTaskCount, tasks_cleaned_up); | 281 EXPECT_EQ(kTaskCount, tasks_cleaned_up); |
273 } | 282 } |
274 | 283 |
275 } // namespace rtc | 284 } // namespace rtc |
OLD | NEW |