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

Unified Diff: mojo/edk/system/core_unittest.cc

Issue 798993003: Add embedder::AsyncWait() (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Updated Created 6 years 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
« mojo/edk/system/core_test_base.cc ('K') | « mojo/edk/system/core_test_base.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/core_unittest.cc
diff --git a/mojo/edk/system/core_unittest.cc b/mojo/edk/system/core_unittest.cc
index d7976a313dbfa970a44bec0e66cda8272538fd6b..f6f257555e5a4c13f4d86e784d892f6d291b279e 100644
--- a/mojo/edk/system/core_unittest.cc
+++ b/mojo/edk/system/core_unittest.cc
@@ -8,8 +8,10 @@
#include <limits>
+#include "base/bind.h"
#include "base/threading/platform_thread.h"
#include "base/time/time.h"
+#include "mojo/edk/system/awakable.h"
#include "mojo/edk/system/core_test_base.h"
namespace mojo {
@@ -1276,6 +1278,38 @@ TEST_F(CoreTest, MessagePipeBasicLocalHandlePassing2) {
EXPECT_EQ(MOJO_RESULT_OK, core()->Close(ch));
}
+struct TestAsyncWaiter {
+ TestAsyncWaiter() : result(MOJO_RESULT_UNKNOWN) {}
+
+ void Awake(MojoResult r) { result = r; }
+
+ MojoResult result;
+};
+
+TEST_F(CoreTest, AsyncWait) {
+ TestAsyncWaiter waiter;
+ MockHandleInfo info;
+ MojoHandle h = CreateMockHandle(&info);
+
+ EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION,
+ core()->AsyncWait(h, MOJO_HANDLE_SIGNAL_READABLE,
+ base::Bind(&TestAsyncWaiter::Awake,
+ base::Unretained(&waiter))));
+ EXPECT_EQ(0u, info.GetAddedAwakableSize());
+
+ info.AllowAddAwakable(true);
+ EXPECT_EQ(MOJO_RESULT_OK,
+ core()->AsyncWait(h, MOJO_HANDLE_SIGNAL_READABLE,
+ base::Bind(&TestAsyncWaiter::Awake,
+ base::Unretained(&waiter))));
+ EXPECT_EQ(1u, info.GetAddedAwakableSize());
+
+ EXPECT_EQ(false, info.GetAddedAwakableAt(0)->Awake(MOJO_RESULT_BUSY, 0));
+ EXPECT_EQ(MOJO_RESULT_BUSY, waiter.result);
+
+ EXPECT_EQ(MOJO_RESULT_OK, core()->Close(h));
+}
+
// TODO(vtl): Test |DuplicateBufferHandle()| and |MapBuffer()|.
} // namespace
« mojo/edk/system/core_test_base.cc ('K') | « mojo/edk/system/core_test_base.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698