Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
e2ab3e58
Unverified
Commit
e2ab3e58
authored
Sep 17, 2022
by
Viren Khatri
Committed by
GitHub
Sep 17, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed inconsistent file names for *_chip.dart files and added a test (#111364)
parent
f13737ce
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
67 additions
and
13 deletions
+67
-13
analyze.dart
dev/bots/analyze.dart
+54
-0
gen_defaults.dart
dev/tools/gen_defaults/bin/gen_defaults.dart
+7
-7
action_chip_template.dart
dev/tools/gen_defaults/lib/action_chip_template.dart
+2
-2
filter_chip_template.dart
dev/tools/gen_defaults/lib/filter_chip_template.dart
+2
-2
input_chip_template.dart
dev/tools/gen_defaults/lib/input_chip_template.dart
+2
-2
action_chip_test.dart
packages/flutter/test/material/action_chip_test.dart
+0
-0
choice_chip_test.dart
packages/flutter/test/material/choice_chip_test.dart
+0
-0
filter_chip_test.dart
packages/flutter/test/material/filter_chip_test.dart
+0
-0
input_chip_test.dart
packages/flutter/test/material/input_chip_test.dart
+0
-0
No files found.
dev/bots/analyze.dart
View file @
e2ab3e58
...
...
@@ -201,6 +201,10 @@ Future<void> run(List<String> arguments) async {
}
finally
{
outDir
.
deleteSync
(
recursive:
true
);
}
// Ensure gen_default links the correct files
printProgress
(
'Correct file names in gen_defaults.dart...'
);
await
verifyTokenTemplatesUpdateCorrectFiles
(
flutterRoot
);
}
...
...
@@ -278,6 +282,56 @@ Future<void> verifyNoDoubleClamp(String workingDirectory) async {
}
}
/// Verify Token Templates are mapped to correct file names while generating
/// M3 defaults in /dev/tools/gen_defaults/bin/gen_defaults.dart.
Future
<
void
>
verifyTokenTemplatesUpdateCorrectFiles
(
String
workingDirectory
)
async
{
final
List
<
String
>
errors
=
<
String
>[];
String
getMaterialDirPath
(
List
<
String
>
lines
)
{
final
String
line
=
lines
.
firstWhere
((
String
line
)
=>
line
.
contains
(
'String materialLib'
));
final
String
relativePath
=
line
.
substring
(
line
.
indexOf
(
"'"
)
+
1
,
line
.
lastIndexOf
(
"'"
));
return
path
.
join
(
workingDirectory
,
relativePath
);
}
String
getFileName
(
String
line
)
{
const
String
materialLibString
=
r"'$materialLib/"
;
final
String
leftClamp
=
line
.
substring
(
line
.
indexOf
(
materialLibString
)
+
materialLibString
.
length
);
return
leftClamp
.
substring
(
0
,
leftClamp
.
indexOf
(
"'"
));
}
final
String
genDefaultsBinDir
=
'
$workingDirectory
/dev/tools/gen_defaults/bin'
;
final
File
file
=
File
(
path
.
join
(
genDefaultsBinDir
,
'gen_defaults.dart'
));
final
List
<
String
>
lines
=
file
.
readAsLinesSync
();
final
String
materialDirPath
=
getMaterialDirPath
(
lines
);
bool
atLeastOneTargetLineExists
=
false
;
for
(
final
String
line
in
lines
)
{
if
(
line
.
contains
(
'updateFile();'
))
{
atLeastOneTargetLineExists
=
true
;
final
String
fileName
=
getFileName
(
line
);
final
String
filePath
=
path
.
join
(
materialDirPath
,
fileName
);
final
File
file
=
File
(
filePath
);
if
(!
file
.
existsSync
())
{
errors
.
add
(
'file
$filePath
does not exist.'
);
}
}
}
assert
(
atLeastOneTargetLineExists
,
'No lines exist that this test expects to '
'verify. Check if the target file is correct or remove this test'
);
// Fail if any errors
if
(
errors
.
isNotEmpty
)
{
final
String
s
=
errors
.
length
>
1
?
's'
:
''
;
final
String
itThem
=
errors
.
length
>
1
?
'them'
:
'it'
;
foundError
(<
String
>[
...
errors
,
'
${bold}
Please correct the file name
$s
or remove
$itThem
from /dev/tools/gen_defaults/bin/gen_defaults.dart
$reset
'
,
]);
}
}
/// Verify tool test files end in `_test.dart`.
///
/// The test runner will only recognize files ending in `_test.dart` as tests to
...
...
dev/tools/gen_defaults/bin/gen_defaults.dart
View file @
e2ab3e58
...
...
@@ -17,17 +17,17 @@
import
'dart:convert'
;
import
'dart:io'
;
import
'package:gen_defaults/action_chip_template.dart'
;
import
'package:gen_defaults/app_bar_template.dart'
;
import
'package:gen_defaults/banner_template.dart'
;
import
'package:gen_defaults/button_template.dart'
;
import
'package:gen_defaults/card_template.dart'
;
import
'package:gen_defaults/checkbox_template.dart'
;
import
'package:gen_defaults/chip_action_template.dart'
;
import
'package:gen_defaults/chip_filter_template.dart'
;
import
'package:gen_defaults/chip_input_template.dart'
;
import
'package:gen_defaults/dialog_template.dart'
;
import
'package:gen_defaults/fab_template.dart'
;
import
'package:gen_defaults/filter_chip_template.dart'
;
import
'package:gen_defaults/icon_button_template.dart'
;
import
'package:gen_defaults/input_chip_template.dart'
;
import
'package:gen_defaults/input_decorator_template.dart'
;
import
'package:gen_defaults/navigation_bar_template.dart'
;
import
'package:gen_defaults/navigation_rail_template.dart'
;
...
...
@@ -104,6 +104,7 @@ Future<void> main(List<String> args) async {
tokens
[
'colorsLight'
]
=
_readTokenFile
(
'color_light.json'
);
tokens
[
'colorsDark'
]
=
_readTokenFile
(
'color_dark.json'
);
ActionChipTemplate
(
'ActionChip'
,
'
$materialLib
/action_chip.dart'
,
tokens
).
updateFile
();
AppBarTemplate
(
'AppBar'
,
'
$materialLib
/app_bar.dart'
,
tokens
).
updateFile
();
BannerTemplate
(
'Banner'
,
'
$materialLib
/banner.dart'
,
tokens
).
updateFile
();
ButtonTemplate
(
'md.comp.elevated-button'
,
'ElevatedButton'
,
'
$materialLib
/elevated_button.dart'
,
tokens
).
updateFile
();
...
...
@@ -113,13 +114,12 @@ Future<void> main(List<String> args) async {
ButtonTemplate
(
'md.comp.text-button'
,
'TextButton'
,
'
$materialLib
/text_button.dart'
,
tokens
).
updateFile
();
CardTemplate
(
'Card'
,
'
$materialLib
/card.dart'
,
tokens
).
updateFile
();
CheckboxTemplate
(
'Checkbox'
,
'
$materialLib
/checkbox.dart'
,
tokens
).
updateFile
();
ChipActionTemplate
(
'ActionChip'
,
'
$materialLib
/action_chip.dart'
,
tokens
).
updateFile
();
ChipFilterTemplate
(
'FilterChip'
,
'
$materialLib
/filter_chip.dart'
,
tokens
).
updateFile
();
ChipFilterTemplate
(
'FilterChip'
,
'
$materialLib
/choice_chip.dart'
,
tokens
).
updateFile
();
ChipInputTemplate
(
'InputChip'
,
'
$materialLib
/input_chip.dart'
,
tokens
).
updateFile
();
DialogTemplate
(
'Dialog'
,
'
$materialLib
/dialog.dart'
,
tokens
).
updateFile
();
FABTemplate
(
'FAB'
,
'
$materialLib
/floating_action_button.dart'
,
tokens
).
updateFile
();
FilterChipTemplate
(
'ChoiceChip'
,
'
$materialLib
/choice_chip.dart'
,
tokens
).
updateFile
();
FilterChipTemplate
(
'FilterChip'
,
'
$materialLib
/filter_chip.dart'
,
tokens
).
updateFile
();
IconButtonTemplate
(
'IconButton'
,
'
$materialLib
/icon_button.dart'
,
tokens
).
updateFile
();
InputChipTemplate
(
'InputChip'
,
'
$materialLib
/input_chip.dart'
,
tokens
).
updateFile
();
InputDecoratorTemplate
(
'InputDecorator'
,
'
$materialLib
/input_decorator.dart'
,
tokens
).
updateFile
();
NavigationBarTemplate
(
'NavigationBar'
,
'
$materialLib
/navigation_bar.dart'
,
tokens
).
updateFile
();
NavigationRailTemplate
(
'NavigationRail'
,
'
$materialLib
/navigation_rail.dart'
,
tokens
).
updateFile
();
...
...
dev/tools/gen_defaults/lib/
chip_action
_template.dart
→
dev/tools/gen_defaults/lib/
action_chip
_template.dart
View file @
e2ab3e58
...
...
@@ -4,9 +4,9 @@
import
'template.dart'
;
class
ChipAction
Template
extends
TokenTemplate
{
class
ActionChip
Template
extends
TokenTemplate
{
const
ChipAction
Template
(
super
.
blockName
,
super
.
fileName
,
super
.
tokens
);
const
ActionChip
Template
(
super
.
blockName
,
super
.
fileName
,
super
.
tokens
);
static
const
String
tokenGroup
=
'md.comp.assist-chip'
;
static
const
String
variant
=
'.flat'
;
...
...
dev/tools/gen_defaults/lib/
chip_filter
_template.dart
→
dev/tools/gen_defaults/lib/
filter_chip
_template.dart
View file @
e2ab3e58
...
...
@@ -4,8 +4,8 @@
import
'template.dart'
;
class
ChipFilter
Template
extends
TokenTemplate
{
const
ChipFilter
Template
(
super
.
blockName
,
super
.
fileName
,
super
.
tokens
);
class
FilterChip
Template
extends
TokenTemplate
{
const
FilterChip
Template
(
super
.
blockName
,
super
.
fileName
,
super
.
tokens
);
static
const
String
tokenGroup
=
'md.comp.filter-chip'
;
static
const
String
variant
=
'.flat'
;
...
...
dev/tools/gen_defaults/lib/
chip_input
_template.dart
→
dev/tools/gen_defaults/lib/
input_chip
_template.dart
View file @
e2ab3e58
...
...
@@ -4,8 +4,8 @@
import
'template.dart'
;
class
ChipInput
Template
extends
TokenTemplate
{
const
ChipInput
Template
(
super
.
blockName
,
super
.
fileName
,
super
.
tokens
);
class
InputChip
Template
extends
TokenTemplate
{
const
InputChip
Template
(
super
.
blockName
,
super
.
fileName
,
super
.
tokens
);
static
const
String
tokenGroup
=
'md.comp.input-chip'
;
static
const
String
variant
=
''
;
...
...
packages/flutter/test/material/
chip_action
_test.dart
→
packages/flutter/test/material/
action_chip
_test.dart
View file @
e2ab3e58
File moved
packages/flutter/test/material/ch
ip_choice
_test.dart
→
packages/flutter/test/material/ch
oice_chip
_test.dart
View file @
e2ab3e58
File moved
packages/flutter/test/material/
chip_filter
_test.dart
→
packages/flutter/test/material/
filter_chip
_test.dart
View file @
e2ab3e58
File moved
packages/flutter/test/material/
chip_input
_test.dart
→
packages/flutter/test/material/
input_chip
_test.dart
View file @
e2ab3e58
File moved
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment