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

Side by Side Diff: mojo/python/tests/runloop_unittest.py

Issue 675563002: Remove mojo/python and gyp targets (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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/python/tests/promise_unittest.py ('k') | mojo/python/tests/system_unittest.py » ('j') | 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 mojo_unittest
6
7 # pylint: disable=E0611
8 from mojo import system
9
10
11 def _Increment(array):
12 def _Closure():
13 array.append(0)
14 return _Closure
15
16
17 class RunLoopTest(mojo_unittest.MojoTestCase):
18
19 def testRunLoop(self):
20 array = []
21 for _ in xrange(10):
22 self.loop.PostDelayedTask(_Increment(array))
23 self.loop.RunUntilIdle()
24 self.assertEquals(len(array), 10)
25
26 def testRunLoopWithException(self):
27 def Throw():
28 raise Exception("error")
29 array = []
30 self.loop.PostDelayedTask(Throw)
31 self.loop.PostDelayedTask(_Increment(array))
32 with self.assertRaisesRegexp(Exception, '^error$'):
33 self.loop.Run()
34 self.assertEquals(len(array), 0)
35 self.loop.RunUntilIdle()
36 self.assertEquals(len(array), 1)
37
38 def testCurrent(self):
39 self.assertEquals(system.RunLoop.Current(), self.loop)
40 self.loop = None
41 self.assertIsNone(system.RunLoop.Current())
OLDNEW
« no previous file with comments | « mojo/python/tests/promise_unittest.py ('k') | mojo/python/tests/system_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698