Skip to content

Commit 806c1f8

Browse files
authored
Deprecate these old APIs (#116793)
Deprecate these old APIs
1 parent 54e6000 commit 806c1f8

File tree

16 files changed

+113
-81
lines changed

16 files changed

+113
-81
lines changed

dev/bots/analyze.dart

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,14 @@ Future<void> verifyDeprecations(String workingDirectory, { int minimumMatches =
534534
String possibleReason = '';
535535
if (lines[lineNumber].trimLeft().startsWith('"')) {
536536
possibleReason = ' You might have used double quotes (") for the string instead of single quotes (\').';
537+
} else if (!lines[lineNumber].contains("'")) {
538+
possibleReason = ' It might be missing the line saying "This feature was deprecated after...".';
539+
} else if (!lines[lineNumber].trimRight().endsWith(" '")) {
540+
if (lines[lineNumber].contains('This feature was deprecated')) {
541+
possibleReason = ' There might not be an explanatory message.';
542+
} else {
543+
possibleReason = ' There might be a missing space character at the end of the line.';
544+
}
537545
}
538546
throw 'Deprecation notice does not match required pattern.$possibleReason';
539547
}
@@ -546,6 +554,8 @@ Future<void> verifyDeprecations(String workingDirectory, { int minimumMatches =
546554
if (firstChar.toUpperCase() != firstChar) {
547555
throw 'Deprecation notice should be a grammatically correct sentence and start with a capital letter; see style guide: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo';
548556
}
557+
} else {
558+
message += messageMatch.namedGroup('message')!;
549559
}
550560
lineNumber += 1;
551561
if (lineNumber >= lines.length) {
@@ -565,7 +575,7 @@ Future<void> verifyDeprecations(String workingDirectory, { int minimumMatches =
565575
}
566576
}
567577
if (!message.endsWith('.') && !message.endsWith('!') && !message.endsWith('?')) {
568-
throw 'Deprecation notice should be a grammatically correct sentence and end with a period.';
578+
throw 'Deprecation notice should be a grammatically correct sentence and end with a period; notice appears to be "$message".';
569579
}
570580
if (!lines[lineNumber].startsWith("$indent '")) {
571581
throw 'Unexpected deprecation notice indent.';

dev/bots/post_process_docs.dart

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,18 @@ Future<void> runProcessWithValidations(
9494
List<String> command,
9595
String workingDirectory, {
9696
@visibleForTesting ProcessManager processManager = const LocalProcessManager(),
97+
bool verbose = true,
9798
}) async {
9899
final ProcessResult result =
99100
processManager.runSync(command, stdoutEncoding: utf8, workingDirectory: workingDirectory);
100101
if (result.exitCode == 0) {
101-
print('Stdout: ${result.stdout}');
102+
if (verbose) {
103+
print('stdout: ${result.stdout}');
104+
}
102105
} else {
103-
print('StdErr: ${result.stderr}');
106+
if (verbose) {
107+
print('stderr: ${result.stderr}');
108+
}
104109
throw CommandException();
105110
}
106111
}

dev/bots/test/analyze-test-input/root/packages/foo/deprecation.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,8 @@ void test17() { }
100100
'This feature was deprecated after v2.1.0-11.0.pre.'
101101
)
102102
void test18() { }
103+
104+
@Deprecated( // flutter_ignore: deprecation_syntax, https://github.com/flutter/flutter/issues/000000
105+
'Missing the version line. '
106+
)
107+
void test19() { }

dev/bots/test/analyze_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ void main() {
4545
test('analyze.dart - verifyDeprecations', () async {
4646
final String result = await capture(() => verifyDeprecations(testRootPath, minimumMatches: 2), shouldHaveErrors: true);
4747
final String lines = <String>[
48-
'║ test/analyze-test-input/root/packages/foo/deprecation.dart:12: Deprecation notice does not match required pattern.',
48+
'║ test/analyze-test-input/root/packages/foo/deprecation.dart:12: Deprecation notice does not match required pattern. There might be a missing space character at the end of the line.',
4949
'║ test/analyze-test-input/root/packages/foo/deprecation.dart:18: Deprecation notice should be a grammatically correct sentence and start with a capital letter; see style guide: STYLE_GUIDE_URL',
50-
'║ test/analyze-test-input/root/packages/foo/deprecation.dart:25: Deprecation notice should be a grammatically correct sentence and end with a period.',
50+
'║ test/analyze-test-input/root/packages/foo/deprecation.dart:25: Deprecation notice should be a grammatically correct sentence and end with a period; notice appears to be "Also bad grammar".',
5151
'║ test/analyze-test-input/root/packages/foo/deprecation.dart:29: Deprecation notice does not match required pattern.',
5252
'║ test/analyze-test-input/root/packages/foo/deprecation.dart:32: Deprecation notice does not match required pattern.',
53-
'║ test/analyze-test-input/root/packages/foo/deprecation.dart:37: Deprecation notice does not match required pattern.',
54-
'║ test/analyze-test-input/root/packages/foo/deprecation.dart:41: Deprecation notice does not match required pattern.',
53+
'║ test/analyze-test-input/root/packages/foo/deprecation.dart:37: Deprecation notice does not match required pattern. It might be missing the line saying "This feature was deprecated after...".',
54+
'║ test/analyze-test-input/root/packages/foo/deprecation.dart:41: Deprecation notice does not match required pattern. There might not be an explanatory message.',
5555
'║ test/analyze-test-input/root/packages/foo/deprecation.dart:48: End of deprecation notice does not match required pattern.',
5656
'║ test/analyze-test-input/root/packages/foo/deprecation.dart:51: Unexpected deprecation notice indent.',
5757
'║ test/analyze-test-input/root/packages/foo/deprecation.dart:70: Deprecation notice does not accurately indicate a beta branch version number; please see RELEASES_URL to find the latest beta build version number.',

dev/bots/test/post_process_docs_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ void main() async {
118118
),
119119
],
120120
);
121-
await runProcessWithValidations(command, '', processManager: processManager);
121+
await runProcessWithValidations(command, '', processManager: processManager, verbose: false);
122122
expect(processManager, hasNoRemainingExpectations);
123123
});
124124

@@ -133,7 +133,7 @@ void main() async {
133133
],
134134
);
135135
try {
136-
await runProcessWithValidations(command, '', processManager: processManager);
136+
await runProcessWithValidations(command, '', processManager: processManager, verbose: false);
137137
throw Exception('Exception was not thrown');
138138
} on CommandException catch (e) {
139139
expect(e, isA<Exception>());

dev/integration_tests/web_e2e_tests/test_driver/platform_messages_integration.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ void main() {
2121
await tester.pumpAndSettle();
2222

2323
// TODO(nurhan): https://github.com/flutter/flutter/issues/51885
24-
SystemChannels.textInput.setMockMethodCallHandler(null);
24+
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.textInput, null);
2525
// Focus on a TextFormField.
2626
final Finder finder = find.byKey(const Key('input'));
2727
expect(finder, findsOneWidget);
@@ -39,7 +39,7 @@ void main() {
3939
platformViewsRegistry.getNextPlatformViewId();
4040
// ignore: undefined_prefixed_name, avoid_dynamic_calls
4141
ui.platformViewRegistry.registerViewFactory('MyView', (int viewId) {
42-
++viewInstanceCount;
42+
viewInstanceCount += 1;
4343
return html.DivElement();
4444
});
4545

examples/api/test/widgets/binding/widget_binding_observer.0_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ void main() {
1313
Future<void> setAppLifeCycleState(AppLifecycleState state) async {
1414
final ByteData? message =
1515
const StringCodec().encodeMessage(state.toString());
16-
await ServicesBinding.instance.defaultBinaryMessenger
17-
.handlePlatformMessage('flutter/lifecycle', message, (_) {});
16+
await tester.binding.defaultBinaryMessenger.handlePlatformMessage(
17+
'flutter/lifecycle', message, (_) {});
1818
}
1919

2020
await tester.pumpWidget(

examples/api/test/widgets/editable_text/editable_text.on_content_inserted.0_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void main() {
4444
});
4545

4646
try {
47-
await ServicesBinding.instance.defaultBinaryMessenger.handlePlatformMessage(
47+
await tester.binding.defaultBinaryMessenger.handlePlatformMessage(
4848
'flutter/textinput',
4949
messageBytes,
5050
(ByteData? _) {},

packages/flutter/lib/src/services/binary_messenger.dart

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,12 @@ abstract class BinaryMessenger {
4545
/// To register a handler for a given message channel, see [setMessageHandler].
4646
///
4747
/// To send a message _to_ a plugin on the platform thread, see [send].
48-
// TODO(ianh): deprecate this method once cocoon and other customer_tests are migrated:
49-
// @NotYetDeprecated(
50-
// 'Instead of calling this method, use ServicesBinding.instance.channelBuffers.push. '
51-
// 'In tests, consider using tester.binding.defaultBinaryMessenger.handlePlatformMessage '
52-
// 'or TestDefaultBinaryMessenger.instance.defaultBinaryMessenger.handlePlatformMessage. '
53-
// 'This feature was deprecated after v2.1.0-10.0.pre.'
54-
// )
48+
@Deprecated(
49+
'Instead of calling this method, use ServicesBinding.instance.channelBuffers.push. '
50+
'In tests, consider using tester.binding.defaultBinaryMessenger.handlePlatformMessage '
51+
'or TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.handlePlatformMessage. '
52+
'This feature was deprecated after v3.9.0-19.0.pre.'
53+
)
5554
Future<void> handlePlatformMessage(String channel, ByteData? data, ui.PlatformMessageResponseCallback? callback);
5655

5756
/// Send a binary message to the platform plugins on the given channel.

packages/flutter/test/cupertino/scrollbar_test.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,11 @@ void main() {
208208
await tester.pump();
209209

210210
int hapticFeedbackCalls = 0;
211-
SystemChannels.platform.setMockMethodCallHandler((MethodCall methodCall) async {
211+
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async {
212212
if (methodCall.method == 'HapticFeedback.vibrate') {
213-
hapticFeedbackCalls++;
213+
hapticFeedbackCalls += 1;
214214
}
215+
return null;
215216
});
216217

217218
// Long press on the scrollbar thumb and expect a vibration after it resizes.
@@ -966,10 +967,11 @@ void main() {
966967
await tester.pump();
967968

968969
int hapticFeedbackCalls = 0;
969-
SystemChannels.platform.setMockMethodCallHandler((MethodCall methodCall) async {
970+
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async {
970971
if (methodCall.method == 'HapticFeedback.vibrate') {
971-
hapticFeedbackCalls++;
972+
hapticFeedbackCalls += 1;
972973
}
974+
return null;
973975
});
974976

975977
// Long press on the scrollbar thumb and expect a vibration after it resizes.

0 commit comments

Comments
 (0)