-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Cupertino icons golden tests #7421
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
auto-submit
merged 14 commits into
flutter:main
from
LongCatIsLooong:cupertino-icons-golden-tests
Aug 27, 2024
Merged
Changes from 7 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
822ec82
add golden tests for cupertino_icons
LongCatIsLooong a474995
fix goldens
LongCatIsLooong 718a9a6
hooray
LongCatIsLooong 9721434
unmodifiable
LongCatIsLooong c5ba512
dart:io
LongCatIsLooong 76e4d40
Linux only
LongCatIsLooong 7a33212
pin dev deps version
LongCatIsLooong f021829
Update cupertino_icons_golden_test.dart
LongCatIsLooong 8aa7409
Update icons_list.dart
LongCatIsLooong b7e2ff8
Update cupertino_icons_golden_test.dart
LongCatIsLooong 894af19
Update CODEOWNERS
LongCatIsLooong 8f0fe45
unpin path
LongCatIsLooong fb4c4bb
Merge branch 'cupertino-icons-golden-tests' of github.com:LongCatIsLo…
LongCatIsLooong be49a15
pin path to ^1.9.0
LongCatIsLooong 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
80 changes: 80 additions & 0 deletions
80
third_party/packages/cupertino_icons/test/cupertino_icons_golden_test.dart
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,80 @@ | ||
// Copyright 2013 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 'dart:io' show File, Platform; | ||
|
||
import 'package:collection/collection.dart'; | ||
import 'package:flutter/cupertino.dart'; | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:flutter/services.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:path/path.dart' as path; | ||
|
||
import 'icons_list.dart'; | ||
|
||
// The EM of the font is 512. Keep this a power of 2 for fixed-point arithmetic. | ||
const double iconSize = 128.0; | ||
const int iconsPerRow = 5; | ||
const int iconsPerCol = 5; | ||
const int iconsPerImage = iconsPerRow * iconsPerCol; | ||
|
||
void main() async { | ||
// Do not run on web since this test uses dart:io. | ||
// The golden test runs on Linux only to avoid platform rendering differences. | ||
if (kIsWeb || !Platform.isLinux) { | ||
return; | ||
} | ||
// Load font. | ||
final String effectiveFontFamily = const TextStyle(fontFamily: CupertinoIcons.iconFont, package: CupertinoIcons.iconFontPackage).fontFamily!; | ||
final FontLoader fontLoader = FontLoader(effectiveFontFamily); | ||
final String filePath = path.canonicalize('assets/CupertinoIcons.ttf'); | ||
final File file = File(filePath); | ||
fontLoader.addFont(file.readAsBytes().then((Uint8List v) => v.buffer.asByteData())); | ||
await fontLoader.load(); | ||
|
||
assert(icons.isNotEmpty); | ||
for (int index = 0; index < icons.length;) { | ||
final int groupEndCodePoint = (icons[index].codePoint ~/ iconsPerImage + 1) * iconsPerImage; | ||
final int next = icons.indexWhere((IconData icon) => icon.codePoint >= groupEndCodePoint, index); | ||
final int nextIndex = next < 0 ? icons.length : next; | ||
registerTestForIconGroup(icons.slice(index, nextIndex)); | ||
index = nextIndex; | ||
} | ||
} | ||
|
||
// Generating goldens for each glyph is very slow. Group the sorted icons | ||
// into codepoint-aligned groups (each of which has a max capacity of | ||
// iconsPerRow * iconsPerCol), so the goldens are easier to review when | ||
// symbols are added or removed. | ||
void registerTestForIconGroup(List<IconData> iconGroup) { | ||
assert(iconGroup.isNotEmpty); | ||
String hexCodePoint(int codePoint) => codePoint.toRadixString(16).toUpperCase().padLeft(4, '0'); | ||
final int groupStartCodePoint = (iconGroup.first.codePoint ~/ iconsPerImage) * iconsPerImage; | ||
final String range = 'U+${hexCodePoint(groupStartCodePoint)}-${hexCodePoint(groupStartCodePoint + iconsPerImage - 1)}'; | ||
|
||
testWidgets('font golden test: $range', (WidgetTester tester) async { | ||
addTearDown(tester.view.reset); | ||
const Size canvasSize = Size(iconSize * iconsPerRow, iconSize * iconsPerCol); | ||
tester.view.physicalSize = canvasSize * tester.view.devicePixelRatio; | ||
|
||
const Widget fillerBox = SizedBox.square(dimension: iconSize); | ||
final List<Widget> children = List<Widget>.filled(iconsPerImage, fillerBox); | ||
for (final IconData icon in iconGroup) { | ||
children[icon.codePoint - groupStartCodePoint] = Icon(icon, size: iconSize); | ||
} | ||
|
||
final Widget widget = Directionality( | ||
textDirection: TextDirection.ltr, | ||
child: Center( | ||
child: SizedBox( | ||
height: iconSize * iconsPerCol, | ||
width: iconSize * iconsPerRow, | ||
child: RepaintBoundary(child: Wrap(children: children)), | ||
), | ||
), | ||
); | ||
await tester.pumpWidget(widget); | ||
await expectLater(find.byType(Wrap) , matchesGoldenFile('goldens/glyph_$range.png')); | ||
}); | ||
} |
Binary file added
BIN
+7.05 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F104-F11C.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+12.6 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F217-F22F.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.12 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F2AD-F2C5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.47 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F2C6-F2DE.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.28 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F2DF-F2F7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.06 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F35C-F374.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.86 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F375-F38D.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+11.6 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F3A7-F3BF.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.45 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F3C0-F3D8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.67 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F3D9-F3F1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+26.6 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F3F2-F40A.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+15.2 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F40B-F423.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+21.4 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F424-F43C.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+17.7 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F43D-F455.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+15.3 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F456-F46E.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+19.8 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F46F-F487.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+26.5 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F488-F4A0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+14.1 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F4A1-F4B9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+19.6 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F4BA-F4D2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+49.7 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F4D3-F4EB.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+42.7 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F4EC-F504.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+38.8 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F505-F51D.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+49.9 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F51E-F536.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+48.2 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F537-F54F.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+44.5 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F550-F568.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+44.8 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F569-F581.png
Oops, something went wrong.
Binary file added
BIN
+46.9 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F582-F59A.png
Oops, something went wrong.
Binary file added
BIN
+44.3 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F59B-F5B3.png
Oops, something went wrong.
Binary file added
BIN
+47.7 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F5B4-F5CC.png
Oops, something went wrong.
Binary file added
BIN
+41.3 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F5CD-F5E5.png
Oops, something went wrong.
Binary file added
BIN
+50.1 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F5E6-F5FE.png
Oops, something went wrong.
Binary file added
BIN
+54.1 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F5FF-F617.png
Oops, something went wrong.
Binary file added
BIN
+43.3 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F618-F630.png
Oops, something went wrong.
Binary file added
BIN
+44.2 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F631-F649.png
Oops, something went wrong.
Binary file added
BIN
+46.2 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F64A-F662.png
Oops, something went wrong.
Binary file added
BIN
+42.5 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F663-F67B.png
Oops, something went wrong.
Binary file added
BIN
+53.2 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F67C-F694.png
Oops, something went wrong.
Binary file added
BIN
+55.4 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F695-F6AD.png
Oops, something went wrong.
Binary file added
BIN
+54.1 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F6AE-F6C6.png
Oops, something went wrong.
Binary file added
BIN
+40.9 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F6C7-F6DF.png
Oops, something went wrong.
Binary file added
BIN
+43.6 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F6E0-F6F8.png
Oops, something went wrong.
Binary file added
BIN
+43.9 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F6F9-F711.png
Oops, something went wrong.
Binary file added
BIN
+46.8 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F712-F72A.png
Oops, something went wrong.
Binary file added
BIN
+46.5 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F72B-F743.png
Oops, something went wrong.
Binary file added
BIN
+53.4 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F744-F75C.png
Oops, something went wrong.
Binary file added
BIN
+40.7 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F75D-F775.png
Oops, something went wrong.
Binary file added
BIN
+39.4 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F776-F78E.png
Oops, something went wrong.
Binary file added
BIN
+41.2 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F78F-F7A7.png
Oops, something went wrong.
Binary file added
BIN
+34 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F7A8-F7C0.png
Oops, something went wrong.
Binary file added
BIN
+43.3 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F7C1-F7D9.png
Oops, something went wrong.
Binary file added
BIN
+43.3 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F7DA-F7F2.png
Oops, something went wrong.
Binary file added
BIN
+34.7 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F7F3-F80B.png
Oops, something went wrong.
Binary file added
BIN
+38.9 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F80C-F824.png
Oops, something went wrong.
Binary file added
BIN
+43.5 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F825-F83D.png
Oops, something went wrong.
Binary file added
BIN
+32.7 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F83E-F856.png
Oops, something went wrong.
Binary file added
BIN
+55.6 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F857-F86F.png
Oops, something went wrong.
Binary file added
BIN
+42.2 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F870-F888.png
Oops, something went wrong.
Binary file added
BIN
+55.2 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F889-F8A1.png
Oops, something went wrong.
Binary file added
BIN
+45.9 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F8A2-F8BA.png
Oops, something went wrong.
Binary file added
BIN
+41.7 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F8BB-F8D3.png
Oops, something went wrong.
Binary file added
BIN
+49.4 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F8D4-F8EC.png
Oops, something went wrong.
Binary file added
BIN
+41.6 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F8ED-F905.png
Oops, something went wrong.
Binary file added
BIN
+42.9 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F906-F91E.png
Oops, something went wrong.
Binary file added
BIN
+8.6 KB
third_party/packages/cupertino_icons/test/goldens/glyph_U+F91F-F937.png
Oops, something went wrong.
Large diffs are not rendered by default.
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.
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.
Why is this pinned to an exact version?
path
is allowed as an unpinned dependency in the repo.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 made the change after reading https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#dependencies
But it looks like that only applies to external packages. I'll change it back to
any
.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 shouldn't be
any
, it should be a standard^
dependency.