mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Add tests for single_activator.0.dart API example. (#147426)
This PR contributes to https://github.com/flutter/flutter/issues/130459 ### Description - Fixes name of the `examples/api/lib/widgets/shortcuts/single_activator.single_activator.0.dart` - Adds tests for `examples/api/lib/widgets/shortcuts/single_activator.0.dart`
This commit is contained in:
parent
2867ac7885
commit
d33bb8fa5e
@ -433,7 +433,6 @@ final Set<String> _knownMissingTests = <String>{
|
||||
'examples/api/test/widgets/image/image.loading_builder.0_test.dart',
|
||||
'examples/api/test/widgets/shortcuts/logical_key_set.0_test.dart',
|
||||
'examples/api/test/widgets/shortcuts/shortcuts.0_test.dart',
|
||||
'examples/api/test/widgets/shortcuts/single_activator.single_activator.0_test.dart',
|
||||
'examples/api/test/widgets/shortcuts/shortcuts.1_test.dart',
|
||||
'examples/api/test/widgets/shortcuts/callback_shortcuts.0_test.dart',
|
||||
'examples/api/test/widgets/page_storage/page_storage.0_test.dart',
|
||||
|
@ -5,7 +5,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
/// Flutter code sample for [SingleActivator.SingleActivator].
|
||||
/// Flutter code sample for [SingleActivator].
|
||||
|
||||
void main() => runApp(const SingleActivatorExampleApp());
|
||||
|
@ -0,0 +1,47 @@
|
||||
// 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/services.dart';
|
||||
import 'package:flutter_api_samples/widgets/shortcuts/single_activator.0.dart'
|
||||
as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
Future<void> pressControlC(WidgetTester tester) async {
|
||||
await tester.sendKeyDownEvent(LogicalKeyboardKey.control);
|
||||
await tester.sendKeyDownEvent(LogicalKeyboardKey.keyC);
|
||||
await tester.sendKeyUpEvent(LogicalKeyboardKey.keyC);
|
||||
await tester.sendKeyUpEvent(LogicalKeyboardKey.control);
|
||||
}
|
||||
|
||||
group('SingleActivatorExampleApp', () {
|
||||
testWidgets('displays correct labels', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.SingleActivatorExampleApp(),
|
||||
);
|
||||
|
||||
expect(
|
||||
find.text('Add to the counter by pressing Ctrl+C'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('count: 0'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'updates counter when Ctrl-C combination pressed',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.SingleActivatorExampleApp(),
|
||||
);
|
||||
|
||||
for (int counter = 0; counter < 10; counter++) {
|
||||
expect(find.text('count: $counter'), findsOneWidget);
|
||||
|
||||
await pressControlC(tester);
|
||||
await tester.pump();
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
@ -432,7 +432,7 @@ class SingleActivator with Diagnosticable, MenuSerializableShortcut implements S
|
||||
/// In the following example, the shortcut `Control + C` increases the
|
||||
/// counter:
|
||||
///
|
||||
/// ** See code in examples/api/lib/widgets/shortcuts/single_activator.single_activator.0.dart **
|
||||
/// ** See code in examples/api/lib/widgets/shortcuts/single_activator.0.dart **
|
||||
/// {@end-tool}
|
||||
const SingleActivator(
|
||||
this.trigger, {
|
||||
|
Loading…
Reference in New Issue
Block a user