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
73df0697
Unverified
Commit
73df0697
authored
Jun 14, 2021
by
Jonah Williams
Committed by
GitHub
Jun 14, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] fully remove mocks from resident_runner_test.dart (#84591)
parent
477683e0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
192 additions
and
357 deletions
+192
-357
resident_runner_test.dart
...lutter_tools/test/general.shard/resident_runner_test.dart
+192
-357
No files found.
packages/flutter_tools/test/general.shard/resident_runner_test.dart
View file @
73df0697
...
@@ -35,8 +35,8 @@ import 'package:flutter_tools/src/run_hot.dart';
...
@@ -35,8 +35,8 @@ import 'package:flutter_tools/src/run_hot.dart';
import
'package:flutter_tools/src/version.dart'
;
import
'package:flutter_tools/src/version.dart'
;
import
'package:flutter_tools/src/vmservice.dart'
;
import
'package:flutter_tools/src/vmservice.dart'
;
import
'package:meta/meta.dart'
;
import
'package:meta/meta.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:package_config/package_config.dart'
;
import
'package:package_config/package_config.dart'
;
import
'package:test/fake.dart'
;
import
'package:vm_service/vm_service.dart'
as
vm_service
;
import
'package:vm_service/vm_service.dart'
as
vm_service
;
import
'../src/common.dart'
;
import
'../src/common.dart'
;
...
@@ -142,10 +142,10 @@ final Uri testUri = Uri.parse('foo://bar');
...
@@ -142,10 +142,10 @@ final Uri testUri = Uri.parse('foo://bar');
void
main
(
)
{
void
main
(
)
{
Testbed
testbed
;
Testbed
testbed
;
MockFlutterDevice
mockF
lutterDevice
;
FakeFlutterDevice
f
lutterDevice
;
FakeDevFS
mockD
evFS
;
FakeDevFS
d
evFS
;
ResidentRunner
residentRunner
;
ResidentRunner
residentRunner
;
FakeDevice
mockD
evice
;
FakeDevice
d
evice
;
FakeVmServiceHost
fakeVmServiceHost
;
FakeVmServiceHost
fakeVmServiceHost
;
setUp
(()
{
setUp
(()
{
...
@@ -157,7 +157,7 @@ void main() {
...
@@ -157,7 +157,7 @@ void main() {
..
writeAsStringSync
(
'ABC'
);
..
writeAsStringSync
(
'ABC'
);
residentRunner
=
HotRunner
(
residentRunner
=
HotRunner
(
<
FlutterDevice
>[
<
FlutterDevice
>[
mockF
lutterDevice
,
f
lutterDevice
,
],
],
stayResident:
false
,
stayResident:
false
,
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
),
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
),
...
@@ -165,48 +165,13 @@ void main() {
...
@@ -165,48 +165,13 @@ void main() {
devtoolsHandler:
createNoOpHandler
,
devtoolsHandler:
createNoOpHandler
,
);
);
});
});
mockFlutterDevice
=
MockFlutterDevice
();
device
=
FakeDevice
();
mockDevice
=
FakeDevice
();
devFS
=
FakeDevFS
();
mockDevFS
=
FakeDevFS
();
flutterDevice
=
FakeFlutterDevice
()
// FlutterDevice Mocks.
..
testUri
=
testUri
when
(
mockFlutterDevice
.
updateDevFS
(
..
vmServiceHost
=
(()
=>
fakeVmServiceHost
)
invalidatedFiles:
anyNamed
(
'invalidatedFiles'
),
..
device
=
device
mainUri:
anyNamed
(
'mainUri'
),
..
_devFS
=
devFS
;
target:
anyNamed
(
'target'
),
bundle:
anyNamed
(
'bundle'
),
firstBuildTime:
anyNamed
(
'firstBuildTime'
),
bundleFirstUpload:
anyNamed
(
'bundleFirstUpload'
),
bundleDirty:
anyNamed
(
'bundleDirty'
),
fullRestart:
anyNamed
(
'fullRestart'
),
projectRootPath:
anyNamed
(
'projectRootPath'
),
pathToReload:
anyNamed
(
'pathToReload'
),
dillOutputPath:
anyNamed
(
'dillOutputPath'
),
packageConfig:
anyNamed
(
'packageConfig'
),
)).
thenAnswer
((
Invocation
invocation
)
async
{
return
UpdateFSReport
(
success:
true
,
syncedBytes:
0
,
invalidatedSourcesCount:
1
,
);
});
when
(
mockFlutterDevice
.
devFS
).
thenReturn
(
mockDevFS
);
when
(
mockFlutterDevice
.
device
).
thenReturn
(
mockDevice
);
when
(
mockFlutterDevice
.
stopEchoingDeviceLog
()).
thenAnswer
((
Invocation
invocation
)
async
{
});
when
(
mockFlutterDevice
.
observatoryUris
).
thenAnswer
((
_
)
=>
Stream
<
Uri
>.
value
(
testUri
));
when
(
mockFlutterDevice
.
connect
(
reloadSources:
anyNamed
(
'reloadSources'
),
restart:
anyNamed
(
'restart'
),
compileExpression:
anyNamed
(
'compileExpression'
),
getSkSLMethod:
anyNamed
(
'getSkSLMethod'
),
allowExistingDdsInstance:
anyNamed
(
'allowExistingDdsInstance'
),
)).
thenAnswer
((
Invocation
invocation
)
async
{
});
when
(
mockFlutterDevice
.
setupDevFS
(
any
,
any
))
.
thenAnswer
((
Invocation
invocation
)
async
{
return
testUri
;
});
when
(
mockFlutterDevice
.
vmService
).
thenAnswer
((
Invocation
invocation
)
{
return
fakeVmServiceHost
?.
vmService
;
});
});
});
testUsingContext
(
'ResidentRunner can attach to device successfully'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'ResidentRunner can attach to device successfully'
,
()
=>
testbed
.
run
(()
async
{
...
@@ -225,9 +190,6 @@ void main() {
...
@@ -225,9 +190,6 @@ void main() {
final
Future
<
DebugConnectionInfo
>
connectionInfo
=
futureConnectionInfo
.
future
;
final
Future
<
DebugConnectionInfo
>
connectionInfo
=
futureConnectionInfo
.
future
;
expect
(
await
result
,
0
);
expect
(
await
result
,
0
);
verify
(
mockFlutterDevice
.
initLogReader
()).
called
(
1
);
expect
(
futureConnectionInfo
.
isCompleted
,
true
);
expect
(
futureConnectionInfo
.
isCompleted
,
true
);
expect
((
await
connectionInfo
).
baseUri
,
'foo://bar'
);
expect
((
await
connectionInfo
).
baseUri
,
'foo://bar'
);
expect
(
futureAppStart
.
isCompleted
,
true
);
expect
(
futureAppStart
.
isCompleted
,
true
);
...
@@ -242,45 +204,21 @@ void main() {
...
@@ -242,45 +204,21 @@ void main() {
listViews
,
listViews
,
setAssetBundlePath
,
setAssetBundlePath
,
]);
]);
final
MockResidentCompiler
residentCompiler
=
MockResidentCompiler
();
final
FakeResidentCompiler
residentCompiler
=
FakeResidentCompiler
()
..
nextOutput
=
const
CompilerOutput
(
'foo'
,
0
,<
Uri
>[]);
residentRunner
=
HotRunner
(
residentRunner
=
HotRunner
(
<
FlutterDevice
>[
<
FlutterDevice
>[
mockF
lutterDevice
,
f
lutterDevice
,
],
],
stayResident:
false
,
stayResident:
false
,
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
),
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
),
target:
'main.dart'
,
target:
'main.dart'
,
devtoolsHandler:
createNoOpHandler
,
devtoolsHandler:
createNoOpHandler
,
);
);
when
(
mockFlutterDevice
.
generator
).
thenReturn
(
residentCompiler
);
flutterDevice
.
generator
=
residentCompiler
;
when
(
residentCompiler
.
recompile
(
any
,
any
,
outputPath:
anyNamed
(
'outputPath'
),
packageConfig:
anyNamed
(
'packageConfig'
),
suppressErrors:
true
,
projectRootPath:
anyNamed
(
'projectRootPath'
),
fs:
anyNamed
(
'fs'
),
)).
thenAnswer
((
Invocation
invocation
)
async
{
return
const
CompilerOutput
(
'foo'
,
0
,<
Uri
>[]);
});
when
(
mockFlutterDevice
.
runHot
(
hotRunner:
anyNamed
(
'hotRunner'
),
route:
anyNamed
(
'route'
),
)).
thenAnswer
((
Invocation
invocation
)
async
{
return
0
;
});
expect
(
await
residentRunner
.
run
(
enableDevTools:
true
),
0
);
expect
(
await
residentRunner
.
run
(
enableDevTools:
true
),
0
);
verify
(
residentCompiler
.
recompile
(
expect
(
residentCompiler
.
didSuppressErrors
,
true
);
any
,
any
,
outputPath:
anyNamed
(
'outputPath'
),
packageConfig:
anyNamed
(
'packageConfig'
),
suppressErrors:
true
,
projectRootPath:
anyNamed
(
'projectRootPath'
),
fs:
anyNamed
(
'fs'
),
)).
called
(
1
);
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
}));
}));
...
@@ -289,34 +227,18 @@ void main() {
...
@@ -289,34 +227,18 @@ void main() {
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'lib'
,
'main.dart'
))
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'lib'
,
'main.dart'
))
.
createSync
(
recursive:
true
);
.
createSync
(
recursive:
true
);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]);
final
MockResidentCompiler
residentCompiler
=
MockResidentCompiler
();
final
FakeResidentCompiler
residentCompiler
=
FakeResidentCompiler
()
..
nextOutput
=
const
CompilerOutput
(
'foo'
,
1
,<
Uri
>[]);
residentRunner
=
HotRunner
(
residentRunner
=
HotRunner
(
<
FlutterDevice
>[
<
FlutterDevice
>[
mockF
lutterDevice
,
f
lutterDevice
,
],
],
stayResident:
false
,
stayResident:
false
,
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
),
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
),
target:
'main.dart'
,
target:
'main.dart'
,
devtoolsHandler:
createNoOpHandler
,
devtoolsHandler:
createNoOpHandler
,
);
);
when
(
mockFlutterDevice
.
generator
).
thenReturn
(
residentCompiler
);
flutterDevice
.
generator
=
residentCompiler
;
when
(
residentCompiler
.
recompile
(
any
,
any
,
outputPath:
anyNamed
(
'outputPath'
),
packageConfig:
anyNamed
(
'packageConfig'
),
suppressErrors:
true
,
projectRootPath:
anyNamed
(
'projectRootPath'
),
fs:
anyNamed
(
'fs'
),
)).
thenAnswer
((
Invocation
invocation
)
async
{
return
const
CompilerOutput
(
'foo'
,
1
,<
Uri
>[]);
});
when
(
mockFlutterDevice
.
runHot
(
hotRunner:
anyNamed
(
'hotRunner'
),
route:
anyNamed
(
'route'
),
)).
thenAnswer
((
Invocation
invocation
)
async
{
return
0
;
});
expect
(
await
residentRunner
.
run
(),
1
);
expect
(
await
residentRunner
.
run
(),
1
);
// Completing this future ensures that the daemon can exit correctly.
// Completing this future ensures that the daemon can exit correctly.
...
@@ -330,19 +252,14 @@ void main() {
...
@@ -330,19 +252,14 @@ void main() {
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]);
residentRunner
=
ColdRunner
(
residentRunner
=
ColdRunner
(
<
FlutterDevice
>[
<
FlutterDevice
>[
mockF
lutterDevice
,
f
lutterDevice
,
],
],
stayResident:
false
,
stayResident:
false
,
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
release
),
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
release
),
target:
'main.dart'
,
target:
'main.dart'
,
devtoolsHandler:
createNoOpHandler
,
devtoolsHandler:
createNoOpHandler
,
);
);
when
(
mockFlutterDevice
.
runCold
(
flutterDevice
.
runColdCode
=
1
;
coldRunner:
anyNamed
(
'coldRunner'
),
route:
anyNamed
(
'route'
),
)).
thenAnswer
((
Invocation
invocation
)
async
{
return
1
;
});
expect
(
await
residentRunner
.
run
(),
1
);
expect
(
await
residentRunner
.
run
(),
1
);
// Completing this future ensures that the daemon can exit correctly.
// Completing this future ensures that the daemon can exit correctly.
...
@@ -356,19 +273,15 @@ void main() {
...
@@ -356,19 +273,15 @@ void main() {
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]);
residentRunner
=
ColdRunner
(
residentRunner
=
ColdRunner
(
<
FlutterDevice
>[
<
FlutterDevice
>[
mockF
lutterDevice
,
f
lutterDevice
,
],
],
stayResident:
false
,
stayResident:
false
,
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
release
),
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
release
),
target:
'main.dart'
,
target:
'main.dart'
,
devtoolsHandler:
createNoOpHandler
,
devtoolsHandler:
createNoOpHandler
,
);
);
when
(
mockFlutterDevice
.
runCold
(
flutterDevice
.
runColdError
=
Exception
(
'BAD STUFF'
);
coldRunner:
anyNamed
(
'coldRunner'
),
route:
anyNamed
(
'route'
),
)).
thenAnswer
((
Invocation
invocation
)
async
{
throw
Exception
(
'BAD STUFF'
);
});
expect
(
await
residentRunner
.
run
(),
1
);
expect
(
await
residentRunner
.
run
(),
1
);
// Completing this future ensures that the daemon can exit correctly.
// Completing this future ensures that the daemon can exit correctly.
...
@@ -383,10 +296,11 @@ void main() {
...
@@ -383,10 +296,11 @@ void main() {
listViews
,
listViews
,
setAssetBundlePath
,
setAssetBundlePath
,
]);
]);
final
MockResidentCompiler
residentCompiler
=
MockResidentCompiler
();
final
FakeResidentCompiler
residentCompiler
=
FakeResidentCompiler
()
..
nextOutput
=
const
CompilerOutput
(
'foo'
,
0
,<
Uri
>[]);
residentRunner
=
HotRunner
(
residentRunner
=
HotRunner
(
<
FlutterDevice
>[
<
FlutterDevice
>[
mockF
lutterDevice
,
f
lutterDevice
,
],
],
applicationBinary:
globals
.
fs
.
file
(
'app.apk'
),
applicationBinary:
globals
.
fs
.
file
(
'app.apk'
),
stayResident:
false
,
stayResident:
false
,
...
@@ -394,35 +308,10 @@ void main() {
...
@@ -394,35 +308,10 @@ void main() {
target:
'main.dart'
,
target:
'main.dart'
,
devtoolsHandler:
createNoOpHandler
,
devtoolsHandler:
createNoOpHandler
,
);
);
when
(
mockFlutterDevice
.
generator
).
thenReturn
(
residentCompiler
);
flutterDevice
.
generator
=
residentCompiler
;
when
(
residentCompiler
.
recompile
(
any
,
any
,
outputPath:
anyNamed
(
'outputPath'
),
packageConfig:
anyNamed
(
'packageConfig'
),
projectRootPath:
anyNamed
(
'projectRootPath'
),
fs:
anyNamed
(
'fs'
),
suppressErrors:
false
,
)).
thenAnswer
((
Invocation
invocation
)
async
{
return
const
CompilerOutput
(
'foo'
,
0
,
<
Uri
>[]);
});
when
(
mockFlutterDevice
.
runHot
(
hotRunner:
anyNamed
(
'hotRunner'
),
route:
anyNamed
(
'route'
),
)).
thenAnswer
((
Invocation
invocation
)
async
{
return
0
;
});
expect
(
await
residentRunner
.
run
(
enableDevTools:
true
),
0
);
expect
(
await
residentRunner
.
run
(
enableDevTools:
true
),
0
);
verify
(
residentCompiler
.
recompile
(
expect
(
residentCompiler
.
didSuppressErrors
,
false
);
any
,
any
,
outputPath:
anyNamed
(
'outputPath'
),
packageConfig:
anyNamed
(
'packageConfig'
),
suppressErrors:
false
,
projectRootPath:
anyNamed
(
'projectRootPath'
),
fs:
anyNamed
(
'fs'
),
)).
called
(
1
);
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
}));
}));
...
@@ -468,7 +357,7 @@ void main() {
...
@@ -468,7 +357,7 @@ void main() {
]);
]);
residentRunner
=
HotRunner
(
residentRunner
=
HotRunner
(
<
FlutterDevice
>[
<
FlutterDevice
>[
mockF
lutterDevice
,
f
lutterDevice
,
],
],
stayResident:
false
,
stayResident:
false
,
debuggingOptions:
DebuggingOptions
.
enabled
(
debuggingOptions:
DebuggingOptions
.
enabled
(
...
@@ -489,9 +378,6 @@ void main() {
...
@@ -489,9 +378,6 @@ void main() {
final
Future
<
DebugConnectionInfo
>
connectionInfo
=
futureConnectionInfo
.
future
;
final
Future
<
DebugConnectionInfo
>
connectionInfo
=
futureConnectionInfo
.
future
;
expect
(
await
result
,
0
);
expect
(
await
result
,
0
);
verify
(
mockFlutterDevice
.
initLogReader
()).
called
(
1
);
expect
(
futureConnectionInfo
.
isCompleted
,
true
);
expect
(
futureConnectionInfo
.
isCompleted
,
true
);
expect
((
await
connectionInfo
).
baseUri
,
'foo://bar'
);
expect
((
await
connectionInfo
).
baseUri
,
'foo://bar'
);
expect
(
futureAppStart
.
isCompleted
,
true
);
expect
(
futureAppStart
.
isCompleted
,
true
);
...
@@ -513,20 +399,7 @@ void main() {
...
@@ -513,20 +399,7 @@ void main() {
enableDevTools:
true
,
enableDevTools:
true
,
));
));
await
futureAppStart
.
future
;
await
futureAppStart
.
future
;
when
(
mockFlutterDevice
.
updateDevFS
(
flutterDevice
.
reportError
=
vm_service
.
RPCError
(
'something bad happened'
,
666
,
''
);
mainUri:
anyNamed
(
'mainUri'
),
target:
anyNamed
(
'target'
),
bundle:
anyNamed
(
'bundle'
),
firstBuildTime:
anyNamed
(
'firstBuildTime'
),
bundleFirstUpload:
anyNamed
(
'bundleFirstUpload'
),
bundleDirty:
anyNamed
(
'bundleDirty'
),
fullRestart:
anyNamed
(
'fullRestart'
),
projectRootPath:
anyNamed
(
'projectRootPath'
),
pathToReload:
anyNamed
(
'pathToReload'
),
invalidatedFiles:
anyNamed
(
'invalidatedFiles'
),
dillOutputPath:
anyNamed
(
'dillOutputPath'
),
packageConfig:
anyNamed
(
'packageConfig'
),
)).
thenThrow
(
vm_service
.
RPCError
(
'something bad happened'
,
666
,
''
));
final
OperationResult
result
=
await
residentRunner
.
restart
(
fullRestart:
false
);
final
OperationResult
result
=
await
residentRunner
.
restart
(
fullRestart:
false
);
expect
(
result
.
fatal
,
true
);
expect
(
result
.
fatal
,
true
);
...
@@ -557,7 +430,7 @@ void main() {
...
@@ -557,7 +430,7 @@ void main() {
connectionInfoCompleter:
futureConnectionInfo
,
connectionInfoCompleter:
futureConnectionInfo
,
));
));
await
futureAppStart
.
future
;
await
futureAppStart
.
future
;
when
(
mockFlutterDevice
.
devFS
).
thenReturn
(
null
)
;
flutterDevice
.
_devFS
=
null
;
final
OperationResult
result
=
await
residentRunner
.
restart
(
fullRestart:
false
);
final
OperationResult
result
=
await
residentRunner
.
restart
(
fullRestart:
false
);
expect
(
result
.
fatal
,
false
);
expect
(
result
.
fatal
,
false
);
...
@@ -581,20 +454,7 @@ void main() {
...
@@ -581,20 +454,7 @@ void main() {
enableDevTools:
true
,
enableDevTools:
true
,
));
));
await
futureAppStart
.
future
;
await
futureAppStart
.
future
;
when
(
mockFlutterDevice
.
updateDevFS
(
flutterDevice
.
reportError
=
vm_service
.
RPCError
(
'something bad happened'
,
kIsolateReloadBarred
,
''
);
mainUri:
anyNamed
(
'mainUri'
),
target:
anyNamed
(
'target'
),
bundle:
anyNamed
(
'bundle'
),
firstBuildTime:
anyNamed
(
'firstBuildTime'
),
bundleFirstUpload:
anyNamed
(
'bundleFirstUpload'
),
bundleDirty:
anyNamed
(
'bundleDirty'
),
fullRestart:
anyNamed
(
'fullRestart'
),
projectRootPath:
anyNamed
(
'projectRootPath'
),
pathToReload:
anyNamed
(
'pathToReload'
),
invalidatedFiles:
anyNamed
(
'invalidatedFiles'
),
dillOutputPath:
anyNamed
(
'dillOutputPath'
),
packageConfig:
anyNamed
(
'packageConfig'
),
)).
thenThrow
(
vm_service
.
RPCError
(
'something bad happened'
,
kIsolateReloadBarred
,
''
));
final
OperationResult
result
=
await
residentRunner
.
restart
(
fullRestart:
false
);
final
OperationResult
result
=
await
residentRunner
.
restart
(
fullRestart:
false
);
expect
(
result
.
fatal
,
true
);
expect
(
result
.
fatal
,
true
);
...
@@ -623,7 +483,7 @@ void main() {
...
@@ -623,7 +483,7 @@ void main() {
]);
]);
residentRunner
=
HotRunner
(
residentRunner
=
HotRunner
(
<
FlutterDevice
>[
<
FlutterDevice
>[
mockF
lutterDevice
,
f
lutterDevice
,
],
],
stayResident:
false
,
stayResident:
false
,
target:
'main.dart'
,
target:
'main.dart'
,
...
@@ -642,20 +502,7 @@ void main() {
...
@@ -642,20 +502,7 @@ void main() {
enableDevTools:
true
,
enableDevTools:
true
,
));
));
await
futureAppStart
.
future
;
await
futureAppStart
.
future
;
when
(
mockFlutterDevice
.
updateDevFS
(
flutterDevice
.
reportError
=
vm_service
.
RPCError
(
'something bad happened'
,
666
,
''
);
mainUri:
anyNamed
(
'mainUri'
),
target:
anyNamed
(
'target'
),
bundle:
anyNamed
(
'bundle'
),
firstBuildTime:
anyNamed
(
'firstBuildTime'
),
bundleFirstUpload:
anyNamed
(
'bundleFirstUpload'
),
bundleDirty:
anyNamed
(
'bundleDirty'
),
fullRestart:
anyNamed
(
'fullRestart'
),
projectRootPath:
anyNamed
(
'projectRootPath'
),
pathToReload:
anyNamed
(
'pathToReload'
),
invalidatedFiles:
anyNamed
(
'invalidatedFiles'
),
dillOutputPath:
anyNamed
(
'dillOutputPath'
),
packageConfig:
anyNamed
(
'packageConfig'
),
)).
thenThrow
(
vm_service
.
RPCError
(
'something bad happened'
,
666
,
''
));
final
OperationResult
result
=
await
residentRunner
.
restart
(
fullRestart:
false
);
final
OperationResult
result
=
await
residentRunner
.
restart
(
fullRestart:
false
);
expect
(
result
.
fatal
,
true
);
expect
(
result
.
fatal
,
true
);
...
@@ -696,7 +543,7 @@ void main() {
...
@@ -696,7 +543,7 @@ void main() {
]);
]);
residentRunner
=
HotRunner
(
residentRunner
=
HotRunner
(
<
FlutterDevice
>[
<
FlutterDevice
>[
mockF
lutterDevice
,
f
lutterDevice
,
],
],
stayResident:
false
,
stayResident:
false
,
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
),
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
),
...
@@ -711,22 +558,7 @@ void main() {
...
@@ -711,22 +558,7 @@ void main() {
enableDevTools:
true
,
enableDevTools:
true
,
));
));
await
futureAppStart
.
future
;
await
futureAppStart
.
future
;
when
(
mockFlutterDevice
.
updateDevFS
(
flutterDevice
.
report
=
UpdateFSReport
(
success:
true
,
invalidatedSourcesCount:
0
);
mainUri:
anyNamed
(
'mainUri'
),
target:
anyNamed
(
'target'
),
bundle:
anyNamed
(
'bundle'
),
firstBuildTime:
anyNamed
(
'firstBuildTime'
),
bundleFirstUpload:
anyNamed
(
'bundleFirstUpload'
),
bundleDirty:
anyNamed
(
'bundleDirty'
),
fullRestart:
anyNamed
(
'fullRestart'
),
projectRootPath:
anyNamed
(
'projectRootPath'
),
pathToReload:
anyNamed
(
'pathToReload'
),
invalidatedFiles:
anyNamed
(
'invalidatedFiles'
),
dillOutputPath:
anyNamed
(
'dillOutputPath'
),
packageConfig:
anyNamed
(
'packageConfig'
),
)).
thenAnswer
((
Invocation
_
)
async
{
return
UpdateFSReport
(
success:
true
,
invalidatedSourcesCount:
0
);
});
final
OperationResult
result
=
await
residentRunner
.
restart
(
fullRestart:
false
);
final
OperationResult
result
=
await
residentRunner
.
restart
(
fullRestart:
false
);
...
@@ -785,22 +617,7 @@ void main() {
...
@@ -785,22 +617,7 @@ void main() {
enableDevTools:
true
,
enableDevTools:
true
,
));
));
await
futureAppStart
.
future
;
await
futureAppStart
.
future
;
when
(
mockFlutterDevice
.
updateDevFS
(
flutterDevice
.
report
=
UpdateFSReport
(
success:
true
,
invalidatedSourcesCount:
1
);
mainUri:
anyNamed
(
'mainUri'
),
target:
anyNamed
(
'target'
),
bundle:
anyNamed
(
'bundle'
),
firstBuildTime:
anyNamed
(
'firstBuildTime'
),
bundleFirstUpload:
anyNamed
(
'bundleFirstUpload'
),
bundleDirty:
anyNamed
(
'bundleDirty'
),
fullRestart:
anyNamed
(
'fullRestart'
),
projectRootPath:
anyNamed
(
'projectRootPath'
),
pathToReload:
anyNamed
(
'pathToReload'
),
invalidatedFiles:
anyNamed
(
'invalidatedFiles'
),
dillOutputPath:
anyNamed
(
'dillOutputPath'
),
packageConfig:
anyNamed
(
'packageConfig'
),
)).
thenAnswer
((
Invocation
invocation
)
async
{
return
UpdateFSReport
(
success:
true
,
invalidatedSourcesCount:
1
);
});
final
OperationResult
result
=
await
residentRunner
.
restart
(
fullRestart:
false
);
final
OperationResult
result
=
await
residentRunner
.
restart
(
fullRestart:
false
);
...
@@ -865,29 +682,14 @@ void main() {
...
@@ -865,29 +682,14 @@ void main() {
enableDevTools:
true
,
enableDevTools:
true
,
));
));
await
futureAppStart
.
future
;
await
futureAppStart
.
future
;
when
(
mockFlutterDevice
.
updateDevFS
(
flutterDevice
.
report
=
UpdateFSReport
(
success:
true
,
invalidatedSourcesCount:
1
);
mainUri:
anyNamed
(
'mainUri'
),
target:
anyNamed
(
'target'
),
bundle:
anyNamed
(
'bundle'
),
firstBuildTime:
anyNamed
(
'firstBuildTime'
),
bundleFirstUpload:
anyNamed
(
'bundleFirstUpload'
),
bundleDirty:
anyNamed
(
'bundleDirty'
),
fullRestart:
anyNamed
(
'fullRestart'
),
projectRootPath:
anyNamed
(
'projectRootPath'
),
pathToReload:
anyNamed
(
'pathToReload'
),
invalidatedFiles:
anyNamed
(
'invalidatedFiles'
),
dillOutputPath:
anyNamed
(
'dillOutputPath'
),
packageConfig:
anyNamed
(
'packageConfig'
),
)).
thenAnswer
((
Invocation
invocation
)
async
{
return
UpdateFSReport
(
success:
true
,
invalidatedSourcesCount:
1
);
});
final
OperationResult
result
=
await
residentRunner
.
restart
(
fullRestart:
false
);
final
OperationResult
result
=
await
residentRunner
.
restart
(
fullRestart:
false
);
expect
(
result
.
fatal
,
false
);
expect
(
result
.
fatal
,
false
);
expect
(
result
.
message
,
contains
(
'Reload rejected: Failed to hot reload'
));
// contains error message from reload report.
expect
(
result
.
message
,
contains
(
'Reload rejected: Failed to hot reload'
));
// contains error message from reload report.
expect
(
result
.
code
,
1
);
expect
(
result
.
code
,
1
);
expect
(
mockD
evFS
.
lastCompiled
,
null
);
expect
(
d
evFS
.
lastCompiled
,
null
);
}));
}));
testUsingContext
(
'ResidentRunner can send target platform to analytics from hot reload'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'ResidentRunner can send target platform to analytics from hot reload'
,
()
=>
testbed
.
run
(()
async
{
...
@@ -998,11 +800,11 @@ void main() {
...
@@ -998,11 +800,11 @@ void main() {
},
},
),
),
]);
]);
final
Fake
FlutterDevice
flutterDevice
=
Fak
eFlutterDevice
(
final
Fake
DelegateFlutterDevice
flutterDevice
=
FakeDelegat
eFlutterDevice
(
mockD
evice
,
d
evice
,
BuildInfo
.
debug
,
BuildInfo
.
debug
,
FakeResidentCompiler
(),
FakeResidentCompiler
(),
mockD
evFS
,
d
evFS
,
)..
vmService
=
fakeVmServiceHost
.
vmService
;
)..
vmService
=
fakeVmServiceHost
.
vmService
;
residentRunner
=
HotRunner
(
residentRunner
=
HotRunner
(
<
FlutterDevice
>[
<
FlutterDevice
>[
...
@@ -1013,7 +815,7 @@ void main() {
...
@@ -1013,7 +815,7 @@ void main() {
target:
'main.dart'
,
target:
'main.dart'
,
devtoolsHandler:
createNoOpHandler
,
devtoolsHandler:
createNoOpHandler
,
);
);
mockD
evFS
.
nextUpdateReport
=
UpdateFSReport
(
d
evFS
.
nextUpdateReport
=
UpdateFSReport
(
success:
true
,
success:
true
,
fastReassembleClassName:
'FOO'
,
fastReassembleClassName:
'FOO'
,
invalidatedSourcesCount:
1
,
invalidatedSourcesCount:
1
,
...
@@ -1310,20 +1112,7 @@ void main() {
...
@@ -1310,20 +1112,7 @@ void main() {
enableDevTools:
true
,
enableDevTools:
true
,
));
));
await
futureAppStart
.
future
;
await
futureAppStart
.
future
;
when
(
mockFlutterDevice
.
updateDevFS
(
flutterDevice
.
reportError
=
vm_service
.
RPCError
(
'something bad happened'
,
666
,
''
);
mainUri:
anyNamed
(
'mainUri'
),
target:
anyNamed
(
'target'
),
bundle:
anyNamed
(
'bundle'
),
firstBuildTime:
anyNamed
(
'firstBuildTime'
),
bundleFirstUpload:
anyNamed
(
'bundleFirstUpload'
),
bundleDirty:
anyNamed
(
'bundleDirty'
),
fullRestart:
anyNamed
(
'fullRestart'
),
projectRootPath:
anyNamed
(
'projectRootPath'
),
pathToReload:
anyNamed
(
'pathToReload'
),
invalidatedFiles:
anyNamed
(
'invalidatedFiles'
),
dillOutputPath:
anyNamed
(
'dillOutputPath'
),
packageConfig:
anyNamed
(
'packageConfig'
),
)).
thenThrow
(
vm_service
.
RPCError
(
'something bad happened'
,
666
,
''
));
final
OperationResult
result
=
await
residentRunner
.
restart
(
fullRestart:
true
);
final
OperationResult
result
=
await
residentRunner
.
restart
(
fullRestart:
true
);
expect
(
result
.
fatal
,
true
);
expect
(
result
.
fatal
,
true
);
...
@@ -1348,7 +1137,7 @@ void main() {
...
@@ -1348,7 +1137,7 @@ void main() {
final
ResidentRunner
otherRunner
=
HotRunner
(
final
ResidentRunner
otherRunner
=
HotRunner
(
<
FlutterDevice
>[
<
FlutterDevice
>[
mockF
lutterDevice
,
f
lutterDevice
,
],
],
stayResident:
false
,
stayResident:
false
,
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
),
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
),
...
@@ -1510,7 +1299,7 @@ void main() {
...
@@ -1510,7 +1299,7 @@ void main() {
fakeVmServiceHost
=
null
;
fakeVmServiceHost
=
null
;
residentRunner
=
ColdRunner
(
residentRunner
=
ColdRunner
(
<
FlutterDevice
>[
<
FlutterDevice
>[
mockF
lutterDevice
,
f
lutterDevice
,
],
],
stayResident:
false
,
stayResident:
false
,
debuggingOptions:
DebuggingOptions
.
disabled
(
BuildInfo
.
release
),
debuggingOptions:
DebuggingOptions
.
disabled
(
BuildInfo
.
release
),
...
@@ -1545,7 +1334,7 @@ void main() {
...
@@ -1545,7 +1334,7 @@ void main() {
fakeVmServiceHost
=
null
;
fakeVmServiceHost
=
null
;
residentRunner
=
ColdRunner
(
residentRunner
=
ColdRunner
(
<
FlutterDevice
>[
<
FlutterDevice
>[
mockF
lutterDevice
,
f
lutterDevice
,
],
],
stayResident:
false
,
stayResident:
false
,
debuggingOptions:
DebuggingOptions
.
disabled
(
BuildInfo
.
release
),
debuggingOptions:
DebuggingOptions
.
disabled
(
BuildInfo
.
release
),
...
@@ -1635,19 +1424,13 @@ void main() {
...
@@ -1635,19 +1424,13 @@ void main() {
]);
]);
residentRunner
=
ColdRunner
(
residentRunner
=
ColdRunner
(
<
FlutterDevice
>[
<
FlutterDevice
>[
mockF
lutterDevice
,
f
lutterDevice
,
],
],
stayResident:
false
,
stayResident:
false
,
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
profile
,
vmserviceOutFile:
'foo'
),
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
profile
,
vmserviceOutFile:
'foo'
),
target:
'main.dart'
,
target:
'main.dart'
,
devtoolsHandler:
createNoOpHandler
,
devtoolsHandler:
createNoOpHandler
,
);
);
when
(
mockFlutterDevice
.
runCold
(
coldRunner:
anyNamed
(
'coldRunner'
),
route:
anyNamed
(
'route'
),
)).
thenAnswer
((
Invocation
invocation
)
async
{
return
0
;
});
final
Future
<
int
>
result
=
residentRunner
.
attach
(
enableDevTools:
false
);
final
Future
<
int
>
result
=
residentRunner
.
attach
(
enableDevTools:
false
);
expect
(
await
result
,
0
);
expect
(
await
result
,
0
);
...
@@ -1655,25 +1438,25 @@ void main() {
...
@@ -1655,25 +1438,25 @@ void main() {
testUsingContext
(
'FlutterDevice can exit from a release mode isolate with no VmService'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'FlutterDevice can exit from a release mode isolate with no VmService'
,
()
=>
testbed
.
run
(()
async
{
final
TestFlutterDevice
flutterDevice
=
TestFlutterDevice
(
final
TestFlutterDevice
flutterDevice
=
TestFlutterDevice
(
mockD
evice
,
d
evice
,
);
);
await
flutterDevice
.
exitApps
();
await
flutterDevice
.
exitApps
();
expect
(
mockD
evice
.
appStopped
,
true
);
expect
(
d
evice
.
appStopped
,
true
);
}));
}));
testUsingContext
(
'FlutterDevice will exit an un-paused isolate using stopApp'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'FlutterDevice will exit an un-paused isolate using stopApp'
,
()
=>
testbed
.
run
(()
async
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]);
final
TestFlutterDevice
flutterDevice
=
TestFlutterDevice
(
final
TestFlutterDevice
flutterDevice
=
TestFlutterDevice
(
mockD
evice
,
d
evice
,
);
);
flutterDevice
.
vmService
=
fakeVmServiceHost
.
vmService
;
flutterDevice
.
vmService
=
fakeVmServiceHost
.
vmService
;
final
Future
<
void
>
exitFuture
=
flutterDevice
.
exitApps
();
final
Future
<
void
>
exitFuture
=
flutterDevice
.
exitApps
();
await
expectLater
(
exitFuture
,
completes
);
await
expectLater
(
exitFuture
,
completes
);
expect
(
mockD
evice
.
appStopped
,
true
);
expect
(
d
evice
.
appStopped
,
true
);
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
}));
}));
...
@@ -1686,19 +1469,14 @@ void main() {
...
@@ -1686,19 +1469,14 @@ void main() {
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'lib'
,
'main.dart'
)).
createSync
(
recursive:
true
);
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'lib'
,
'main.dart'
)).
createSync
(
recursive:
true
);
residentRunner
=
HotRunner
(
residentRunner
=
HotRunner
(
<
FlutterDevice
>[
<
FlutterDevice
>[
mockF
lutterDevice
,
f
lutterDevice
,
],
],
stayResident:
false
,
stayResident:
false
,
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
,
vmserviceOutFile:
'foo'
),
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
,
vmserviceOutFile:
'foo'
),
target:
'main.dart'
,
target:
'main.dart'
,
devtoolsHandler:
createNoOpHandler
,
devtoolsHandler:
createNoOpHandler
,
);
);
when
(
mockFlutterDevice
.
runHot
(
hotRunner:
anyNamed
(
'hotRunner'
),
route:
anyNamed
(
'route'
),
)).
thenAnswer
((
Invocation
invocation
)
async
{
return
0
;
});
await
residentRunner
.
run
(
enableDevTools:
true
);
await
residentRunner
.
run
(
enableDevTools:
true
);
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
...
@@ -1714,7 +1492,7 @@ void main() {
...
@@ -1714,7 +1492,7 @@ void main() {
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'lib'
,
'main.dart'
)).
createSync
(
recursive:
true
);
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'lib'
,
'main.dart'
)).
createSync
(
recursive:
true
);
residentRunner
=
HotRunner
(
residentRunner
=
HotRunner
(
<
FlutterDevice
>[
<
FlutterDevice
>[
mockF
lutterDevice
,
f
lutterDevice
,
],
],
stayResident:
false
,
stayResident:
false
,
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
),
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
),
...
@@ -1722,12 +1500,7 @@ void main() {
...
@@ -1722,12 +1500,7 @@ void main() {
devtoolsHandler:
createNoOpHandler
,
devtoolsHandler:
createNoOpHandler
,
);
);
residentRunner
.
artifactDirectory
.
childFile
(
'app.dill'
).
writeAsStringSync
(
'ABC'
);
residentRunner
.
artifactDirectory
.
childFile
(
'app.dill'
).
writeAsStringSync
(
'ABC'
);
when
(
mockFlutterDevice
.
runHot
(
hotRunner:
anyNamed
(
'hotRunner'
),
route:
anyNamed
(
'route'
),
)).
thenAnswer
((
Invocation
invocation
)
async
{
return
0
;
});
await
residentRunner
.
run
(
enableDevTools:
true
);
await
residentRunner
.
run
(
enableDevTools:
true
);
expect
(
await
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'build'
,
'cache.dill'
)).
readAsString
(),
'ABC'
);
expect
(
await
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'build'
,
'cache.dill'
)).
readAsString
(),
'ABC'
);
...
@@ -1742,7 +1515,7 @@ void main() {
...
@@ -1742,7 +1515,7 @@ void main() {
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'lib'
,
'main.dart'
)).
createSync
(
recursive:
true
);
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'lib'
,
'main.dart'
)).
createSync
(
recursive:
true
);
residentRunner
=
HotRunner
(
residentRunner
=
HotRunner
(
<
FlutterDevice
>[
<
FlutterDevice
>[
mockF
lutterDevice
,
f
lutterDevice
,
],
],
stayResident:
false
,
stayResident:
false
,
debuggingOptions:
DebuggingOptions
.
enabled
(
debuggingOptions:
DebuggingOptions
.
enabled
(
...
@@ -1757,12 +1530,7 @@ void main() {
...
@@ -1757,12 +1530,7 @@ void main() {
devtoolsHandler:
createNoOpHandler
,
devtoolsHandler:
createNoOpHandler
,
);
);
residentRunner
.
artifactDirectory
.
childFile
(
'app.dill'
).
writeAsStringSync
(
'ABC'
);
residentRunner
.
artifactDirectory
.
childFile
(
'app.dill'
).
writeAsStringSync
(
'ABC'
);
when
(
mockFlutterDevice
.
runHot
(
hotRunner:
anyNamed
(
'hotRunner'
),
route:
anyNamed
(
'route'
),
)).
thenAnswer
((
Invocation
invocation
)
async
{
return
0
;
});
await
residentRunner
.
run
(
enableDevTools:
true
);
await
residentRunner
.
run
(
enableDevTools:
true
);
expect
(
await
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
expect
(
await
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
...
@@ -1778,7 +1546,7 @@ void main() {
...
@@ -1778,7 +1546,7 @@ void main() {
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'lib'
,
'main.dart'
)).
createSync
(
recursive:
true
);
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'lib'
,
'main.dart'
)).
createSync
(
recursive:
true
);
residentRunner
=
HotRunner
(
residentRunner
=
HotRunner
(
<
FlutterDevice
>[
<
FlutterDevice
>[
mockF
lutterDevice
,
f
lutterDevice
,
],
],
stayResident:
false
,
stayResident:
false
,
debuggingOptions:
DebuggingOptions
.
enabled
(
debuggingOptions:
DebuggingOptions
.
enabled
(
...
@@ -1793,12 +1561,7 @@ void main() {
...
@@ -1793,12 +1561,7 @@ void main() {
devtoolsHandler:
createNoOpHandler
,
devtoolsHandler:
createNoOpHandler
,
);
);
residentRunner
.
artifactDirectory
.
childFile
(
'app.dill'
).
writeAsStringSync
(
'ABC'
);
residentRunner
.
artifactDirectory
.
childFile
(
'app.dill'
).
writeAsStringSync
(
'ABC'
);
when
(
mockFlutterDevice
.
runHot
(
hotRunner:
anyNamed
(
'hotRunner'
),
route:
anyNamed
(
'route'
),
)).
thenAnswer
((
Invocation
invocation
)
async
{
return
0
;
});
await
residentRunner
.
run
(
enableDevTools:
true
);
await
residentRunner
.
run
(
enableDevTools:
true
);
expect
(
await
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
expect
(
await
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
...
@@ -1814,7 +1577,7 @@ void main() {
...
@@ -1814,7 +1577,7 @@ void main() {
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'lib'
,
'main.dart'
)).
createSync
(
recursive:
true
);
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'lib'
,
'main.dart'
)).
createSync
(
recursive:
true
);
residentRunner
=
HotRunner
(
residentRunner
=
HotRunner
(
<
FlutterDevice
>[
<
FlutterDevice
>[
mockF
lutterDevice
,
f
lutterDevice
,
],
],
stayResident:
false
,
stayResident:
false
,
dillOutputPath:
'test'
,
dillOutputPath:
'test'
,
...
@@ -1823,12 +1586,7 @@ void main() {
...
@@ -1823,12 +1586,7 @@ void main() {
devtoolsHandler:
createNoOpHandler
,
devtoolsHandler:
createNoOpHandler
,
);
);
residentRunner
.
artifactDirectory
.
childFile
(
'app.dill'
).
writeAsStringSync
(
'ABC'
);
residentRunner
.
artifactDirectory
.
childFile
(
'app.dill'
).
writeAsStringSync
(
'ABC'
);
when
(
mockFlutterDevice
.
runHot
(
hotRunner:
anyNamed
(
'hotRunner'
),
route:
anyNamed
(
'route'
),
)).
thenAnswer
((
Invocation
invocation
)
async
{
return
0
;
});
await
residentRunner
.
run
(
enableDevTools:
true
);
await
residentRunner
.
run
(
enableDevTools:
true
);
expect
(
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'build'
,
'cache.dill'
)),
isNot
(
exists
));
expect
(
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'build'
,
'cache.dill'
)),
isNot
(
exists
));
...
@@ -1843,7 +1601,7 @@ void main() {
...
@@ -1843,7 +1601,7 @@ void main() {
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'lib'
,
'main.dart'
)).
createSync
(
recursive:
true
);
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'lib'
,
'main.dart'
)).
createSync
(
recursive:
true
);
residentRunner
=
HotRunner
(
residentRunner
=
HotRunner
(
<
FlutterDevice
>[
<
FlutterDevice
>[
mockF
lutterDevice
,
f
lutterDevice
,
],
],
stayResident:
false
,
stayResident:
false
,
debuggingOptions:
DebuggingOptions
.
enabled
(
const
BuildInfo
(
debuggingOptions:
DebuggingOptions
.
enabled
(
const
BuildInfo
(
...
@@ -1856,12 +1614,7 @@ void main() {
...
@@ -1856,12 +1614,7 @@ void main() {
devtoolsHandler:
createNoOpHandler
,
devtoolsHandler:
createNoOpHandler
,
);
);
residentRunner
.
artifactDirectory
.
childFile
(
'app.dill'
).
writeAsStringSync
(
'ABC'
);
residentRunner
.
artifactDirectory
.
childFile
(
'app.dill'
).
writeAsStringSync
(
'ABC'
);
when
(
mockFlutterDevice
.
runHot
(
hotRunner:
anyNamed
(
'hotRunner'
),
route:
anyNamed
(
'route'
),
)).
thenAnswer
((
Invocation
invocation
)
async
{
return
0
;
});
await
residentRunner
.
run
(
enableDevTools:
true
);
await
residentRunner
.
run
(
enableDevTools:
true
);
expect
(
await
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'build'
,
'cache.dill.track.dill'
)).
readAsString
(),
'ABC'
);
expect
(
await
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'build'
,
'cache.dill.track.dill'
)).
readAsString
(),
'ABC'
);
...
@@ -1876,22 +1629,16 @@ void main() {
...
@@ -1876,22 +1629,16 @@ void main() {
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'lib'
,
'main.dart'
)).
createSync
(
recursive:
true
);
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'lib'
,
'main.dart'
)).
createSync
(
recursive:
true
);
residentRunner
=
HotRunner
(
residentRunner
=
HotRunner
(
<
FlutterDevice
>[
<
FlutterDevice
>[
mockF
lutterDevice
,
f
lutterDevice
,
],
],
stayResident:
false
,
stayResident:
false
,
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
),
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
),
target:
'main.dart'
,
target:
'main.dart'
,
devtoolsHandler:
createNoOpHandler
,
devtoolsHandler:
createNoOpHandler
,
);
);
when
(
mockFlutterDevice
.
runHot
(
hotRunner:
anyNamed
(
'hotRunner'
),
route:
anyNamed
(
'route'
),
)).
thenAnswer
((
Invocation
invocation
)
async
{
return
0
;
});
await
residentRunner
.
run
();
await
residentRunner
.
run
();
expect
(
mockD
evice
.
disposed
,
true
);
expect
(
d
evice
.
disposed
,
true
);
}));
}));
testUsingContext
(
'HotRunner handles failure to write vmservice file'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'HotRunner handles failure to write vmservice file'
,
()
=>
testbed
.
run
(()
async
{
...
@@ -1903,19 +1650,14 @@ void main() {
...
@@ -1903,19 +1650,14 @@ void main() {
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'lib'
,
'main.dart'
)).
createSync
(
recursive:
true
);
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'lib'
,
'main.dart'
)).
createSync
(
recursive:
true
);
residentRunner
=
HotRunner
(
residentRunner
=
HotRunner
(
<
FlutterDevice
>[
<
FlutterDevice
>[
mockF
lutterDevice
,
f
lutterDevice
,
],
],
stayResident:
false
,
stayResident:
false
,
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
,
vmserviceOutFile:
'foo'
),
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
,
vmserviceOutFile:
'foo'
),
target:
'main.dart'
,
target:
'main.dart'
,
devtoolsHandler:
createNoOpHandler
,
devtoolsHandler:
createNoOpHandler
,
);
);
when
(
mockFlutterDevice
.
runHot
(
hotRunner:
anyNamed
(
'hotRunner'
),
route:
anyNamed
(
'route'
),
)).
thenAnswer
((
Invocation
invocation
)
async
{
return
0
;
});
await
residentRunner
.
run
(
enableDevTools:
true
);
await
residentRunner
.
run
(
enableDevTools:
true
);
expect
(
testLogger
.
errorText
,
contains
(
'Failed to write vmservice-out-file at foo'
));
expect
(
testLogger
.
errorText
,
contains
(
'Failed to write vmservice-out-file at foo'
));
...
@@ -1931,19 +1673,14 @@ void main() {
...
@@ -1931,19 +1673,14 @@ void main() {
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'lib'
,
'main.dart'
)).
createSync
(
recursive:
true
);
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'lib'
,
'main.dart'
)).
createSync
(
recursive:
true
);
residentRunner
=
ColdRunner
(
residentRunner
=
ColdRunner
(
<
FlutterDevice
>[
<
FlutterDevice
>[
mockF
lutterDevice
,
f
lutterDevice
,
],
],
stayResident:
false
,
stayResident:
false
,
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
profile
,
vmserviceOutFile:
'foo'
),
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
profile
,
vmserviceOutFile:
'foo'
),
target:
'main.dart'
,
target:
'main.dart'
,
devtoolsHandler:
createNoOpHandler
,
devtoolsHandler:
createNoOpHandler
,
);
);
when
(
mockFlutterDevice
.
runCold
(
coldRunner:
anyNamed
(
'coldRunner'
),
route:
anyNamed
(
'route'
),
)).
thenAnswer
((
Invocation
invocation
)
async
{
return
0
;
});
await
residentRunner
.
run
(
enableDevTools:
true
);
await
residentRunner
.
run
(
enableDevTools:
true
);
expect
(
await
globals
.
fs
.
file
(
'foo'
).
readAsString
(),
testUri
.
toString
());
expect
(
await
globals
.
fs
.
file
(
'foo'
).
readAsString
(),
testUri
.
toString
());
...
@@ -1952,9 +1689,9 @@ void main() {
...
@@ -1952,9 +1689,9 @@ void main() {
testUsingContext
(
'FlutterDevice uses dartdevc configuration when targeting web'
,
()
async
{
testUsingContext
(
'FlutterDevice uses dartdevc configuration when targeting web'
,
()
async
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]);
final
FakeDevice
mockD
evice
=
FakeDevice
(
targetPlatform:
TargetPlatform
.
web_javascript
);
final
FakeDevice
d
evice
=
FakeDevice
(
targetPlatform:
TargetPlatform
.
web_javascript
);
final
DefaultResidentCompiler
residentCompiler
=
(
await
FlutterDevice
.
create
(
final
DefaultResidentCompiler
residentCompiler
=
(
await
FlutterDevice
.
create
(
mockD
evice
,
d
evice
,
buildInfo:
const
BuildInfo
(
buildInfo:
const
BuildInfo
(
BuildMode
.
debug
,
BuildMode
.
debug
,
''
,
''
,
...
@@ -1982,10 +1719,10 @@ void main() {
...
@@ -1982,10 +1719,10 @@ void main() {
testUsingContext
(
'FlutterDevice uses dartdevc configuration when targeting web with null-safety autodetected'
,
()
async
{
testUsingContext
(
'FlutterDevice uses dartdevc configuration when targeting web with null-safety autodetected'
,
()
async
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]);
final
FakeDevice
mockD
evice
=
FakeDevice
(
targetPlatform:
TargetPlatform
.
web_javascript
);
final
FakeDevice
d
evice
=
FakeDevice
(
targetPlatform:
TargetPlatform
.
web_javascript
);
final
DefaultResidentCompiler
residentCompiler
=
(
await
FlutterDevice
.
create
(
final
DefaultResidentCompiler
residentCompiler
=
(
await
FlutterDevice
.
create
(
mockD
evice
,
d
evice
,
buildInfo:
const
BuildInfo
(
buildInfo:
const
BuildInfo
(
BuildMode
.
debug
,
BuildMode
.
debug
,
''
,
''
,
...
@@ -2013,10 +1750,10 @@ void main() {
...
@@ -2013,10 +1750,10 @@ void main() {
testUsingContext
(
'FlutterDevice passes flutter-widget-cache flag when feature is enabled'
,
()
async
{
testUsingContext
(
'FlutterDevice passes flutter-widget-cache flag when feature is enabled'
,
()
async
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]);
final
FakeDevice
mockD
evice
=
FakeDevice
(
targetPlatform:
TargetPlatform
.
android_arm
);
final
FakeDevice
d
evice
=
FakeDevice
(
targetPlatform:
TargetPlatform
.
android_arm
);
final
DefaultResidentCompiler
residentCompiler
=
(
await
FlutterDevice
.
create
(
final
DefaultResidentCompiler
residentCompiler
=
(
await
FlutterDevice
.
create
(
mockD
evice
,
d
evice
,
buildInfo:
const
BuildInfo
(
buildInfo:
const
BuildInfo
(
BuildMode
.
debug
,
BuildMode
.
debug
,
''
,
''
,
...
@@ -2037,11 +1774,11 @@ void main() {
...
@@ -2037,11 +1774,11 @@ void main() {
testUsingContext
(
'FlutterDevice passes alternative-invalidation-strategy flag'
,
()
async
{
testUsingContext
(
'FlutterDevice passes alternative-invalidation-strategy flag'
,
()
async
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]);
final
FakeDevice
mockD
evice
=
FakeDevice
(
targetPlatform:
TargetPlatform
.
android_arm
);
final
FakeDevice
d
evice
=
FakeDevice
(
targetPlatform:
TargetPlatform
.
android_arm
);
final
DefaultResidentCompiler
residentCompiler
=
(
await
FlutterDevice
.
create
(
final
DefaultResidentCompiler
residentCompiler
=
(
await
FlutterDevice
.
create
(
mockD
evice
,
d
evice
,
buildInfo:
const
BuildInfo
(
buildInfo:
const
BuildInfo
(
BuildMode
.
debug
,
BuildMode
.
debug
,
''
,
''
,
...
@@ -2061,10 +1798,10 @@ void main() {
...
@@ -2061,10 +1798,10 @@ void main() {
testUsingContext
(
'FlutterDevice passes initializeFromDill parameter if specified'
,
()
async
{
testUsingContext
(
'FlutterDevice passes initializeFromDill parameter if specified'
,
()
async
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]);
final
FakeDevice
mockD
evice
=
FakeDevice
(
targetPlatform:
TargetPlatform
.
android_arm
);
final
FakeDevice
d
evice
=
FakeDevice
(
targetPlatform:
TargetPlatform
.
android_arm
);
final
DefaultResidentCompiler
residentCompiler
=
(
await
FlutterDevice
.
create
(
final
DefaultResidentCompiler
residentCompiler
=
(
await
FlutterDevice
.
create
(
mockD
evice
,
d
evice
,
buildInfo:
const
BuildInfo
(
buildInfo:
const
BuildInfo
(
BuildMode
.
debug
,
BuildMode
.
debug
,
''
,
''
,
...
@@ -2084,7 +1821,7 @@ void main() {
...
@@ -2084,7 +1821,7 @@ void main() {
testUsingContext
(
'Handle existing VM service clients DDS error'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'Handle existing VM service clients DDS error'
,
()
=>
testbed
.
run
(()
async
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]);
final
FakeDevice
mockD
evice
=
FakeDevice
()
final
FakeDevice
d
evice
=
FakeDevice
()
..
dds
=
DartDevelopmentService
();
..
dds
=
DartDevelopmentService
();
ddsLauncherCallback
=
(
Uri
uri
,
{
bool
enableAuthCodes
,
bool
ipv6
,
Uri
serviceUri
})
{
ddsLauncherCallback
=
(
Uri
uri
,
{
bool
enableAuthCodes
,
bool
ipv6
,
Uri
serviceUri
})
{
throw
FakeDartDevelopmentServiceException
(
message:
throw
FakeDartDevelopmentServiceException
(
message:
...
@@ -2092,7 +1829,7 @@ void main() {
...
@@ -2092,7 +1829,7 @@ void main() {
);
);
};
};
final
TestFlutterDevice
flutterDevice
=
TestFlutterDevice
(
final
TestFlutterDevice
flutterDevice
=
TestFlutterDevice
(
mockD
evice
,
d
evice
,
observatoryUris:
Stream
<
Uri
>.
value
(
testUri
),
observatoryUris:
Stream
<
Uri
>.
value
(
testUri
),
);
);
bool
caught
=
false
;
bool
caught
=
false
;
...
@@ -2126,13 +1863,13 @@ void main() {
...
@@ -2126,13 +1863,13 @@ void main() {
testUsingContext
(
'Failed DDS start outputs error message'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'Failed DDS start outputs error message'
,
()
=>
testbed
.
run
(()
async
{
// See https://github.com/flutter/flutter/issues/72385 for context.
// See https://github.com/flutter/flutter/issues/72385 for context.
final
FakeDevice
mockD
evice
=
FakeDevice
()
final
FakeDevice
d
evice
=
FakeDevice
()
..
dds
=
DartDevelopmentService
();
..
dds
=
DartDevelopmentService
();
ddsLauncherCallback
=
(
Uri
uri
,
{
bool
enableAuthCodes
,
bool
ipv6
,
Uri
serviceUri
})
{
ddsLauncherCallback
=
(
Uri
uri
,
{
bool
enableAuthCodes
,
bool
ipv6
,
Uri
serviceUri
})
{
throw
FakeDartDevelopmentServiceException
(
message:
'No URI'
);
throw
FakeDartDevelopmentServiceException
(
message:
'No URI'
);
};
};
final
TestFlutterDevice
flutterDevice
=
TestFlutterDevice
(
final
TestFlutterDevice
flutterDevice
=
TestFlutterDevice
(
mockD
evice
,
d
evice
,
observatoryUris:
Stream
<
Uri
>.
value
(
testUri
),
observatoryUris:
Stream
<
Uri
>.
value
(
testUri
),
);
);
bool
caught
=
false
;
bool
caught
=
false
;
...
@@ -2176,7 +1913,7 @@ void main() {
...
@@ -2176,7 +1913,7 @@ void main() {
testUsingContext
(
'cleanupAtFinish shuts down resident devtools handler'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'cleanupAtFinish shuts down resident devtools handler'
,
()
=>
testbed
.
run
(()
async
{
residentRunner
=
HotRunner
(
residentRunner
=
HotRunner
(
<
FlutterDevice
>[
<
FlutterDevice
>[
mockF
lutterDevice
,
f
lutterDevice
,
],
],
stayResident:
false
,
stayResident:
false
,
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
,
vmserviceOutFile:
'foo'
),
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
,
vmserviceOutFile:
'foo'
),
...
@@ -2189,9 +1926,6 @@ void main() {
...
@@ -2189,9 +1926,6 @@ void main() {
}));
}));
}
}
class
MockFlutterDevice
extends
Mock
implements
FlutterDevice
{}
class
MockResidentCompiler
extends
Mock
implements
ResidentCompiler
{}
class
FakeDartDevelopmentServiceException
implements
dds
.
DartDevelopmentServiceException
{
class
FakeDartDevelopmentServiceException
implements
dds
.
DartDevelopmentServiceException
{
FakeDartDevelopmentServiceException
({
this
.
message
=
defaultMessage
});
FakeDartDevelopmentServiceException
({
this
.
message
=
defaultMessage
});
...
@@ -2226,8 +1960,105 @@ class ThrowingForwardingFileSystem extends ForwardingFileSystem {
...
@@ -2226,8 +1960,105 @@ class ThrowingForwardingFileSystem extends ForwardingFileSystem {
}
}
}
}
class
FakeFlutterDevice
extends
FlutterDevice
{
class
FakeFlutterDevice
extends
Fake
implements
FlutterDevice
{
FakeFlutterDevice
(
FakeVmServiceHost
Function
()
vmServiceHost
;
Uri
testUri
;
UpdateFSReport
report
=
UpdateFSReport
(
success:
true
,
syncedBytes:
0
,
invalidatedSourcesCount:
1
,
);
Object
reportError
;
Object
runColdError
;
int
runHotCode
=
0
;
int
runColdCode
=
0
;
@override
ResidentCompiler
generator
;
@override
Stream
<
Uri
>
get
observatoryUris
=>
Stream
<
Uri
>.
value
(
testUri
);
@override
FlutterVmService
get
vmService
=>
vmServiceHost
?.
call
()?.
vmService
;
DevFS
_devFS
;
@override
DevFS
get
devFS
=>
_devFS
;
@override
set
devFS
(
DevFS
value
)
{
}
@override
Device
device
;
@override
Future
<
void
>
stopEchoingDeviceLog
()
async
{
}
@override
Future
<
void
>
initLogReader
()
async
{
}
@override
Future
<
Uri
>
setupDevFS
(
String
fsName
,
Directory
rootDirectory
)
async
{
return
testUri
;
}
@override
Future
<
int
>
runHot
({
HotRunner
hotRunner
,
String
route
})
async
{
return
runHotCode
;
}
@override
Future
<
int
>
runCold
({
ColdRunner
coldRunner
,
String
route
})
async
{
if
(
runColdError
!=
null
)
{
throw
runColdError
;
}
return
runColdCode
;
}
@override
Future
<
void
>
connect
({
ReloadSources
reloadSources
,
Restart
restart
,
CompileExpression
compileExpression
,
GetSkSLMethod
getSkSLMethod
,
PrintStructuredErrorLogMethod
printStructuredErrorLogMethod
,
int
hostVmServicePort
,
int
ddsPort
,
bool
disableServiceAuthCodes
=
false
,
bool
enableDds
=
true
,
@required
bool
allowExistingDdsInstance
,
bool
ipv6
=
false
,
})
async
{
}
@override
Future
<
UpdateFSReport
>
updateDevFS
({
Uri
mainUri
,
String
target
,
AssetBundle
bundle
,
DateTime
firstBuildTime
,
bool
bundleFirstUpload
=
false
,
bool
bundleDirty
=
false
,
bool
fullRestart
=
false
,
String
projectRootPath
,
String
pathToReload
,
String
dillOutputPath
,
List
<
Uri
>
invalidatedFiles
,
PackageConfig
packageConfig
,
})
async
{
if
(
reportError
!=
null
)
{
throw
reportError
;
}
return
report
;
}
@override
Future
<
void
>
updateReloadStatus
(
bool
wasReloadSuccessful
)
async
{
}
}
class
FakeDelegateFlutterDevice
extends
FlutterDevice
{
FakeDelegateFlutterDevice
(
Device
device
,
Device
device
,
BuildInfo
buildInfo
,
BuildInfo
buildInfo
,
ResidentCompiler
residentCompiler
,
ResidentCompiler
residentCompiler
,
...
@@ -2260,6 +2091,9 @@ class FakeFlutterDevice extends FlutterDevice {
...
@@ -2260,6 +2091,9 @@ class FakeFlutterDevice extends FlutterDevice {
}
}
class
FakeResidentCompiler
extends
Fake
implements
ResidentCompiler
{
class
FakeResidentCompiler
extends
Fake
implements
ResidentCompiler
{
CompilerOutput
nextOutput
;
bool
didSuppressErrors
=
false
;
@override
@override
Future
<
CompilerOutput
>
recompile
(
Future
<
CompilerOutput
>
recompile
(
Uri
mainUri
,
Uri
mainUri
,
...
@@ -2270,7 +2104,8 @@ class FakeResidentCompiler extends Fake implements ResidentCompiler {
...
@@ -2270,7 +2104,8 @@ class FakeResidentCompiler extends Fake implements ResidentCompiler {
@required
FileSystem
fs
,
@required
FileSystem
fs
,
bool
suppressErrors
=
false
,
bool
suppressErrors
=
false
,
})
async
{
})
async
{
return
const
CompilerOutput
(
'foo.dill'
,
0
,
<
Uri
>[]);
didSuppressErrors
=
suppressErrors
;
return
nextOutput
??
const
CompilerOutput
(
'foo.dill'
,
0
,
<
Uri
>[]);
}
}
@override
@override
...
...
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