Improve test mecanic; Continue test until 2nd derivation view
This commit is contained in:
parent
c77b776d59
commit
1a604bfb5a
|
@ -9,11 +9,12 @@
|
||||||
<uses-permission android:name="android.permission.CAMERA" />
|
<uses-permission android:name="android.permission.CAMERA" />
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||||
<application
|
<application android:requestLegacyExternalStorage="true"
|
||||||
android:name="io.flutter.app.FlutterApplication"
|
android:name="io.flutter.app.FlutterApplication"
|
||||||
android:label="Ğecko">
|
android:label="Ğecko">
|
||||||
<!-- android:icon="@mipmap/ic_launcher"> -->
|
<!-- android:icon="@mipmap/ic_launcher"> -->
|
||||||
<activity
|
<activity
|
||||||
|
android:requestLegacyExternalStorage="true"
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
android:launchMode="singleTop"
|
android:launchMode="singleTop"
|
||||||
android:theme="@style/LaunchTheme"
|
android:theme="@style/LaunchTheme"
|
||||||
|
|
|
@ -63,6 +63,7 @@ class WalletsHome extends StatelessWidget {
|
||||||
width: 80.0,
|
width: 80.0,
|
||||||
child: FittedBox(
|
child: FittedBox(
|
||||||
child: FloatingActionButton(
|
child: FloatingActionButton(
|
||||||
|
key: Key('addDerivation'),
|
||||||
heroTag: "buttonGenerateWallet",
|
heroTag: "buttonGenerateWallet",
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
showDialog(
|
showDialog(
|
||||||
|
@ -223,6 +224,7 @@ class WalletsHome extends StatelessWidget {
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
|
key: Key('validDerivation'),
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
elevation: 1,
|
elevation: 1,
|
||||||
primary: Color(0xffFFD68E), // background
|
primary: Color(0xffFFD68E), // background
|
||||||
|
|
|
@ -70,6 +70,7 @@ class OnboardingStepFourteen extends StatelessWidget {
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 30),
|
padding: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 30),
|
||||||
child: PinCodeTextField(
|
child: PinCodeTextField(
|
||||||
|
key: Key('formKey2'),
|
||||||
autoFocus: true,
|
autoFocus: true,
|
||||||
appContext: context,
|
appContext: context,
|
||||||
pastedTextStyle: TextStyle(
|
pastedTextStyle: TextStyle(
|
||||||
|
@ -77,7 +78,7 @@ class OnboardingStepFourteen extends StatelessWidget {
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
length: _pinLenght,
|
length: _pinLenght,
|
||||||
obscureText: false,
|
obscureText: true,
|
||||||
obscuringCharacter: '*',
|
obscuringCharacter: '*',
|
||||||
animationType: AnimationType.fade,
|
animationType: AnimationType.fade,
|
||||||
validator: (v) {
|
validator: (v) {
|
||||||
|
|
|
@ -56,6 +56,7 @@ class OnboardingStepNine extends StatelessWidget {
|
||||||
width: 400,
|
width: 400,
|
||||||
height: 62,
|
height: 62,
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
|
key: Key('generateMnemonic'),
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
elevation: 5,
|
elevation: 5,
|
||||||
primary: Color(0xffFFD58D),
|
primary: Color(0xffFFD58D),
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
// Imports the Flutter Driver API.
|
// Imports the Flutter Driver API.
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:flutter_driver/flutter_driver.dart';
|
import 'package:flutter_driver/flutter_driver.dart';
|
||||||
// import 'package:flutter_test/flutter_test.dart';
|
// import 'package:flutter_test/flutter_test.dart';
|
||||||
|
@ -28,6 +29,17 @@ void main() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Function to tap the widget by key
|
||||||
|
Future tapOn(String key) async {
|
||||||
|
await driver.tap(find.byValueKey(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String> getText(String text) async {
|
||||||
|
return await driver.getText(find.byValueKey(
|
||||||
|
text,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
test('OnBoarding - Open wallets management', (
|
test('OnBoarding - Open wallets management', (
|
||||||
{timeout: const Duration(seconds: 2)}) async {
|
{timeout: const Duration(seconds: 2)}) async {
|
||||||
// await driver.runUnsynchronized(() async { // Needed if we want to manage async drivers
|
// await driver.runUnsynchronized(() async { // Needed if we want to manage async drivers
|
||||||
|
@ -48,12 +60,12 @@ void main() {
|
||||||
|
|
||||||
test('OnBoarding - Go to create restore sentance', (
|
test('OnBoarding - Go to create restore sentance', (
|
||||||
{timeout: const Duration(seconds: 5)}) async {
|
{timeout: const Duration(seconds: 5)}) async {
|
||||||
await driver.tap(find.byValueKey('goStep1'));
|
await tapOn('goStep1');
|
||||||
await driver.tap(find.byValueKey('goStep2'));
|
await tapOn('goStep2');
|
||||||
await driver.tap(find.byValueKey('goStep3'));
|
await tapOn('goStep3');
|
||||||
await driver.tap(find.byValueKey('goStep4'));
|
await tapOn('goStep4');
|
||||||
await driver.tap(find.byValueKey('goStep5'));
|
await tapOn('goStep5');
|
||||||
await driver.tap(find.byValueKey('goStep6'));
|
await tapOn('goStep6');
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
await driver.getText(find.byValueKey(
|
await driver.getText(find.byValueKey(
|
||||||
|
@ -64,95 +76,114 @@ void main() {
|
||||||
|
|
||||||
test('OnBoarding - Generate sentance and confirme it', (
|
test('OnBoarding - Generate sentance and confirme it', (
|
||||||
{timeout: const Duration(seconds: 5)}) async {
|
{timeout: const Duration(seconds: 5)}) async {
|
||||||
await driver.tap(find.byValueKey('goStep7'));
|
await tapOn('goStep7');
|
||||||
|
|
||||||
print('THE SECOND WORD IS:');
|
while (await getText('word1') == '...') {
|
||||||
|
|
||||||
while (await driver.getText(find.byValueKey(
|
|
||||||
'word1',
|
|
||||||
)) ==
|
|
||||||
'...') {
|
|
||||||
print('Waiting for Mnemonic generation...');
|
print('Waiting for Mnemonic generation...');
|
||||||
await Future.delayed(const Duration(seconds: 1));
|
await Future.delayed(const Duration(milliseconds: 100));
|
||||||
}
|
}
|
||||||
|
|
||||||
List words = [for (var i = 1; i <= 13; i += 1) i];
|
Future selectWord() async {
|
||||||
|
List words = [for (var i = 1; i <= 13; i += 1) i];
|
||||||
|
|
||||||
for (var j = 1; j < 13; j++) {
|
for (var j = 1; j < 13; j++) {
|
||||||
words[j] = await driver.getText(find.byValueKey(
|
words[j] = await getText('word$j');
|
||||||
'word$j',
|
}
|
||||||
));
|
expect(
|
||||||
|
await getText('step7'), "C'est le moment de noter votre phrase !");
|
||||||
|
|
||||||
|
await tapOn('goStep8');
|
||||||
|
await Future.delayed(const Duration(milliseconds: 50));
|
||||||
|
|
||||||
|
String goodWord = words[int.parse(
|
||||||
|
await getText('askedWord'),
|
||||||
|
)];
|
||||||
|
|
||||||
|
// Enter the expected word
|
||||||
|
await driver.enterText(goodWord);
|
||||||
|
|
||||||
|
// Check if word is valid
|
||||||
|
await driver.waitFor(find.text("C'est le bon mot !"));
|
||||||
|
|
||||||
|
// Continue onboarding workflow
|
||||||
|
await tapOn('goStep9');
|
||||||
}
|
}
|
||||||
|
|
||||||
// print word 1, 2 and 12
|
await selectWord();
|
||||||
// print(words[1] + words[2] + words[12]);
|
|
||||||
|
|
||||||
expect(
|
//Go back 2 times to mnemonic generation screen
|
||||||
await driver.getText(find.byValueKey(
|
await goBack();
|
||||||
'step7',
|
await goBack();
|
||||||
)),
|
await Future.delayed(const Duration(milliseconds: 100));
|
||||||
"C'est le moment de noter votre phrase !");
|
|
||||||
|
|
||||||
await driver.tap(find.byValueKey('goStep8'));
|
// Generate 3 times mnemonic
|
||||||
|
await tapOn('generateMnemonic');
|
||||||
|
await tapOn('generateMnemonic');
|
||||||
|
await tapOn('generateMnemonic');
|
||||||
|
await Future.delayed(const Duration(milliseconds: 500));
|
||||||
|
|
||||||
final String goodWord = words[int.parse(
|
await selectWord();
|
||||||
await driver.getText(
|
|
||||||
find.byValueKey(
|
|
||||||
'askedWord',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)];
|
|
||||||
|
|
||||||
await driver.enterText(goodWord);
|
|
||||||
|
|
||||||
await driver.tap(find.byValueKey('goStep9'));
|
|
||||||
});
|
});
|
||||||
test('OnBoarding - Generate secret code and confirm it', (
|
test('OnBoarding - Generate secret code and confirm it', (
|
||||||
{timeout: const Duration(seconds: 5)}) async {
|
{timeout: const Duration(seconds: 5)}) async {
|
||||||
expect(
|
expect(await getText('step9'),
|
||||||
await driver.getText(find.byValueKey(
|
|
||||||
'step9',
|
|
||||||
)),
|
|
||||||
"Super !\n\nJe vais maintenant créer votre code secret. \n\nVotre code secret chiffre votre trousseau de clefs, ce qui le rend inutilisable par d’autres, par exemple si vous perdez votre téléphone ou si on vous le vole.");
|
"Super !\n\nJe vais maintenant créer votre code secret. \n\nVotre code secret chiffre votre trousseau de clefs, ce qui le rend inutilisable par d’autres, par exemple si vous perdez votre téléphone ou si on vous le vole.");
|
||||||
|
|
||||||
await driver.tap(find.byValueKey('goStep10'));
|
await tapOn('goStep10');
|
||||||
await driver.tap(find.byValueKey('goStep11'));
|
await tapOn('goStep11');
|
||||||
|
|
||||||
while (await driver.getText(find.byValueKey(
|
while (await getText('generatedPin') == '') {
|
||||||
'generatedPin',
|
|
||||||
)) ==
|
|
||||||
'') {
|
|
||||||
print('Waiting for pin code generation...');
|
print('Waiting for pin code generation...');
|
||||||
await Future.delayed(const Duration(seconds: 1));
|
await Future.delayed(const Duration(milliseconds: 100));
|
||||||
}
|
}
|
||||||
|
|
||||||
final pinCode = await driver.getText(
|
final pinCode = await getText('generatedPin');
|
||||||
find.byValueKey(
|
|
||||||
'generatedPin',
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
await driver.tap(find.byValueKey('goStep12'));
|
await tapOn('goStep12');
|
||||||
await Future.delayed(const Duration(seconds: 1));
|
await Future.delayed(const Duration(milliseconds: 300));
|
||||||
|
|
||||||
|
// //Enter bad secret code
|
||||||
|
// await driver.enterText('abcde');
|
||||||
|
// await tapOn('formKey');
|
||||||
|
// await Future.delayed(const Duration(milliseconds: 4000));
|
||||||
|
// await tapOn('formKey2');
|
||||||
|
|
||||||
|
//Enter good secret code
|
||||||
await driver.enterText(pinCode);
|
await driver.enterText(pinCode);
|
||||||
|
|
||||||
expect(
|
expect(await getText('step13'),
|
||||||
await driver.getText(find.byValueKey(
|
|
||||||
'step13',
|
|
||||||
)),
|
|
||||||
"Top !\n\nVotre trousseau de clef et votre portefeuille ont été créés avec un immense succès.\n\nFélicitations !");
|
"Top !\n\nVotre trousseau de clef et votre portefeuille ont été créés avec un immense succès.\n\nFélicitations !");
|
||||||
});
|
});
|
||||||
|
|
||||||
test('OnBoarding - Create a derivation and display it', (
|
test('My wallets - Create a derivation and display it', (
|
||||||
{timeout: const Duration(seconds: 5)}) async {
|
{timeout: const Duration(seconds: 5)}) async {
|
||||||
await driver.tap(find.byValueKey('goWalletHome'));
|
await tapOn('goWalletHome');
|
||||||
|
|
||||||
expect(
|
expect(await getText('myWallets'), "Mes portefeuilles");
|
||||||
await driver.getText(find.byValueKey(
|
await Future.delayed(const Duration(milliseconds: 300));
|
||||||
'myWallets',
|
|
||||||
)),
|
// Add a second derivation
|
||||||
"Mes portefeuilles");
|
await tapOn('addDerivation');
|
||||||
|
await Future.delayed(const Duration(milliseconds: 50));
|
||||||
|
|
||||||
|
await driver.enterText('Derivation 2');
|
||||||
|
|
||||||
|
await tapOn('validDerivation');
|
||||||
|
await Future.delayed(const Duration(milliseconds: 300));
|
||||||
|
|
||||||
|
await driver.tap(find.text('Derivation 2'));
|
||||||
|
|
||||||
|
// Wait 3 seconds at the end
|
||||||
|
await Future.delayed(const Duration(seconds: 3));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Function to go back to previous screen
|
||||||
|
Future goBack() async {
|
||||||
|
await Process.run(
|
||||||
|
'adb',
|
||||||
|
<String>['shell', 'input', 'keyevent', 'KEYCODE_BACK'],
|
||||||
|
runInShell: true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue