2022-10-04 13:12:54 +03:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2022 Yubico.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2023-03-03 18:09:40 +03:00
|
|
|
import 'package:flutter/foundation.dart';
|
2023-10-20 10:59:31 +03:00
|
|
|
import 'package:flutter/material.dart';
|
2022-09-11 12:05:00 +03:00
|
|
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
|
|
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
|
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
2023-03-03 18:09:40 +03:00
|
|
|
import 'package:yubico_authenticator/android/keys.dart' as android_keys;
|
2023-10-20 10:59:31 +03:00
|
|
|
import 'package:yubico_authenticator/android/models.dart';
|
2022-09-23 11:17:28 +03:00
|
|
|
import 'package:yubico_authenticator/android/state.dart';
|
|
|
|
import 'package:yubico_authenticator/app/state.dart';
|
2023-10-20 10:59:31 +03:00
|
|
|
import 'package:yubico_authenticator/app/views/keys.dart' as app_keys;
|
2023-03-03 18:09:40 +03:00
|
|
|
import 'package:yubico_authenticator/app/views/settings_page.dart';
|
2022-09-11 12:05:00 +03:00
|
|
|
import 'package:yubico_authenticator/core/state.dart';
|
|
|
|
|
|
|
|
Widget createMaterialApp({required Widget child}) {
|
|
|
|
return MaterialApp(
|
|
|
|
localizationsDelegates: const [
|
|
|
|
AppLocalizations.delegate,
|
|
|
|
GlobalMaterialLocalizations.delegate,
|
|
|
|
GlobalWidgetsLocalizations.delegate,
|
|
|
|
GlobalCupertinoLocalizations.delegate,
|
|
|
|
],
|
|
|
|
supportedLocales: const [
|
|
|
|
Locale('en', ''),
|
|
|
|
],
|
|
|
|
home: child,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
extension _WidgetTesterHelper on WidgetTester {
|
|
|
|
Future<void> openNfcTapOptionSelection() async {
|
2023-03-03 18:09:40 +03:00
|
|
|
var widget = find.byKey(android_keys.nfcTapSetting).hitTestable();
|
2022-09-11 12:05:00 +03:00
|
|
|
expect(widget, findsOneWidget);
|
|
|
|
await tap(widget);
|
|
|
|
await pumpAndSettle();
|
|
|
|
}
|
|
|
|
|
2023-10-20 10:59:31 +03:00
|
|
|
Future<void> selectDoNothingOption() async {
|
|
|
|
await openNfcTapOptionSelection();
|
|
|
|
await tap(find.byKey(android_keys.nfcTapOption(NfcTapAction.noAction)));
|
|
|
|
await pumpAndSettle();
|
|
|
|
}
|
|
|
|
|
2022-09-11 12:05:00 +03:00
|
|
|
Future<void> selectLaunchOption() async {
|
|
|
|
await openNfcTapOptionSelection();
|
2023-03-03 18:09:40 +03:00
|
|
|
await tap(find.byKey(android_keys.nfcTapOption(NfcTapAction.launch)));
|
2022-09-11 12:05:00 +03:00
|
|
|
await pumpAndSettle();
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> selectCopyOption() async {
|
|
|
|
await openNfcTapOptionSelection();
|
2023-03-03 18:09:40 +03:00
|
|
|
await tap(find.byKey(android_keys.nfcTapOption(NfcTapAction.copy)));
|
2022-09-11 12:05:00 +03:00
|
|
|
await pumpAndSettle();
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> selectBothOption() async {
|
|
|
|
await openNfcTapOptionSelection();
|
2023-10-20 10:59:31 +03:00
|
|
|
await tap(
|
|
|
|
find.byKey(android_keys.nfcTapOption(NfcTapAction.launchAndCopy)));
|
2022-09-11 12:05:00 +03:00
|
|
|
await pumpAndSettle();
|
|
|
|
}
|
|
|
|
|
|
|
|
ListTile keyboardLayoutListTile() =>
|
2023-03-03 18:09:40 +03:00
|
|
|
find.byKey(android_keys.nfcKeyboardLayoutSetting).evaluate().single.widget
|
2022-09-11 12:05:00 +03:00
|
|
|
as ListTile;
|
|
|
|
|
|
|
|
Future<void> openKeyboardLayoutOptionSelection() async {
|
2023-03-03 18:09:40 +03:00
|
|
|
var widget =
|
|
|
|
find.byKey(android_keys.nfcKeyboardLayoutSetting).hitTestable();
|
2022-09-11 12:05:00 +03:00
|
|
|
expect(widget, findsOneWidget);
|
|
|
|
await tap(widget);
|
|
|
|
await pumpAndSettle();
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> selectKeyboardLayoutUSOption() async {
|
|
|
|
await openKeyboardLayoutOptionSelection();
|
2023-03-03 18:09:40 +03:00
|
|
|
await tap(find.byKey(android_keys.keyboardLayoutOption('US')));
|
2022-09-11 12:05:00 +03:00
|
|
|
await pumpAndSettle();
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> selectKeyboardLayoutDEOption() async {
|
|
|
|
await openKeyboardLayoutOptionSelection();
|
2023-03-03 18:09:40 +03:00
|
|
|
await tap(find.byKey(android_keys.keyboardLayoutOption('DE')));
|
2022-09-11 12:05:00 +03:00
|
|
|
await pumpAndSettle();
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> selectKeyboardLayoutDECHOption() async {
|
|
|
|
await openKeyboardLayoutOptionSelection();
|
2023-03-03 18:09:40 +03:00
|
|
|
await tap(find.byKey(android_keys.keyboardLayoutOption('DE-CH')));
|
2022-09-11 12:05:00 +03:00
|
|
|
await pumpAndSettle();
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> tapBypassTouch() async {
|
2023-03-03 18:09:40 +03:00
|
|
|
await tap(find.byKey(android_keys.nfcBypassTouchSetting));
|
2022-09-11 12:05:00 +03:00
|
|
|
await pumpAndSettle();
|
|
|
|
}
|
2022-09-23 11:17:28 +03:00
|
|
|
|
2022-11-28 13:44:55 +03:00
|
|
|
Future<void> tapOpenAppOnUsb() async {
|
2023-03-03 18:09:40 +03:00
|
|
|
await ensureVisible(find.byKey(android_keys.usbOpenApp));
|
|
|
|
await tap(find.byKey(android_keys.usbOpenApp));
|
2022-11-28 13:44:55 +03:00
|
|
|
await pumpAndSettle();
|
|
|
|
}
|
|
|
|
|
2023-01-10 13:44:43 +03:00
|
|
|
Future<void> tapSilenceNfcSounds() async {
|
2023-03-03 18:09:40 +03:00
|
|
|
await tap(find.byKey(android_keys.nfcSilenceSoundsSettings));
|
2023-01-03 15:10:03 +03:00
|
|
|
await pumpAndSettle();
|
|
|
|
}
|
|
|
|
|
2022-09-23 11:17:28 +03:00
|
|
|
ListTile themeModeListTile() =>
|
2023-03-03 18:09:40 +03:00
|
|
|
find.byKey(app_keys.themeModeSetting).evaluate().single.widget
|
|
|
|
as ListTile;
|
2022-09-23 11:17:28 +03:00
|
|
|
|
|
|
|
Future<void> openAppThemeOptionSelection() async {
|
2023-03-03 18:09:40 +03:00
|
|
|
await ensureVisible(find.byKey(app_keys.themeModeSetting));
|
|
|
|
var widget = find.byKey(app_keys.themeModeSetting).hitTestable();
|
2022-09-23 11:17:28 +03:00
|
|
|
expect(widget, findsOneWidget);
|
|
|
|
await tap(widget);
|
|
|
|
await pumpAndSettle();
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> selectSystemTheme() async {
|
|
|
|
await openAppThemeOptionSelection();
|
2023-03-03 18:09:40 +03:00
|
|
|
await tap(find.byKey(app_keys.themeModeOption(ThemeMode.system)));
|
2022-09-23 11:17:28 +03:00
|
|
|
await pumpAndSettle();
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> selectLightTheme() async {
|
|
|
|
await openAppThemeOptionSelection();
|
2023-03-03 18:09:40 +03:00
|
|
|
await tap(find.byKey(app_keys.themeModeOption(ThemeMode.light)));
|
2022-09-23 11:17:28 +03:00
|
|
|
await pumpAndSettle();
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> selectDarkTheme() async {
|
|
|
|
await openAppThemeOptionSelection();
|
2023-03-03 18:09:40 +03:00
|
|
|
await tap(find.byKey(app_keys.themeModeOption(ThemeMode.dark)));
|
2022-09-23 11:17:28 +03:00
|
|
|
await pumpAndSettle();
|
|
|
|
}
|
2022-09-11 12:05:00 +03:00
|
|
|
}
|
|
|
|
|
2023-10-20 11:04:35 +03:00
|
|
|
Future<Widget> androidWidget({
|
|
|
|
SharedPreferences? sharedPrefs,
|
2022-09-23 11:17:28 +03:00
|
|
|
int sdkVersion = 33,
|
2023-10-20 10:59:31 +03:00
|
|
|
bool hasNfcSupport = true,
|
|
|
|
Widget? child,
|
2023-10-20 11:04:35 +03:00
|
|
|
}) async =>
|
2022-09-23 11:17:28 +03:00
|
|
|
ProviderScope(overrides: [
|
2023-10-20 11:04:35 +03:00
|
|
|
prefProvider.overrideWithValue(
|
|
|
|
sharedPrefs ?? await SharedPreferences.getInstance()),
|
2022-09-23 11:17:28 +03:00
|
|
|
androidSdkVersionProvider.overrideWithValue(sdkVersion),
|
|
|
|
supportedThemesProvider
|
2023-10-20 10:59:31 +03:00
|
|
|
.overrideWith((ref) => ref.watch(androidSupportedThemesProvider)),
|
|
|
|
androidNfcSupportProvider.overrideWithValue(hasNfcSupport)
|
|
|
|
], child: child ?? createMaterialApp(child: const SettingsPage()));
|
2022-09-23 11:17:28 +03:00
|
|
|
|
2022-09-11 12:05:00 +03:00
|
|
|
void main() {
|
2023-03-03 18:09:40 +03:00
|
|
|
debugDefaultTargetPlatformOverride = TargetPlatform.android;
|
2022-09-11 12:05:00 +03:00
|
|
|
|
|
|
|
testWidgets('NFC Tap options', (WidgetTester tester) async {
|
2023-03-03 18:09:40 +03:00
|
|
|
const prefNfcOpenApp = 'prefNfcOpenApp';
|
|
|
|
const prefNfcCopyOtp = 'prefNfcCopyOtp';
|
2022-09-11 12:05:00 +03:00
|
|
|
SharedPreferences.setMockInitialValues(
|
|
|
|
{prefNfcOpenApp: true, prefNfcCopyOtp: false});
|
|
|
|
|
|
|
|
SharedPreferences sharedPrefs = await SharedPreferences.getInstance();
|
|
|
|
|
2023-10-20 11:04:35 +03:00
|
|
|
await tester.pumpWidget(await androidWidget(sharedPrefs: sharedPrefs));
|
2022-09-11 12:05:00 +03:00
|
|
|
|
|
|
|
// launch - preserves original value
|
|
|
|
await tester.selectLaunchOption();
|
|
|
|
expect(sharedPrefs.getBool(prefNfcOpenApp), equals(true));
|
|
|
|
expect(sharedPrefs.getBool(prefNfcCopyOtp), equals(false));
|
|
|
|
|
|
|
|
// copy
|
|
|
|
await tester.selectCopyOption();
|
|
|
|
expect(sharedPrefs.getBool(prefNfcOpenApp), equals(false));
|
|
|
|
expect(sharedPrefs.getBool(prefNfcCopyOtp), equals(true));
|
|
|
|
|
|
|
|
// both
|
|
|
|
await tester.selectBothOption();
|
|
|
|
expect(sharedPrefs.getBool(prefNfcOpenApp), equals(true));
|
|
|
|
expect(sharedPrefs.getBool(prefNfcCopyOtp), equals(true));
|
|
|
|
|
2023-10-20 10:59:31 +03:00
|
|
|
// do nothing
|
|
|
|
await tester.selectDoNothingOption();
|
|
|
|
expect(sharedPrefs.getBool(prefNfcOpenApp), equals(false));
|
|
|
|
expect(sharedPrefs.getBool(prefNfcCopyOtp), equals(false));
|
|
|
|
|
2022-09-11 12:05:00 +03:00
|
|
|
// launch - changes to value
|
|
|
|
await tester.selectLaunchOption();
|
|
|
|
expect(sharedPrefs.getBool(prefNfcOpenApp), equals(true));
|
|
|
|
expect(sharedPrefs.getBool(prefNfcCopyOtp), equals(false));
|
|
|
|
});
|
|
|
|
|
|
|
|
testWidgets('Static password keyboard layout', (WidgetTester tester) async {
|
2023-03-03 18:09:40 +03:00
|
|
|
const prefNfcOpenApp = 'prefNfcOpenApp';
|
|
|
|
const prefNfcCopyOtp = 'prefNfcCopyOtp';
|
|
|
|
const prefClipKbdLayout = 'prefClipKbdLayout';
|
2022-09-11 12:05:00 +03:00
|
|
|
SharedPreferences.setMockInitialValues(
|
|
|
|
{prefNfcOpenApp: true, prefNfcCopyOtp: false, prefClipKbdLayout: 'US'});
|
|
|
|
|
|
|
|
SharedPreferences sharedPrefs = await SharedPreferences.getInstance();
|
|
|
|
|
2023-10-20 11:04:35 +03:00
|
|
|
await tester.pumpWidget(await androidWidget(sharedPrefs: sharedPrefs));
|
2023-10-20 10:59:31 +03:00
|
|
|
|
|
|
|
// option is disabled for "do nothing"
|
|
|
|
await tester.selectDoNothingOption();
|
|
|
|
expect(tester.keyboardLayoutListTile().enabled, equals(false));
|
2022-09-11 12:05:00 +03:00
|
|
|
|
|
|
|
// option is disabled for "open"
|
|
|
|
expect(tester.keyboardLayoutListTile().enabled, equals(false));
|
|
|
|
|
|
|
|
// option is enabled for "copy" and "launch"
|
|
|
|
await tester.selectCopyOption();
|
|
|
|
expect(tester.keyboardLayoutListTile().enabled, equals(true));
|
|
|
|
|
|
|
|
await tester.selectBothOption();
|
|
|
|
expect(tester.keyboardLayoutListTile().enabled, equals(true));
|
|
|
|
|
|
|
|
// US - preserves the original value value
|
|
|
|
await tester.selectKeyboardLayoutUSOption();
|
|
|
|
expect(sharedPrefs.getString(prefClipKbdLayout), equals('US'));
|
|
|
|
|
|
|
|
// DE
|
|
|
|
await tester.selectKeyboardLayoutDEOption();
|
|
|
|
expect(sharedPrefs.getString(prefClipKbdLayout), equals('DE'));
|
|
|
|
|
|
|
|
// DE-CH
|
|
|
|
await tester.selectKeyboardLayoutDECHOption();
|
|
|
|
expect(sharedPrefs.getString(prefClipKbdLayout), equals('DE-CH'));
|
|
|
|
|
|
|
|
// US
|
|
|
|
await tester.selectKeyboardLayoutUSOption();
|
|
|
|
expect(sharedPrefs.getString(prefClipKbdLayout), equals('US'));
|
|
|
|
});
|
|
|
|
|
|
|
|
testWidgets('Bypass touch req', (WidgetTester tester) async {
|
2023-03-03 18:09:40 +03:00
|
|
|
const prefNfcBypassTouch = 'prefNfcBypassTouch';
|
2022-09-11 12:05:00 +03:00
|
|
|
SharedPreferences.setMockInitialValues({prefNfcBypassTouch: false});
|
|
|
|
SharedPreferences sharedPrefs = await SharedPreferences.getInstance();
|
|
|
|
|
2023-10-20 11:04:35 +03:00
|
|
|
await tester.pumpWidget(await androidWidget(sharedPrefs: sharedPrefs));
|
2022-09-11 12:05:00 +03:00
|
|
|
|
|
|
|
// change to true
|
|
|
|
await tester.tapBypassTouch();
|
|
|
|
expect(sharedPrefs.getBool(prefNfcBypassTouch), equals(true));
|
|
|
|
|
|
|
|
// change to false
|
|
|
|
await tester.tapBypassTouch();
|
|
|
|
expect(sharedPrefs.getBool(prefNfcBypassTouch), equals(false));
|
|
|
|
});
|
2022-09-23 11:17:28 +03:00
|
|
|
|
|
|
|
group('Theme settings', () {
|
|
|
|
testWidgets('Theme default on Android 10+', (WidgetTester tester) async {
|
|
|
|
// no value for theme
|
|
|
|
SharedPreferences.setMockInitialValues({});
|
|
|
|
SharedPreferences sharedPrefs = await SharedPreferences.getInstance();
|
|
|
|
|
2023-10-20 11:04:35 +03:00
|
|
|
await tester.pumpWidget(await androidWidget(
|
2022-09-23 11:17:28 +03:00
|
|
|
sharedPrefs: sharedPrefs,
|
|
|
|
// Android 10 (API Level 29)
|
|
|
|
sdkVersion: 29,
|
|
|
|
));
|
|
|
|
|
|
|
|
// we expect System theme default
|
|
|
|
expect((tester.themeModeListTile().subtitle as Text).data,
|
|
|
|
equals('System default'));
|
|
|
|
});
|
|
|
|
|
|
|
|
testWidgets('Theme default on Android <10', (WidgetTester tester) async {
|
|
|
|
// no value for theme
|
|
|
|
SharedPreferences.setMockInitialValues({});
|
|
|
|
SharedPreferences sharedPrefs = await SharedPreferences.getInstance();
|
|
|
|
|
2023-10-20 11:04:35 +03:00
|
|
|
await tester.pumpWidget(await androidWidget(
|
2022-09-23 11:17:28 +03:00
|
|
|
sharedPrefs: sharedPrefs,
|
|
|
|
// Android 9 (API Level 28)
|
|
|
|
sdkVersion: 28,
|
|
|
|
));
|
|
|
|
|
|
|
|
// we expect System theme default
|
|
|
|
expect((tester.themeModeListTile().subtitle as Text).data,
|
2023-02-28 17:02:12 +03:00
|
|
|
equals('Light mode'));
|
2022-09-23 11:17:28 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
testWidgets('Theme preferences update', (WidgetTester tester) async {
|
|
|
|
// no value for theme
|
|
|
|
SharedPreferences.setMockInitialValues({});
|
|
|
|
SharedPreferences sharedPrefs = await SharedPreferences.getInstance();
|
2023-03-03 18:09:40 +03:00
|
|
|
const prefTheme = 'APP_STATE_THEME';
|
2022-09-23 11:17:28 +03:00
|
|
|
|
2023-10-20 11:04:35 +03:00
|
|
|
await tester.pumpWidget(await androidWidget(sharedPrefs: sharedPrefs));
|
2022-09-23 11:17:28 +03:00
|
|
|
|
|
|
|
await tester.selectSystemTheme();
|
|
|
|
expect(sharedPrefs.getString(prefTheme), equals('system'));
|
|
|
|
|
|
|
|
await tester.selectLightTheme();
|
|
|
|
expect(sharedPrefs.getString(prefTheme), equals('light'));
|
|
|
|
|
|
|
|
await tester.selectDarkTheme();
|
|
|
|
expect(sharedPrefs.getString(prefTheme), equals('dark'));
|
|
|
|
});
|
|
|
|
});
|
2022-11-28 13:44:55 +03:00
|
|
|
|
|
|
|
testWidgets('Open app on USB', (WidgetTester tester) async {
|
2023-03-03 18:09:40 +03:00
|
|
|
const prefUsbOpenApp = 'prefUsbOpenApp';
|
2022-11-28 13:44:55 +03:00
|
|
|
SharedPreferences.setMockInitialValues({prefUsbOpenApp: false});
|
|
|
|
SharedPreferences sharedPrefs = await SharedPreferences.getInstance();
|
|
|
|
|
2023-10-20 11:04:35 +03:00
|
|
|
await tester.pumpWidget(await androidWidget(sharedPrefs: sharedPrefs));
|
2022-11-28 13:44:55 +03:00
|
|
|
|
|
|
|
// change to true
|
|
|
|
await tester.tapOpenAppOnUsb();
|
|
|
|
expect(sharedPrefs.getBool(prefUsbOpenApp), equals(true));
|
|
|
|
|
|
|
|
// change to false
|
|
|
|
await tester.tapOpenAppOnUsb();
|
|
|
|
expect(sharedPrefs.getBool(prefUsbOpenApp), equals(false));
|
|
|
|
});
|
2023-01-03 15:10:03 +03:00
|
|
|
|
2023-01-10 13:44:43 +03:00
|
|
|
testWidgets('Silence NFC sound', (WidgetTester tester) async {
|
2023-03-03 18:09:40 +03:00
|
|
|
const prefNfcSilenceSounds = 'prefNfcSilenceSounds';
|
2023-01-10 13:44:43 +03:00
|
|
|
SharedPreferences.setMockInitialValues({prefNfcSilenceSounds: false});
|
2023-01-03 15:10:03 +03:00
|
|
|
SharedPreferences sharedPrefs = await SharedPreferences.getInstance();
|
|
|
|
|
2023-10-20 11:04:35 +03:00
|
|
|
await tester.pumpWidget(await androidWidget(sharedPrefs: sharedPrefs));
|
2023-01-03 15:10:03 +03:00
|
|
|
|
|
|
|
// change to true
|
2023-01-10 13:44:43 +03:00
|
|
|
await tester.tapSilenceNfcSounds();
|
|
|
|
expect(sharedPrefs.getBool(prefNfcSilenceSounds), equals(true));
|
|
|
|
|
|
|
|
// change to false
|
|
|
|
await tester.tapSilenceNfcSounds();
|
|
|
|
expect(sharedPrefs.getBool(prefNfcSilenceSounds), equals(false));
|
2023-01-03 15:10:03 +03:00
|
|
|
});
|
2023-03-03 18:09:40 +03:00
|
|
|
|
2023-10-20 10:59:31 +03:00
|
|
|
testWidgets('NFC options visible on device with NFC support',
|
|
|
|
(WidgetTester tester) async {
|
2023-10-20 12:38:36 +03:00
|
|
|
await tester.pumpWidget(await androidWidget(hasNfcSupport: true));
|
2023-10-20 10:59:31 +03:00
|
|
|
|
|
|
|
expect(find.byKey(android_keys.nfcTapSetting), findsOneWidget);
|
|
|
|
expect(find.byKey(android_keys.nfcKeyboardLayoutSetting), findsOneWidget);
|
|
|
|
expect(find.byKey(android_keys.nfcSilenceSoundsSettings), findsOneWidget);
|
|
|
|
expect(find.byKey(android_keys.nfcBypassTouchSetting), findsOneWidget);
|
|
|
|
});
|
|
|
|
|
|
|
|
testWidgets('NFC options hidden on device without NFC support',
|
|
|
|
(WidgetTester tester) async {
|
2023-10-20 12:38:36 +03:00
|
|
|
await tester.pumpWidget(await androidWidget(hasNfcSupport: false));
|
2023-10-20 10:59:31 +03:00
|
|
|
|
|
|
|
expect(find.byKey(android_keys.nfcTapSetting), findsNothing);
|
|
|
|
expect(find.byKey(android_keys.nfcKeyboardLayoutSetting), findsNothing);
|
|
|
|
expect(find.byKey(android_keys.nfcSilenceSoundsSettings), findsNothing);
|
|
|
|
expect(find.byKey(android_keys.nfcBypassTouchSetting), findsNothing);
|
|
|
|
});
|
|
|
|
|
|
|
|
testWidgets('USB options visible on device with NFC support',
|
|
|
|
(WidgetTester tester) async {
|
2023-10-20 11:04:35 +03:00
|
|
|
await tester.pumpWidget(await androidWidget(hasNfcSupport: true));
|
2023-10-20 10:59:31 +03:00
|
|
|
|
|
|
|
expect(find.byKey(android_keys.usbOpenApp), findsOneWidget);
|
|
|
|
});
|
|
|
|
|
|
|
|
testWidgets('USB options visible on device without NFC support',
|
|
|
|
(WidgetTester tester) async {
|
2023-10-20 11:04:35 +03:00
|
|
|
await tester.pumpWidget(await androidWidget(hasNfcSupport: false));
|
2023-10-20 10:59:31 +03:00
|
|
|
|
|
|
|
expect(find.byKey(android_keys.usbOpenApp), findsOneWidget);
|
|
|
|
});
|
|
|
|
|
2023-03-03 18:09:40 +03:00
|
|
|
debugDefaultTargetPlatformOverride = null;
|
2022-09-11 12:05:00 +03:00
|
|
|
}
|