Tests: Simple beginnings for Elm unit tests, enabled Eo tests.

This commit is contained in:
Kai Huuhko 2013-12-18 20:05:26 +02:00
parent 056fad315c
commit 277ed843ae
8 changed files with 146 additions and 22 deletions

View File

@ -0,0 +1,9 @@
#!/usr/bin/env python
import unittest
loader = unittest.TestLoader()
suite = loader.discover('.')
runner = unittest.TextTestRunner(verbosity=2)
result = runner.run(suite)

View File

BIN
tests/elementary/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

@ -0,0 +1,30 @@
#!/usr/bin/env python
import unittest
from efl.eo import Eo
from efl import elementary
from efl.elementary.window import Window, ELM_WIN_BASIC
from efl.elementary.button import Button
elementary.init()
class TestElmBasics(unittest.TestCase):
def setUp(self):
self.o = Window("t", ELM_WIN_BASIC)
def tearDown(self):
self.o.delete()
def testParentGet1(self):
self.assertIsNone(self.o.parent_get())
def testParentGet2(self):
o = Button(self.o)
self.assertEqual(Eo.parent_get(o), self.o)
o.delete()
if __name__ == '__main__':
unittest.main(verbosity=2)
elementary.shutdown()

View File

@ -0,0 +1,98 @@
#!/usr/bin/env python
import os
import unittest
from efl.eo import Eo
from efl.evas import Image as evasImage
from efl import elementary
from efl.elementary.window import Window, ELM_WIN_BASIC
from efl.elementary.image import Image
from efl.elementary.icon import Icon
script_path = os.path.dirname(os.path.abspath(__file__))
img_path = os.path.join(script_path, "images")
elementary.init()
class TestElmImage(unittest.TestCase):
def setUp(self):
self.w = Window("t", ELM_WIN_BASIC)
self.o = Image(self.w)
def tearDown(self):
self.o.delete()
self.w.delete()
def testImageConstructor(self):
self.assertIsNotNone(self.o)
self.assertEqual(Eo.parent_get(self.o), self.w)
def testImageFile(self):
self.o.file = os.path.join(script_path, u"icon.png")
self.assertEqual(
self.o.file[0], os.path.join(script_path, u"icon.png"))
self.assertEqual(self.o.object_size, (48, 48))
def testImageFileException(self):
self.assertRaises(
RuntimeError, setattr, self.o, "file", u"this_fails.png")
def testImageEvas(self):
self.assertIsInstance(self.o.object, evasImage)
def testImageBooleans(self):
self.assertTrue(self.o.aspect_fixed)
self.o.aspect_fixed = False
self.assertFalse(self.o.aspect_fixed)
self.assertFalse(self.o.editable)
self.o.editable = True
self.assertTrue(self.o.editable)
self.assertFalse(self.o.fill_outside)
self.o.fill_outside = True
self.assertTrue(self.o.fill_outside)
self.assertFalse(self.o.no_scale)
self.o.no_scale = True
self.assertTrue(self.o.no_scale)
# Write-only value
self.o.preload_disabled = True
self.assertRaises(AttributeError, getattr, self.o, "preload_disabled")
self.assertEqual(self.o.resizable, (True, True))
self.o.resizable = False, False
self.assertEqual(self.o.resizable, (False, False))
self.assertTrue(self.o.smooth)
self.o.smooth = False
self.assertFalse(self.o.smooth)
class TestElmIcon(unittest.TestCase):
def setUp(self):
self.w = Window("t", ELM_WIN_BASIC)
self.o = Icon(self.w)
def tearDown(self):
self.o.delete()
self.w.delete()
def testIconConstructor(self):
self.assertIsNotNone(self.o)
self.assertEqual(Eo.parent_get(self.o), self.w)
def testIconStandard(self):
self.o.standard = u"elementary"
self.assertEqual(u"elementary", self.o.standard)
def testIconStandardException(self):
self.assertRaises(
RuntimeWarning, setattr, self.o, "standard", u"this_fails")
if __name__ == '__main__':
unittest.main(verbosity=2)
elementary.shutdown()

View File

@ -0,0 +1,9 @@
#!/usr/bin/env python
import unittest
loader = unittest.TestLoader()
suite = loader.discover('.')
runner = unittest.TextTestRunner(verbosity=2)
result = runner.run(suite)

0
tests/eo/__init__.py Normal file
View File

View File

@ -3,16 +3,10 @@
from efl import eo
from efl.eo import Eo
from efl import elementary
from efl.elementary.window import Window, ELM_WIN_BASIC
from efl.elementary.button import Button
eo.init()
elementary.init()
import os, unittest
class TestBasics(unittest.TestCase):
def setUp(self):
@ -30,23 +24,7 @@ class TestBasics(unittest.TestCase):
def testParentGet(self):
self.assertIsNone(self.o.parent_get())
class TestElmBasics(unittest.TestCase):
def setUp(self):
self.o = Window("t", ELM_WIN_BASIC)
def tearDown(self):
self.o.delete()
def testParentGet1(self):
self.assertIsNone(self.o.parent_get())
def testParentGet2(self):
o = Button(self.o)
self.assertEqual(Eo.parent_get(o), self.o)
o.delete()
if __name__ == '__main__':
unittest.main(verbosity=2)
elementary.shutdown()
eo.shutdown()