flutter/dev/tracing_tests/test/common.dart
engine-flutter-autoroll 0da0479702
Manual roll Flutter Engine from 4f4734cd48da to a0d650e37f5d (3 revisions) (#131967)
Manual roll requested by jacksongardner@google.com

Cannot build log URL because revision "a0d650e37f5d" is invalid: Luci builds of "Linux Web Framework tests" for a0d650e37f5d715468d8797519c622998ff5ab27 was FAILURE

2023-08-04 skia-flutter-autoroll@skia.org Roll Dart SDK from a0b59bac20fc to 8a3277696c52 (1 revision) (flutter/engine#44405)
2023-08-04 skia-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from ZvUiUZL9vUp2LcvHG... to 3uzA1Z-yaMQE_Cz5f... (flutter/engine#44403)
2023-08-04 skia-flutter-autoroll@skia.org Roll Skia from 6dc76e862f90 to 7cf7e2da3557 (1 revision) (flutter/engine#44402)

Also rolling transitive DEPS:
  fuchsia/sdk/core/linux-amd64 from ZvUiUZL9vUp2 to 3uzA1Z-yaMQE

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC jacksongardner@google.com,rmistry@google.com,zra@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
2023-08-05 01:22:17 +00:00

83 lines
2.8 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:developer' as developer;
import 'dart:isolate' as isolate;
import 'package:flutter/foundation.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:vm_service/vm_service.dart';
import 'package:vm_service/vm_service_io.dart';
export 'package:vm_service/vm_service.dart' show TimelineEvent;
late String isolateId;
late VmService _vmService;
void initTimelineTests() {
setUpAll(() async {
final developer.ServiceProtocolInfo info = await developer.Service.getInfo();
if (info.serverUri == null) {
fail('This test _must_ be run with --enable-vmservice.');
}
_vmService = await vmServiceConnectUri('ws://localhost:${info.serverUri!.port}${info.serverUri!.path}ws');
await _vmService.setVMTimelineFlags(<String>['Dart']);
isolateId = developer.Service.getIsolateId(isolate.Isolate.current)!;
});
}
Future<List<TimelineEvent>> fetchTimelineEvents() async {
final Timeline timeline = await _vmService.getVMTimeline();
await _vmService.clearVMTimeline();
return timeline.traceEvents!;
}
Future<List<TimelineEvent>> fetchInterestingEvents(Set<String> interestingLabels) async {
return (await fetchTimelineEvents()).where((TimelineEvent event) {
return interestingLabels.contains(event.json!['name'])
&& event.json!['ph'] == 'B'; // "Begin" mark of events, vs E which is for the "End" mark of events.
}).toList();
}
String eventToName(TimelineEvent event) => event.json!['name'] as String;
Future<List<String>> fetchInterestingEventNames(Set<String> interestingLabels) async {
return (await fetchInterestingEvents(interestingLabels)).map<String>(eventToName).toList();
}
Future<void> runFrame(VoidCallback callback) {
final Future<void> result = SchedulerBinding.instance.endOfFrame; // schedules a frame
callback();
return result;
}
// This binding skips the zones tests. These tests were written before we
// verified zones properly, and they have been legacied-in to avoid having
// to refactor them.
//
// When creating new tests, avoid relying on this class.
class ZoneIgnoringTestBinding extends WidgetsFlutterBinding {
@override
void initInstances() {
super.initInstances();
_instance = this;
}
@override
bool debugCheckZone(String entryPoint) { return true; }
static ZoneIgnoringTestBinding get instance => BindingBase.checkInstance(_instance);
static ZoneIgnoringTestBinding? _instance;
static ZoneIgnoringTestBinding ensureInitialized() {
if (ZoneIgnoringTestBinding._instance == null) {
ZoneIgnoringTestBinding();
}
return ZoneIgnoringTestBinding.instance;
}
}