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

Unified Diff: mojo/python/tests/async_wait_unittest.py

Issue 573253002: mojo: Add async waiter for python bindings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compilation due to pre-processor variable Created 6 years, 3 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/public/python/src/python_system_helper.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/python/tests/async_wait_unittest.py
diff --git a/mojo/python/tests/async_wait_unittest.py b/mojo/python/tests/async_wait_unittest.py
new file mode 100644
index 0000000000000000000000000000000000000000..c80cae0f7a8da4fbf2ca1fdf1e1b7e50300c5fb9
--- /dev/null
+++ b/mojo/python/tests/async_wait_unittest.py
@@ -0,0 +1,51 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import unittest
+
+# pylint: disable=F0401
+import mojo.embedder
+from mojo import system
+
+
+class AsyncWaitTest(unittest.TestCase):
+
+ def setUp(self):
+ mojo.embedder.Init()
+ self.loop = system.RunLoop()
+ self.array = []
+ self.handles = system.MessagePipe()
+ self.cancel = self.handles.handle0.AsyncWait(system.HANDLE_SIGNAL_READABLE,
+ system.DEADLINE_INDEFINITE,
+ self.OnResult)
+ self.loop.PostDelayedTask(self.WriteToHandle, 100)
+
+ def tearDown(self):
+ self.handles = None
+ self.array = None
+ self.loop = None
+
+ def OnResult(self, value):
+ self.array.append(value)
+
+ def WriteToHandle(self):
+ self.handles.handle1.WriteMessage()
+
+ def testAsyncWait(self):
+ self.loop.RunUntilIdle()
+ self.assertEquals(len(self.array), 1)
+ self.assertEquals(system.RESULT_OK, self.array[0])
+ self.cancel()
+
+ def testAsyncWaitCancel(self):
+ self.loop.PostDelayedTask(self.cancel, 50)
+ self.loop.RunUntilIdle()
+ self.assertEquals(len(self.array), 0)
+ self.cancel()
+
+ def testAsyncWaitImmediateCancel(self):
+ self.cancel()
+ self.loop.RunUntilIdle()
+ self.assertEquals(len(self.array), 0)
+ self.cancel()
« no previous file with comments | « mojo/public/python/src/python_system_helper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698