Cleanup the shell test, removing unused code (flutter/engine#54238)
Guess we'll find out!
This commit is contained in:
parent
38f3b2c83b
commit
4d74b4b05a
@ -2,7 +2,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
import 'dart:async' show scheduleMicrotask;
|
// ignore_for_file: avoid_print
|
||||||
|
|
||||||
import 'dart:convert' show json, utf8;
|
import 'dart:convert' show json, utf8;
|
||||||
import 'dart:isolate';
|
import 'dart:isolate';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
@ -78,14 +79,15 @@ void drawFrames() {
|
|||||||
@pragma('vm:entry-point')
|
@pragma('vm:entry-point')
|
||||||
void reportTimingsMain() {
|
void reportTimingsMain() {
|
||||||
PlatformDispatcher.instance.onReportTimings = (List<FrameTiming> timings) {
|
PlatformDispatcher.instance.onReportTimings = (List<FrameTiming> timings) {
|
||||||
List<int> timestamps = [];
|
final timestamps = <int>[];
|
||||||
for (FrameTiming t in timings) {
|
for (final t in timings) {
|
||||||
for (FramePhase phase in FramePhase.values) {
|
for (final phase in FramePhase.values) {
|
||||||
timestamps.add(t.timestampInMicroseconds(phase));
|
timestamps.add(t.timestampInMicroseconds(phase));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nativeReportTimingsCallback(timestamps);
|
nativeReportTimingsCallback(timestamps);
|
||||||
PlatformDispatcher.instance.onReportTimings = (List<FrameTiming> timings) {};
|
PlatformDispatcher.instance.onReportTimings =
|
||||||
|
(List<FrameTiming> timings) {};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,8 +102,8 @@ void onBeginFrameMain() {
|
|||||||
@pragma('vm:entry-point')
|
@pragma('vm:entry-point')
|
||||||
void onPointerDataPacketMain() {
|
void onPointerDataPacketMain() {
|
||||||
PlatformDispatcher.instance.onPointerDataPacket = (PointerDataPacket packet) {
|
PlatformDispatcher.instance.onPointerDataPacket = (PointerDataPacket packet) {
|
||||||
List<int> sequence = <int>[];
|
final sequence = <int>[];
|
||||||
for (PointerData data in packet.data) {
|
for (final data in packet.data) {
|
||||||
sequence.add(PointerChange.values.indexOf(data.change));
|
sequence.add(PointerChange.values.indexOf(data.change));
|
||||||
}
|
}
|
||||||
nativeOnPointerDataPacket(sequence);
|
nativeOnPointerDataPacket(sequence);
|
||||||
@ -123,7 +125,8 @@ void reportMetrics() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@pragma('vm:external-name', 'ReportMetrics')
|
@pragma('vm:external-name', 'ReportMetrics')
|
||||||
external void _reportMetrics(double devicePixelRatio, double width, double height);
|
external void _reportMetrics(
|
||||||
|
double devicePixelRatio, double width, double height);
|
||||||
|
|
||||||
@pragma('vm:entry-point')
|
@pragma('vm:entry-point')
|
||||||
void dummyReportTimingsMain() {
|
void dummyReportTimingsMain() {
|
||||||
@ -150,7 +153,7 @@ void thousandCallsToNative() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void secondaryIsolateMain(String message) {
|
void secondaryIsolateMain(String message) {
|
||||||
print('Secondary isolate got message: ' + message);
|
print('Secondary isolate got message: $message');
|
||||||
notifyNative();
|
notifyNative();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,21 +165,23 @@ void testCanLaunchSecondaryIsolate() {
|
|||||||
|
|
||||||
@pragma('vm:entry-point')
|
@pragma('vm:entry-point')
|
||||||
void testSkiaResourceCacheSendsResponse() {
|
void testSkiaResourceCacheSendsResponse() {
|
||||||
final PlatformMessageResponseCallback callback = (ByteData? data) {
|
void callback(ByteData? data) {
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
throw 'Response must not be null.';
|
throw AssertionError('Response must not be null.');
|
||||||
}
|
}
|
||||||
final String response = utf8.decode(data.buffer.asUint8List());
|
final String response = utf8.decode(data.buffer.asUint8List());
|
||||||
final List<bool> jsonResponse = json.decode(response).cast<bool>();
|
final jsonResponse = (json.decode(response) as List).cast<bool>();
|
||||||
if (jsonResponse[0] != true) {
|
if (!jsonResponse[0]) {
|
||||||
throw 'Response was not true';
|
throw AssertionError('Response was not true');
|
||||||
}
|
}
|
||||||
notifyNative();
|
notifyNative();
|
||||||
};
|
}
|
||||||
const String jsonRequest = '''{
|
|
||||||
"method": "Skia.setResourceCacheMaxBytes",
|
const String jsonRequest = '''
|
||||||
"args": 10000
|
{
|
||||||
}''';
|
"method": "Skia.setResourceCacheMaxBytes",
|
||||||
|
"args": 10000
|
||||||
|
}''';
|
||||||
PlatformDispatcher.instance.sendPlatformMessage(
|
PlatformDispatcher.instance.sendPlatformMessage(
|
||||||
'flutter/skia',
|
'flutter/skia',
|
||||||
ByteData.sublistView(utf8.encode(jsonRequest)),
|
ByteData.sublistView(utf8.encode(jsonRequest)),
|
||||||
@ -211,7 +216,10 @@ void canCreateImageFromDecompressedData() {
|
|||||||
void canAccessIsolateLaunchData() {
|
void canAccessIsolateLaunchData() {
|
||||||
notifyMessage(
|
notifyMessage(
|
||||||
utf8.decode(
|
utf8.decode(
|
||||||
PlatformDispatcher.instance.getPersistentIsolateData()!.buffer.asUint8List(),
|
PlatformDispatcher.instance
|
||||||
|
.getPersistentIsolateData()!
|
||||||
|
.buffer
|
||||||
|
.asUint8List(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -219,9 +227,11 @@ void canAccessIsolateLaunchData() {
|
|||||||
@pragma('vm:entry-point')
|
@pragma('vm:entry-point')
|
||||||
void performanceModeImpactsNotifyIdle() {
|
void performanceModeImpactsNotifyIdle() {
|
||||||
notifyNativeBool(false);
|
notifyNativeBool(false);
|
||||||
PlatformDispatcher.instance.requestDartPerformanceMode(DartPerformanceMode.latency);
|
PlatformDispatcher.instance
|
||||||
|
.requestDartPerformanceMode(DartPerformanceMode.latency);
|
||||||
notifyNativeBool(true);
|
notifyNativeBool(true);
|
||||||
PlatformDispatcher.instance.requestDartPerformanceMode(DartPerformanceMode.balanced);
|
PlatformDispatcher.instance
|
||||||
|
.requestDartPerformanceMode(DartPerformanceMode.balanced);
|
||||||
}
|
}
|
||||||
|
|
||||||
@pragma('vm:entry-point')
|
@pragma('vm:entry-point')
|
||||||
@ -252,12 +262,12 @@ external bool waitFixture();
|
|||||||
// Return local date-time as a string, to an hour resolution. So, "2020-07-23
|
// Return local date-time as a string, to an hour resolution. So, "2020-07-23
|
||||||
// 14:03:22" will become "2020-07-23 14".
|
// 14:03:22" will become "2020-07-23 14".
|
||||||
String localTimeAsString() {
|
String localTimeAsString() {
|
||||||
final now = DateTime.now().toLocal();
|
final now = DateTime.now().toLocal();
|
||||||
// This is: "$y-$m-$d $h:$min:$sec.$ms$us";
|
// This is: "$y-$m-$d $h:$min:$sec.$ms$us";
|
||||||
final timeStr = now.toString();
|
final timeStr = now.toString();
|
||||||
// Forward only "$y-$m-$d $h" for timestamp comparison. Not using DateTime
|
// Forward only "$y-$m-$d $h" for timestamp comparison. Not using DateTime
|
||||||
// formatting since package:intl is not available.
|
// formatting since package:intl is not available.
|
||||||
return timeStr.split(":")[0];
|
return timeStr.split(':')[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
@pragma('vm:entry-point')
|
@pragma('vm:entry-point')
|
||||||
@ -279,7 +289,7 @@ external void notifyCanAccessResource(bool success);
|
|||||||
external void notifySetAssetBundlePath();
|
external void notifySetAssetBundlePath();
|
||||||
|
|
||||||
@pragma('vm:entry-point')
|
@pragma('vm:entry-point')
|
||||||
void canAccessResourceFromAssetDir() async {
|
Future<void> canAccessResourceFromAssetDir() async {
|
||||||
notifySetAssetBundlePath();
|
notifySetAssetBundlePath();
|
||||||
window.sendPlatformMessage(
|
window.sendPlatformMessage(
|
||||||
'flutter/assets',
|
'flutter/assets',
|
||||||
@ -298,12 +308,14 @@ external void notifyNativeWhenEngineSpawn(bool success);
|
|||||||
|
|
||||||
@pragma('vm:entry-point')
|
@pragma('vm:entry-point')
|
||||||
void canReceiveArgumentsWhenEngineRun(List<String> args) {
|
void canReceiveArgumentsWhenEngineRun(List<String> args) {
|
||||||
notifyNativeWhenEngineRun(args.length == 2 && args[0] == 'foo' && args[1] == 'bar');
|
notifyNativeWhenEngineRun(
|
||||||
|
args.length == 2 && args[0] == 'foo' && args[1] == 'bar');
|
||||||
}
|
}
|
||||||
|
|
||||||
@pragma('vm:entry-point')
|
@pragma('vm:entry-point')
|
||||||
void canReceiveArgumentsWhenEngineSpawn(List<String> args) {
|
void canReceiveArgumentsWhenEngineSpawn(List<String> args) {
|
||||||
notifyNativeWhenEngineSpawn(args.length == 2 && args[0] == 'arg1' && args[1] == 'arg2');
|
notifyNativeWhenEngineSpawn(
|
||||||
|
args.length == 2 && args[0] == 'arg1' && args[1] == 'arg2');
|
||||||
}
|
}
|
||||||
|
|
||||||
@pragma('vm:entry-point')
|
@pragma('vm:entry-point')
|
||||||
@ -315,38 +327,16 @@ void onBeginFrameWithNotifyNativeMain() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@pragma('vm:entry-point')
|
@pragma('vm:entry-point')
|
||||||
void frameCallback(Object? image, int durationMilliseconds, String decodeError) {
|
void frameCallback(
|
||||||
|
Object? image, int durationMilliseconds, String decodeError) {
|
||||||
if (image == null) {
|
if (image == null) {
|
||||||
throw Exception('Expeccted image in frame callback to be non-null');
|
throw Exception('Expeccted image in frame callback to be non-null');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Picture CreateRedBox(Size size) {
|
|
||||||
Paint paint = Paint()
|
|
||||||
..color = Color.fromARGB(255, 255, 0, 0)
|
|
||||||
..style = PaintingStyle.fill;
|
|
||||||
PictureRecorder baseRecorder = PictureRecorder();
|
|
||||||
Canvas canvas = Canvas(baseRecorder);
|
|
||||||
canvas.drawRect(Rect.fromLTRB(0.0, 0.0, size.width, size.height), paint);
|
|
||||||
return baseRecorder.endRecording();
|
|
||||||
}
|
|
||||||
|
|
||||||
@pragma('vm:entry-point')
|
|
||||||
void scene_with_red_box() {
|
|
||||||
PlatformDispatcher.instance.onBeginFrame = (Duration duration) {
|
|
||||||
SceneBuilder builder = SceneBuilder();
|
|
||||||
builder.pushOffset(0.0, 0.0);
|
|
||||||
builder.addPicture(Offset(0.0, 0.0), CreateRedBox(Size(2.0, 2.0)));
|
|
||||||
builder.pop();
|
|
||||||
PlatformDispatcher.instance.views.first.render(builder.build());
|
|
||||||
};
|
|
||||||
PlatformDispatcher.instance.scheduleFrame();
|
|
||||||
}
|
|
||||||
|
|
||||||
@pragma('vm:external-name', 'NativeOnBeforeToImageSync')
|
@pragma('vm:external-name', 'NativeOnBeforeToImageSync')
|
||||||
external void onBeforeToImageSync();
|
external void onBeforeToImageSync();
|
||||||
|
|
||||||
|
|
||||||
@pragma('vm:entry-point')
|
@pragma('vm:entry-point')
|
||||||
Future<void> toImageSync() async {
|
Future<void> toImageSync() async {
|
||||||
final PictureRecorder recorder = PictureRecorder();
|
final PictureRecorder recorder = PictureRecorder();
|
||||||
@ -386,13 +376,9 @@ Future<void> toImageSync() async {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@pragma('vm:entry-point')
|
@pragma('vm:entry-point')
|
||||||
Future<void> included() async {
|
Future<void> included() async {}
|
||||||
|
|
||||||
}
|
Future<void> excluded() async {}
|
||||||
|
|
||||||
Future<void> excluded() async {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class IsolateParam {
|
class IsolateParam {
|
||||||
const IsolateParam(this.sendPort, this.rawHandle);
|
const IsolateParam(this.sendPort, this.rawHandle);
|
||||||
@ -403,13 +389,13 @@ class IsolateParam {
|
|||||||
@pragma('vm:entry-point')
|
@pragma('vm:entry-point')
|
||||||
Future<void> runCallback(IsolateParam param) async {
|
Future<void> runCallback(IsolateParam param) async {
|
||||||
try {
|
try {
|
||||||
final Future<dynamic> Function() func = PluginUtilities.getCallbackFromHandle(
|
final Future<dynamic> Function() func =
|
||||||
CallbackHandle.fromRawHandle(param.rawHandle)
|
PluginUtilities.getCallbackFromHandle(
|
||||||
)! as Future<dynamic> Function();
|
CallbackHandle.fromRawHandle(param.rawHandle))!
|
||||||
|
as Future<dynamic> Function();
|
||||||
await func.call();
|
await func.call();
|
||||||
param.sendPort.send(true);
|
param.sendPort.send(true);
|
||||||
}
|
} on NoSuchMethodError {
|
||||||
on NoSuchMethodError {
|
|
||||||
param.sendPort.send(false);
|
param.sendPort.send(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -424,13 +410,10 @@ external void notifyDestroyed();
|
|||||||
Future<void> testPluginUtilitiesCallbackHandle() async {
|
Future<void> testPluginUtilitiesCallbackHandle() async {
|
||||||
ReceivePort port = ReceivePort();
|
ReceivePort port = ReceivePort();
|
||||||
await Isolate.spawn(
|
await Isolate.spawn(
|
||||||
runCallback,
|
runCallback,
|
||||||
IsolateParam(
|
IsolateParam(port.sendPort,
|
||||||
port.sendPort,
|
PluginUtilities.getCallbackHandle(included)!.toRawHandle()),
|
||||||
PluginUtilities.getCallbackHandle(included)!.toRawHandle()
|
onError: port.sendPort);
|
||||||
),
|
|
||||||
onError: port.sendPort
|
|
||||||
);
|
|
||||||
final dynamic result1 = await port.first;
|
final dynamic result1 = await port.first;
|
||||||
if (result1 != true) {
|
if (result1 != true) {
|
||||||
print('Expected $result1 to == true');
|
print('Expected $result1 to == true');
|
||||||
@ -441,13 +424,10 @@ Future<void> testPluginUtilitiesCallbackHandle() async {
|
|||||||
if (const bool.fromEnvironment('dart.vm.product')) {
|
if (const bool.fromEnvironment('dart.vm.product')) {
|
||||||
port = ReceivePort();
|
port = ReceivePort();
|
||||||
await Isolate.spawn(
|
await Isolate.spawn(
|
||||||
runCallback,
|
runCallback,
|
||||||
IsolateParam(
|
IsolateParam(port.sendPort,
|
||||||
port.sendPort,
|
PluginUtilities.getCallbackHandle(excluded)!.toRawHandle()),
|
||||||
PluginUtilities.getCallbackHandle(excluded)!.toRawHandle()
|
onError: port.sendPort);
|
||||||
),
|
|
||||||
onError: port.sendPort
|
|
||||||
);
|
|
||||||
final dynamic result2 = await port.first;
|
final dynamic result2 = await port.first;
|
||||||
if (result2 != false) {
|
if (result2 != false) {
|
||||||
print('Expected $result2 to == false');
|
print('Expected $result2 to == false');
|
||||||
@ -463,18 +443,19 @@ Future<void> testPluginUtilitiesCallbackHandle() async {
|
|||||||
Future<void> testThatAssetLoadingHappensOnWorkerThread() async {
|
Future<void> testThatAssetLoadingHappensOnWorkerThread() async {
|
||||||
try {
|
try {
|
||||||
await ImmutableBuffer.fromAsset('DoesNotExist');
|
await ImmutableBuffer.fromAsset('DoesNotExist');
|
||||||
} catch (err) { /* Do nothing */ }
|
} catch (err) {/* Do nothing */}
|
||||||
notifyNative();
|
notifyNative();
|
||||||
}
|
}
|
||||||
|
|
||||||
@pragma('vm:external-name', 'NativeReportViewIdsCallback')
|
@pragma('vm:external-name', 'NativeReportViewIdsCallback')
|
||||||
external void nativeReportViewIdsCallback(bool hasImplicitView, List<int> viewIds);
|
external void nativeReportViewIdsCallback(
|
||||||
|
bool hasImplicitView, List<int> viewIds);
|
||||||
|
|
||||||
List<int> getCurrentViewIds() {
|
List<int> getCurrentViewIds() {
|
||||||
final List<int> result = PlatformDispatcher.instance.views
|
final List<int> result = PlatformDispatcher.instance.views
|
||||||
.map((FlutterView view) => view.viewId)
|
.map((FlutterView view) => view.viewId)
|
||||||
.toList()
|
.toList()
|
||||||
..sort();
|
..sort();
|
||||||
assert(result.toSet().length == result.length,
|
assert(result.toSet().length == result.length,
|
||||||
'Unexpected duplicate view ID found: $result');
|
'Unexpected duplicate view ID found: $result');
|
||||||
return result;
|
return result;
|
||||||
@ -498,12 +479,14 @@ bool listEquals<T>(List<T> a, List<T> b) {
|
|||||||
@pragma('vm:entry-point')
|
@pragma('vm:entry-point')
|
||||||
void testReportViewIds() {
|
void testReportViewIds() {
|
||||||
List<int> viewIds = getCurrentViewIds();
|
List<int> viewIds = getCurrentViewIds();
|
||||||
nativeReportViewIdsCallback(PlatformDispatcher.instance.implicitView != null, viewIds);
|
nativeReportViewIdsCallback(
|
||||||
|
PlatformDispatcher.instance.implicitView != null, viewIds);
|
||||||
PlatformDispatcher.instance.onMetricsChanged = () {
|
PlatformDispatcher.instance.onMetricsChanged = () {
|
||||||
final List<int> newViewIds = getCurrentViewIds();
|
final List<int> newViewIds = getCurrentViewIds();
|
||||||
if (!listEquals(viewIds, newViewIds)) {
|
if (!listEquals(viewIds, newViewIds)) {
|
||||||
viewIds = newViewIds;
|
viewIds = newViewIds;
|
||||||
nativeReportViewIdsCallback(PlatformDispatcher.instance.implicitView != null, viewIds);
|
nativeReportViewIdsCallback(
|
||||||
|
PlatformDispatcher.instance.implicitView != null, viewIds);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -550,9 +533,7 @@ void renderDummyToView(FlutterView view) {
|
|||||||
@pragma('vm:entry-point')
|
@pragma('vm:entry-point')
|
||||||
void onDrawFrameRenderAllViews() {
|
void onDrawFrameRenderAllViews() {
|
||||||
PlatformDispatcher.instance.onDrawFrame = () {
|
PlatformDispatcher.instance.onDrawFrame = () {
|
||||||
for (final FlutterView view in PlatformDispatcher.instance.views) {
|
PlatformDispatcher.instance.views.forEach(renderDummyToView);
|
||||||
renderDummyToView(view);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
notifyNative();
|
notifyNative();
|
||||||
}
|
}
|
||||||
@ -567,7 +548,7 @@ void renderViewsInFrameAndOutOfFrame() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@pragma('vm:external-name', 'CaptureRootLayer')
|
@pragma('vm:external-name', 'CaptureRootLayer')
|
||||||
external _captureRootLayer(SceneBuilder sceneBuilder);
|
external void _captureRootLayer(SceneBuilder sceneBuilder);
|
||||||
|
|
||||||
@pragma('vm:entry-point')
|
@pragma('vm:entry-point')
|
||||||
void renderTwiceForOneView() {
|
void renderTwiceForOneView() {
|
||||||
@ -637,17 +618,14 @@ void renderWarmUpImplicitView() {
|
|||||||
void renderWarmUpView1and2() {
|
void renderWarmUpView1and2() {
|
||||||
bool beginFrameCalled = false;
|
bool beginFrameCalled = false;
|
||||||
|
|
||||||
PlatformDispatcher.instance.scheduleWarmUpFrame(
|
PlatformDispatcher.instance.scheduleWarmUpFrame(beginFrame: () {
|
||||||
beginFrame: () {
|
expect(beginFrameCalled, false);
|
||||||
expect(beginFrameCalled, false);
|
beginFrameCalled = true;
|
||||||
beginFrameCalled = true;
|
}, drawFrame: () {
|
||||||
},
|
expect(beginFrameCalled, true);
|
||||||
drawFrame: () {
|
|
||||||
expect(beginFrameCalled, true);
|
|
||||||
|
|
||||||
for (final int viewId in <int>[1, 2]) {
|
for (final int viewId in <int>[1, 2]) {
|
||||||
renderDummyToView(PlatformDispatcher.instance.view(id: viewId)!);
|
renderDummyToView(PlatformDispatcher.instance.view(id: viewId)!);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
);
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user