Attempt to speed up Steam even more. Sound for link added.
This commit is contained in:
1 parent
ee4292564a
commit
6e049e35e2
10 files changed
+349
-11
No files matched your search
@@ -34,13 +34,37 @@ class {class_name}(Plugin):
|
||||
self.deactivation_count += 1
|
||||
"""
|
||||
|
||||
PLUGIN_TEMPLATE_PLAIN_SIGNATURE = """
|
||||
from cthulhu.plugin import Plugin, cthulhu_hookimpl
|
||||
|
||||
|
||||
class {class_name}(Plugin):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.activation_count = 0
|
||||
self.deactivation_count = 0
|
||||
|
||||
@cthulhu_hookimpl
|
||||
def activate(self):
|
||||
self.activation_count += 1
|
||||
|
||||
@cthulhu_hookimpl
|
||||
def deactivate(self):
|
||||
self.deactivation_count += 1
|
||||
"""
|
||||
|
||||
|
||||
class PluginSystemManagerRegressionTests(unittest.TestCase):
|
||||
def _create_plugin_info(self, root_dir: str, module_name: str) -> PluginInfo:
|
||||
def _create_plugin_info(
|
||||
self,
|
||||
root_dir: str,
|
||||
module_name: str,
|
||||
template: str = PLUGIN_TEMPLATE,
|
||||
) -> PluginInfo:
|
||||
plugin_dir = Path(root_dir) / module_name
|
||||
plugin_dir.mkdir()
|
||||
(plugin_dir / "plugin.py").write_text(
|
||||
textwrap.dedent(PLUGIN_TEMPLATE.format(class_name=module_name)),
|
||||
textwrap.dedent(template.format(class_name=module_name)),
|
||||
encoding="utf-8",
|
||||
)
|
||||
return PluginInfo(
|
||||
@@ -93,6 +117,26 @@ class PluginSystemManagerRegressionTests(unittest.TestCase):
|
||||
self.assertEqual(first_plugin.instance.deactivation_count, 0)
|
||||
self.assertEqual(second_instance.deactivation_count, 1)
|
||||
|
||||
@mock.patch("cthulhu.plugin_system_manager.dbus_service.get_remote_controller")
|
||||
def test_loading_plugin_with_plain_activate_signature_succeeds(self, remote_controller):
|
||||
remote_controller.return_value = mock.Mock()
|
||||
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
manager = self._create_manager()
|
||||
plugin_info = self._create_plugin_info(
|
||||
temp_dir,
|
||||
"PlainSignaturePlugin",
|
||||
template=PLUGIN_TEMPLATE_PLAIN_SIGNATURE,
|
||||
)
|
||||
|
||||
self.assertTrue(manager.loadPlugin(plugin_info))
|
||||
instance = plugin_info.instance
|
||||
self.assertEqual(instance.activation_count, 1)
|
||||
|
||||
self.assertTrue(manager.unloadPlugin(plugin_info))
|
||||
self.assertEqual(instance.deactivation_count, 1)
|
||||
self.assertEqual(plugin_info.instance, None)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user