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
8beee479
Unverified
Commit
8beee479
authored
May 24, 2021
by
Jonah Williams
Committed by
GitHub
May 24, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] remove more mocks from resident_runner tests (#83155)
parent
4bcf8fb4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
87 additions
and
195 deletions
+87
-195
resident_runner_test.dart
...lutter_tools/test/general.shard/resident_runner_test.dart
+87
-195
No files found.
packages/flutter_tools/test/general.shard/resident_runner_test.dart
View file @
8beee479
...
@@ -11,6 +11,7 @@ import 'package:file/memory.dart';
...
@@ -11,6 +11,7 @@ import 'package:file/memory.dart';
import
'package:file_testing/file_testing.dart'
;
import
'package:file_testing/file_testing.dart'
;
import
'package:flutter_tools/src/application_package.dart'
;
import
'package:flutter_tools/src/application_package.dart'
;
import
'package:flutter_tools/src/artifacts.dart'
;
import
'package:flutter_tools/src/artifacts.dart'
;
import
'package:flutter_tools/src/asset.dart'
;
import
'package:flutter_tools/src/base/command_help.dart'
;
import
'package:flutter_tools/src/base/command_help.dart'
;
import
'package:flutter_tools/src/base/common.dart'
;
import
'package:flutter_tools/src/base/common.dart'
;
import
'package:flutter_tools/src/base/dds.dart'
;
import
'package:flutter_tools/src/base/dds.dart'
;
...
@@ -143,11 +144,10 @@ void main() {
...
@@ -143,11 +144,10 @@ void main() {
Testbed
testbed
;
Testbed
testbed
;
MockFlutterDevice
mockFlutterDevice
;
MockFlutterDevice
mockFlutterDevice
;
MockVMService
mockVMService
;
MockVMService
mockVMService
;
Mock
DevFS
mockDevFS
;
Fake
DevFS
mockDevFS
;
ResidentRunner
residentRunner
;
ResidentRunner
residentRunner
;
FakeDevice
mockDevice
;
FakeDevice
mockDevice
;
FakeVmServiceHost
fakeVmServiceHost
;
FakeVmServiceHost
fakeVmServiceHost
;
MockDevtoolsLauncher
mockDevtoolsLauncher
;
setUp
(()
{
setUp
(()
{
testbed
=
Testbed
(
setup:
()
{
testbed
=
Testbed
(
setup:
()
{
...
@@ -169,15 +169,7 @@ void main() {
...
@@ -169,15 +169,7 @@ void main() {
mockFlutterDevice
=
MockFlutterDevice
();
mockFlutterDevice
=
MockFlutterDevice
();
mockDevice
=
FakeDevice
();
mockDevice
=
FakeDevice
();
mockVMService
=
MockVMService
();
mockVMService
=
MockVMService
();
mockDevFS
=
MockDevFS
();
mockDevFS
=
FakeDevFS
();
mockDevtoolsLauncher
=
MockDevtoolsLauncher
();
// DevFS Mocks
when
(
mockDevFS
.
lastCompiled
).
thenReturn
(
DateTime
(
2000
));
when
(
mockDevFS
.
sources
).
thenReturn
(<
Uri
>[]);
when
(
mockDevFS
.
baseUri
).
thenReturn
(
Uri
());
when
(
mockDevFS
.
destroy
()).
thenAnswer
((
Invocation
invocation
)
async
{
});
when
(
mockDevFS
.
assetPathsToEvict
).
thenReturn
(<
String
>{});
// FlutterDevice Mocks.
// FlutterDevice Mocks.
when
(
mockFlutterDevice
.
updateDevFS
(
when
(
mockFlutterDevice
.
updateDevFS
(
invalidatedFiles:
anyNamed
(
'invalidatedFiles'
),
invalidatedFiles:
anyNamed
(
'invalidatedFiles'
),
...
@@ -242,9 +234,7 @@ void main() {
...
@@ -242,9 +234,7 @@ void main() {
expect
((
await
connectionInfo
).
baseUri
,
'foo://bar'
);
expect
((
await
connectionInfo
).
baseUri
,
'foo://bar'
);
expect
(
futureAppStart
.
isCompleted
,
true
);
expect
(
futureAppStart
.
isCompleted
,
true
);
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
}),
overrides:
<
Type
,
Generator
>{
}));
DevtoolsLauncher:
()
=>
mockDevtoolsLauncher
,
});
testUsingContext
(
'ResidentRunner suppresses errors for the initial compilation'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'ResidentRunner suppresses errors for the initial compilation'
,
()
=>
testbed
.
run
(()
async
{
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'lib'
,
'main.dart'
))
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'lib'
,
'main.dart'
))
...
@@ -294,9 +284,7 @@ void main() {
...
@@ -294,9 +284,7 @@ void main() {
fs:
anyNamed
(
'fs'
),
fs:
anyNamed
(
'fs'
),
)).
called
(
1
);
)).
called
(
1
);
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
}),
overrides:
<
Type
,
Generator
>{
}));
DevtoolsLauncher:
()
=>
mockDevtoolsLauncher
,
});
// Regression test for https://github.com/flutter/flutter/issues/60613
// Regression test for https://github.com/flutter/flutter/issues/60613
testUsingContext
(
'ResidentRunner calls appFailedToStart if initial compilation fails'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'ResidentRunner calls appFailedToStart if initial compilation fails'
,
()
=>
testbed
.
run
(()
async
{
...
@@ -438,9 +426,7 @@ void main() {
...
@@ -438,9 +426,7 @@ void main() {
fs:
anyNamed
(
'fs'
),
fs:
anyNamed
(
'fs'
),
)).
called
(
1
);
)).
called
(
1
);
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
}),
overrides:
<
Type
,
Generator
>{
}));
DevtoolsLauncher:
()
=>
mockDevtoolsLauncher
,
});
testUsingContext
(
'ResidentRunner can attach to device successfully with --fast-start'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'ResidentRunner can attach to device successfully with --fast-start'
,
()
=>
testbed
.
run
(()
async
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
@@ -512,9 +498,7 @@ void main() {
...
@@ -512,9 +498,7 @@ void main() {
expect
((
await
connectionInfo
).
baseUri
,
'foo://bar'
);
expect
((
await
connectionInfo
).
baseUri
,
'foo://bar'
);
expect
(
futureAppStart
.
isCompleted
,
true
);
expect
(
futureAppStart
.
isCompleted
,
true
);
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
}),
overrides:
<
Type
,
Generator
>{
}));
DevtoolsLauncher:
()
=>
mockDevtoolsLauncher
,
});
testUsingContext
(
'ResidentRunner can handle an RPC exception from hot reload'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'ResidentRunner can handle an RPC exception from hot reload'
,
()
=>
testbed
.
run
(()
async
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
@@ -560,9 +544,7 @@ void main() {
...
@@ -560,9 +544,7 @@ void main() {
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
Usage:
()
=>
TestUsage
(),
Usage:
()
=>
TestUsage
(),
}),
overrides:
<
Type
,
Generator
>{
}));
DevtoolsLauncher:
()
=>
mockDevtoolsLauncher
,
});
testUsingContext
(
'ResidentRunner fails its operation if the device initialization is not complete'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'ResidentRunner fails its operation if the device initialization is not complete'
,
()
=>
testbed
.
run
(()
async
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
@@ -632,9 +614,7 @@ void main() {
...
@@ -632,9 +614,7 @@ void main() {
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
Usage:
()
=>
TestUsage
(),
Usage:
()
=>
TestUsage
(),
}),
overrides:
<
Type
,
Generator
>{
}));
DevtoolsLauncher:
()
=>
mockDevtoolsLauncher
,
});
testUsingContext
(
'ResidentRunner reports hot reload event with null safety analytics'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'ResidentRunner reports hot reload event with null safety analytics'
,
()
=>
testbed
.
run
(()
async
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
@@ -693,7 +673,6 @@ void main() {
...
@@ -693,7 +673,6 @@ void main() {
));
));
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
DevtoolsLauncher:
()
=>
mockDevtoolsLauncher
,
Usage:
()
=>
TestUsage
(),
Usage:
()
=>
TestUsage
(),
}));
}));
...
@@ -755,9 +734,7 @@ void main() {
...
@@ -755,9 +734,7 @@ void main() {
expect
(
result
.
code
,
0
);
expect
(
result
.
code
,
0
);
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
}),
overrides:
<
Type
,
Generator
>{
}));
DevtoolsLauncher:
()
=>
mockDevtoolsLauncher
,
});
testUsingContext
(
'ResidentRunner reports error with missing entrypoint file'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'ResidentRunner reports error with missing entrypoint file'
,
()
=>
testbed
.
run
(()
async
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
@@ -833,9 +810,7 @@ void main() {
...
@@ -833,9 +810,7 @@ void main() {
expect
(
testLogger
.
errorText
,
contains
(
'The entrypoint file (i.e. the file with main())'
));
expect
(
testLogger
.
errorText
,
contains
(
'The entrypoint file (i.e. the file with main())'
));
expect
(
result
.
fatal
,
false
);
expect
(
result
.
fatal
,
false
);
expect
(
result
.
code
,
0
);
expect
(
result
.
code
,
0
);
}),
overrides:
<
Type
,
Generator
>{
}));
DevtoolsLauncher:
()
=>
mockDevtoolsLauncher
,
});
testUsingContext
(
'ResidentRunner resets compilation time on reload reject'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'ResidentRunner resets compilation time on reload reject'
,
()
=>
testbed
.
run
(()
async
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
@@ -914,10 +889,8 @@ void main() {
...
@@ -914,10 +889,8 @@ void main() {
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
);
verify
(
mockDevFS
.
resetLastCompiled
()).
called
(
1
);
// compilation time is reset.
expect
(
mockDevFS
.
lastCompiled
,
null
);
}),
overrides:
<
Type
,
Generator
>{
}));
DevtoolsLauncher:
()
=>
mockDevtoolsLauncher
,
});
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
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
@@ -981,9 +954,7 @@ void main() {
...
@@ -981,9 +954,7 @@ void main() {
expect
(
event
.
parameters
.
hotEventTargetPlatform
,
getNameForTargetPlatform
(
TargetPlatform
.
android_arm
));
expect
(
event
.
parameters
.
hotEventTargetPlatform
,
getNameForTargetPlatform
(
TargetPlatform
.
android_arm
));
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
Usage:
()
=>
TestUsage
(),
Usage:
()
=>
TestUsage
(),
}),
overrides:
<
Type
,
Generator
>{
}));
DevtoolsLauncher:
()
=>
mockDevtoolsLauncher
,
});
testUsingContext
(
'ResidentRunner can perform fast reassemble'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'ResidentRunner can perform fast reassemble'
,
()
=>
testbed
.
run
(()
async
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
@@ -1044,27 +1015,11 @@ void main() {
...
@@ -1044,27 +1015,11 @@ void main() {
target:
'main.dart'
,
target:
'main.dart'
,
devtoolsHandler:
createNoOpHandler
,
devtoolsHandler:
createNoOpHandler
,
);
);
when
(
mockDevFS
.
update
(
mockDevFS
.
nextUpdateReport
=
UpdateFSReport
(
mainUri:
anyNamed
(
'mainUri'
),
target:
anyNamed
(
'target'
),
bundle:
anyNamed
(
'bundle'
),
firstBuildTime:
anyNamed
(
'firstBuildTime'
),
bundleFirstUpload:
anyNamed
(
'bundleFirstUpload'
),
generator:
anyNamed
(
'generator'
),
fullRestart:
anyNamed
(
'fullRestart'
),
dillOutputPath:
anyNamed
(
'dillOutputPath'
),
trackWidgetCreation:
anyNamed
(
'trackWidgetCreation'
),
projectRootPath:
anyNamed
(
'projectRootPath'
),
pathToReload:
anyNamed
(
'pathToReload'
),
invalidatedFiles:
anyNamed
(
'invalidatedFiles'
),
packageConfig:
anyNamed
(
'packageConfig'
),
)).
thenAnswer
((
Invocation
invocation
)
async
{
return
UpdateFSReport
(
success:
true
,
success:
true
,
fastReassembleClassName:
'FOO'
,
fastReassembleClassName:
'FOO'
,
invalidatedSourcesCount:
1
,
invalidatedSourcesCount:
1
,
);
);
});
final
Completer
<
DebugConnectionInfo
>
futureConnectionInfo
=
Completer
<
DebugConnectionInfo
>.
sync
();
final
Completer
<
DebugConnectionInfo
>
futureConnectionInfo
=
Completer
<
DebugConnectionInfo
>.
sync
();
final
Completer
<
void
>
futureAppStart
=
Completer
<
void
>.
sync
();
final
Completer
<
void
>
futureAppStart
=
Completer
<
void
>.
sync
();
...
@@ -1090,9 +1045,7 @@ void main() {
...
@@ -1090,9 +1045,7 @@ void main() {
ProjectFileInvalidator:
()
=>
FakeProjectFileInvalidator
(),
ProjectFileInvalidator:
()
=>
FakeProjectFileInvalidator
(),
Usage:
()
=>
TestUsage
(),
Usage:
()
=>
TestUsage
(),
FeatureFlags:
()
=>
TestFeatureFlags
(
isSingleWidgetReloadEnabled:
true
),
FeatureFlags:
()
=>
TestFeatureFlags
(
isSingleWidgetReloadEnabled:
true
),
}),
overrides:
<
Type
,
Generator
>{
}));
DevtoolsLauncher:
()
=>
mockDevtoolsLauncher
,
});
testUsingContext
(
'ResidentRunner can send target platform to analytics from full restart'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'ResidentRunner can send target platform to analytics from full restart'
,
()
=>
testbed
.
run
(()
async
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
@@ -1153,9 +1106,7 @@ void main() {
...
@@ -1153,9 +1106,7 @@ void main() {
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
Usage:
()
=>
TestUsage
(),
Usage:
()
=>
TestUsage
(),
}),
overrides:
<
Type
,
Generator
>{
}));
DevtoolsLauncher:
()
=>
mockDevtoolsLauncher
,
});
testUsingContext
(
'ResidentRunner can remove breakpoints from paused isolate during hot restart'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'ResidentRunner can remove breakpoints from paused isolate during hot restart'
,
()
=>
testbed
.
run
(()
async
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
@@ -1222,9 +1173,7 @@ void main() {
...
@@ -1222,9 +1173,7 @@ void main() {
expect
(
result
.
isOk
,
true
);
expect
(
result
.
isOk
,
true
);
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
}),
overrides:
<
Type
,
Generator
>{
}));
DevtoolsLauncher:
()
=>
mockDevtoolsLauncher
,
});
testUsingContext
(
'ResidentRunner will alternative the name of the dill file uploaded for a hot restart'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'ResidentRunner will alternative the name of the dill file uploaded for a hot restart'
,
()
=>
testbed
.
run
(()
async
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
@@ -1347,9 +1296,7 @@ void main() {
...
@@ -1347,9 +1296,7 @@ void main() {
await
residentRunner
.
restart
(
fullRestart:
true
);
await
residentRunner
.
restart
(
fullRestart:
true
);
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
}),
overrides:
<
Type
,
Generator
>{
}));
DevtoolsLauncher:
()
=>
mockDevtoolsLauncher
,
});
testUsingContext
(
'ResidentRunner Can handle an RPC exception from hot restart'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'ResidentRunner Can handle an RPC exception from hot restart'
,
()
=>
testbed
.
run
(()
async
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
@@ -1395,9 +1342,7 @@ void main() {
...
@@ -1395,9 +1342,7 @@ void main() {
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
Usage:
()
=>
TestUsage
(),
Usage:
()
=>
TestUsage
(),
}),
overrides:
<
Type
,
Generator
>{
}));
DevtoolsLauncher:
()
=>
mockDevtoolsLauncher
,
});
testUsingContext
(
'ResidentRunner uses temp directory when there is no output dill path'
,
()
=>
testbed
.
run
(()
{
testUsingContext
(
'ResidentRunner uses temp directory when there is no output dill path'
,
()
=>
testbed
.
run
(()
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]);
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]);
...
@@ -1684,21 +1629,6 @@ void main() {
...
@@ -1684,21 +1629,6 @@ void main() {
FlutterVersion:
()
=>
FakeFlutterVersion
(
engineRevision:
'abcdefg'
)
FlutterVersion:
()
=>
FakeFlutterVersion
(
engineRevision:
'abcdefg'
)
}));
}));
testUsingContext
(
'ResidentRunner ignores DevToolsLauncher when attaching with enableDevTools: false'
,
()
=>
testbed
.
run
(()
async
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
listViews
,
listViews
,
setAssetBundlePath
,
]);
final
Future
<
int
>
result
=
residentRunner
.
attach
(
enableDevTools:
false
);
expect
(
await
result
,
0
);
// Verify DevTools was served.
verifyNever
(
mockDevtoolsLauncher
.
serve
());
}),
overrides:
<
Type
,
Generator
>{
DevtoolsLauncher:
()
=>
mockDevtoolsLauncher
,
});
testUsingContext
(
'ResidentRunner ignores DevtoolsLauncher when attaching with enableDevTools: false - cold mode'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'ResidentRunner ignores DevtoolsLauncher when attaching with enableDevTools: false - cold mode'
,
()
=>
testbed
.
run
(()
async
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
listViews
,
listViews
,
...
@@ -1723,12 +1653,7 @@ void main() {
...
@@ -1723,12 +1653,7 @@ void main() {
final
Future
<
int
>
result
=
residentRunner
.
attach
(
enableDevTools:
false
);
final
Future
<
int
>
result
=
residentRunner
.
attach
(
enableDevTools:
false
);
expect
(
await
result
,
0
);
expect
(
await
result
,
0
);
}));
// Verify DevTools was served.
verifyNever
(
mockDevtoolsLauncher
.
serve
());
}),
overrides:
<
Type
,
Generator
>{
DevtoolsLauncher:
()
=>
mockDevtoolsLauncher
,
});
testUsingContext
(
'FlutterDevice will not exit a paused isolate'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'FlutterDevice will not exit a paused isolate'
,
()
=>
testbed
.
run
(()
async
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
@@ -1906,9 +1831,7 @@ void main() {
...
@@ -1906,9 +1831,7 @@ void main() {
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
expect
(
await
globals
.
fs
.
file
(
'foo'
).
readAsString
(),
testUri
.
toString
());
expect
(
await
globals
.
fs
.
file
(
'foo'
).
readAsString
(),
testUri
.
toString
());
}),
overrides:
<
Type
,
Generator
>{
}));
DevtoolsLauncher:
()
=>
mockDevtoolsLauncher
,
});
testUsingContext
(
'HotRunner copies compiled app.dill to cache during startup'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'HotRunner copies compiled app.dill to cache during startup'
,
()
=>
testbed
.
run
(()
async
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
@@ -1936,9 +1859,7 @@ void main() {
...
@@ -1936,9 +1859,7 @@ void main() {
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'
);
}),
overrides:
<
Type
,
Generator
>{
}));
DevtoolsLauncher:
()
=>
mockDevtoolsLauncher
,
});
testUsingContext
(
'HotRunner copies compiled app.dill to cache during startup with dart defines'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'HotRunner copies compiled app.dill to cache during startup with dart defines'
,
()
=>
testbed
.
run
(()
async
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
@@ -1974,9 +1895,7 @@ void main() {
...
@@ -1974,9 +1895,7 @@ void main() {
expect
(
await
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
expect
(
await
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'build'
,
'187ef4436122d1cc2f40dc2b92f0eba0.cache.dill'
)).
readAsString
(),
'ABC'
);
'build'
,
'187ef4436122d1cc2f40dc2b92f0eba0.cache.dill'
)).
readAsString
(),
'ABC'
);
}),
overrides:
<
Type
,
Generator
>{
}));
DevtoolsLauncher:
()
=>
mockDevtoolsLauncher
,
});
testUsingContext
(
'HotRunner copies compiled app.dill to cache during startup with null safety'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'HotRunner copies compiled app.dill to cache during startup with null safety'
,
()
=>
testbed
.
run
(()
async
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
@@ -2012,9 +1931,7 @@ void main() {
...
@@ -2012,9 +1931,7 @@ void main() {
expect
(
await
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
expect
(
await
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'build'
,
'3416d3007730479552122f01c01e326d.cache.dill'
)).
readAsString
(),
'ABC'
);
'build'
,
'3416d3007730479552122f01c01e326d.cache.dill'
)).
readAsString
(),
'ABC'
);
}),
overrides:
<
Type
,
Generator
>{
}));
DevtoolsLauncher:
()
=>
mockDevtoolsLauncher
,
});
testUsingContext
(
'HotRunner does not copy app.dill if a dillOutputPath is given'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'HotRunner does not copy app.dill if a dillOutputPath is given'
,
()
=>
testbed
.
run
(()
async
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
@@ -2043,9 +1960,7 @@ void main() {
...
@@ -2043,9 +1960,7 @@ void main() {
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
));
}),
overrides:
<
Type
,
Generator
>{
}));
DevtoolsLauncher:
()
=>
mockDevtoolsLauncher
,
});
testUsingContext
(
'HotRunner copies compiled app.dill to cache during startup with --track-widget-creation'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'HotRunner copies compiled app.dill to cache during startup with --track-widget-creation'
,
()
=>
testbed
.
run
(()
async
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
@@ -2078,9 +1993,7 @@ void main() {
...
@@ -2078,9 +1993,7 @@ void main() {
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'
);
}),
overrides:
<
Type
,
Generator
>{
}));
DevtoolsLauncher:
()
=>
mockDevtoolsLauncher
,
});
testUsingContext
(
'HotRunner calls device dispose'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'HotRunner calls device dispose'
,
()
=>
testbed
.
run
(()
async
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
@@ -2107,9 +2020,7 @@ void main() {
...
@@ -2107,9 +2020,7 @@ void main() {
await
residentRunner
.
run
();
await
residentRunner
.
run
();
expect
(
mockDevice
.
disposed
,
true
);
expect
(
mockDevice
.
disposed
,
true
);
}),
overrides:
<
Type
,
Generator
>{
}));
DevtoolsLauncher:
()
=>
mockDevtoolsLauncher
,
});
testUsingContext
(
'HotRunner handles failure to write vmservice file'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'HotRunner handles failure to write vmservice file'
,
()
=>
testbed
.
run
(()
async
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[
...
@@ -2139,9 +2050,7 @@ void main() {
...
@@ -2139,9 +2050,7 @@ void main() {
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
ThrowingForwardingFileSystem
(
MemoryFileSystem
.
test
()),
FileSystem:
()
=>
ThrowingForwardingFileSystem
(
MemoryFileSystem
.
test
()),
}),
overrides:
<
Type
,
Generator
>{
}));
DevtoolsLauncher:
()
=>
mockDevtoolsLauncher
,
});
testUsingContext
(
'ColdRunner writes vm service file when providing debugging option'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'ColdRunner writes vm service file when providing debugging option'
,
()
=>
testbed
.
run
(()
async
{
...
@@ -2168,9 +2077,7 @@ void main() {
...
@@ -2168,9 +2077,7 @@ void main() {
expect
(
await
globals
.
fs
.
file
(
'foo'
).
readAsString
(),
testUri
.
toString
());
expect
(
await
globals
.
fs
.
file
(
'foo'
).
readAsString
(),
testUri
.
toString
());
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
expect
(
fakeVmServiceHost
.
hasRemainingExpectations
,
false
);
}),
overrides:
<
Type
,
Generator
>{
}));
DevtoolsLauncher:
()
=>
mockDevtoolsLauncher
,
});
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
>[]);
...
@@ -2231,7 +2138,7 @@ void main() {
...
@@ -2231,7 +2138,7 @@ void main() {
Artifacts:
()
=>
Artifacts
.
test
(),
Artifacts:
()
=>
Artifacts
.
test
(),
FileSystem:
()
=>
MemoryFileSystem
.
test
(),
FileSystem:
()
=>
MemoryFileSystem
.
test
(),
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
}
,
skip:
true
);
// TODO(jonahwilliams): null safe autodetection does not work on the web.
}
);
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
>[]);
...
@@ -2282,69 +2189,6 @@ void main() {
...
@@ -2282,69 +2189,6 @@ void main() {
FeatureFlags:
()
=>
TestFeatureFlags
(
isExperimentalInvalidationStrategyEnabled:
true
)
FeatureFlags:
()
=>
TestFeatureFlags
(
isExperimentalInvalidationStrategyEnabled:
true
)
});
});
testUsingContext
(
'connect sets up log reader'
,
()
=>
testbed
.
run
(()
async
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]);
final
MockDevice
mockDevice
=
MockDevice
();
final
MockDartDevelopmentService
mockDds
=
MockDartDevelopmentService
();
final
MockDeviceLogReader
mockLogReader
=
MockDeviceLogReader
();
final
Completer
<
void
>
noopCompleter
=
Completer
<
void
>();
when
(
mockDevice
.
getLogReader
(
app:
anyNamed
(
'app'
))).
thenReturn
(
mockLogReader
);
when
(
mockDevice
.
dds
).
thenReturn
(
mockDds
);
when
(
mockDds
.
startDartDevelopmentService
(
any
,
any
,
any
,
any
,
logger:
anyNamed
(
'logger'
))).
thenReturn
(
null
);
when
(
mockDds
.
uri
).
thenReturn
(
Uri
.
parse
(
'http://localhost:8181'
));
when
(
mockDds
.
done
).
thenAnswer
((
_
)
=>
noopCompleter
.
future
);
final
TestFlutterDevice
flutterDevice
=
TestFlutterDevice
(
mockDevice
,
observatoryUris:
Stream
<
Uri
>.
value
(
testUri
),
);
await
flutterDevice
.
connect
(
allowExistingDdsInstance:
true
);
verify
(
mockLogReader
.
connectedVMService
=
mockVMService
);
},
overrides:
<
Type
,
Generator
>{
VMServiceConnector:
()
=>
(
Uri
httpUri
,
{
ReloadSources
reloadSources
,
Restart
restart
,
CompileExpression
compileExpression
,
GetSkSLMethod
getSkSLMethod
,
PrintStructuredErrorLogMethod
printStructuredErrorLogMethod
,
io
.
CompressionOptions
compression
,
Device
device
,
Logger
logger
,
})
async
=>
mockVMService
,
}));
testUsingContext
(
'FlutterDevice handles existing DDS instance'
,
()
=>
testbed
.
run
(()
async
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]);
final
MockDevice
mockDevice
=
MockDevice
();
final
MockDartDevelopmentService
mockDds
=
MockDartDevelopmentService
();
final
MockDeviceLogReader
mockLogReader
=
MockDeviceLogReader
();
final
Completer
<
void
>
noopCompleter
=
Completer
<
void
>();
when
(
mockDevice
.
getLogReader
(
app:
anyNamed
(
'app'
))).
thenReturn
(
mockLogReader
);
when
(
mockDevice
.
dds
).
thenReturn
(
mockDds
);
when
(
mockDds
.
startDartDevelopmentService
(
any
,
any
,
any
,
any
,
logger:
anyNamed
(
'logger'
))).
thenThrow
(
FakeDartDevelopmentServiceException
());
when
(
mockDds
.
uri
).
thenReturn
(
Uri
.
parse
(
'http://localhost:1234'
));
when
(
mockDds
.
done
).
thenAnswer
((
_
)
=>
noopCompleter
.
future
);
final
TestFlutterDevice
flutterDevice
=
TestFlutterDevice
(
mockDevice
,
observatoryUris:
Stream
<
Uri
>.
value
(
testUri
),
);
await
flutterDevice
.
connect
(
allowExistingDdsInstance:
true
);
verify
(
mockLogReader
.
connectedVMService
=
mockVMService
);
},
overrides:
<
Type
,
Generator
>{
VMServiceConnector:
()
=>
(
Uri
httpUri
,
{
ReloadSources
reloadSources
,
Restart
restart
,
CompileExpression
compileExpression
,
GetSkSLMethod
getSkSLMethod
,
PrintStructuredErrorLogMethod
printStructuredErrorLogMethod
,
io
.
CompressionOptions
compression
,
Device
device
,
Logger
logger
,
})
async
=>
mockVMService
,
}));
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
mockDevice
=
FakeDevice
()
final
FakeDevice
mockDevice
=
FakeDevice
()
...
@@ -2454,13 +2298,9 @@ void main() {
...
@@ -2454,13 +2298,9 @@ void main() {
}
}
class
MockFlutterDevice
extends
Mock
implements
FlutterDevice
{}
class
MockFlutterDevice
extends
Mock
implements
FlutterDevice
{}
class
MockDartDevelopmentService
extends
Mock
implements
DartDevelopmentService
{}
class
MockVMService
extends
Mock
implements
FlutterVmService
{}
class
MockVMService
extends
Mock
implements
FlutterVmService
{}
class
MockDevFS
extends
Mock
implements
DevFS
{}
class
MockDevFS
extends
Mock
implements
DevFS
{}
class
MockDeviceLogReader
extends
Mock
implements
DeviceLogReader
{}
class
MockDevtoolsLauncher
extends
Mock
implements
DevtoolsLauncher
{}
class
MockResidentCompiler
extends
Mock
implements
ResidentCompiler
{}
class
MockResidentCompiler
extends
Mock
implements
ResidentCompiler
{}
class
MockDevice
extends
Mock
implements
Device
{}
class
FakeDartDevelopmentServiceException
implements
dds
.
DartDevelopmentServiceException
{
class
FakeDartDevelopmentServiceException
implements
dds
.
DartDevelopmentServiceException
{
FakeDartDevelopmentServiceException
({
this
.
message
=
defaultMessage
});
FakeDartDevelopmentServiceException
({
this
.
message
=
defaultMessage
});
...
@@ -2643,3 +2483,55 @@ class FakeDevice extends Fake implements Device {
...
@@ -2643,3 +2483,55 @@ class FakeDevice extends Fake implements Device {
@override
@override
DevicePortForwarder
portForwarder
=
const
NoOpDevicePortForwarder
();
DevicePortForwarder
portForwarder
=
const
NoOpDevicePortForwarder
();
}
}
class
FakeDevFS
extends
Fake
implements
DevFS
{
@override
DateTime
lastCompiled
=
DateTime
(
2000
);
@override
PackageConfig
lastPackageConfig
=
PackageConfig
.
empty
;
@override
List
<
Uri
>
sources
=
<
Uri
>[];
@override
Uri
baseUri
=
Uri
();
@override
Future
<
void
>
destroy
()
async
{
}
@override
Set
<
String
>
assetPathsToEvict
=
<
String
>{};
UpdateFSReport
nextUpdateReport
=
UpdateFSReport
(
success:
true
);
@override
Future
<
Uri
>
create
()
async
{
return
Uri
();
}
@override
void
resetLastCompiled
()
{
lastCompiled
=
null
;
}
@override
Future
<
UpdateFSReport
>
update
({
@required
Uri
mainUri
,
@required
ResidentCompiler
generator
,
@required
bool
trackWidgetCreation
,
@required
String
pathToReload
,
@required
List
<
Uri
>
invalidatedFiles
,
@required
PackageConfig
packageConfig
,
@required
String
dillOutputPath
,
DevFSWriter
devFSWriter
,
String
target
,
AssetBundle
bundle
,
DateTime
firstBuildTime
,
bool
bundleFirstUpload
=
false
,
bool
fullRestart
=
false
,
String
projectRootPath
,
})
async
{
return
nextUpdateReport
;
}
}
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