Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
scripts.databasebuilder_test.DatabaseBuilderTestCase Class Reference
Inheritance diagram for scripts.databasebuilder_test.DatabaseBuilderTestCase:

Public Member Functions

def setUp (self)
 
def tearDown (self)
 
def test_basic_import (self)
 
def test_splitting (self)
 
def test_renames (self)
 
def test_type_defs (self)
 
def test_merge (self)
 
def test_mergeDartName (self)
 
def test_supplemental (self)
 
def test_impl_stmt (self)
 
def test_obsolete (self)
 
def test_annotation_normalization (self)
 
def test_fix_displacements (self)
 

Detailed Description

Definition at line 17 of file databasebuilder_test.py.

Member Function Documentation

◆ setUp()

def scripts.databasebuilder_test.DatabaseBuilderTestCase.setUp (   self)

Definition at line 51 of file databasebuilder_test.py.

51 def setUp(self):
52 working_dir = tempfile.mkdtemp()
53 self._database_dir = os.path.join(working_dir, 'database')
54 self.assertFalse(os.path.exists(self._database_dir))
55
56 self._input_dir = os.path.join(working_dir, 'inputdir')
57 os.makedirs(self._input_dir)
58
59 self._db = database.Database(self._database_dir)
60 self.assertTrue(os.path.exists(self._database_dir))
61
62 self._builder = DatabaseBuilder(self._db)
63

◆ tearDown()

def scripts.databasebuilder_test.DatabaseBuilderTestCase.tearDown (   self)

Definition at line 64 of file databasebuilder_test.py.

64 def tearDown(self):
65 shutil.rmtree(self._database_dir)
66

◆ test_annotation_normalization()

def scripts.databasebuilder_test.DatabaseBuilderTestCase.test_annotation_normalization (   self)

Definition at line 334 of file databasebuilder_test.py.

334 def test_annotation_normalization(self):
335 file_name = self._create_input(
336 'input.idl', '''
337 module M {
338 interface I : J{
339 const int C = 0;
340 readonly attribute int a;
341 int op();
342 };
343 };''')
344 self._builder.import_idl_file(
345 file_name,
346 DatabaseBuilderOptions(source='Src', source_attributes={'x': 'y'}))
347 self._builder.merge_imported_interfaces([])
348 interface = self._db.GetInterface('I')
349 interface.parents[0].annotations['Src']['x'] = 'u'
350 interface.constants[0].annotations['Src']['z'] = 'w'
351 interface.attributes[0].annotations['Src']['x'] = 'u'
352 self._db.Save()
353
354 # Before normalization
355 self._assert_content_equals(
356 'I.idl', '''
357 @Src(module=M, x=y)
358 interface I : @Src(x=u) J {
359 /* Constants */
360 @Src(x=y, z=w) const int C = 0;
361 /* Attributes */
362 @Src(x=u) getter attribute int a;
363 /* Operations */
364 @Src(x=y) int op();
365 };''')
366
367 # Normalize
368 self._builder.normalize_annotations(['Src'])
369 self._db.Save()
370
371 # After normalization
372 self._assert_content_equals(
373 'I.idl', '''
374 @Src(module=M, x=y)
375 interface I : @Src(x=u) J {
376 /* Constants */
377 @Src(z=w) const int C = 0;
378 /* Attributes */
379 @Src(x=u) getter attribute int a;
380 /* Operations */
381 @Src int op();
382 };''')
383

◆ test_basic_import()

def scripts.databasebuilder_test.DatabaseBuilderTestCase.test_basic_import (   self)

Definition at line 67 of file databasebuilder_test.py.

67 def test_basic_import(self):
68 file_name = self._create_input(
69 'input.idl', '''
70 module M {
71 interface I {
72 attribute int a;
73 };
74 };''')
75 self._builder.import_idl_file(file_name)
76 self._builder.merge_imported_interfaces([])
77 self._db.Save()
78 self._assert_interface_exists('I.idl')
79

◆ test_fix_displacements()

def scripts.databasebuilder_test.DatabaseBuilderTestCase.test_fix_displacements (   self)

Definition at line 384 of file databasebuilder_test.py.

384 def test_fix_displacements(self):
385 file_name1 = self._create_input(
386 'input1.idl', '''
387 module M {
388 interface I {};
389 interface J : I {
390 readonly attribute int attr;
391 };
392 };''')
393 self._builder.import_idl_file(file_name1,
394 DatabaseBuilderOptions(source='1st'))
395 file_name2 = self._create_input(
396 'input2.idl', '''
397 module M {
398 interface I {
399 readonly attribute int attr;
400 };
401 interface J : I {};
402 };''')
403 self._builder.import_idl_file(file_name2,
404 DatabaseBuilderOptions(source='2nd'))
405 self._builder.merge_imported_interfaces([])
406 self._builder.fix_displacements('2nd')
407 self._db.Save()
408 self._assert_content_equals(
409 'J.idl', '''
410 @1st(module=M) @2nd(module=M) interface J :
411 @1st @2nd I {
412 /* Attributes */
413 @1st
414 @2nd(via=I)
415 getter attribute int attr;
416 };''')
417
418

