mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2025-08-18 19:16:41 +00:00
Compare commits
No commits in common. "aa3d9ddec1d1880a7a012bab6e05b13c70649b6c" and "b3989219a2fc3cbc51c04c1301e7ca6cf52df5fe" have entirely different histories.
aa3d9ddec1
...
b3989219a2
6 changed files with 7 additions and 91 deletions
|
@ -1,79 +0,0 @@
|
||||||
import 'dart:convert';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
|
||||||
import 'package:lightmeter/data/models/ev_source_type.dart';
|
|
||||||
import 'package:lightmeter/data/models/metering_screen_layout_config.dart';
|
|
||||||
import 'package:lightmeter/data/shared_prefs_service.dart';
|
|
||||||
import 'package:lightmeter/generated/l10n.dart';
|
|
||||||
import 'package:lightmeter/screens/equipment_profile_edit/screen_equipment_profile_edit.dart';
|
|
||||||
import 'package:lightmeter/screens/lightmeter_pro/screen_lightmeter_pro.dart';
|
|
||||||
import 'package:lightmeter/screens/logbook_photos/screen_logbook_photos.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';
|
|
||||||
|
|
||||||
import '../integration_test/utils/widget_tester_actions.dart';
|
|
||||||
import 'mocks/iap_products_mock.dart';
|
|
||||||
|
|
||||||
@isTest
|
|
||||||
void testGuardProTap(String description) {
|
|
||||||
testWidgets(
|
|
||||||
description,
|
|
||||||
(tester) async {
|
|
||||||
SharedPreferences.setMockInitialValues({
|
|
||||||
/// Metering values
|
|
||||||
UserPreferencesService.evSourceTypeKey: EvSourceType.camera.index,
|
|
||||||
UserPreferencesService.meteringScreenLayoutKey: json.encode(
|
|
||||||
{
|
|
||||||
MeteringScreenLayoutFeature.equipmentProfiles: true,
|
|
||||||
MeteringScreenLayoutFeature.extremeExposurePairs: true,
|
|
||||||
MeteringScreenLayoutFeature.filmPicker: true,
|
|
||||||
}.toJson(),
|
|
||||||
),
|
|
||||||
UserPreferencesService.seenChangelogVersionKey: await const PlatformUtils().version,
|
|
||||||
});
|
|
||||||
|
|
||||||
await tester.pumpApplication(isPro: false);
|
|
||||||
await tester.openSettings();
|
|
||||||
await tester.tapDescendantTextOf<SettingsScreen>(S.current.equipmentProfiles);
|
|
||||||
|
|
||||||
/// Try adding a new equipment profile
|
|
||||||
await tester.tap(find.byIcon(Icons.add_outlined).first);
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
expect(find.byType(LightmeterProScreen), findsOneWidget);
|
|
||||||
|
|
||||||
/// Purchase Pro
|
|
||||||
(tester.state(find.byType(MockIAPProductsProvider)) as MockIAPProductsProviderState).buy();
|
|
||||||
await tester.navigatorPop(true);
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
expect(find.byType(LightmeterProScreen), findsNothing);
|
|
||||||
expect(find.byType(EquipmentProfileEditScreen), findsOneWidget);
|
|
||||||
await tester.navigatorPop();
|
|
||||||
await tester.navigatorPop();
|
|
||||||
|
|
||||||
/// Refund
|
|
||||||
(tester.state(find.byType(MockIAPProductsProvider)) as MockIAPProductsProviderState).clearPurchases();
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
await tester.tapDescendantTextOf<SettingsScreen>(S.current.logbook);
|
|
||||||
|
|
||||||
/// Try enabling logbook
|
|
||||||
await tester.tap(find.text(S.current.saveNewPhotos));
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
expect(find.byType(LightmeterProScreen), findsOneWidget);
|
|
||||||
(tester.state(find.byType(MockIAPProductsProvider)) as MockIAPProductsProviderState).buy();
|
|
||||||
await tester.navigatorPop(true);
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
expect(find.byType(LightmeterProScreen), findsNothing);
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
expect(
|
|
||||||
find.descendant(
|
|
||||||
of: find.byType(LogbookPhotosScreen),
|
|
||||||
matching: find.byWidgetPredicate((widget) => widget is SwitchListTile && widget.value),
|
|
||||||
),
|
|
||||||
findsOneWidget,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
|
@ -2,7 +2,6 @@ import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:integration_test/integration_test.dart';
|
import 'package:integration_test/integration_test.dart';
|
||||||
|
|
||||||
import 'e2e_test.dart';
|
import 'e2e_test.dart';
|
||||||
import 'guard_pro_tap_test.dart';
|
|
||||||
import 'logbook_test.dart';
|
import 'logbook_test.dart';
|
||||||
import 'metering_screen_layout_test.dart';
|
import 'metering_screen_layout_test.dart';
|
||||||
import 'purchases_test.dart';
|
import 'purchases_test.dart';
|
||||||
|
@ -20,7 +19,6 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
testPurchases('Purchase & refund premium features');
|
testPurchases('Purchase & refund premium features');
|
||||||
testGuardProTap('Guard Pro tap');
|
|
||||||
testToggleLayoutFeatures('Toggle metering screen layout features');
|
testToggleLayoutFeatures('Toggle metering screen layout features');
|
||||||
testLogbook('Logbook');
|
testLogbook('Logbook');
|
||||||
testE2E('e2e');
|
testE2E('e2e');
|
||||||
|
|
|
@ -68,8 +68,8 @@ extension WidgetTesterCommonActions on WidgetTester {
|
||||||
await pumpAndSettle();
|
await pumpAndSettle();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> navigatorPop([Object? result]) async {
|
Future<void> navigatorPop() async {
|
||||||
(state(find.byType(Navigator)) as NavigatorState).pop(result);
|
(state(find.byType(Navigator)) as NavigatorState).pop();
|
||||||
await pumpAndSettle(Dimens.durationML);
|
await pumpAndSettle(Dimens.durationML);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,7 +115,7 @@ class _LightmeterProScreenState extends State<LightmeterProScreen> {
|
||||||
try {
|
try {
|
||||||
final isPro = await IAPProductsProvider.of(context).restorePurchases();
|
final isPro = await IAPProductsProvider.of(context).restorePurchases();
|
||||||
if (mounted && isPro) {
|
if (mounted && isPro) {
|
||||||
Navigator.of(context).pop(true);
|
Navigator.of(context).pop();
|
||||||
}
|
}
|
||||||
} on PlatformException catch (e) {
|
} on PlatformException catch (e) {
|
||||||
_showSnackbar(e.message ?? '');
|
_showSnackbar(e.message ?? '');
|
||||||
|
@ -131,7 +131,7 @@ class _LightmeterProScreenState extends State<LightmeterProScreen> {
|
||||||
try {
|
try {
|
||||||
final isPro = await IAPProductsProvider.of(context).buyPro(product);
|
final isPro = await IAPProductsProvider.of(context).buyPro(product);
|
||||||
if (mounted && isPro) {
|
if (mounted && isPro) {
|
||||||
Navigator.of(context).pop(true);
|
Navigator.of(context).pop();
|
||||||
}
|
}
|
||||||
} on PlatformException catch (e) {
|
} on PlatformException catch (e) {
|
||||||
_showSnackbar(e.message ?? '');
|
_showSnackbar(e.message ?? '');
|
||||||
|
|
|
@ -20,7 +20,7 @@ class AboutSettingsSection extends StatelessWidget {
|
||||||
const ReportIssueListTile(),
|
const ReportIssueListTile(),
|
||||||
const WriteEmailListTile(),
|
const WriteEmailListTile(),
|
||||||
const VersionListTile(),
|
const VersionListTile(),
|
||||||
if (!context.isPro) const RestorePurchasesListTile(),
|
if (context.isPro) const RestorePurchasesListTile(),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,13 +2,10 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:lightmeter/navigation/routes.dart';
|
import 'package:lightmeter/navigation/routes.dart';
|
||||||
import 'package:lightmeter/utils/context_utils.dart';
|
import 'package:lightmeter/utils/context_utils.dart';
|
||||||
|
|
||||||
Future<void> guardProTap(BuildContext context, VoidCallback callback) async {
|
void guardProTap(BuildContext context, VoidCallback callback) {
|
||||||
if (context.isPro) {
|
if (context.isPro) {
|
||||||
callback();
|
callback();
|
||||||
} else {
|
} else {
|
||||||
final isPro = await Navigator.of(context).pushNamed(NavigationRoutes.proFeaturesScreen.name);
|
Navigator.of(context).pushNamed(NavigationRoutes.proFeaturesScreen.name);
|
||||||
if (isPro == true) {
|
|
||||||
callback();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue