-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[material_ui] Enable bottom_navigation_bar_test
#12005
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
elliette
merged 4 commits into
flutter:main
from
elliette:pr184297/bottom-navigation-bar-test
Jun 25, 2026
+105
−49
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,51 @@ | ||
| // Copyright 2013 The Flutter Authors | ||
| // 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_test/flutter_test.dart'; | ||
|
|
||
| /// Tracks how often feedback has been requested since its instantiation. | ||
| /// | ||
| /// It replaces the MockMethodCallHandler of [SystemChannels.platform] and | ||
| /// cannot be used in combination with other classes that do the same. | ||
| class FeedbackTester { | ||
| FeedbackTester() { | ||
| TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler( | ||
| SystemChannels.platform, | ||
| _handler, | ||
| ); | ||
| } | ||
|
|
||
| /// Number of times haptic feedback was requested (vibration). | ||
| int get hapticCount => _hapticCount; | ||
| int _hapticCount = 0; | ||
|
|
||
| /// Number of times the click sound was requested to play. | ||
| int get clickSoundCount => _clickSoundCount; | ||
| int _clickSoundCount = 0; | ||
|
|
||
| Future<void> _handler(MethodCall methodCall) async { | ||
| if (methodCall.method == 'HapticFeedback.vibrate') { | ||
| _hapticCount++; | ||
| } | ||
| if (methodCall.method == 'SystemSound.play' && | ||
| methodCall.arguments == SystemSoundType.click.toString()) { | ||
| _clickSoundCount++; | ||
| } | ||
| } | ||
|
|
||
| /// Stops tracking. | ||
| void dispose() { | ||
| assert( | ||
| TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.checkMockMessageHandler( | ||
| SystemChannels.platform.name, | ||
| _handler, | ||
| ), | ||
| ); | ||
| TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler( | ||
| SystemChannels.platform, | ||
| null, | ||
| ); | ||
| } | ||
| } |
This file contains hidden or 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,43 @@ | ||
| // Copyright 2013 The Flutter Authors | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| import 'package:flutter_test/flutter_test.dart'; | ||
| import 'package:material_ui/material_ui.dart'; | ||
|
|
||
| /// Finds [RawTooltip] or [Tooltip] widgets with the given `message`. | ||
| /// | ||
| /// ## Sample code | ||
| /// | ||
| /// ```dart | ||
| /// expect(find.byTooltip('Back'), findsOneWidget); | ||
| /// expect(find.byTooltip(RegExp('Back.*')), findsNWidgets(2)); | ||
| /// ``` | ||
| /// | ||
| /// If the `skipOffstage` argument is true (the default), then this skips | ||
| /// nodes that are [Offstage] or that are from inactive [Route]s. | ||
| /// | ||
| /// This was copied from flutter_test, which uses flutter/material.dart. | ||
| /// | ||
| // TODO(justinmc): Port flutter_test to material_ui, then delete this method and | ||
| // use that one. See https://github.com/flutter/flutter/issues/186966 | ||
| Finder findByTooltip(Pattern message, {bool skipOffstage = true}) { | ||
| return find.byWidgetPredicate((Widget widget) { | ||
| // Compare RawTooltip's semantics tooltip with the given message. | ||
| // However, Tooltip's message needs to be checked directly if: | ||
| // 1. Tooltip.excludeFromSemantics is true, since in this case Tooltip | ||
| // provides no semantics tooltip to the underlying RawTooltip. | ||
| // 2. Tooltip.message and Tooltip.richMessage are empty, since in this | ||
| // case no RawTooltip is created. | ||
| if (widget is Tooltip) { | ||
| final String tooltipMessage = widget.message ?? widget.richMessage!.toPlainText(); | ||
| if ((widget.excludeFromSemantics ?? false) || tooltipMessage.isEmpty) { | ||
| return message is RegExp ? message.hasMatch(tooltipMessage) : tooltipMessage == message; | ||
| } | ||
| } | ||
| return widget is RawTooltip && | ||
| (message is RegExp | ||
| ? message.hasMatch(widget.semanticsTooltip ?? '') | ||
| : widget.semanticsTooltip == message); | ||
| }, skipOffstage: skipOffstage); | ||
| } | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.