import 'package:flutter_test/flutter_test.dart';
import 'package:recording_tool/features/recording/platform/recording_channel_names.dart';
import 'package:recording_tool/features/recording/platform/recording_platform.dart';

void main() {
  group('RecordingChannelNames', () {
    test('uses stable bridge names without package binding', () {
      expect(RecordingChannelNames.method, 'app.record_tool/recording');
      expect(RecordingChannelNames.events, 'app.record_tool/recording_events');
    });
  });

  group('RecordingPlatform support', () {
    test('supports Android and iOS hosts only', () {
      expect(
        RecordingPlatform.supportsHost(isAndroid: true, isIOS: false),
        isTrue,
      );
      expect(
        RecordingPlatform.supportsHost(isAndroid: false, isIOS: true),
        isTrue,
      );
      expect(
        RecordingPlatform.supportsHost(isAndroid: false, isIOS: false),
        isFalse,
      );
    });
  });

  group('RecordingStopResult', () {
    test('parses file save result fields from platform payload', () {
      final result = RecordingStopResult.fromMap(<String, dynamic>{
        'outputPath': '/Documents/recordings/test.mov',
        'status': <String, dynamic>{'state': 'previewing'},
        'fileSaved': false,
        'fileErrorMessage': '保存到文件夹失败',
      });

      expect(result.outputPath, '/Documents/recordings/test.mov');
      expect(result.status.state, RecordingState.previewing);
      expect(result.fileSaved, isFalse);
      expect(result.fileErrorMessage, '保存到文件夹失败');
    });
  });
}
