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
335a3181
Unverified
Commit
335a3181
authored
May 12, 2021
by
Jonah Williams
Committed by
GitHub
May 12, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] remove mocks from hot test (#82301)
parent
f6842f78
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
68 deletions
+76
-68
hot_test.dart
packages/flutter_tools/test/general.shard/hot_test.dart
+76
-67
update_packages_test.dart
...lutter_tools/test/general.shard/update_packages_test.dart
+0
-1
No files found.
packages/flutter_tools/test/general.shard/hot_test.dart
View file @
335a3181
...
...
@@ -5,6 +5,7 @@
// @dart = 2.8
import
'package:file/memory.dart'
;
import
'package:flutter_tools/src/application_package.dart'
;
import
'package:flutter_tools/src/artifacts.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/io.dart'
;
...
...
@@ -18,7 +19,7 @@ import 'package:flutter_tools/src/resident_runner.dart';
import
'package:flutter_tools/src/run_hot.dart'
;
import
'package:flutter_tools/src/vmservice.dart'
;
import
'package:meta/meta.dart'
;
import
'package:
mockito/mockito
.dart'
;
import
'package:
test/fake
.dart'
;
import
'package:vm_service/vm_service.dart'
as
vm_service
;
import
'../src/common.dart'
;
...
...
@@ -144,30 +145,8 @@ void main() {
group
(
'hotRestart'
,
()
{
final
FakeResidentCompiler
residentCompiler
=
FakeResidentCompiler
();
final
MockDevFs
mockDevFs
=
MockDevFs
();
FileSystem
fileSystem
;
when
(
mockDevFs
.
update
(
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
_
)
=>
Future
<
UpdateFSReport
>.
value
(
UpdateFSReport
(
success:
true
,
syncedBytes:
1000
,
invalidatedSourcesCount:
1
)));
when
(
mockDevFs
.
assetPathsToEvict
).
thenReturn
(<
String
>{});
when
(
mockDevFs
.
baseUri
).
thenReturn
(
Uri
.
file
(
'test'
));
when
(
mockDevFs
.
sources
).
thenReturn
(<
Uri
>[
Uri
.
file
(
'test'
)]);
when
(
mockDevFs
.
lastCompiled
).
thenReturn
(
DateTime
.
now
());
setUp
(()
{
fileSystem
=
MemoryFileSystem
.
test
();
});
...
...
@@ -176,12 +155,9 @@ void main() {
fileSystem
.
file
(
'.packages'
)
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
'
\n
'
);
final
MockDevice
mockDevice
=
MockDevice
();
when
(
mockDevice
.
supportsHotReload
).
thenReturn
(
true
);
when
(
mockDevice
.
supportsHotRestart
).
thenReturn
(
true
);
when
(
mockDevice
.
targetPlatform
).
thenAnswer
((
Invocation
_
)
async
=>
TargetPlatform
.
tester
);
final
FakeDevice
device
=
FakeDevice
();
final
List
<
FlutterDevice
>
devices
=
<
FlutterDevice
>[
FlutterDevice
(
mockDevice
,
generator:
residentCompiler
,
buildInfo:
BuildInfo
.
debug
)..
devFS
=
Mock
DevFs
(),
FlutterDevice
(
device
,
generator:
residentCompiler
,
buildInfo:
BuildInfo
.
debug
)..
devFS
=
Fake
DevFs
(),
];
final
OperationResult
result
=
await
HotRunner
(
devices
,
...
...
@@ -212,12 +188,9 @@ void main() {
fileSystem
.
file
(
'.packages'
)
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
'
\n
'
);
final
MockDevice
mockDevice
=
MockDevice
();
when
(
mockDevice
.
supportsHotReload
).
thenReturn
(
true
);
when
(
mockDevice
.
supportsHotRestart
).
thenReturn
(
true
);
when
(
mockDevice
.
supportsFlutterExit
).
thenReturn
(
false
);
final
FakeDevice
device
=
FakeDevice
();
final
List
<
FlutterDevice
>
devices
=
<
FlutterDevice
>[
FlutterDevice
(
mockD
evice
,
generator:
residentCompiler
,
buildInfo:
BuildInfo
.
debug
),
FlutterDevice
(
d
evice
,
generator:
residentCompiler
,
buildInfo:
BuildInfo
.
debug
),
];
await
HotRunner
(
devices
,
...
...
@@ -237,12 +210,9 @@ void main() {
fileSystem
.
file
(
'.packages'
)
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
'
\n
'
);
final
MockDevice
mockDevice
=
MockDevice
();
when
(
mockDevice
.
supportsHotReload
).
thenReturn
(
true
);
when
(
mockDevice
.
supportsHotRestart
).
thenReturn
(
true
);
when
(
mockDevice
.
supportsFlutterExit
).
thenReturn
(
false
);
final
FakeDevice
device
=
FakeDevice
();
final
List
<
FlutterDevice
>
devices
=
<
FlutterDevice
>[
FlutterDevice
(
mockD
evice
,
generator:
residentCompiler
,
buildInfo:
BuildInfo
.
debug
),
FlutterDevice
(
d
evice
,
generator:
residentCompiler
,
buildInfo:
BuildInfo
.
debug
),
];
await
HotRunner
(
devices
,
...
...
@@ -274,15 +244,10 @@ void main() {
..
writeAsStringSync
(
'
\n
'
);
final
FakeResidentCompiler
residentCompiler
=
FakeResidentCompiler
();
final
MockDevice
mockDevice
=
MockDevice
();
when
(
mockDevice
.
supportsHotReload
).
thenReturn
(
true
);
when
(
mockDevice
.
supportsHotRestart
).
thenReturn
(
false
);
when
(
mockDevice
.
targetPlatform
).
thenAnswer
((
Invocation
_
)
async
=>
TargetPlatform
.
tester
);
when
(
mockDevice
.
sdkNameAndVersion
).
thenAnswer
((
Invocation
_
)
async
=>
'Android 10'
);
final
FakeDevice
device
=
FakeDevice
();
final
List
<
FlutterDevice
>
devices
=
<
FlutterDevice
>[
TestFlutterDevice
(
device:
mockD
evice
,
device:
d
evice
,
generator:
residentCompiler
,
exception:
const
HttpException
(
'Connection closed before full header was received, '
'uri = http://127.0.0.1:63394/5ZmLv8A59xY=/ws'
),
...
...
@@ -306,22 +271,15 @@ void main() {
});
group
(
'hot cleanupAtFinish()'
,
()
{
MockFlutterDevice
mockFlutterDeviceFactory
(
Device
device
)
{
final
MockFlutterDevice
mockFlutterDevice
=
MockFlutterDevice
();
when
(
mockFlutterDevice
.
stopEchoingDeviceLog
()).
thenAnswer
((
Invocation
invocation
)
=>
Future
<
void
>.
value
(
null
));
when
(
mockFlutterDevice
.
device
).
thenReturn
(
device
);
return
mockFlutterDevice
;
}
testUsingContext
(
'disposes each device'
,
()
async
{
final
MockDevice
mockDevice1
=
Mock
Device
();
final
MockDevice
mockDevice2
=
Mock
Device
();
final
MockFlutterDevice
mockFlutterDevice1
=
mockFlutterDeviceFactory
(
mockD
evice1
);
final
MockFlutterDevice
mockFlutterDevice2
=
mockFlutterDeviceFactory
(
mockD
evice2
);
final
FakeDevice
device1
=
Fake
Device
();
final
FakeDevice
device2
=
Fake
Device
();
final
FakeFlutterDevice
flutterDevice1
=
FakeFlutterDevice
(
d
evice1
);
final
FakeFlutterDevice
flutterDevice2
=
FakeFlutterDevice
(
d
evice2
);
final
List
<
FlutterDevice
>
devices
=
<
FlutterDevice
>[
mockF
lutterDevice1
,
mockF
lutterDevice2
,
f
lutterDevice1
,
f
lutterDevice2
,
];
await
HotRunner
(
devices
,
...
...
@@ -329,23 +287,74 @@ void main() {
target:
'main.dart'
,
).
cleanupAtFinish
();
verify
(
mockDevice1
.
dispose
());
verify
(
mockFlutterDevice1
.
stopEchoingDeviceLog
());
verify
(
mockDevice2
.
dispose
());
verify
(
mockFlutterDevice2
.
stopEchoingDeviceLog
());
expect
(
device1
.
disposed
,
true
);
expect
(
device2
.
disposed
,
true
);
expect
(
flutterDevice1
.
stoppedEchoingDeviceLog
,
true
);
expect
(
flutterDevice2
.
stoppedEchoingDeviceLog
,
true
);
});
});
}
class
MockDevFs
extends
Mock
implements
DevFS
{}
class
FakeDevFs
extends
Fake
implements
DevFS
{
@override
Future
<
void
>
destroy
()
async
{
}
}
class
FakeDevice
extends
Fake
implements
Device
{
bool
disposed
=
false
;
@override
bool
isSupported
()
=>
true
;
@override
bool
supportsHotReload
=
true
;
class
MockDevice
extends
Mock
implements
Device
{
MockDevice
()
{
when
(
isSupported
()).
thenReturn
(
true
);
@override
bool
supportsHotRestart
=
true
;
@override
bool
supportsFlutterExit
=
true
;
@override
Future
<
TargetPlatform
>
get
targetPlatform
async
=>
TargetPlatform
.
tester
;
@override
Future
<
String
>
get
sdkNameAndVersion
async
=>
'Tester'
;
@override
Future
<
bool
>
get
isLocalEmulator
async
=>
false
;
@override
Future
<
bool
>
stopApp
(
covariant
ApplicationPackage
app
,
{
String
userIdentifier
,
})
async
{
return
true
;
}
@override
Future
<
void
>
dispose
()
async
{
disposed
=
true
;
}
}
class
MockFlutterDevice
extends
Mock
implements
FlutterDevice
{}
class
FakeFlutterDevice
extends
Fake
implements
FlutterDevice
{
FakeFlutterDevice
(
this
.
device
);
bool
stoppedEchoingDeviceLog
=
false
;
@override
final
FakeDevice
device
;
@override
Future
<
void
>
stopEchoingDeviceLog
()
async
{
stoppedEchoingDeviceLog
=
true
;
}
@override
DevFS
devFS
=
FakeDevFs
();
}
class
TestFlutterDevice
extends
FlutterDevice
{
TestFlutterDevice
({
...
...
packages/flutter_tools/test/general.shard/update_packages_test.dart
View file @
335a3181
...
...
@@ -42,7 +42,6 @@ dev_dependencies:
sdk: flutter
flutter_goldens:
sdk: flutter
mockito: 4.1.1
archive: 2.0.11 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
...
...
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