mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-23 16:00:41 +00:00
Fixed integration tests
This commit is contained in:
parent
7f8ea54c6e
commit
90bfe7c7b8
8 changed files with 44 additions and 16 deletions
|
@ -17,6 +17,7 @@ import 'package:lightmeter/screens/settings/components/shared/dialog_filter/widg
|
|||
import 'package:lightmeter/screens/settings/components/shared/dialog_range_picker/widget_dialog_picker_range.dart';
|
||||
import 'package:lightmeter/screens/settings/screen_settings.dart';
|
||||
import 'package:lightmeter/utils/double_to_zoom.dart';
|
||||
import 'package:lightmeter/utils/platform_utils.dart';
|
||||
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
@ -27,7 +28,7 @@ import 'utils/expectations.dart';
|
|||
|
||||
@isTest
|
||||
void testE2E(String description) {
|
||||
setUp(() {
|
||||
setUp(() async {
|
||||
SharedPreferences.setMockInitialValues({
|
||||
/// Metering values
|
||||
UserPreferencesService.evSourceTypeKey: EvSourceType.camera.index,
|
||||
|
@ -38,6 +39,8 @@ void testE2E(String description) {
|
|||
MeteringScreenLayoutFeature.filmPicker: true,
|
||||
}.toJson(),
|
||||
),
|
||||
|
||||
UserPreferencesService.seenChangelogVersionKey: await const PlatformUtils().version,
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ import 'package:lightmeter/screens/metering/components/shared/readings_container
|
|||
import 'package:lightmeter/screens/metering/components/shared/readings_container/components/extreme_exposure_pairs_container/widget_container_extreme_exposure_pairs.dart';
|
||||
import 'package:lightmeter/screens/metering/components/shared/readings_container/components/film_picker/widget_picker_film.dart';
|
||||
import 'package:lightmeter/screens/settings/screen_settings.dart';
|
||||
import 'package:lightmeter/utils/platform_utils.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
|
@ -22,7 +23,7 @@ void testToggleLayoutFeatures(String description) {
|
|||
group(
|
||||
description,
|
||||
() {
|
||||
setUp(() {
|
||||
setUp(() async {
|
||||
SharedPreferences.setMockInitialValues({
|
||||
/// Metering values
|
||||
UserPreferencesService.evSourceTypeKey: EvSourceType.camera.index,
|
||||
|
@ -33,6 +34,7 @@ void testToggleLayoutFeatures(String description) {
|
|||
MeteringScreenLayoutFeature.filmPicker: true,
|
||||
}.toJson(),
|
||||
),
|
||||
UserPreferencesService.seenChangelogVersionKey: await const PlatformUtils().version,
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import 'package:lightmeter/screens/metering/components/shared/readings_container
|
|||
import 'package:lightmeter/screens/metering/components/shared/readings_container/components/nd_picker/widget_picker_nd.dart';
|
||||
import 'package:lightmeter/screens/settings/components/shared/disable/widget_disable.dart';
|
||||
import 'package:lightmeter/screens/settings/screen_settings.dart';
|
||||
import 'package:lightmeter/utils/platform_utils.dart';
|
||||
import 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
@ -38,6 +39,7 @@ void testPurchases(String description) {
|
|||
MeteringScreenLayoutFeature.filmPicker: true,
|
||||
}.toJson(),
|
||||
),
|
||||
UserPreferencesService.seenChangelogVersionKey: await const PlatformUtils().version,
|
||||
});
|
||||
|
||||
await tester.pumpApplication(productStatus: IAPProductStatus.purchasable);
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:lightmeter/generated/l10n.dart';
|
||||
import 'package:lightmeter/screens/shared/release_notes_dialog/widget_dialog_release_notes.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import 'package:lightmeter/utils/platform_utils.dart';
|
||||
|
||||
class VersionListTile extends StatelessWidget {
|
||||
const VersionListTile({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FutureBuilder<PackageInfo>(
|
||||
future: PackageInfo.fromPlatform(),
|
||||
return FutureBuilder<({String buildNumber, String version})>(
|
||||
future: const PlatformUtils().buildVersion,
|
||||
builder: (context, snapshot) => ListTile(
|
||||
leading: const Icon(Icons.info_outline),
|
||||
title: Text(S.of(context).version),
|
||||
|
|
|
@ -3,19 +3,23 @@ import 'dart:async';
|
|||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:lightmeter/data/shared_prefs_service.dart';
|
||||
import 'package:lightmeter/screens/shared/release_notes_dialog/state_release_notes.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
import 'package:lightmeter/utils/platform_utils.dart';
|
||||
|
||||
class ReleaseNotesBloc extends Cubit<ReleaseNotesState> {
|
||||
final UserPreferencesService _userPreferencesService;
|
||||
final PlatformUtils _platformUtils;
|
||||
|
||||
ReleaseNotesBloc(this._userPreferencesService) : super(const HiddenReleaseNotesDialogState()) {
|
||||
ReleaseNotesBloc(
|
||||
this._userPreferencesService,
|
||||
this._platformUtils,
|
||||
) : super(const HiddenReleaseNotesDialogState()) {
|
||||
_showDialogIfNeeded();
|
||||
}
|
||||
|
||||
Future<void> _showDialogIfNeeded() async {
|
||||
PackageInfo.fromPlatform().then((value) {
|
||||
if (value.version != _userPreferencesService.seenChangelogVersion) {
|
||||
emit(ShowReleaseNotesDialogState(value.version));
|
||||
_platformUtils.version.then((version) {
|
||||
if (version != _userPreferencesService.seenChangelogVersion) {
|
||||
emit(ShowReleaseNotesDialogState(version));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import 'package:lightmeter/providers/services_provider.dart';
|
|||
import 'package:lightmeter/screens/shared/release_notes_dialog/bloc_release_notes.dart';
|
||||
import 'package:lightmeter/screens/shared/release_notes_dialog/state_release_notes.dart';
|
||||
import 'package:lightmeter/screens/shared/release_notes_dialog/widget_dialog_release_notes.dart';
|
||||
import 'package:lightmeter/utils/platform_utils.dart';
|
||||
|
||||
class ReleaseNotesFlow extends StatelessWidget {
|
||||
final Widget child;
|
||||
|
@ -13,7 +14,10 @@ class ReleaseNotesFlow extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (context) => ReleaseNotesBloc(ServicesProvider.of(context).userPreferencesService),
|
||||
create: (context) => ReleaseNotesBloc(
|
||||
ServicesProvider.of(context).userPreferencesService,
|
||||
const PlatformUtils(),
|
||||
),
|
||||
child: BlocListener<ReleaseNotesBloc, ReleaseNotesState>(
|
||||
listener: (context, state) {
|
||||
if (state is ShowReleaseNotesDialogState) {
|
||||
|
|
10
lib/utils/platform_utils.dart
Normal file
10
lib/utils/platform_utils.dart
Normal file
|
@ -0,0 +1,10 @@
|
|||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
|
||||
class PlatformUtils {
|
||||
const PlatformUtils();
|
||||
|
||||
Future<String> get version async => (await PackageInfo.fromPlatform()).version;
|
||||
|
||||
Future<({String version, String buildNumber})> get buildVersion async =>
|
||||
PackageInfo.fromPlatform().then((value) => (version: value.version, buildNumber: value.buildNumber));
|
||||
}
|
|
@ -22,6 +22,7 @@ import 'package:lightmeter/screens/settings/components/metering/components/equip
|
|||
import 'package:lightmeter/screens/settings/screen_settings.dart';
|
||||
import 'package:lightmeter/screens/shared/animated_circular_button/widget_button_circular_animated.dart';
|
||||
import 'package:lightmeter/screens/timer/screen_timer.dart';
|
||||
import 'package:lightmeter/utils/platform_utils.dart';
|
||||
import 'package:m3_lightmeter_resources/m3_lightmeter_resources.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
|
@ -42,13 +43,13 @@ void main() {
|
|||
final binding = IntegrationTestWidgetsFlutterBinding();
|
||||
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
void mockSharedPrefs({
|
||||
Future<void> mockSharedPrefs({
|
||||
int iso = 400,
|
||||
int nd = 0,
|
||||
double calibration = 0.0,
|
||||
required ThemeType theme,
|
||||
required Color color,
|
||||
}) {
|
||||
}) async {
|
||||
SharedPreferences.setMockInitialValues({
|
||||
/// Metering values
|
||||
UserPreferencesService.evSourceTypeKey: EvSourceType.camera.index,
|
||||
|
@ -78,6 +79,8 @@ void main() {
|
|||
UserPreferencesService.themeTypeKey: theme.index,
|
||||
UserPreferencesService.primaryColorKey: color.value,
|
||||
UserPreferencesService.dynamicColorKey: false,
|
||||
|
||||
UserPreferencesService.seenChangelogVersionKey: await const PlatformUtils().version,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -87,7 +90,7 @@ void main() {
|
|||
|
||||
/// Generates several screenshots with the light theme
|
||||
testWidgets('Generate light theme screenshots', (tester) async {
|
||||
mockSharedPrefs(theme: ThemeType.light, color: _lightThemeColor);
|
||||
await mockSharedPrefs(theme: ThemeType.light, color: _lightThemeColor);
|
||||
await tester.pumpApplication(
|
||||
availableFilms: [_mockFilm],
|
||||
filmsInUse: [_mockFilm],
|
||||
|
@ -127,7 +130,7 @@ void main() {
|
|||
testWidgets(
|
||||
'Generate dark theme screenshots',
|
||||
(tester) async {
|
||||
mockSharedPrefs(theme: ThemeType.dark, color: _darkThemeColor);
|
||||
await mockSharedPrefs(theme: ThemeType.dark, color: _darkThemeColor);
|
||||
await tester.pumpApplication(
|
||||
availableFilms: [_mockFilm],
|
||||
filmsInUse: [_mockFilm],
|
||||
|
@ -146,7 +149,7 @@ void main() {
|
|||
ApertureValue(16, StopType.full),
|
||||
ShutterSpeedValue(8, false, StopType.full),
|
||||
);
|
||||
mockSharedPrefs(
|
||||
await mockSharedPrefs(
|
||||
iso: 100,
|
||||
nd: 8,
|
||||
calibration: -0.3,
|
||||
|
|
Loading…
Reference in a new issue