make integration_test_driver_extended.dart support writeResponseData--(done) (#128382)

*Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.*

*List which issues are fixed by this PR. You must list at least one issue.*
- https://github.com/flutter/flutter/issues/128381

*If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*
This commit is contained in:
LinChen
2023-10-17 17:17:09 -05:00
committed by GitHub
parent 380520d41d
commit 3d1d4532b5
5 changed files with 105 additions and 4 deletions

View File

@@ -1181,6 +1181,8 @@ Future<void> _runWebLongRunningTests() async {
driver: path.join('test_driver', 'integration_test.dart'),
buildMode: buildMode,
renderer: 'canvaskit',
expectWriteResponseFile: true,
expectResponseFileContent: 'null',
),
() => _runFlutterDriverWebTest(
testAppDirectory: path.join('packages', 'integration_test', 'example'),
@@ -1188,6 +1190,20 @@ Future<void> _runWebLongRunningTests() async {
driver: path.join('test_driver', 'extended_integration_test.dart'),
buildMode: buildMode,
renderer: 'canvaskit',
expectWriteResponseFile: true,
expectResponseFileContent: '''
{
"screenshots": [
{
"screenshotName": "platform_name",
"bytes": []
},
{
"screenshotName": "platform_name_2",
"bytes": []
}
]
}''',
),
],
@@ -1321,6 +1337,8 @@ Future<void> _runFlutterDriverWebTest({
String? driver,
bool expectFailure = false,
bool silenceBrowserOutput = false,
bool expectWriteResponseFile = false,
String expectResponseFileContent = '',
}) async {
printProgress('${green}Running integration tests $target in $buildMode mode.$reset');
await runCommand(
@@ -1328,6 +1346,11 @@ Future<void> _runFlutterDriverWebTest({
<String>[ 'clean' ],
workingDirectory: testAppDirectory,
);
final String responseFile =
path.join(testAppDirectory, 'build', 'integration_response_data.json');
if (File(responseFile).existsSync()) {
File(responseFile).deleteSync();
}
await runCommand(
flutter,
<String>[
@@ -1356,6 +1379,20 @@ Future<void> _runFlutterDriverWebTest({
return false;
},
);
if (expectWriteResponseFile) {
if (!File(responseFile).existsSync()) {
foundError(<String>[
'$bold${red}Command did not write the response file but expected response file written.$reset',
]);
} else {
final String response = File(responseFile).readAsStringSync();
if (response != expectResponseFileContent) {
foundError(<String>[
'$bold${red}Command write the response file with $response but expected response file with $expectResponseFileContent.$reset',
]);
}
}
}
}
// Compiles a sample web app and checks that its JS doesn't contain certain