aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorsalmonik <raisersoft@proton.me>2026-05-08 01:12:31 +0200
committersalmonik <raisersoft@proton.me>2026-05-08 01:12:31 +0200
commit0f00616dca071750381234b5c59c8ec1e71b28ed (patch)
tree35d01b2ea8bbff458df5cb39ccc7d7b5dc6640ae /tests
parentAdd desktop notifications for track changes, queue end, and errors (diff)
downloadrsplayer-0f00616dca071750381234b5c59c8ec1e71b28ed.tar.gz
rsplayer-0f00616dca071750381234b5c59c8ec1e71b28ed.zip
Fix shuffle first song not being shuffled
update_shuffle_indices now shuffles all indices when position is 0 (no tracks have been played yet), so the first track played is random instead of always being tracks[0]. Directory playback now uses q.current() to pick the first track, resolving through shuffled indices when shuffle is active. Also pins notify-rust version in Cargo.toml and removes PLAN.md (superseded by TODO.md).
Diffstat (limited to '')
-rw-r--r--tests/queue.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/tests/queue.rs b/tests/queue.rs
index 0ceaba0..d3e923e 100644
--- a/tests/queue.rs
+++ b/tests/queue.rs
@@ -269,8 +269,6 @@ fn test_shuffle_all_navigates_in_shuffled_order() {
269 add_track(&mut q, &format!("/music/song{}.mp3", i)); 269 add_track(&mut q, &format!("/music/song{}.mp3", i));
270 } 270 }
271 q.set_shuffle(ShuffleMode::All); 271 q.set_shuffle(ShuffleMode::All);
272 // Current should still return the first track
273 assert_eq!(q.current().unwrap().path, PathBuf::from("/music/song0.mp3"));
274 // Navigate through all tracks, should visit all 10 (in shuffled order) 272 // Navigate through all tracks, should visit all 10 (in shuffled order)
275 let mut visited = std::collections::HashSet::new(); 273 let mut visited = std::collections::HashSet::new();
276 visited.insert(q.current().unwrap().path.clone()); 274 visited.insert(q.current().unwrap().path.clone());
@@ -291,7 +289,9 @@ fn test_shuffle_all_current_stays_at_position_zero() {
291 } 289 }
292 q.set_shuffle(ShuffleMode::All); 290 q.set_shuffle(ShuffleMode::All);
293 assert_eq!(q.position(), 0); 291 assert_eq!(q.position(), 0);
294 assert_eq!(q.shuffled_indices()[0], 0); 292 let mut sorted = q.shuffled_indices().to_vec();
293 sorted.sort();
294 assert_eq!(sorted, vec![0, 1, 2, 3, 4]);
295} 295}
296 296
297#[test] 297#[test]