diff --git a/lib/web_ui/dev/steps/run_suite_step.dart b/lib/web_ui/dev/steps/run_suite_step.dart index b4a8571ecf9f3..2944187a7f38b 100644 --- a/lib/web_ui/dev/steps/run_suite_step.dart +++ b/lib/web_ui/dev/steps/run_suite_step.dart @@ -217,7 +217,7 @@ class RunSuiteStep implements PipelineStep { Future _checkSkiaClient(SkiaGoldClient skiaClient) async { // Now let's check whether Skia Gold is reachable or not. if (isLuci) { - if (isSkiaGoldClientAvailable) { + if (SkiaGoldClient.isAvailable()) { try { await skiaClient.auth(); return true; diff --git a/testing/dart/goldens.dart b/testing/dart/goldens.dart index 5a70ecfc95f78..84addf8e20d69 100644 --- a/testing/dart/goldens.dart +++ b/testing/dart/goldens.dart @@ -43,7 +43,7 @@ class ImageComparer { final Map dimensions = { 'impeller_enabled': impellerEnabled.toString(), }; - final SkiaGoldClient client = isSkiaGoldClientAvailable && _useSkiaGold + final SkiaGoldClient client = SkiaGoldClient.isAvailable() && _useSkiaGold ? SkiaGoldClient(workDirectory, dimensions: dimensions, verbose: verbose) : _FakeSkiaGoldClient(workDirectory, dimensions, verbose: verbose); diff --git a/testing/scenario_app/bin/run_android_tests.dart b/testing/scenario_app/bin/run_android_tests.dart index e253f85565416..9c16fb9ed6fe6 100644 --- a/testing/scenario_app/bin/run_android_tests.dart +++ b/testing/scenario_app/bin/run_android_tests.dart @@ -194,7 +194,7 @@ Future _run({ if (verbose) { log('wrote ${goldenFile.absolute.path}'); } - if (isSkiaGoldClientAvailable) { + if (SkiaGoldClient.isAvailable()) { final Future comparison = skiaGoldClient! // Each color channel can be off by 2. .addImg(fileName, goldenFile, screenshotSize: screenshot.pixelCount, pixelColorDelta: 8) @@ -311,7 +311,7 @@ Future _run({ }); await step('Skia Gold auth...', () async { - if (isSkiaGoldClientAvailable) { + if (SkiaGoldClient.isAvailable()) { await skiaGoldClient!.auth(); log('skia gold client is available'); } else { diff --git a/testing/skia_gold_client/README.md b/testing/skia_gold_client/README.md index 3e7f6ec2d5fea..8c4c68e19985c 100644 --- a/testing/skia_gold_client/README.md +++ b/testing/skia_gold_client/README.md @@ -12,7 +12,7 @@ The web UI is available on https://flutter-engine-gold.skia.org/. 1. In `.ci.yaml`, ensure that the task has a dependency on `goldctl`: ```yaml - dependencies: [{"dependency": "goldctl"}] +dependencies: [{ "dependency": "goldctl" }] ``` 2. In the builder `.json` file, ensure the drone has a dependency on `goldctl`: @@ -50,7 +50,7 @@ Future main() { ); try { - if (isSkiaGoldClientAvailable) { + if (SkiaGoldClient.isAvailable()) { await client.auth(); await client.addImg( diff --git a/testing/skia_gold_client/lib/skia_gold_client.dart b/testing/skia_gold_client/lib/skia_gold_client.dart index 5dde4d8608003..ec657fe2bb925 100644 --- a/testing/skia_gold_client/lib/skia_gold_client.dart +++ b/testing/skia_gold_client/lib/skia_gold_client.dart @@ -18,13 +18,6 @@ const String _kLuciEnvName = 'LUCI_CONTEXT'; const String _skiaGoldHost = 'https://flutter-engine-gold.skia.org'; const String _instance = 'flutter-engine'; -/// Whether the Skia Gold client is available and can be used in this -/// environment. -bool get isSkiaGoldClientAvailable => SkiaGoldClient.isAvailable(); - -/// Returns true if the current environment is a LUCI builder. -bool get isLuciEnv => io.Platform.environment.containsKey(_kLuciEnvName); - /// A client for uploading image tests and making baseline requests to the /// Flutter Gold Dashboard. interface class SkiaGoldClient { @@ -463,32 +456,28 @@ interface class SkiaGoldClient { Future getExpectationForTest(String testName) async { late String? expectation; final String traceID = getTraceID(testName); - await io.HttpOverrides.runWithHttpOverrides>(() async { - final Uri requestForExpectations = Uri.parse( - '$_skiaGoldHost/json/v2/latestpositivedigest/$traceID' - ); - late String rawResponse; - try { - final io.HttpClientRequest request = await httpClient.getUrl(requestForExpectations); - final io.HttpClientResponse response = await request.close(); - rawResponse = await utf8.decodeStream(response); - final dynamic jsonResponse = json.decode(rawResponse); - if (jsonResponse is! Map) { - throw const FormatException('Skia gold expectations do not match expected format.'); - } - expectation = jsonResponse['digest'] as String?; - } on FormatException catch (error) { - _stderr.writeln( - 'Formatting error detected requesting expectations from Flutter Gold.\n' - 'error: $error\n' - 'url: $requestForExpectations\n' - 'response: $rawResponse' - ); - rethrow; - } - }, - SkiaGoldHttpOverrides(), + final Uri requestForExpectations = Uri.parse( + '$_skiaGoldHost/json/v2/latestpositivedigest/$traceID' ); + late String rawResponse; + try { + final io.HttpClientRequest request = await httpClient.getUrl(requestForExpectations); + final io.HttpClientResponse response = await request.close(); + rawResponse = await utf8.decodeStream(response); + final dynamic jsonResponse = json.decode(rawResponse); + if (jsonResponse is! Map) { + throw const FormatException('Skia gold expectations do not match expected format.'); + } + expectation = jsonResponse['digest'] as String?; + } on FormatException catch (error) { + _stderr.writeln( + 'Formatting error detected requesting expectations from Flutter Gold.\n' + 'error: $error\n' + 'url: $requestForExpectations\n' + 'response: $rawResponse' + ); + rethrow; + } return expectation; } @@ -561,6 +550,3 @@ interface class SkiaGoldClient { return md5Sum; } } - -/// Used to make HttpRequests during testing. -class SkiaGoldHttpOverrides extends io.HttpOverrides { } diff --git a/web_sdk/web_test_utils/lib/image_compare.dart b/web_sdk/web_test_utils/lib/image_compare.dart index a6d9fbdf869fb..4fca24189500c 100644 --- a/web_sdk/web_test_utils/lib/image_compare.dart +++ b/web_sdk/web_test_utils/lib/image_compare.dart @@ -34,7 +34,7 @@ Future compareImage( await screenshotFile.create(recursive: true); await screenshotFile.writeAsBytes(encodePng(screenshot), flush: true); - if (isLuciEnv) { + if (SkiaGoldClient.isLuciEnv()) { // This is temporary to get started by uploading existing screenshots to // Skia Gold. The next step would be to actually use Skia Gold for // comparison.