Skip to content

Commit

Permalink
integration_test: add testing theme mode setting (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
wfleischer authored Dec 4, 2024
1 parent 9700ed7 commit 5a92ee1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ i18n_untranslated.json
.pub-cache/
.pub/
/build/
/coverage/

# Symbolication related
app.*.symbols
Expand Down
22 changes: 22 additions & 0 deletions integration_test/app_test.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:collection/collection.dart';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
Expand Down Expand Up @@ -1057,6 +1058,27 @@ void main() async {
expect(find.byKey(const Key('version')), findsOneWidget);
expect(find.byKey(const Key('copyright')), findsOneWidget);

await tester.tap(find.byIcon(Icons.light_mode));
await tester.pumpAndSettle();

final BuildContext context = tester.element(find.byType(Scaffold));
expect(Theme.of(context).brightness, Brightness.light);

await tester.tap(find.byIcon(Icons.auto_mode));
await tester.pumpAndSettle();

expect(Theme.of(context).brightness, SchedulerBinding.instance.platformDispatcher.platformBrightness);

await tester.tap(find.byIcon(Icons.dark_mode));
await tester.pumpAndSettle();

expect(Theme.of(context).brightness, Brightness.dark);

await tester.tap(find.byIcon(Icons.auto_mode));
await tester.pumpAndSettle();

expect(Theme.of(context).brightness, SchedulerBinding.instance.platformDispatcher.platformBrightness);

await tester.pageBack();
await tester.pumpAndSettle();

Expand Down

0 comments on commit 5a92ee1

Please sign in to comment.