perf: reduce queue and extension runtime overhead

This commit is contained in:
zarzet
2026-08-28 01:47:51 +07:00
parent a744514e10
commit 433f8ed685
16 changed files with 251 additions and 90 deletions
+17
View File
@@ -755,6 +755,7 @@ void main() {
expect(lookup.queuedCount, 3);
expect(lookup.activeDownloadsCount, 1);
expect(lookup.finalizingCount, 1);
expect(lookup.notCompletedItemIds, ['queued', 'active', 'finalizing']);
final next = List<DownloadItem>.from(previous);
next[2] = previous[2].copyWith(status: DownloadStatus.completed);
@@ -769,6 +770,22 @@ void main() {
expect(updated.finalizingCount, 0);
expect(identical(updated.indexByItemId, lookup.indexByItemId), isTrue);
expect(identical(updated.itemIds, lookup.itemIds), isTrue);
expect(updated.notCompletedItemIds, ['queued', 'active']);
final progressOnly = List<DownloadItem>.from(next);
progressOnly[1] = next[1].copyWith(progress: 0.5);
final progressUpdated = updated.updatedForIndices(
previousItems: next,
nextItems: progressOnly,
changedIndices: const [1],
);
expect(
identical(
progressUpdated.notCompletedItemIds,
updated.notCompletedItemIds,
),
isTrue,
);
});
});
@@ -104,4 +104,26 @@ void main() {
expect(calls, 1);
expect(metadata['title'], 'Instrumental');
});
test('shuffle candidate selection excludes recent tracks', () {
expect(
buildShuffleCandidatePool(
mediaCount: 6,
currentIndex: 2,
recentIndices: const [0, 1, 3],
),
[4, 5],
);
});
test('shuffle candidate selection resets after exhausting the pool', () {
expect(
buildShuffleCandidatePool(
mediaCount: 4,
currentIndex: 2,
recentIndices: const [0, 1, 3],
),
[0, 1, 3],
);
});
}