-
Notifications
You must be signed in to change notification settings - Fork 309
emoji_reaction: Add EmojiReactionTheme, including dark variant #805
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
Huh, when I run tests locally at the tip of this, they fail — I think on exactly the RTL half of the cases:
That begins at the "Set up whole ZulipApp" commit. It persists even after I run Clearly it works for you and in CI. So presumably there's something that's getting cached for me locally — like the list of locales, perhaps, so that it doesn't know about Persists also if I run |
What does |
|
Hmm, mine was auto-updating to include |
Cool, yeah, I think that probably means
I guess we'll have to warn everyone to do that after this gets merged. |
(Probably this should be thought of as a bug in the |
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.
(Haven't yet read the main commit at the end.)
addTearDown(tester.platformDispatcher.clearLocaleTestValue); | ||
addTearDown(tester.platformDispatcher.clearLocalesTestValue); | ||
|
||
await tester.pumpWidget(const ZulipApp()); |
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.
This commit turns out to make these tests quite a bit slower:
# before:
$ time flutter test test/widgets/emoji_reaction_test.dart
00:05 +160: All tests passed!
time: 6.078s wall (7.313s u, 0.940s s)
# after:
$ time flutter test test/widgets/emoji_reaction_test.dart
00:09 +160: All tests passed!
time: 10.528s wall (12.424s u, 1.321s s)
The slowdown happens with this commit:
fa3f012 emoji_reaction test: Set up whole ZulipApp, not just MaterialApp
It'd be good to try to pin down where that time is going. The strategy of reusing ZulipApp in tests makes a lot of sense in principle, so we're likely to try using it in more and more tests… and I'd like to figure out how to do so without slowing all our tests down by 75%.
The strategy I'd try is to just start commenting out parts of ZulipApp's functionality, and rerunning this one test file, and see which pieces are contributing the time.
Then once we know which pieces are at issue, we can see about finding hacks for tests to cut those out, or strip them down to a minimum.
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.
Thanks @chrisbobbe! Generally this looks good.
- The same two small comments as at theme: Implement DesignVariables.dark #804 apply here.
- Let's also investigate that test slowdown above, and see if we can find an easy workaround for it.
And then repeating here just so the action items are in one place:
- On merging this, we'll need to make a PSA in #mobile-team that people need to run
flutter gen-l10n
(or justflutter run
) after rebasing in order to get tests working again.- And as a bonus followup it'd be nice to find or file an upstream flutter-tool issue about the need for that.
Yeah, I'm not sure. Happy to have both approaches going, and we can see which we like better and optionally refactor later to a single approach. |
Greg noticed an instance where using ZulipApp directly was causing tests to slow down by some 75%: zulip#805 (comment) Specifically, that was when we converted the emoji-reaction widget tests over to use ZulipApp instead of mimicking it with a MaterialApp, etc. It's helpful to use something approaching the real ZulipApp. But we'd like to avoid that slowdown, especially if it's happening in code that most tests don't need to exercise. So, here's a stripped-down version that does that. It takes roughly the same time as the MaterialApp approach in those emoji-reaction tests. (11s on my machine, vs. 16s with ZulipApp.) This commit just converts the tests that were using ZulipApp. Next, we'll sweep through and treat the ones using the ad hoc MaterialApp approach.
cf3ef49
to
7dd90d1
Compare
Thanks for the review! Revision pushed. |
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.
Thanks! Here's a partial review before I switch to another task.
Small comments below, and I tried out the performance effects of these two commits:
0a2b459 test: Add TestZulipApp; replace uses of ZulipApp
c026fce test: Use TestZulipApp everywhere else it makes sense
on flutter test test/widgets
on my machine, measuring the fastest of three runs.
Before:
time: 15.837s wall (68.737s u, 9.182s s)
After replacing ZulipApp uses:
time: 15.389s wall (64.851s u, 8.641s s)
After using TestZulipApp more widely:
time: 15.684s wall (64.010s u, 9.070s s)
So replacing ZulipApp made a small speedup, about 7% less total CPU time. Then using TestZulipApp more widely had roughly zero impact, as hoped.
I haven't yet read the last four commits (or revisions to them, at least) in detail:
c026fce test: Use TestZulipApp everywhere else it makes sense
5967ff0 emoji_reaction test [nfc]: Move some setup code out next to similar code
309cff5 emoji_reaction test: Add another convenient test-setup check
7dd90d1 emoji_reaction: Add EmojiReactionTheme, including dark variant
lib/widgets/emoji_reaction.dart
Outdated
factory EmojiReactionTheme.light() { | ||
return EmojiReactionTheme._( |
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.
bump on redirecting constructor (one of those two #804 comments I mentioned)
this.navigatorObservers, | ||
this.child = const Placeholder(), |
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.
nit: this final ordering is good but the reordering should get squashed into the commit that introduces the widget
test/widgets/text_test.dart
Outdated
await tester.pumpAndSettle(); | ||
await tester.pump(); |
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 that a lot of pumpAndSettle
calls seem to become unnecessary in favor of just pump
.
Noting here to help us remember it: #827 introduces another spot that could benefit from TestZulipApp: so whichever of these PRs lands first, we can update that spot in the other PR. edit: Also #835. |
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.
OK, and here's the rest of a review on this revision. Generally looks great — several nits, and two other comments on tests which should be quick to fix.
test/widgets/app_test.dart
Outdated
supportedLocales: ZulipLocalizations.supportedLocales, | ||
home: GlobalStoreWidget( | ||
child: ChooseAccountPage()))); | ||
await tester.pumpWidget(const TestZulipApp(child: ChooseAccountPage())); |
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.
nit: the specific page is the main interesting bit here, and I think a bit easier to spot if it starts a line:
await tester.pumpWidget(const TestZulipApp(child: ChooseAccountPage())); | |
await tester.pumpWidget(const TestZulipApp( | |
child: ChooseAccountPage())); |
home: Directionality( | ||
textDirection: textDirection ?? TextDirection.ltr, |
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.
nit: currently these get turned into the tester.platformDispatcher
logic in the big conversion commit:
c026fce test: Use TestZulipApp everywhere else it makes sense
Probably that'd be better as a separate commit coming after that one, since it's different from the otherwise-repetitive other changes in the commit.
tester.platformDispatcher.accessibilityFeaturesTestValue = | ||
FakeAccessibilityFeatures(boldText: platformRequestsBold); | ||
addTearDown(tester.platformDispatcher.clearAccessibilityFeaturesTestValue); |
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.
This seems fine to include in the same commit, though. It's fairly straightforwardly just another way of expressing the effect of that MediaQuery
.
test/widgets/theme_test.dart
Outdated
await tester.pump(); | ||
final buttonTextFinder = find.text(buttonText); | ||
final context = tester.element(buttonTextFinder); | ||
final text = tester.renderObject<RenderParagraph>(buttonTextFinder).text; |
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.
small simplification:
final text = tester.renderObject<RenderParagraph>(buttonTextFinder).text; | |
final text = (context.renderObject as RenderParagraph).text; |
Then also buttonTextFinder
is used just once and can be inlined.
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.
also nit: reorder this line to just before the check
, after computing the expected values; or perhaps even just inline it into the check
call
@@ -204,6 +215,45 @@ void main() { | |||
} | |||
} | |||
} | |||
|
|||
testWidgets('Smoke test for light/dark/lerped', (tester) async { |
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.
nit: nested in unintended group
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.
The 'ReactionChipsList' group? It uses some helpers that are in that group. Those could be moved out of the group, though.
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.
Yeah, this test didn't seem to be about the ReactionChipsList widget.
I guess that is the widget that test helper is setting up, though, so maybe the grouping is appropriate.
await prepare(); | ||
await store.addUsers([eg.selfUser, eg.otherUser]); | ||
|
||
debugFollowPlatformBrightness = true; |
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.
needs teardown
Greg noticed an instance where using ZulipApp directly was causing tests to slow down by some 75%: zulip#805 (comment) Specifically, that was when we converted the emoji-reaction widget tests over to use ZulipApp instead of mimicking it with a MaterialApp, etc. It's helpful to use something approaching the real ZulipApp. But we'd like to avoid that slowdown, especially if it's happening in code that most tests don't need to exercise. So, here's a stripped-down version that does that. It takes roughly the same time as the MaterialApp approach in those emoji-reaction tests. (11s on my machine, vs. 16s with ZulipApp.) This commit just converts the tests that were using ZulipApp. Next, we'll sweep through and treat the ones using the ad hoc MaterialApp approach.
3a4af4d
to
2f804d5
Compare
Thanks for the review! Revision pushed. |
This will let us simplify how we simulate RTL in the emoji-reaction widget tests, coming up. Fixes: zulip#803
We're about to refactor the way RTL gets applied. While we're at it, also check the width of the ReactionChipsList element.
Greg noticed an instance where using ZulipApp directly was causing tests to slow down by some 75%: zulip#805 (comment) Specifically, that was when we converted the emoji-reaction widget tests over to use ZulipApp instead of mimicking it with a MaterialApp, etc. It's helpful to use something approaching the real ZulipApp. But we'd like to avoid that slowdown, especially if it's happening in code that most tests don't need to exercise. So, here's a stripped-down version that does that. It takes roughly the same time as the MaterialApp approach in those emoji-reaction tests. (11s on my machine, vs. 16s with ZulipApp.) This commit just converts the tests that were using ZulipApp. Next, we'll sweep through and treat the ones using the ad hoc MaterialApp approach.
2f804d5
to
6324bf3
Compare
Thanks! Looks good — merging. |
Screenshot (also showing some unrelated tweaks toward dark-theme that will land separately):
I thought it might be helpful to have a new
ThemeExtension
for this part of the UI instead of adding all these values toDesignVariables
. This way at least we don't have to alphabetize these items along with a lot of attributes from unrelated parts of the UI. I see that we're taking theDesignVariables
approach in #762, though, and it's possible that that'll end up being preferred for some reason.Related: #95