Gitea CI / Check code and tests (push) Successful in 6m37s
Gitea CI / Build Windows x64 app (push) Successful in 3m18s
Gitea CI / Build Android APK (push) Successful in 3m47s
Gitea CI / Audit and package Windows x64 (push) Successful in 1m7s
Gitea CI / Assemble and validate CI artifacts (push) Successful in 50s
Gitea CI / Gitea CI passed (push) Successful in 2s
Gitea Release / Prepare draft Release (push) Successful in 9s
Gitea Release / Upload Android to draft Release (push) Successful in 16s
Gitea Release / Upload Windows to draft Release (push) Successful in 22s
Gitea Release / Verify and publish Release (push) Successful in 14s
123 lines
4.1 KiB
Dart
123 lines
4.1 KiB
Dart
import 'dart:async';
|
|
import 'dart:io';
|
|
|
|
import 'package:cutdex/persistence/app_database.dart';
|
|
import 'package:cutdex/persistence/app_settings_repositories.dart';
|
|
import 'package:cutdex/workspace/persistence/recent_projects.dart';
|
|
import 'package:cutdex/workspace/projects.dart';
|
|
import 'package:cutdex/workspace/view_settings.dart';
|
|
import 'package:drift/native.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
import '../support/memory_app_settings.dart';
|
|
|
|
void main() {
|
|
TestWidgetsFlutterBinding.ensureInitialized();
|
|
for (final superseded in [false, true]) {
|
|
test(
|
|
'project layout is prepared before publication (superseded: $superseded)',
|
|
() async {
|
|
final root = await Directory.systemTemp.createTemp(
|
|
'cutdex-project-layout-',
|
|
);
|
|
final database = AppDatabase(NativeDatabase.memory());
|
|
final layouts = _DelayedLayouts();
|
|
final container = ProviderContainer(
|
|
overrides: [
|
|
appDatabaseProvider.overrideWithValue(database),
|
|
recentProjectsProvider.overrideWithValue(
|
|
MemoryRecentProjectsRepository(),
|
|
),
|
|
resourceLocationSettingsRepositoryProvider.overrideWithValue(
|
|
MemoryResourceLocationSettingsRepository(root.path),
|
|
),
|
|
projectViewSettingsRepositoryProvider.overrideWithValue(layouts),
|
|
],
|
|
);
|
|
try {
|
|
final projects = container.read(projectsProvider.notifier);
|
|
expect(
|
|
await projects.open('${root.path}/First.cutdex', name: 'First'),
|
|
isTrue,
|
|
);
|
|
final initial = container.read(projectsProvider).requireValue;
|
|
var current = true;
|
|
final opening = projects.open(
|
|
'${root.path}/Second.cutdex',
|
|
name: 'Second',
|
|
isCurrent: () => current,
|
|
);
|
|
final targetId = await layouts.requested.future;
|
|
expect(
|
|
container.read(projectsProvider).requireValue.activeProject,
|
|
initial.activeProject,
|
|
);
|
|
expect(
|
|
container.read(projectsProvider).requireValue.timeline,
|
|
initial.timeline,
|
|
);
|
|
expect(
|
|
container.read(projectsProvider).requireValue.projectBusy,
|
|
isTrue,
|
|
);
|
|
expect(
|
|
container.read(projectViewSettingsProvider(targetId)).isLoading,
|
|
isTrue,
|
|
);
|
|
current = !superseded;
|
|
layouts.prepared.complete(
|
|
const ProjectViewSettingsData(
|
|
propertiesOpen: true,
|
|
timelineHeight: 320,
|
|
),
|
|
);
|
|
expect(await opening, !superseded);
|
|
final published = container.read(projectsProvider).requireValue;
|
|
expect(
|
|
published.activeProject?.id,
|
|
superseded ? initial.activeProject!.id : targetId,
|
|
);
|
|
expect(published.projectBusy, isFalse);
|
|
expect(published.error, isNull);
|
|
expect(
|
|
container
|
|
.read(projectViewSettingsProvider(targetId))
|
|
.requireValue
|
|
.propertiesOpen,
|
|
isTrue,
|
|
);
|
|
expect(
|
|
container
|
|
.read(projectViewSettingsProvider(targetId))
|
|
.requireValue
|
|
.timelineHeight,
|
|
320,
|
|
);
|
|
} finally {
|
|
await container.read(projectsProvider.notifier).prepareToQuit();
|
|
container.dispose();
|
|
await database.close();
|
|
await root.delete(recursive: true);
|
|
}
|
|
},
|
|
);
|
|
}
|
|
}
|
|
|
|
class _DelayedLayouts implements ProjectViewSettingsRepository {
|
|
String? _firstProjectId;
|
|
final requested = Completer<String>();
|
|
final prepared = Completer<ProjectViewSettingsData>();
|
|
@override
|
|
Future<ProjectViewSettingsData> load(String projectId) async {
|
|
_firstProjectId ??= projectId;
|
|
if (projectId == _firstProjectId) return const ProjectViewSettingsData();
|
|
requested.complete(projectId);
|
|
return prepared.future;
|
|
}
|
|
|
|
@override
|
|
Future<void> save(String projectId, ProjectViewSettingsData settings) async {}
|
|
}
|