mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-21 15:00:40 +00:00
updated golden tests
This commit is contained in:
parent
b991f7b7c3
commit
63f990ed7e
9 changed files with 73 additions and 39 deletions
|
@ -1,5 +1,4 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:lightmeter/data/models/app_feature.dart';
|
||||
import 'package:lightmeter/generated/l10n.dart';
|
||||
|
@ -11,7 +10,8 @@ import 'package:lightmeter/utils/text_height.dart';
|
|||
import 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart';
|
||||
|
||||
class LightmeterProScreen extends StatelessWidget {
|
||||
final features = Platform.isAndroid ? AppFeature.androidFeatures : AppFeature.iosFeatures;
|
||||
final features =
|
||||
defaultTargetPlatform == TargetPlatform.android ? AppFeature.androidFeatures : AppFeature.iosFeatures;
|
||||
|
||||
LightmeterProScreen({super.key});
|
||||
|
||||
|
@ -38,7 +38,7 @@ class LightmeterProScreen extends StatelessWidget {
|
|||
Dimens.paddingM,
|
||||
0,
|
||||
Dimens.paddingM,
|
||||
Dimens.paddingM,
|
||||
Dimens.paddingS,
|
||||
),
|
||||
child: Text(
|
||||
S.of(context).proFeaturesWhatsIncluded,
|
||||
|
|
BIN
test/screens/lightmeter_pro/goldens/lightmeter_pro_screen.png
Normal file
BIN
test/screens/lightmeter_pro/goldens/lightmeter_pro_screen.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 301 KiB |
|
@ -0,0 +1,49 @@
|
|||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:golden_toolkit/golden_toolkit.dart';
|
||||
import 'package:lightmeter/data/models/theme_type.dart';
|
||||
import 'package:lightmeter/screens/lightmeter_pro/screen_lightmeter_pro.dart';
|
||||
import 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../../application_mock.dart';
|
||||
import '../../utils/golden_test_set_theme.dart';
|
||||
|
||||
void main() {
|
||||
setUpAll(() {
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
});
|
||||
|
||||
testGoldens(
|
||||
'LightmeterProScreen golden test',
|
||||
(tester) async {
|
||||
final builder = DeviceBuilder();
|
||||
builder.addScenario(
|
||||
name: 'Get Pro',
|
||||
widget: const _MockLightmeterProFlow(),
|
||||
onCreate: (scenarioWidgetKey) async {
|
||||
if (scenarioWidgetKey.toString().contains('Dark')) {
|
||||
await setTheme<LightmeterProScreen>(tester, scenarioWidgetKey, ThemeType.dark);
|
||||
}
|
||||
},
|
||||
);
|
||||
await tester.pumpDeviceBuilder(builder);
|
||||
await screenMatchesGolden(
|
||||
tester,
|
||||
'lightmeter_pro_screen',
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
class _MockLightmeterProFlow extends StatelessWidget {
|
||||
const _MockLightmeterProFlow();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GoldenTestApplicationMock(
|
||||
productStatus: IAPProductStatus.purchasable,
|
||||
child: LightmeterProScreen(),
|
||||
);
|
||||
}
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 1.5 MiB After Width: | Height: | Size: 1.6 MiB |
|
@ -15,6 +15,7 @@ import 'package:shared_preferences/shared_preferences.dart';
|
|||
import '../../../integration_test/utils/finder_actions.dart';
|
||||
import '../../../integration_test/utils/platform_channel_mock.dart';
|
||||
import '../../application_mock.dart';
|
||||
import '../../utils/golden_test_set_theme.dart';
|
||||
|
||||
class _MeteringScreenConfig {
|
||||
final IAPProductStatus iapProductStatus;
|
||||
|
@ -54,16 +55,6 @@ void main() {
|
|||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
Future<void> setTheme(WidgetTester tester, Key scenarioWidgetKey, ThemeType themeType) async {
|
||||
final flow = find.descendant(
|
||||
of: find.byKey(scenarioWidgetKey),
|
||||
matching: find.byType(MeteringFlow),
|
||||
);
|
||||
final BuildContext context = tester.element(flow);
|
||||
UserPreferencesProvider.of(context).setThemeType(themeType);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
Future<void> takePhoto(WidgetTester tester, Key scenarioWidgetKey) async {
|
||||
final button = find.descendant(
|
||||
of: find.byKey(scenarioWidgetKey),
|
||||
|
@ -110,7 +101,7 @@ void main() {
|
|||
onCreate: (scenarioWidgetKey) async {
|
||||
await setEvSource(tester, scenarioWidgetKey, scenario.evSourceType);
|
||||
if (scenarioWidgetKey.toString().contains('Dark')) {
|
||||
await setTheme(tester, scenarioWidgetKey, ThemeType.dark);
|
||||
await setTheme<MeteringFlow>(tester, scenarioWidgetKey, ThemeType.dark);
|
||||
}
|
||||
if (scenario.evSourceType == EvSourceType.camera) {
|
||||
await takePhoto(tester, scenarioWidgetKey);
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 498 KiB After Width: | Height: | Size: 497 KiB |
|
@ -7,13 +7,13 @@ import 'package:lightmeter/data/models/ev_source_type.dart';
|
|||
import 'package:lightmeter/data/models/metering_screen_layout_config.dart';
|
||||
import 'package:lightmeter/data/models/theme_type.dart';
|
||||
import 'package:lightmeter/data/shared_prefs_service.dart';
|
||||
import 'package:lightmeter/providers/user_preferences_provider.dart';
|
||||
import 'package:lightmeter/screens/settings/flow_settings.dart';
|
||||
import 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../../application_mock.dart';
|
||||
import '../../utils/golden_test_set_theme.dart';
|
||||
|
||||
class _SettingsScreenConfig {
|
||||
final IAPProductStatus iapProductStatus;
|
||||
|
@ -33,16 +33,6 @@ final _testScenarios = [IAPProductStatus.purchased, IAPProductStatus.purchasable
|
|||
);
|
||||
|
||||
void main() {
|
||||
Future<void> setTheme(WidgetTester tester, Key scenarioWidgetKey, ThemeType themeType) async {
|
||||
final flow = find.descendant(
|
||||
of: find.byKey(scenarioWidgetKey),
|
||||
matching: find.byType(SettingsFlow),
|
||||
);
|
||||
final BuildContext context = tester.element(flow);
|
||||
UserPreferencesProvider.of(context).setThemeType(themeType);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
setUpAll(() {
|
||||
SharedPreferences.setMockInitialValues({
|
||||
UserPreferencesService.evSourceTypeKey: EvSourceType.camera.index,
|
||||
|
@ -73,7 +63,7 @@ void main() {
|
|||
widget: _MockSettingsFlow(productStatus: scenario.iapProductStatus),
|
||||
onCreate: (scenarioWidgetKey) async {
|
||||
if (scenarioWidgetKey.toString().contains('Dark')) {
|
||||
await setTheme(tester, scenarioWidgetKey, ThemeType.dark);
|
||||
await setTheme<SettingsFlow>(tester, scenarioWidgetKey, ThemeType.dark);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
|
|
@ -4,7 +4,6 @@ import 'package:golden_toolkit/golden_toolkit.dart';
|
|||
import 'package:lightmeter/data/models/exposure_pair.dart';
|
||||
import 'package:lightmeter/data/models/theme_type.dart';
|
||||
import 'package:lightmeter/data/shared_prefs_service.dart';
|
||||
import 'package:lightmeter/providers/user_preferences_provider.dart';
|
||||
import 'package:lightmeter/res/dimens.dart';
|
||||
import 'package:lightmeter/screens/shared/animated_circular_button/widget_button_circular_animated.dart';
|
||||
import 'package:lightmeter/screens/timer/flow_timer.dart';
|
||||
|
@ -13,6 +12,7 @@ import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
|
|||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../../application_mock.dart';
|
||||
import '../../utils/golden_test_set_theme.dart';
|
||||
|
||||
class _TimerScreenConfig {
|
||||
final ShutterSpeedValue shutterSpeedValue;
|
||||
|
@ -52,16 +52,6 @@ final _testScenarios = [
|
|||
);
|
||||
|
||||
void main() {
|
||||
Future<void> setTheme(WidgetTester tester, Key scenarioWidgetKey, ThemeType themeType) async {
|
||||
final flow = find.descendant(
|
||||
of: find.byKey(scenarioWidgetKey),
|
||||
matching: find.byType(TimerFlow),
|
||||
);
|
||||
final BuildContext context = tester.element(flow);
|
||||
UserPreferencesProvider.of(context).setThemeType(themeType);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
Future<void> toggleTimer(WidgetTester tester, Key scenarioWidgetKey) async {
|
||||
final button = find.descendant(
|
||||
of: find.byKey(scenarioWidgetKey),
|
||||
|
@ -98,7 +88,7 @@ void main() {
|
|||
widget: _MockTimerFlow(scenario.shutterSpeedValue),
|
||||
onCreate: (scenarioWidgetKey) async {
|
||||
if (scenarioWidgetKey.toString().contains('Dark')) {
|
||||
await setTheme(tester, scenarioWidgetKey, ThemeType.dark);
|
||||
await setTheme<TimerFlow>(tester, scenarioWidgetKey, ThemeType.dark);
|
||||
}
|
||||
if (!scenario.isStopped) {
|
||||
await toggleTimer(tester, scenarioWidgetKey);
|
||||
|
|
14
test/utils/golden_test_set_theme.dart
Normal file
14
test/utils/golden_test_set_theme.dart
Normal file
|
@ -0,0 +1,14 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:lightmeter/data/models/theme_type.dart';
|
||||
import 'package:lightmeter/providers/user_preferences_provider.dart';
|
||||
|
||||
Future<void> setTheme<T>(WidgetTester tester, Key scenarioWidgetKey, ThemeType themeType) async {
|
||||
final flow = find.descendant(
|
||||
of: find.byKey(scenarioWidgetKey),
|
||||
matching: find.byType(T),
|
||||
);
|
||||
final BuildContext context = tester.element(flow);
|
||||
UserPreferencesProvider.of(context).setThemeType(themeType);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
Loading…
Reference in a new issue