forked from flutter/flutter
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for single_activator.0.dart API example. (flutter#147426)
This PR contributes to flutter#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`
- Loading branch information
1 parent
2867ac7
commit d33bb8f
Showing
4 changed files
with
49 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
examples/api/test/widgets/shortcuts/single_activator.0_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
}, | ||
); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters