Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Side by Side Diff: mojo/public/cpp/system/tests/core_unittest.cc

Issue 1825553002: Properly "handle" MOJO_RESULT_BUSY in a few flaces. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/message_pump/message_pump_mojo.cc ('k') | mojo/public/cpp/system/wait.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « mojo/message_pump/message_pump_mojo.cc ('k') | mojo/public/cpp/system/wait.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698