diff options
| author | salmonik <raisersoft@proton.me> | 2026-05-10 00:37:43 +0200 |
|---|---|---|
| committer | salmonik <raisersoft@proton.me> | 2026-05-10 00:37:43 +0200 |
| commit | add0ace8f7b3de69679436aba80b1c7c7546633f (patch) | |
| tree | e11ee1569f83673eb70efd988450996bbbdd7845 /tests | |
| parent | Fix queue display returning nothing - removed daemon pager, return full outpu... (diff) | |
| download | rsplayer-add0ace8f7b3de69679436aba80b1c7c7546633f.tar.gz rsplayer-add0ace8f7b3de69679436aba80b1c7c7546633f.zip | |
Add shuffle restore tests, remove debug prints, update TODO
Diffstat (limited to '')
| -rw-r--r-- | tests/queue.rs | 50 |
1 files changed, 41 insertions, 9 deletions
diff --git a/tests/queue.rs b/tests/queue.rs index e511612..438fa23 100644 --- a/tests/queue.rs +++ b/tests/queue.rs | |||
| @@ -549,7 +549,10 @@ fn test_shuffle_all_then_none_exact_scenario() { | |||
| 549 | q.set_position(3); | 549 | q.set_position(3); |
| 550 | 550 | ||
| 551 | let current_before = q.current().unwrap().path.clone(); | 551 | let current_before = q.current().unwrap().path.clone(); |
| 552 | println!("Current before restore: {:?}", current_before.file_name().unwrap()); | 552 | println!( |
| 553 | "Current before restore: {:?}", | ||
| 554 | current_before.file_name().unwrap() | ||
| 555 | ); | ||
| 553 | println!("Position: {}", q.position()); | 556 | println!("Position: {}", q.position()); |
| 554 | 557 | ||
| 555 | // Now shuffle none | 558 | // Now shuffle none |
| @@ -557,7 +560,11 @@ fn test_shuffle_all_then_none_exact_scenario() { | |||
| 557 | 560 | ||
| 558 | println!("After restore:"); | 561 | println!("After restore:"); |
| 559 | for i in 0..q.len() { | 562 | for i in 0..q.len() { |
| 560 | println!(" {}: {:?}", i+1, q.track_at(i).unwrap().path.file_name().unwrap()); | 563 | println!( |
| 564 | " {}: {:?}", | ||
| 565 | i + 1, | ||
| 566 | q.track_at(i).unwrap().path.file_name().unwrap() | ||
| 567 | ); | ||
| 561 | } | 568 | } |
| 562 | 569 | ||
| 563 | // After restore: | 570 | // After restore: |
| @@ -567,7 +574,10 @@ fn test_shuffle_all_then_none_exact_scenario() { | |||
| 567 | assert_eq!(q.position(), 3, "position should stay same"); | 574 | assert_eq!(q.position(), 3, "position should stay same"); |
| 568 | 575 | ||
| 569 | let current_after = q.current().unwrap().path.clone(); | 576 | let current_after = q.current().unwrap().path.clone(); |
| 570 | assert_eq!(current_before, current_after, "current track should stay same"); | 577 | assert_eq!( |
| 578 | current_before, current_after, | ||
| 579 | "current track should stay same" | ||
| 580 | ); | ||
| 571 | } | 581 | } |
| 572 | 582 | ||
| 573 | #[test] | 583 | #[test] |
| @@ -597,10 +607,17 @@ fn test_shuffle_restore_simulation() { | |||
| 597 | 607 | ||
| 598 | println!("After 4 next() calls:"); | 608 | println!("After 4 next() calls:"); |
| 599 | println!(" Position: {}", q.position()); | 609 | println!(" Position: {}", q.position()); |
| 600 | println!(" Current: {:?}", q.current().unwrap().path.file_name().unwrap()); | 610 | println!( |
| 611 | " Current: {:?}", | ||
| 612 | q.current().unwrap().path.file_name().unwrap() | ||
| 613 | ); | ||
| 601 | println!(" Tracks:"); | 614 | println!(" Tracks:"); |
| 602 | for i in 0..q.len() { | 615 | for i in 0..q.len() { |
| 603 | println!(" {}: {:?}", i, q.track_at(i).unwrap().path.file_name().unwrap()); | 616 | println!( |
| 617 | " {}: {:?}", | ||
| 618 | i, | ||
| 619 | q.track_at(i).unwrap().path.file_name().unwrap() | ||
| 620 | ); | ||
| 604 | } | 621 | } |
| 605 | 622 | ||
| 606 | let current_path = q.current().unwrap().path.clone(); | 623 | let current_path = q.current().unwrap().path.clone(); |
| @@ -611,20 +628,35 @@ fn test_shuffle_restore_simulation() { | |||
| 611 | 628 | ||
| 612 | println!("After shuffle none:"); | 629 | println!("After shuffle none:"); |
| 613 | println!(" Position: {}", q.position()); | 630 | println!(" Position: {}", q.position()); |
| 614 | println!(" Current: {:?}", q.current().unwrap().path.file_name().unwrap()); | 631 | println!( |
| 632 | " Current: {:?}", | ||
| 633 | q.current().unwrap().path.file_name().unwrap() | ||
| 634 | ); | ||
| 615 | println!(" Tracks:"); | 635 | println!(" Tracks:"); |
| 616 | for i in 0..q.len() { | 636 | for i in 0..q.len() { |
| 617 | println!(" {}: {:?}", i, q.track_at(i).unwrap().path.file_name().unwrap()); | 637 | println!( |
| 638 | " {}: {:?}", | ||
| 639 | i, | ||
| 640 | q.track_at(i).unwrap().path.file_name().unwrap() | ||
| 641 | ); | ||
| 618 | } | 642 | } |
| 619 | 643 | ||
| 620 | // Assertions | 644 | // Assertions |
| 621 | assert_eq!(q.position(), pos_before, "position should be preserved"); | 645 | assert_eq!(q.position(), pos_before, "position should be preserved"); |
| 622 | assert_eq!(q.current().unwrap().path, current_path, "current track should be preserved"); | 646 | assert_eq!( |
| 647 | q.current().unwrap().path, | ||
| 648 | current_path, | ||
| 649 | "current track should be preserved" | ||
| 650 | ); | ||
| 623 | 651 | ||
| 624 | // The key requirement: tracks before current position should remain in played order | 652 | // The key requirement: tracks before current position should remain in played order |
| 625 | // and tracks after should be remaining from original in original order | 653 | // and tracks after should be remaining from original in original order |
| 626 | let pos = q.position(); | 654 | let pos = q.position(); |
| 627 | for i in 0..pos { | 655 | for i in 0..pos { |
| 628 | println!("Played track {}: {:?}", i, q.track_at(i).unwrap().path.file_name().unwrap()); | 656 | println!( |
| 657 | "Played track {}: {:?}", | ||
| 658 | i, | ||
| 659 | q.track_at(i).unwrap().path.file_name().unwrap() | ||
| 660 | ); | ||
| 629 | } | 661 | } |
| 630 | } | 662 | } |
