86 lines
3.6 KiB
Dart
86 lines
3.6 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:audio_session/audio_session.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:integration_test/integration_test.dart';
|
|
import 'package:just_audio/just_audio.dart';
|
|
import 'package:lumen/domain/book.dart';
|
|
import 'package:lumen/domain/game.dart';
|
|
import 'package:lumen/main.dart';
|
|
import 'package:lumen/services/progress.dart';
|
|
|
|
void main() {
|
|
final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
|
testWidgets('Qwen readings decode and mix with bridge atmosphere', (
|
|
tester,
|
|
) async {
|
|
expect(const bool.fromEnvironment('QA_TEST'), true);
|
|
final book = await Book.load();
|
|
final session = await AudioSession.instance;
|
|
await session.configure(const AudioSessionConfiguration.speech());
|
|
final probe = AudioPlayer();
|
|
// Exercise the end of every fully regenerated recording.
|
|
for (final track in book.tracks.values) {
|
|
await probe.setAsset('assets/audio/${track['file']}');
|
|
expect(probe.duration!.inMilliseconds, closeTo(track['durationMs'], 5));
|
|
final start = Duration(milliseconds: track['cues'].last['startMs']);
|
|
await probe.seek(start);
|
|
await probe.setVolume(.3);
|
|
unawaited(probe.play());
|
|
await Future<void>.delayed(const Duration(milliseconds: 350));
|
|
expect(probe.position, greaterThanOrEqualTo(start));
|
|
expect(probe.processingState, ProcessingState.ready);
|
|
await probe.stop();
|
|
}
|
|
await probe.dispose();
|
|
final g = Game(book, Progress.memory({'story_access_level': 11}));
|
|
g.briefing(6);
|
|
await tester.pumpWidget(LumenApp(game: g, adsEnabled: false));
|
|
await tester.pumpAndSettle();
|
|
await tester.ensureVisible(find.text('Play this reading'));
|
|
await tester.pumpAndSettle();
|
|
await tester.tap(find.text('Play this reading'));
|
|
await Future<void>.delayed(const Duration(seconds: 2));
|
|
await tester.pump();
|
|
expect(find.text('Pause recording'), findsOneWidget);
|
|
// The host captures AudioFlinger during this interval to verify two real tracks.
|
|
debugPrint('MIXED_AUDIO_READY: bridge water and narration');
|
|
await Future<void>.delayed(const Duration(seconds: 12));
|
|
await tester.tap(find.text('Pause recording'));
|
|
await tester.pumpAndSettle();
|
|
expect(find.text('Resume recording'), findsOneWidget);
|
|
await tester.tap(find.text('Sound & atmosphere'));
|
|
await tester.pumpAndSettle();
|
|
await tester.tap(find.byType(SwitchListTile));
|
|
await tester.pumpAndSettle();
|
|
expect(g.progress.flag('ambience_enabled'), false);
|
|
await tester.tap(find.text('Keep going'));
|
|
await tester.pumpAndSettle();
|
|
await tester.tap(find.text('Stop'));
|
|
await tester.pumpAndSettle();
|
|
|
|
// One Play control carries Mara's letter into the present-day narrator.
|
|
g.showStory(1);
|
|
await tester.pumpAndSettle();
|
|
await tester.ensureVisible(find.text('Play this reading'));
|
|
await tester.pumpAndSettle();
|
|
await tester.tap(find.text('Play this reading'));
|
|
final narratorCue = (book.tracks['cottage.window']['cues'] as List)
|
|
.firstWhere((cue) => cue['speaker'] == 'Narrator');
|
|
await Future<void>.delayed(
|
|
Duration(milliseconds: (narratorCue['startMs'] as int) + 1800),
|
|
);
|
|
await tester.pump();
|
|
expect(find.text('Narrator · recorded story'), findsOneWidget);
|
|
await tester.tap(find.text('Pause recording'));
|
|
await tester.pumpAndSettle();
|
|
expect(tester.takeException(), isNull);
|
|
await binding.convertFlutterSurfaceToImage();
|
|
await tester.pump();
|
|
await binding.takeScreenshot('expanded-narration-continuation');
|
|
await tester.pumpWidget(const SizedBox());
|
|
await tester.pumpAndSettle();
|
|
});
|
|
}
|