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
fa491fc9
Unverified
Commit
fa491fc9
authored
Jun 20, 2019
by
Jenn Magder
Committed by
GitHub
Jun 20, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Close platform when tests are complete (dispose compiler and delete font files) (#34685)
parent
b9932d55
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
89 additions
and
25 deletions
+89
-25
flutter_platform.dart
packages/flutter_tools/lib/src/test/flutter_platform.dart
+34
-24
runner.dart
packages/flutter_tools/lib/src/test/runner.dart
+2
-1
flutter_platform_test.dart
packages/flutter_tools/test/flutter_platform_test.dart
+53
-0
No files found.
packages/flutter_tools/lib/src/test/flutter_platform.dart
View file @
fa491fc9
...
...
@@ -68,12 +68,14 @@ final Map<InternetAddressType, InternetAddress> _kHosts = <InternetAddressType,
InternetAddressType
.
IPv6
:
InternetAddress
.
loopbackIPv6
,
};
typedef
PlatformPluginRegistration
=
void
Function
(
FlutterPlatform
platform
);
/// Configure the `test` package to work with Flutter.
///
/// On systems where each [FlutterPlatform] is only used to run one test suite
/// (that is, one Dart file with a `*_test.dart` file name and a single `void
/// main()`), you can set an observatory port explicitly.
void
installHook
(
{
FlutterPlatform
installHook
(
{
@required
String
shellPath
,
TestWatcher
watcher
,
bool
enableObservatory
=
false
,
...
...
@@ -91,32 +93,40 @@ void installHook({
Uri
projectRootDirectory
,
FlutterProject
flutterProject
,
String
icudtlPath
,
PlatformPluginRegistration
platformPluginRegistration
})
{
assert
(
enableObservatory
||
(!
startPaused
&&
observatoryPort
==
null
));
hack
.
registerPlatformPlugin
(
<
Runtime
>[
Runtime
.
vm
],
()
{
return
FlutterPlatform
(
shellPath:
shellPath
,
watcher:
watcher
,
machine:
machine
,
enableObservatory:
enableObservatory
,
startPaused:
startPaused
,
disableServiceAuthCodes:
disableServiceAuthCodes
,
explicitObservatoryPort:
observatoryPort
,
host:
_kHosts
[
serverType
],
port:
port
,
precompiledDillPath:
precompiledDillPath
,
precompiledDillFiles:
precompiledDillFiles
,
trackWidgetCreation:
trackWidgetCreation
,
updateGoldens:
updateGoldens
,
buildTestAssets:
buildTestAssets
,
projectRootDirectory:
projectRootDirectory
,
flutterProject:
flutterProject
,
icudtlPath:
icudtlPath
,
);
}
// registerPlatformPlugin can be injected for testing since it's not very mock-friendly.
platformPluginRegistration
??=
(
FlutterPlatform
platform
)
{
hack
.
registerPlatformPlugin
(
<
Runtime
>[
Runtime
.
vm
],
()
{
return
platform
;
}
);
};
final
FlutterPlatform
platform
=
FlutterPlatform
(
shellPath:
shellPath
,
watcher:
watcher
,
machine:
machine
,
enableObservatory:
enableObservatory
,
startPaused:
startPaused
,
disableServiceAuthCodes:
disableServiceAuthCodes
,
explicitObservatoryPort:
observatoryPort
,
host:
_kHosts
[
serverType
],
port:
port
,
precompiledDillPath:
precompiledDillPath
,
precompiledDillFiles:
precompiledDillFiles
,
trackWidgetCreation:
trackWidgetCreation
,
updateGoldens:
updateGoldens
,
buildTestAssets:
buildTestAssets
,
projectRootDirectory:
projectRootDirectory
,
flutterProject:
flutterProject
,
icudtlPath:
icudtlPath
,
);
platformPluginRegistration
(
platform
);
return
platform
;
}
/// Generates the bootstrap entry point script that will be used to launch an
...
...
packages/flutter_tools/lib/src/test/runner.dart
View file @
fa491fc9
...
...
@@ -105,7 +105,7 @@ Future<int> runTests(
final
InternetAddressType
serverType
=
ipv6
?
InternetAddressType
.
IPv6
:
InternetAddressType
.
IPv4
;
loader
.
installHook
(
final
loader
.
FlutterPlatform
platform
=
loader
.
installHook
(
shellPath:
shellPath
,
watcher:
watcher
,
enableObservatory:
enableObservatory
,
...
...
@@ -145,5 +145,6 @@ Future<int> runTests(
return
exitCode
;
}
finally
{
fs
.
currentDirectory
=
saved
;
await
platform
.
close
();
}
}
packages/flutter_tools/test/flutter_platform_test.dart
View file @
fa491fc9
...
...
@@ -3,6 +3,7 @@
// found in the LICENSE file.
import
'package:flutter_tools/src/base/common.dart'
;
import
'package:flutter_tools/src/base/io.dart'
;
import
'package:flutter_tools/src/test/flutter_platform.dart'
;
import
'package:mockito/mockito.dart'
;
...
...
@@ -24,6 +25,58 @@ void main() {
flutterPlatfrom
.
loadChannel
(
'test1.dart'
,
MockPlatform
());
expect
(()
=>
flutterPlatfrom
.
loadChannel
(
'test2.dart'
,
MockPlatform
()),
throwsA
(
isA
<
ToolExit
>()));
});
testUsingContext
(
'installHook creates a FlutterPlatform'
,
()
{
expect
(()
=>
installHook
(
shellPath:
'abc'
,
enableObservatory:
false
,
startPaused:
true
),
throwsA
(
isA
<
AssertionError
>()));
expect
(()
=>
installHook
(
shellPath:
'abc'
,
enableObservatory:
false
,
startPaused:
false
,
observatoryPort:
123
),
throwsA
(
isA
<
AssertionError
>()));
FlutterPlatform
capturedPlatform
;
final
Map
<
String
,
String
>
expectedPrecompiledDillFiles
=
<
String
,
String
>{
'Key'
:
'Value'
};
final
FlutterPlatform
flutterPlatform
=
installHook
(
shellPath:
'abc'
,
enableObservatory:
true
,
machine:
true
,
startPaused:
true
,
disableServiceAuthCodes:
true
,
port:
100
,
precompiledDillPath:
'def'
,
precompiledDillFiles:
expectedPrecompiledDillFiles
,
trackWidgetCreation:
true
,
updateGoldens:
true
,
buildTestAssets:
true
,
observatoryPort:
200
,
serverType:
InternetAddressType
.
IPv6
,
icudtlPath:
'ghi'
,
platformPluginRegistration:
(
FlutterPlatform
platform
)
{
capturedPlatform
=
platform
;
});
expect
(
identical
(
capturedPlatform
,
flutterPlatform
),
equals
(
true
));
expect
(
flutterPlatform
.
shellPath
,
equals
(
'abc'
));
expect
(
flutterPlatform
.
enableObservatory
,
equals
(
true
));
expect
(
flutterPlatform
.
machine
,
equals
(
true
));
expect
(
flutterPlatform
.
startPaused
,
equals
(
true
));
expect
(
flutterPlatform
.
disableServiceAuthCodes
,
equals
(
true
));
expect
(
flutterPlatform
.
port
,
equals
(
100
));
expect
(
flutterPlatform
.
host
,
InternetAddress
.
loopbackIPv6
);
expect
(
flutterPlatform
.
explicitObservatoryPort
,
equals
(
200
));
expect
(
flutterPlatform
.
precompiledDillPath
,
equals
(
'def'
));
expect
(
flutterPlatform
.
precompiledDillFiles
,
expectedPrecompiledDillFiles
);
expect
(
flutterPlatform
.
trackWidgetCreation
,
equals
(
true
));
expect
(
flutterPlatform
.
updateGoldens
,
equals
(
true
));
expect
(
flutterPlatform
.
buildTestAssets
,
equals
(
true
));
expect
(
flutterPlatform
.
icudtlPath
,
equals
(
'ghi'
));
});
});
}
...
...
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