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

More diagnostic clean ups #54265

Merged
merged 4 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/snapshot/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# found in the LICENSE file.

# This file is needed by Fuchsia's dart_library template.
name: _snapshot_but_this_package_name_is_not_used

environment:
sdk: '>=3.2.0-0 <4.0.0'
2 changes: 0 additions & 2 deletions runtime/fixtures/split_lib_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

library splitlib;

int splitAdd(int i, int j) {
return i + j;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// ignore_for_file: avoid_print

import 'dart:io';
import 'dart:typed_data';
import 'dart:ui';

@pragma('vm:external-name', 'SignalNativeTest')
external void signalNativeTest();

void main() {
}
void main() {}

@pragma('vm:entry-point')
void empty() {
}
void empty() {}

/// Notifies the test of a string value.
///
Expand All @@ -38,11 +38,11 @@ void canLogToStdout() {
@pragma('vm:entry-point')
void canCompositePlatformViews() {
PlatformDispatcher.instance.onBeginFrame = (Duration duration) {
SceneBuilder builder = SceneBuilder();
builder.addPicture(Offset(1.0, 1.0), _createSimplePicture());
final builder = SceneBuilder();
builder.addPicture(const Offset(1.0, 1.0), _createSimplePicture());
builder.pushOffset(1.0, 2.0);
builder.addPlatformView(42, width: 123.0, height: 456.0);
builder.addPicture(Offset(1.0, 1.0), _createSimplePicture());
builder.addPicture(const Offset(1.0, 1.0), _createSimplePicture());
builder.pop(); // offset
PlatformDispatcher.instance.views.first.render(builder.build());
};
Expand All @@ -52,8 +52,8 @@ void canCompositePlatformViews() {
@pragma('vm:entry-point')
void drawIntoAllViews() {
PlatformDispatcher.instance.onBeginFrame = (Duration duration) {
SceneBuilder builder = SceneBuilder();
builder.addPicture(Offset(1.0, 1.0), _createSimplePicture());
final builder = SceneBuilder();
builder.addPicture(const Offset(1.0, 1.0), _createSimplePicture());
for (final FlutterView view in PlatformDispatcher.instance.views) {
view.render(builder.build());
}
Expand All @@ -63,10 +63,10 @@ void drawIntoAllViews() {

/// Returns a [Picture] of a simple black square.
Picture _createSimplePicture() {
Paint blackPaint = Paint();
PictureRecorder baseRecorder = PictureRecorder();
Canvas canvas = Canvas(baseRecorder);
canvas.drawRect(Rect.fromLTRB(0.0, 0.0, 1000.0, 1000.0), blackPaint);
final blackPaint = Paint();
final baseRecorder = PictureRecorder();
final canvas = Canvas(baseRecorder);
canvas.drawRect(const Rect.fromLTRB(0.0, 0.0, 1000.0, 1000.0), blackPaint);
return baseRecorder.endRecording();
}

Expand All @@ -83,5 +83,6 @@ void backgroundTest() {

@pragma('vm:entry-point')
void sendFooMessage() {
PlatformDispatcher.instance.sendPlatformMessage('foo', null, (ByteData? result) {});
PlatformDispatcher.instance
.sendPlatformMessage('foo', null, (ByteData? result) {});
}
101 changes: 55 additions & 46 deletions shell/platform/windows/fixtures/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
// found in the LICENSE file.

import 'dart:async';
import 'dart:convert';
import 'dart:io' as io;
import 'dart:typed_data' show ByteData, Endian, Uint8List;
import 'dart:typed_data' show ByteData, Uint8List;
import 'dart:ui' as ui;
import 'dart:convert';

// Signals a waiting latch in the native test.
@pragma('vm:external-name', 'Signal')
Expand Down Expand Up @@ -53,7 +53,7 @@ Future<void> get semanticsChanged {
}

@pragma('vm:entry-point')
void sendAccessibilityAnnouncement() async {
Future<void> sendAccessibilityAnnouncement() async {
// Wait until semantics are enabled.
if (!ui.PlatformDispatcher.instance.semanticsEnabled) {
await semanticsChanged;
Expand Down Expand Up @@ -91,7 +91,7 @@ void sendAccessibilityAnnouncement() async {
}

@pragma('vm:entry-point')
void sendAccessibilityTooltipEvent() async {
Future<void> sendAccessibilityTooltipEvent() async {
// Wait until semantics are enabled.
if (!ui.PlatformDispatcher.instance.semanticsEnabled) {
await semanticsChanged;
Expand Down Expand Up @@ -129,10 +129,13 @@ void sendAccessibilityTooltipEvent() async {
}

@pragma('vm:entry-point')
void exitTestExit() async {
Future<void> exitTestExit() async {
final Completer<ByteData?> closed = Completer<ByteData?>();
ui.channelBuffers.setListener('flutter/platform', (ByteData? data, ui.PlatformMessageResponseCallback callback) async {
final String jsonString = json.encode(<Map<String, String>>[{'response': 'exit'}]);
ui.channelBuffers.setListener('flutter/platform',
(ByteData? data, ui.PlatformMessageResponseCallback callback) async {
final String jsonString = json.encode(<Map<String, String>>[
{'response': 'exit'}
]);
final ByteData responseData = ByteData.sublistView(utf8.encode(jsonString));
callback(responseData);
closed.complete(data);
Expand All @@ -141,10 +144,13 @@ void exitTestExit() async {
}

@pragma('vm:entry-point')
void exitTestCancel() async {
Future<void> exitTestCancel() async {
final Completer<ByteData?> closed = Completer<ByteData?>();
ui.channelBuffers.setListener('flutter/platform', (ByteData? data, ui.PlatformMessageResponseCallback callback) async {
final String jsonString = json.encode(<Map<String, String>>[{'response': 'cancel'}]);
ui.channelBuffers.setListener('flutter/platform',
(ByteData? data, ui.PlatformMessageResponseCallback callback) async {
final String jsonString = json.encode(<Map<String, String>>[
{'response': 'cancel'}
]);
final ByteData responseData = ByteData.sublistView(utf8.encode(jsonString));
callback(responseData);
closed.complete(data);
Expand All @@ -155,53 +161,52 @@ void exitTestCancel() async {
final Completer<ByteData?> exited = Completer<ByteData?>();
final String jsonString = json.encode(<String, dynamic>{
'method': 'System.exitApplication',
'args': <String, dynamic>{
'type': 'required', 'exitCode': 0
}
});
'args': <String, dynamic>{'type': 'required', 'exitCode': 0}
});
ui.PlatformDispatcher.instance.sendPlatformMessage(
'flutter/platform',
ByteData.sublistView(utf8.encode(jsonString)),
(ByteData? reply) {
exited.complete(reply);
});
'flutter/platform', ByteData.sublistView(utf8.encode(jsonString)),
(ByteData? reply) {
exited.complete(reply);
});
await exited.future;
}

@pragma('vm:entry-point')
void enableLifecycleTest() async {
Future<void> enableLifecycleTest() async {
final Completer<ByteData?> finished = Completer<ByteData?>();
ui.channelBuffers.setListener('flutter/lifecycle', (ByteData? data, ui.PlatformMessageResponseCallback callback) async {
ui.channelBuffers.setListener('flutter/lifecycle',
(ByteData? data, ui.PlatformMessageResponseCallback callback) async {
if (data != null) {
ui.PlatformDispatcher.instance.sendPlatformMessage(
'flutter/unittest',
data,
(ByteData? reply) {
finished.complete();
});
ui.PlatformDispatcher.instance
.sendPlatformMessage('flutter/unittest', data, (ByteData? reply) {
finished.complete();
});
}
});
await finished.future;
}

@pragma('vm:entry-point')
void enableLifecycleToFrom() async {
ui.channelBuffers.setListener('flutter/lifecycle', (ByteData? data, ui.PlatformMessageResponseCallback callback) async {
Future<void> enableLifecycleToFrom() async {
ui.channelBuffers.setListener('flutter/lifecycle',
(ByteData? data, ui.PlatformMessageResponseCallback callback) async {
if (data != null) {
ui.PlatformDispatcher.instance.sendPlatformMessage(
'flutter/unittest',
data,
(ByteData? reply) {});
ui.PlatformDispatcher.instance
.sendPlatformMessage('flutter/unittest', data, (ByteData? reply) {});
}
});
final Completer<ByteData?> enabledLifecycle = Completer<ByteData?>();
ui.PlatformDispatcher.instance.sendPlatformMessage('flutter/platform', ByteData.sublistView(utf8.encode('{"method":"System.initializationComplete"}')), (ByteData? data) {
ui.PlatformDispatcher.instance.sendPlatformMessage(
'flutter/platform',
ByteData.sublistView(
utf8.encode('{"method":"System.initializationComplete"}')),
(ByteData? data) {
enabledLifecycle.complete(data);
});
}

@pragma('vm:entry-point')
void sendCreatePlatformViewMethod() async {
Future<void> sendCreatePlatformViewMethod() async {
// The platform view method channel uses the standard method codec.
// See https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/services/message_codecs.dart#L262
// for the implementation of the encoding and magic number identifiers.
Expand All @@ -225,14 +230,15 @@ void sendCreatePlatformViewMethod() async {

final Completer<ByteData?> completed = Completer<ByteData?>();
final ByteData bytes = ByteData.sublistView(Uint8List.fromList(data));
ui.PlatformDispatcher.instance.sendPlatformMessage('flutter/platform_views', bytes, (ByteData? response) {
ui.PlatformDispatcher.instance.sendPlatformMessage(
'flutter/platform_views', bytes, (ByteData? response) {
completed.complete(response);
});
await completed.future;
}

@pragma('vm:entry-point')
void sendGetKeyboardState() async {
Future<void> sendGetKeyboardState() async {
// The keyboard method channel uses the standard method codec.
// See https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/services/message_codecs.dart#L262
// for the implementation of the encoding and magic number identifiers.
Expand All @@ -250,7 +256,8 @@ void sendGetKeyboardState() async {

final Completer<void> completer = Completer<void>();
final ByteData bytes = ByteData.sublistView(Uint8List.fromList(data));
ui.PlatformDispatcher.instance.sendPlatformMessage('flutter/keyboard', bytes, (ByteData? response) {
ui.PlatformDispatcher.instance.sendPlatformMessage('flutter/keyboard', bytes,
(ByteData? response) {
// For magic numbers for decoding a reply envelope, see:
// https://github.com/flutter/flutter/blob/67271f69f7f88a4edba6d8023099e3bd27a072d2/packages/flutter/lib/src/services/message_codecs.dart#L577-L587
const int replyEnvelopeSuccess = 0;
Expand All @@ -259,11 +266,14 @@ void sendGetKeyboardState() async {
if (response == null) {
signalStringValue('Unexpected null response');
} else if (response.lengthInBytes < 2) {
signalStringValue('Unexpected response length of ${response.lengthInBytes} bytes');
signalStringValue(
'Unexpected response length of ${response.lengthInBytes} bytes');
} else if (response.getUint8(0) != replyEnvelopeSuccess) {
signalStringValue('Unexpected response envelope status: ${response.getUint8(0)}');
signalStringValue(
'Unexpected response envelope status: ${response.getUint8(0)}');
} else if (response.getUint8(1) != valueMap) {
signalStringValue('Unexpected response value magic number: ${response.getUint8(1)}');
signalStringValue(
'Unexpected response value magic number: ${response.getUint8(1)}');
} else {
signalStringValue('Success');
}
Expand All @@ -287,7 +297,7 @@ void verifyNativeFunctionWithParameters() {

@pragma('vm:entry-point')
void verifyNativeFunctionWithReturn() {
bool value = signalBoolReturn();
final value = signalBoolReturn();
signalBoolValue(value);
}

Expand Down Expand Up @@ -334,15 +344,14 @@ ui.Picture _createColoredBox(ui.Color color, ui.Size size) {
@pragma('vm:entry-point')
void renderImplicitView() {
ui.PlatformDispatcher.instance.onBeginFrame = (Duration duration) {
final ui.Size size = ui.Size(800.0, 600.0);
final ui.Color red = ui.Color.fromARGB(127, 255, 0, 0);
const ui.Size size = ui.Size(800.0, 600.0);
const ui.Color red = ui.Color.fromARGB(127, 255, 0, 0);

final ui.SceneBuilder builder = ui.SceneBuilder();

builder.pushOffset(0.0, 0.0);

builder.addPicture(
ui.Offset(0.0, 0.0), _createColoredBox(red, size));
builder.addPicture(ui.Offset.zero, _createColoredBox(red, size));

builder.pop();

Expand Down