| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 API. | 5 // This file tests the C API. |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include "mojo/public/c/system/buffer.h" | 9 #include "mojo/public/c/system/buffer.h" |
| 10 #include "mojo/public/c/system/data_pipe.h" | 10 #include "mojo/public/c/system/data_pipe.h" |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 | 404 |
| 405 // Set the read threshold to 2. | 405 // Set the read threshold to 2. |
| 406 copts.struct_size = kCoptsSize; | 406 copts.struct_size = kCoptsSize; |
| 407 copts.read_threshold_num_bytes = 2u; | 407 copts.read_threshold_num_bytes = 2u; |
| 408 EXPECT_EQ(MOJO_RESULT_OK, MojoSetDataPipeConsumerOptions(hc, &copts)); | 408 EXPECT_EQ(MOJO_RESULT_OK, MojoSetDataPipeConsumerOptions(hc, &copts)); |
| 409 | 409 |
| 410 // Should have the read threshold signal again. | 410 // Should have the read threshold signal again. |
| 411 EXPECT_EQ(MOJO_RESULT_OK, | 411 EXPECT_EQ(MOJO_RESULT_OK, |
| 412 MojoWait(hc, MOJO_HANDLE_SIGNAL_READ_THRESHOLD, 0, nullptr)); | 412 MojoWait(hc, MOJO_HANDLE_SIGNAL_READ_THRESHOLD, 0, nullptr)); |
| 413 | 413 |
| 414 // Set the read threshold to the default by passing null, and check it. |
| 415 EXPECT_EQ(MOJO_RESULT_OK, MojoSetDataPipeConsumerOptions(hc, nullptr)); |
| 416 |
| 417 memset(&copts, 255, kCoptsSize); |
| 418 EXPECT_EQ(MOJO_RESULT_OK, |
| 419 MojoGetDataPipeConsumerOptions(hc, &copts, kCoptsSize)); |
| 420 EXPECT_EQ(kCoptsSize, copts.struct_size); |
| 421 EXPECT_EQ(0u, copts.read_threshold_num_bytes); |
| 422 |
| 423 // Should still have the read threshold signal. |
| 424 EXPECT_EQ(MOJO_RESULT_OK, |
| 425 MojoWait(hc, MOJO_HANDLE_SIGNAL_READ_THRESHOLD, 0, nullptr)); |
| 426 |
| 414 EXPECT_EQ(MOJO_RESULT_OK, MojoClose(hp)); | 427 EXPECT_EQ(MOJO_RESULT_OK, MojoClose(hp)); |
| 415 EXPECT_EQ(MOJO_RESULT_OK, MojoClose(hc)); | 428 EXPECT_EQ(MOJO_RESULT_OK, MojoClose(hc)); |
| 416 } | 429 } |
| 417 | 430 |
| 418 // TODO(ncbray): enable this test once NaCl supports the corresponding APIs. | 431 // TODO(ncbray): enable this test once NaCl supports the corresponding APIs. |
| 419 #ifdef __native_client__ | 432 #ifdef __native_client__ |
| 420 #define MAYBE_BasicSharedBuffer DISABLED_BasicSharedBuffer | 433 #define MAYBE_BasicSharedBuffer DISABLED_BasicSharedBuffer |
| 421 #else | 434 #else |
| 422 #define MAYBE_BasicSharedBuffer BasicSharedBuffer | 435 #define MAYBE_BasicSharedBuffer BasicSharedBuffer |
| 423 #endif | 436 #endif |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 | 503 |
| 491 TEST(CoreTest, MinimalCppTest) { | 504 TEST(CoreTest, MinimalCppTest) { |
| 492 const char* failure = MinimalCppTest(); | 505 const char* failure = MinimalCppTest(); |
| 493 EXPECT_FALSE(failure) << failure; | 506 EXPECT_FALSE(failure) << failure; |
| 494 } | 507 } |
| 495 | 508 |
| 496 // TODO(vtl): Add multi-threaded tests. | 509 // TODO(vtl): Add multi-threaded tests. |
| 497 | 510 |
| 498 } // namespace | 511 } // namespace |
| 499 } // namespace mojo | 512 } // namespace mojo |
| OLD | NEW |