dev
dart 52 lines 1.43 KB
Raw
1 import 'package:cake_wallet/src/screens/pin_code/pin_code_widget.dart';
2 import 'package:flutter_test/flutter_test.dart';
3
4 import '../components/common_test_cases.dart';
5
6 class PinCodeWidgetRobot {
7 PinCodeWidgetRobot(this.tester) : commonTestCases = CommonTestCases(tester);
8
9 final WidgetTester tester;
10 late CommonTestCases commonTestCases;
11
12 void hasPinCodeWidget() {
13 final pinCodeWidget = find.bySubtype<PinCodeWidget>();
14 expect(pinCodeWidget, findsOneWidget);
15 }
16
17 void hasNumberButtonsVisible() {
18 // Confirmation for buttons 1-9
19 for (var i = 1; i < 10; i++) {
20 commonTestCases.hasValueKey('pin_code_button_${i}_key');
21 }
22
23 // Confirmation for 0 button
24 commonTestCases.hasValueKey('pin_code_button_0_key');
25 }
26
27 Future<void> enterPassword(String password, {int pumpDuration = 100}) async {
28 await commonTestCases.enterText(
29 password,
30 'enter_wallet_password',
31 );
32 await tester.pumpAndSettle();
33 await commonTestCases.tapItemByKey(
34 'unlock',
35 );
36 await tester.pumpAndSettle();
37
38 await commonTestCases.defaultSleepTime();
39 }
40
41 Future<void> enterPinCode(List<int> pinCode, {int pumpDuration = 100}) async {
42 for (int pin in pinCode) {
43 await commonTestCases.tapItemByKey(
44 'pin_code_button_${pin}_key',
45 pumpDuration: pumpDuration,
46 );
47 }
48
49 await commonTestCases.takeScreenshots('pin_code_widget');
50 await commonTestCases.defaultSleepTime();
51 }
52 }