test: 按新 UI 基线重写过期用例
覆盖 155 条失败与 4 处编译错误:入口改走推荐流 tab、弹框换 AppGlowDialog、 rail 尺寸与底部锚定、子页标题字重 w400、底栏选中品牌红、收藏文案改收藏短剧。 全量 flutter test 775 通过。
This commit is contained in:
1 parent
799f3d1b7d
commit
1d4ab5e0e6
33 files changed
+853
-1114
No files matched your search
@@ -28,12 +28,20 @@ void main() {
|
||||
});
|
||||
|
||||
group('platform support', () {
|
||||
test('should_support_only_android_when_target_is_checked', () {
|
||||
debugDefaultTargetPlatformOverride = TargetPlatform.android;
|
||||
expect(pip().isPlatformSupported, isTrue);
|
||||
test('should_support_android_and_ios_when_target_is_checked', () {
|
||||
for (final platform in <TargetPlatform>[
|
||||
TargetPlatform.android,
|
||||
TargetPlatform.iOS,
|
||||
]) {
|
||||
debugDefaultTargetPlatformOverride = platform;
|
||||
expect(
|
||||
pip().isPlatformSupported,
|
||||
isTrue,
|
||||
reason: '$platform must claim picture in picture support',
|
||||
);
|
||||
}
|
||||
|
||||
for (final platform in <TargetPlatform>[
|
||||
TargetPlatform.iOS,
|
||||
TargetPlatform.macOS,
|
||||
TargetPlatform.linux,
|
||||
TargetPlatform.windows,
|
||||
@@ -50,8 +58,10 @@ void main() {
|
||||
});
|
||||
|
||||
group('enter', () {
|
||||
test('should_refuse_without_touching_channel_when_target_is_not_android', () async {
|
||||
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
|
||||
const url = 'https://cdn.example.com/episode-1.mp4';
|
||||
|
||||
test('should_refuse_without_touching_channel_when_target_is_not_supported', () async {
|
||||
debugDefaultTargetPlatformOverride = TargetPlatform.macOS;
|
||||
final calls = <MethodCall>[];
|
||||
messenger.setMockMethodCallHandler(channel, (call) async {
|
||||
calls.add(call);
|
||||
@@ -59,7 +69,10 @@ void main() {
|
||||
});
|
||||
addTearDown(() => messenger.setMockMethodCallHandler(channel, null));
|
||||
|
||||
expect(await pip().enter(), isFalse);
|
||||
expect(
|
||||
await pip().enter(url: url, positionMs: 4200),
|
||||
isFalse,
|
||||
);
|
||||
expect(calls, isEmpty);
|
||||
});
|
||||
|
||||
@@ -68,7 +81,10 @@ void main() {
|
||||
messenger.setMockMethodCallHandler(channel, (call) async => null);
|
||||
addTearDown(() => messenger.setMockMethodCallHandler(channel, null));
|
||||
|
||||
expect(await pip().enter(), isFalse);
|
||||
expect(
|
||||
await pip().enter(url: url, positionMs: 4200),
|
||||
isFalse,
|
||||
);
|
||||
});
|
||||
|
||||
test('should_report_entered_when_native_call_succeeds', () async {
|
||||
@@ -80,16 +96,19 @@ void main() {
|
||||
});
|
||||
addTearDown(() => messenger.setMockMethodCallHandler(channel, null));
|
||||
|
||||
expect(await pip().enter(), isTrue);
|
||||
expect(
|
||||
await pip().enter(url: url, positionMs: 4200),
|
||||
isTrue,
|
||||
);
|
||||
expect(calls.single.method, 'enter');
|
||||
expect(calls.single.arguments, isNull);
|
||||
expect(calls.single.arguments, {'url': url, 'positionMs': 4200});
|
||||
});
|
||||
});
|
||||
|
||||
group('state listener', () {
|
||||
test('should_deliver_pip_state_changes_in_order_when_native_events_arrive', () async {
|
||||
final received = <bool>[];
|
||||
pip().setStateListener(received.add);
|
||||
pip().setStateListener((active, _) => received.add(active));
|
||||
|
||||
await sendToDart('onPipChanged', true);
|
||||
await sendToDart('onPipChanged', false);
|
||||
@@ -99,7 +118,7 @@ void main() {
|
||||
|
||||
test('should_treat_only_literal_true_as_enabled_when_native_value_arrives', () async {
|
||||
final received = <bool>[];
|
||||
pip().setStateListener(received.add);
|
||||
pip().setStateListener((active, _) => received.add(active));
|
||||
|
||||
await sendToDart('onPipChanged', null);
|
||||
await sendToDart('onPipChanged', 'yes');
|
||||
@@ -110,7 +129,7 @@ void main() {
|
||||
|
||||
test('should_ignore_unrelated_native_methods_when_events_arrive', () async {
|
||||
final received = <bool>[];
|
||||
pip().setStateListener(received.add);
|
||||
pip().setStateListener((active, _) => received.add(active));
|
||||
|
||||
await sendToDart('somethingElse', true);
|
||||
await sendToDart('onPipChanged', true);
|
||||
@@ -120,7 +139,8 @@ void main() {
|
||||
|
||||
test('should_silence_later_callbacks_when_listener_is_cleared', () async {
|
||||
final received = <bool>[];
|
||||
final observer = pip()..setStateListener(received.add);
|
||||
final observer = pip()
|
||||
..setStateListener((active, _) => received.add(active));
|
||||
await sendToDart('onPipChanged', true);
|
||||
|
||||
observer.setStateListener(null);
|
||||
|
||||
@@ -27,11 +27,11 @@ void main() {
|
||||
);
|
||||
final title = tester.widget<Text>(find.byKey(const Key('subpage-title')));
|
||||
expect(title.style?.fontSize, 18);
|
||||
expect(title.style?.fontWeight, FontWeight.w800);
|
||||
expect(title.style?.fontWeight, FontWeight.w400);
|
||||
expect(title.style?.color, AppColors.textPrimary);
|
||||
final back = tester.getRect(find.byKey(const Key('sample-back')));
|
||||
final titleRect = tester.getRect(find.byKey(const Key('subpage-title')));
|
||||
expect(titleRect.left - back.right, closeTo(12, 0.5));
|
||||
expect(titleRect.left - back.right, closeTo(6, 0.5));
|
||||
final surface = tester.widget<Material>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('sample-back')),
|
||||
|
||||
Reference in new issue
Block a user