Add the Flutter video editing application with project management, media import, timeline editing, preview, AI assistance, diagnostics and settings. Include shared UI and native host packages, platform runners, application tests and release tooling. Provide usage and contribution guides, the MIT license and third-party notices. Exclude local credentials, build outputs and validation data.
87 lines
3.0 KiB
Dart
87 lines
3.0 KiB
Dart
// Dedicated test app: never distribute its release packages.
|
|
import 'dart:async';
|
|
import 'dart:convert';
|
|
import 'dart:io';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
|
|
const channel = MethodChannel('deskup');
|
|
const smokeRoot = String.fromEnvironment('CUTDEX_UPDATE_SMOKE_ROOT');
|
|
|
|
void main() {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
// The isolated smoke fixture depends only on Flutter, without Riverpod.
|
|
// ignore: riverpod_lint/missing_provider_scope
|
|
runApp(
|
|
const MaterialApp(
|
|
home: Scaffold(body: Center(child: Text('Cutdex update test'))),
|
|
),
|
|
);
|
|
unawaited(runSmoke());
|
|
}
|
|
|
|
Future<Map<String, Object?>> status() async =>
|
|
await channel.invokeMapMethod<String, Object?>('status') ?? {};
|
|
|
|
Future<Map<String, Object?>> waitFor(
|
|
bool Function(Map<String, Object?>) predicate,
|
|
) async {
|
|
final deadline = DateTime.now().add(const Duration(minutes: 3));
|
|
while (DateTime.now().isBefore(deadline)) {
|
|
final value = await status();
|
|
if (predicate(value)) return value;
|
|
await Future<void>.delayed(const Duration(milliseconds: 100));
|
|
}
|
|
throw StateError(
|
|
'Timed out waiting for native update state: ${await status()}',
|
|
);
|
|
}
|
|
|
|
Future<void> record(String name, Object value) async {
|
|
await File('$smokeRoot/$name.json')
|
|
.writeAsString(jsonEncode(value), flush: true);
|
|
}
|
|
|
|
Future<void> runSmoke() async {
|
|
if (smokeRoot.isEmpty) {
|
|
throw StateError('Set CUTDEX_UPDATE_SMOKE_ROOT for this test app');
|
|
}
|
|
try {
|
|
await channel.invokeMethod<void>('ready');
|
|
final initial = await waitFor(
|
|
(value) => value['configured'] == true && value['canCheck'] == true,
|
|
);
|
|
await channel.invokeMethod<void>('check');
|
|
var checked = await waitFor((value) => value['canCheck'] == true);
|
|
if (initial['build'] == '900002') {
|
|
if (checked['phase'] != 'current') {
|
|
throw StateError('Updated version was offered again: $checked');
|
|
}
|
|
await record('after', checked);
|
|
exit(0);
|
|
}
|
|
if (checked['phase'] != 'available' ||
|
|
checked['availableVersion'] != '1.0.0-build.900002') {
|
|
throw StateError('Expected version 1.0.0-build.900002: $checked');
|
|
}
|
|
await channel.invokeMethod<void>('download');
|
|
final rejected = await waitFor((value) => value['canCheck'] == true);
|
|
if (rejected['phase'] == 'ready' || rejected['error'] == '') {
|
|
throw StateError('Corrupted package was not rejected: $rejected');
|
|
}
|
|
await record('corrupt-rejected', rejected);
|
|
await channel.invokeMethod<void>('download');
|
|
checked = await waitFor((value) => value['canCheck'] == true);
|
|
if (checked['phase'] != 'ready' || checked['error'] != '') {
|
|
throw StateError('Could not download valid update: $checked');
|
|
}
|
|
await record('before', checked);
|
|
await channel.invokeMethod<void>('validateInstall');
|
|
await channel.invokeMethod<void>('install');
|
|
} catch (error, stack) {
|
|
await record('failure', {'error': '$error', 'stack': '$stack'});
|
|
exit(1);
|
|
}
|
|
}
|