| 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 <stddef.h> | 9 #include <stddef.h> |
| 10 | 10 |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 TEST(CoreCppTest, ScopedHandleMoveCtorSelf) { | 486 TEST(CoreCppTest, ScopedHandleMoveCtorSelf) { |
| 487 ScopedSharedBufferHandle buffer1; | 487 ScopedSharedBufferHandle buffer1; |
| 488 EXPECT_EQ(MOJO_RESULT_OK, CreateSharedBuffer(nullptr, 1024, &buffer1)); | 488 EXPECT_EQ(MOJO_RESULT_OK, CreateSharedBuffer(nullptr, 1024, &buffer1)); |
| 489 EXPECT_TRUE(buffer1.is_valid()); | 489 EXPECT_TRUE(buffer1.is_valid()); |
| 490 | 490 |
| 491 buffer1 = buffer1.Pass(); | 491 buffer1 = buffer1.Pass(); |
| 492 | 492 |
| 493 EXPECT_TRUE(buffer1.is_valid()); | 493 EXPECT_TRUE(buffer1.is_valid()); |
| 494 } | 494 } |
| 495 | 495 |
| 496 TEST(CoreCppTest, WaitManyResult) { |
| 497 { |
| 498 WaitManyResult wmr(MOJO_RESULT_OK); |
| 499 EXPECT_FALSE(wmr.IsIndexValid()); |
| 500 EXPECT_TRUE(wmr.AreSignalsStatesValid()); |
| 501 EXPECT_EQ(MOJO_RESULT_OK, wmr.result); |
| 502 } |
| 503 |
| 504 { |
| 505 WaitManyResult wmr(MOJO_RESULT_FAILED_PRECONDITION); |
| 506 EXPECT_FALSE(wmr.IsIndexValid()); |
| 507 EXPECT_TRUE(wmr.AreSignalsStatesValid()); |
| 508 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, wmr.result); |
| 509 } |
| 510 |
| 511 { |
| 512 WaitManyResult wmr(MOJO_RESULT_INVALID_ARGUMENT); |
| 513 EXPECT_FALSE(wmr.IsIndexValid()); |
| 514 EXPECT_FALSE(wmr.AreSignalsStatesValid()); |
| 515 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, wmr.result); |
| 516 } |
| 517 |
| 518 // These should be like "invalid argument". |
| 519 EXPECT_FALSE( |
| 520 WaitManyResult(MOJO_RESULT_RESOURCE_EXHAUSTED).AreSignalsStatesValid()); |
| 521 EXPECT_FALSE(WaitManyResult(MOJO_RESULT_BUSY).AreSignalsStatesValid()); |
| 522 |
| 523 { |
| 524 WaitManyResult wmr(MOJO_RESULT_OK, 5u); |
| 525 EXPECT_TRUE(wmr.IsIndexValid()); |
| 526 EXPECT_TRUE(wmr.AreSignalsStatesValid()); |
| 527 EXPECT_EQ(MOJO_RESULT_OK, wmr.result); |
| 528 EXPECT_EQ(5u, wmr.index); |
| 529 } |
| 530 |
| 531 { |
| 532 WaitManyResult wmr(MOJO_RESULT_FAILED_PRECONDITION, 5u); |
| 533 EXPECT_TRUE(wmr.IsIndexValid()); |
| 534 EXPECT_TRUE(wmr.AreSignalsStatesValid()); |
| 535 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, wmr.result); |
| 536 EXPECT_EQ(5u, wmr.index); |
| 537 } |
| 538 } |
| 539 |
| 496 // TODO(vtl): Write data pipe tests. | 540 // TODO(vtl): Write data pipe tests. |
| 497 | 541 |
| 498 } // namespace | 542 } // namespace |
| 499 } // namespace mojo | 543 } // namespace mojo |
| OLD | NEW |