flutter_flutter/packages/flutter/test/semantics/semantics_service_test.dart
auto-submit[bot] 5e146d47a6
Reverts "Reapply "Update the AccessibilityPlugin::Announce method to account f… (#174365)" (#176059)
<!-- start_original_pr_link -->
Reverts: flutter/flutter#174365
<!-- end_original_pr_link -->
<!-- start_initiating_author -->
Initiated by: chunhtai
<!-- end_initiating_author -->
<!-- start_revert_reason -->
Reason for reverting: outdated g3fix
<!-- end_revert_reason -->
<!-- start_original_pr_author -->
Original PR Author: mattkae
<!-- end_original_pr_author -->

<!-- start_reviewers -->
Reviewed By: {chunhtai}
<!-- end_reviewers -->

<!-- start_revert_body -->
This change reverts the following previous change:
…o… (#174223)

This reverts commit 86327198ff0678f46cbdfb3e12f1759d03aa768d.

Reverts the revert: https://github.com/flutter/flutter/pull/174223

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

<!-- end_revert_body -->

Co-authored-by: auto-submit[bot] <flutter-engprod-team@google.com>
2025-09-25 22:37:49 +00:00

48 lines
1.5 KiB
Dart

// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/semantics.dart';
import 'package:flutter/services.dart' show SystemChannels;
import 'package:flutter_test/flutter_test.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
test('Semantic announcement', () async {
final List<Map<dynamic, dynamic>> log = <Map<dynamic, dynamic>>[];
Future<dynamic> handleMessage(dynamic mockMessage) async {
final Map<dynamic, dynamic> message = mockMessage as Map<dynamic, dynamic>;
log.add(message);
}
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockDecodedMessageHandler<dynamic>(SystemChannels.accessibility, handleMessage);
await SemanticsService.announce('announcement 1', TextDirection.ltr);
await SemanticsService.announce(
'announcement 2',
TextDirection.rtl,
assertiveness: Assertiveness.assertive,
);
expect(
log,
equals(<Map<String, dynamic>>[
<String, dynamic>{
'type': 'announce',
'data': <String, dynamic>{'message': 'announcement 1', 'textDirection': 1},
},
<String, dynamic>{
'type': 'announce',
'data': <String, dynamic>{
'message': 'announcement 2',
'textDirection': 0,
'assertiveness': 1,
},
},
]),
);
});
}