OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "mojo/edk/system/wait_set_dispatcher.h" | 5 #include "mojo/edk/system/wait_set_dispatcher.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 uint32_t num_bytes = sizeof(read_buffer); | 229 uint32_t num_bytes = sizeof(read_buffer); |
230 ReadMessage(dispatcher0_.get(), read_buffer, &num_bytes); | 230 ReadMessage(dispatcher0_.get(), read_buffer, &num_bytes); |
231 EXPECT_EQ(sizeof(buffer), num_bytes); | 231 EXPECT_EQ(sizeof(buffer), num_bytes); |
232 | 232 |
233 // No dispatchers are ready. | 233 // No dispatchers are ready. |
234 w.Init(); | 234 w.Init(); |
235 woken_dispatcher = nullptr; | 235 woken_dispatcher = nullptr; |
236 context = 0; | 236 context = 0; |
237 EXPECT_EQ(MOJO_RESULT_SHOULD_WAIT, | 237 EXPECT_EQ(MOJO_RESULT_SHOULD_WAIT, |
238 GetOneReadyDispatcher(wait_set, &woken_dispatcher, &context)); | 238 GetOneReadyDispatcher(wait_set, &woken_dispatcher, &context)); |
239 EXPECT_EQ(nullptr, woken_dispatcher); | 239 EXPECT_FALSE(woken_dispatcher); |
240 EXPECT_EQ(0u, context); | 240 EXPECT_EQ(0u, context); |
241 EXPECT_EQ(MOJO_RESULT_DEADLINE_EXCEEDED, w.Wait(0, nullptr)); | 241 EXPECT_EQ(MOJO_RESULT_DEADLINE_EXCEEDED, w.Wait(0, nullptr)); |
242 } | 242 } |
243 | 243 |
244 wait_set->RemoveAwakable(&w, nullptr); | 244 wait_set->RemoveAwakable(&w, nullptr); |
245 } | 245 } |
246 | 246 |
247 TEST_F(WaitSetDispatcherTest, MultipleReady) { | 247 TEST_F(WaitSetDispatcherTest, MultipleReady) { |
248 scoped_refptr<WaitSetDispatcher> wait_set = new WaitSetDispatcher(); | 248 scoped_refptr<WaitSetDispatcher> wait_set = new WaitSetDispatcher(); |
249 CloseOnShutdown(wait_set); | 249 CloseOnShutdown(wait_set); |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 EXPECT_EQ(MOJO_RESULT_OK, | 484 EXPECT_EQ(MOJO_RESULT_OK, |
485 GetOneReadyDispatcher(wait_set, &woken_dispatcher, nullptr)); | 485 GetOneReadyDispatcher(wait_set, &woken_dispatcher, nullptr)); |
486 EXPECT_EQ(nested_wait_set, woken_dispatcher); | 486 EXPECT_EQ(nested_wait_set, woken_dispatcher); |
487 | 487 |
488 wait_set->RemoveAwakable(&w, nullptr); | 488 wait_set->RemoveAwakable(&w, nullptr); |
489 } | 489 } |
490 | 490 |
491 } // namespace | 491 } // namespace |
492 } // namespace edk | 492 } // namespace edk |
493 } // namespace mojo | 493 } // namespace mojo |
OLD | NEW |