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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/system/tests/core_unittest.cc
diff --git a/mojo/public/cpp/system/tests/core_unittest.cc b/mojo/public/cpp/system/tests/core_unittest.cc
index 686f6c626efb3859f4705107b00de3166014ceee..6df03bfc410217241fb14709b12c9cfa2a9b15eb 100644
--- a/mojo/public/cpp/system/tests/core_unittest.cc
+++ b/mojo/public/cpp/system/tests/core_unittest.cc
@@ -493,6 +493,50 @@ TEST(CoreCppTest, ScopedHandleMoveCtorSelf) {
EXPECT_TRUE(buffer1.is_valid());
}
+TEST(CoreCppTest, WaitManyResult) {
+ {
+ WaitManyResult wmr(MOJO_RESULT_OK);
+ EXPECT_FALSE(wmr.IsIndexValid());
+ EXPECT_TRUE(wmr.AreSignalsStatesValid());
+ EXPECT_EQ(MOJO_RESULT_OK, wmr.result);
+ }
+
+ {
+ WaitManyResult wmr(MOJO_RESULT_FAILED_PRECONDITION);
+ EXPECT_FALSE(wmr.IsIndexValid());
+ EXPECT_TRUE(wmr.AreSignalsStatesValid());
+ EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, wmr.result);
+ }
+
+ {
+ WaitManyResult wmr(MOJO_RESULT_INVALID_ARGUMENT);
+ EXPECT_FALSE(wmr.IsIndexValid());
+ EXPECT_FALSE(wmr.AreSignalsStatesValid());
+ EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, wmr.result);
+ }
+
+ // These should be like "invalid argument".
+ EXPECT_FALSE(
+ WaitManyResult(MOJO_RESULT_RESOURCE_EXHAUSTED).AreSignalsStatesValid());
+ EXPECT_FALSE(WaitManyResult(MOJO_RESULT_BUSY).AreSignalsStatesValid());
+
+ {
+ WaitManyResult wmr(MOJO_RESULT_OK, 5u);
+ EXPECT_TRUE(wmr.IsIndexValid());
+ EXPECT_TRUE(wmr.AreSignalsStatesValid());
+ EXPECT_EQ(MOJO_RESULT_OK, wmr.result);
+ EXPECT_EQ(5u, wmr.index);
+ }
+
+ {
+ WaitManyResult wmr(MOJO_RESULT_FAILED_PRECONDITION, 5u);
+ EXPECT_TRUE(wmr.IsIndexValid());
+ EXPECT_TRUE(wmr.AreSignalsStatesValid());
+ EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, wmr.result);
+ EXPECT_EQ(5u, wmr.index);
+ }
+}
+
// TODO(vtl): Write data pipe tests.
} // namespace
« 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