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
d39d4505
Unverified
Commit
d39d4505
authored
Mar 08, 2021
by
Jonah Williams
Committed by
GitHub
Mar 08, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] remove most globals from resident web runner (#77432)
parent
85e2c52b
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
265 additions
and
263 deletions
+265
-263
file_system.dart
packages/flutter_tools/lib/src/base/file_system.dart
+7
-7
logger.dart
packages/flutter_tools/lib/src/base/logger.dart
+21
-23
daemon.dart
packages/flutter_tools/lib/src/commands/daemon.dart
+4
-0
run.dart
packages/flutter_tools/lib/src/commands/run.dart
+4
-0
web_driver_service.dart
packages/flutter_tools/lib/src/drive/web_driver_service.dart
+4
-0
resident_web_runner.dart
...s/flutter_tools/lib/src/isolated/resident_web_runner.dart
+73
-70
resident_runner.dart
packages/flutter_tools/lib/src/resident_runner.dart
+2
-2
web_runner.dart
packages/flutter_tools/lib/src/web/web_runner.dart
+8
-0
attach_test.dart
...utter_tools/test/commands.shard/hermetic/attach_test.dart
+3
-0
resident_web_runner_cold_test.dart
...ols/test/general.shard/resident_web_runner_cold_test.dart
+7
-2
resident_web_runner_test.dart
...er_tools/test/general.shard/resident_web_runner_test.dart
+132
-159
No files found.
packages/flutter_tools/lib/src/base/file_system.dart
View file @
d39d4505
...
...
@@ -73,13 +73,6 @@ class FileSystemUtils {
}
}
/// Return a relative path if [fullPath] is contained by the cwd, else return an
/// absolute path.
String
getDisplayPath
(
String
fullPath
)
{
final
String
cwd
=
_fileSystem
.
currentDirectory
.
path
+
_fileSystem
.
path
.
separator
;
return
fullPath
.
startsWith
(
cwd
)
?
fullPath
.
substring
(
cwd
.
length
)
:
fullPath
;
}
/// Escapes [path].
///
/// On Windows it replaces all '\' with '\\'. On other platforms, it returns the
...
...
@@ -115,6 +108,13 @@ class FileSystemUtils {
}
}
/// Return a relative path if [fullPath] is contained by the cwd, else return an
/// absolute path.
String
getDisplayPath
(
String
fullPath
,
FileSystem
fileSystem
)
{
final
String
cwd
=
fileSystem
.
currentDirectory
.
path
+
fileSystem
.
path
.
separator
;
return
fullPath
.
startsWith
(
cwd
)
?
fullPath
.
substring
(
cwd
.
length
)
:
fullPath
;
}
/// Creates `destDir` if needed, then recursively copies `srcDir` to
/// `destDir`, invoking [onFileCopied], if specified, for each
/// source/destination file pair.
...
...
packages/flutter_tools/lib/src/base/logger.dart
View file @
d39d4505
...
...
@@ -11,7 +11,7 @@ import 'package:meta/meta.dart';
import
'../convert.dart'
;
import
'../globals.dart'
as
globals
;
import
'io.dart'
;
import
'terminal.dart'
show
AnsiTerminal
,
Terminal
,
TerminalColor
,
OutputPreferences
;
import
'terminal.dart'
show
Terminal
,
TerminalColor
,
OutputPreferences
;
import
'utils.dart'
;
const
int
kDefaultStatusPadding
=
59
;
...
...
@@ -36,7 +36,7 @@ abstract class Logger {
bool
get
hasTerminal
;
Terminal
get
_
terminal
;
Terminal
get
terminal
;
OutputPreferences
get
_outputPreferences
;
...
...
@@ -162,7 +162,7 @@ class DelegatingLogger implements Logger {
bool
get
hasTerminal
=>
_delegate
.
hasTerminal
;
@override
Terminal
get
_terminal
=>
_delegate
.
_
terminal
;
Terminal
get
terminal
=>
_delegate
.
terminal
;
@override
OutputPreferences
get
_outputPreferences
=>
_delegate
.
_outputPreferences
;
...
...
@@ -241,18 +241,17 @@ T asLogger<T extends Logger>(Logger logger) {
class
StdoutLogger
extends
Logger
{
StdoutLogger
({
@required
Terminal
terminal
,
@required
this
.
terminal
,
@required
Stdio
stdio
,
@required
OutputPreferences
outputPreferences
,
StopwatchFactory
stopwatchFactory
=
const
StopwatchFactory
(),
})
:
_stdio
=
stdio
,
_terminal
=
terminal
,
_outputPreferences
=
outputPreferences
,
_stopwatchFactory
=
stopwatchFactory
;
@override
final
Terminal
_
terminal
;
final
Terminal
terminal
;
@override
final
OutputPreferences
_outputPreferences
;
final
Stdio
_stdio
;
...
...
@@ -264,7 +263,7 @@ class StdoutLogger extends Logger {
bool
get
isVerbose
=>
false
;
@override
bool
get
supportsColor
=>
_
terminal
.
supportsColor
;
bool
get
supportsColor
=>
terminal
.
supportsColor
;
@override
bool
get
hasTerminal
=>
_stdio
.
stdinHasTerminal
;
...
...
@@ -288,9 +287,9 @@ class StdoutLogger extends Logger {
columnWidth:
_outputPreferences
.
wrapColumn
,
);
if
(
emphasis
==
true
)
{
message
=
_
terminal
.
bolden
(
message
);
message
=
terminal
.
bolden
(
message
);
}
message
=
_
terminal
.
color
(
message
,
color
??
TerminalColor
.
red
);
message
=
terminal
.
color
(
message
,
color
??
TerminalColor
.
red
);
writeToStdErr
(
'
$message
\n
'
);
if
(
stackTrace
!=
null
)
{
writeToStdErr
(
'
$stackTrace
\n
'
);
...
...
@@ -317,10 +316,10 @@ class StdoutLogger extends Logger {
columnWidth:
_outputPreferences
.
wrapColumn
,
);
if
(
emphasis
==
true
)
{
message
=
_
terminal
.
bolden
(
message
);
message
=
terminal
.
bolden
(
message
);
}
if
(
color
!=
null
)
{
message
=
_
terminal
.
color
(
message
,
color
);
message
=
terminal
.
color
(
message
,
color
);
}
if
(
newline
!=
false
)
{
message
=
'
$message
\n
'
;
...
...
@@ -361,7 +360,7 @@ class StdoutLogger extends Logger {
onFinish:
_clearStatus
,
stdio:
_stdio
,
stopwatch:
_stopwatchFactory
.
createStopwatch
(),
terminal:
_
terminal
,
terminal:
terminal
,
)..
start
();
}
else
{
_status
=
SummaryStatus
(
...
...
@@ -385,7 +384,7 @@ class StdoutLogger extends Logger {
@override
void
clear
()
{
_status
?.
pause
();
writeToStdOut
(
_
terminal
.
clearScreen
()
+
'
\n
'
);
writeToStdOut
(
terminal
.
clearScreen
()
+
'
\n
'
);
_status
?.
resume
();
}
}
...
...
@@ -413,7 +412,7 @@ class WindowsStdoutLogger extends StdoutLogger {
@override
void
writeToStdOut
(
String
message
)
{
final
String
windowsMessage
=
_
terminal
.
supportsEmoji
final
String
windowsMessage
=
terminal
.
supportsEmoji
?
message
:
message
.
replaceAll
(
'🔥'
,
''
)
.
replaceAll
(
'🖼️'
,
''
)
...
...
@@ -428,18 +427,17 @@ class WindowsStdoutLogger extends StdoutLogger {
class
BufferLogger
extends
Logger
{
BufferLogger
({
@required
AnsiTerminal
terminal
,
@required
this
.
terminal
,
@required
OutputPreferences
outputPreferences
,
StopwatchFactory
stopwatchFactory
=
const
StopwatchFactory
(),
})
:
_outputPreferences
=
outputPreferences
,
_terminal
=
terminal
,
_stopwatchFactory
=
stopwatchFactory
;
/// Create a [BufferLogger] with test preferences.
BufferLogger
.
test
({
Terminal
terminal
,
OutputPreferences
outputPreferences
,
})
:
_
terminal
=
terminal
??
Terminal
.
test
(),
})
:
terminal
=
terminal
??
Terminal
.
test
(),
_outputPreferences
=
outputPreferences
??
OutputPreferences
.
test
(),
_stopwatchFactory
=
const
StopwatchFactory
();
...
...
@@ -448,7 +446,7 @@ class BufferLogger extends Logger {
final
OutputPreferences
_outputPreferences
;
@override
final
Terminal
_
terminal
;
final
Terminal
terminal
;
final
StopwatchFactory
_stopwatchFactory
;
...
...
@@ -456,7 +454,7 @@ class BufferLogger extends Logger {
bool
get
isVerbose
=>
false
;
@override
bool
get
supportsColor
=>
_
terminal
.
supportsColor
;
bool
get
supportsColor
=>
terminal
.
supportsColor
;
final
StringBuffer
_error
=
StringBuffer
();
final
StringBuffer
_status
=
StringBuffer
();
...
...
@@ -481,7 +479,7 @@ class BufferLogger extends Logger {
int
hangingIndent
,
bool
wrap
,
})
{
_error
.
writeln
(
_
terminal
.
color
(
_error
.
writeln
(
terminal
.
color
(
wrapText
(
message
,
indent:
indent
,
hangingIndent:
hangingIndent
,
...
...
@@ -654,7 +652,7 @@ class VerboseLogger extends DelegatingLogger {
}
else
{
prefix
=
'+
$millis
ms'
.
padLeft
(
prefixWidth
);
if
(
millis
>=
100
)
{
prefix
=
_
terminal
.
bolden
(
prefix
);
prefix
=
terminal
.
bolden
(
prefix
);
}
}
prefix
=
'[
$prefix
] '
;
...
...
@@ -663,12 +661,12 @@ class VerboseLogger extends DelegatingLogger {
final
String
indentMessage
=
message
.
replaceAll
(
'
\n
'
,
'
\n
$indent
'
);
if
(
type
==
_LogType
.
error
)
{
super
.
printError
(
prefix
+
_
terminal
.
bolden
(
indentMessage
));
super
.
printError
(
prefix
+
terminal
.
bolden
(
indentMessage
));
if
(
stackTrace
!=
null
)
{
super
.
printError
(
indent
+
stackTrace
.
toString
().
replaceAll
(
'
\n
'
,
'
\n
$indent
'
));
}
}
else
if
(
type
==
_LogType
.
status
)
{
super
.
printStatus
(
prefix
+
_
terminal
.
bolden
(
indentMessage
));
super
.
printStatus
(
prefix
+
terminal
.
bolden
(
indentMessage
));
}
else
{
super
.
printStatus
(
prefix
+
indentMessage
);
}
...
...
packages/flutter_tools/lib/src/commands/daemon.dart
View file @
d39d4505
...
...
@@ -484,6 +484,10 @@ class AppDomain extends Domain {
stayResident:
true
,
urlTunneller:
options
.
webEnableExposeUrl
?
daemon
.
daemonDomain
.
exposeUrl
:
null
,
machine:
machine
,
usage:
globals
.
flutterUsage
,
systemClock:
globals
.
systemClock
,
logger:
globals
.
logger
,
fileSystem:
globals
.
fs
,
);
}
else
if
(
enableHotReload
)
{
runner
=
HotRunner
(
...
...
packages/flutter_tools/lib/src/commands/run.dart
View file @
d39d4505
...
...
@@ -495,6 +495,10 @@ class RunCommand extends RunCommandBase {
debuggingOptions:
await
createDebuggingOptions
(
webMode
),
stayResident:
stayResident
,
urlTunneller:
null
,
fileSystem:
globals
.
fs
,
usage:
globals
.
flutterUsage
,
logger:
globals
.
logger
,
systemClock:
globals
.
systemClock
,
);
}
return
ColdRunner
(
...
...
packages/flutter_tools/lib/src/drive/web_driver_service.dart
View file @
d39d4505
...
...
@@ -72,6 +72,10 @@ class WebDriverService extends DriverService {
stayResident:
false
,
urlTunneller:
null
,
flutterProject:
FlutterProject
.
current
(),
fileSystem:
globals
.
fs
,
usage:
globals
.
flutterUsage
,
logger:
globals
.
logger
,
systemClock:
globals
.
systemClock
,
);
final
Completer
<
void
>
appStartedCompleter
=
Completer
<
void
>.
sync
();
final
int
result
=
await
_residentRunner
.
run
(
...
...
packages/flutter_tools/lib/src/isolated/resident_web_runner.dart
View file @
d39d4505
...
...
@@ -21,6 +21,7 @@ import '../base/io.dart';
import
'../base/logger.dart'
;
import
'../base/net.dart'
;
import
'../base/terminal.dart'
;
import
'../base/time.dart'
;
import
'../base/utils.dart'
;
import
'../build_info.dart'
;
import
'../build_system/targets/web.dart'
;
...
...
@@ -28,7 +29,6 @@ import '../dart/language_version.dart';
import
'../devfs.dart'
;
import
'../device.dart'
;
import
'../features.dart'
;
import
'../globals.dart'
as
globals
;
import
'../platform_plugins.dart'
;
import
'../plugins.dart'
;
import
'../project.dart'
;
...
...
@@ -53,9 +53,14 @@ class DwdsWebRunnerFactory extends WebRunnerFactory {
@required
bool
ipv6
,
@required
DebuggingOptions
debuggingOptions
,
@required
UrlTunneller
urlTunneller
,
@required
Logger
logger
,
@required
FileSystem
fileSystem
,
@required
SystemClock
systemClock
,
@required
Usage
usage
,
@required
FeatureFlags
featureFlags
,
bool
machine
=
false
,
})
{
return
_
ResidentWebRunner
(
return
ResidentWebRunner
(
device
,
target:
target
,
flutterProject:
flutterProject
,
...
...
@@ -64,6 +69,11 @@ class DwdsWebRunnerFactory extends WebRunnerFactory {
stayResident:
stayResident
,
urlTunneller:
urlTunneller
,
machine:
machine
,
usage:
usage
,
systemClock:
systemClock
,
fileSystem:
fileSystem
,
logger:
logger
,
featureFlags:
featureFlags
,
);
}
}
...
...
@@ -72,25 +82,43 @@ const String kExitMessage = 'Failed to establish connection with the application
'instance in Chrome.
\n
This can happen if the websocket connection used by the '
'web tooling is unable to correctly establish a connection, for example due to a firewall.'
;
/// A hot-runner which handles browser specific delegation.
abstract
class
ResidentWebRunner
extends
ResidentRunner
{
class
ResidentWebRunner
extends
ResidentRunner
{
ResidentWebRunner
(
FlutterDevice
device
,
{
String
target
,
bool
stayResident
=
true
,
bool
machine
=
false
,
@required
this
.
flutterProject
,
@required
bool
ipv6
,
@required
DebuggingOptions
debuggingOptions
,
bool
stayResident
=
true
,
bool
machine
=
false
,
})
:
super
(
@required
FileSystem
fileSystem
,
@required
Logger
logger
,
@required
SystemClock
systemClock
,
@required
Usage
usage
,
@required
UrlTunneller
urlTunneller
,
@required
FeatureFlags
featureFlags
,
})
:
_fileSystem
=
fileSystem
,
_logger
=
logger
,
_systemClock
=
systemClock
,
_usage
=
usage
,
_urlTunneller
=
urlTunneller
,
_featureFlags
=
featureFlags
,
super
(
<
FlutterDevice
>[
device
],
target:
target
??
globals
.
fs
.
path
.
join
(
'lib'
,
'main.dart'
),
target:
target
??
fileSystem
.
path
.
join
(
'lib'
,
'main.dart'
),
debuggingOptions:
debuggingOptions
,
ipv6:
ipv6
,
stayResident:
stayResident
,
machine:
machine
,
);
final
FileSystem
_fileSystem
;
final
Logger
_logger
;
final
SystemClock
_systemClock
;
final
Usage
_usage
;
final
UrlTunneller
_urlTunneller
;
final
FeatureFlags
_featureFlags
;
FlutterDevice
get
device
=>
flutterDevices
.
first
;
final
FlutterProject
flutterProject
;
DateTime
firstBuildTime
;
...
...
@@ -171,7 +199,7 @@ abstract class ResidentWebRunner extends ResidentRunner {
_generatedEntrypointDirectory
?.
deleteSync
(
recursive:
true
);
}
on
FileSystemException
{
// Best effort to clean up temp dirs.
globals
.
printTrace
(
_logger
.
printTrace
(
'Failed to clean up temp directory:
${_generatedEntrypointDirectory.path}
'
,
);
}
...
...
@@ -191,15 +219,13 @@ abstract class ResidentWebRunner extends ResidentRunner {
const
String
fire
=
'🔥'
;
const
String
rawMessage
=
' To hot restart changes while running, press "r" or "R".'
;
final
String
message
=
globals
.
terminal
.
color
(
fire
+
globals
.
terminal
.
bolden
(
rawMessage
),
final
String
message
=
_logger
.
terminal
.
color
(
fire
+
_logger
.
terminal
.
bolden
(
rawMessage
),
TerminalColor
.
red
,
);
globals
.
printStatus
(
message
);
_logger
.
printStatus
(
message
);
const
String
quitMessage
=
'To quit, press "q".'
;
if
(
device
.
device
is
!
WebServerDevice
)
{
globals
.
printStatus
(
'For a more detailed help message, press "h".
$quitMessage
'
);
}
_logger
.
printStatus
(
'For a more detailed help message, press "h".
$quitMessage
'
);
}
@override
...
...
@@ -276,13 +302,13 @@ abstract class ResidentWebRunner extends ResidentRunner {
?.
flutterPlatformOverride
(
isolateId:
null
,
);
final
String
platform
=
nextPlatform
(
currentPlatform
,
featureFlags
);
final
String
platform
=
nextPlatform
(
currentPlatform
,
_
featureFlags
);
await
_vmService
?.
flutterPlatformOverride
(
platform:
platform
,
isolateId:
null
,
);
globals
.
printStatus
(
'Switched operating system to
$platform
'
);
_logger
.
printStatus
(
'Switched operating system to
$platform
'
);
}
on
vmservice
.
RPCError
{
// do nothing.
}
...
...
@@ -310,7 +336,7 @@ abstract class ResidentWebRunner extends ResidentRunner {
brightness:
next
,
isolateId:
null
,
);
globals
.
logger
.
printStatus
(
'Changed brightness to
$next
.'
);
_
logger
.
printStatus
(
'Changed brightness to
$next
.'
);
}
on
vmservice
.
RPCError
{
// do nothing.
}
...
...
@@ -434,29 +460,6 @@ abstract class ResidentWebRunner extends ResidentRunner {
}
return
true
;
}
}
class
_ResidentWebRunner
extends
ResidentWebRunner
{
_ResidentWebRunner
(
FlutterDevice
device
,
{
String
target
,
@required
FlutterProject
flutterProject
,
@required
bool
ipv6
,
@required
DebuggingOptions
debuggingOptions
,
bool
stayResident
=
true
,
@required
this
.
urlTunneller
,
bool
machine
=
false
,
})
:
super
(
device
,
flutterProject:
flutterProject
,
target:
target
??
globals
.
fs
.
path
.
join
(
'lib'
,
'main.dart'
),
debuggingOptions:
debuggingOptions
,
ipv6:
ipv6
,
stayResident:
stayResident
,
machine:
machine
,
);
final
UrlTunneller
urlTunneller
;
@override
Future
<
int
>
run
({
...
...
@@ -472,12 +475,12 @@ class _ResidentWebRunner extends ResidentWebRunner {
applicationBinary:
null
,
);
if
(
package
==
null
)
{
globals
.
printStatus
(
'This application is not configured to build on the web.'
);
globals
.
printStatus
(
'To add web support to a project, run `flutter create .`.'
);
_logger
.
printStatus
(
'This application is not configured to build on the web.'
);
_logger
.
printStatus
(
'To add web support to a project, run `flutter create .`.'
);
}
final
String
modeName
=
debuggingOptions
.
buildInfo
.
friendlyModeName
;
globals
.
printStatus
(
'Launching
${g
lobals.fsUtils.getDisplayPath(target
)}
'
_logger
.
printStatus
(
'Launching
${g
etDisplayPath(target, _fileSystem
)}
'
'on
${device.device.name}
in
$modeName
mode...'
,
);
if
(
device
.
device
is
ChromiumDevice
)
{
...
...
@@ -496,12 +499,12 @@ class _ResidentWebRunner extends ResidentWebRunner {
?
int
.
tryParse
(
debuggingOptions
.
port
)
:
null
,
packagesFilePath:
packagesFilePath
,
urlTunneller:
urlTunneller
,
urlTunneller:
_
urlTunneller
,
useSseForDebugProxy:
debuggingOptions
.
webUseSseForDebugProxy
,
useSseForDebugBackend:
debuggingOptions
.
webUseSseForDebugBackend
,
buildInfo:
debuggingOptions
.
buildInfo
,
enableDwds:
_enableDwds
,
entrypoint:
globals
.
fs
.
file
(
target
).
uri
,
entrypoint:
_fileSystem
.
file
(
target
).
uri
,
expressionCompiler:
expressionCompiler
,
chromiumLauncher:
_chromiumLauncher
,
nullAssertions:
debuggingOptions
.
nullAssertions
,
...
...
@@ -512,7 +515,7 @@ class _ResidentWebRunner extends ResidentWebRunner {
if
(
debuggingOptions
.
buildInfo
.
isDebug
)
{
final
UpdateFSReport
report
=
await
_updateDevFS
(
fullRestart:
true
);
if
(!
report
.
success
)
{
globals
.
printError
(
'Failed to compile application.'
);
_logger
.
printError
(
'Failed to compile application.'
);
appFailedToStart
();
return
1
;
}
...
...
@@ -569,8 +572,8 @@ class _ResidentWebRunner extends ResidentWebRunner {
String
reason
,
bool
benchmarkMode
=
false
,
})
async
{
final
DateTime
start
=
globals
.
systemClock
.
now
();
final
Status
status
=
globals
.
logger
.
startProgress
(
final
DateTime
start
=
_
systemClock
.
now
();
final
Status
status
=
_
logger
.
startProgress
(
'Performing hot restart...'
,
progressId:
'hot.restart'
,
);
...
...
@@ -604,7 +607,7 @@ class _ResidentWebRunner extends ResidentWebRunner {
try
{
if
(!
deviceIsDebuggable
)
{
globals
.
printStatus
(
'Recompile complete. Page requires refresh.'
);
_logger
.
printStatus
(
'Recompile complete. Page requires refresh.'
);
}
else
if
(
isRunningDebug
)
{
await
_vmService
.
service
.
callMethod
(
'hotRestart'
);
}
else
{
...
...
@@ -620,13 +623,13 @@ class _ResidentWebRunner extends ResidentWebRunner {
status
.
stop
();
}
final
Duration
elapsed
=
globals
.
systemClock
.
now
().
difference
(
start
);
final
Duration
elapsed
=
_
systemClock
.
now
().
difference
(
start
);
final
String
elapsedMS
=
getElapsedAsMilliseconds
(
elapsed
);
globals
.
printStatus
(
'Restarted application in
$elapsedMS
.'
);
_logger
.
printStatus
(
'Restarted application in
$elapsedMS
.'
);
// Don't track restart times for dart2js builds or web-server devices.
if
(
debuggingOptions
.
buildInfo
.
isDebug
&&
deviceIsDebuggable
)
{
globals
.
flutterU
sage
.
sendTiming
(
'hot'
,
'web-incremental-restart'
,
elapsed
);
_u
sage
.
sendTiming
(
'hot'
,
'web-incremental-restart'
,
elapsed
);
HotEvent
(
'restart'
,
targetPlatform:
getNameForTargetPlatform
(
TargetPlatform
.
web_javascript
),
...
...
@@ -647,7 +650,7 @@ class _ResidentWebRunner extends ResidentWebRunner {
Future
<
Uri
>
_generateEntrypoint
(
Uri
mainUri
,
PackageConfig
packageConfig
)
async
{
File
result
=
_generatedEntrypointDirectory
?.
childFile
(
'web_entrypoint.dart'
);
if
(
_generatedEntrypointDirectory
==
null
)
{
_generatedEntrypointDirectory
??=
globals
.
fs
.
systemTempDirectory
.
createTempSync
(
'flutter_tools.'
)
_generatedEntrypointDirectory
??=
_fileSystem
.
systemTempDirectory
.
createTempSync
(
'flutter_tools.'
)
..
createSync
();
result
=
_generatedEntrypointDirectory
.
childFile
(
'web_entrypoint.dart'
);
...
...
@@ -655,7 +658,7 @@ class _ResidentWebRunner extends ResidentWebRunner {
.
any
((
Plugin
p
)
=>
p
.
platforms
.
containsKey
(
WebPlugin
.
kConfigKey
));
await
injectPlugins
(
flutterProject
,
webPlatform:
true
);
final
Uri
generatedUri
=
globals
.
fs
.
currentDirectory
final
Uri
generatedUri
=
_fileSystem
.
currentDirectory
.
childDirectory
(
'lib'
)
.
childFile
(
'generated_plugin_registrant.dart'
)
.
absolute
.
uri
;
...
...
@@ -663,16 +666,16 @@ class _ResidentWebRunner extends ResidentWebRunner {
Uri
importedEntrypoint
=
packageConfig
.
toPackageUri
(
mainUri
);
// Special handling for entrypoints that are not under lib, such as test scripts.
if
(
importedEntrypoint
==
null
)
{
final
String
parent
=
globals
.
fs
.
file
(
mainUri
).
parent
.
path
;
final
String
parent
=
_fileSystem
.
file
(
mainUri
).
parent
.
path
;
flutterDevices
.
first
.
generator
.
addFileSystemRoot
(
parent
);
flutterDevices
.
first
.
generator
.
addFileSystemRoot
(
globals
.
fs
.
directory
(
'test'
).
absolute
.
path
);
flutterDevices
.
first
.
generator
.
addFileSystemRoot
(
_fileSystem
.
directory
(
'test'
).
absolute
.
path
);
importedEntrypoint
=
Uri
(
scheme:
'org-dartlang-app'
,
path:
'/'
+
mainUri
.
pathSegments
.
last
,
);
}
final
LanguageVersion
languageVersion
=
determineLanguageVersion
(
globals
.
fs
.
file
(
mainUri
),
_fileSystem
.
file
(
mainUri
),
packageConfig
[
flutterProject
.
manifest
.
appName
],
);
...
...
@@ -711,7 +714,7 @@ class _ResidentWebRunner extends ResidentWebRunner {
final
bool
isFirstUpload
=
!
assetBundle
.
wasBuiltOnce
();
final
bool
rebuildBundle
=
assetBundle
.
needsBuild
();
if
(
rebuildBundle
)
{
globals
.
printTrace
(
'Updating assets'
);
_logger
.
printTrace
(
'Updating assets'
);
final
int
result
=
await
assetBundle
.
build
(
packagesPath:
debuggingOptions
.
buildInfo
.
packagesPath
);
if
(
result
!=
0
)
{
return
UpdateFSReport
(
success:
false
);
...
...
@@ -724,12 +727,12 @@ class _ResidentWebRunner extends ResidentWebRunner {
packageConfig:
device
.
devFS
.
lastPackageConfig
??
debuggingOptions
.
buildInfo
.
packageConfig
,
);
final
Status
devFSStatus
=
globals
.
logger
.
startProgress
(
final
Status
devFSStatus
=
_
logger
.
startProgress
(
'Waiting for connection from debug service on
${device.device.name}
...'
,
);
final
UpdateFSReport
report
=
await
device
.
devFS
.
update
(
mainUri:
await
_generateEntrypoint
(
globals
.
fs
.
file
(
mainPath
).
absolute
.
uri
,
_fileSystem
.
file
(
mainPath
).
absolute
.
uri
,
invalidationResult
.
packageConfig
,
),
target:
target
,
...
...
@@ -747,7 +750,7 @@ class _ResidentWebRunner extends ResidentWebRunner {
devFSWriter:
null
,
);
devFSStatus
.
stop
();
globals
.
printTrace
(
'Synced
${getSizeAsMB(report.syncedBytes)}
.'
);
_logger
.
printTrace
(
'Synced
${getSizeAsMB(report.syncedBytes)}
.'
);
return
report
;
}
...
...
@@ -777,7 +780,7 @@ class _ResidentWebRunner extends ResidentWebRunner {
void
onLogEvent
(
vmservice
.
Event
event
)
{
final
String
message
=
processVmServiceMessage
(
event
);
globals
.
printStatus
(
message
);
_logger
.
printStatus
(
message
);
}
_stdOutSub
=
_vmService
.
service
.
onStdoutEvent
.
listen
(
onLogEvent
);
...
...
@@ -836,20 +839,20 @@ class _ResidentWebRunner extends ResidentWebRunner {
}
if
(
websocketUri
!=
null
)
{
if
(
debuggingOptions
.
vmserviceOutFile
!=
null
)
{
globals
.
fs
.
file
(
debuggingOptions
.
vmserviceOutFile
)
_fileSystem
.
file
(
debuggingOptions
.
vmserviceOutFile
)
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
websocketUri
.
toString
());
}
globals
.
printStatus
(
'Debug service listening on
$websocketUri
'
);
globals
.
printStatus
(
''
);
_logger
.
printStatus
(
'Debug service listening on
$websocketUri
'
);
_logger
.
printStatus
(
''
);
if
(
debuggingOptions
.
buildInfo
.
nullSafetyMode
==
NullSafetyMode
.
sound
)
{
globals
.
printStatus
(
'💪 Running with sound null safety 💪'
,
emphasis:
true
);
_logger
.
printStatus
(
'💪 Running with sound null safety 💪'
,
emphasis:
true
);
}
else
{
globals
.
printStatus
(
_logger
.
printStatus
(
'Running with unsound null safety'
,
emphasis:
true
,
);
globals
.
printStatus
(
_logger
.
printStatus
(
'For more information see https://dart.dev/null-safety/unsound-null-safety'
,
);
}
...
...
packages/flutter_tools/lib/src/resident_runner.dart
View file @
d39d4505
...
...
@@ -565,7 +565,7 @@ class FlutterDevice {
final
bool
prebuiltMode
=
hotRunner
.
applicationBinary
!=
null
;
final
String
modeName
=
hotRunner
.
debuggingOptions
.
buildInfo
.
friendlyModeName
;
globals
.
printStatus
(
'Launching
${g
lobals.fsUtils.getDisplayPath(hotRunner.mainPath
)}
'
'Launching
${g
etDisplayPath(hotRunner.mainPath, globals.fs
)}
'
'on
${device.name}
in
$modeName
mode...'
,
);
...
...
@@ -645,7 +645,7 @@ class FlutterDevice {
);
}
else
{
globals
.
printStatus
(
'Launching
${g
lobals.fsUtils.getDisplayPath(coldRunner.mainPath
)}
'
'Launching
${g
etDisplayPath(coldRunner.mainPath, globals.fs
)}
'
'on
${device.name}
in
$modeName
mode...'
,
);
}
...
...
packages/flutter_tools/lib/src/web/web_runner.dart
View file @
d39d4505
...
...
@@ -7,9 +7,13 @@
import
'package:meta/meta.dart'
;
import
'../base/context.dart'
;
import
'../base/file_system.dart'
;
import
'../base/logger.dart'
;
import
'../base/net.dart'
;
import
'../base/time.dart'
;
import
'../device.dart'
;
import
'../project.dart'
;
import
'../reporting/reporting.dart'
;
import
'../resident_runner.dart'
;
WebRunnerFactory
get
webRunnerFactory
=>
context
.
get
<
WebRunnerFactory
>();
...
...
@@ -27,6 +31,10 @@ abstract class WebRunnerFactory {
@required
bool
ipv6
,
@required
DebuggingOptions
debuggingOptions
,
@required
UrlTunneller
urlTunneller
,
@required
Logger
logger
,
@required
FileSystem
fileSystem
,
@required
SystemClock
systemClock
,
@required
Usage
usage
,
bool
machine
=
false
,
});
}
packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart
View file @
d39d4505
...
...
@@ -799,6 +799,9 @@ class StreamLogger extends Logger {
@override
void
clear
()
=>
_log
(
'[stdout]
${globals.terminal.clearScreen()}
\n
'
);
@override
Terminal
get
terminal
=>
Terminal
.
test
();
}
class
LoggerInterrupted
implements
Exception
{
...
...
packages/flutter_tools/test/general.shard/resident_web_runner_cold_test.dart
View file @
d39d4505
...
...
@@ -48,14 +48,19 @@ void main() {
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'lib'
,
'main.dart'
)).
createSync
(
recursive:
true
);
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'web'
,
'index.html'
)).
createSync
(
recursive:
true
);
final
FlutterProject
project
=
FlutterProject
.
fromDirectoryTest
(
globals
.
fs
.
currentDirectory
);
residentWebRunner
=
DwdsWebRunnerFactory
().
create
WebRunner
(
residentWebRunner
=
Resident
WebRunner
(
mockFlutterDevice
,
flutterProject:
project
,
debuggingOptions:
DebuggingOptions
.
disabled
(
BuildInfo
.
release
),
ipv6:
true
,
stayResident:
true
,
urlTunneller:
null
,
)
as
ResidentWebRunner
;
featureFlags:
TestFeatureFlags
(),
fileSystem:
globals
.
fs
,
logger:
globals
.
logger
,
systemClock:
globals
.
systemClock
,
usage:
globals
.
flutterUsage
,
);
}
testUsingContext
(
'Can successfully run and connect without vmservice'
,
()
async
{
...
...
packages/flutter_tools/test/general.shard/resident_web_runner_test.dart
View file @
d39d4505
...
...
@@ -14,13 +14,11 @@ import 'package:flutter_tools/src/base/common.dart';
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/base/terminal.dart'
;
import
'package:flutter_tools/src/base/time.dart'
;
import
'package:flutter_tools/src/build_info.dart'
;
import
'package:flutter_tools/src/isolated/devfs_web.dart'
;
import
'package:flutter_tools/src/isolated/resident_web_runner.dart'
;
import
'package:flutter_tools/src/compile.dart'
;
import
'package:flutter_tools/src/dart/pub.dart'
;
import
'package:flutter_tools/src/devfs.dart'
;
import
'package:flutter_tools/src/device.dart'
;
import
'package:flutter_tools/src/globals.dart'
as
globals
;
...
...
@@ -169,14 +167,19 @@ void main() {
logger:
BufferLogger
.
test
(),
));
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]);
final
ResidentRunner
profileResidentWebRunner
=
DwdsWebRunnerFactory
().
create
WebRunner
(
final
ResidentRunner
profileResidentWebRunner
=
Resident
WebRunner
(
mockFlutterDevice
,
flutterProject:
FlutterProject
.
fromDirectoryTest
(
fileSystem
.
currentDirectory
),
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
),
ipv6:
true
,
stayResident:
true
,
urlTunneller:
null
,
)
as
ResidentWebRunner
;
fileSystem:
fileSystem
,
logger:
BufferLogger
.
test
(),
usage:
globals
.
flutterUsage
,
featureFlags:
TestFeatureFlags
(),
systemClock:
globals
.
systemClock
,
);
expect
(
profileResidentWebRunner
.
debuggingEnabled
,
false
);
...
...
@@ -187,8 +190,6 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
testUsingContext
(
'runner with web server device supports debugging with --start-paused'
,
()
{
...
...
@@ -200,13 +201,18 @@ void main() {
when
(
mockFlutterDevice
.
device
).
thenReturn
(
WebServerDevice
(
logger:
BufferLogger
.
test
(),
));
final
ResidentRunner
profileResidentWebRunner
=
DwdsWebRunnerFactory
().
create
WebRunner
(
final
ResidentRunner
profileResidentWebRunner
=
Resident
WebRunner
(
mockFlutterDevice
,
flutterProject:
FlutterProject
.
fromDirectoryTest
(
fileSystem
.
currentDirectory
),
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
,
startPaused:
true
),
ipv6:
true
,
stayResident:
true
,
urlTunneller:
null
,
fileSystem:
fileSystem
,
logger:
BufferLogger
.
test
(),
usage:
globals
.
flutterUsage
,
featureFlags:
TestFeatureFlags
(),
systemClock:
globals
.
systemClock
,
);
expect
(
profileResidentWebRunner
.
uri
,
mockWebDevFS
.
baseUri
);
...
...
@@ -214,30 +220,38 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
testUsingContext
(
'profile does not supportsServiceProtocol'
,
()
{
fileSystem
.
file
(
'.packages'
)
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
'
\n
'
);
final
ResidentRunner
residentWebRunner
=
DwdsWebRunnerFactory
().
create
WebRunner
(
final
ResidentRunner
residentWebRunner
=
Resident
WebRunner
(
mockFlutterDevice
,
flutterProject:
FlutterProject
.
fromDirectoryTest
(
fileSystem
.
currentDirectory
),
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
),
ipv6:
true
,
stayResident:
true
,
urlTunneller:
null
,
)
as
ResidentWebRunner
;
fileSystem:
fileSystem
,
logger:
BufferLogger
.
test
(),
usage:
globals
.
flutterUsage
,
featureFlags:
TestFeatureFlags
(),
systemClock:
globals
.
systemClock
,
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]);
when
(
mockFlutterDevice
.
device
).
thenReturn
(
mockChromeDevice
);
final
ResidentRunner
profileResidentWebRunner
=
DwdsWebRunnerFactory
().
create
WebRunner
(
final
ResidentRunner
profileResidentWebRunner
=
Resident
WebRunner
(
mockFlutterDevice
,
flutterProject:
FlutterProject
.
fromDirectoryTest
(
fileSystem
.
currentDirectory
),
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
profile
),
ipv6:
true
,
stayResident:
true
,
urlTunneller:
null
,
fileSystem:
fileSystem
,
logger:
BufferLogger
.
test
(),
usage:
globals
.
flutterUsage
,
featureFlags:
TestFeatureFlags
(),
systemClock:
globals
.
systemClock
,
);
expect
(
profileResidentWebRunner
.
supportsServiceProtocol
,
false
);
...
...
@@ -245,21 +259,19 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
testUsingContext
(
'Can successfully run and connect to vmservice'
,
()
async
{
final
BufferLogger
bufferLogger
=
BufferLogger
.
test
();
final
FakeStatusLogger
logger
=
FakeStatusLogger
(
bufferLogger
);
fileSystem
.
file
(
'.packages'
)
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
'
\n
'
);
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
,
logger:
logger
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
kAttachExpectations
.
toList
());
_setupMocks
();
final
FakeStatusLogger
fakeStatusLogger
=
globals
.
logger
as
FakeStatusLogger
;
final
BufferLogger
bufferLogger
=
asLogger
<
BufferLogger
>(
fakeStatusLogger
);
final
MockStatus
status
=
MockStatus
();
fakeStatusL
ogger
.
status
=
status
;
l
ogger
.
status
=
status
;
final
Completer
<
DebugConnectionInfo
>
connectionInfoCompleter
=
Completer
<
DebugConnectionInfo
>();
unawaited
(
residentWebRunner
.
run
(
connectionInfoCompleter:
connectionInfoCompleter
,
...
...
@@ -274,8 +286,6 @@ void main() {
Logger:
()
=>
FakeStatusLogger
(
BufferLogger
.
test
()),
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
testUsingContext
(
'WebRunner copies compiled app.dill to cache during startup'
,
()
async
{
...
...
@@ -294,8 +304,6 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
// Regression test for https://github.com/flutter/flutter/issues/60613
...
...
@@ -329,56 +337,62 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
testUsingContext
(
'Can successfully run without an index.html including status warning'
,
()
async
{
final
BufferLogger
logger
=
BufferLogger
.
test
();
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
kAttachExpectations
.
toList
());
_setupMocks
();
fileSystem
.
file
(
fileSystem
.
path
.
join
(
'web'
,
'index.html'
))
.
deleteSync
();
final
ResidentWebRunner
residentWebRunner
=
DwdsWebRunnerFactory
().
create
WebRunner
(
final
ResidentWebRunner
residentWebRunner
=
Resident
WebRunner
(
mockFlutterDevice
,
flutterProject:
FlutterProject
.
fromDirectoryTest
(
fileSystem
.
currentDirectory
),
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
),
ipv6:
true
,
stayResident:
false
,
urlTunneller:
null
,
)
as
ResidentWebRunner
;
fileSystem:
fileSystem
,
logger:
logger
,
usage:
globals
.
flutterUsage
,
featureFlags:
TestFeatureFlags
(),
systemClock:
globals
.
systemClock
,
);
expect
(
await
residentWebRunner
.
run
(),
0
);
expect
(
testL
ogger
.
statusText
,
expect
(
l
ogger
.
statusText
,
contains
(
'This application is not configured to build on the web'
));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
testUsingContext
(
'Can successfully run and disconnect with --no-resident'
,
()
async
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
kAttachExpectations
.
toList
());
_setupMocks
();
final
ResidentRunner
residentWebRunner
=
DwdsWebRunnerFactory
().
create
WebRunner
(
final
ResidentRunner
residentWebRunner
=
Resident
WebRunner
(
mockFlutterDevice
,
flutterProject:
FlutterProject
.
fromDirectoryTest
(
fileSystem
.
currentDirectory
),
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
),
ipv6:
true
,
stayResident:
false
,
urlTunneller:
null
,
)
as
ResidentWebRunner
;
fileSystem:
fileSystem
,
logger:
BufferLogger
.
test
(),
usage:
globals
.
flutterUsage
,
featureFlags:
TestFeatureFlags
(),
systemClock:
globals
.
systemClock
,
);
expect
(
await
residentWebRunner
.
run
(),
0
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
testUsingContext
(
'Listens to stdout and stderr streams before running main'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
final
BufferLogger
logger
=
BufferLogger
.
test
();
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
,
logger:
logger
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
kAttachLogExpectations
,
FakeVmServiceStreamResponse
(
...
...
@@ -406,17 +420,15 @@ void main() {
));
await
connectionInfoCompleter
.
future
;
expect
(
testL
ogger
.
statusText
,
contains
(
'THIS MESSAGE IS IMPORTANT'
));
expect
(
testL
ogger
.
statusText
,
contains
(
'SO IS THIS'
));
expect
(
l
ogger
.
statusText
,
contains
(
'THIS MESSAGE IS IMPORTANT'
));
expect
(
l
ogger
.
statusText
,
contains
(
'SO IS THIS'
));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
testUsingContext
(
'Listens to extension events with structured errors'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
,
logger:
testLogger
);
final
Map
<
String
,
String
>
extensionData
=
<
String
,
String
>{
'test'
:
'data'
,
'renderedErrorText'
:
'error text'
,
...
...
@@ -479,19 +491,22 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
testUsingContext
(
'Does not run main with --start-paused'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
DwdsWebRunnerFactory
().
create
WebRunner
(
final
ResidentRunner
residentWebRunner
=
Resident
WebRunner
(
mockFlutterDevice
,
flutterProject:
FlutterProject
.
fromDirectoryTest
(
fileSystem
.
currentDirectory
),
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
,
startPaused:
true
),
ipv6:
true
,
stayResident:
true
,
urlTunneller:
null
,
)
as
ResidentWebRunner
;
fileSystem:
fileSystem
,
logger:
BufferLogger
.
test
(),
usage:
globals
.
flutterUsage
,
featureFlags:
TestFeatureFlags
(),
systemClock:
globals
.
systemClock
,
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
kAttachExpectations
.
toList
());
_setupMocks
();
final
Completer
<
DebugConnectionInfo
>
connectionInfoCompleter
=
Completer
<
DebugConnectionInfo
>();
...
...
@@ -505,12 +520,15 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
testUsingContext
(
'Can hot reload after attaching'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
final
BufferLogger
logger
=
BufferLogger
.
test
();
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
,
logger:
logger
,
systemClock:
SystemClock
.
fixed
(
DateTime
(
2001
,
1
,
1
)),
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
kAttachExpectations
,
const
FakeVmServiceRequest
(
...
...
@@ -528,7 +546,7 @@ void main() {
when
(
mockFlutterDevice
.
device
).
thenReturn
(
GoogleChromeDevice
(
fileSystem:
fileSystem
,
chromiumLauncher:
chromiumLauncher
,
logger:
globals
.
logger
,
logger:
BufferLogger
.
test
()
,
platform:
FakePlatform
(
operatingSystem:
'linux'
),
processManager:
FakeProcessManager
.
any
(),
));
...
...
@@ -561,7 +579,7 @@ void main() {
final
OperationResult
result
=
await
residentWebRunner
.
restart
(
fullRestart:
false
);
expect
(
testL
ogger
.
statusText
,
contains
(
'Restarted application in'
));
expect
(
l
ogger
.
statusText
,
contains
(
'Restarted application in'
));
expect
(
result
.
code
,
0
);
verify
(
mockResidentCompiler
.
accept
()).
called
(
2
);
...
...
@@ -576,13 +594,15 @@ void main() {
Usage:
()
=>
testUsage
,
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
SystemClock:
()
=>
SystemClock
.
fixed
(
DateTime
(
2001
,
1
,
1
))
});
testUsingContext
(
'Can hot restart after attaching'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
final
BufferLogger
logger
=
BufferLogger
.
test
();
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
,
logger:
logger
,
systemClock:
SystemClock
.
fixed
(
DateTime
(
2001
,
1
,
1
)),
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
kAttachExpectations
,
const
FakeVmServiceRequest
(
...
...
@@ -600,7 +620,7 @@ void main() {
when
(
mockFlutterDevice
.
device
).
thenReturn
(
GoogleChromeDevice
(
fileSystem:
fileSystem
,
chromiumLauncher:
chromiumLauncher
,
logger:
globals
.
logger
,
logger:
BufferLogger
.
test
()
,
platform:
FakePlatform
(
operatingSystem:
'linux'
),
processManager:
FakeProcessManager
.
any
(),
));
...
...
@@ -637,7 +657,7 @@ void main() {
expect
(
entrypointContents
,
contains
(
"import 'dart:ui' as ui;"
));
expect
(
entrypointContents
,
contains
(
'await ui.webOnlyInitializePlatform();'
));
expect
(
testL
ogger
.
statusText
,
contains
(
'Restarted application in'
));
expect
(
l
ogger
.
statusText
,
contains
(
'Restarted application in'
));
expect
(
result
.
code
,
0
);
verify
(
mockResidentCompiler
.
accept
()).
called
(
2
);
...
...
@@ -652,13 +672,15 @@ void main() {
Usage:
()
=>
testUsage
,
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
SystemClock:
()
=>
SystemClock
.
fixed
(
DateTime
(
2001
,
1
,
1
))
});
testUsingContext
(
'Can hot restart after attaching with web-server device'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
final
BufferLogger
logger
=
BufferLogger
.
test
();
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
,
logger:
logger
,
systemClock:
SystemClock
.
fixed
(
DateTime
(
2001
,
1
,
1
)),
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests
:
kAttachExpectations
);
_setupMocks
();
when
(
mockFlutterDevice
.
device
).
thenReturn
(
mockWebServerDevice
);
...
...
@@ -686,7 +708,7 @@ void main() {
await
connectionInfoCompleter
.
future
;
final
OperationResult
result
=
await
residentWebRunner
.
restart
(
fullRestart:
true
);
expect
(
testL
ogger
.
statusText
,
contains
(
'Restarted application in'
));
expect
(
l
ogger
.
statusText
,
contains
(
'Restarted application in'
));
expect
(
result
.
code
,
0
);
verify
(
mockResidentCompiler
.
accept
()).
called
(
2
);
...
...
@@ -697,9 +719,6 @@ void main() {
Usage:
()
=>
testUsage
,
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
SystemClock:
()
=>
SystemClock
.
fixed
(
DateTime
(
2001
,
1
,
1
))
});
testUsingContext
(
'web resident runner is debuggable'
,
()
{
...
...
@@ -710,9 +729,6 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
SystemClock:
()
=>
SystemClock
.
fixed
(
DateTime
(
2001
,
1
,
1
))
});
testUsingContext
(
'Exits when initial compile fails'
,
()
async
{
...
...
@@ -748,12 +764,11 @@ void main() {
Usage:
()
=>
testUsage
,
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
testUsingContext
(
'Faithfully displays stdout messages with leading/trailing spaces'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
final
BufferLogger
logger
=
BufferLogger
.
test
();
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
,
logger:
logger
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
kAttachLogExpectations
,
FakeVmServiceStreamResponse
(
...
...
@@ -775,14 +790,12 @@ void main() {
));
await
connectionInfoCompleter
.
future
;
expect
(
testL
ogger
.
statusText
,
expect
(
l
ogger
.
statusText
,
contains
(
' This is a message with 4 leading and trailing spaces '
));
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
testUsingContext
(
'Fails on compilation errors in hot restart'
,
()
async
{
...
...
@@ -822,8 +835,6 @@ void main() {
Usage:
()
=>
testUsage
,
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
testUsingContext
(
'Fails non-fatally on vmservice response error for hot restart'
,
()
async
{
...
...
@@ -850,8 +861,6 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
testUsingContext
(
'Fails fatally on Vm Service error response'
,
()
async
{
...
...
@@ -878,25 +887,23 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
testUsingContext
(
'printHelp without details shows hot restart help message'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
final
BufferLogger
logger
=
BufferLogger
.
test
();
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
,
logger:
logger
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]);
residentWebRunner
.
printHelp
(
details:
false
);
expect
(
testL
ogger
.
statusText
,
contains
(
'To hot restart changes'
));
expect
(
l
ogger
.
statusText
,
contains
(
'To hot restart changes'
));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
testUsingContext
(
'debugDumpApp'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
final
BufferLogger
logger
=
BufferLogger
.
test
();
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
,
logger:
logger
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
kAttachExpectations
,
const
FakeVmServiceRequest
(
...
...
@@ -918,8 +925,6 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
testUsingContext
(
'debugDumpLayerTree'
,
()
async
{
...
...
@@ -945,8 +950,6 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
testUsingContext
(
'debugDumpRenderTree'
,
()
async
{
...
...
@@ -972,8 +975,6 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
testUsingContext
(
'debugDumpSemanticsTreeInTraversalOrder'
,
()
async
{
...
...
@@ -999,8 +1000,6 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
testUsingContext
(
'debugDumpSemanticsTreeInInverseHitTestOrder'
,
()
async
{
...
...
@@ -1027,8 +1026,6 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
testUsingContext
(
'debugToggleDebugPaintSizeEnabled'
,
()
async
{
...
...
@@ -1068,8 +1065,6 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
testUsingContext
(
'debugTogglePerformanceOverlayOverride'
,
()
async
{
...
...
@@ -1109,8 +1104,6 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
testUsingContext
(
'debugToggleInvertOversizedImagesOverride'
,
()
async
{
...
...
@@ -1150,8 +1143,6 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
testUsingContext
(
'debugToggleWidgetInspector'
,
()
async
{
...
...
@@ -1191,8 +1182,6 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
testUsingContext
(
'debugToggleProfileWidgetBuilds'
,
()
async
{
...
...
@@ -1232,12 +1221,11 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
testUsingContext
(
'debugTogglePlatform'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
final
BufferLogger
logger
=
BufferLogger
.
test
();
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
,
logger:
logger
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
kAttachExpectations
,
const
FakeVmServiceRequest
(
...
...
@@ -1269,18 +1257,17 @@ void main() {
await
residentWebRunner
.
debugTogglePlatform
();
expect
(
testL
ogger
.
statusText
,
expect
(
l
ogger
.
statusText
,
contains
(
'Switched operating system to fuchsia'
));
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
testUsingContext
(
'debugToggleBrightness'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
final
BufferLogger
logger
=
BufferLogger
.
test
();
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
,
logger:
logger
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
kAttachExpectations
,
const
FakeVmServiceRequest
(
...
...
@@ -1312,14 +1299,12 @@ void main() {
await
residentWebRunner
.
debugToggleBrightness
();
expect
(
testL
ogger
.
statusText
,
expect
(
l
ogger
.
statusText
,
contains
(
'Changed brightness to Brightness.dark.'
));
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
testUsingContext
(
'cleanup of resources is safe to call multiple times'
,
()
async
{
...
...
@@ -1350,8 +1335,6 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
testUsingContext
(
'cleans up Chrome if tab is closed'
,
()
async
{
...
...
@@ -1376,12 +1359,11 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
testUsingContext
(
'Prints target and device name on run'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
final
BufferLogger
logger
=
BufferLogger
.
test
();
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
,
logger:
logger
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
kAttachExpectations
,
]);
...
...
@@ -1393,7 +1375,7 @@ void main() {
));
await
connectionInfoCompleter
.
future
;
expect
(
testL
ogger
.
statusText
,
contains
(
expect
(
l
ogger
.
statusText
,
contains
(
'Launching
${fileSystem.path.join('lib', 'main.dart')}
on '
'Chromez in debug mode'
,
));
...
...
@@ -1401,11 +1383,10 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
testUsingContext
(
'Sends launched app.webLaunchUrl event for Chrome device'
,
()
async
{
final
BufferLogger
logger
=
BufferLogger
.
test
();
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
kAttachLogExpectations
,
...
kAttachIsolateExpectations
,
...
...
@@ -1419,7 +1400,7 @@ void main() {
when
(
mockFlutterDevice
.
device
).
thenReturn
(
GoogleChromeDevice
(
fileSystem:
fileSystem
,
chromiumLauncher:
chromiumLauncher
,
logger:
globals
.
logger
,
logger:
logger
,
platform:
FakePlatform
(
operatingSystem:
'linux'
),
processManager:
FakeProcessManager
.
any
(),
));
...
...
@@ -1435,17 +1416,19 @@ void main() {
return
mockWipConnection
;
});
final
FakeStatusLogger
fakeStatusLogger
=
globals
.
logger
as
FakeStatusLogger
;
final
MockStatus
mockStatus
=
MockStatus
();
fakeStatusLogger
.
status
=
mockStatus
;
final
ResidentWebRunner
runner
=
DwdsWebRunnerFactory
().
createWebRunner
(
final
ResidentWebRunner
runner
=
ResidentWebRunner
(
mockFlutterDevice
,
flutterProject:
FlutterProject
.
fromDirectoryTest
(
fileSystem
.
currentDirectory
),
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
),
ipv6:
true
,
stayResident:
true
,
urlTunneller:
null
,
)
as
ResidentWebRunner
;
fileSystem:
fileSystem
,
logger:
logger
,
usage:
globals
.
flutterUsage
,
featureFlags:
TestFeatureFlags
(),
systemClock:
globals
.
systemClock
,
);
final
Completer
<
DebugConnectionInfo
>
connectionInfoCompleter
=
Completer
<
DebugConnectionInfo
>();
unawaited
(
runner
.
run
(
...
...
@@ -1454,7 +1437,7 @@ void main() {
await
connectionInfoCompleter
.
future
;
// Ensure we got the URL and that it was already launched.
expect
(
asLogger
<
BufferLogger
>(
fakeStatusLogger
)
.
eventText
,
expect
(
logger
.
eventText
,
contains
(
json
.
encode
(<
String
,
Object
>{
'name'
:
'app.webLaunchUrl'
,
'args'
:
<
String
,
Object
>{
...
...
@@ -1468,31 +1451,32 @@ void main() {
Logger:
()
=>
FakeStatusLogger
(
BufferLogger
.
test
()),
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
testUsingContext
(
'Sends unlaunched app.webLaunchUrl event for Web Server device'
,
()
async
{
final
BufferLogger
logger
=
BufferLogger
.
test
();
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]);
_setupMocks
();
when
(
mockFlutterDevice
.
device
).
thenReturn
(
WebServerDevice
(
logger:
globals
.
logger
,
logger:
logger
,
));
when
(
mockWebDevFS
.
create
()).
thenAnswer
((
Invocation
invocation
)
async
{
return
Uri
.
parse
(
'http://localhost:8765/app/'
);
});
final
FakeStatusLogger
fakeStatusLogger
=
globals
.
logger
as
FakeStatusLogger
;
final
MockStatus
mockStatus
=
MockStatus
();
fakeStatusLogger
.
status
=
mockStatus
;
final
ResidentWebRunner
runner
=
DwdsWebRunnerFactory
().
createWebRunner
(
final
ResidentWebRunner
runner
=
ResidentWebRunner
(
mockFlutterDevice
,
flutterProject:
FlutterProject
.
fromDirectoryTest
(
fileSystem
.
currentDirectory
),
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
),
ipv6:
true
,
stayResident:
true
,
urlTunneller:
null
,
)
as
ResidentWebRunner
;
fileSystem:
fileSystem
,
logger:
logger
,
usage:
globals
.
flutterUsage
,
featureFlags:
TestFeatureFlags
(),
systemClock:
globals
.
systemClock
,
);
final
Completer
<
DebugConnectionInfo
>
connectionInfoCompleter
=
Completer
<
DebugConnectionInfo
>();
unawaited
(
runner
.
run
(
...
...
@@ -1501,7 +1485,7 @@ void main() {
await
connectionInfoCompleter
.
future
;
// Ensure we got the URL and that it was not already launched.
expect
(
asLogger
<
BufferLogger
>(
fakeStatusLogger
)
.
eventText
,
expect
(
logger
.
eventText
,
contains
(
json
.
encode
(<
String
,
Object
>{
'name'
:
'app.webLaunchUrl'
,
'args'
:
<
String
,
Object
>{
...
...
@@ -1512,11 +1496,8 @@ void main() {
)));
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
},
overrides:
<
Type
,
Generator
>{
Logger:
()
=>
FakeStatusLogger
(
BufferLogger
.
test
()),
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
testUsingContext
(
'Successfully turns WebSocketException into ToolExit'
,
()
async
{
...
...
@@ -1532,8 +1513,6 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
testUsingContext
(
'Successfully turns AppConnectionException into ToolExit'
,
()
async
{
...
...
@@ -1549,8 +1528,6 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
testUsingContext
(
'Successfully turns ChromeDebugError into ToolExit'
,
()
async
{
...
...
@@ -1566,8 +1543,6 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
testUsingContext
(
'Rethrows unknown Exception type from dwds'
,
()
async
{
...
...
@@ -1581,15 +1556,14 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
testUsingContext
(
'Rethrows unknown Error type from dwds tooling'
,
()
async
{
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
);
final
BufferLogger
logger
=
BufferLogger
.
test
();
final
FakeStatusLogger
fakeStatusLogger
=
FakeStatusLogger
(
logger
);
final
ResidentRunner
residentWebRunner
=
setUpResidentRunner
(
mockFlutterDevice
,
logger:
fakeStatusLogger
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]);
_setupMocks
();
final
FakeStatusLogger
fakeStatusLogger
=
globals
.
logger
as
FakeStatusLogger
;
final
MockStatus
mockStatus
=
MockStatus
();
fakeStatusLogger
.
status
=
mockStatus
;
...
...
@@ -1599,29 +1573,28 @@ void main() {
verify
(
mockStatus
.
stop
()).
called
(
1
);
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
},
overrides:
<
Type
,
Generator
>{
Logger:
()
=>
FakeStatusLogger
(
BufferLogger
(
terminal:
AnsiTerminal
(
stdio:
null
,
platform:
const
LocalPlatform
(),
),
outputPreferences:
OutputPreferences
.
test
(),
)),
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
Pub:
()
=>
FakePub
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
});
}
ResidentRunner
setUpResidentRunner
(
FlutterDevice
flutterDevice
)
{
return
DwdsWebRunnerFactory
().
createWebRunner
(
ResidentRunner
setUpResidentRunner
(
FlutterDevice
flutterDevice
,
{
Logger
logger
,
SystemClock
systemClock
,
})
{
return
ResidentWebRunner
(
flutterDevice
,
flutterProject:
FlutterProject
.
fromDirectoryTest
(
globals
.
fs
.
currentDirectory
),
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
),
ipv6:
true
,
stayResident:
true
,
urlTunneller:
null
,
)
as
ResidentWebRunner
;
usage:
globals
.
flutterUsage
,
systemClock:
systemClock
??
SystemClock
.
fixed
(
DateTime
.
now
()),
fileSystem:
globals
.
fs
,
logger:
logger
??
BufferLogger
.
test
(),
featureFlags:
TestFeatureFlags
(),
);
}
class
MockChromeDevice
extends
Mock
implements
ChromiumDevice
{}
...
...
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