| OLD | NEW |
| 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 handle API (the functions declared in | 5 // This file tests the C handle API (the functions declared in |
| 6 // mojo/public/c/include/mojo/system/handle.h). Note: The functionality of these | 6 // mojo/public/c/include/mojo/system/handle.h). Note: The functionality of these |
| 7 // APIs for specific types of handles are tested with the APIs for those types | 7 // APIs for specific types of handles are tested with the APIs for those types |
| 8 // of handles. | 8 // of handles. |
| 9 | 9 |
| 10 #include <mojo/system/handle.h> | 10 #include <mojo/system/handle.h> |
| 11 | 11 |
| 12 #include <mojo/result.h> | 12 #include <mojo/result.h> |
| 13 #include <mojo/system/message_pipe.h> | 13 #include <mojo/system/message_pipe.h> |
| 14 | 14 |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "gtest/gtest.h" |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 const MojoHandleRights kDefaultMessagePipeHandleRights = | 19 const MojoHandleRights kDefaultMessagePipeHandleRights = |
| 20 MOJO_HANDLE_RIGHT_TRANSFER | MOJO_HANDLE_RIGHT_READ | | 20 MOJO_HANDLE_RIGHT_TRANSFER | MOJO_HANDLE_RIGHT_READ | |
| 21 MOJO_HANDLE_RIGHT_WRITE | MOJO_HANDLE_RIGHT_GET_OPTIONS | | 21 MOJO_HANDLE_RIGHT_WRITE | MOJO_HANDLE_RIGHT_GET_OPTIONS | |
| 22 MOJO_HANDLE_RIGHT_SET_OPTIONS; | 22 MOJO_HANDLE_RIGHT_SET_OPTIONS; |
| 23 | 23 |
| 24 TEST(HandleTest, InvalidHandle) { | 24 TEST(HandleTest, InvalidHandle) { |
| 25 // MojoClose: | 25 // MojoClose: |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 // Make sure that the rights are actually correctly enforced. | 109 // Make sure that the rights are actually correctly enforced. |
| 110 EXPECT_EQ( | 110 EXPECT_EQ( |
| 111 MOJO_RESULT_PERMISSION_DENIED, | 111 MOJO_RESULT_PERMISSION_DENIED, |
| 112 MojoWriteMessage(h0r1, &x, 1u, nullptr, 0, MOJO_WRITE_MESSAGE_FLAG_NONE)); | 112 MojoWriteMessage(h0r1, &x, 1u, nullptr, 0, MOJO_WRITE_MESSAGE_FLAG_NONE)); |
| 113 | 113 |
| 114 EXPECT_EQ(MOJO_RESULT_OK, MojoClose(h0r1)); | 114 EXPECT_EQ(MOJO_RESULT_OK, MojoClose(h0r1)); |
| 115 EXPECT_EQ(MOJO_RESULT_OK, MojoClose(h1)); | 115 EXPECT_EQ(MOJO_RESULT_OK, MojoClose(h1)); |
| 116 } | 116 } |
| 117 | 117 |
| 118 } // namespace | 118 } // namespace |
| OLD | NEW |