| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // This file tests the C wait API (the functions declared in | |
| 6 // mojo/public/c/include/mojo/system/wait.h). | |
| 7 | |
| 8 #include <mojo/system/wait.h> | |
| 9 | |
| 10 #include <mojo/result.h> | |
| 11 #include <mojo/system/handle.h> | |
| 12 | |
| 13 #include "gtest/gtest.h" | |
| 14 | |
| 15 namespace { | |
| 16 | |
| 17 TEST(WaitTest, InvalidHandle) { | |
| 18 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, | |
| 19 MojoWait(MOJO_HANDLE_INVALID, ~MOJO_HANDLE_SIGNAL_NONE, 1000000u, | |
| 20 nullptr)); | |
| 21 | |
| 22 const MojoHandle h = MOJO_HANDLE_INVALID; | |
| 23 MojoHandleSignals sig = ~MOJO_HANDLE_SIGNAL_NONE; | |
| 24 EXPECT_EQ( | |
| 25 MOJO_RESULT_INVALID_ARGUMENT, | |
| 26 MojoWaitMany(&h, &sig, 1u, MOJO_DEADLINE_INDEFINITE, nullptr, nullptr)); | |
| 27 } | |
| 28 | |
| 29 TEST(WaitTest, WaitManyNoHandles) { | |
| 30 EXPECT_EQ(MOJO_RESULT_DEADLINE_EXCEEDED, | |
| 31 MojoWaitMany(nullptr, nullptr, 0u, static_cast<MojoDeadline>(0), | |
| 32 nullptr, nullptr)); | |
| 33 | |
| 34 // The |result_index| argument is optional, so make sure it doesn't touch it | |
| 35 // even if it's non-null. | |
| 36 // TODO(vtl): The same is true for the |signals_states| argument. | |
| 37 uint32_t result_index = static_cast<uint32_t>(-1); | |
| 38 EXPECT_EQ(MOJO_RESULT_DEADLINE_EXCEEDED, | |
| 39 MojoWaitMany(nullptr, nullptr, 0u, static_cast<MojoDeadline>(1000), | |
| 40 &result_index, nullptr)); | |
| 41 EXPECT_EQ(static_cast<uint32_t>(-1), result_index); | |
| 42 } | |
| 43 | |
| 44 // TODO(vtl): Write tests that actually test waiting. | |
| 45 | |
| 46 } // namespace | |
| OLD | NEW |