Autoplay page narration after a three-second delay
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:integration_test/integration_test.dart';
|
||||
import 'package:lumen/domain/book.dart';
|
||||
import 'package:lumen/domain/game.dart';
|
||||
import 'package:lumen/main.dart';
|
||||
import 'package:lumen/services/narrator.dart';
|
||||
import 'package:lumen/services/progress.dart';
|
||||
|
||||
void main() {
|
||||
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||
testWidgets(
|
||||
'real recordings autoplay after three seconds and page turns cancel them',
|
||||
(tester) async {
|
||||
expect(const bool.fromEnvironment('QA_TEST'), true);
|
||||
final book = await Book.load();
|
||||
final voice = Narrator(book.tracks);
|
||||
final game = Game(book, Progress.memory())..showStory(0);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Notebook(game: game, adsEnabled: false, narrator: voice),
|
||||
),
|
||||
);
|
||||
await Future<void>.delayed(const Duration(milliseconds: 2300));
|
||||
await tester.pump();
|
||||
expect(voice.playing, false);
|
||||
await Future<void>.delayed(const Duration(milliseconds: 1800));
|
||||
await tester.pump();
|
||||
expect(voice.page, 'cottage.dedication');
|
||||
expect(voice.playing, true);
|
||||
expect(voice.error, isEmpty);
|
||||
game.showStory(1);
|
||||
await tester.pump();
|
||||
await Future<void>.delayed(const Duration(milliseconds: 600));
|
||||
game.showStory(2);
|
||||
await tester.pump();
|
||||
await Future<void>.delayed(const Duration(milliseconds: 3500));
|
||||
expect(voice.playing, false);
|
||||
expect(voice.page, isEmpty);
|
||||
game.showStory(1);
|
||||
await tester.pump();
|
||||
await Future<void>.delayed(const Duration(milliseconds: 4100));
|
||||
expect(voice.playing, true);
|
||||
expect(voice.page, 'cottage.window');
|
||||
await voice.stop();
|
||||
await Future<void>.delayed(const Duration(milliseconds: 3500));
|
||||
expect(voice.playing, false);
|
||||
expect(voice.autoplayPending, false);
|
||||
await tester.pumpWidget(const SizedBox());
|
||||
await tester.pumpAndSettle();
|
||||
},
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user