diff --git a/core/input.py b/core/input.py index fce461e..1a0037f 100644 --- a/core/input.py +++ b/core/input.py @@ -1,6 +1,8 @@ import uuid import logging +import core.event + import util.cli LEFT_MOUSE = 1 diff --git a/tests/core/test_theme.py b/tests/core/test_theme.py index ebc4323..891a6b3 100644 --- a/tests/core/test_theme.py +++ b/tests/core/test_theme.py @@ -1,7 +1,9 @@ import unittest +import types import core.theme import core.event +import core.widget class theme(unittest.TestCase): def setUp(self): @@ -28,6 +30,15 @@ class theme(unittest.TestCase): self.walTheme = { 'colors': ['wal'] } + self.cycleValueTheme = { + 'defaults': { + 'fg': [ 'red', 'green', 'blue' ] + } + } + self.stateTheme = { + 'warning': { 'fg': 'yellow' }, + 'critical': { 'fg': 'red' } + } def test_invalid_theme(self): with self.assertRaises(RuntimeError): @@ -90,4 +101,24 @@ class theme(unittest.TestCase): theme = core.theme.Theme(raw_data=self.walTheme) self.assertEqual({'background': '#ff0000'}, theme.keywords()) + def test_cycle_value(self): + widget = core.widget.Widget() + expected = self.cycleValueTheme['defaults']['fg'] + theme = core.theme.Theme(raw_data=self.cycleValueTheme) + + for i in range(0, len(expected)*3): + self.assertEqual(expected[i%len(expected)], theme.fg(widget)) + + def test_state(self): + widget = core.widget.Widget() + theme = core.theme.Theme(raw_data=self.stateTheme) + + self.assertEqual(None, theme.fg(widget)) + + widget.state = types.MethodType(lambda self: ['warning'], widget) + self.assertEqual(self.stateTheme['warning']['fg'], theme.fg(widget)) + + widget.state = types.MethodType(lambda self: ['critical'], widget) + self.assertEqual(self.stateTheme['critical']['fg'], theme.fg(widget)) + # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4