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
Show 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,
...
@@ -68,12 +68,14 @@ final Map<InternetAddressType, InternetAddress> _kHosts = <InternetAddressType,
InternetAddressType
.
IPv6
:
InternetAddress
.
loopbackIPv6
,
InternetAddressType
.
IPv6
:
InternetAddress
.
loopbackIPv6
,
};
};
typedef
PlatformPluginRegistration
=
void
Function
(
FlutterPlatform
platform
);
/// Configure the `test` package to work with Flutter.
/// Configure the `test` package to work with Flutter.
///
///
/// On systems where each [FlutterPlatform] is only used to run one test suite
/// 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
/// (that is, one Dart file with a `*_test.dart` file name and a single `void
/// main()`), you can set an observatory port explicitly.
/// main()`), you can set an observatory port explicitly.
void
installHook
(
{
FlutterPlatform
installHook
(
{
@required
String
shellPath
,
@required
String
shellPath
,
TestWatcher
watcher
,
TestWatcher
watcher
,
bool
enableObservatory
=
false
,
bool
enableObservatory
=
false
,
...
@@ -91,12 +93,20 @@ void installHook({
...
@@ -91,12 +93,20 @@ void installHook({
Uri
projectRootDirectory
,
Uri
projectRootDirectory
,
FlutterProject
flutterProject
,
FlutterProject
flutterProject
,
String
icudtlPath
,
String
icudtlPath
,
PlatformPluginRegistration
platformPluginRegistration
})
{
})
{
assert
(
enableObservatory
||
(!
startPaused
&&
observatoryPort
==
null
));
assert
(
enableObservatory
||
(!
startPaused
&&
observatoryPort
==
null
));
// registerPlatformPlugin can be injected for testing since it's not very mock-friendly.
platformPluginRegistration
??=
(
FlutterPlatform
platform
)
{
hack
.
registerPlatformPlugin
(
hack
.
registerPlatformPlugin
(
<
Runtime
>[
Runtime
.
vm
],
<
Runtime
>[
Runtime
.
vm
],
()
{
()
{
return
FlutterPlatform
(
return
platform
;
}
);
};
final
FlutterPlatform
platform
=
FlutterPlatform
(
shellPath:
shellPath
,
shellPath:
shellPath
,
watcher:
watcher
,
watcher:
watcher
,
machine:
machine
,
machine:
machine
,
...
@@ -115,8 +125,8 @@ void installHook({
...
@@ -115,8 +125,8 @@ void installHook({
flutterProject:
flutterProject
,
flutterProject:
flutterProject
,
icudtlPath:
icudtlPath
,
icudtlPath:
icudtlPath
,
);
);
}
platformPluginRegistration
(
platform
);
)
;
return
platform
;
}
}
/// Generates the bootstrap entry point script that will be used to launch an
/// 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(
...
@@ -105,7 +105,7 @@ Future<int> runTests(
final
InternetAddressType
serverType
=
final
InternetAddressType
serverType
=
ipv6
?
InternetAddressType
.
IPv6
:
InternetAddressType
.
IPv4
;
ipv6
?
InternetAddressType
.
IPv6
:
InternetAddressType
.
IPv4
;
loader
.
installHook
(
final
loader
.
FlutterPlatform
platform
=
loader
.
installHook
(
shellPath:
shellPath
,
shellPath:
shellPath
,
watcher:
watcher
,
watcher:
watcher
,
enableObservatory:
enableObservatory
,
enableObservatory:
enableObservatory
,
...
@@ -145,5 +145,6 @@ Future<int> runTests(
...
@@ -145,5 +145,6 @@ Future<int> runTests(
return
exitCode
;
return
exitCode
;
}
finally
{
}
finally
{
fs
.
currentDirectory
=
saved
;
fs
.
currentDirectory
=
saved
;
await
platform
.
close
();
}
}
}
}
packages/flutter_tools/test/flutter_platform_test.dart
View file @
fa491fc9
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
// found in the LICENSE file.
// found in the LICENSE file.
import
'package:flutter_tools/src/base/common.dart'
;
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:flutter_tools/src/test/flutter_platform.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:mockito/mockito.dart'
;
...
@@ -24,6 +25,58 @@ void main() {
...
@@ -24,6 +25,58 @@ void main() {
flutterPlatfrom
.
loadChannel
(
'test1.dart'
,
MockPlatform
());
flutterPlatfrom
.
loadChannel
(
'test1.dart'
,
MockPlatform
());
expect
(()
=>
flutterPlatfrom
.
loadChannel
(
'test2.dart'
,
MockPlatform
()),
throwsA
(
isA
<
ToolExit
>()));
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