Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Side by Side Diff: mojo/public/c/system/tests/wait_unittest.cc

Issue 2110103002: Make MojoWaitMany() accept zero handles. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/edk/system/core_unittest.cc ('k') | mojo/public/c/system/wait.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 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 // This file tests the C wait API (the functions declared in 5 // This file tests the C wait API (the functions declared in
6 // mojo/public/c/system/wait.h). 6 // mojo/public/c/system/wait.h).
7 7
8 #include "mojo/public/c/system/wait.h" 8 #include "mojo/public/c/system/wait.h"
9 9
10 #include "mojo/public/c/system/handle.h" 10 #include "mojo/public/c/system/handle.h"
11 #include "mojo/public/c/system/result.h" 11 #include "mojo/public/c/system/result.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace { 14 namespace {
15 15
16 TEST(WaitTest, InvalidHandle) { 16 TEST(WaitTest, InvalidHandle) {
17 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, 17 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
18 MojoWait(MOJO_HANDLE_INVALID, ~MOJO_HANDLE_SIGNAL_NONE, 1000000u, 18 MojoWait(MOJO_HANDLE_INVALID, ~MOJO_HANDLE_SIGNAL_NONE, 1000000u,
19 nullptr)); 19 nullptr));
20 20
21 const MojoHandle h = MOJO_HANDLE_INVALID; 21 const MojoHandle h = MOJO_HANDLE_INVALID;
22 MojoHandleSignals sig = ~MOJO_HANDLE_SIGNAL_NONE; 22 MojoHandleSignals sig = ~MOJO_HANDLE_SIGNAL_NONE;
23 EXPECT_EQ( 23 EXPECT_EQ(
24 MOJO_RESULT_INVALID_ARGUMENT, 24 MOJO_RESULT_INVALID_ARGUMENT,
25 MojoWaitMany(&h, &sig, 1u, MOJO_DEADLINE_INDEFINITE, nullptr, nullptr)); 25 MojoWaitMany(&h, &sig, 1u, MOJO_DEADLINE_INDEFINITE, nullptr, nullptr));
26 } 26 }
27 27
28 TEST(WaitTest, WaitManyNoHandles) {
29 EXPECT_EQ(MOJO_RESULT_DEADLINE_EXCEEDED,
30 MojoWaitMany(nullptr, nullptr, 0u, static_cast<MojoDeadline>(0),
31 nullptr, nullptr));
32
33 // The |result_index| argument is optional, so make sure it doesn't touch it
34 // even if it's non-null.
35 // TODO(vtl): The same is true for the |signals_states| argument.
36 uint32_t result_index = static_cast<uint32_t>(-1);
37 EXPECT_EQ(MOJO_RESULT_DEADLINE_EXCEEDED,
38 MojoWaitMany(nullptr, nullptr, 0u, static_cast<MojoDeadline>(1000),
39 &result_index, nullptr));
40 EXPECT_EQ(static_cast<uint32_t>(-1), result_index);
41 }
42
28 // TODO(vtl): Write tests that actually test waiting. 43 // TODO(vtl): Write tests that actually test waiting.
29 44
30 } // namespace 45 } // namespace
OLDNEW
« no previous file with comments | « mojo/edk/system/core_unittest.cc ('k') | mojo/public/c/system/wait.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698