summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2018-11-27 22:25:53 +0100
committerDaniel Kolesa <d.kolesa@samsung.com>2018-11-27 22:25:53 +0100
commit42c92b45ded79ce1fde345c640eefea93040b14b (patch)
tree74f13418f9fdb3ace4cc7733afa2883109a989a0 /src
parentedacff4fa5f564b9762a374a50791de78ad76ae7 (diff)
pyolian: Fix tests after class renames and API change
Summary: There is still a test failing as at least Ecore.Audio is both a namespace and a class. Test Plan: python test_pyolian.py Reviewers: DaveMDS, q66 Reviewed By: q66 Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D7371
Diffstat (limited to 'src')
-rw-r--r--src/scripts/pyolian/eolian.py9
-rwxr-xr-xsrc/scripts/pyolian/test_eolian.py81
2 files changed, 47 insertions, 43 deletions
diff --git a/src/scripts/pyolian/eolian.py b/src/scripts/pyolian/eolian.py
index b87e4fd630..5a5767662a 100644
--- a/src/scripts/pyolian/eolian.py
+++ b/src/scripts/pyolian/eolian.py
@@ -698,9 +698,12 @@ class Class(Object):
698 @cached_property 698 @cached_property
699 def inherits_full(self): 699 def inherits_full(self):
700 L = [] 700 L = []
701
701 def do_class_recursive(cls): 702 def do_class_recursive(cls):
703 if cls.parent:
704 L.append(cls.parent)
702 for other in cls.inherits: 705 for other in cls.inherits:
703 if not other in L: 706 if other not in L:
704 L.append(other) 707 L.append(other)
705 do_class_recursive(other) 708 do_class_recursive(other)
706 709
@@ -718,9 +721,7 @@ class Class(Object):
718 721
719 @cached_property 722 @cached_property
720 def base_class(self): 723 def base_class(self):
721 inherits = list(self.inherits) 724 return self.parent
722 if len(inherits) > 0:
723 return inherits[0]
724 725
725 @cached_property 726 @cached_property
726 def ctor_enable(self): 727 def ctor_enable(self):
diff --git a/src/scripts/pyolian/test_eolian.py b/src/scripts/pyolian/test_eolian.py
index 34fdbafbdf..0ed27c2180 100755
--- a/src/scripts/pyolian/test_eolian.py
+++ b/src/scripts/pyolian/test_eolian.py
@@ -25,13 +25,13 @@ eolian_db = None
25 25
26class TestBaseObject(unittest.TestCase): 26class TestBaseObject(unittest.TestCase):
27 def test_base_object_equality(self): 27 def test_base_object_equality(self):
28 cls1 = eolian_db.class_by_name_get('Efl.Loop.Timer') 28 cls1 = eolian_db.class_by_name_get('Efl.Loop_Timer')
29 cls2 = eolian_db.class_by_file_get('efl_loop_timer.eo') 29 cls2 = eolian_db.class_by_file_get('efl_loop_timer.eo')
30 self.assertIsInstance(cls1, eolian.Class) 30 self.assertIsInstance(cls1, eolian.Class)
31 self.assertIsInstance(cls2, eolian.Class) 31 self.assertIsInstance(cls2, eolian.Class)
32 self.assertEqual(cls1, cls2) 32 self.assertEqual(cls1, cls2)
33 self.assertEqual(cls1, 'Efl.Loop.Timer') 33 self.assertEqual(cls1, 'Efl.Loop_Timer')
34 self.assertEqual(cls2, 'Efl.Loop.Timer') 34 self.assertEqual(cls2, 'Efl.Loop_Timer')
35 self.assertNotEqual(cls1, 'another string') 35 self.assertNotEqual(cls1, 'another string')
36 self.assertNotEqual(cls1, 1234) 36 self.assertNotEqual(cls1, 1234)
37 self.assertNotEqual(cls1, None) 37 self.assertNotEqual(cls1, None)
@@ -97,10 +97,11 @@ class TestEolianUnit(unittest.TestCase):
97 self.assertIsInstance(unit, eolian.Eolian_Unit) 97 self.assertIsInstance(unit, eolian.Eolian_Unit)
98 self.assertEqual(unit.file, 'efl_ui_win.eo') 98 self.assertEqual(unit.file, 'efl_ui_win.eo')
99 99
100 def test_children_listing(self): 100 # Commented out until unit/state support is fixed
101 l = list(eolian_db.children) 101 # def test_children_listing(self):
102 self.assertGreater(len(l), 500) 102 # l = list(eolian_db.children)
103 self.assertIsInstance(l[0], eolian.Eolian_Unit) 103 # self.assertGreater(len(l), 500)
104 # self.assertIsInstance(l[0], eolian.Eolian_Unit)
104 105
105 def test_file_listing(self): 106 def test_file_listing(self):
106 l = list(eolian_db.eo_file_paths) 107 l = list(eolian_db.eo_file_paths)
@@ -209,8 +210,10 @@ class TestEolianNamespace(unittest.TestCase):
209 count = 0 210 count = 0
210 for ns in eolian_db.all_namespaces: 211 for ns in eolian_db.all_namespaces:
211 self.assertIsInstance(ns, eolian.Namespace) 212 self.assertIsInstance(ns, eolian.Namespace)
213 cls = eolian_db.class_by_name_get(ns.name)
214 self.assertIsNone(cls)
212 count += 1 215 count += 1
213 self.assertGreater(count, 200) 216 self.assertGreater(count, 100)
214 217
215 def test_namespace_equality(self): 218 def test_namespace_equality(self):
216 ns1 = eolian.Namespace(eolian_db, 'Efl.Io') 219 ns1 = eolian.Namespace(eolian_db, 'Efl.Io')
@@ -308,23 +311,23 @@ class TestEolianClass(unittest.TestCase):
308 cls = eolian_db.class_by_file_get('efl_loop_timer.eo') 311 cls = eolian_db.class_by_file_get('efl_loop_timer.eo')
309 self.assertIsInstance(cls, eolian.Class) 312 self.assertIsInstance(cls, eolian.Class)
310 313
311 cls = eolian_db.class_by_name_get('Efl.Loop.Timer') 314 cls = eolian_db.class_by_name_get('Efl.Loop_Timer')
312 self.assertIsInstance(cls, eolian.Class) 315 self.assertIsInstance(cls, eolian.Class)
313 316
314 self.assertEqual(cls.name, 'Efl.Loop.Timer') 317 self.assertEqual(cls.name, 'Efl.Loop_Timer')
315 self.assertEqual(cls.short_name, 'Timer') 318 self.assertEqual(cls.short_name, 'Loop_Timer')
316 self.assertEqual(cls.file, 'efl_loop_timer.eo') 319 self.assertEqual(cls.file, 'efl_loop_timer.eo')
317 self.assertEqual(list(cls.namespaces), ['Efl', 'Loop']) 320 self.assertEqual(list(cls.namespaces), ['Efl'])
318 self.assertEqual(cls.type, eolian.Eolian_Class_Type.REGULAR) 321 self.assertEqual(cls.type, eolian.Eolian_Class_Type.REGULAR)
319 self.assertIsInstance(cls.documentation, eolian.Documentation) 322 self.assertIsInstance(cls.documentation, eolian.Documentation)
320 self.assertEqual(cls.legacy_prefix, 'ecore_timer') 323 self.assertEqual(cls.legacy_prefix, 'ecore_timer')
321 self.assertIsNone(cls.eo_prefix) # TODO fin a class with a value 324 self.assertIsNone(cls.eo_prefix) # TODO fin a class with a value
322 self.assertIsNone(cls.event_prefix) # TODO same as above 325 self.assertIsNone(cls.event_prefix) # TODO same as above
323 self.assertIsNone(cls.data_type) # TODO same as above 326 self.assertIsNone(cls.data_type) # TODO same as above
324 self.assertEqual(cls.base_class.name, 'Efl.Loop.Consumer') 327 self.assertEqual(cls.base_class.name, 'Efl.Loop_Consumer')
325 self.assertEqual([c.name for c in cls.inherits], ['Efl.Loop.Consumer']) 328 self.assertEqual(cls.parent.name, 'Efl.Loop_Consumer')
326 self.assertEqual([c.name for c in cls.inherits_full], ['Efl.Loop.Consumer', 'Efl.Object']) 329 self.assertEqual([c.name for c in cls.extensions], [])
327 self.assertEqual([c.name for c in cls.hierarchy], ['Efl.Loop.Consumer', 'Efl.Object']) 330 self.assertEqual([c.name for c in cls.hierarchy], ['Efl.Loop_Consumer', 'Efl.Object'])
328 self.assertFalse(cls.ctor_enable) 331 self.assertFalse(cls.ctor_enable)
329 self.assertFalse(cls.dtor_enable) 332 self.assertFalse(cls.dtor_enable)
330 self.assertEqual(cls.c_get_function_name, 'efl_loop_timer_class_get') 333 self.assertEqual(cls.c_get_function_name, 'efl_loop_timer_class_get')
@@ -338,7 +341,7 @@ class TestEolianClass(unittest.TestCase):
338 341
339class TestEolianFunction(unittest.TestCase): 342class TestEolianFunction(unittest.TestCase):
340 def test_function(self): 343 def test_function(self):
341 cls = eolian_db.class_by_name_get('Efl.Loop.Timer') 344 cls = eolian_db.class_by_name_get('Efl.Loop_Timer')
342 f = cls.function_by_name_get('delay') 345 f = cls.function_by_name_get('delay')
343 self.assertIsInstance(f, eolian.Function) 346 self.assertIsInstance(f, eolian.Function)
344 self.assertEqual(f.name, 'delay') 347 self.assertEqual(f.name, 'delay')
@@ -365,11 +368,11 @@ class TestEolianFunction(unittest.TestCase):
365 self.assertEqual(len(list(f.parameters)), 1) 368 self.assertEqual(len(list(f.parameters)), 1)
366 self.assertFalse(f.return_is_warn_unused(eolian.Eolian_Function_Type.METHOD)) 369 self.assertFalse(f.return_is_warn_unused(eolian.Eolian_Function_Type.METHOD))
367 self.assertFalse(f.object_is_const) 370 self.assertFalse(f.object_is_const)
368 self.assertEqual(f.class_.name, 'Efl.Loop.Timer') 371 self.assertEqual(f.class_.name, 'Efl.Loop_Timer')
369 self.assertIsInstance(f.implement, eolian.Implement) 372 self.assertIsInstance(f.implement, eolian.Implement)
370 373
371 def test_function_parameter(self): 374 def test_function_parameter(self):
372 cls = eolian_db.class_by_name_get('Efl.Loop.Timer') 375 cls = eolian_db.class_by_name_get('Efl.Loop_Timer')
373 f = cls.function_by_name_get('delay') 376 f = cls.function_by_name_get('delay')
374 p = list(f.parameters)[0] 377 p = list(f.parameters)[0]
375 self.assertEqual(p.direction, eolian.Eolian_Parameter_Dir.IN) 378 self.assertEqual(p.direction, eolian.Eolian_Parameter_Dir.IN)
@@ -384,11 +387,11 @@ class TestEolianFunction(unittest.TestCase):
384 387
385class TestEolianImplement(unittest.TestCase): 388class TestEolianImplement(unittest.TestCase):
386 def test_implement(self): 389 def test_implement(self):
387 cls = eolian_db.class_by_name_get('Efl.Loop.Timer') 390 cls = eolian_db.class_by_name_get('Efl.Loop_Timer')
388 f = cls.function_by_name_get('delay') 391 f = cls.function_by_name_get('delay')
389 im = f.implement 392 im = f.implement
390 self.assertIsInstance(im, eolian.Implement) 393 self.assertIsInstance(im, eolian.Implement)
391 self.assertEqual(im.name, 'Efl.Loop.Timer.delay') 394 self.assertEqual(im.name, 'Efl.Loop_Timer.delay')
392 self.assertIsInstance(im.class_, eolian.Class) 395 self.assertIsInstance(im.class_, eolian.Class)
393 self.assertIsInstance(im.function, eolian.Function) 396 self.assertIsInstance(im.function, eolian.Function)
394 self.assertIsInstance(im.documentation_get(), eolian.Documentation) # TODO is UNRESOLVED correct ? 397 self.assertIsInstance(im.documentation_get(), eolian.Documentation) # TODO is UNRESOLVED correct ?
@@ -403,7 +406,7 @@ class TestEolianImplement(unittest.TestCase):
403 406
404class TestEolianEvent(unittest.TestCase): 407class TestEolianEvent(unittest.TestCase):
405 def test_event(self): 408 def test_event(self):
406 cls = eolian_db.class_by_name_get('Efl.Loop.Timer') 409 cls = eolian_db.class_by_name_get('Efl.Loop_Timer')
407 self.assertEqual([e.name for e in cls.events], ['tick']) 410 self.assertEqual([e.name for e in cls.events], ['tick'])
408 ev = cls.event_by_name_get('tick') 411 ev = cls.event_by_name_get('tick')
409 self.assertIsInstance(ev, eolian.Event) 412 self.assertIsInstance(ev, eolian.Event)
@@ -426,7 +429,7 @@ class TestEolianPart(unittest.TestCase):
426 part = parts[0] 429 part = parts[0]
427 self.assertEqual(part.name, 'backwall') 430 self.assertEqual(part.name, 'backwall')
428 self.assertIsInstance(part.class_, eolian.Class) 431 self.assertIsInstance(part.class_, eolian.Class)
429 self.assertEqual(part.class_.name, 'Efl.Ui.Popup.Part') 432 self.assertEqual(part.class_.name, 'Efl.Ui.Popup_Part_Backwall')
430 self.assertIsInstance(part.documentation, eolian.Documentation) 433 self.assertIsInstance(part.documentation, eolian.Documentation)
431 434
432 435
@@ -447,7 +450,7 @@ class TestEolianConstructor(unittest.TestCase):
447 450
448class TestEolianDocumentation(unittest.TestCase): 451class TestEolianDocumentation(unittest.TestCase):
449 def test_documentation(self): 452 def test_documentation(self):
450 td = eolian_db.class_by_name_get('Efl.Net.Control') 453 td = eolian_db.class_by_name_get('Efl.Net.Control.Manager')
451 doc = td.documentation 454 doc = td.documentation
452 self.assertIsInstance(doc, eolian.Documentation) 455 self.assertIsInstance(doc, eolian.Documentation)
453 self.assertIsInstance(doc.summary, str) 456 self.assertIsInstance(doc.summary, str)
@@ -472,14 +475,14 @@ class TestEolianVariable(unittest.TestCase):
472 self.assertIsNone(var.value) # TODO is None correct here? no value? 475 self.assertIsNone(var.value) # TODO is None correct here? no value?
473 476
474 def test_variable_constant(self): 477 def test_variable_constant(self):
475 var = eolian_db.constant_by_name_get('Efl.Gfx.Size.Hint.Fill') 478 var = eolian_db.constant_by_name_get('Efl.Gfx.Size_Hint_Fill')
476 self.assertIsInstance(var, eolian.Variable) 479 self.assertIsInstance(var, eolian.Variable)
477 self.assertEqual(var.name, 'Efl.Gfx.Size.Hint.Fill') 480 self.assertEqual(var.name, 'Efl.Gfx.Size_Hint_Fill')
478 self.assertEqual(var.short_name, 'Fill') 481 self.assertEqual(var.short_name, 'Size_Hint_Fill')
479 self.assertEqual(var.type, eolian.Eolian_Variable_Type.CONSTANT) 482 self.assertEqual(var.type, eolian.Eolian_Variable_Type.CONSTANT)
480 self.assertEqual(var.file, 'efl_gfx_size_hint.eo') 483 self.assertEqual(var.file, 'efl_gfx_size_hint.eo')
481 self.assertFalse(var.is_extern) 484 self.assertFalse(var.is_extern)
482 self.assertEqual(list(var.namespaces), ['Efl','Gfx','Size','Hint']) 485 self.assertEqual(list(var.namespaces), ['Efl','Gfx'])
483 self.assertIsInstance(var.documentation, eolian.Documentation) 486 self.assertIsInstance(var.documentation, eolian.Documentation)
484 self.assertIsInstance(var.base_type, eolian.Type) 487 self.assertIsInstance(var.base_type, eolian.Type)
485 self.assertIsInstance(var.value, eolian.Expression) 488 self.assertIsInstance(var.value, eolian.Expression)
@@ -547,7 +550,7 @@ class TestEolianTypedecl(unittest.TestCase):
547 550
548class TestEolianType(unittest.TestCase): 551class TestEolianType(unittest.TestCase):
549 def test_type_regular_builtin(self): 552 def test_type_regular_builtin(self):
550 cls = eolian_db.class_by_name_get('Efl.Loop.Timer') 553 cls = eolian_db.class_by_name_get('Efl.Loop_Timer')
551 func = cls.function_by_name_get('delay') 554 func = cls.function_by_name_get('delay')
552 param = list(func.parameters)[0] 555 param = list(func.parameters)[0]
553 t = param.type # type: double 556 t = param.type # type: double
@@ -572,7 +575,7 @@ class TestEolianType(unittest.TestCase):
572 self.assertEqual(t.c_type_return, 'double') 575 self.assertEqual(t.c_type_return, 'double')
573 576
574 def test_type_regular(self): 577 def test_type_regular(self):
575 cls = eolian_db.class_by_name_get('Efl.Gfx') 578 cls = eolian_db.class_by_name_get('Efl.Gfx.Entity')
576 func = cls.function_by_name_get('geometry') 579 func = cls.function_by_name_get('geometry')
577 param = list(func.setter_values)[0] 580 param = list(func.setter_values)[0]
578 t = param.type # type: Eina.Rect 581 t = param.type # type: Eina.Rect
@@ -581,7 +584,7 @@ class TestEolianType(unittest.TestCase):
581 self.assertEqual(t.short_name, 'Rect') 584 self.assertEqual(t.short_name, 'Rect')
582 self.assertEqual(t.type, eolian.Eolian_Type_Type.REGULAR) 585 self.assertEqual(t.type, eolian.Eolian_Type_Type.REGULAR)
583 self.assertEqual(t.builtin_type, eolian.Eolian_Type_Builtin_Type.INVALID) 586 self.assertEqual(t.builtin_type, eolian.Eolian_Type_Builtin_Type.INVALID)
584 self.assertEqual(t.file, 'efl_gfx.eo') # TODO is this correct ? 587 self.assertEqual(t.file, 'efl_gfx_entity.eo') # TODO is this correct ?
585 self.assertEqual(list(t.namespaces), ['Eina']) 588 self.assertEqual(list(t.namespaces), ['Eina'])
586 self.assertEqual(t.free_func, 'eina_rectangle_free') 589 self.assertEqual(t.free_func, 'eina_rectangle_free')
587 self.assertIsNone(t.class_) 590 self.assertIsNone(t.class_)
@@ -601,22 +604,22 @@ class TestEolianType(unittest.TestCase):
601 param = list(func.setter_values)[0] 604 param = list(func.setter_values)[0]
602 t = param.type # type: Efl.Gfx (class interface) 605 t = param.type # type: Efl.Gfx (class interface)
603 self.assertIsInstance(t, eolian.Type) 606 self.assertIsInstance(t, eolian.Type)
604 self.assertEqual(t.name, 'Efl.Gfx') 607 self.assertEqual(t.name, 'Efl.Gfx.Entity')
605 self.assertEqual(t.short_name, 'Gfx') 608 self.assertEqual(t.short_name, 'Entity')
606 self.assertEqual(t.type, eolian.Eolian_Type_Type.CLASS) 609 self.assertEqual(t.type, eolian.Eolian_Type_Type.CLASS)
607 self.assertEqual(t.builtin_type, eolian.Eolian_Type_Builtin_Type.INVALID) 610 self.assertEqual(t.builtin_type, eolian.Eolian_Type_Builtin_Type.INVALID)
608 self.assertEqual(t.file, 'efl_content.eo') # TODO is this correct ? 611 self.assertEqual(t.file, 'efl_content.eo') # TODO is this correct ?
609 self.assertEqual(list(t.namespaces), ['Efl']) 612 self.assertEqual(list(t.namespaces), ['Efl', 'Gfx'])
610 self.assertEqual(t.free_func, 'efl_del') 613 self.assertEqual(t.free_func, 'efl_del')
611 self.assertEqual(t, t.aliased_base) 614 self.assertEqual(t, t.aliased_base)
612 615
613 self.assertEqual(t.c_type_default, 'Efl_Gfx *') # TODO find a better test 616 self.assertEqual(t.c_type_default, 'Efl_Gfx_Entity *') # TODO find a better test
614 self.assertEqual(t.c_type_param, 'Efl_Gfx *') 617 self.assertEqual(t.c_type_param, 'Efl_Gfx_Entity *')
615 self.assertEqual(t.c_type_return, 'Efl_Gfx *') 618 self.assertEqual(t.c_type_return, 'Efl_Gfx_Entity *')
616 619
617 cls = t.class_ 620 cls = t.class_
618 self.assertIsInstance(cls, eolian.Class) 621 self.assertIsInstance(cls, eolian.Class)
619 self.assertEqual(cls.name, 'Efl.Gfx') 622 self.assertEqual(cls.name, 'Efl.Gfx.Entity')
620 623
621 624
622class TestEolianExpression(unittest.TestCase): 625class TestEolianExpression(unittest.TestCase):
@@ -629,7 +632,7 @@ class TestEolianExpression(unittest.TestCase):
629 self.assertEqual(exp.serialize, '100') 632 self.assertEqual(exp.serialize, '100')
630 633
631 def test_expression_unary(self): 634 def test_expression_unary(self):
632 var = eolian_db.constant_by_name_get('Efl.Gfx.Size.Hint.Fill') 635 var = eolian_db.constant_by_name_get('Efl.Gfx.Size_Hint_Fill')
633 exp = var.value 636 exp = var.value
634 self.assertIsInstance(exp, eolian.Expression) 637 self.assertIsInstance(exp, eolian.Expression)
635 self.assertEqual(exp.type, eolian.Eolian_Expression_Type.UNARY) 638 self.assertEqual(exp.type, eolian.Eolian_Expression_Type.UNARY)