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

Commit 41fce3f

Browse files
authored
Remove or replaced unused or duplicate code in SkiaGoldClient. (#51399)
- `get isAvailable` -> `SkiaGoldClient.isAvailable()` - `get isLuciEnv` -> `SkiaGoldClient.isLuciEnv()` - Remove unused `SkiaGoldHttpOverrides`
1 parent 46993c1 commit 41fce3f

File tree

6 files changed

+28
-42
lines changed

6 files changed

+28
-42
lines changed

lib/web_ui/dev/steps/run_suite_step.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ class RunSuiteStep implements PipelineStep {
217217
Future<bool> _checkSkiaClient(SkiaGoldClient skiaClient) async {
218218
// Now let's check whether Skia Gold is reachable or not.
219219
if (isLuci) {
220-
if (isSkiaGoldClientAvailable) {
220+
if (SkiaGoldClient.isAvailable()) {
221221
try {
222222
await skiaClient.auth();
223223
return true;

testing/dart/goldens.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class ImageComparer {
4343
final Map<String, String> dimensions = <String, String>{
4444
'impeller_enabled': impellerEnabled.toString(),
4545
};
46-
final SkiaGoldClient client = isSkiaGoldClientAvailable && _useSkiaGold
46+
final SkiaGoldClient client = SkiaGoldClient.isAvailable() && _useSkiaGold
4747
? SkiaGoldClient(workDirectory,
4848
dimensions: dimensions, verbose: verbose)
4949
: _FakeSkiaGoldClient(workDirectory, dimensions, verbose: verbose);

testing/scenario_app/bin/run_android_tests.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ Future<void> _run({
194194
if (verbose) {
195195
log('wrote ${goldenFile.absolute.path}');
196196
}
197-
if (isSkiaGoldClientAvailable) {
197+
if (SkiaGoldClient.isAvailable()) {
198198
final Future<void> comparison = skiaGoldClient!
199199
// Each color channel can be off by 2.
200200
.addImg(fileName, goldenFile, screenshotSize: screenshot.pixelCount, pixelColorDelta: 8)
@@ -311,7 +311,7 @@ Future<void> _run({
311311
});
312312

313313
await step('Skia Gold auth...', () async {
314-
if (isSkiaGoldClientAvailable) {
314+
if (SkiaGoldClient.isAvailable()) {
315315
await skiaGoldClient!.auth();
316316
log('skia gold client is available');
317317
} else {

testing/skia_gold_client/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The web UI is available on https://flutter-engine-gold.skia.org/.
1212
1. In `.ci.yaml`, ensure that the task has a dependency on `goldctl`:
1313

1414
```yaml
15-
dependencies: [{"dependency": "goldctl"}]
15+
dependencies: [{ "dependency": "goldctl" }]
1616
```
1717
1818
2. In the builder `.json` file, ensure the drone has a dependency on `goldctl`:
@@ -50,7 +50,7 @@ Future<void> main() {
5050
);
5151
5252
try {
53-
if (isSkiaGoldClientAvailable) {
53+
if (SkiaGoldClient.isAvailable()) {
5454
await client.auth();
5555
5656
await client.addImg(

testing/skia_gold_client/lib/skia_gold_client.dart

Lines changed: 21 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,6 @@ const String _kLuciEnvName = 'LUCI_CONTEXT';
1818
const String _skiaGoldHost = 'https://flutter-engine-gold.skia.org';
1919
const String _instance = 'flutter-engine';
2020

21-
/// Whether the Skia Gold client is available and can be used in this
22-
/// environment.
23-
bool get isSkiaGoldClientAvailable => SkiaGoldClient.isAvailable();
24-
25-
/// Returns true if the current environment is a LUCI builder.
26-
bool get isLuciEnv => io.Platform.environment.containsKey(_kLuciEnvName);
27-
2821
/// A client for uploading image tests and making baseline requests to the
2922
/// Flutter Gold Dashboard.
3023
interface class SkiaGoldClient {
@@ -463,32 +456,28 @@ interface class SkiaGoldClient {
463456
Future<String?> getExpectationForTest(String testName) async {
464457
late String? expectation;
465458
final String traceID = getTraceID(testName);
466-
await io.HttpOverrides.runWithHttpOverrides<Future<void>>(() async {
467-
final Uri requestForExpectations = Uri.parse(
468-
'$_skiaGoldHost/json/v2/latestpositivedigest/$traceID'
469-
);
470-
late String rawResponse;
471-
try {
472-
final io.HttpClientRequest request = await httpClient.getUrl(requestForExpectations);
473-
final io.HttpClientResponse response = await request.close();
474-
rawResponse = await utf8.decodeStream(response);
475-
final dynamic jsonResponse = json.decode(rawResponse);
476-
if (jsonResponse is! Map<String, dynamic>) {
477-
throw const FormatException('Skia gold expectations do not match expected format.');
478-
}
479-
expectation = jsonResponse['digest'] as String?;
480-
} on FormatException catch (error) {
481-
_stderr.writeln(
482-
'Formatting error detected requesting expectations from Flutter Gold.\n'
483-
'error: $error\n'
484-
'url: $requestForExpectations\n'
485-
'response: $rawResponse'
486-
);
487-
rethrow;
488-
}
489-
},
490-
SkiaGoldHttpOverrides(),
459+
final Uri requestForExpectations = Uri.parse(
460+
'$_skiaGoldHost/json/v2/latestpositivedigest/$traceID'
491461
);
462+
late String rawResponse;
463+
try {
464+
final io.HttpClientRequest request = await httpClient.getUrl(requestForExpectations);
465+
final io.HttpClientResponse response = await request.close();
466+
rawResponse = await utf8.decodeStream(response);
467+
final dynamic jsonResponse = json.decode(rawResponse);
468+
if (jsonResponse is! Map<String, dynamic>) {
469+
throw const FormatException('Skia gold expectations do not match expected format.');
470+
}
471+
expectation = jsonResponse['digest'] as String?;
472+
} on FormatException catch (error) {
473+
_stderr.writeln(
474+
'Formatting error detected requesting expectations from Flutter Gold.\n'
475+
'error: $error\n'
476+
'url: $requestForExpectations\n'
477+
'response: $rawResponse'
478+
);
479+
rethrow;
480+
}
492481
return expectation;
493482
}
494483

@@ -561,6 +550,3 @@ interface class SkiaGoldClient {
561550
return md5Sum;
562551
}
563552
}
564-
565-
/// Used to make HttpRequests during testing.
566-
class SkiaGoldHttpOverrides extends io.HttpOverrides { }

web_sdk/web_test_utils/lib/image_compare.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Future<String> compareImage(
3434
await screenshotFile.create(recursive: true);
3535
await screenshotFile.writeAsBytes(encodePng(screenshot), flush: true);
3636

37-
if (isLuciEnv) {
37+
if (SkiaGoldClient.isLuciEnv()) {
3838
// This is temporary to get started by uploading existing screenshots to
3939
// Skia Gold. The next step would be to actually use Skia Gold for
4040
// comparison.

0 commit comments

Comments
 (0)