tests: fixed driver test
This commit is contained in:
parent
53a7387db7
commit
59c19966e4
4 changed files with 27 additions and 18 deletions
|
@ -91,6 +91,7 @@ class _AvesAppState extends State<AvesApp> {
|
||||||
: 'debug');
|
: 'debug');
|
||||||
});
|
});
|
||||||
await settings.init();
|
await settings.init();
|
||||||
|
await settings.initCrashlytics();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onNewIntent() {
|
void _onNewIntent() {
|
||||||
|
|
|
@ -53,10 +53,11 @@ class Settings extends ChangeNotifier {
|
||||||
|
|
||||||
Future<void> init() async {
|
Future<void> init() async {
|
||||||
_prefs = await SharedPreferences.getInstance();
|
_prefs = await SharedPreferences.getInstance();
|
||||||
await _setupCrashlytics();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _setupCrashlytics() async {
|
// Crashlytics initialization is separated from the main settings initialization
|
||||||
|
// to allow settings customization without Firebase context (e.g. before a Flutter Driver test)
|
||||||
|
Future<void> initCrashlytics() async {
|
||||||
await Firebase.app().setAutomaticDataCollectionEnabled(isCrashlyticsEnabled);
|
await Firebase.app().setAutomaticDataCollectionEnabled(isCrashlyticsEnabled);
|
||||||
await FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(isCrashlyticsEnabled);
|
await FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(isCrashlyticsEnabled);
|
||||||
}
|
}
|
||||||
|
@ -75,7 +76,7 @@ class Settings extends ChangeNotifier {
|
||||||
|
|
||||||
set isCrashlyticsEnabled(bool newValue) {
|
set isCrashlyticsEnabled(bool newValue) {
|
||||||
setAndNotify(isCrashlyticsEnabledKey, newValue);
|
setAndNotify(isCrashlyticsEnabledKey, newValue);
|
||||||
unawaited(_setupCrashlytics());
|
unawaited(initCrashlytics());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get mustBackTwiceToExit => getBoolOrDefault(mustBackTwiceToExitKey, true);
|
bool get mustBackTwiceToExit => getBoolOrDefault(mustBackTwiceToExitKey, true);
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
import 'package:aves/main.dart' as app;
|
import 'package:aves/main.dart' as app;
|
||||||
|
import 'package:aves/model/settings/screen_on.dart';
|
||||||
|
import 'package:aves/model/settings/settings.dart';
|
||||||
import 'package:aves/services/android_file_service.dart';
|
import 'package:aves/services/android_file_service.dart';
|
||||||
import 'package:flutter_driver/driver_extension.dart';
|
import 'package:flutter_driver/driver_extension.dart';
|
||||||
import 'package:path/path.dart' as path;
|
import 'package:path/path.dart' as path;
|
||||||
|
@ -14,5 +16,12 @@ void main() {
|
||||||
// because `MEDIA_SCANNER_SCAN_FILE` intent got deprecated in API 29
|
// because `MEDIA_SCANNER_SCAN_FILE` intent got deprecated in API 29
|
||||||
unawaited(AndroidFileService.scanFile(path.join(targetPicturesDir, 'ipse.jpg'), 'image/jpeg'));
|
unawaited(AndroidFileService.scanFile(path.join(targetPicturesDir, 'ipse.jpg'), 'image/jpeg'));
|
||||||
|
|
||||||
|
configureAndLaunch();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> configureAndLaunch() async {
|
||||||
|
await settings.init();
|
||||||
|
settings.keepScreenOn = KeepScreenOn.always;
|
||||||
|
|
||||||
app.main();
|
app.main();
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ import 'utils/driver_extension.dart';
|
||||||
FlutterDriver driver;
|
FlutterDriver driver;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
group('Aves app', () {
|
group('[Aves app]', () {
|
||||||
print('adb=${[adb, ...adbDeviceParam].join(' ')}');
|
print('adb=${[adb, ...adbDeviceParam].join(' ')}');
|
||||||
|
|
||||||
setUpAll(() async {
|
setUpAll(() async {
|
||||||
|
@ -60,19 +60,6 @@ void agreeToTerms() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void groupCollection() {
|
|
||||||
test('[collection] group', () async {
|
|
||||||
await driver.tap(find.byValueKey('appbar-menu-button'));
|
|
||||||
await driver.waitUntilNoTransientCallbacks();
|
|
||||||
|
|
||||||
await driver.tap(find.byValueKey('menu-group'));
|
|
||||||
await driver.waitUntilNoTransientCallbacks();
|
|
||||||
|
|
||||||
await driver.tap(find.byValueKey(EntryGroupFactor.album.toString()));
|
|
||||||
await driver.tap(find.byValueKey('apply-button'));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void sortCollection() {
|
void sortCollection() {
|
||||||
test('[collection] sort', () async {
|
test('[collection] sort', () async {
|
||||||
await driver.tap(find.byValueKey('appbar-menu-button'));
|
await driver.tap(find.byValueKey('appbar-menu-button'));
|
||||||
|
@ -82,7 +69,18 @@ void sortCollection() {
|
||||||
await driver.waitUntilNoTransientCallbacks();
|
await driver.waitUntilNoTransientCallbacks();
|
||||||
|
|
||||||
await driver.tap(find.byValueKey(EntrySortFactor.date.toString()));
|
await driver.tap(find.byValueKey(EntrySortFactor.date.toString()));
|
||||||
await driver.tap(find.byValueKey('apply-button'));
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void groupCollection() {
|
||||||
|
test('[collection] group', () async {
|
||||||
|
await driver.tap(find.byValueKey('appbar-menu-button'));
|
||||||
|
await driver.waitUntilNoTransientCallbacks();
|
||||||
|
|
||||||
|
await driver.tap(find.byValueKey('menu-group'));
|
||||||
|
await driver.waitUntilNoTransientCallbacks();
|
||||||
|
|
||||||
|
await driver.tap(find.byValueKey(EntryGroupFactor.album.toString()));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue