2022-08-26 08:11:35 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_svg/svg.dart';
|
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
2023-05-12 20:02:04 +00:00
|
|
|
import 'package:stackwallet/models/isar/stack_theme.dart';
|
2023-05-09 21:57:40 +00:00
|
|
|
import 'package:stackwallet/themes/stack_colors.dart';
|
2023-05-26 15:45:45 +00:00
|
|
|
import 'package:stackwallet/utilities/text_styles.dart';
|
2022-08-26 08:11:35 +00:00
|
|
|
import 'package:stackwallet/widgets/custom_pin_put/custom_pin_put.dart';
|
|
|
|
import 'package:stackwallet/widgets/custom_pin_put/pin_keyboard.dart';
|
|
|
|
|
2023-05-12 20:02:04 +00:00
|
|
|
import '../sample_data/theme_json.dart';
|
|
|
|
|
2023-05-26 15:45:45 +00:00
|
|
|
class PinWidget extends StatefulWidget {
|
|
|
|
const PinWidget({
|
|
|
|
super.key,
|
|
|
|
this.onSubmit,
|
|
|
|
this.controller,
|
|
|
|
required this.pinAnimation,
|
|
|
|
required this.isRandom,
|
|
|
|
});
|
|
|
|
|
|
|
|
final void Function(String)? onSubmit;
|
|
|
|
final TextEditingController? controller;
|
|
|
|
final bool isRandom;
|
|
|
|
final PinAnimationType pinAnimation;
|
|
|
|
|
|
|
|
@override
|
|
|
|
PinWidgetState createState() => PinWidgetState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class PinWidgetState extends State<PinWidget> {
|
|
|
|
int pinCount = 1;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
bool submittedPinMatches = false;
|
|
|
|
|
|
|
|
return CustomPinPut(
|
|
|
|
fieldsCount: pinCount,
|
|
|
|
isRandom: widget.isRandom,
|
|
|
|
useNativeKeyboard: false,
|
|
|
|
eachFieldHeight: 12,
|
|
|
|
eachFieldWidth: 12,
|
|
|
|
textStyle: STextStyles.label(context).copyWith(
|
|
|
|
fontSize: 1,
|
|
|
|
),
|
|
|
|
obscureText: "",
|
|
|
|
onPinLengthChanged: (newLength) {
|
|
|
|
setState(() {
|
|
|
|
pinCount = newLength;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
onSubmit: widget.onSubmit,
|
|
|
|
controller: widget.controller,
|
|
|
|
pinAnimationType: widget.pinAnimation,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-26 08:11:35 +00:00
|
|
|
void main() {
|
2023-05-02 22:45:34 +00:00
|
|
|
group("CustomPinPut tests, non-random PIN", () {
|
2023-05-01 21:31:15 +00:00
|
|
|
testWidgets("CustomPinPut with 4 fields builds correctly, non-random PIN",
|
|
|
|
(tester) async {
|
2023-05-02 22:45:34 +00:00
|
|
|
await tester.pumpWidget(
|
|
|
|
MaterialApp(
|
|
|
|
theme: ThemeData(
|
|
|
|
extensions: [
|
2023-05-08 17:59:00 +00:00
|
|
|
StackColors.fromStackColorTheme(
|
|
|
|
StackTheme.fromJson(
|
2023-05-12 20:02:04 +00:00
|
|
|
json: lightThemeJsonMap,
|
2023-05-08 17:59:00 +00:00
|
|
|
),
|
|
|
|
),
|
2023-05-02 22:45:34 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
home: const Material(
|
2023-05-26 15:45:45 +00:00
|
|
|
child: PinWidget(
|
|
|
|
pinAnimation: PinAnimationType.none,
|
|
|
|
isRandom: false,
|
|
|
|
),
|
2023-05-02 22:45:34 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
// expects 5 here. Four + the actual text field text
|
2023-05-26 15:45:45 +00:00
|
|
|
expect(find.text(""), findsNWidgets(1));
|
2023-05-02 22:45:34 +00:00
|
|
|
expect(find.byType(PinKeyboard), findsOneWidget);
|
|
|
|
expect(find.byType(BackspaceKey), findsOneWidget);
|
|
|
|
expect(find.byType(NumberKey), findsNWidgets(10));
|
|
|
|
});
|
|
|
|
|
2023-05-01 21:31:15 +00:00
|
|
|
testWidgets("CustomPinPut entering a pin successfully, non-random PIN",
|
|
|
|
(tester) async {
|
2023-05-02 22:45:34 +00:00
|
|
|
bool submittedPinMatches = false;
|
|
|
|
|
|
|
|
await tester.pumpWidget(
|
|
|
|
MaterialApp(
|
|
|
|
theme: ThemeData(
|
|
|
|
extensions: [
|
2023-05-08 17:59:00 +00:00
|
|
|
StackColors.fromStackColorTheme(
|
|
|
|
StackTheme.fromJson(
|
2023-05-12 20:02:04 +00:00
|
|
|
json: lightThemeJsonMap,
|
2023-05-08 17:59:00 +00:00
|
|
|
),
|
|
|
|
),
|
2023-05-02 22:45:34 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
home: Material(
|
2023-05-26 15:45:45 +00:00
|
|
|
child: PinWidget(
|
|
|
|
pinAnimation: PinAnimationType.none,
|
|
|
|
isRandom: false,
|
|
|
|
onSubmit: (pin) {
|
|
|
|
submittedPinMatches = pin == "1234";
|
|
|
|
print("pin entered: $pin");
|
|
|
|
},
|
|
|
|
),
|
2023-05-02 22:45:34 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
await tester.tap(find.byWidgetPredicate(
|
|
|
|
(widget) => widget is NumberKey && widget.number == "1"));
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
await tester.tap(find.byWidgetPredicate(
|
|
|
|
(widget) => widget is NumberKey && widget.number == "2"));
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
await tester.tap(find.byWidgetPredicate(
|
|
|
|
(widget) => widget is NumberKey && widget.number == "6"));
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
await tester.tap(find.byType(BackspaceKey));
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
await tester.tap(find.byWidgetPredicate(
|
|
|
|
(widget) => widget is NumberKey && widget.number == "3"));
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
await tester.tap(find.byWidgetPredicate(
|
|
|
|
(widget) => widget is NumberKey && widget.number == "4"));
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
await tester.tap(find.byType(SubmitKey));
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
|
|
|
|
expect(submittedPinMatches, true);
|
|
|
|
});
|
|
|
|
|
2023-05-01 21:31:15 +00:00
|
|
|
testWidgets("CustomPinPut pin enter fade animation, non-random PIN",
|
|
|
|
(tester) async {
|
2023-05-02 22:45:34 +00:00
|
|
|
final controller = TextEditingController();
|
|
|
|
|
|
|
|
await tester.pumpWidget(
|
|
|
|
MaterialApp(
|
|
|
|
theme: ThemeData(
|
|
|
|
extensions: [
|
2023-05-08 17:59:00 +00:00
|
|
|
StackColors.fromStackColorTheme(
|
|
|
|
StackTheme.fromJson(
|
2023-05-12 20:02:04 +00:00
|
|
|
json: lightThemeJsonMap,
|
2023-05-08 17:59:00 +00:00
|
|
|
),
|
|
|
|
),
|
2023-05-02 22:45:34 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
home: Material(
|
2023-05-26 15:45:45 +00:00
|
|
|
child: PinWidget(
|
|
|
|
pinAnimation: PinAnimationType.none,
|
|
|
|
isRandom: false,
|
|
|
|
controller: controller,
|
|
|
|
),
|
2023-05-02 22:45:34 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
await tester.tap(find.byWidgetPredicate(
|
|
|
|
(widget) => widget is NumberKey && widget.number == "1"));
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(controller.text, "1");
|
|
|
|
|
|
|
|
await tester.tap(find.byType(BackspaceKey));
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(controller.text, "");
|
|
|
|
});
|
|
|
|
|
2023-05-01 21:31:15 +00:00
|
|
|
testWidgets("CustomPinPut pin enter scale animation, non-random PIN",
|
|
|
|
(tester) async {
|
2023-05-02 22:45:34 +00:00
|
|
|
final controller = TextEditingController();
|
|
|
|
|
|
|
|
await tester.pumpWidget(
|
|
|
|
MaterialApp(
|
|
|
|
theme: ThemeData(
|
|
|
|
extensions: [
|
2023-05-08 17:59:00 +00:00
|
|
|
StackColors.fromStackColorTheme(
|
|
|
|
StackTheme.fromJson(
|
2023-05-12 20:02:04 +00:00
|
|
|
json: lightThemeJsonMap,
|
2023-05-08 17:59:00 +00:00
|
|
|
),
|
|
|
|
),
|
2023-05-02 22:45:34 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
home: Material(
|
2023-05-26 15:45:45 +00:00
|
|
|
child: PinWidget(
|
|
|
|
pinAnimation: PinAnimationType.scale,
|
|
|
|
isRandom: false,
|
|
|
|
controller: controller,
|
|
|
|
),
|
2023-05-02 22:45:34 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
await tester.tap(find.byWidgetPredicate(
|
|
|
|
(widget) => widget is NumberKey && widget.number == "1"));
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(controller.text, "1");
|
|
|
|
|
|
|
|
await tester.tap(find.byType(BackspaceKey));
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(controller.text, "");
|
|
|
|
});
|
|
|
|
|
2023-05-01 21:31:15 +00:00
|
|
|
testWidgets("CustomPinPut pin enter rotate animation, non-random PIN",
|
|
|
|
(tester) async {
|
2023-05-02 22:45:34 +00:00
|
|
|
final controller = TextEditingController();
|
|
|
|
|
|
|
|
await tester.pumpWidget(
|
|
|
|
MaterialApp(
|
|
|
|
theme: ThemeData(
|
|
|
|
extensions: [
|
2023-05-08 17:59:00 +00:00
|
|
|
StackColors.fromStackColorTheme(
|
|
|
|
StackTheme.fromJson(
|
2023-05-12 20:02:04 +00:00
|
|
|
json: lightThemeJsonMap,
|
2023-05-08 17:59:00 +00:00
|
|
|
),
|
|
|
|
),
|
2023-05-02 22:45:34 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
home: Material(
|
2023-05-26 15:45:45 +00:00
|
|
|
child: PinWidget(
|
|
|
|
pinAnimation: PinAnimationType.rotation,
|
|
|
|
isRandom: false,
|
|
|
|
controller: controller,
|
|
|
|
),
|
2023-05-02 22:45:34 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
await tester.tap(find.byWidgetPredicate(
|
|
|
|
(widget) => widget is NumberKey && widget.number == "1"));
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(controller.text, "1");
|
|
|
|
|
|
|
|
await tester.tap(find.byType(BackspaceKey));
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(controller.text, "");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2023-05-01 21:31:15 +00:00
|
|
|
testWidgets("PinKeyboard builds correctly, non-random PIN", (tester) async {
|
2023-05-02 22:45:34 +00:00
|
|
|
final keyboard = PinKeyboard(
|
|
|
|
onNumberKeyPressed: (_) {},
|
|
|
|
onBackPressed: () {},
|
|
|
|
onSubmitPressed: () {},
|
|
|
|
isRandom: false,
|
|
|
|
);
|
|
|
|
|
|
|
|
await tester.pumpWidget(
|
|
|
|
MaterialApp(
|
|
|
|
theme: ThemeData(
|
|
|
|
extensions: [
|
2023-05-08 17:59:00 +00:00
|
|
|
StackColors.fromStackColorTheme(
|
|
|
|
StackTheme.fromJson(
|
2023-05-12 20:02:04 +00:00
|
|
|
json: lightThemeJsonMap,
|
2023-05-08 17:59:00 +00:00
|
|
|
),
|
|
|
|
),
|
2023-05-02 22:45:34 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
home: Material(
|
|
|
|
child: keyboard,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(find.byType(BackspaceKey), findsOneWidget);
|
2023-05-01 21:31:15 +00:00
|
|
|
expect(find.byType(SubmitKey), findsOneWidget);
|
2023-05-02 22:45:34 +00:00
|
|
|
expect(find.byType(NumberKey), findsNWidgets(10));
|
|
|
|
expect(find.text("0"), findsOneWidget);
|
|
|
|
expect(find.text("1"), findsOneWidget);
|
|
|
|
expect(find.text("2"), findsOneWidget);
|
|
|
|
expect(find.text("3"), findsOneWidget);
|
|
|
|
expect(find.text("4"), findsOneWidget);
|
|
|
|
expect(find.text("5"), findsOneWidget);
|
|
|
|
expect(find.text("6"), findsOneWidget);
|
|
|
|
expect(find.text("7"), findsOneWidget);
|
|
|
|
expect(find.text("8"), findsOneWidget);
|
|
|
|
expect(find.text("9"), findsOneWidget);
|
2023-05-01 21:31:15 +00:00
|
|
|
expect(find.byType(SvgPicture), findsNWidgets(2));
|
2023-05-02 22:45:34 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
group("CustomPinPut tests, with random PIN", () {
|
2023-05-01 21:31:15 +00:00
|
|
|
testWidgets("CustomPinPut with 4 fields builds correctly, with random PIN",
|
|
|
|
(tester) async {
|
2022-08-26 08:11:35 +00:00
|
|
|
await tester.pumpWidget(
|
2022-09-23 14:04:21 +00:00
|
|
|
MaterialApp(
|
|
|
|
theme: ThemeData(
|
|
|
|
extensions: [
|
2023-05-08 17:59:00 +00:00
|
|
|
StackColors.fromStackColorTheme(
|
|
|
|
StackTheme.fromJson(
|
2023-05-12 20:02:04 +00:00
|
|
|
json: lightThemeJsonMap,
|
2023-05-08 17:59:00 +00:00
|
|
|
),
|
|
|
|
),
|
2022-09-23 14:04:21 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
home: const Material(
|
2023-05-26 15:45:45 +00:00
|
|
|
child: PinWidget(
|
|
|
|
pinAnimation: PinAnimationType.none,
|
|
|
|
isRandom: true,
|
|
|
|
),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
// expects 5 here. Four + the actual text field text
|
2023-05-26 15:45:45 +00:00
|
|
|
expect(find.text(""), findsNWidgets(1));
|
2022-08-26 08:11:35 +00:00
|
|
|
expect(find.byType(PinKeyboard), findsOneWidget);
|
|
|
|
expect(find.byType(BackspaceKey), findsOneWidget);
|
|
|
|
expect(find.byType(NumberKey), findsNWidgets(10));
|
|
|
|
});
|
|
|
|
|
2023-05-26 15:45:45 +00:00
|
|
|
// testWidgets("CustomPinPut entering a pin successfully, with random PIN",
|
|
|
|
// (tester) async {
|
|
|
|
// bool submittedPinMatches = false;
|
|
|
|
//
|
|
|
|
// await tester.pumpWidget(
|
|
|
|
// MaterialApp(
|
|
|
|
// theme: ThemeData(
|
|
|
|
// extensions: [
|
|
|
|
// StackColors.fromStackColorTheme(
|
|
|
|
// StackTheme.fromJson(
|
|
|
|
// json: lightThemeJsonMap,
|
2023-07-04 00:25:18 +00:00
|
|
|
//
|
2023-05-26 15:45:45 +00:00
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// ],
|
|
|
|
// ),
|
|
|
|
// home: Material(
|
|
|
|
// child: PinWidget(
|
|
|
|
// pinAnimation: PinAnimationType.none,
|
|
|
|
// isRandom: true,
|
|
|
|
// onSubmit: (pin) {
|
|
|
|
// submittedPinMatches = pin == "1234";
|
|
|
|
// print("pin entered: $pin");
|
|
|
|
// },
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// );
|
|
|
|
//
|
|
|
|
// await tester.tap(find.byWidgetPredicate(
|
|
|
|
// (widget) => widget is NumberKey && widget.number == "1"));
|
|
|
|
// await tester.pumpAndSettle();
|
|
|
|
// await tester.tap(find.byWidgetPredicate(
|
|
|
|
// (widget) => widget is NumberKey && widget.number == "2"));
|
|
|
|
// await tester.pumpAndSettle();
|
|
|
|
// await tester.tap(find.byWidgetPredicate(
|
|
|
|
// (widget) => widget is NumberKey && widget.number == "6"));
|
|
|
|
// await tester.pumpAndSettle();
|
|
|
|
// await tester.tap(find.byType(BackspaceKey));
|
|
|
|
// await tester.pumpAndSettle();
|
|
|
|
// await tester.tap(find.byWidgetPredicate(
|
|
|
|
// (widget) => widget is NumberKey && widget.number == "3"));
|
|
|
|
// await tester.pumpAndSettle();
|
|
|
|
// await tester.tap(find.byWidgetPredicate(
|
|
|
|
// (widget) => widget is NumberKey && widget.number == "4"));
|
|
|
|
// await tester.pumpAndSettle();
|
|
|
|
// await tester.tap(find.byType(SubmitKey));
|
|
|
|
// await tester.pumpAndSettle();
|
|
|
|
//
|
|
|
|
// expect(submittedPinMatches, true);
|
|
|
|
// });
|
2022-08-26 08:11:35 +00:00
|
|
|
|
2023-05-01 21:31:15 +00:00
|
|
|
testWidgets("CustomPinPut pin enter fade animation, with random PIN",
|
|
|
|
(tester) async {
|
2022-08-26 08:11:35 +00:00
|
|
|
final controller = TextEditingController();
|
|
|
|
|
|
|
|
await tester.pumpWidget(
|
|
|
|
MaterialApp(
|
2022-09-23 14:04:21 +00:00
|
|
|
theme: ThemeData(
|
|
|
|
extensions: [
|
2023-05-08 17:59:00 +00:00
|
|
|
StackColors.fromStackColorTheme(
|
|
|
|
StackTheme.fromJson(
|
2023-05-12 20:02:04 +00:00
|
|
|
json: lightThemeJsonMap,
|
2023-05-08 17:59:00 +00:00
|
|
|
),
|
|
|
|
),
|
2022-09-23 14:04:21 +00:00
|
|
|
],
|
|
|
|
),
|
2022-08-26 08:11:35 +00:00
|
|
|
home: Material(
|
2023-05-26 15:45:45 +00:00
|
|
|
child: PinWidget(
|
|
|
|
pinAnimation: PinAnimationType.fade,
|
|
|
|
isRandom: true,
|
|
|
|
controller: controller,
|
|
|
|
),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
await tester.tap(find.byWidgetPredicate(
|
|
|
|
(widget) => widget is NumberKey && widget.number == "1"));
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(controller.text, "1");
|
|
|
|
|
|
|
|
await tester.tap(find.byType(BackspaceKey));
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(controller.text, "");
|
|
|
|
});
|
|
|
|
|
2023-05-01 21:31:15 +00:00
|
|
|
testWidgets("CustomPinPut pin enter scale animation, with random PIN",
|
|
|
|
(tester) async {
|
2022-08-26 08:11:35 +00:00
|
|
|
final controller = TextEditingController();
|
|
|
|
final pinPut = CustomPinPut(
|
|
|
|
fieldsCount: 4,
|
|
|
|
pinAnimationType: PinAnimationType.scale,
|
|
|
|
controller: controller,
|
2023-05-02 22:45:34 +00:00
|
|
|
isRandom: true,
|
2022-08-26 08:11:35 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
await tester.pumpWidget(
|
|
|
|
MaterialApp(
|
2022-09-23 14:04:21 +00:00
|
|
|
theme: ThemeData(
|
|
|
|
extensions: [
|
2023-05-08 17:59:00 +00:00
|
|
|
StackColors.fromStackColorTheme(
|
|
|
|
StackTheme.fromJson(
|
2023-05-12 20:02:04 +00:00
|
|
|
json: lightThemeJsonMap,
|
2023-05-08 17:59:00 +00:00
|
|
|
),
|
|
|
|
),
|
2022-09-23 14:04:21 +00:00
|
|
|
],
|
|
|
|
),
|
2022-08-26 08:11:35 +00:00
|
|
|
home: Material(
|
2023-05-26 15:45:45 +00:00
|
|
|
child: PinWidget(
|
|
|
|
isRandom: true,
|
|
|
|
controller: controller,
|
|
|
|
pinAnimation: PinAnimationType.scale,
|
|
|
|
),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
await tester.tap(find.byWidgetPredicate(
|
|
|
|
(widget) => widget is NumberKey && widget.number == "1"));
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(controller.text, "1");
|
|
|
|
|
|
|
|
await tester.tap(find.byType(BackspaceKey));
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(controller.text, "");
|
|
|
|
});
|
|
|
|
|
2023-05-01 21:31:15 +00:00
|
|
|
testWidgets("CustomPinPut pin enter rotate animation, with random PIN",
|
|
|
|
(tester) async {
|
2022-08-26 08:11:35 +00:00
|
|
|
final controller = TextEditingController();
|
|
|
|
final pinPut = CustomPinPut(
|
|
|
|
fieldsCount: 4,
|
|
|
|
pinAnimationType: PinAnimationType.rotation,
|
|
|
|
controller: controller,
|
2023-05-02 22:45:34 +00:00
|
|
|
isRandom: true,
|
2022-08-26 08:11:35 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
await tester.pumpWidget(
|
|
|
|
MaterialApp(
|
2022-09-23 14:04:21 +00:00
|
|
|
theme: ThemeData(
|
|
|
|
extensions: [
|
2023-05-08 17:59:00 +00:00
|
|
|
StackColors.fromStackColorTheme(
|
|
|
|
StackTheme.fromJson(
|
2023-05-12 20:02:04 +00:00
|
|
|
json: lightThemeJsonMap,
|
2023-05-08 17:59:00 +00:00
|
|
|
),
|
|
|
|
),
|
2022-09-23 14:04:21 +00:00
|
|
|
],
|
|
|
|
),
|
2022-08-26 08:11:35 +00:00
|
|
|
home: Material(
|
2023-05-26 15:45:45 +00:00
|
|
|
child: PinWidget(
|
|
|
|
isRandom: true,
|
|
|
|
controller: controller,
|
|
|
|
pinAnimation: PinAnimationType.rotation,
|
|
|
|
),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
await tester.tap(find.byWidgetPredicate(
|
|
|
|
(widget) => widget is NumberKey && widget.number == "1"));
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(controller.text, "1");
|
|
|
|
|
|
|
|
await tester.tap(find.byType(BackspaceKey));
|
|
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(controller.text, "");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2023-05-01 21:31:15 +00:00
|
|
|
testWidgets("PinKeyboard builds correctly, with random PIN", (tester) async {
|
2022-08-26 08:11:35 +00:00
|
|
|
final keyboard = PinKeyboard(
|
|
|
|
onNumberKeyPressed: (_) {},
|
|
|
|
onBackPressed: () {},
|
|
|
|
onSubmitPressed: () {},
|
2023-05-02 22:45:34 +00:00
|
|
|
isRandom: true,
|
2022-08-26 08:11:35 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
await tester.pumpWidget(
|
|
|
|
MaterialApp(
|
2022-09-23 14:04:21 +00:00
|
|
|
theme: ThemeData(
|
|
|
|
extensions: [
|
2023-05-08 17:59:00 +00:00
|
|
|
StackColors.fromStackColorTheme(
|
|
|
|
StackTheme.fromJson(
|
2023-05-12 20:02:04 +00:00
|
|
|
json: lightThemeJsonMap,
|
2023-05-08 17:59:00 +00:00
|
|
|
),
|
|
|
|
),
|
2022-09-23 14:04:21 +00:00
|
|
|
],
|
|
|
|
),
|
2022-08-26 08:11:35 +00:00
|
|
|
home: Material(
|
|
|
|
child: keyboard,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(find.byType(BackspaceKey), findsOneWidget);
|
2023-05-01 21:31:15 +00:00
|
|
|
expect(find.byType(SubmitKey), findsOneWidget);
|
2022-08-26 08:11:35 +00:00
|
|
|
expect(find.byType(NumberKey), findsNWidgets(10));
|
|
|
|
expect(find.text("0"), findsOneWidget);
|
|
|
|
expect(find.text("1"), findsOneWidget);
|
|
|
|
expect(find.text("2"), findsOneWidget);
|
|
|
|
expect(find.text("3"), findsOneWidget);
|
|
|
|
expect(find.text("4"), findsOneWidget);
|
|
|
|
expect(find.text("5"), findsOneWidget);
|
|
|
|
expect(find.text("6"), findsOneWidget);
|
|
|
|
expect(find.text("7"), findsOneWidget);
|
|
|
|
expect(find.text("8"), findsOneWidget);
|
|
|
|
expect(find.text("9"), findsOneWidget);
|
2023-05-01 21:31:15 +00:00
|
|
|
expect(find.byType(SvgPicture), findsNWidgets(2));
|
2022-08-26 08:11:35 +00:00
|
|
|
});
|
|
|
|
}
|