fix(home): 修复频道快速切换卡 loading
This commit is contained in:
1 parent
c8392b2f2a
commit
3c4d65a9b2
5 files changed
+408
-110
No files matched your search
@@ -431,7 +431,7 @@ void main() {
|
||||
final activeBefore = logic.session.active;
|
||||
|
||||
logic.updateFeed([...feed, _drama('third')], keepDramaId: 'signal');
|
||||
await pumpEventQueue();
|
||||
await logic.feedUpdateSettled;
|
||||
|
||||
expect(logic.currentDramaId, 'signal');
|
||||
expect(logic.visibleIndices, [0, 1, 2]);
|
||||
@@ -463,7 +463,7 @@ void main() {
|
||||
[_drama('city'), _drama('signal'), _drama('third')],
|
||||
keepDramaId: 'city',
|
||||
);
|
||||
await pumpEventQueue();
|
||||
await logic.feedUpdateSettled;
|
||||
|
||||
expect(logic.currentDramaId, 'city');
|
||||
expect(logic.session.currentIndex, 0);
|
||||
@@ -488,7 +488,11 @@ void main() {
|
||||
logic.start(factory: factory.create, coordinator: PlaybackCoordinator());
|
||||
await _drain(logic);
|
||||
|
||||
logic.updateFeed([_drama('anime-a'), _drama('anime-b')]);
|
||||
logic.updateFeed(
|
||||
[_drama('anime-a'), _drama('anime-b')],
|
||||
resetToFirst: true,
|
||||
);
|
||||
await logic.feedUpdateSettled;
|
||||
await _drain(logic);
|
||||
|
||||
expect(logic.queue.entryAt(0).drama.id, 'anime-a');
|
||||
@@ -517,6 +521,7 @@ void main() {
|
||||
await _drain(logic);
|
||||
|
||||
logic.updateFeed(const []);
|
||||
await logic.feedUpdateSettled;
|
||||
|
||||
expect(logic.queue.length, 0);
|
||||
expect(logic.visibleIndices, isEmpty);
|
||||
@@ -524,6 +529,95 @@ void main() {
|
||||
logic.dispose();
|
||||
await _drain(logic);
|
||||
});
|
||||
|
||||
test('should_apply_only_latest_feed_when_update_is_called_five_times',
|
||||
() async {
|
||||
final factory = _RecordingFactory();
|
||||
final logic = _logic(FakeWatchHistory());
|
||||
final initial = [_drama('initial')];
|
||||
logic.attach(
|
||||
PlayerPage(
|
||||
drama: initial.first,
|
||||
initialIndex: 0,
|
||||
homeMode: true,
|
||||
feedDramas: initial,
|
||||
),
|
||||
isMounted: () => true,
|
||||
);
|
||||
logic.start(factory: factory.create, coordinator: PlaybackCoordinator());
|
||||
await _drain(logic);
|
||||
|
||||
for (var index = 1; index <= 5; index++) {
|
||||
logic.updateFeed([_drama('feed-$index')], resetToFirst: true);
|
||||
}
|
||||
await logic.feedUpdateSettled;
|
||||
await _drain(logic);
|
||||
|
||||
expect(logic.feedRevision, 5);
|
||||
expect(logic.queue.entryAt(0).drama.id, 'feed-5');
|
||||
expect(logic.sessionEpisodes.single.id, 'feed-5-1');
|
||||
expect(logic.currentDramaId, 'feed-5');
|
||||
logic.dispose();
|
||||
await _drain(logic);
|
||||
});
|
||||
|
||||
test('should_select_first_item_when_feed_recovers_from_empty', () async {
|
||||
final factory = _RecordingFactory();
|
||||
final feed = [_drama('signal')];
|
||||
final logic = _logic(FakeWatchHistory());
|
||||
logic.attach(
|
||||
PlayerPage(
|
||||
drama: feed.first,
|
||||
initialIndex: 0,
|
||||
homeMode: true,
|
||||
feedDramas: feed,
|
||||
),
|
||||
isMounted: () => true,
|
||||
);
|
||||
logic.start(factory: factory.create, coordinator: PlaybackCoordinator());
|
||||
await _drain(logic);
|
||||
logic.updateFeed(const []);
|
||||
await logic.feedUpdateSettled;
|
||||
|
||||
logic.updateFeed([_drama('restored')], resetToFirst: true);
|
||||
await logic.feedUpdateSettled;
|
||||
await _drain(logic);
|
||||
|
||||
expect(logic.queue.entryAt(0).drama.id, 'restored');
|
||||
expect(logic.session.currentIndex, 0);
|
||||
expect(logic.currentDramaId, 'restored');
|
||||
expect(factory.live, greaterThan(0));
|
||||
logic.dispose();
|
||||
await _drain(logic);
|
||||
});
|
||||
|
||||
test('should_reset_to_first_when_channel_changes_with_same_ids',
|
||||
() async {
|
||||
final factory = _RecordingFactory();
|
||||
final feed = [_drama('same-a'), _drama('same-b')];
|
||||
final logic = _logic(FakeWatchHistory());
|
||||
logic.attach(
|
||||
PlayerPage(
|
||||
drama: feed.first,
|
||||
initialIndex: 1,
|
||||
homeMode: true,
|
||||
feedDramas: feed,
|
||||
),
|
||||
isMounted: () => true,
|
||||
);
|
||||
logic.start(factory: factory.create, coordinator: PlaybackCoordinator());
|
||||
await _drain(logic);
|
||||
expect(logic.session.currentIndex, 1);
|
||||
|
||||
logic.updateFeed(feed, resetToFirst: true);
|
||||
await logic.feedUpdateSettled;
|
||||
await _drain(logic);
|
||||
|
||||
expect(logic.session.currentIndex, 0);
|
||||
expect(logic.currentDramaId, 'same-a');
|
||||
logic.dispose();
|
||||
await _drain(logic);
|
||||
});
|
||||
});
|
||||
|
||||
group('lifecycle', () {
|
||||
|
||||
Reference in new issue
Block a user