f645203579
Until now, widgets were re-created during each iteration. For multiple, reasons, using static widget objects is much easier, so instead of creating new widgets continuously, modules now create the widgets during instantiation and get the list of widgets passed as parameter whenever an update occurs. During the update, they can still manipulate the widget list by removing and adding elements as needed. Advantages: * Less memory fragmentation (fewer (de)allocations) * Easier event management (widgets now have static IDs) * Easier module code (widget contents can simply be the result of a callback) see #23
23 lines
626 B
Python
23 lines
626 B
Python
# pylint: disable=C0103,C0111
|
|
|
|
import unittest
|
|
|
|
from bumblebee.modules.cpu import Module
|
|
from tests.util import assertWidgetAttributes
|
|
|
|
class TestCPUModule(unittest.TestCase):
|
|
def setUp(self):
|
|
self.module = Module(None)
|
|
|
|
def test_widgets(self):
|
|
widgets = self.module.widgets()
|
|
for widget in widgets:
|
|
assertWidgetAttributes(self, widget)
|
|
|
|
def test_update(self):
|
|
widgets = self.module.widgets()
|
|
self.module.update(widgets)
|
|
self.test_widgets()
|
|
self.assertEquals(widgets, self.module.widgets())
|
|
|
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|