From: Dave Andreoli Date: Sun, 11 Mar 2018 14:24:59 +0000 (+0100) Subject: Pyolian: add tests for Eolian_Object X-Git-Tag: upstream/1.21.0~1687 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ea47d4d62dab5c868336e1e769a53a7bf381a4c3;p=platform%2Fupstream%2Fefl.git Pyolian: add tests for Eolian_Object Two of the new tests are failing, the problem is that now we have name clashes between Eolian_Object and Eolian_Class (at least) For the moment I spotted: - Object.name clash with Class.name - Object.type clash with Class.type Also fixed a typo in eolian_lib.py spotted by the new tests, and removed the old tests for Declaration. --- diff --git a/src/scripts/pyolian/eolian_lib.py b/src/scripts/pyolian/eolian_lib.py index bf333b6..277f60a 100644 --- a/src/scripts/pyolian/eolian_lib.py +++ b/src/scripts/pyolian/eolian_lib.py @@ -98,8 +98,8 @@ lib.eolian_state_object_by_name_get.argtypes = [c_void_p, c_char_p] lib.eolian_state_object_by_name_get.restype = c_void_p # EAPI Eina_Iterator *eolian_state_objects_by_file_get(const Eolian_State *state, const char *file_name); -lib.eolian_state_object_by_file_get.argtypes = [c_void_p, c_char_p] -lib.eolian_state_object_by_file_get.restype = c_void_p +lib.eolian_state_objects_by_file_get.argtypes = [c_void_p, c_char_p] +lib.eolian_state_objects_by_file_get.restype = c_void_p # EAPI Eina_Iterator *eolian_state_objects_get(const Eolian_State *state); lib.eolian_state_objects_get.argtypes = [c_void_p] diff --git a/src/scripts/pyolian/test_eolian.py b/src/scripts/pyolian/test_eolian.py index 606e262..41f3bf7 100755 --- a/src/scripts/pyolian/test_eolian.py +++ b/src/scripts/pyolian/test_eolian.py @@ -65,6 +65,26 @@ class TestEolianState(unittest.TestCase): self.assertIsInstance(unit, eolian.Eolian_Unit) self.assertEqual(unit.file, 'efl_ui_win.eo') + def test_object_getters(self): + obj = eolian_db.object_by_name_get('Efl.Ui.Frame') + self.assertIsInstance(obj, eolian.Object) + self.assertFalse(type(obj) == eolian.Object) + self.assertEqual(obj.full_name, 'Efl.Ui.Frame') + + count = 0 + for obj in eolian_db.objects: + self.assertIsInstance(obj, eolian.Object) + self.assertFalse(type(obj) == eolian.Object) + count += 1 + self.assertGreater(count, 800) + + count = 0 + for obj in eolian_db.objects_by_file_get('efl_loop.eo'): + self.assertIsInstance(obj, eolian.Object) + self.assertFalse(type(obj) == eolian.Object) + count += 1 + self.assertGreater(count, 1) + class TestEolianUnit(unittest.TestCase): def test_file_get(self): @@ -94,6 +114,22 @@ class TestEolianUnit(unittest.TestCase): self.assertGreater(len(l), 10) self.assertTrue(l[0].endswith('.eot')) + def test_object_listing(self): + unit = eolian_db.unit_by_file_get('efl_ui_win.eo') + self.assertIsNone(unit.object_by_name_get('Efl.Ui.Frame')) + + obj = unit.object_by_name_get('Efl.Ui.Win') + self.assertIsInstance(obj, eolian.Object) + self.assertFalse(type(obj) == eolian.Object) + self.assertEqual(obj.full_name, 'Efl.Ui.Win') + + count = 0 + for obj in unit.objects: + self.assertIsInstance(obj, eolian.Object) + self.assertFalse(type(obj) == eolian.Object) + count += 1 + self.assertGreater(count, 5) + def test_enum_listing(self): l = list(eolian_db.enums_by_file_get('efl_ui_win.eo')) self.assertGreater(len(l), 5) @@ -155,15 +191,6 @@ class TestEolianUnit(unittest.TestCase): self.assertGreater(len(l), 10) self.assertIsInstance(l[0], eolian.Variable) - def test_declaration_listing(self): - l = list(eolian_db.declarations_get_by_file('eina_types.eot')) - self.assertGreater(len(l), 10) - self.assertIsInstance(l[0], eolian.Declaration) - - l = list(eolian_db.all_declarations) - self.assertGreater(len(l), 100) - self.assertIsInstance(l[0], eolian.Declaration) - def test_class_listing(self): all_count = 0 for cls in eolian_db.classes: @@ -237,6 +264,37 @@ class TestEolianNamespace(unittest.TestCase): self.assertEqual(td.type, eolian.Eolian_Typedecl_Type.STRUCT) +class TestEolianObject(unittest.TestCase): + def test_object_instance(self): + obj = eolian_db.object_by_name_get('Efl.Ui.Frame') + self.assertIsInstance(obj, eolian.Class) + self.assertEqual(obj.full_name, 'Efl.Ui.Frame') + + @unittest.expectedFailure # Object.name clash with Class.name + def test_name(self): + obj = eolian_db.object_by_name_get('Efl.Ui.Frame') + self.assertEqual(obj.name, 'Efl.Ui.Frame') + + @unittest.expectedFailure # Object.type clash with Class.type + def test_type(self): + obj = eolian_db.object_by_name_get('Efl.Ui.Frame') + self.assertIs(obj.type, eolian.Eolian_Object_Type.CLASS) + + def test_file(self): + obj = eolian_db.object_by_name_get('Efl.Ui.Frame') + self.assertEqual(obj.file, 'efl_ui_frame.eo') + + def test_line(self): + obj = eolian_db.object_by_name_get('Efl.Ui.Frame') + self.assertIsInstance(obj.line, int) + self.assertGreater(obj.line, 0) + + def test_column(self): + obj = eolian_db.object_by_name_get('Efl.Ui.Frame') + self.assertIsInstance(obj.column, int) + self.assertGreater(obj.column, 0) + + class TestEolianClass(unittest.TestCase): def test_class(self): cls = eolian_db.class_by_file_get('efl_loop_timer.eo') @@ -553,18 +611,6 @@ class TestEolianType(unittest.TestCase): self.assertEqual(cls.full_name, 'Efl.Gfx') -class TestEolianDeclaration(unittest.TestCase): - def test_declaration(self): - d = eolian_db.declaration_get_by_name('Eina.File') - self.assertIsInstance(d, eolian.Declaration) - self.assertEqual(d.name, 'Eina.File') - self.assertEqual(d.type, eolian.Eolian_Declaration_Type.STRUCT) - # self.assertIsNone(d.class_) # TODO find a better test - # self.assertIsNone(d.variable) # TODO find a better test - self.assertIsInstance(d.data_type, eolian.Typedecl) - self.assertEqual(d.data_type.full_name, 'Eina.File') - - class TestEolianExpression(unittest.TestCase): def test_expression_simple(self): td = eolian_db.enum_by_name_get('Efl.Net.Http.Version')