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
428d7d7f
Unverified
Commit
428d7d7f
authored
Oct 15, 2019
by
Christopher Fujino
Committed by
GitHub
Oct 15, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dispose devices on cleanupAtFinish() for run_cold.dart (#42668)
parent
daa7143c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
111 additions
and
1 deletion
+111
-1
run_cold.dart
packages/flutter_tools/lib/src/run_cold.dart
+4
-0
run_test.dart
.../flutter_tools/test/commands.shard/hermetic/run_test.dart
+0
-1
cold_test.dart
packages/flutter_tools/test/general.shard/cold_test.dart
+75
-0
hot_test.dart
packages/flutter_tools/test/general.shard/hot_test.dart
+32
-0
No files found.
packages/flutter_tools/lib/src/run_cold.dart
View file @
428d7d7f
...
...
@@ -168,6 +168,10 @@ class ColdRunner extends ResidentRunner {
@override
Future
<
void
>
cleanupAtFinish
()
async
{
for
(
FlutterDevice
flutterDevice
in
flutterDevices
)
{
flutterDevice
.
device
.
dispose
();
}
await
stopEchoingDeviceLog
();
}
...
...
packages/flutter_tools/test/commands.shard/hermetic/run_test.dart
View file @
428d7d7f
...
...
@@ -43,7 +43,6 @@ void main() {
}
});
group
(
'dart-flags option'
,
()
{
setUpAll
(()
{
when
(
mockDeviceManager
.
getDevices
()).
thenAnswer
((
Invocation
invocation
)
{
...
...
packages/flutter_tools/test/general.shard/cold_test.dart
View file @
428d7d7f
...
...
@@ -4,6 +4,7 @@
import
'dart:async'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/io.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/build_info.dart'
;
...
...
@@ -84,8 +85,82 @@ void main() {
Logger:
()
=>
mockLogger
,
});
});
group
(
'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
=
MockDevice
();
final
MockDevice
mockDevice2
=
MockDevice
();
final
MockFlutterDevice
mockFlutterDevice1
=
mockFlutterDeviceFactory
(
mockDevice1
);
final
MockFlutterDevice
mockFlutterDevice2
=
mockFlutterDeviceFactory
(
mockDevice2
);
final
List
<
FlutterDevice
>
devices
=
<
FlutterDevice
>[
mockFlutterDevice1
,
mockFlutterDevice2
];
await
ColdRunner
(
devices
,
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
),
).
cleanupAtFinish
();
verify
(
mockDevice1
.
dispose
());
verify
(
mockFlutterDevice1
.
stopEchoingDeviceLog
());
verify
(
mockDevice2
.
dispose
());
verify
(
mockFlutterDevice2
.
stopEchoingDeviceLog
());
});
});
group
(
'cold run'
,
()
{
BufferLogger
mockLogger
;
setUp
(()
{
mockLogger
=
BufferLogger
();
});
testUsingContext
(
'returns 1 if not prebuilt mode & mainPath does not exist'
,
()
async
{
final
MockDevice
mockDevice
=
MockDevice
();
final
MockFlutterDevice
mockFlutterDevice
=
MockFlutterDevice
();
when
(
mockFlutterDevice
.
device
).
thenReturn
(
mockDevice
);
final
List
<
FlutterDevice
>
devices
=
<
FlutterDevice
>[
mockFlutterDevice
];
final
int
result
=
await
ColdRunner
(
devices
).
run
();
expect
(
result
,
1
);
expect
(
mockLogger
.
errorText
,
matches
(
r'Tried to run .*, but that file does not exist\.'
));
expect
(
mockLogger
.
errorText
,
matches
(
r'Consider using the -t option to specify the Dart file to start\.'
));
},
overrides:
<
Type
,
Generator
>{
Logger:
()
=>
mockLogger
,
});
testUsingContext
(
'calls runCold on attached device'
,
()
async
{
final
MockDevice
mockDevice
=
MockDevice
();
final
MockFlutterDevice
mockFlutterDevice
=
MockFlutterDevice
();
when
(
mockFlutterDevice
.
device
).
thenReturn
(
mockDevice
);
when
(
mockFlutterDevice
.
runCold
(
coldRunner:
anyNamed
(
'coldRunner'
),
route:
anyNamed
(
'route'
)
)).
thenAnswer
((
Invocation
invocation
)
=>
Future
<
int
>.
value
(
1
));
final
List
<
FlutterDevice
>
devices
=
<
FlutterDevice
>[
mockFlutterDevice
];
final
MockFile
applicationBinary
=
MockFile
();
final
int
result
=
await
ColdRunner
(
devices
,
applicationBinary:
applicationBinary
,
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
),
).
run
();
expect
(
result
,
1
);
verify
(
mockFlutterDevice
.
runCold
(
coldRunner:
anyNamed
(
'coldRunner'
),
route:
anyNamed
(
'route'
),
));
},
overrides:
<
Type
,
Generator
>{
Logger:
()
=>
mockLogger
,
});
});
}
class
MockFile
extends
Mock
implements
File
{}
class
MockFlutterDevice
extends
Mock
implements
FlutterDevice
{}
class
MockDevice
extends
Mock
implements
Device
{
MockDevice
()
{
when
(
isSupported
()).
thenReturn
(
true
);
...
...
packages/flutter_tools/test/general.shard/hot_test.dart
View file @
428d7d7f
...
...
@@ -337,6 +337,36 @@ void main() {
HotRunnerConfig:
()
=>
TestHotRunnerConfig
(
successfulSetup:
true
),
});
});
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
=
MockDevice
();
final
MockDevice
mockDevice2
=
MockDevice
();
final
MockFlutterDevice
mockFlutterDevice1
=
mockFlutterDeviceFactory
(
mockDevice1
);
final
MockFlutterDevice
mockFlutterDevice2
=
mockFlutterDeviceFactory
(
mockDevice2
);
final
List
<
FlutterDevice
>
devices
=
<
FlutterDevice
>[
mockFlutterDevice1
,
mockFlutterDevice2
,
];
await
HotRunner
(
devices
,
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
debug
),
).
cleanupAtFinish
();
verify
(
mockDevice1
.
dispose
());
verify
(
mockFlutterDevice1
.
stopEchoingDeviceLog
());
verify
(
mockDevice2
.
dispose
());
verify
(
mockFlutterDevice2
.
stopEchoingDeviceLog
());
});
});
}
class
MockDevFs
extends
Mock
implements
DevFS
{}
...
...
@@ -349,6 +379,8 @@ class MockDevice extends Mock implements Device {
}
}
class
MockFlutterDevice
extends
Mock
implements
FlutterDevice
{}
class
TestFlutterDevice
extends
FlutterDevice
{
TestFlutterDevice
({
@required
Device
device
,
...
...
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