1# This program is free software; you can redistribute it and/or modify 2# it under the terms of the GNU General Public License as published by 3# the Free Software Foundation; either version 2 of the License, or 4# (at your option) any later version. 5 6from tests import TestCase, skipIf 7 8from quodlibet.util.tags import USER_TAGS 9from quodlibet.qltk import is_wayland 10 11 12class TagsCombo(TestCase): 13 def setUp(self): 14 self.all = self.Kind() 15 self.some = self.Kind(["artist", "album", "~people", "foobar"]) 16 17 def tearDown(self): 18 self.all.destroy() 19 self.some.destroy() 20 21 22class TagsComboMixin(object): 23 24 def test_none(self): 25 self.failUnlessRaises(ValueError, self.Kind, []) 26 27 def test_some(self): 28 self.some.set_active(2) 29 self.failUnlessEqual(self.some.tag, "foobar") 30 31 def test_all(self): 32 tags = list(USER_TAGS) 33 tags.sort() 34 for i, value in enumerate(tags): 35 self.all.set_active(i) 36 self.failUnlessEqual(self.all.tag, value) 37 38 39@skipIf(is_wayland(), "crashes..") 40class TTagsComboBox(TagsCombo, TagsComboMixin): 41 from quodlibet.qltk.tagscombobox import TagsComboBox as Kind 42 Kind 43 44 45@skipIf(is_wayland(), "crashes..") 46class TTagsComboBoxEntry(TagsCombo, TagsComboMixin): 47 from quodlibet.qltk.tagscombobox import TagsComboBoxEntry as Kind 48 Kind 49 50 def test_custom(self): 51 self.all.get_child().set_text("a new tag") 52 self.failUnlessEqual(self.all.tag, "a new tag") 53