[core/theme|output] Add separators

Add a way for themes to specify custom separators. Doing that, make
nicer interfaces for drawing "supplementary" components (separators)
for widgets and generalize the attribute retrieval within the theme.
This commit is contained in:
Tobias Witek 2020-02-22 13:42:44 +01:00
parent d3fc648c08
commit 38410adcb8
6 changed files with 63 additions and 15 deletions

View file

@ -1,9 +1,11 @@
import unittest
import core.theme
import core.event
class theme(unittest.TestCase):
def setUp(self):
core.event.clear()
self.invalidThemeName = 'this-theme-does-not-exist'
self.validThemeName = 'default'
self.defaultsTheme = {
@ -34,14 +36,18 @@ class theme(unittest.TestCase):
def test_cycle(self):
theme = core.theme.Theme(raw_data=self.cycleTheme)
self.assertEqual(None, theme.prev_bg(None))
self.assertEqual(self.cycleTheme['cycle'][0]['fg'], theme.fg())
self.assertEqual(self.cycleTheme['cycle'][0]['bg'], theme.bg())
core.event.trigger('next-widget')
self.assertEqual(self.cycleTheme['cycle'][0]['bg'], theme.prev_bg(None))
core.event.trigger('next-widget')
self.assertEqual(self.cycleTheme['cycle'][2]['fg'], theme.fg())
self.assertEqual(self.cycleTheme['cycle'][2]['bg'], theme.bg())
core.event.trigger('start')
self.assertEqual(self.cycleTheme['cycle'][0]['fg'], theme.fg())
self.assertEqual(self.cycleTheme['cycle'][0]['bg'], theme.bg())
with unittest.mock.patch('core.output.sys.stdout'):
core.event.trigger('update')
self.assertEqual(self.cycleTheme['cycle'][0]['fg'], theme.fg())
self.assertEqual(self.cycleTheme['cycle'][0]['bg'], theme.bg())
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4