Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 146595e

Browse files
author
nturgut
committed
address some comments
1 parent 8a321d9 commit 146595e

File tree

4 files changed

+14
-23
lines changed

4 files changed

+14
-23
lines changed

e2etests/web/regular_integration_tests/lib/screenshot_support.dart

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import 'package:image/image.dart';
1616
///
1717
/// We are allowing a higher difference rate compared to the unit tests (where
1818
/// this rate is set to 0.28), since during the end to end tests there are
19-
/// more components on the screen which are not related to the functinality
19+
/// more components on the screen which are not related to the functionality
2020
/// under test ex: a blinking cursor.
2121
const double kMaxDiffRateFailure = 0.5 / 100; // 0.5%
2222

@@ -31,29 +31,26 @@ const double kMaxDiffRateFailure = 0.5 / 100; // 0.5%
3131
///
3232
/// It provides an `onScreenshot` callback to the `integrationDriver` method.
3333
/// It also includes options for updating the golden files.
34-
Future<void> main() async {
34+
Future<void> runTestWithScreenshots(
35+
{double diffRateFailure = kMaxDiffRateFailure}) async {
3536
final WebFlutterDriver driver =
3637
await FlutterDriver.connect() as WebFlutterDriver;
3738

3839
// Learn the browser in use from the webDriver.
3940
final String browser = driver.webDriver.capabilities['browserName'] as String;
4041

4142
bool updateGoldens = false;
42-
try {
43+
final String updateGoldensFlag = io.Platform.environment['UPDATE_GOLDENS'];
44+
if (updateGoldensFlag == null || updateGoldensFlag.toLowerCase() != 'true') {
4345
// We are using an environment variable since instead of an argument, since
4446
// this code is not invoked from the shell but from the `flutter drive`
4547
// tool itself. Therefore we do not have control on the command line
4648
// arguments.
4749
// Please read the README, further info on how to update the goldens.
48-
updateGoldens =
49-
io.Platform.environment['UPDATE_GOLDENS'].toLowerCase() == 'true';
50-
} catch (ex) {
51-
if (ex
52-
.toString()
53-
.contains('is not a subtype of type \'bool\' in type cast')) {
54-
print('INFO: goldens will not be updated, please set `UPDATE_GOLDENS` '
55-
'environment variable to true');
56-
}
50+
print('INFO: Goldens will not be updated. Please set `UPDATE_GOLDENS` '
51+
'environment variable to `true` for updating them.');
52+
} else {
53+
updateGoldens = true;
5754
}
5855

5956
test.integrationDriver(
@@ -65,7 +62,7 @@ Future<void> main() async {
6562
updateGoldens,
6663
'$screenshotName-$browser.png',
6764
PixelComparison.fuzzy,
68-
kMaxDiffRateFailure,
65+
diffRateFailure,
6966
forIntegrationTests: true,
7067
write: updateGoldens,
7168
);

e2etests/web/regular_integration_tests/test_driver/text_editing_integration_test.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
import 'package:regular_integration_tests/screenshot_support.dart'
6-
as with_screenshot;
5+
import 'package:regular_integration_tests/screenshot_support.dart' as test;
76

87
Future<void> main() async {
9-
await with_screenshot.main();
8+
await test.runTestWithScreenshots();
109
}

web_sdk/common_test_utils/lib/exceptions.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
import 'dart:io' as io;
6-
7-
import 'package:meta/meta.dart';
8-
95
class BrowserInstallerException implements Exception {
106
BrowserInstallerException(this.message);
117

web_sdk/golden_comparator/lib/goldens.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ String getPrintableDiffFilesInfo(double diffRate, double maxRate) =>
191191
'(${((diffRate) * 100).toStringAsFixed(4)}% of pixels were different. '
192192
'Maximum allowed rate is: ${(maxRate * 100).toStringAsFixed(4)}%).';
193193

194-
/// Downloads the repository that we store the golden files.
194+
/// Downloads the repository that stores the golden files.
195195
///
196196
/// Reads the url of the repo and `commit no` to sync to, from
197197
/// `goldens_lock.yaml`.
@@ -257,7 +257,7 @@ class GoldensRepoFetcher {
257257
}
258258

259259
/// Runs `git` with given arguments.
260-
Future<int> _runGit(
260+
Future<void> _runGit(
261261
List<String> arguments,
262262
String workingDirectory,
263263
) async {
@@ -276,6 +276,5 @@ class GoldensRepoFetcher {
276276
'workingDirectory: $workingDirectory resulting with exitCode: '
277277
'$exitCode');
278278
}
279-
return exitCode;
280279
}
281280
}

0 commit comments

Comments
 (0)