def test_set_drag_dest(self): x, y = self.c.convert_bin_window_to_widget_coords(0, 0) # empty model self.c.unset_rows_drag_dest() self.c.set_drag_dest(x, y) path, pos = self.c.get_drag_dest_row() self.assertTrue(path is None) # filled model but not realized, fall back to last path model = _fill_view(self.c) self.c.set_drag_dest(x, y) path, pos = self.c.get_drag_dest_row() self.assertEqual(model[-1].path, path) # realized now, so the first path with realized(self.c): x, y = self.c.convert_bin_window_to_widget_coords(0, 0) self.c.unset_rows_drag_dest() self.c.set_drag_dest(x, y, into_only=False) path, pos = self.c.get_drag_dest_row() self.assertEqual(model[0].path, path) self.assertEqual(pos, Gtk.TreeViewDropPosition.BEFORE) self.c.unset_rows_drag_dest() self.c.set_drag_dest(x, y, into_only=True) path, pos = self.c.get_drag_dest_row() self.assertEqual(model[0].path, path) self.assertEqual(pos, Gtk.TreeViewDropPosition.INTO_OR_BEFORE)
def test_filter_text(self): with realized(self.b): self.b.filter("foo", ["bar"]) self.b.filter("(((((##!!!!))),", ["(((((##!!!!))),"]) if self.b.can_filter_text(): self.b.filter_text("foo") self.b.filter_text("(((((##!!!!))),,,==")
def test_can_filter(self): with realized(self.bar): self.failUnless(self.bar.can_filter(None)) self.failUnless(self.bar.can_filter("album")) self.failUnless(self.bar.can_filter("foobar")) self.failIf(self.bar.can_filter("~#length")) self.failIf(self.bar.can_filter("title"))
def test_msic(self): with realized(self.b): self.b.activate() self.b.statusbar(1000) self.b.statusbar(1) song = AudioFile({"~filename": fsnative(u"/fake")}) song.sanitize() self.b.scroll(song)
def test_active_filter(self): with realized(self.bar): self.bar.filter("artist", ["piman"]) self._wait() self.failUnless(self.bar.active_filter(self.songs[0])) for s in SONGS: if s is not self.songs[0]: self.failIf(self.bar.active_filter(s))
def test_set_text(self): with realized(self.bar): self.bar.filter_text("artist=piman") self._wait() self.failUnlessEqual(len(self.songs), 1) self.bar.filter_text("") self._wait() self.failUnlessEqual(set(self.songs), set(SONGS))
def test_get_filter_text(self): with realized(self.b): if self.b.can_filter_text(): self.assertEqual(self.b.get_filter_text(), u"") self.assertTrue(isinstance(self.b.get_filter_text(), unicode)) self.b.filter_text(u"foo") self.assertEqual(self.b.get_filter_text(), u"foo") self.assertTrue(isinstance(self.b.get_filter_text(), unicode))
def test_filter_text(self): with realized(self.b): if self.b.can_filter_tag("foo"): self.b.filter("foo", ["bar"]) if self.b.can_filter_tag("(((((##!!!!))),"): self.b.filter("(((((##!!!!))),", ["(((((##!!!!))),"]) if self.b.can_filter_text(): self.b.filter_text("foo") self.b.filter_text("(((((##!!!!))),,,==")
def test_filter_album(self): with realized(self.bar): self.bar.filter_text("dsagfsag") self._wait() self.failUnlessEqual(len(self.songs), 0) self.bar.filter_text("") self._wait() self.bar.filter("album", ["one", "three"]) self._wait() self.failUnlessEqual(len(self.songs), 3)
def setUp(self): config.init() library = SongLibrary() library.librarian = SongLibrarian() AlbumList.init(library) for af in SONGS: af.sanitize() library.add(SONGS) self.bar = AlbumList(library, True) self._id = self.bar.connect("songs-selected", self._selected) self._id2 = self.bar.connect("activated", self._activated) with realized(self.bar): self.bar.filter_text("") self._wait() self.songs = [] self.activated = False
def setUp(self): config.init() library = SongLibrary() library.librarian = SongLibrarian() AlbumList.init(library) for af in SONGS: af.sanitize() library.add(SONGS) self.bar = AlbumList(library) self._id = self.bar.connect("songs-selected", self._selected) self._id2 = self.bar.connect("songs-activated", self._activated) with realized(self.bar): self.bar.filter_text("") self._wait() self.songs = [] self.activated = False
def test_filter_albums(self): with realized(self.b): if self.b.can_filter_albums(): self.b.filter_albums([]) self.b.filter_albums([object]) self.b.filter_albums(self.library.albums.values())
def test_active_filter(self): with realized(self.b): if self.b.active_filter is not None: self.b.active_filter(SONGS[0])
def test_activated(self): with realized(self.bar): view = self.bar.view view.row_activated(Gtk.TreePath((0, )), view.get_column(0)) self.failUnless(self.activated)
def test_add_remove_and_show(self): with realized(self.pane): self.pane.add(SONGS) with realized(self.pane): self.pane.remove(SONGS) self.assertFalse(self.pane.list("arist"))
def test_filter_other(self): with realized(self.b): self.b.unfilter()
def test_activated(self): with realized(self.bar): view = self.bar.view view.row_activated(Gtk.TreePath((0,)), view.get_column(0)) self.failUnless(self.activated)
def test_filters_caps(self): with realized(self.b): self.failUnless(isinstance(self.b.can_filter_tag("foo"), bool)) self.failUnless(isinstance(self.b.can_filter_text(), bool)) self.failUnless(isinstance(self.b.can_filter("foo"), bool))
def test_filter_artist(self): with realized(self.bar): self.bar.filter("artist", ["piman"]) self._wait() self.failUnlessEqual(len(self.songs), 1) self.failUnlessEqual(self.songs[0]("artist"), "piman")