为什么:客户端原型在 14d7bd3 之后又做了一轮(页面分层、发现页、分类滑动、播放器控件等),
一直留在工作区没入库。下一批账号链路要改其中的 app.dart / home_view / player_view / mine_view,
先归档这批既存改动,本批的实际 diff 才说得清边界。
只归档,不改行为:当前工作区 flutter analyze 0 问题、flutter test 148 全过。
77 lines
2.2 KiB
Dart
77 lines
2.2 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:nontonki/core/data/models/drama.dart';
|
|
import 'package:nontonki/core/data/services/playback_queue.dart';
|
|
|
|
void main() {
|
|
test('home feed advances between dramas, series player between episodes', () {
|
|
final dramas = [_drama('a', 3), _drama('b', 2), _drama('c', 4)];
|
|
|
|
final home = PlaybackQueue.home(dramas);
|
|
expect(home.length, 3);
|
|
expect(home.entryAt(0).drama.id, 'a');
|
|
expect(home.entryAt(1).drama.id, 'b');
|
|
expect(home.entryAt(1).episode.number, 1);
|
|
expect(home.nextIndex(0), 1);
|
|
expect(home.nextIndex(2), isNull);
|
|
|
|
final series = PlaybackQueue.series(dramas[0]);
|
|
expect(series.length, 3);
|
|
expect(series.entryAt(0).drama.id, series.entryAt(1).drama.id);
|
|
expect(series.entryAt(1).episode.number, 2);
|
|
expect(series.nextIndex(0), 1);
|
|
expect(series.nextIndex(2), isNull);
|
|
});
|
|
|
|
test('dramas without episodes are left out of the home queue', () {
|
|
final home = PlaybackQueue.home([
|
|
_drama('a', 2),
|
|
Drama(
|
|
id: 'empty',
|
|
title: '没有剧集',
|
|
synopsis: '',
|
|
posterUrl: '/files/empty.jpg',
|
|
),
|
|
]);
|
|
expect(home.length, 1);
|
|
expect(home.entryAt(0).drama.id, 'a');
|
|
});
|
|
|
|
test('a list card with a preview episode plays on the home feed', () {
|
|
final home = PlaybackQueue.home([
|
|
Drama.fromCardJson(const {
|
|
'id': 5,
|
|
'title': '闪婚后',
|
|
'cover': '/files/cover.jpg',
|
|
'totalEpisodes': 77,
|
|
'preview': {
|
|
'id': 9,
|
|
'number': 1,
|
|
'title': '第 1 集',
|
|
'isFree': true,
|
|
'playUrl': '/files/episode/9.mp4',
|
|
},
|
|
}),
|
|
]);
|
|
|
|
expect(home.length, 1);
|
|
expect(home.entryAt(0).episode.videoUrl, '/files/episode/9.mp4');
|
|
});
|
|
}
|
|
|
|
Drama _drama(String id, int episodeCount) => Drama(
|
|
id: id,
|
|
title: 'Drama $id',
|
|
synopsis: '简介 $id',
|
|
posterUrl: '/files/$id.jpg',
|
|
episodes: [
|
|
for (var index = 1; index <= episodeCount; index++)
|
|
Episode(
|
|
id: '$id-$index',
|
|
number: index,
|
|
title: '第 $index 集',
|
|
isFree: true,
|
|
videoUrl: 'https://example.test/$id-$index.mp4',
|
|
),
|
|
],
|
|
);
|