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
31709953
Unverified
Commit
31709953
authored
Sep 07, 2022
by
Kenzie Davisson
Committed by
GitHub
Sep 07, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
only include foundation changes (#111146)
parent
46998c4a
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
106 additions
and
29 deletions
+106
-29
foundation.dart
packages/flutter/lib/foundation.dart
+1
-0
binding.dart
packages/flutter/lib/src/foundation/binding.dart
+9
-10
service_extensions.dart
packages/flutter/lib/src/foundation/service_extensions.dart
+77
-0
service_extensions_test.dart
...ages/flutter/test/foundation/service_extensions_test.dart
+19
-19
No files found.
packages/flutter/lib/foundation.dart
View file @
31709953
...
...
@@ -41,6 +41,7 @@ export 'src/foundation/persistent_hash_map.dart';
export
'src/foundation/platform.dart'
;
export
'src/foundation/print.dart'
;
export
'src/foundation/serialization.dart'
;
export
'src/foundation/service_extensions.dart'
;
export
'src/foundation/stack_frame.dart'
;
export
'src/foundation/synchronous_future.dart'
;
export
'src/foundation/unicode.dart'
;
packages/flutter/lib/src/foundation/binding.dart
View file @
31709953
...
...
@@ -18,6 +18,7 @@ import 'debug.dart';
import
'object.dart'
;
import
'platform.dart'
;
import
'print.dart'
;
import
'service_extensions.dart'
;
export
'dart:ui'
show
PlatformDispatcher
,
SingletonFlutterWindow
;
...
...
@@ -424,7 +425,7 @@ abstract class BindingBase {
assert
(()
{
registerSignalServiceExtension
(
name:
'reassemble'
,
name:
FoundationServiceExtensions
.
reassemble
.
name
,
callback:
reassembleApplication
,
);
return
true
;
...
...
@@ -433,20 +434,20 @@ abstract class BindingBase {
if
(!
kReleaseMode
)
{
if
(!
kIsWeb
)
{
registerSignalServiceExtension
(
name:
'exit'
,
name:
FoundationServiceExtensions
.
exit
.
name
,
callback:
_exitApplication
,
);
}
// These service extensions are used in profile mode applications.
registerStringServiceExtension
(
name:
'connectedVmServiceUri'
,
name:
FoundationServiceExtensions
.
connectedVmServiceUri
.
name
,
getter:
()
async
=>
connectedVmServiceUri
??
''
,
setter:
(
String
uri
)
async
{
connectedVmServiceUri
=
uri
;
},
);
registerStringServiceExtension
(
name:
'activeDevToolsServerAddress'
,
name:
FoundationServiceExtensions
.
activeDevToolsServerAddress
.
name
,
getter:
()
async
=>
activeDevToolsServerAddress
??
''
,
setter:
(
String
serverAddress
)
async
{
activeDevToolsServerAddress
=
serverAddress
;
...
...
@@ -455,9 +456,8 @@ abstract class BindingBase {
}
assert
(()
{
const
String
platformOverrideExtensionName
=
'platformOverride'
;
registerServiceExtension
(
name:
platformOverrideExtensionN
ame
,
name:
FoundationServiceExtensions
.
platformOverride
.
n
ame
,
callback:
(
Map
<
String
,
String
>
parameters
)
async
{
if
(
parameters
.
containsKey
(
'value'
))
{
switch
(
parameters
[
'value'
])
{
...
...
@@ -484,7 +484,7 @@ abstract class BindingBase {
debugDefaultTargetPlatformOverride
=
null
;
}
_postExtensionStateChangedEvent
(
platformOverrideExtensionN
ame
,
FoundationServiceExtensions
.
platformOverride
.
n
ame
,
defaultTargetPlatform
.
toString
().
substring
(
'
$TargetPlatform
.'
.
length
),
);
await
reassembleApplication
();
...
...
@@ -497,9 +497,8 @@ abstract class BindingBase {
},
);
const
String
brightnessOverrideExtensionName
=
'brightnessOverride'
;
registerServiceExtension
(
name:
brightnessOverrideExtensionN
ame
,
name:
FoundationServiceExtensions
.
brightnessOverride
.
n
ame
,
callback:
(
Map
<
String
,
String
>
parameters
)
async
{
if
(
parameters
.
containsKey
(
'value'
))
{
switch
(
parameters
[
'value'
])
{
...
...
@@ -513,7 +512,7 @@ abstract class BindingBase {
debugBrightnessOverride
=
null
;
}
_postExtensionStateChangedEvent
(
brightnessOverrideExtensionN
ame
,
FoundationServiceExtensions
.
brightnessOverride
.
n
ame
,
(
debugBrightnessOverride
??
platformDispatcher
.
platformBrightness
).
toString
(),
);
await
reassembleApplication
();
...
...
packages/flutter/lib/src/foundation/service_extensions.dart
0 → 100644
View file @
31709953
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/// Service extension constants for the foundation library.
///
/// These constants will be used when registering service extensions in the
/// framework, and they will also be used by tools and services that call these
/// service extensions.
///
/// The String value for each of these extension names should be accessed by
/// calling the `.name` property on the enum value.
enum
FoundationServiceExtensions
{
/// Name of service extension that, when called, will cause the entire
/// application to redraw.
///
/// See also:
///
/// * [BindingBase.initServiceExtensions], where the service extension is
/// registered.
reassemble
,
/// Name of service extension that, when called, will terminate the Flutter
/// application.
///
/// See also:
///
/// * [BindingBase.initServiceExtensions], where the service extension is
/// registered.
exit
,
/// Name of service extension that, when called, will get or set the value of
/// [connectedVmServiceUri].
///
/// See also:
///
/// * [connectedVmServiceUri], which stores the uri for the connected vm service
/// protocol.
/// * [BindingBase.initServiceExtensions], where the service extension is
/// registered.
connectedVmServiceUri
,
/// Name of service extension that, when called, will get or set the value of
/// [activeDevToolsServerAddress].
///
/// See also:
///
/// * [activeDevToolsServerAddress], which stores the address for the active
/// DevTools server used for debugging this application.
/// * [BindingBase.initServiceExtensions], where the service extension is
/// registered.
activeDevToolsServerAddress
,
/// Name of service extension that, when called, will change the value of
/// [defaultTargetPlatform], which controls which [TargetPlatform] that the
/// framework will execute for.
///
/// See also:
///
/// * [debugDefaultTargetPlatformOverride], which is the flag that this service
/// extension exposes.
/// * [BindingBase.initServiceExtensions], where the service extension is
/// registered.
platformOverride
,
/// Name of service extension that, when called, will override the platform
/// [Brightness].
///
/// See also:
///
/// * [debugBrightnessOverride], which is the flag that this service
/// extension exposes.
/// * [BindingBase.initServiceExtensions], where the service extension is
/// registered.
brightnessOverride
,
}
packages/flutter/test/foundation/service_extensions_test.dart
View file @
31709953
...
...
@@ -578,7 +578,7 @@ void main() {
test
(
'Service extensions - exit'
,
()
async
{
// no test for _calling_ 'exit', because that should terminate the process!
// Not expecting extension to be available for web platform.
expect
(
binding
.
extensions
.
containsKey
(
'exit'
),
!
isBrowser
);
expect
(
binding
.
extensions
.
containsKey
(
FoundationServiceExtensions
.
exit
.
name
),
!
isBrowser
);
});
test
(
'Service extensions - platformOverride'
,
()
async
{
...
...
@@ -588,11 +588,11 @@ void main() {
expect
(
binding
.
reassembled
,
0
);
expect
(
defaultTargetPlatform
,
TargetPlatform
.
android
);
result
=
await
binding
.
testExtension
(
'platformOverride'
,
<
String
,
String
>{});
result
=
await
binding
.
testExtension
(
FoundationServiceExtensions
.
platformOverride
.
name
,
<
String
,
String
>{});
expect
(
result
,
<
String
,
String
>{
'value'
:
'android'
});
expect
(
defaultTargetPlatform
,
TargetPlatform
.
android
);
expect
(
extensionChangedEvents
,
isEmpty
);
result
=
await
hasReassemble
(
binding
.
testExtension
(
'platformOverride'
,
<
String
,
String
>{
'value'
:
'iOS'
}));
result
=
await
hasReassemble
(
binding
.
testExtension
(
FoundationServiceExtensions
.
platformOverride
.
name
,
<
String
,
String
>{
'value'
:
'iOS'
}));
expect
(
result
,
<
String
,
String
>{
'value'
:
'iOS'
});
expect
(
binding
.
reassembled
,
1
);
expect
(
defaultTargetPlatform
,
TargetPlatform
.
iOS
);
...
...
@@ -600,7 +600,7 @@ void main() {
extensionChangedEvent
=
extensionChangedEvents
.
last
;
expect
(
extensionChangedEvent
[
'extension'
],
'ext.flutter.platformOverride'
);
expect
(
extensionChangedEvent
[
'value'
],
'iOS'
);
result
=
await
hasReassemble
(
binding
.
testExtension
(
'platformOverride'
,
<
String
,
String
>{
'value'
:
'macOS'
}));
result
=
await
hasReassemble
(
binding
.
testExtension
(
FoundationServiceExtensions
.
platformOverride
.
name
,
<
String
,
String
>{
'value'
:
'macOS'
}));
expect
(
result
,
<
String
,
String
>{
'value'
:
'macOS'
});
expect
(
binding
.
reassembled
,
2
);
expect
(
defaultTargetPlatform
,
TargetPlatform
.
macOS
);
...
...
@@ -608,7 +608,7 @@ void main() {
extensionChangedEvent
=
extensionChangedEvents
.
last
;
expect
(
extensionChangedEvent
[
'extension'
],
'ext.flutter.platformOverride'
);
expect
(
extensionChangedEvent
[
'value'
],
'macOS'
);
result
=
await
hasReassemble
(
binding
.
testExtension
(
'platformOverride'
,
<
String
,
String
>{
'value'
:
'android'
}));
result
=
await
hasReassemble
(
binding
.
testExtension
(
FoundationServiceExtensions
.
platformOverride
.
name
,
<
String
,
String
>{
'value'
:
'android'
}));
expect
(
result
,
<
String
,
String
>{
'value'
:
'android'
});
expect
(
binding
.
reassembled
,
3
);
expect
(
defaultTargetPlatform
,
TargetPlatform
.
android
);
...
...
@@ -616,7 +616,7 @@ void main() {
extensionChangedEvent
=
extensionChangedEvents
.
last
;
expect
(
extensionChangedEvent
[
'extension'
],
'ext.flutter.platformOverride'
);
expect
(
extensionChangedEvent
[
'value'
],
'android'
);
result
=
await
hasReassemble
(
binding
.
testExtension
(
'platformOverride'
,
<
String
,
String
>{
'value'
:
'fuchsia'
}));
result
=
await
hasReassemble
(
binding
.
testExtension
(
FoundationServiceExtensions
.
platformOverride
.
name
,
<
String
,
String
>{
'value'
:
'fuchsia'
}));
expect
(
result
,
<
String
,
String
>{
'value'
:
'fuchsia'
});
expect
(
binding
.
reassembled
,
4
);
expect
(
defaultTargetPlatform
,
TargetPlatform
.
fuchsia
);
...
...
@@ -624,7 +624,7 @@ void main() {
extensionChangedEvent
=
extensionChangedEvents
.
last
;
expect
(
extensionChangedEvent
[
'extension'
],
'ext.flutter.platformOverride'
);
expect
(
extensionChangedEvent
[
'value'
],
'fuchsia'
);
result
=
await
hasReassemble
(
binding
.
testExtension
(
'platformOverride'
,
<
String
,
String
>{
'value'
:
'default'
}));
result
=
await
hasReassemble
(
binding
.
testExtension
(
FoundationServiceExtensions
.
platformOverride
.
name
,
<
String
,
String
>{
'value'
:
'default'
}));
expect
(
result
,
<
String
,
String
>{
'value'
:
'android'
});
expect
(
binding
.
reassembled
,
5
);
expect
(
defaultTargetPlatform
,
TargetPlatform
.
android
);
...
...
@@ -632,7 +632,7 @@ void main() {
extensionChangedEvent
=
extensionChangedEvents
.
last
;
expect
(
extensionChangedEvent
[
'extension'
],
'ext.flutter.platformOverride'
);
expect
(
extensionChangedEvent
[
'value'
],
'android'
);
result
=
await
hasReassemble
(
binding
.
testExtension
(
'platformOverride'
,
<
String
,
String
>{
'value'
:
'iOS'
}));
result
=
await
hasReassemble
(
binding
.
testExtension
(
FoundationServiceExtensions
.
platformOverride
.
name
,
<
String
,
String
>{
'value'
:
'iOS'
}));
expect
(
result
,
<
String
,
String
>{
'value'
:
'iOS'
});
expect
(
binding
.
reassembled
,
6
);
expect
(
defaultTargetPlatform
,
TargetPlatform
.
iOS
);
...
...
@@ -640,7 +640,7 @@ void main() {
extensionChangedEvent
=
extensionChangedEvents
.
last
;
expect
(
extensionChangedEvent
[
'extension'
],
'ext.flutter.platformOverride'
);
expect
(
extensionChangedEvent
[
'value'
],
'iOS'
);
result
=
await
hasReassemble
(
binding
.
testExtension
(
'platformOverride'
,
<
String
,
String
>{
'value'
:
'linux'
}));
result
=
await
hasReassemble
(
binding
.
testExtension
(
FoundationServiceExtensions
.
platformOverride
.
name
,
<
String
,
String
>{
'value'
:
'linux'
}));
expect
(
result
,
<
String
,
String
>{
'value'
:
'linux'
});
expect
(
binding
.
reassembled
,
7
);
expect
(
defaultTargetPlatform
,
TargetPlatform
.
linux
);
...
...
@@ -648,7 +648,7 @@ void main() {
extensionChangedEvent
=
extensionChangedEvents
.
last
;
expect
(
extensionChangedEvent
[
'extension'
],
'ext.flutter.platformOverride'
);
expect
(
extensionChangedEvent
[
'value'
],
'linux'
);
result
=
await
hasReassemble
(
binding
.
testExtension
(
'platformOverride'
,
<
String
,
String
>{
'value'
:
'windows'
}));
result
=
await
hasReassemble
(
binding
.
testExtension
(
FoundationServiceExtensions
.
platformOverride
.
name
,
<
String
,
String
>{
'value'
:
'windows'
}));
expect
(
result
,
<
String
,
String
>{
'value'
:
'windows'
});
expect
(
binding
.
reassembled
,
8
);
expect
(
defaultTargetPlatform
,
TargetPlatform
.
windows
);
...
...
@@ -656,7 +656,7 @@ void main() {
extensionChangedEvent
=
extensionChangedEvents
.
last
;
expect
(
extensionChangedEvent
[
'extension'
],
'ext.flutter.platformOverride'
);
expect
(
extensionChangedEvent
[
'value'
],
'windows'
);
result
=
await
hasReassemble
(
binding
.
testExtension
(
'platformOverride'
,
<
String
,
String
>{
'value'
:
'bogus'
}));
result
=
await
hasReassemble
(
binding
.
testExtension
(
FoundationServiceExtensions
.
platformOverride
.
name
,
<
String
,
String
>{
'value'
:
'bogus'
}));
expect
(
result
,
<
String
,
String
>{
'value'
:
'android'
});
expect
(
binding
.
reassembled
,
9
);
expect
(
defaultTargetPlatform
,
TargetPlatform
.
android
);
...
...
@@ -843,7 +843,7 @@ void main() {
completed
=
false
;
expect
(
binding
.
reassembled
,
0
);
pendingResult
=
binding
.
testExtension
(
'reassemble'
,
<
String
,
String
>{});
pendingResult
=
binding
.
testExtension
(
FoundationServiceExtensions
.
reassemble
.
name
,
<
String
,
String
>{});
pendingResult
.
whenComplete
(()
{
completed
=
true
;
});
await
binding
.
flushMicrotasks
();
expect
(
binding
.
frameScheduled
,
isTrue
);
...
...
@@ -925,7 +925,7 @@ void main() {
test
(
'Service extensions - brightnessOverride'
,
()
async
{
Map
<
String
,
dynamic
>
result
;
result
=
await
binding
.
testExtension
(
'brightnessOverride'
,
<
String
,
String
>{});
result
=
await
binding
.
testExtension
(
FoundationServiceExtensions
.
brightnessOverride
.
name
,
<
String
,
String
>{});
final
String
brightnessValue
=
result
[
'value'
]
as
String
;
expect
(
brightnessValue
,
'Brightness.light'
);
...
...
@@ -933,26 +933,26 @@ void main() {
test
(
'Service extensions - activeDevToolsServerAddress'
,
()
async
{
Map
<
String
,
dynamic
>
result
;
result
=
await
binding
.
testExtension
(
'activeDevToolsServerAddress'
,
<
String
,
String
>{});
result
=
await
binding
.
testExtension
(
FoundationServiceExtensions
.
activeDevToolsServerAddress
.
name
,
<
String
,
String
>{});
String
serverAddress
=
result
[
'value'
]
as
String
;
expect
(
serverAddress
,
''
);
result
=
await
binding
.
testExtension
(
'activeDevToolsServerAddress'
,
<
String
,
String
>{
'value'
:
'http://127.0.0.1:9101'
});
result
=
await
binding
.
testExtension
(
FoundationServiceExtensions
.
activeDevToolsServerAddress
.
name
,
<
String
,
String
>{
'value'
:
'http://127.0.0.1:9101'
});
serverAddress
=
result
[
'value'
]
as
String
;
expect
(
serverAddress
,
'http://127.0.0.1:9101'
);
result
=
await
binding
.
testExtension
(
'activeDevToolsServerAddress'
,
<
String
,
String
>{
'value'
:
'http://127.0.0.1:9102'
});
result
=
await
binding
.
testExtension
(
FoundationServiceExtensions
.
activeDevToolsServerAddress
.
name
,
<
String
,
String
>{
'value'
:
'http://127.0.0.1:9102'
});
serverAddress
=
result
[
'value'
]
as
String
;
expect
(
serverAddress
,
'http://127.0.0.1:9102'
);
});
test
(
'Service extensions - connectedVmServiceUri'
,
()
async
{
Map
<
String
,
dynamic
>
result
;
result
=
await
binding
.
testExtension
(
'connectedVmServiceUri'
,
<
String
,
String
>{});
result
=
await
binding
.
testExtension
(
FoundationServiceExtensions
.
connectedVmServiceUri
.
name
,
<
String
,
String
>{});
String
serverAddress
=
result
[
'value'
]
as
String
;
expect
(
serverAddress
,
''
);
result
=
await
binding
.
testExtension
(
'connectedVmServiceUri'
,
<
String
,
String
>{
'value'
:
'http://127.0.0.1:54669/kMUMseKAnog=/'
});
result
=
await
binding
.
testExtension
(
FoundationServiceExtensions
.
connectedVmServiceUri
.
name
,
<
String
,
String
>{
'value'
:
'http://127.0.0.1:54669/kMUMseKAnog=/'
});
serverAddress
=
result
[
'value'
]
as
String
;
expect
(
serverAddress
,
'http://127.0.0.1:54669/kMUMseKAnog=/'
);
result
=
await
binding
.
testExtension
(
'connectedVmServiceUri'
,
<
String
,
String
>{
'value'
:
'http://127.0.0.1:54000/kMUMseKAnog=/'
});
result
=
await
binding
.
testExtension
(
FoundationServiceExtensions
.
connectedVmServiceUri
.
name
,
<
String
,
String
>{
'value'
:
'http://127.0.0.1:54000/kMUMseKAnog=/'
});
serverAddress
=
result
[
'value'
]
as
String
;
expect
(
serverAddress
,
'http://127.0.0.1:54000/kMUMseKAnog=/'
);
});
...
...
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