Auto-format Framework (#160545)
This auto-formats all *.dart files in the repository outside of the `engine` subdirectory and enforces that these files stay formatted with a presubmit check. **Reviewers:** Please carefully review all the commits except for the one titled "formatted". The "formatted" commit was auto-generated by running `dev/tools/format.sh -a -f`. The other commits were hand-crafted to prepare the repo for the formatting change. I recommend reviewing the commits one-by-one via the "Commits" tab and avoiding Github's "Files changed" tab as it will likely slow down your browser because of the size of this PR. --------- Co-authored-by: Kate Lovett <katelovett@google.com> Co-authored-by: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
8e0993eda8
commit
5491c8c146
@@ -44,17 +44,8 @@ class _TestAppState extends State<TestApp> {
|
||||
<String, dynamic>{'key': 42},
|
||||
],
|
||||
};
|
||||
static final Uint8List someUint8s = Uint8List.fromList(<int>[
|
||||
0xBA,
|
||||
0x5E,
|
||||
0xBA,
|
||||
0x11,
|
||||
]);
|
||||
static final Int32List someInt32s = Int32List.fromList(<int>[
|
||||
-0x7fffffff - 1,
|
||||
0,
|
||||
0x7fffffff,
|
||||
]);
|
||||
static final Uint8List someUint8s = Uint8List.fromList(<int>[0xBA, 0x5E, 0xBA, 0x11]);
|
||||
static final Int32List someInt32s = Int32List.fromList(<int>[-0x7fffffff - 1, 0, 0x7fffffff]);
|
||||
static final Int64List someInt64s = Int64List.fromList(<int>[
|
||||
-0x7fffffffffffffff - 1,
|
||||
0,
|
||||
@@ -71,8 +62,7 @@ class _TestAppState extends State<TestApp> {
|
||||
double.maxFinite,
|
||||
double.infinity,
|
||||
]);
|
||||
static final Float64List someFloat64s =
|
||||
Float64List.fromList(<double>[
|
||||
static final Float64List someFloat64s = Float64List.fromList(<double>[
|
||||
double.nan,
|
||||
double.negativeInfinity,
|
||||
-double.maxFinite,
|
||||
@@ -187,10 +177,7 @@ class _TestAppState extends State<TestApp> {
|
||||
});
|
||||
}
|
||||
|
||||
Widget _buildTestResultWidget(
|
||||
BuildContext context,
|
||||
AsyncSnapshot<TestStepResult> snapshot,
|
||||
) {
|
||||
Widget _buildTestResultWidget(BuildContext context, AsyncSnapshot<TestStepResult> snapshot) {
|
||||
return TestStepResult.fromSnapshot(snapshot).asWidget(context);
|
||||
}
|
||||
|
||||
@@ -199,15 +186,10 @@ class _TestAppState extends State<TestApp> {
|
||||
return MaterialApp(
|
||||
title: 'Channels Test',
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Channels Test'),
|
||||
),
|
||||
appBar: AppBar(title: const Text('Channels Test')),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: FutureBuilder<TestStepResult>(
|
||||
future: _result,
|
||||
builder: _buildTestResultWidget,
|
||||
),
|
||||
child: FutureBuilder<TestStepResult>(future: _result, builder: _buildTestResultWidget),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
key: const ValueKey<String>('step'),
|
||||
|
||||
@@ -41,13 +41,11 @@ class ExtendedStandardMessageCodec extends StandardMessageCodec {
|
||||
}
|
||||
|
||||
Future<TestStepResult> basicBinaryHandshake(ByteData? message) async {
|
||||
const BasicMessageChannel<ByteData?> channel =
|
||||
BasicMessageChannel<ByteData?>(
|
||||
const BasicMessageChannel<ByteData?> channel = BasicMessageChannel<ByteData?>(
|
||||
'binary-msg',
|
||||
BinaryCodec(),
|
||||
);
|
||||
return _basicMessageHandshake<ByteData?>(
|
||||
'Binary >${toString(message)}<', channel, message);
|
||||
return _basicMessageHandshake<ByteData?>('Binary >${toString(message)}<', channel, message);
|
||||
}
|
||||
|
||||
Future<TestStepResult> basicStringHandshake(String? message) async {
|
||||
@@ -59,8 +57,7 @@ Future<TestStepResult> basicStringHandshake(String? message) async {
|
||||
}
|
||||
|
||||
Future<TestStepResult> basicJsonHandshake(dynamic message) async {
|
||||
const BasicMessageChannel<dynamic> channel =
|
||||
BasicMessageChannel<dynamic>(
|
||||
const BasicMessageChannel<dynamic> channel = BasicMessageChannel<dynamic>(
|
||||
'json-msg',
|
||||
JSONMessageCodec(),
|
||||
);
|
||||
@@ -68,37 +65,31 @@ Future<TestStepResult> basicJsonHandshake(dynamic message) async {
|
||||
}
|
||||
|
||||
Future<TestStepResult> basicStandardHandshake(dynamic message) async {
|
||||
const BasicMessageChannel<dynamic> channel =
|
||||
BasicMessageChannel<dynamic>(
|
||||
const BasicMessageChannel<dynamic> channel = BasicMessageChannel<dynamic>(
|
||||
'std-msg',
|
||||
ExtendedStandardMessageCodec(),
|
||||
);
|
||||
return _basicMessageHandshake<dynamic>(
|
||||
'Standard >${toString(message)}<', channel, message);
|
||||
return _basicMessageHandshake<dynamic>('Standard >${toString(message)}<', channel, message);
|
||||
}
|
||||
|
||||
Future<void> _basicBackgroundStandardEchoMain(List<Object> args) async {
|
||||
final SendPort sendPort = args[2] as SendPort;
|
||||
final Object message = args[1];
|
||||
final String name = 'Background Echo >${toString(message)}<';
|
||||
const String description =
|
||||
'Uses a platform channel from a background isolate.';
|
||||
const String description = 'Uses a platform channel from a background isolate.';
|
||||
try {
|
||||
BackgroundIsolateBinaryMessenger.ensureInitialized(
|
||||
args[0] as RootIsolateToken);
|
||||
BackgroundIsolateBinaryMessenger.ensureInitialized(args[0] as RootIsolateToken);
|
||||
const BasicMessageChannel<dynamic> channel = BasicMessageChannel<dynamic>(
|
||||
'std-echo',
|
||||
ExtendedStandardMessageCodec(),
|
||||
);
|
||||
final Object response = await channel.send(message) as Object;
|
||||
|
||||
final TestStatus testStatus = TestStepResult.deepEquals(message, response)
|
||||
? TestStatus.ok
|
||||
: TestStatus.failed;
|
||||
final TestStatus testStatus =
|
||||
TestStepResult.deepEquals(message, response) ? TestStatus.ok : TestStatus.failed;
|
||||
sendPort.send(TestStepResult(name, description, testStatus));
|
||||
} catch (ex) {
|
||||
sendPort.send(TestStepResult(name, description, TestStatus.failed,
|
||||
error: ex.toString()));
|
||||
sendPort.send(TestStepResult(name, description, TestStatus.failed, error: ex.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,8 +104,7 @@ Future<TestStepResult> basicBackgroundStandardEcho(Object message) async {
|
||||
}
|
||||
|
||||
Future<TestStepResult> basicBinaryMessageToUnknownChannel() async {
|
||||
const BasicMessageChannel<ByteData?> channel =
|
||||
BasicMessageChannel<ByteData?>(
|
||||
const BasicMessageChannel<ByteData?> channel = BasicMessageChannel<ByteData?>(
|
||||
'binary-unknown',
|
||||
BinaryCodec(),
|
||||
);
|
||||
@@ -130,8 +120,7 @@ Future<TestStepResult> basicStringMessageToUnknownChannel() async {
|
||||
}
|
||||
|
||||
Future<TestStepResult> basicJsonMessageToUnknownChannel() async {
|
||||
const BasicMessageChannel<dynamic> channel =
|
||||
BasicMessageChannel<dynamic>(
|
||||
const BasicMessageChannel<dynamic> channel = BasicMessageChannel<dynamic>(
|
||||
'json-unknown',
|
||||
JSONMessageCodec(),
|
||||
);
|
||||
@@ -139,8 +128,7 @@ Future<TestStepResult> basicJsonMessageToUnknownChannel() async {
|
||||
}
|
||||
|
||||
Future<TestStepResult> basicStandardMessageToUnknownChannel() async {
|
||||
const BasicMessageChannel<dynamic> channel =
|
||||
BasicMessageChannel<dynamic>(
|
||||
const BasicMessageChannel<dynamic> channel = BasicMessageChannel<dynamic>(
|
||||
'std-unknown',
|
||||
ExtendedStandardMessageCodec(),
|
||||
);
|
||||
@@ -204,9 +192,7 @@ Future<TestStepResult> _basicMessageToUnknownChannel<T>(
|
||||
|
||||
String toString(dynamic message) {
|
||||
if (message is ByteData) {
|
||||
return message.buffer
|
||||
.asUint8List(message.offsetInBytes, message.lengthInBytes)
|
||||
.toString();
|
||||
return message.buffer.asUint8List(message.offsetInBytes, message.lengthInBytes).toString();
|
||||
} else {
|
||||
return '$message';
|
||||
}
|
||||
|
||||
@@ -8,25 +8,21 @@ import 'basic_messaging.dart';
|
||||
import 'test_step.dart';
|
||||
|
||||
Future<TestStepResult> methodCallJsonSuccessHandshake(dynamic payload) async {
|
||||
const MethodChannel channel =
|
||||
MethodChannel('json-method', JSONMethodCodec());
|
||||
const MethodChannel channel = MethodChannel('json-method', JSONMethodCodec());
|
||||
return _methodCallSuccessHandshake('JSON success($payload)', channel, payload);
|
||||
}
|
||||
|
||||
Future<TestStepResult> methodCallJsonErrorHandshake(dynamic payload) async {
|
||||
const MethodChannel channel =
|
||||
MethodChannel('json-method', JSONMethodCodec());
|
||||
const MethodChannel channel = MethodChannel('json-method', JSONMethodCodec());
|
||||
return _methodCallErrorHandshake('JSON error($payload)', channel, payload);
|
||||
}
|
||||
|
||||
Future<TestStepResult> methodCallJsonNotImplementedHandshake() async {
|
||||
const MethodChannel channel =
|
||||
MethodChannel('json-method', JSONMethodCodec());
|
||||
const MethodChannel channel = MethodChannel('json-method', JSONMethodCodec());
|
||||
return _methodCallNotImplementedHandshake('JSON notImplemented()', channel);
|
||||
}
|
||||
|
||||
Future<TestStepResult> methodCallStandardSuccessHandshake(
|
||||
dynamic payload) async {
|
||||
Future<TestStepResult> methodCallStandardSuccessHandshake(dynamic payload) async {
|
||||
const MethodChannel channel = MethodChannel(
|
||||
'std-method',
|
||||
StandardMethodCodec(ExtendedStandardMessageCodec()),
|
||||
|
||||
@@ -38,10 +38,10 @@ class TestStepResult {
|
||||
|
||||
factory TestStepResult.fromSnapshot(AsyncSnapshot<TestStepResult> snapshot) {
|
||||
return switch (snapshot.connectionState) {
|
||||
ConnectionState.none => const TestStepResult('Not started', nothing, TestStatus.ok),
|
||||
ConnectionState.none => const TestStepResult('Not started', nothing, TestStatus.ok),
|
||||
ConnectionState.waiting => const TestStepResult('Executing', nothing, TestStatus.pending),
|
||||
ConnectionState.done => snapshot.data ?? snapshot.error! as TestStepResult,
|
||||
ConnectionState.active => throw 'Unsupported state: ConnectionState.active',
|
||||
ConnectionState.done => snapshot.data ?? snapshot.error! as TestStepResult,
|
||||
ConnectionState.active => throw 'Unsupported state: ConnectionState.active',
|
||||
};
|
||||
}
|
||||
|
||||
@@ -75,8 +75,7 @@ class TestStepResult {
|
||||
const Text(' '),
|
||||
Text(
|
||||
status.name,
|
||||
key: ValueKey<String>(
|
||||
status == TestStatus.pending ? 'nostatus' : 'status'),
|
||||
key: ValueKey<String>(status == TestStatus.pending ? 'nostatus' : 'status'),
|
||||
style: bold,
|
||||
),
|
||||
],
|
||||
@@ -128,9 +127,7 @@ Future<TestStepResult> resultOfHandshake(
|
||||
|
||||
String _toString(dynamic message) {
|
||||
if (message is ByteData) {
|
||||
return message.buffer
|
||||
.asUint8List(message.offsetInBytes, message.lengthInBytes)
|
||||
.toString();
|
||||
return message.buffer.asUint8List(message.offsetInBytes, message.lengthInBytes).toString();
|
||||
} else {
|
||||
return '$message';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user