本文整理汇总了Python中quodlibet.qltk.songlist.SongList.emit方法的典型用法代码示例。如果您正苦于以下问题:Python SongList.emit方法的具体用法?Python SongList.emit怎么用?Python SongList.emit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类quodlibet.qltk.songlist.SongList
的用法示例。
在下文中一共展示了SongList.emit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TEventPlugins
# 需要导入模块: from quodlibet.qltk.songlist import SongList [as 别名]
# 或者: from quodlibet.qltk.songlist.SongList import emit [as 别名]
class TEventPlugins(TestCase):
def setUp(self):
self.tempdir = mkdtemp()
self.pm = PluginManager(folders=[self.tempdir])
self.lib = SongLibrarian()
lib = SongLibrary()
lib.librarian = self.lib
self.songlist = SongList(library=lib)
self.player = player.init_player("nullbe", self.lib)
self.handler = EventPluginHandler(
librarian=self.lib, player=self.player, songlist=self.songlist)
self.pm.register_handler(self.handler)
self.pm.rescan()
self.assertEquals(self.pm.plugins, [])
def tearDown(self):
self.pm.quit()
shutil.rmtree(self.tempdir)
def create_plugin(self, name='', funcs=None):
fd, fn = mkstemp(suffix='.py', text=True, dir=self.tempdir)
file = os.fdopen(fd, 'w')
file.write("from quodlibet.plugins.events import EventPlugin\n")
file.write("log = []\n")
file.write("class %s(EventPlugin):\n" % name)
indent = ' '
file.write("%spass\n" % indent)
if name:
file.write("%sPLUGIN_ID = %r\n" % (indent, name))
file.write("%sPLUGIN_NAME = %r\n" % (indent, name))
for f in (funcs or []):
file.write("%sdef %s(s, *args): log.append((%r, args))\n" %
(indent, f, f))
file.flush()
file.close()
def _get_calls(self, plugin):
mod = sys.modules[plugin.cls.__module__]
return mod.log
def test_found(self):
self.create_plugin(name='Name')
self.pm.rescan()
self.assertEquals(len(self.pm.plugins), 1)
def test_player_paused(self):
self.create_plugin(name='Name', funcs=["plugin_on_paused"])
self.pm.rescan()
self.assertEquals(len(self.pm.plugins), 1)
plugin = self.pm.plugins[0]
self.pm.enable(plugin, True)
self.player.emit("paused")
self.failUnlessEqual([("plugin_on_paused", tuple())],
self._get_calls(plugin))
def test_lib_changed(self):
self.create_plugin(name='Name', funcs=["plugin_on_changed"])
self.pm.rescan()
self.assertEquals(len(self.pm.plugins), 1)
plugin = self.pm.plugins[0]
self.pm.enable(plugin, True)
self.lib.emit("changed", [None])
self.failUnlessEqual([("plugin_on_changed", ([None],))],
self._get_calls(plugin))
def test_songs_selected(self):
self.create_plugin(name='Name', funcs=["plugin_on_songs_selected"])
self.pm.rescan()
self.assertEquals(len(self.pm.plugins), 1)
plugin = self.pm.plugins[0]
self.pm.enable(plugin, True)
self.songlist.emit("selection-changed", self.songlist.get_selection())
self.failUnlessEqual(self._get_calls(plugin),
[("plugin_on_songs_selected", ([], ))])