Unverified Commit c78c9133 authored by Alexandre Ardhuin's avatar Alexandre Ardhuin Committed by GitHub

add missing trailing commas (#81042)

parent d332cbdf
...@@ -88,7 +88,8 @@ void main() { ...@@ -88,7 +88,8 @@ void main() {
)); ));
expect(client2.currentTextEditingValue, text2); expect(client2.currentTextEditingValue, text2);
}); },
);
}); });
} }
...@@ -212,7 +213,8 @@ class FakeTextChannel implements MethodChannel { ...@@ -212,7 +213,8 @@ class FakeTextChannel implements MethodChannel {
print( print(
'Index $i did not match:\n' 'Index $i did not match:\n'
' actual: ${outgoingCalls[i]}\n' ' actual: ${outgoingCalls[i]}\n'
' expected: ${calls[i]}'); ' expected: ${calls[i]}',
);
hasError = true; hasError = true;
} }
} }
......
...@@ -56,11 +56,15 @@ void main() { ...@@ -56,11 +56,15 @@ void main() {
final List<LicenseEntry> licenses = await LicenseRegistry.licenses.toList(); final List<LicenseEntry> licenses = await LicenseRegistry.licenses.toList();
expect(licenses[0].packages, equals(<String>['L1Package1', 'L1Package2', 'L1Package3'])); expect(licenses[0].packages, equals(<String>['L1Package1', 'L1Package2', 'L1Package3']));
expect(licenses[0].paragraphs.map((LicenseParagraph p) => p.text), expect(
equals(<String>['L1Paragraph1', 'L1Paragraph2', 'L1Paragraph3'])); licenses[0].paragraphs.map((LicenseParagraph p) => p.text),
equals(<String>['L1Paragraph1', 'L1Paragraph2', 'L1Paragraph3']),
);
expect(licenses[1].packages, equals(<String>['L2Package1', 'L2Package2', 'L2Package3'])); expect(licenses[1].packages, equals(<String>['L2Package1', 'L2Package2', 'L2Package3']));
expect(licenses[1].paragraphs.map((LicenseParagraph p) => p.text), expect(
equals(<String>['L2Paragraph1', 'L2Paragraph2', 'L2Paragraph3'])); licenses[1].paragraphs.map((LicenseParagraph p) => p.text),
equals(<String>['L2Paragraph1', 'L2Paragraph2', 'L2Paragraph3']),
);
}); });
} }
...@@ -22,12 +22,14 @@ void main() { ...@@ -22,12 +22,14 @@ void main() {
int count = 0; int count = 0;
const String channel = 'foo'; const String channel = 'foo';
ServicesBinding.instance!.defaultBinaryMessenger.handlePlatformMessage( ServicesBinding.instance!.defaultBinaryMessenger.handlePlatformMessage(
channel, _makeByteData('bar'), (ByteData? message) async { channel,
_makeByteData('bar'),
(ByteData? message) async {
count += 1; count += 1;
}); },
);
expect(count, equals(0)); expect(count, equals(0));
await ui.channelBuffers.drain(channel, await ui.channelBuffers.drain(channel, (ByteData? data, ui.PlatformMessageResponseCallback callback) async {
(ByteData? data, ui.PlatformMessageResponseCallback callback) async {
callback(null); callback(null);
}); });
expect(count, equals(1)); expect(count, equals(1));
......
...@@ -72,7 +72,8 @@ void main() { ...@@ -72,7 +72,8 @@ void main() {
LogicalKeyboardKey.control, LogicalKeyboardKey.control,
LogicalKeyboardKey.alt, LogicalKeyboardKey.alt,
LogicalKeyboardKey.meta, LogicalKeyboardKey.meta,
})); }),
);
expect( expect(
LogicalKeyboardKey.collapseSynonyms(<LogicalKeyboardKey>{ LogicalKeyboardKey.collapseSynonyms(<LogicalKeyboardKey>{
LogicalKeyboardKey.shiftRight, LogicalKeyboardKey.shiftRight,
...@@ -85,7 +86,8 @@ void main() { ...@@ -85,7 +86,8 @@ void main() {
LogicalKeyboardKey.control, LogicalKeyboardKey.control,
LogicalKeyboardKey.alt, LogicalKeyboardKey.alt,
LogicalKeyboardKey.meta, LogicalKeyboardKey.meta,
})); }),
);
expect( expect(
LogicalKeyboardKey.collapseSynonyms(<LogicalKeyboardKey>{ LogicalKeyboardKey.collapseSynonyms(<LogicalKeyboardKey>{
LogicalKeyboardKey.shiftLeft, LogicalKeyboardKey.shiftLeft,
...@@ -102,7 +104,8 @@ void main() { ...@@ -102,7 +104,8 @@ void main() {
LogicalKeyboardKey.control, LogicalKeyboardKey.control,
LogicalKeyboardKey.alt, LogicalKeyboardKey.alt,
LogicalKeyboardKey.meta, LogicalKeyboardKey.meta,
})); }),
);
}); });
test('Values are equal', () async { test('Values are equal', () async {
expect(LogicalKeyboardKey.keyA == LogicalKeyboardKey(LogicalKeyboardKey.keyA.keyId), true); expect(LogicalKeyboardKey.keyA == LogicalKeyboardKey(LogicalKeyboardKey.keyA.keyId), true);
......
...@@ -55,10 +55,13 @@ void main() { ...@@ -55,10 +55,13 @@ void main() {
); );
expect( expect(
() => method.decodeEnvelope(errorData), () => method.decodeEnvelope(errorData),
throwsA(predicate((PlatformException e) => throwsA(predicate(
(PlatformException e) =>
e.code == 'errorCode' && e.code == 'errorCode' &&
e.message == 'errorMessage' && e.message == 'errorMessage' &&
e.details == 'errorDetails'))); e.details == 'errorDetails',
)),
);
}); });
test('should decode error envelope with native stacktrace.', () { test('should decode error envelope with native stacktrace.', () {
final WriteBuffer buffer = WriteBuffer(); final WriteBuffer buffer = WriteBuffer();
...@@ -70,8 +73,8 @@ void main() { ...@@ -70,8 +73,8 @@ void main() {
final ByteData errorData = buffer.done(); final ByteData errorData = buffer.done();
expect( expect(
() => method.decodeEnvelope(errorData), () => method.decodeEnvelope(errorData),
throwsA(predicate((PlatformException e) => throwsA(predicate((PlatformException e) => e.stacktrace == 'errorStacktrace')),
e.stacktrace == 'errorStacktrace'))); );
}); });
test('should allow null error message,', () { test('should allow null error message,', () {
...@@ -104,23 +107,25 @@ void main() { ...@@ -104,23 +107,25 @@ void main() {
); );
expect( expect(
() => jsonMethodCodec.decodeEnvelope(errorData), () => jsonMethodCodec.decodeEnvelope(errorData),
throwsA(predicate((PlatformException e) => throwsA(predicate(
(PlatformException e) =>
e.code == 'errorCode' && e.code == 'errorCode' &&
e.message == 'errorMessage' && e.message == 'errorMessage' &&
e.details == 'errorDetails'))); e.details == 'errorDetails',
)),
);
}); });
test('should decode error envelope with native stacktrace.', () { test('should decode error envelope with native stacktrace.', () {
final ByteData? errorData = stringCodec.encodeMessage(json final ByteData? errorData = stringCodec.encodeMessage(json.encode(<dynamic>[
.encode(<dynamic>[
'errorCode', 'errorCode',
'errorMessage', 'errorMessage',
'errorDetails', 'errorDetails',
'errorStacktrace' 'errorStacktrace',
])); ]));
expect( expect(
() => jsonMethodCodec.decodeEnvelope(errorData!), () => jsonMethodCodec.decodeEnvelope(errorData!),
throwsA(predicate((PlatformException e) => throwsA(predicate((PlatformException e) => e.stacktrace == 'errorStacktrace')),
e.stacktrace == 'errorStacktrace'))); );
}); });
}); });
group('JSON message codec', () { group('JSON message codec', () {
......
...@@ -46,8 +46,7 @@ bool deepEquals(dynamic valueA, dynamic valueB) { ...@@ -46,8 +46,7 @@ bool deepEquals(dynamic valueA, dynamic valueB) {
bool deepEqualsTypedData(TypedData valueA, TypedData valueB) { bool deepEqualsTypedData(TypedData valueA, TypedData valueB) {
if (valueA is ByteData) { if (valueA is ByteData) {
return valueB is ByteData return valueB is ByteData
&& deepEqualsList( && deepEqualsList(valueA.buffer.asUint8List(), valueB.buffer.asUint8List());
valueA.buffer.asUint8List(), valueB.buffer.asUint8List());
} }
if (valueA is Uint8List) if (valueA is Uint8List)
return valueB is Uint8List && deepEqualsList(valueA, valueB); return valueB is Uint8List && deepEqualsList(valueA, valueB);
......
...@@ -74,8 +74,7 @@ void main() { ...@@ -74,8 +74,7 @@ void main() {
test('should encode and decode a list containing big numbers', () { test('should encode and decode a list containing big numbers', () {
final List<dynamic> message = <dynamic>[ final List<dynamic> message = <dynamic>[
-7000000000000000007, -7000000000000000007,
Int64List.fromList( Int64List.fromList(<int>[-0x7fffffffffffffff - 1, 0, 0x7fffffffffffffff]),
<int>[-0x7fffffffffffffff - 1, 0, 0x7fffffffffffffff]),
]; ];
checkEncodeDecode<dynamic>(standard, message); checkEncodeDecode<dynamic>(standard, message);
}); });
......
...@@ -54,7 +54,8 @@ void main() { ...@@ -54,7 +54,8 @@ void main() {
const FakeAndroidPlatformView(0, 'webview', Size(100.0, 100.0), AndroidViewController.kAndroidLayoutDirectionLtr, null), const FakeAndroidPlatformView(0, 'webview', Size(100.0, 100.0), AndroidViewController.kAndroidLayoutDirectionLtr, null),
const FakeAndroidPlatformView(1, 'webview', Size(200.0, 300.0), AndroidViewController.kAndroidLayoutDirectionRtl, null), const FakeAndroidPlatformView(1, 'webview', Size(200.0, 300.0), AndroidViewController.kAndroidLayoutDirectionRtl, null),
const FakeAndroidPlatformView(2, 'webview', null, AndroidViewController.kAndroidLayoutDirectionRtl, true), const FakeAndroidPlatformView(2, 'webview', null, AndroidViewController.kAndroidLayoutDirectionRtl, true),
])); ]),
);
}); });
test('reuse Android view id', () async { test('reuse Android view id', () async {
...@@ -66,8 +67,12 @@ void main() { ...@@ -66,8 +67,12 @@ void main() {
).setSize(const Size(100.0, 100.0)); ).setSize(const Size(100.0, 100.0));
expect( expect(
() => PlatformViewsService.initAndroidView( () => PlatformViewsService.initAndroidView(
id: 0, viewType: 'web', layoutDirection: TextDirection.ltr).setSize(const Size(100.0, 100.0)), id: 0,
throwsA(isA<PlatformException>())); viewType: 'web',
layoutDirection: TextDirection.ltr,
).setSize(const Size(100.0, 100.0)),
throwsA(isA<PlatformException>()),
);
await PlatformViewsService.initSurfaceAndroidView( await PlatformViewsService.initSurfaceAndroidView(
id: 1, id: 1,
...@@ -76,14 +81,21 @@ void main() { ...@@ -76,14 +81,21 @@ void main() {
).create(); ).create();
expect( expect(
() => PlatformViewsService.initSurfaceAndroidView( () => PlatformViewsService.initSurfaceAndroidView(
id: 1, viewType: 'web', layoutDirection: TextDirection.ltr).create(), id: 1,
throwsA(isA<PlatformException>())); viewType: 'web',
layoutDirection: TextDirection.ltr,
).create(),
throwsA(isA<PlatformException>()),
);
}); });
test('dispose Android view', () async { test('dispose Android view', () async {
viewsController.registerViewType('webview'); viewsController.registerViewType('webview');
await PlatformViewsService.initAndroidView( await PlatformViewsService.initAndroidView(
id: 0, viewType: 'webview', layoutDirection: TextDirection.ltr).setSize(const Size(100.0, 100.0)); id: 0,
viewType: 'webview',
layoutDirection: TextDirection.ltr,
).setSize(const Size(100.0, 100.0));
final AndroidViewController viewController = final AndroidViewController viewController =
PlatformViewsService.initAndroidView(id: 1, viewType: 'webview', layoutDirection: TextDirection.ltr); PlatformViewsService.initAndroidView(id: 1, viewType: 'webview', layoutDirection: TextDirection.ltr);
await viewController.setSize(const Size(200.0, 300.0)); await viewController.setSize(const Size(200.0, 300.0));
...@@ -97,13 +109,17 @@ void main() { ...@@ -97,13 +109,17 @@ void main() {
viewsController.views, viewsController.views,
unorderedEquals(<FakeAndroidPlatformView>[ unorderedEquals(<FakeAndroidPlatformView>[
const FakeAndroidPlatformView(0, 'webview', Size(100.0, 100.0), AndroidViewController.kAndroidLayoutDirectionLtr, null), const FakeAndroidPlatformView(0, 'webview', Size(100.0, 100.0), AndroidViewController.kAndroidLayoutDirectionLtr, null),
])); ]),
);
}); });
test('dispose inexisting Android view', () async { test('dispose inexisting Android view', () async {
viewsController.registerViewType('webview'); viewsController.registerViewType('webview');
await PlatformViewsService.initAndroidView( await PlatformViewsService.initAndroidView(
id: 0, viewType: 'webview', layoutDirection: TextDirection.ltr).setSize(const Size(100.0, 100.0)); id: 0,
viewType: 'webview',
layoutDirection: TextDirection.ltr,
).setSize(const Size(100.0, 100.0));
final AndroidViewController viewController = final AndroidViewController viewController =
PlatformViewsService.initAndroidView(id: 1, viewType: 'webview', layoutDirection: TextDirection.ltr); PlatformViewsService.initAndroidView(id: 1, viewType: 'webview', layoutDirection: TextDirection.ltr);
await viewController.setSize(const Size(200.0, 300.0)); await viewController.setSize(const Size(200.0, 300.0));
...@@ -118,7 +134,7 @@ void main() { ...@@ -118,7 +134,7 @@ void main() {
id: 0, id: 0,
viewType: 'webview', viewType: 'webview',
layoutDirection: TextDirection.ltr, layoutDirection: TextDirection.ltr,
onFocus: () { didFocus = true; } onFocus: () { didFocus = true; },
); );
await viewController.setSize(const Size(100.0, 100.0)); await viewController.setSize(const Size(100.0, 100.0));
await viewController.dispose(); await viewController.dispose();
...@@ -131,7 +147,10 @@ void main() { ...@@ -131,7 +147,10 @@ void main() {
test('resize Android view', () async { test('resize Android view', () async {
viewsController.registerViewType('webview'); viewsController.registerViewType('webview');
await PlatformViewsService.initAndroidView( await PlatformViewsService.initAndroidView(
id: 0, viewType: 'webview', layoutDirection: TextDirection.ltr).setSize(const Size(100.0, 100.0)); id: 0,
viewType: 'webview',
layoutDirection: TextDirection.ltr,
).setSize(const Size(100.0, 100.0));
final AndroidViewController viewController = final AndroidViewController viewController =
PlatformViewsService.initAndroidView(id: 1, viewType: 'webview', layoutDirection: TextDirection.ltr); PlatformViewsService.initAndroidView(id: 1, viewType: 'webview', layoutDirection: TextDirection.ltr);
await viewController.setSize(const Size(200.0, 300.0)); await viewController.setSize(const Size(200.0, 300.0));
...@@ -141,7 +160,8 @@ void main() { ...@@ -141,7 +160,8 @@ void main() {
unorderedEquals(<FakeAndroidPlatformView>[ unorderedEquals(<FakeAndroidPlatformView>[
const FakeAndroidPlatformView(0, 'webview', Size(100.0, 100.0), AndroidViewController.kAndroidLayoutDirectionLtr, null), const FakeAndroidPlatformView(0, 'webview', Size(100.0, 100.0), AndroidViewController.kAndroidLayoutDirectionLtr, null),
const FakeAndroidPlatformView(1, 'webview', Size(500.0, 500.0), AndroidViewController.kAndroidLayoutDirectionLtr, null), const FakeAndroidPlatformView(1, 'webview', Size(500.0, 500.0), AndroidViewController.kAndroidLayoutDirectionLtr, null),
])); ]),
);
}); });
test('OnPlatformViewCreated callback', () async { test('OnPlatformViewCreated callback', () async {
...@@ -181,7 +201,8 @@ void main() { ...@@ -181,7 +201,8 @@ void main() {
viewsController.views, viewsController.views,
unorderedEquals(<FakeAndroidPlatformView>[ unorderedEquals(<FakeAndroidPlatformView>[
const FakeAndroidPlatformView(0, 'webview', Size(100.0, 100.0), AndroidViewController.kAndroidLayoutDirectionLtr, null), const FakeAndroidPlatformView(0, 'webview', Size(100.0, 100.0), AndroidViewController.kAndroidLayoutDirectionLtr, null),
])); ]),
);
}); });
test("change Android view's directionality after creation", () async { test("change Android view's directionality after creation", () async {
...@@ -194,7 +215,8 @@ void main() { ...@@ -194,7 +215,8 @@ void main() {
viewsController.views, viewsController.views,
unorderedEquals(<FakeAndroidPlatformView>[ unorderedEquals(<FakeAndroidPlatformView>[
const FakeAndroidPlatformView(0, 'webview', Size(100.0, 100.0), AndroidViewController.kAndroidLayoutDirectionRtl, null), const FakeAndroidPlatformView(0, 'webview', Size(100.0, 100.0), AndroidViewController.kAndroidLayoutDirectionRtl, null),
])); ]),
);
}); });
}); });
...@@ -219,10 +241,8 @@ void main() { ...@@ -219,10 +241,8 @@ void main() {
test('create iOS views', () async { test('create iOS views', () async {
viewsController.registerViewType('webview'); viewsController.registerViewType('webview');
await PlatformViewsService.initUiKitView( await PlatformViewsService.initUiKitView(id: 0, viewType: 'webview', layoutDirection: TextDirection.ltr);
id: 0, viewType: 'webview', layoutDirection: TextDirection.ltr); await PlatformViewsService.initUiKitView(id: 1, viewType: 'webview', layoutDirection: TextDirection.rtl);
await PlatformViewsService.initUiKitView(
id: 1, viewType: 'webview', layoutDirection: TextDirection.rtl);
expect( expect(
viewsController.views, viewsController.views,
unorderedEquals(<FakeUiKitView>[ unorderedEquals(<FakeUiKitView>[
...@@ -240,32 +260,37 @@ void main() { ...@@ -240,32 +260,37 @@ void main() {
layoutDirection: TextDirection.ltr, layoutDirection: TextDirection.ltr,
); );
expect( expect(
() => PlatformViewsService.initUiKitView( () => PlatformViewsService.initUiKitView(id: 0, viewType: 'web', layoutDirection: TextDirection.ltr),
id: 0, viewType: 'web', layoutDirection: TextDirection.ltr),
throwsA(isA<PlatformException>()), throwsA(isA<PlatformException>()),
); );
}); });
test('dispose iOS view', () async { test('dispose iOS view', () async {
viewsController.registerViewType('webview'); viewsController.registerViewType('webview');
await PlatformViewsService.initUiKitView( await PlatformViewsService.initUiKitView(id: 0, viewType: 'webview', layoutDirection: TextDirection.ltr);
id: 0, viewType: 'webview', layoutDirection: TextDirection.ltr);
final UiKitViewController viewController = await PlatformViewsService.initUiKitView( final UiKitViewController viewController = await PlatformViewsService.initUiKitView(
id: 1, viewType: 'webview', layoutDirection: TextDirection.ltr); id: 1,
viewType: 'webview',
layoutDirection: TextDirection.ltr,
);
viewController.dispose(); viewController.dispose();
expect( expect(
viewsController.views, viewsController.views,
unorderedEquals(<FakeUiKitView>[ unorderedEquals(<FakeUiKitView>[
const FakeUiKitView(0, 'webview'), const FakeUiKitView(0, 'webview'),
])); ]),
);
}); });
test('dispose inexisting iOS view', () async { test('dispose inexisting iOS view', () async {
viewsController.registerViewType('webview'); viewsController.registerViewType('webview');
await PlatformViewsService.initUiKitView(id: 0, viewType: 'webview', layoutDirection: TextDirection.ltr); await PlatformViewsService.initUiKitView(id: 0, viewType: 'webview', layoutDirection: TextDirection.ltr);
final UiKitViewController viewController = await PlatformViewsService.initUiKitView( final UiKitViewController viewController = await PlatformViewsService.initUiKitView(
id: 1, viewType: 'webview', layoutDirection: TextDirection.ltr); id: 1,
viewType: 'webview',
layoutDirection: TextDirection.ltr,
);
await viewController.dispose(); await viewController.dispose();
expect( expect(
() async { () async {
......
...@@ -119,7 +119,8 @@ void main() { ...@@ -119,7 +119,8 @@ void main() {
if (platform != 'macos') LogicalKeyboardKey.fn, if (platform != 'macos') LogicalKeyboardKey.fn,
}, },
), ),
reason: 'on $platform'); reason: 'on $platform',
);
await simulateKeyDownEvent(LogicalKeyboardKey.f12, platform: platform); await simulateKeyDownEvent(LogicalKeyboardKey.f12, platform: platform);
expect( expect(
RawKeyboard.instance.keysPressed, RawKeyboard.instance.keysPressed,
...@@ -1539,7 +1540,7 @@ void main() { ...@@ -1539,7 +1540,7 @@ void main() {
(ByteData? data) { (ByteData? data) {
final Map<String, dynamic> decoded = SystemChannels.keyEvent.codec.decodeMessage(data) as Map<String, dynamic>; final Map<String, dynamic> decoded = SystemChannels.keyEvent.codec.decodeMessage(data) as Map<String, dynamic>;
lastHandled = decoded['handled'] as bool; lastHandled = decoded['handled'] as bool;
} },
); );
} }
RawKeyboard.instance.addListener(events.add); RawKeyboard.instance.addListener(events.add);
......
...@@ -191,7 +191,7 @@ void main() { ...@@ -191,7 +191,7 @@ void main() {
'The following IDs were claimed multiple times from the parent RestorationBucket(restorationId: root, owner: MockManager):\n' 'The following IDs were claimed multiple times from the parent RestorationBucket(restorationId: root, owner: MockManager):\n'
' * "child1" was claimed by:\n' ' * "child1" was claimed by:\n'
' * SecondClaim\n' ' * SecondClaim\n'
' * FirstClaim (current owner)' ' * FirstClaim (current owner)',
); );
} }
}); });
......
...@@ -322,7 +322,7 @@ Map<dynamic, dynamic> _createEncodedRestorationData1() { ...@@ -322,7 +322,7 @@ Map<dynamic, dynamic> _createEncodedRestorationData1() {
'child1' : <String, dynamic>{ 'child1' : <String, dynamic>{
valuesMapKey : <String, dynamic>{ valuesMapKey : <String, dynamic>{
'another value': 22, 'another value': 22,
} },
}, },
}, },
}; };
...@@ -338,7 +338,7 @@ Map<dynamic, dynamic> _createEncodedRestorationData2() { ...@@ -338,7 +338,7 @@ Map<dynamic, dynamic> _createEncodedRestorationData2() {
'childFoo' : <String, dynamic>{ 'childFoo' : <String, dynamic>{
valuesMapKey : <String, dynamic>{ valuesMapKey : <String, dynamic>{
'bar': 'Hello', 'bar': 'Hello',
} },
}, },
}, },
}; };
......
...@@ -47,7 +47,7 @@ void main() { ...@@ -47,7 +47,7 @@ void main() {
}); });
await SystemChrome.setApplicationSwitcherDescription( await SystemChrome.setApplicationSwitcherDescription(
const ApplicationSwitcherDescription(label: 'Example label', primaryColor: 0xFF00FF00) const ApplicationSwitcherDescription(label: 'Example label', primaryColor: 0xFF00FF00),
); );
expect(log, hasLength(1)); expect(log, hasLength(1));
...@@ -65,7 +65,7 @@ void main() { ...@@ -65,7 +65,7 @@ void main() {
}); });
await SystemChrome.setApplicationSwitcherDescription( await SystemChrome.setApplicationSwitcherDescription(
const ApplicationSwitcherDescription(label: 'Example label', primaryColor: 0xFF00FF00) const ApplicationSwitcherDescription(label: 'Example label', primaryColor: 0xFF00FF00),
); );
expect(log, isNotEmpty); expect(log, isNotEmpty);
......
...@@ -22,7 +22,7 @@ void main() { ...@@ -22,7 +22,7 @@ void main() {
calledOldValue = oldValue; calledOldValue = oldValue;
calledNewValue = newValue; calledNewValue = newValue;
return TextEditingValue.empty; return TextEditingValue.empty;
} },
); );
formatterUnderTest.formatEditUpdate(testOldValue, testNewValue); formatterUnderTest.formatEditUpdate(testOldValue, testNewValue);
...@@ -416,7 +416,7 @@ void main() { ...@@ -416,7 +416,7 @@ void main() {
LengthLimitingTextInputFormatter(maxLength); LengthLimitingTextInputFormatter(maxLength);
final TextEditingValue formatted = formatter.formatEditUpdate( final TextEditingValue formatted = formatter.formatEditUpdate(
oldValue, oldValue,
newValue newValue,
); );
expect(formatted.text, newValue.text); expect(formatted.text, newValue.text);
}); });
...@@ -436,7 +436,7 @@ void main() { ...@@ -436,7 +436,7 @@ void main() {
LengthLimitingTextInputFormatter(maxLength); LengthLimitingTextInputFormatter(maxLength);
final TextEditingValue formatted = formatter.formatEditUpdate( final TextEditingValue formatted = formatter.formatEditUpdate(
oldValue, oldValue,
newValue newValue,
); );
expect(formatted.text, oldValue.text); expect(formatted.text, oldValue.text);
}); });
...@@ -456,7 +456,7 @@ void main() { ...@@ -456,7 +456,7 @@ void main() {
LengthLimitingTextInputFormatter(maxLength); LengthLimitingTextInputFormatter(maxLength);
final TextEditingValue formatted = formatter.formatEditUpdate( final TextEditingValue formatted = formatter.formatEditUpdate(
oldValue, oldValue,
newValue newValue,
); );
expect(formatted.text, 'bbbbbbbbbb'); expect(formatted.text, 'bbbbbbbbbb');
}); });
...@@ -575,8 +575,7 @@ void main() { ...@@ -575,8 +575,7 @@ void main() {
final TextInputFormatter formatter = final TextInputFormatter formatter =
FilteringTextInputFormatter.digitsOnly; FilteringTextInputFormatter.digitsOnly;
TextEditingValue formatted = formatter.formatEditUpdate(oldValue, TextEditingValue formatted = formatter.formatEditUpdate(oldValue, newValue);
newValue);
// assert that we are passing digits only at the first time // assert that we are passing digits only at the first time
expect(oldValue.text, equals('123')); expect(oldValue.text, equals('123'));
...@@ -586,8 +585,7 @@ void main() { ...@@ -586,8 +585,7 @@ void main() {
expect(formatted.selection.baseOffset, equals(6)); expect(formatted.selection.baseOffset, equals(6));
// move cursor at the middle of the text and then add the number 9. // move cursor at the middle of the text and then add the number 9.
oldValue = newValue.copyWith( oldValue = newValue.copyWith(selection: const TextSelection.collapsed(offset: 4));
selection: const TextSelection.collapsed(offset: 4));
newValue = oldValue.copyWith(text: '1239456'); newValue = oldValue.copyWith(text: '1239456');
formatted = formatter.formatEditUpdate(oldValue, newValue); formatted = formatter.formatEditUpdate(oldValue, newValue);
...@@ -608,8 +606,7 @@ void main() { ...@@ -608,8 +606,7 @@ void main() {
final TextInputFormatter formatter = final TextInputFormatter formatter =
FilteringTextInputFormatter.digitsOnly; FilteringTextInputFormatter.digitsOnly;
TextEditingValue formatted = formatter.formatEditUpdate(oldValue, TextEditingValue formatted = formatter.formatEditUpdate(oldValue, newValue);
newValue);
// assert that we are passing digits only at the first time // assert that we are passing digits only at the first time
expect(oldValue.text, equals('123')); expect(oldValue.text, equals('123'));
...@@ -619,8 +616,7 @@ void main() { ...@@ -619,8 +616,7 @@ void main() {
expect(formatted.selection.baseOffset, equals(6)); expect(formatted.selection.baseOffset, equals(6));
// move cursor at the middle of the text and then add the number 9. // move cursor at the middle of the text and then add the number 9.
oldValue = newValue.copyWith( oldValue = newValue.copyWith(selection: const TextSelection.collapsed(offset: 4));
selection: const TextSelection.collapsed(offset: 4));
newValue = oldValue.copyWith(text: '1239456'); newValue = oldValue.copyWith(text: '1239456');
formatted = formatter.formatEditUpdate(oldValue, newValue); formatted = formatter.formatEditUpdate(oldValue, newValue);
......
...@@ -70,7 +70,8 @@ void main() { ...@@ -70,7 +70,8 @@ void main() {
'selectionIsDirectional': false, 'selectionIsDirectional': false,
'composingBase': -1, 'composingBase': -1,
'composingExtent': -1, 'composingExtent': -1,
}), },
),
]); ]);
}); });
}); });
...@@ -197,8 +198,7 @@ void main() { ...@@ -197,8 +198,7 @@ void main() {
final ByteData? messageBytes = const JSONMessageCodec().encodeMessage(<String, dynamic>{ final ByteData? messageBytes = const JSONMessageCodec().encodeMessage(<String, dynamic>{
'args': <dynamic>[ 'args': <dynamic>[
1, 1,
jsonDecode( jsonDecode('{"action": "actionCommand", "data": {"input_context" : "abcdefg"}}'),
'{"action": "actionCommand", "data": {"input_context" : "abcdefg"}}')
], ],
'method': 'TextInputClient.performPrivateCommand', 'method': 'TextInputClient.performPrivateCommand',
}); });
...@@ -211,8 +211,7 @@ void main() { ...@@ -211,8 +211,7 @@ void main() {
expect(client.latestMethodCall, 'performPrivateCommand'); expect(client.latestMethodCall, 'performPrivateCommand');
}); });
test('TextInputClient performPrivateCommand method is called with float', test('TextInputClient performPrivateCommand method is called with float', () async {
() async {
// Assemble a TextInputConnection so we can verify its change in state. // Assemble a TextInputConnection so we can verify its change in state.
final FakeTextInputClient client = FakeTextInputClient(TextEditingValue.empty); final FakeTextInputClient client = FakeTextInputClient(TextEditingValue.empty);
const TextInputConfiguration configuration = TextInputConfiguration(); const TextInputConfiguration configuration = TextInputConfiguration();
...@@ -224,8 +223,7 @@ void main() { ...@@ -224,8 +223,7 @@ void main() {
final ByteData? messageBytes = const JSONMessageCodec().encodeMessage(<String, dynamic>{ final ByteData? messageBytes = const JSONMessageCodec().encodeMessage(<String, dynamic>{
'args': <dynamic>[ 'args': <dynamic>[
1, 1,
jsonDecode( jsonDecode('{"action": "actionCommand", "data": {"input_context" : 0.5}}'),
'{"action": "actionCommand", "data": {"input_context" : 0.5}}')
], ],
'method': 'TextInputClient.performPrivateCommand', 'method': 'TextInputClient.performPrivateCommand',
}); });
...@@ -238,9 +236,7 @@ void main() { ...@@ -238,9 +236,7 @@ void main() {
expect(client.latestMethodCall, 'performPrivateCommand'); expect(client.latestMethodCall, 'performPrivateCommand');
}); });
test( test('TextInputClient performPrivateCommand method is called with CharSequence array', () async {
'TextInputClient performPrivateCommand method is called with CharSequence array',
() async {
// Assemble a TextInputConnection so we can verify its change in state. // Assemble a TextInputConnection so we can verify its change in state.
final FakeTextInputClient client = FakeTextInputClient(TextEditingValue.empty); final FakeTextInputClient client = FakeTextInputClient(TextEditingValue.empty);
const TextInputConfiguration configuration = TextInputConfiguration(); const TextInputConfiguration configuration = TextInputConfiguration();
...@@ -252,8 +248,7 @@ void main() { ...@@ -252,8 +248,7 @@ void main() {
final ByteData? messageBytes = const JSONMessageCodec().encodeMessage(<String, dynamic>{ final ByteData? messageBytes = const JSONMessageCodec().encodeMessage(<String, dynamic>{
'args': <dynamic>[ 'args': <dynamic>[
1, 1,
jsonDecode( jsonDecode('{"action": "actionCommand", "data": {"input_context" : ["abc", "efg"]}}'),
'{"action": "actionCommand", "data": {"input_context" : ["abc", "efg"]}}')
], ],
'method': 'TextInputClient.performPrivateCommand', 'method': 'TextInputClient.performPrivateCommand',
}); });
...@@ -266,9 +261,7 @@ void main() { ...@@ -266,9 +261,7 @@ void main() {
expect(client.latestMethodCall, 'performPrivateCommand'); expect(client.latestMethodCall, 'performPrivateCommand');
}); });
test( test('TextInputClient performPrivateCommand method is called with CharSequence', () async {
'TextInputClient performPrivateCommand method is called with CharSequence',
() async {
// Assemble a TextInputConnection so we can verify its change in state. // Assemble a TextInputConnection so we can verify its change in state.
final FakeTextInputClient client = FakeTextInputClient(TextEditingValue.empty); final FakeTextInputClient client = FakeTextInputClient(TextEditingValue.empty);
const TextInputConfiguration configuration = TextInputConfiguration(); const TextInputConfiguration configuration = TextInputConfiguration();
...@@ -281,8 +274,7 @@ void main() { ...@@ -281,8 +274,7 @@ void main() {
const JSONMessageCodec().encodeMessage(<String, dynamic>{ const JSONMessageCodec().encodeMessage(<String, dynamic>{
'args': <dynamic>[ 'args': <dynamic>[
1, 1,
jsonDecode( jsonDecode('{"action": "actionCommand", "data": {"input_context" : "abc"}}'),
'{"action": "actionCommand", "data": {"input_context" : "abc"}}')
], ],
'method': 'TextInputClient.performPrivateCommand', 'method': 'TextInputClient.performPrivateCommand',
}); });
...@@ -295,9 +287,7 @@ void main() { ...@@ -295,9 +287,7 @@ void main() {
expect(client.latestMethodCall, 'performPrivateCommand'); expect(client.latestMethodCall, 'performPrivateCommand');
}); });
test( test('TextInputClient performPrivateCommand method is called with float array', () async {
'TextInputClient performPrivateCommand method is called with float array',
() async {
// Assemble a TextInputConnection so we can verify its change in state. // Assemble a TextInputConnection so we can verify its change in state.
final FakeTextInputClient client = FakeTextInputClient(TextEditingValue.empty); final FakeTextInputClient client = FakeTextInputClient(TextEditingValue.empty);
const TextInputConfiguration configuration = TextInputConfiguration(); const TextInputConfiguration configuration = TextInputConfiguration();
...@@ -310,8 +300,7 @@ void main() { ...@@ -310,8 +300,7 @@ void main() {
const JSONMessageCodec().encodeMessage(<String, dynamic>{ const JSONMessageCodec().encodeMessage(<String, dynamic>{
'args': <dynamic>[ 'args': <dynamic>[
1, 1,
jsonDecode( jsonDecode('{"action": "actionCommand", "data": {"input_context" : [0.5, 0.8]}}'),
'{"action": "actionCommand", "data": {"input_context" : [0.5, 0.8]}}')
], ],
'method': 'TextInputClient.performPrivateCommand', 'method': 'TextInputClient.performPrivateCommand',
}); });
...@@ -324,8 +313,7 @@ void main() { ...@@ -324,8 +313,7 @@ void main() {
expect(client.latestMethodCall, 'performPrivateCommand'); expect(client.latestMethodCall, 'performPrivateCommand');
}); });
test('TextInputClient showAutocorrectionPromptRect method is called', test('TextInputClient showAutocorrectionPromptRect method is called', () async {
() async {
// Assemble a TextInputConnection so we can verify its change in state. // Assemble a TextInputConnection so we can verify its change in state.
final FakeTextInputClient client = FakeTextInputClient(TextEditingValue.empty); final FakeTextInputClient client = FakeTextInputClient(TextEditingValue.empty);
const TextInputConfiguration configuration = TextInputConfiguration(); const TextInputConfiguration configuration = TextInputConfiguration();
...@@ -477,7 +465,8 @@ class FakeTextChannel implements MethodChannel { ...@@ -477,7 +465,8 @@ class FakeTextChannel implements MethodChannel {
print( print(
'Index $i did not match:\n' 'Index $i did not match:\n'
' actual: $outgoingString\n' ' actual: $outgoingString\n'
' expected: $expectedString'); ' expected: $expectedString',
);
hasError = true; hasError = true;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment