OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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++ Mojo system core wrappers. | 5 // This file tests the C++ Mojo system core wrappers. |
6 // TODO(vtl): Maybe rename "CoreCppTest" -> "CoreTest" if/when this gets | 6 // TODO(vtl): Maybe rename "CoreCppTest" -> "CoreTest" if/when this gets |
7 // compiled into a different binary from the C API tests. | 7 // compiled into a different binary from the C API tests. |
8 | 8 |
9 #include "mojo/public/cpp/system/core.h" | 9 #include "mojo/public/cpp/system/core.h" |
10 | 10 |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 // Tear down a message pipe which still has a message enqueued, with the | 359 // Tear down a message pipe which still has a message enqueued, with the |
360 // message also having a valid message pipe handle. | 360 // message also having a valid message pipe handle. |
361 { | 361 { |
362 ScopedMessagePipeHandle h0; | 362 ScopedMessagePipeHandle h0; |
363 ScopedMessagePipeHandle h1; | 363 ScopedMessagePipeHandle h1; |
364 CreateMessagePipe(nullptr, &h0, &h1); | 364 CreateMessagePipe(nullptr, &h0, &h1); |
365 | 365 |
366 // Send a handle over the previously-establish message pipe. | 366 // Send a handle over the previously-establish message pipe. |
367 ScopedMessagePipeHandle h2; | 367 ScopedMessagePipeHandle h2; |
368 ScopedMessagePipeHandle h3; | 368 ScopedMessagePipeHandle h3; |
369 CreateMessagePipe(nullptr, &h2, &h3); | 369 MojoCreateMessagePipeOptions options; |
| 370 options.struct_size = sizeof(MojoCreateMessagePipeOptions); |
| 371 options.flags = MOJO_CREATE_MESSAGE_PIPE_OPTIONS_FLAG_TRANSFERABLE; |
| 372 if (CreateMessagePipe(&options, &h2, &h3) != MOJO_RESULT_OK) |
| 373 CreateMessagePipe(nullptr, &h2, &h3); // Must be old EDK. |
370 | 374 |
371 // Write a message to |h2|, before we send |h3|. | 375 // Write a message to |h2|, before we send |h3|. |
372 const char kWorld[] = "world!"; | 376 const char kWorld[] = "world!"; |
373 const uint32_t kWorldSize = static_cast<uint32_t>(sizeof(kWorld)); | 377 const uint32_t kWorldSize = static_cast<uint32_t>(sizeof(kWorld)); |
374 EXPECT_EQ(MOJO_RESULT_OK, | 378 EXPECT_EQ(MOJO_RESULT_OK, |
375 WriteMessageRaw(h2.get(), | 379 WriteMessageRaw(h2.get(), |
376 kWorld, | 380 kWorld, |
377 kWorldSize, | 381 kWorldSize, |
378 nullptr, | 382 nullptr, |
379 0, | 383 0, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 // Do this in a different order: make the enqueued message pipe handle only | 416 // Do this in a different order: make the enqueued message pipe handle only |
413 // half-alive. | 417 // half-alive. |
414 { | 418 { |
415 ScopedMessagePipeHandle h0; | 419 ScopedMessagePipeHandle h0; |
416 ScopedMessagePipeHandle h1; | 420 ScopedMessagePipeHandle h1; |
417 CreateMessagePipe(nullptr, &h0, &h1); | 421 CreateMessagePipe(nullptr, &h0, &h1); |
418 | 422 |
419 // Send a handle over the previously-establish message pipe. | 423 // Send a handle over the previously-establish message pipe. |
420 ScopedMessagePipeHandle h2; | 424 ScopedMessagePipeHandle h2; |
421 ScopedMessagePipeHandle h3; | 425 ScopedMessagePipeHandle h3; |
422 CreateMessagePipe(nullptr, &h2, &h3); | 426 MojoCreateMessagePipeOptions options; |
| 427 options.struct_size = sizeof(MojoCreateMessagePipeOptions); |
| 428 options.flags = MOJO_CREATE_MESSAGE_PIPE_OPTIONS_FLAG_TRANSFERABLE; |
| 429 if (CreateMessagePipe(&options, &h2, &h3) != MOJO_RESULT_OK) |
| 430 CreateMessagePipe(nullptr, &h2, &h3); // Must be old EDK. |
423 | 431 |
424 // Write a message to |h2|, before we send |h3|. | 432 // Write a message to |h2|, before we send |h3|. |
425 const char kWorld[] = "world!"; | 433 const char kWorld[] = "world!"; |
426 const uint32_t kWorldSize = static_cast<uint32_t>(sizeof(kWorld)); | 434 const uint32_t kWorldSize = static_cast<uint32_t>(sizeof(kWorld)); |
427 EXPECT_EQ(MOJO_RESULT_OK, | 435 EXPECT_EQ(MOJO_RESULT_OK, |
428 WriteMessageRaw(h2.get(), | 436 WriteMessageRaw(h2.get(), |
429 kWorld, | 437 kWorld, |
430 kWorldSize, | 438 kWorldSize, |
431 nullptr, | 439 nullptr, |
432 0, | 440 0, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 buffer1 = std::move(buffer2); | 485 buffer1 = std::move(buffer2); |
478 | 486 |
479 EXPECT_TRUE(buffer1.is_valid()); | 487 EXPECT_TRUE(buffer1.is_valid()); |
480 EXPECT_FALSE(buffer2.is_valid()); | 488 EXPECT_FALSE(buffer2.is_valid()); |
481 } | 489 } |
482 | 490 |
483 // TODO(vtl): Write data pipe tests. | 491 // TODO(vtl): Write data pipe tests. |
484 | 492 |
485 } // namespace | 493 } // namespace |
486 } // namespace mojo | 494 } // namespace mojo |
OLD | NEW |