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

Side by Side Diff: mojo/python/tests/system_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: Follow review 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/runloop_unittest.py ('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
1 # Copyright 2014 The Chromium Authors. All rights reserved. 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 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import random 5 import random
6 import sys
7 import time 6 import time
8 import unittest 7
8 import mojo_unittest
9 9
10 # pylint: disable=F0401 10 # pylint: disable=F0401
11 import mojo.embedder
12 from mojo import system 11 from mojo import system
13 12
14 DATA_SIZE = 1024 13 DATA_SIZE = 1024
15 14
16 15
17 def _GetRandomBuffer(size): 16 def _GetRandomBuffer(size):
18 random.seed(size) 17 random.seed(size)
19 return bytearray(''.join(chr(random.randint(0, 255)) for i in xrange(size))) 18 return bytearray(''.join(chr(random.randint(0, 255)) for i in xrange(size)))
20 19
21 20
22 class BaseMojoTest(unittest.TestCase): 21 class CoreTest(mojo_unittest.MojoTestCase):
23
24 def setUp(self):
25 mojo.embedder.Init()
26
27
28 class CoreTest(BaseMojoTest):
29 22
30 def testResults(self): 23 def testResults(self):
31 self.assertEquals(system.RESULT_OK, 0) 24 self.assertEquals(system.RESULT_OK, 0)
32 self.assertLess(system.RESULT_CANCELLED, 0) 25 self.assertLess(system.RESULT_CANCELLED, 0)
33 self.assertLess(system.RESULT_UNKNOWN, 0) 26 self.assertLess(system.RESULT_UNKNOWN, 0)
34 self.assertLess(system.RESULT_INVALID_ARGUMENT, 0) 27 self.assertLess(system.RESULT_INVALID_ARGUMENT, 0)
35 self.assertLess(system.RESULT_DEADLINE_EXCEEDED, 0) 28 self.assertLess(system.RESULT_DEADLINE_EXCEEDED, 0)
36 self.assertLess(system.RESULT_NOT_FOUND, 0) 29 self.assertLess(system.RESULT_NOT_FOUND, 0)
37 self.assertLess(system.RESULT_ALREADY_EXISTS, 0) 30 self.assertLess(system.RESULT_ALREADY_EXISTS, 0)
38 self.assertLess(system.RESULT_PERMISSION_DENIED, 0) 31 self.assertLess(system.RESULT_PERMISSION_DENIED, 0)
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 self.assertEquals(system.RESULT_OK, res1) 286 self.assertEquals(system.RESULT_OK, res1)
294 self.assertEquals(system.RESULT_OK, res2) 287 self.assertEquals(system.RESULT_OK, res2)
295 self.assertEquals(DATA_SIZE, len(buf1.buffer)) 288 self.assertEquals(DATA_SIZE, len(buf1.buffer))
296 self.assertEquals(DATA_SIZE, len(buf2.buffer)) 289 self.assertEquals(DATA_SIZE, len(buf2.buffer))
297 self.assertEquals(buf1.buffer, buf2.buffer) 290 self.assertEquals(buf1.buffer, buf2.buffer)
298 291
299 buf1.buffer[:] = data 292 buf1.buffer[:] = data
300 self.assertEquals(data, buf1.buffer) 293 self.assertEquals(data, buf1.buffer)
301 self.assertEquals(data, buf2.buffer) 294 self.assertEquals(data, buf2.buffer)
302 self.assertEquals(buf1.buffer, buf2.buffer) 295 self.assertEquals(buf1.buffer, buf2.buffer)
303
304
305 if __name__ == '__main__':
306 suite = unittest.TestLoader().loadTestsFromTestCase(CoreTest)
307 test_results = unittest.TextTestRunner(verbosity=0).run(suite)
308 if not test_results.wasSuccessful():
309 sys.exit(1)
310 sys.exit(0)
OLDNEW
« no previous file with comments | « mojo/python/tests/runloop_unittest.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698