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 data pipe API (the functions declared in | 5 // This file tests the C data pipe API (the functions declared in |
6 // mojo/public/c/system/data_pipe.h). | 6 // mojo/public/c/system/data_pipe.h). |
7 | 7 |
8 #include "mojo/public/c/system/data_pipe.h" | 8 #include "mojo/public/c/system/data_pipe.h" |
9 | 9 |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 MojoReadData(MOJO_HANDLE_INVALID, buffer, &buffer_size, | 56 MojoReadData(MOJO_HANDLE_INVALID, buffer, &buffer_size, |
57 MOJO_READ_DATA_FLAG_NONE)); | 57 MOJO_READ_DATA_FLAG_NONE)); |
58 const void* read_pointer = nullptr; | 58 const void* read_pointer = nullptr; |
59 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, | 59 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, |
60 MojoBeginReadData(MOJO_HANDLE_INVALID, &read_pointer, &buffer_size, | 60 MojoBeginReadData(MOJO_HANDLE_INVALID, &read_pointer, &buffer_size, |
61 MOJO_READ_DATA_FLAG_NONE)); | 61 MOJO_READ_DATA_FLAG_NONE)); |
62 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, | 62 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, |
63 MojoEndReadData(MOJO_HANDLE_INVALID, 1u)); | 63 MojoEndReadData(MOJO_HANDLE_INVALID, 1u)); |
64 } | 64 } |
65 | 65 |
66 // TODO(ncbray): enable this test once NaCl supports the corresponding APIs. | 66 TEST(DataPipeTest, Basic) { |
67 #ifdef __native_client__ | |
68 #define MAYBE_Basic DISABLED_Basic | |
69 #else | |
70 #define MAYBE_Basic Basic | |
71 #endif | |
72 TEST(DataPipeTest, MAYBE_Basic) { | |
73 MojoHandle hp = MOJO_HANDLE_INVALID; | 67 MojoHandle hp = MOJO_HANDLE_INVALID; |
74 MojoHandle hc = MOJO_HANDLE_INVALID; | 68 MojoHandle hc = MOJO_HANDLE_INVALID; |
75 EXPECT_EQ(MOJO_RESULT_OK, MojoCreateDataPipe(nullptr, &hp, &hc)); | 69 EXPECT_EQ(MOJO_RESULT_OK, MojoCreateDataPipe(nullptr, &hp, &hc)); |
76 EXPECT_NE(hp, MOJO_HANDLE_INVALID); | 70 EXPECT_NE(hp, MOJO_HANDLE_INVALID); |
77 EXPECT_NE(hc, MOJO_HANDLE_INVALID); | 71 EXPECT_NE(hc, MOJO_HANDLE_INVALID); |
78 EXPECT_NE(hp, hc); | 72 EXPECT_NE(hp, hc); |
79 | 73 |
80 // Both handles should have the correct rights. | 74 // Both handles should have the correct rights. |
81 MojoHandleRights rights = MOJO_HANDLE_RIGHT_NONE; | 75 MojoHandleRights rights = MOJO_HANDLE_RIGHT_NONE; |
82 EXPECT_EQ(MOJO_RESULT_OK, MojoGetRights(hp, &rights)); | 76 EXPECT_EQ(MOJO_RESULT_OK, MojoGetRights(hp, &rights)); |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 EXPECT_EQ(MOJO_RESULT_OK, | 431 EXPECT_EQ(MOJO_RESULT_OK, |
438 MojoWait(hc, MOJO_HANDLE_SIGNAL_READ_THRESHOLD, 0, nullptr)); | 432 MojoWait(hc, MOJO_HANDLE_SIGNAL_READ_THRESHOLD, 0, nullptr)); |
439 | 433 |
440 EXPECT_EQ(MOJO_RESULT_OK, MojoClose(hp)); | 434 EXPECT_EQ(MOJO_RESULT_OK, MojoClose(hp)); |
441 EXPECT_EQ(MOJO_RESULT_OK, MojoClose(hc)); | 435 EXPECT_EQ(MOJO_RESULT_OK, MojoClose(hc)); |
442 } | 436 } |
443 | 437 |
444 // TODO(vtl): Add multi-threaded tests. | 438 // TODO(vtl): Add multi-threaded tests. |
445 | 439 |
446 } // namespace | 440 } // namespace |
OLD | NEW |