-
Notifications
You must be signed in to change notification settings - Fork 270
[SuperEditor] Migrate golden tests (Resolves #2654) #2702
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
base: main
Are you sure you want to change the base?
Conversation
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.
I read through the new golden file and left some questions/thoughts about the current flutter_test_goldens API.
Also, any thoughts on your end based on your direct usage?
testGoldenSceneOnMac('shows caret at right side of an image', (tester) async { | ||
await Gallery( | ||
tester, | ||
sceneName: 'goldens/super-editor-image-caret-downstream-mac', |
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.
I think we wanna do something different here. The term sceneName
doesn't imply a file path, but it is. There are three things related to this: the directory path, the file name, and a human readable description of the scene. This is a note for us to figure out those properties.
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.
Maybe we should default to place the file in a goldens
directory. Since this the default in the golden_toolkit
people are already used to it.
) | ||
.itemFromPumper( | ||
id: "1", | ||
description: 'SuperEditor', |
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.
These descriptions are meant to be a short statement about what's captured in the golden. I'm guessing that "SuperEditor" isn't what this one should be.
await tester.pump(); | ||
}, | ||
) | ||
.renderOrCompareGolden(); |
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.
Perhaps we should have a single shot API, too. I don't know if that's worth it or not, but obviously in this test we're not utilizing the gallery part of a Gallery
.
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, I think it makes sense for single image tests.
await tester.pump(); | ||
|
||
await screenMatchesGolden(tester, 'super-editor-image-caret-downstream-ios'); | ||
testGoldenSceneOnIOS('shows caret at right side of an image', (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.
I'm wondering if we should try to rework the platform structure so that the platform is configured per golden image?
As I look at this I'm wondering, wouldn't it feel more appropriate to see the various platform versions of the caret all in one scene? It looks like most/all of the tests in this file could be a single scene image...
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.
It would be nice. We'll need to see how practical would that be. I guess this would only work when using itemFromPumper
, right?
}); | ||
|
||
group('phone rotation updates caret position', () { | ||
const screenSizePortrait = Size(400.0, 800.0); | ||
const screenSizeLandscape = Size(800.0, 400); | ||
|
||
testGoldensOniOS('from portrait to landscape', (tester) async { | ||
testGoldenSceneOnIOS('from portrait to landscape', (tester) async { | ||
tester.view | ||
..devicePixelRatio = 1.0 |
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.
Do you remember why we're making these changes to the test view here? The golden test runners set the pixel ratio to 1 for all goldens to reduce anti-aliasing.
}) | ||
.takePhoto(find.byType(SuperEditor), "landscape") | ||
.renderOrCompareGolden( | ||
goldenName: "super-editor-caret-rotation-portrait-landscape-ios", |
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.
I changed Gallery
to include these configurations in the constructor. Should we do the same for FilmStrip
?
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, I think it makes more sense to have this in the constructor.
tester.view.physicalSize = screenSizeLandscape; | ||
await tester.pumpAndSettle(); | ||
}) | ||
.takePhoto(find.byType(SuperEditor), "landscape") |
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.
Should we make the Finder
optional and default to looking for a GoldenImageBounds
to reduce the verbosity?
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.
I think it would be helpful.
The only downside for now that we have to add this to the tests: return scaffold(
_widgetTester,
GoldenImageBounds(
child: decorator != null //
? decorator.call(_widgetTester, superEditor)
: superEditor,
),
); But I don't have a better alternative at the moment. |
No description provided.