| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/core.h" | 5 #include "mojo/edk/system/core.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 | 10 |
| 11 #include "base/bind.h" | |
| 12 #include "mojo/edk/system/awakable.h" | 11 #include "mojo/edk/system/awakable.h" |
| 13 #include "mojo/edk/system/core_test_base.h" | 12 #include "mojo/edk/system/core_test_base.h" |
| 14 #include "mojo/edk/system/test/sleep.h" | 13 #include "mojo/edk/system/test/sleep.h" |
| 15 #include "mojo/public/cpp/system/macros.h" | 14 #include "mojo/public/cpp/system/macros.h" |
| 16 | 15 |
| 17 namespace mojo { | 16 namespace mojo { |
| 18 namespace system { | 17 namespace system { |
| 19 namespace { | 18 namespace { |
| 20 | 19 |
| 21 const MojoHandleSignalsState kEmptyMojoHandleSignalsState = {0u, 0u}; | 20 const MojoHandleSignalsState kEmptyMojoHandleSignalsState = {0u, 0u}; |
| (...skipping 1263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1285 | 1284 |
| 1286 MojoResult result; | 1285 MojoResult result; |
| 1287 }; | 1286 }; |
| 1288 | 1287 |
| 1289 TEST_F(CoreTest, AsyncWait) { | 1288 TEST_F(CoreTest, AsyncWait) { |
| 1290 TestAsyncWaiter waiter; | 1289 TestAsyncWaiter waiter; |
| 1291 MockHandleInfo info; | 1290 MockHandleInfo info; |
| 1292 MojoHandle h = CreateMockHandle(&info); | 1291 MojoHandle h = CreateMockHandle(&info); |
| 1293 | 1292 |
| 1294 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, | 1293 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, |
| 1295 core()->AsyncWait(h, MOJO_HANDLE_SIGNAL_READABLE, | 1294 core()->AsyncWait( |
| 1296 base::Bind(&TestAsyncWaiter::Awake, | 1295 h, MOJO_HANDLE_SIGNAL_READABLE, |
| 1297 base::Unretained(&waiter)))); | 1296 [&waiter](MojoResult result) { waiter.Awake(result); })); |
| 1298 EXPECT_EQ(0u, info.GetAddedAwakableSize()); | 1297 EXPECT_EQ(0u, info.GetAddedAwakableSize()); |
| 1299 | 1298 |
| 1300 info.AllowAddAwakable(true); | 1299 info.AllowAddAwakable(true); |
| 1301 EXPECT_EQ(MOJO_RESULT_OK, | 1300 EXPECT_EQ(MOJO_RESULT_OK, core()->AsyncWait(h, MOJO_HANDLE_SIGNAL_READABLE, |
| 1302 core()->AsyncWait(h, MOJO_HANDLE_SIGNAL_READABLE, | 1301 [&waiter](MojoResult result) { |
| 1303 base::Bind(&TestAsyncWaiter::Awake, | 1302 waiter.Awake(result); |
| 1304 base::Unretained(&waiter)))); | 1303 })); |
| 1305 EXPECT_EQ(1u, info.GetAddedAwakableSize()); | 1304 EXPECT_EQ(1u, info.GetAddedAwakableSize()); |
| 1306 | 1305 |
| 1307 EXPECT_FALSE(info.GetAddedAwakableAt(0)->Awake(MOJO_RESULT_BUSY, 0)); | 1306 EXPECT_FALSE(info.GetAddedAwakableAt(0)->Awake(MOJO_RESULT_BUSY, 0)); |
| 1308 EXPECT_EQ(MOJO_RESULT_BUSY, waiter.result); | 1307 EXPECT_EQ(MOJO_RESULT_BUSY, waiter.result); |
| 1309 | 1308 |
| 1310 EXPECT_EQ(MOJO_RESULT_OK, core()->Close(h)); | 1309 EXPECT_EQ(MOJO_RESULT_OK, core()->Close(h)); |
| 1311 } | 1310 } |
| 1312 | 1311 |
| 1313 // TODO(vtl): Test |DuplicateBufferHandle()| and |MapBuffer()|. | 1312 // TODO(vtl): Test |DuplicateBufferHandle()| and |MapBuffer()|. |
| 1314 | 1313 |
| 1315 } // namespace | 1314 } // namespace |
| 1316 } // namespace system | 1315 } // namespace system |
| 1317 } // namespace mojo | 1316 } // namespace mojo |
| OLD | NEW |