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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « mojo/public/python/src/python_system_helper.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 # found in the LICENSE file.
4
5 import unittest
6
7 # pylint: disable=F0401
8 import mojo.embedder
9 from mojo import system
10
11
12 class AsyncWaitTest(unittest.TestCase):
13
14 def setUp(self):
15 mojo.embedder.Init()
16 self.loop = system.RunLoop()
17 self.array = []
18 self.handles = system.MessagePipe()
19 self.cancel = self.handles.handle0.AsyncWait(system.HANDLE_SIGNAL_READABLE,
20 system.DEADLINE_INDEFINITE,
21 self.OnResult)
22 self.loop.PostDelayedTask(self.WriteToHandle, 100)
23
24 def tearDown(self):
25 self.handles = None
26 self.array = None
27 self.loop = None
28
29 def OnResult(self, value):
30 self.array.append(value)
31
32 def WriteToHandle(self):
33 self.handles.handle1.WriteMessage()
34
35 def testAsyncWait(self):
36 self.loop.RunUntilIdle()
37 self.assertEquals(len(self.array), 1)
38 self.assertEquals(system.RESULT_OK, self.array[0])
39 self.cancel()
40
41 def testAsyncWaitCancel(self):
42 self.loop.PostDelayedTask(self.cancel, 50)
43 self.loop.RunUntilIdle()
44 self.assertEquals(len(self.array), 0)
45 self.cancel()
46
47 def testAsyncWaitImmediateCancel(self):
48 self.cancel()
49 self.loop.RunUntilIdle()
50 self.assertEquals(len(self.array), 0)
51 self.cancel()
OLDNEW
« 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