summaryrefslogtreecommitdiff
path: root/tests/test_cairo.py
diff options
context:
space:
mode:
authorSimon Feltman <sfeltman@src.gnome.org>2014-05-05 19:48:06 -0700
committerSimon Feltman <sfeltman@src.gnome.org>2014-05-05 20:24:32 -0700
commit4ee91a4cd0018d069c7aaf66d83e2f8235f2262a (patch)
treebb43bef70fea64a32a5350acbe7c6250c017a028 /tests/test_cairo.py
parent31ecd935564984068e6646676392122bdc03e42e (diff)
downloadpygobject-4ee91a4cd0018d069c7aaf66d83e2f8235f2262a.tar.gz
tests: Move cairo tests into test_cairo.py
Move cairo related tests from test_everything.py into test_cairo.py https://bugzilla.gnome.org/show_bug.cgi?id=694604
Diffstat (limited to 'tests/test_cairo.py')
-rw-r--r--tests/test_cairo.py67
1 files changed, 67 insertions, 0 deletions
diff --git a/tests/test_cairo.py b/tests/test_cairo.py
new file mode 100644
index 00000000..4674068b
--- /dev/null
+++ b/tests/test_cairo.py
@@ -0,0 +1,67 @@
+# -*- Mode: Python; py-indent-offset: 4 -*-
+# coding=utf-8
+# vim: tabstop=4 shiftwidth=4 expandtab
+
+import unittest
+
+try:
+ import cairo
+ from gi.repository import Regress
+ has_cairo = True
+except ImportError:
+ has_cairo = False
+
+try:
+ from gi.repository import Gtk
+ Gtk # pyflakes
+except:
+ Gtk = None
+
+
+@unittest.skipUnless(has_cairo, 'built without cairo support')
+class Test(unittest.TestCase):
+ def test_cairo_context(self):
+ context = Regress.test_cairo_context_full_return()
+ self.assertTrue(isinstance(context, cairo.Context))
+
+ surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 10, 10)
+ context = cairo.Context(surface)
+ Regress.test_cairo_context_none_in(context)
+
+ def test_cairo_surface(self):
+ surface = Regress.test_cairo_surface_none_return()
+ self.assertTrue(isinstance(surface, cairo.ImageSurface))
+ self.assertTrue(isinstance(surface, cairo.Surface))
+ self.assertEqual(surface.get_format(), cairo.FORMAT_ARGB32)
+ self.assertEqual(surface.get_width(), 10)
+ self.assertEqual(surface.get_height(), 10)
+
+ surface = Regress.test_cairo_surface_full_return()
+ self.assertTrue(isinstance(surface, cairo.ImageSurface))
+ self.assertTrue(isinstance(surface, cairo.Surface))
+ self.assertEqual(surface.get_format(), cairo.FORMAT_ARGB32)
+ self.assertEqual(surface.get_width(), 10)
+ self.assertEqual(surface.get_height(), 10)
+
+ surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 10, 10)
+ Regress.test_cairo_surface_none_in(surface)
+
+ surface = Regress.test_cairo_surface_full_out()
+ self.assertTrue(isinstance(surface, cairo.ImageSurface))
+ self.assertTrue(isinstance(surface, cairo.Surface))
+ self.assertEqual(surface.get_format(), cairo.FORMAT_ARGB32)
+ self.assertEqual(surface.get_width(), 10)
+ self.assertEqual(surface.get_height(), 10)
+
+
+@unittest.skipUnless(has_cairo, 'built without cairo support')
+@unittest.skipUnless(Gtk, 'Gtk not available')
+class TestPango(unittest.TestCase):
+ def test_cairo_font_options(self):
+ screen = Gtk.Window().get_screen()
+ font_opts = screen.get_font_options()
+ self.assertEqual(type(font_opts.get_subpixel_order()), int)
+
+
+if __name__ == '__main__':
+ unittest.main()