5"""Tests for dartgenerator."""
21 def _InDatabase(self, interface_name):
22 return os.path.exists(
25 def _FilePathForDartInterface(self, interface_name):
26 return os.path.join(self.
_generator._output_dir,
'src',
'interface',
27 '%s.dart' % interface_name)
29 def _InOutput(self, interface_name):
32 def _ReadOutputFile(self, interface_name):
33 self.assertTrue(self.
_InOutput(interface_name))
35 f = open(file_path,
'r')
38 return content, file_path
40 def _AssertOutputSansHeaderEquals(self, interface_name, expected_content):
43 header_re = re.compile(
r'^(\s*(//.*|/\*([^*]|\*[^/])*\*/)\s*)*')
44 actual_content = header_re.sub(
'', full_actual_content)
45 if expected_content != actual_content:
52""" % (file_path, expected_content, actual_content)
55 def _AssertOutputContains(self, interface_name, expected_content):
57 if expected_content
not in actual_content:
60Was found not in output file: %s
63""" % (expected_content, file_path, actual_content)
66 def _AssertOutputDoesNotContain(self, interface_name, expected_content):
68 if expected_content
in actual_content:
71Was found in output file: %s
74""" % (expected_content, file_path, actual_content)
93 @A1 @A2 getter attribute int attr;
94 @A1 setter attribute int attr;
96 const long CONSTANT = 1;
97 getter attribute DOMString strAttr;
100 Rectangle createRectangle();
101 void addLine(lines::Line line);
102 void someDartType(File file);
103 void someUnidentifiedType(UnidentifiableType t);
109 interface Rectangle :
@A3 shapes::Shape {
110 void someTemplatedType(List<Shape> list);
116 interface Line : shapes::Shape {
121 parser = idlparser.IDLParser(idlparser.FREMONTCUT_SYNTAX)
122 ast = parser.parse(content)
124 for interface
in idl_file.interfaces:
125 db.AddInterface(interface)
134 '../templates',
'test')
147 self.assertTrue(self.
_InOutput(
'Rectangle'))
158 self.assertTrue(self.
_InOutput(
'Rectangle'))
164 'Shape',
"""interface Shape {
173 'interface Rectangle extends shapes::Shape')
187 'interface Rectangle extends Forma')
223if __name__ ==
'__main__':
224 logging.config.fileConfig(
'logging.conf')
225 if __name__ ==
'__main__':
def _FilePathForDartInterface(self, interface_name)
def _AssertOutputDoesNotContain(self, interface_name, expected_content)
def _ReadOutputFile(self, interface_name)
def _AssertOutputSansHeaderEquals(self, interface_name, expected_content)
def testBasicGeneration(self)
def testFilterByAnnotations(self)
def testQualifiedDartTypes(self)
def testTypeRenames(self)
def _AssertOutputContains(self, interface_name, expected_content)
def _InOutput(self, interface_name)
def _InDatabase(self, interface_name)
void Flush(SkSurface *surface)
int compare(const void *untyped_lhs, const void *untyped_rhs)