-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Launch UI tests, with screenshots taking. Fix bug in add/modify entry screen
- Loading branch information
Showing
17 changed files
with
376 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule fastlane
updated
from 9ec655 to 987c66
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import 'package:drift/native.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:hooks_riverpod/hooks_riverpod.dart'; | ||
import 'package:integration_test/integration_test.dart'; | ||
import 'package:tagros_comptes/generated/l10n.dart'; | ||
import 'package:tagros_comptes/main.dart'; | ||
import 'package:tagros_comptes/monetization/domain/premium_plan.dart'; | ||
import 'package:tagros_comptes/state/providers.dart'; | ||
import 'package:tagros_comptes/tagros/data/source/db/app_database.dart'; | ||
import 'package:tagros_comptes/tagros/data/source/db/db_providers.dart'; | ||
import 'package:tagros_comptes/theme/domain/theme.dart'; | ||
import 'package:tagros_comptes/theme/domain/theme_providers.dart'; | ||
import 'package:tagros_comptes/theme/domain/theme_repository.dart'; | ||
import 'package:universal_platform/universal_platform.dart'; | ||
|
||
Future<void> createApp(WidgetTester widgetTester, | ||
{String lang = 'en', ThemeColor? themeColor}) async { | ||
await S.load(Locale(lang)); | ||
|
||
await widgetTester.pumpWidget(ProviderScope( | ||
overrides: [ | ||
themeRepositoryProvider.overrideWithValue( | ||
_FakeThemeRepository(themeColor: themeColor), | ||
), | ||
databaseProvider.overrideWith((ref) { | ||
final appDatabase = AppDatabase(NativeDatabase.memory()); | ||
ref.onDispose(() { | ||
appDatabase.close(); | ||
}); | ||
return appDatabase; | ||
}), | ||
isPremiumProvider.overrideWith((ref) => true), | ||
showAdsProvider.overrideWith((ref) => ShowAds.hide), | ||
bannerAdsProvider.overrideWith((ref, arg) => Future.error('')), | ||
], | ||
child: MyApp(locale: Locale(lang)), | ||
)); | ||
} | ||
|
||
/// Take a screenshot of the current screen. | ||
/// Cannot take more than one screenshot per test. | ||
Future<void> takeScreenshot( | ||
IntegrationTestWidgetsFlutterBinding binding, WidgetTester tester, | ||
{required String screenshotName, bool settle = true}) async { | ||
if (UniversalPlatform.isAndroid) { | ||
await binding.convertFlutterSurfaceToImage(); | ||
if (settle) { | ||
await tester.pumpAndSettle(); | ||
} | ||
} | ||
await binding.takeScreenshot(screenshotName); | ||
} | ||
|
||
class _FakeThemeRepository extends Fake implements ThemeRepository { | ||
final ThemeColor _themeColor; | ||
|
||
_FakeThemeRepository({ThemeColor? themeColor}) | ||
: _themeColor = themeColor ?? ThemeColor.defaultTheme(); | ||
|
||
@override | ||
Stream<ThemeData> get themeData => Stream.value(_themeColor.toDataTheme); | ||
|
||
@override | ||
Stream<ThemeColor> selectedTheme() { | ||
return Future.value(ThemeColor.defaultTheme()).asStream(); | ||
} | ||
|
||
@override | ||
Stream<List<ThemeColor>> allThemes() { | ||
return Future.value(ThemeColor.allThemes).asStream(); | ||
} | ||
|
||
@override | ||
Future<void> selectTheme({required int id}) async {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
import 'dart:math'; | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:integration_test/integration_test.dart'; | ||
import 'package:tagros_comptes/generated/l10n.dart'; | ||
import 'package:tagros_comptes/tagros/domain/game/poignee.dart'; | ||
|
||
import 'common.dart'; | ||
|
||
void main() { | ||
final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized(); | ||
const namesEn = ['Mary', 'David', 'Lisa', 'Ronald', 'Sarah']; | ||
const namesFr = ['Jade', 'David', 'Lisa', 'Raphaël', 'Sarah']; | ||
group('Taking screenshots', () { | ||
testWidgets('Player dialog with 5 players en', (t) async { | ||
await createApp(t, lang: 'en'); | ||
await t.pumpAndSettle(); | ||
await _newGame(t, namesEn); | ||
for (var i = 0; i < 20; i++) { | ||
await _addRandomRound(t, namesEn); | ||
} | ||
|
||
await takeScreenshot(binding, t, screenshotName: '1_en-US'); | ||
}); | ||
testWidgets('Player dialog with 5 players fr', (t) async { | ||
await createApp(t, lang: 'fr'); | ||
await t.pumpAndSettle(); | ||
await _newGame(t, namesFr); | ||
for (var i = 0; i < 20; i++) { | ||
await _addRandomRound(t, namesFr); | ||
} | ||
|
||
await takeScreenshot(binding, t, screenshotName: '1_fr-FR'); | ||
}); | ||
|
||
testWidgets('Edit game en', (t) async { | ||
await createApp(t, lang: 'en'); | ||
await t.pumpAndSettle(); | ||
final names = namesEn.take(4).toList(); | ||
await _newGame(t, names); | ||
|
||
await _editGame(t, names); | ||
await takeScreenshot(binding, t, | ||
screenshotName: '2_en-US', settle: false); | ||
}); | ||
|
||
testWidgets('Edit game fr', (t) async { | ||
await createApp(t, lang: 'fr'); | ||
await t.pumpAndSettle(); | ||
final names = namesFr.take(4).toList(); | ||
await _newGame(t, names); | ||
await _editGame(t, names); | ||
|
||
await takeScreenshot(binding, t, | ||
screenshotName: '2_fr-FR', settle: false); | ||
}); | ||
}); | ||
} | ||
|
||
Future<void> _editGame( | ||
WidgetTester t, | ||
List<String> names, | ||
) async { | ||
await t.tap(find.byIcon(Icons.add)); | ||
await t.pumpAndSettle(); | ||
|
||
final score = Random().nextInt(91).toString(); | ||
await t.enterText(find.byType(EditableText), score); | ||
await t.tap(find.byKey(const ValueKey('dropdown-contract'))); | ||
await t.pumpAndSettle(); | ||
await t.tap(find.text(S.current.priseTypeGardeContre)); | ||
await t.pumpAndSettle(); | ||
await t.tap(find.byKey(const ValueKey('dropdown-oudlers'))); | ||
await t.pumpAndSettle(); | ||
await t.tap(find.text('3')); | ||
await t.pumpAndSettle(); | ||
await t.tap(find.byType(Checkbox).first); | ||
await t.pumpAndSettle(); | ||
final handful = find.byKey(const ValueKey('dropdown-handful')); | ||
await t.tap(handful); | ||
await t.pumpAndSettle(); | ||
await t.tap(find.text(S.current.addModifyPoigneeNbTrumps( | ||
getNbAtouts(PoigneeType.double, names.length), | ||
PoigneeType.double.displayName))); | ||
await t.pump(); | ||
} | ||
|
||
Future<void> _newGame(WidgetTester tester, List<String> names) async { | ||
await tester.tap(find.text(S.current.newGame)); | ||
|
||
await tester.pumpAndSettle(); | ||
|
||
final editText = find.byType(EditableText); | ||
for (final name in names) { | ||
await tester.enterText(editText, name); | ||
await tester.testTextInput.receiveAction(TextInputAction.next); | ||
} | ||
|
||
await tester.tap(find.text('OK')); | ||
await tester.pumpAndSettle(); | ||
} | ||
|
||
Future<void> _addRandomRound(WidgetTester tester, List<String> names) async { | ||
await tester.tap(find.byIcon(Icons.add)); | ||
await tester.pumpAndSettle(); | ||
|
||
var name = names[Random().nextInt(names.length)]; | ||
await tester.dragUntilVisible( | ||
find.descendant( | ||
of: find.byKey(const ValueKey('player1')), matching: find.text(name)), | ||
find.byKey(const ValueKey('player1')), | ||
const Offset(500, 0)); | ||
await tester.tap(find.text(name).first); | ||
name = names[Random().nextInt(names.length)]; | ||
await tester.dragUntilVisible( | ||
find.descendant( | ||
of: find.byKey(const ValueKey('player2')), matching: find.text(name)), | ||
find.byKey(const ValueKey('player2')), | ||
const Offset(500, 0)); | ||
await tester.tap(find.text(name).last); | ||
final score = Random().nextInt(91).toString(); | ||
await tester.enterText(find.byType(EditableText), score); | ||
|
||
await tester.tap(find.byIcon(Icons.check)); | ||
await tester.pump(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:integration_test/integration_test.dart'; | ||
|
||
import 'common.dart'; | ||
|
||
void main() { | ||
IntegrationTestWidgetsFlutterBinding.ensureInitialized(); | ||
|
||
group('smoke testing', () { | ||
testWidgets('go to themes screen smoke test', (t) async { | ||
await createApp(t); | ||
|
||
expect(find.text('New game'), findsOneWidget); | ||
|
||
expect(find.text('Continue'), findsOneWidget); | ||
expect(find.text('Settings'), findsNothing); | ||
|
||
await t.tap(find.byIcon(Icons.settings)); | ||
await t.pumpAndSettle(); | ||
|
||
expect(find.text('Settings'), findsOneWidget); | ||
|
||
expect(find.text('New game'), findsNothing); | ||
expect(find.text('Continue'), findsNothing); | ||
|
||
await t.tap(find.text('Theme')); | ||
await t.pumpAndSettle(); | ||
|
||
expect(find.text('Classic'), findsOneWidget); | ||
expect(find.text('Chocolate'), findsOneWidget); | ||
|
||
await t.tap(find.text('Chocolate')); | ||
|
||
expect(find.text('Chocolate'), findsOneWidget); | ||
expect(find.text('Classic'), findsOneWidget); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.