1 // Copyright 2017 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 #include "mojo/public/cpp/system/handle_signals_state.h" 6 7 #include "mojo/public/c/system/types.h" 8 #include "testing/gtest/include/gtest/gtest.h" 9 10 namespace mojo { 11 namespace { 12 13 using HandleSignalsStateTest = testing::Test; 14 TEST_F(HandleSignalsStateTest,SanityCheck)15TEST_F(HandleSignalsStateTest, SanityCheck) { 16 // There's not much to test here. Just a quick sanity check to make sure the 17 // code compiles and the helper methods do what they're supposed to do. 18 19 HandleSignalsState empty_signals(MOJO_HANDLE_SIGNAL_NONE, 20 MOJO_HANDLE_SIGNAL_NONE); 21 EXPECT_FALSE(empty_signals.readable()); 22 EXPECT_FALSE(empty_signals.writable()); 23 EXPECT_FALSE(empty_signals.peer_closed()); 24 EXPECT_FALSE(empty_signals.peer_remote()); 25 EXPECT_TRUE(empty_signals.never_readable()); 26 EXPECT_TRUE(empty_signals.never_writable()); 27 EXPECT_TRUE(empty_signals.never_peer_closed()); 28 EXPECT_TRUE(empty_signals.never_peer_remote()); 29 30 HandleSignalsState all_signals( 31 MOJO_HANDLE_SIGNAL_READABLE | MOJO_HANDLE_SIGNAL_WRITABLE | 32 MOJO_HANDLE_SIGNAL_PEER_CLOSED | MOJO_HANDLE_SIGNAL_PEER_REMOTE, 33 MOJO_HANDLE_SIGNAL_READABLE | MOJO_HANDLE_SIGNAL_WRITABLE | 34 MOJO_HANDLE_SIGNAL_PEER_CLOSED | MOJO_HANDLE_SIGNAL_PEER_REMOTE); 35 EXPECT_TRUE(all_signals.readable()); 36 EXPECT_TRUE(all_signals.writable()); 37 EXPECT_TRUE(all_signals.peer_closed()); 38 EXPECT_TRUE(all_signals.peer_remote()); 39 EXPECT_FALSE(all_signals.never_readable()); 40 EXPECT_FALSE(all_signals.never_writable()); 41 EXPECT_FALSE(all_signals.never_peer_closed()); 42 EXPECT_FALSE(all_signals.never_peer_remote()); 43 } 44 45 } // namespace 46 } // namespace mojo 47