This commit is contained in:
macbook_max
2026-10-15 20:36:59 +08:00
commit 6bf949949c
7923 changed files with 1369582 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
// 播放地址解析钩子单测:测试流注入的三分支行为
import 'package:flutter_test/flutter_test.dart';
import 'package:video_app/core/config/test_stream.dart';
import 'package:video_app/models/video_item.dart';
VideoItem _item(String url) =>
VideoItem(videoId: 1, author: VideoAuthor(userId: 1), videoUrl: url);
void main() {
group('resolvePlayUrl', () {
const testUrl = 'https://test.cdn/sample.m3u8';
test('原始地址为 http 绝对地址时不替换', () {
final item = _item('https://cdn.example.com/hls/1/index.m3u8');
expect(resolvePlayUrl(item, testUrl: testUrl),
'https://cdn.example.com/hls/1/index.m3u8');
});
test('原始地址不可用且注入测试流时替换为测试流', () {
expect(resolvePlayUrl(_item('/hls/1/index.m3u8'), testUrl: testUrl),
testUrl);
expect(resolvePlayUrl(_item(''), testUrl: testUrl), testUrl);
});
test('原始地址不可用且未注入测试流时原样返回', () {
expect(resolvePlayUrl(_item('/hls/1/index.m3u8'), testUrl: ''),
'/hls/1/index.m3u8');
expect(resolvePlayUrl(_item(''), testUrl: ''), '');
});
});
}