Anna Schumaker
c899c15c42
This Label supports setting a prefix that is applied to the displayed string and setting a font size in pixels. Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
68 lines
2.8 KiB
Python
68 lines
2.8 KiB
Python
# Copyright 2022 (c) Anna Schumaker.
|
|
"""Test that the gi.repository has been configured correctly."""
|
|
import unittest
|
|
import pathlib
|
|
import emmental
|
|
import gi
|
|
import xdg.BaseDirectory
|
|
|
|
|
|
class TestGSetup(unittest.TestCase):
|
|
"""GObject Introspection configuration test case."""
|
|
|
|
def test_require_version(self):
|
|
"""Check that gi.require_version() has been called."""
|
|
self.assertEqual(gi.get_required_version("Gtk"), "4.0")
|
|
self.assertEqual(gi.get_required_version("Adw"), "1")
|
|
self.assertEqual(gi.get_required_version("Gst"), "1.0")
|
|
self.assertEqual(gi.get_required_version("Pango"), "1.0")
|
|
|
|
def test_adw(self):
|
|
"""Check that libadwaita style has been set."""
|
|
style = gi.repository.Adw.StyleManager.get_default()
|
|
self.assertEqual(style.get_color_scheme(),
|
|
gi.repository.Adw.ColorScheme.DEFAULT)
|
|
|
|
def test_gst(self):
|
|
"""Check that gstreamer has been initialized."""
|
|
self.assertTrue(gi.repository.Gst.is_initialized())
|
|
|
|
def test_import(self):
|
|
"""Check that modules have been imported."""
|
|
self.assertIsNotNone(emmental.gsetup.gi)
|
|
|
|
def test_application_id(self):
|
|
"""Check that the application id is generated properly."""
|
|
self.assertEqual(emmental.gsetup.DEBUG_STR, "-debug")
|
|
self.assertEqual(emmental.gsetup.APPLICATION_ID,
|
|
"com.nowheycreamery.emmental-debug")
|
|
|
|
def test_css(self):
|
|
"""Check that our custom stylesheet is configured."""
|
|
path = pathlib.Path(emmental.__file__).parent / "emmental.css"
|
|
self.assertEqual(emmental.gsetup.CSS_FILE, path)
|
|
self.assertEqual(emmental.gsetup.CSS_PRIORITY,
|
|
gi.repository.Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
|
|
self.assertIsInstance(emmental.gsetup.CSS_PROVIDER,
|
|
gi.repository.Gtk.CssProvider)
|
|
|
|
def test_resource(self):
|
|
"""Check that emmental.resource has been loaded."""
|
|
path = pathlib.Path(emmental.__file__).parent.parent
|
|
path = path / "emmental.gresource"
|
|
|
|
self.assertEqual(emmental.gsetup.RESOURCE_PATH,
|
|
"/com/nowheycreamery/emmental")
|
|
icons = f"{emmental.gsetup.RESOURCE_PATH}/icons/scalable/apps"
|
|
self.assertEqual(emmental.gsetup.RESOURCE_ICONS, icons)
|
|
self.assertEqual(emmental.gsetup.RESOURCE_FILE, path)
|
|
self.assertTrue(emmental.gsetup.RESOURCE_FILE.is_file())
|
|
|
|
self.assertIsInstance(emmental.gsetup.RESOURCE,
|
|
gi.repository.Gio.Resource)
|
|
|
|
def test_data_dir(self):
|
|
"""Check that the DATA_DIR points to the right place."""
|
|
data_path = xdg.BaseDirectory.save_data_path("emmental")
|
|
self.assertEqual(emmental.gsetup.DATA_DIR, pathlib.Path(data_path))
|