-
Notifications
You must be signed in to change notification settings - Fork 28.7k
Make chip test not depend on child order #94624
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
Conversation
@@ -307,7 +307,7 @@ void main() { | |||
expect(getIconData(tester).color?.value, 0xffffffff); | |||
expect(getIconData(tester).opacity, null); | |||
expect(getIconData(tester).size, null); | |||
expect(getLabelStyle(tester).style.color?.value, 0xffffffff); | |||
expect(getLabelStyle(tester, 'Chip A').style.color?.value, 0xdeffffff); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@HansMuller Can you double-check that this is actually what the color should be in this case? It matches what the ChoiceChip already asserts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -307,7 +307,7 @@ void main() { | |||
expect(getIconData(tester).color?.value, 0xffffffff); | |||
expect(getIconData(tester).opacity, null); | |||
expect(getIconData(tester).size, null); | |||
expect(getLabelStyle(tester).style.color?.value, 0xffffffff); | |||
expect(getLabelStyle(tester, 'Chip A').style.color?.value, 0xdeffffff); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's correct.
find.descendant( | ||
of: find.byType(RawChip), | ||
find.ancestor( | ||
of: find.text(labelText), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NICE
This pull request is not suitable for automatic merging in its current state.
|
…94077)" Test was fixed in flutter#94624.
The current implementation of Chip has a subtle bug where the during initial build the child elements are ordered avatar, deleteIcon, label:
flutter/packages/flutter/lib/src/material/chip.dart
Lines 2163 to 2165 in 4517d16
During subsequent builds, the order is changed to label, avatar, deleteIcon:
flutter/packages/flutter/lib/src/material/chip.dart
Lines 2183 to 2185 in 4517d16
However, in
chip_test.dart
thegetLabelStyle
method is assuming that the label is always the last child:flutter/packages/flutter/test/material/chip_test.dart
Lines 49 to 56 in 4517d16
This is only true after initial build. If a test rebuilds the chip, the label is the middle child and
getLabelStyle
returns the incorrect style of the deleteIcon. This PR fixesgetLabelStyle
to no longer rely on the child order of Chip. As it turns out, one of the test cases introduced in #94179 was making incorrect assumptions about the label style because of this bug. That assumption is fixed as well.The bug was discovered when #94077 unified the child order of first and subsequent builds.