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

Side by Side Diff: tools/json_schema_compiler/dart_generator_test.py

Issue 12218151: Added unit tests for the Dart Chrome.* API wrappers. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 10 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 | « no previous file | tools/json_schema_compiler/dart_test/basic_event.dart » ('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 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 from dart_generator import DartGenerator
7 import os
8 import unittest
9 import glob
10
11 class DartTest(unittest.TestCase):
12
13 def _RunTest(self,
14 test_filename,
15 tests_dir='./dart_test/',
16 diff_flags=['--ignore-blank-lines', '--unified',
17 '--ignore-tab-expansion']):
18 '''Given the name of a test, runs compiler.py on the file:
19 <test_dir>/test_filename.idl
20 and compares it to the output in the file:
21 <test_dir>/test_filename.dart
22
23 The default |test_dir| location can be overwritten by passing in the new
24 location.
25 Similarly, you can override the default |diff_flags| by passing a list of
26 them into the function.
27 '''
28 cmd = ' | '.join(self.commands) % {
29 'expected_output_file': os.path.join(tests_dir,
30 '%s.dart' % test_filename),
31 'input_dir': tests_dir,
32 'input_file': os.path.join(tests_dir, '%s.idl' % test_filename),
33 'diff_flags': ' '.join(diff_flags)
34 }
35 self.assertEquals(0, os.system(cmd))
36
37 def setUp(self):
38 # Instead of outputting to a file and creating lots of temporary files,
39 # run the compiler and output to stdout, then pipe this straight into diff.
40 # This avoids creating temporary files we have to clean up later.
41 # Also remove the first line of output, since it contains the input
42 # filename.
43 self.commands = [
44 'python compiler.py -g dart -r %(input_dir)s %(input_file)s',
45 'tail -n +2',
46 'diff %(diff_flags)s %(expected_output_file)s -']
not at google - send to devlin 2013/02/20 00:43:01 I don't think we can assume that these will work -
sashab 2013/02/20 02:54:23 Done.
47
48 def testBasicEvent(self):
49 self._RunTest('basic_event')
50
51 def testBasicFunction(self):
52 self._RunTest('basic_function')
53
54 def testBasicType(self):
55 self._RunTest('basic_type')
56
57 def testComments(self):
58 self._RunTest('comments')
59
60 def testComplexType(self):
61 self._RunTest('complex_type')
62
63 def testEmptyNamespace(self):
64 self._RunTest('empty_namespace')
65
66 def testEmptyType(self):
67 self._RunTest('empty_type')
68
69 def testOpratableType(self):
70 self._RunTest('operatable_type')
71
72 def testTags(self):
73 self._RunTest('tags')
74
75 if __name__ == '__main__':
76 unittest.main()
OLDNEW
« no previous file with comments | « no previous file | tools/json_schema_compiler/dart_test/basic_event.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698