chore(client): 归档原型阶段新增文件(配置、主题、模型与测试)
为什么:上一批归档只覆盖了「已跟踪文件的修改」,原型阶段新增的文件(app_config、theme、 home_feed/play_ticket 模型、catalog_api、测试目录等)还是未入库状态 —— 而已入库的代码会 import 它们, 留在工作区会导致 HEAD 处的代码编译不过。一并归档,让 HEAD 自洽。 纯归档,无行为改动。
This commit is contained in:
1 parent
e1b98df509
commit
feecc349a0
19 files changed
+2210
No files matched your search
@@ -0,0 +1,132 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:nontonki/core/data/services/android_picture_in_picture.dart';
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
const channel = MethodChannel('test/pip_channel');
|
||||
final messenger =
|
||||
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger;
|
||||
|
||||
AndroidPictureInPicture pip() => AndroidPictureInPicture(channel: channel);
|
||||
|
||||
/// Simulates a native call arriving on the channel.
|
||||
Future<void> sendToDart(String method, Object? arguments) => messenger
|
||||
.handlePlatformMessage(
|
||||
channel.name,
|
||||
const StandardMethodCodec().encodeMethodCall(
|
||||
MethodCall(method, arguments),
|
||||
),
|
||||
(_) {},
|
||||
);
|
||||
|
||||
tearDown(() {
|
||||
debugDefaultTargetPlatformOverride = null;
|
||||
channel.setMethodCallHandler(null);
|
||||
});
|
||||
|
||||
group('platform support', () {
|
||||
test('android is the only supported target', () {
|
||||
debugDefaultTargetPlatformOverride = TargetPlatform.android;
|
||||
expect(pip().isPlatformSupported, isTrue);
|
||||
|
||||
for (final platform in <TargetPlatform>[
|
||||
TargetPlatform.iOS,
|
||||
TargetPlatform.macOS,
|
||||
TargetPlatform.linux,
|
||||
TargetPlatform.windows,
|
||||
TargetPlatform.fuchsia,
|
||||
]) {
|
||||
debugDefaultTargetPlatformOverride = platform;
|
||||
expect(
|
||||
pip().isPlatformSupported,
|
||||
isFalse,
|
||||
reason: '$platform must not claim picture in picture support',
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
group('enter', () {
|
||||
test('is refused without touching the channel off android', () async {
|
||||
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
|
||||
final calls = <MethodCall>[];
|
||||
messenger.setMockMethodCallHandler(channel, (call) async {
|
||||
calls.add(call);
|
||||
return true;
|
||||
});
|
||||
addTearDown(() => messenger.setMockMethodCallHandler(channel, null));
|
||||
|
||||
expect(await pip().enter(), isFalse);
|
||||
expect(calls, isEmpty);
|
||||
});
|
||||
|
||||
test('a missing native answer counts as a refusal', () async {
|
||||
debugDefaultTargetPlatformOverride = TargetPlatform.android;
|
||||
messenger.setMockMethodCallHandler(channel, (call) async => null);
|
||||
addTearDown(() => messenger.setMockMethodCallHandler(channel, null));
|
||||
|
||||
expect(await pip().enter(), isFalse);
|
||||
});
|
||||
|
||||
test('a native success is reported as entered', () async {
|
||||
debugDefaultTargetPlatformOverride = TargetPlatform.android;
|
||||
final calls = <MethodCall>[];
|
||||
messenger.setMockMethodCallHandler(channel, (call) async {
|
||||
calls.add(call);
|
||||
return true;
|
||||
});
|
||||
addTearDown(() => messenger.setMockMethodCallHandler(channel, null));
|
||||
|
||||
expect(await pip().enter(), isTrue);
|
||||
expect(calls.single.method, 'enter');
|
||||
expect(calls.single.arguments, isNull);
|
||||
});
|
||||
});
|
||||
|
||||
group('state listener', () {
|
||||
test('pip state changes reach the listener in order', () async {
|
||||
final received = <bool>[];
|
||||
pip().setStateListener(received.add);
|
||||
|
||||
await sendToDart('onPipChanged', true);
|
||||
await sendToDart('onPipChanged', false);
|
||||
|
||||
expect(received, [true, false]);
|
||||
});
|
||||
|
||||
test('only a literal true is read as enabled', () async {
|
||||
final received = <bool>[];
|
||||
pip().setStateListener(received.add);
|
||||
|
||||
await sendToDart('onPipChanged', null);
|
||||
await sendToDart('onPipChanged', 'yes');
|
||||
await sendToDart('onPipChanged', 1);
|
||||
|
||||
expect(received, [false, false, false]);
|
||||
});
|
||||
|
||||
test('unrelated native methods are ignored', () async {
|
||||
final received = <bool>[];
|
||||
pip().setStateListener(received.add);
|
||||
|
||||
await sendToDart('somethingElse', true);
|
||||
await sendToDart('onPipChanged', true);
|
||||
|
||||
expect(received, [true]);
|
||||
});
|
||||
|
||||
test('clearing the listener silences later callbacks', () async {
|
||||
final received = <bool>[];
|
||||
final observer = pip()..setStateListener(received.add);
|
||||
await sendToDart('onPipChanged', true);
|
||||
|
||||
observer.setStateListener(null);
|
||||
await sendToDart('onPipChanged', true);
|
||||
|
||||
expect(received, [true]);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user