mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-18 20:40:43 +01:00
After shuffling the playlist, make sure next works as expected. Fixes issue #248
This commit is contained in:
parent
a0386d68d3
commit
36af3ddbe4
@ -887,6 +887,7 @@ void Playlist::Shuffle() {
|
||||
changePersistentIndex(pidx, index(i, pidx.column(), QModelIndex()));
|
||||
}
|
||||
}
|
||||
current_virtual_index_ = virtual_items_.indexOf(current_index());
|
||||
|
||||
layoutChanged();
|
||||
|
||||
|
@ -403,6 +403,43 @@ TEST_F(PlaylistTest, UndoRemoveOldCurrent) {
|
||||
EXPECT_EQ(-1, playlist_.last_played_index());
|
||||
}
|
||||
|
||||
TEST_F(PlaylistTest, ShuffleThenNext) {
|
||||
// Add 100 items
|
||||
PlaylistItemList items;
|
||||
for (int i=0 ; i<100 ; ++i)
|
||||
items << MakeMockItemP("Item " + QString::number(i));
|
||||
playlist_.InsertItems(items);
|
||||
|
||||
playlist_.set_current_index(0);
|
||||
|
||||
// Shuffle until the current index is not at the end
|
||||
forever {
|
||||
playlist_.Shuffle();
|
||||
if (playlist_.current_index() != items.count()-1)
|
||||
break;
|
||||
}
|
||||
|
||||
int index = playlist_.current_index();
|
||||
EXPECT_EQ("Item 0", playlist_.current_item()->Metadata().title());
|
||||
EXPECT_EQ("Item 0", playlist_.data(playlist_.index(index, Playlist::Column_Title)));
|
||||
EXPECT_EQ(index, playlist_.last_played_index());
|
||||
EXPECT_EQ(index + 1, playlist_.next_index());
|
||||
|
||||
// Shuffle until the current index *is* at the end
|
||||
forever {
|
||||
playlist_.Shuffle();
|
||||
if (playlist_.current_index() == items.count()-1)
|
||||
break;
|
||||
}
|
||||
|
||||
index = playlist_.current_index();
|
||||
EXPECT_EQ("Item 0", playlist_.current_item()->Metadata().title());
|
||||
EXPECT_EQ("Item 0", playlist_.data(playlist_.index(index, Playlist::Column_Title)));
|
||||
EXPECT_EQ(index, playlist_.last_played_index());
|
||||
EXPECT_EQ(-1, playlist_.next_index());
|
||||
EXPECT_EQ(index-1, playlist_.previous_index());
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user