◆ test_impl_stmt()

def scripts.databasebuilder_test.DatabaseBuilderTestCase.test_impl_stmt (   self)

Definition at line 284 of file databasebuilder_test.py.

284 def test_impl_stmt(self):
285 file_name = self._create_input(
286 'input.idl', '''
287 module M {
288 interface I {};
289 I implements J;
290 };''')
291 self._builder.import_idl_file(file_name,
292 DatabaseBuilderOptions(source='Src'))
293 self._builder.merge_imported_interfaces([])
294 self._db.Save()
295 self._assert_content_equals(
296 'I.idl', '''
297 @Src(module=M) interface I :
298 @Src J {
299 };''')
300

◆ test_merge()

def scripts.databasebuilder_test.DatabaseBuilderTestCase.test_merge (   self)

Definition at line 149 of file databasebuilder_test.py.

149 def test_merge(self):
150 file_name1 = self._create_input(
151 'input1.idl', '''
152 module M {
153 interface I {
154 const int CONST_BOTH = 0;
155 const int CONST_ONLY_FIRST = 0;
156 const int CONST_BOTH_DIFFERENT_VALUE = 0;
157
158 readonly attribute int attr_only_first;
159 readonly attribute int attr_both;
160 readonly attribute int attr_both_readonly_difference;
161 readonly attribute int attr_both_int_long_difference;
162
163 int op_only_first();
164 int op_both(int a);
165 int op_both_optionals_difference(int a,
166 in optional int b);
167 int op_both_arg_rename(int arg);
168 };
169 };''')
170 self._builder.import_idl_file(
171 file_name1,
172 DatabaseBuilderOptions(
173 source='1st', idl_syntax=idlparser.FREMONTCUT_SYNTAX))
174 file_name2 = self._create_input(
175 'input2.idl', '''
176 module M {
177 interface I {
178 const int CONST_BOTH = 0;
179 const int CONST_ONLY_SECOND = 0;
180 const int CONST_BOTH_DIFFERENT_VALUE = 1;
181
182 readonly attribute int attr_only_second;
183 readonly attribute int attr_both;
184 readonly attribute long attr_both_int_long_difference;
185 attribute int attr_both_readonly_difference;
186
187 int op_only_second();
188 int op_both(int a);
189 int op_both_optionals_difference(int a,
190 optional boolean b);
191 int op_both_arg_rename(int betterName);
192 };
193 };''')
194 self._builder.import_idl_file(
195 file_name2,
196 DatabaseBuilderOptions(
197 source='2nd', idl_syntax=idlparser.FREMONTCUT_SYNTAX))
198 self._builder.set_same_signatures({'int': 'long'})
199 self._builder.merge_imported_interfaces([])
200 self._db.Save()
201 self._assert_content_equals(
202 'I.idl', '''
203 @1st(module=M) @2nd(module=M) interface I {
204 /* Constants */
205 @1st @2nd const int CONST_BOTH = 0;
206 @1st const int CONST_BOTH_DIFFERENT_VALUE = 0;
207 @2nd const int CONST_BOTH_DIFFERENT_VALUE = 1;
208 @1st const int CONST_ONLY_FIRST = 0;
209 @2nd const int CONST_ONLY_SECOND = 0;
210
211 /* Attributes */
212 @1st @2nd getter attribute int attr_both;
213 @1st @2nd getter attribute int attr_both_int_long_difference;
214 @1st @2nd getter attribute int attr_both_readonly_difference;
215 @2nd setter attribute int attr_both_readonly_difference;
216 @1st getter attribute int attr_only_first;
217 @2nd getter attribute int attr_only_second;
218
219 /* Operations */
220 @1st @2nd int op_both(in t a);
221 @1st @2nd int op_both_arg_rename(in t betterName);
222 @1st @2nd int op_both_optionals_difference(in t a);
223 @1st int op_both_optionals_difference(in t a, in int b);
224 @2nd int op_both_optionals_difference(in t a, in boolean b);
225 @1st int op_only_first();
226 @2nd int op_only_second();
227 };''')
228

◆ test_mergeDartName()

def scripts.databasebuilder_test.DatabaseBuilderTestCase.test_mergeDartName (   self)

Definition at line 229 of file databasebuilder_test.py.

229 def test_mergeDartName(self):
230 file_name1 = self._create_input(
231 'input1.idl', '''
232 module M {
233 interface I {
234 [ImplementationFunction=foo] int member(in int a);
235 };
236 };''')
237 self._builder.import_idl_file(
238 file_name1,
239 DatabaseBuilderOptions(
240 source='1st', idl_syntax=idlparser.FREMONTCUT_SYNTAX))
241 file_name2 = self._create_input(
242 'input2.idl', '''
243 module M {
244 interface I {
245 [DartName=bar] int member(in int a);
246 };
247 };''')
248 self._builder.import_idl_file(
249 file_name2,
250 DatabaseBuilderOptions(
251 source='2nd', idl_syntax=idlparser.FREMONTCUT_SYNTAX))
252 self._builder.merge_imported_interfaces([])
253 self._db.Save()
254 self._assert_content_equals(
255 'I.idl', '''
256 @1st(module=M) @2nd(module=M) interface I {
257 /* Operations */
258 @1st @2nd [DartName=bar, ImplementationFunction=foo] int member(in int a);
259 };''')
260

