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

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

Issue 644773002: mojo: Add RunLoop::Current() and refactor unit tests. (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 side-by-side diff with in-line comments
Download patch
Index: mojo/python/tests/runloop_unittest.py
diff --git a/mojo/python/tests/runloop_unittest.py b/mojo/python/tests/runloop_unittest.py
index 3549dbe5e1afbeb16c5abe01619f00d52e8d9903..c41f91ac4d2ec9330f71df87605cbed17da4d2f2 100644
--- a/mojo/python/tests/runloop_unittest.py
+++ b/mojo/python/tests/runloop_unittest.py
@@ -2,10 +2,9 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-import unittest
+import mojo_unittest
# pylint: disable=F0401
-import mojo.embedder
from mojo import system
@@ -15,28 +14,28 @@ def _Increment(array):
return _Closure
-class RunLoopTest(unittest.TestCase):
-
- def setUp(self):
- mojo.embedder.Init()
+class RunLoopTest(mojo_unittest.MojoTestCase):
def testRunLoop(self):
- loop = system.RunLoop()
array = []
for _ in xrange(10):
- loop.PostDelayedTask(_Increment(array))
- loop.RunUntilIdle()
+ self.loop.PostDelayedTask(_Increment(array))
+ self.loop.RunUntilIdle()
self.assertEquals(len(array), 10)
def testRunLoopWithException(self):
- loop = system.RunLoop()
def Throw():
raise Exception("error")
array = []
- loop.PostDelayedTask(Throw)
- loop.PostDelayedTask(_Increment(array))
+ self.loop.PostDelayedTask(Throw)
+ self.loop.PostDelayedTask(_Increment(array))
with self.assertRaisesRegexp(Exception, '^error$'):
- loop.Run()
+ self.loop.Run()
self.assertEquals(len(array), 0)
- loop.RunUntilIdle()
+ self.loop.RunUntilIdle()
self.assertEquals(len(array), 1)
+
+ def testCurrent(self):
+ self.assertEquals(system.RunLoop.Current(), self.loop)
+ self.loop = None
+ self.assertIsNone(system.RunLoop.Current())

Powered by Google App Engine
This is Rietveld 408576698