mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00

This test was outputting the "success" string multiple times, which is probably causing the harness to kill the app halfway through its cycle. I suspect this is causing some of the flakiness we've seen of this test. Instead, we should just output the string at the very end of the test, right before the app is done.
53 lines
1.3 KiB
Dart
53 lines
1.3 KiB
Dart
// Copyright 2014 The Flutter Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import 'dart:js_interop';
|
|
|
|
import 'package:web/web.dart' as web;
|
|
|
|
Future<void> main() async {
|
|
if (await testFetchResources()) {
|
|
print('--- TEST SUCCEEDED ---');
|
|
} else {
|
|
print('--- TEST FAILED ---');
|
|
}
|
|
}
|
|
|
|
// Attempt to load CanvasKit resources hosted on gstatic.
|
|
Future<bool> testFetchResources() async {
|
|
const String engineVersion = String.fromEnvironment('TEST_FLUTTER_ENGINE_VERSION');
|
|
if (engineVersion.isEmpty) {
|
|
return false;
|
|
}
|
|
try {
|
|
final web.Response response = await web.window.fetch(
|
|
'https://www.gstatic.com/flutter-canvaskit/$engineVersion/canvaskit.js'.toJS,
|
|
web.RequestInit(
|
|
method: 'GET',
|
|
),
|
|
).toDart;
|
|
if (!response.ok) {
|
|
return false;
|
|
}
|
|
} catch (err) {
|
|
print(err);
|
|
return false;
|
|
}
|
|
try {
|
|
final web.Response response = await web.window.fetch(
|
|
'https://www.gstatic.com/flutter-canvaskit/$engineVersion/canvaskit.wasm'.toJS,
|
|
web.RequestInit(
|
|
method: 'GET',
|
|
)
|
|
).toDart;
|
|
if (!response.ok) {
|
|
return false;
|
|
}
|
|
} catch (err) {
|
|
print(err);
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|