◆ test_obsolete()

def scripts.databasebuilder_test.DatabaseBuilderTestCase.test_obsolete (   self)

Definition at line 301 of file databasebuilder_test.py.

301 def test_obsolete(self):
302 file_name1 = self._create_input(
303 'input1.idl', '''
304 module M {
305 interface I {
306 readonly attribute int keep;
307 readonly attribute int obsolete; // Would be removed
308 };
309 };''')
310 self._builder.import_idl_file(file_name1,
311 DatabaseBuilderOptions(source='src'))
312 file_name2 = self._create_input(
313 'input2.idl', '''
314 module M {
315 interface I {
316 readonly attribute int keep;
317 readonly attribute int new;
318 };
319 };''')
320 self._builder.import_idl_file(
321 file_name2,
322 DatabaseBuilderOptions(
323 source='src', obsolete_old_declarations=True))
324 self._builder.merge_imported_interfaces([])
325 self._db.Save()
326 self._assert_content_equals(
327 'I.idl', '''
328 @src(module=M) interface I {
329 /* Attributes */
330 @src getter attribute int keep;
331 @src getter attribute int new;
332 };''')
333

◆ test_renames()

def scripts.databasebuilder_test.DatabaseBuilderTestCase.test_renames (   self)

Definition at line 103 of file databasebuilder_test.py.

103 def test_renames(self):
104 file_name = self._create_input(
105 'input.idl', '''
106 module M {
107 [Constructor(in T x)] interface I {
108 T op(T x);
109 readonly attribute N::T attr;
110 };
111 };''')
112 options = DatabaseBuilderOptions(type_rename_map={'I': 'i', 'T': 't'})
113 self._builder.import_idl_file(file_name, options)
114 self._builder.merge_imported_interfaces([])
115 self._db.Save()
116 self._assert_content_equals(
117 'i.idl', '''
118 [Constructor(in t x)] interface i {
119 /* Attributes */
120 getter attribute t attr;
121 /* Operations */
122 t op(in t x);
123 };''')
124

◆ test_splitting()

def scripts.databasebuilder_test.DatabaseBuilderTestCase.test_splitting (   self)

Definition at line 80 of file databasebuilder_test.py.

80 def test_splitting(self):
81 file_name = self._create_input(
82 'input.idl', '''
83 module M {
84 interface I {
85 readonly attribute int a;
86 int o(in int x, in optional int y);
87 };
88 };''')
89 self._builder.import_idl_file(file_name)
90 self._builder.merge_imported_interfaces([])
91 self._db.Save()
92 self._assert_content_equals(
93 'I.idl', '''
94 interface I {
95 /* Attributes */
96 getter attribute int a;
97
98 /* Operations */
99 int o(in int x);
100 int o(in int x, in int y);
101 };''')
102

◆ test_supplemental()

def scripts.databasebuilder_test.DatabaseBuilderTestCase.test_supplemental (   self)

Definition at line 261 of file databasebuilder_test.py.

261 def test_supplemental(self):
262 file_name = self._create_input(
263 'input1.idl', '''
264 module M {
265 interface I {
266 readonly attribute int a;
267 };
268 [Supplemental] interface I {
269 readonly attribute int b;
270 };
271 };''')
272 self._builder.import_idl_file(file_name,
273 DatabaseBuilderOptions(source='Src'))
274 self._builder.merge_imported_interfaces([])
275 self._db.Save()
276 self._assert_content_equals(
277 'I.idl', '''
278 @Src(module=M) [Supplemental] interface I {
279 /* Attributes */
280 @Src getter attribute int a;
281 @Src getter attribute int b;
282 };''')
283

◆ test_type_defs()

def scripts.databasebuilder_test.DatabaseBuilderTestCase.test_type_defs (   self)

Definition at line 125 of file databasebuilder_test.py.

125 def test_type_defs(self):
126 file_name = self._create_input(
127 'input.idl', '''
128 module M {
129 typedef T S;
130 interface I : S {
131 S op(S x);
132 readonly attribute S attr;
133 };
134 };''')
135 options = DatabaseBuilderOptions()
136 self._builder.import_idl_file(file_name, options)
137 self._builder.merge_imported_interfaces([])
138 self._db.Save()
139 self._assert_content_equals(
140 'I.idl', '''
141 interface I :
142 T {
143 /* Attributes */
144 getter attribute T attr;
145 /* Operations */
146 T op(in T x);
147 };''')
148

The documentation for this class was generated from the following file: