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
0508a1de
Unverified
Commit
0508a1de
authored
Aug 31, 2022
by
Tae Hyung Kim
Committed by
GitHub
Aug 31, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] Generate Localizations on `flutter run` for web (#110526)
parent
34a62848
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
105 additions
and
0 deletions
+105
-0
resident_web_runner.dart
...s/flutter_tools/lib/src/isolated/resident_web_runner.dart
+1
-0
resident_runner_test.dart
...lutter_tools/test/general.shard/resident_runner_test.dart
+41
-0
resident_web_runner_test.dart
...er_tools/test/general.shard/resident_web_runner_test.dart
+63
-0
No files found.
packages/flutter_tools/lib/src/isolated/resident_web_runner.dart
View file @
0508a1de
...
...
@@ -280,6 +280,7 @@ class ResidentWebRunner extends ResidentRunner {
);
final
Uri
url
=
await
device
!.
devFS
!.
create
();
if
(
debuggingOptions
.
buildInfo
.
isDebug
)
{
await
runSourceGenerators
();
final
UpdateFSReport
report
=
await
_updateDevFS
(
fullRestart:
true
);
if
(!
report
.
success
)
{
_logger
!.
printError
(
'Failed to compile application.'
);
...
...
packages/flutter_tools/test/general.shard/resident_runner_test.dart
View file @
0508a1de
...
...
@@ -1388,6 +1388,47 @@ flutter:
expect
(
testLogger
.
statusText
,
isEmpty
);
}));
testUsingContext
(
'ResidentRunner generates files when l10n.yaml exists'
,
()
=>
testbed
.
run
(()
async
{
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'lib'
,
'main.dart'
))
.
createSync
(
recursive:
true
);
final
File
arbFile
=
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'lib'
,
'l10n'
,
'app_en.arb'
))
..
createSync
(
recursive:
true
);
arbFile
.
writeAsStringSync
(
'''
{
"helloWorld": "Hello, World!",
"@helloWorld": {
"description": "Sample description"
}
}'''
);
globals
.
fs
.
file
(
'l10n.yaml'
).
createSync
();
globals
.
fs
.
file
(
'pubspec.yaml'
).
writeAsStringSync
(
'flutter:
\n
generate: true
\n
'
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]);
final
FakeResidentCompiler
residentCompiler
=
FakeResidentCompiler
()
..
nextOutput
=
const
CompilerOutput
(
'foo'
,
1
,<
Uri
>[]);
residentRunner
=
HotRunner
(
<
FlutterDevice
>[
flutterDevice
,
],
stayResident:
false
,
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
),
target:
'main.dart'
,
devtoolsHandler:
createNoOpHandler
,
);
flutterDevice
.
generator
=
residentCompiler
;
await
residentRunner
.
run
();
final
File
generatedLocalizationsFile
=
globals
.
fs
.
directory
(
'.dart_tool'
)
.
childDirectory
(
'flutter_gen'
)
.
childDirectory
(
'gen_l10n'
)
.
childFile
(
'app_localizations.dart'
);
expect
(
generatedLocalizationsFile
.
existsSync
(),
isTrue
);
// Completing this future ensures that the daemon can exit correctly.
expect
(
await
residentRunner
.
waitForAppToFinish
(),
1
);
}));
testUsingContext
(
'ResidentRunner printHelpDetails hot runner'
,
()
=>
testbed
.
run
(()
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]);
...
...
packages/flutter_tools/test/general.shard/resident_web_runner_test.dart
View file @
0508a1de
...
...
@@ -1049,6 +1049,69 @@ void main() {
ProcessManager:
()
=>
processManager
,
});
testUsingContext
(
'ResidentWebRunner generates files when l10n.yaml exists'
,
()
async
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
kAttachExpectations
.
toList
());
setupMocks
();
final
ResidentRunner
residentWebRunner
=
ResidentWebRunner
(
flutterDevice
,
flutterProject:
FlutterProject
.
fromDirectoryTest
(
fileSystem
.
currentDirectory
),
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
),
ipv6:
true
,
stayResident:
false
,
fileSystem:
fileSystem
,
logger:
BufferLogger
.
test
(),
usage:
globals
.
flutterUsage
,
systemClock:
globals
.
systemClock
,
);
// Create necessary files.
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'lib'
,
'main.dart'
))
.
createSync
(
recursive:
true
);
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'lib'
,
'l10n'
,
'app_en.arb'
))
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
'''
{
"helloWorld": "Hello, World!",
"@helloWorld": {
"description": "Sample description"
}
}'''
);
globals
.
fs
.
file
(
'l10n.yaml'
).
createSync
();
globals
.
fs
.
file
(
'pubspec.yaml'
).
writeAsStringSync
(
'''
flutter:
generate: true
'''
);
globals
.
fs
.
directory
(
'.dart_tool'
)
.
childFile
(
'package_config.json'
)
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
'''
{
"configVersion": 2,
"packages": [
{
"name": "path_provider_linux",
"rootUri": "../../../path_provider_linux",
"packageUri": "lib/",
"languageVersion": "2.12"
}
]
}
'''
);
expect
(
await
residentWebRunner
.
run
(),
0
);
final
File
generatedLocalizationsFile
=
globals
.
fs
.
directory
(
'.dart_tool'
)
.
childDirectory
(
'flutter_gen'
)
.
childDirectory
(
'gen_l10n'
)
.
childFile
(
'app_localizations.dart'
);
expect
(
generatedLocalizationsFile
.
existsSync
(),
isTrue
);
// Completing this future ensures that the daemon can exit correctly.
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
});
// While this file should be ignored on web, generating it here will cause a
// perf regression in hot restart.
testUsingContext
(
'Does not generate dart_plugin_registrant.dart'
,
()
async
{
...
...
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