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
d4c77f31
Unverified
Commit
d4c77f31
authored
Jan 07, 2021
by
Ferhat
Committed by
GitHub
Jan 07, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[web] Switch flutter tool web-renderer default for web to auto (#73502)
parent
705811fe
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
95 additions
and
55 deletions
+95
-55
flutter_command.dart
packages/flutter_tools/lib/src/runner/flutter_command.dart
+2
-2
build_web_test.dart
...er_tools/test/commands.shard/hermetic/build_web_test.dart
+93
-53
No files found.
packages/flutter_tools/lib/src/runner/flutter_command.dart
View file @
d4c77f31
...
@@ -461,7 +461,7 @@ abstract class FlutterCommand extends Command<void> {
...
@@ -461,7 +461,7 @@ abstract class FlutterCommand extends Command<void> {
void
usesWebRendererOption
()
{
void
usesWebRendererOption
()
{
argParser
.
addOption
(
'web-renderer'
,
argParser
.
addOption
(
'web-renderer'
,
defaultsTo:
'
html
'
,
defaultsTo:
'
auto
'
,
allowed:
<
String
>[
'auto'
,
'canvaskit'
,
'html'
],
allowed:
<
String
>[
'auto'
,
'canvaskit'
,
'html'
],
help:
'The renderer implementation to use when building for the web. Possible values are:
\n
'
help:
'The renderer implementation to use when building for the web. Possible values are:
\n
'
'html - always use the HTML renderer. This renderer uses a combination of HTML, CSS, SVG, 2D Canvas, and WebGL. This is the default.
\n
'
'html - always use the HTML renderer. This renderer uses a combination of HTML, CSS, SVG, 2D Canvas, and WebGL. This is the default.
\n
'
...
@@ -902,7 +902,7 @@ abstract class FlutterCommand extends Command<void> {
...
@@ -902,7 +902,7 @@ abstract class FlutterCommand extends Command<void> {
?
stringsArg
(
FlutterOptions
.
kDartDefinesOption
)
?
stringsArg
(
FlutterOptions
.
kDartDefinesOption
)
:
<
String
>[];
:
<
String
>[];
if
(
argParser
.
options
.
containsKey
(
'web-renderer'
)
&&
argResults
.
wasParsed
(
'web-renderer'
)
)
{
if
(
argParser
.
options
.
containsKey
(
'web-renderer'
))
{
dartDefines
=
updateDartDefines
(
dartDefines
,
stringArg
(
'web-renderer'
));
dartDefines
=
updateDartDefines
(
dartDefines
,
stringArg
(
'web-renderer'
));
}
}
...
...
packages/flutter_tools/test/commands.shard/hermetic/build_web_test.dart
View file @
d4c77f31
...
@@ -11,6 +11,7 @@ import 'package:flutter_tools/src/build_system/build_system.dart';
...
@@ -11,6 +11,7 @@ import 'package:flutter_tools/src/build_system/build_system.dart';
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/commands/build.dart'
;
import
'package:flutter_tools/src/commands/build.dart'
;
import
'package:flutter_tools/src/commands/build_web.dart'
;
import
'package:flutter_tools/src/commands/build_web.dart'
;
import
'package:flutter_tools/src/runner/flutter_command.dart'
;
import
'package:flutter_tools/src/dart/pub.dart'
;
import
'package:flutter_tools/src/dart/pub.dart'
;
import
'package:flutter_tools/src/features.dart'
;
import
'package:flutter_tools/src/features.dart'
;
import
'package:flutter_tools/src/globals.dart'
as
globals
;
import
'package:flutter_tools/src/globals.dart'
as
globals
;
...
@@ -97,59 +98,7 @@ void main() {
...
@@ -97,59 +98,7 @@ void main() {
testUsingContext
(
'Builds a web bundle - end to end'
,
()
async
{
testUsingContext
(
'Builds a web bundle - end to end'
,
()
async
{
final
BuildCommand
buildCommand
=
BuildCommand
();
final
BuildCommand
buildCommand
=
BuildCommand
();
final
CommandRunner
<
void
>
runner
=
createTestCommandRunner
(
buildCommand
);
final
CommandRunner
<
void
>
runner
=
createTestCommandRunner
(
buildCommand
);
final
List
<
String
>
dependencies
=
<
String
>[
setupFileSystemForEndToEndTest
(
fileSystem
);
fileSystem
.
path
.
join
(
'packages'
,
'flutter_tools'
,
'lib'
,
'src'
,
'build_system'
,
'targets'
,
'web.dart'
),
fileSystem
.
path
.
join
(
'bin'
,
'cache'
,
'flutter_web_sdk'
),
fileSystem
.
path
.
join
(
'bin'
,
'cache'
,
'dart-sdk'
,
'bin'
,
'snapshots'
,
'dart2js.dart.snapshot'
),
fileSystem
.
path
.
join
(
'bin'
,
'cache'
,
'dart-sdk'
,
'bin'
,
'dart'
),
fileSystem
.
path
.
join
(
'bin'
,
'cache'
,
'dart-sdk '
),
];
for
(
final
String
dependency
in
dependencies
)
{
fileSystem
.
file
(
dependency
).
createSync
(
recursive:
true
);
}
// Project files.
fileSystem
.
file
(
'.packages'
)
.
writeAsStringSync
(
'''
foo:lib/
fizz:bar/lib/
'''
);
fileSystem
.
file
(
'pubspec.yaml'
)
.
writeAsStringSync
(
'''
name: foo
dependencies:
flutter:
sdk: flutter
fizz:
path:
bar/
'''
);
fileSystem
.
file
(
fileSystem
.
path
.
join
(
'bar'
,
'pubspec.yaml'
))
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
'''
name: bar
flutter:
plugin:
platforms:
web:
pluginClass: UrlLauncherPlugin
fileName: url_launcher_web.dart
'''
);
fileSystem
.
file
(
fileSystem
.
path
.
join
(
'bar'
,
'lib'
,
'url_launcher_web.dart'
))
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
'''
class UrlLauncherPlugin {}
'''
);
fileSystem
.
file
(
fileSystem
.
path
.
join
(
'lib'
,
'main.dart'
))
.
writeAsStringSync
(
'void main() { }'
);
// Process calls. We're not testing that these invocations are correct because
// that is covered in targets/web_test.dart.
when
(
globals
.
buildSystem
.
build
(
any
,
any
)).
thenAnswer
((
Invocation
invocation
)
async
{
return
BuildResult
(
success:
true
);
});
await
runner
.
run
(<
String
>[
'build'
,
'web'
]);
await
runner
.
run
(<
String
>[
'build'
,
'web'
]);
expect
(
fileSystem
.
file
(
fileSystem
.
path
.
join
(
'lib'
,
'generated_plugin_registrant.dart'
)).
existsSync
(),
true
);
expect
(
fileSystem
.
file
(
fileSystem
.
path
.
join
(
'lib'
,
'generated_plugin_registrant.dart'
)).
existsSync
(),
true
);
...
@@ -181,7 +130,98 @@ class UrlLauncherPlugin {}
...
@@ -181,7 +130,98 @@ class UrlLauncherPlugin {}
Pub:
()
=>
MockPub
(),
Pub:
()
=>
MockPub
(),
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
});
});
testUsingContext
(
'Defaults to web renderer auto mode when no option is specified'
,
()
async
{
final
TestWebBuildCommand
buildCommand
=
TestWebBuildCommand
();
final
CommandRunner
<
void
>
runner
=
createTestCommandRunner
(
buildCommand
);
setupFileSystemForEndToEndTest
(
fileSystem
);
await
runner
.
run
(<
String
>[
'build'
,
'web'
]);
final
BuildInfo
buildInfo
=
await
buildCommand
.
webCommand
.
getBuildInfo
(
forcedBuildMode:
BuildMode
.
debug
);
expect
(
buildInfo
.
dartDefines
,
contains
(
'FLUTTER_WEB_AUTO_DETECT=true'
));
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
fakePlatform
,
FileSystem:
()
=>
fileSystem
,
FeatureFlags:
()
=>
TestFeatureFlags
(
isWebEnabled:
true
),
Pub:
()
=>
MockPub
(),
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
BuildSystem:
()
=>
MockBuildSystem
(),
});
}
void
setupFileSystemForEndToEndTest
(
FileSystem
fileSystem
)
{
final
List
<
String
>
dependencies
=
<
String
>[
fileSystem
.
path
.
join
(
'packages'
,
'flutter_tools'
,
'lib'
,
'src'
,
'build_system'
,
'targets'
,
'web.dart'
),
fileSystem
.
path
.
join
(
'bin'
,
'cache'
,
'flutter_web_sdk'
),
fileSystem
.
path
.
join
(
'bin'
,
'cache'
,
'dart-sdk'
,
'bin'
,
'snapshots'
,
'dart2js.dart.snapshot'
),
fileSystem
.
path
.
join
(
'bin'
,
'cache'
,
'dart-sdk'
,
'bin'
,
'dart'
),
fileSystem
.
path
.
join
(
'bin'
,
'cache'
,
'dart-sdk '
),
];
for
(
final
String
dependency
in
dependencies
)
{
fileSystem
.
file
(
dependency
).
createSync
(
recursive:
true
);
}
// Project files.
fileSystem
.
file
(
'.packages'
)
.
writeAsStringSync
(
'''
foo:lib/
fizz:bar/lib/
'''
);
fileSystem
.
file
(
'pubspec.yaml'
)
.
writeAsStringSync
(
'''
name: foo
dependencies:
flutter:
sdk: flutter
fizz:
path:
bar/
'''
);
fileSystem
.
file
(
fileSystem
.
path
.
join
(
'bar'
,
'pubspec.yaml'
))
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
'''
name: bar
flutter:
plugin:
platforms:
web:
pluginClass: UrlLauncherPlugin
fileName: url_launcher_web.dart
'''
);
fileSystem
.
file
(
fileSystem
.
path
.
join
(
'bar'
,
'lib'
,
'url_launcher_web.dart'
))
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
'''
class UrlLauncherPlugin {}
'''
);
fileSystem
.
file
(
fileSystem
.
path
.
join
(
'lib'
,
'main.dart'
))
.
writeAsStringSync
(
'void main() { }'
);
// Process calls. We're not testing that these invocations are correct because
// that is covered in targets/web_test.dart.
when
(
globals
.
buildSystem
.
build
(
any
,
any
)).
thenAnswer
((
Invocation
invocation
)
async
{
return
BuildResult
(
success:
true
);
});
}
}
class
MockBuildSystem
extends
Mock
implements
BuildSystem
{}
class
MockBuildSystem
extends
Mock
implements
BuildSystem
{}
class
MockPub
extends
Mock
implements
Pub
{}
class
MockPub
extends
Mock
implements
Pub
{}
class
TestWebBuildCommand
extends
FlutterCommand
{
TestWebBuildCommand
({
bool
verboseHelp
=
false
})
:
webCommand
=
BuildWebCommand
(
verboseHelp:
verboseHelp
)
{
addSubcommand
(
webCommand
);
}
final
BuildWebCommand
webCommand
;
@override
final
String
name
=
'build'
;
@override
final
String
description
=
'Build a test executable app.'
;
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
=>
null
;
}
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