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
2d550329
Unverified
Commit
2d550329
authored
Aug 18, 2021
by
Jenn Magder
Committed by
GitHub
Aug 18, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate dds.dart to null safety (#88382)
parent
cc380b9c
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
79 additions
and
37 deletions
+79
-37
dds.dart
packages/flutter_tools/lib/src/base/dds.dart
+16
-21
drive_service.dart
packages/flutter_tools/lib/src/drive/drive_service.dart
+3
-3
fuchsia_device.dart
packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart
+3
-3
resident_runner.dart
packages/flutter_tools/lib/src/resident_runner.dart
+3
-3
attach_test.dart
...utter_tools/test/commands.shard/hermetic/attach_test.dart
+3
-3
drive_service_test.dart
...er_tools/test/general.shard/drive/drive_service_test.dart
+3
-3
fuchsia_device_test.dart
...tools/test/general.shard/fuchsia/fuchsia_device_test.dart
+7
-1
resident_runner_test.dart
...lutter_tools/test/general.shard/resident_runner_test.dart
+41
-0
No files found.
packages/flutter_tools/lib/src/base/dds.dart
View file @
2d550329
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
import
'dart:async'
;
import
'package:dds/dds.dart'
as
dds
;
import
'package:dds/dds.dart'
as
dds
;
...
@@ -15,36 +13,33 @@ import 'logger.dart';
...
@@ -15,36 +13,33 @@ import 'logger.dart';
@visibleForTesting
@visibleForTesting
Future
<
dds
.
DartDevelopmentService
>
Function
(
Future
<
dds
.
DartDevelopmentService
>
Function
(
Uri
,
Uri
remoteVmServiceUri
,
{
{
bool
enableAuthCodes
,
bool
enableAuthCodes
,
bool
ipv6
,
bool
ipv6
,
Uri
serviceUri
,
Uri
?
serviceUri
,
})
ddsLauncherCallback
=
dds
.
DartDevelopmentService
.
startDartDevelopmentService
;
})
ddsLauncherCallback
=
dds
.
DartDevelopmentService
.
startDartDevelopmentService
;
/// Helper class to launch a [dds.DartDevelopmentService]. Allows for us to
/// Helper class to launch a [dds.DartDevelopmentService]. Allows for us to
/// mock out this functionality for testing purposes.
/// mock out this functionality for testing purposes.
class
DartDevelopmentService
{
class
DartDevelopmentService
{
dds
.
DartDevelopmentService
_ddsInstance
;
dds
.
DartDevelopmentService
?
_ddsInstance
;
Uri
get
uri
=>
_ddsInstance
?.
uri
??
_existingDdsUri
;
Uri
?
get
uri
=>
_ddsInstance
?.
uri
??
_existingDdsUri
;
Uri
_existingDdsUri
;
Uri
?
_existingDdsUri
;
Future
<
void
>
get
done
=>
_completer
.
future
;
Future
<
void
>
get
done
=>
_completer
.
future
;
final
Completer
<
void
>
_completer
=
Completer
<
void
>();
final
Completer
<
void
>
_completer
=
Completer
<
void
>();
Future
<
void
>
startDartDevelopmentService
(
Future
<
void
>
startDartDevelopmentService
(
Uri
observatoryUri
,
Uri
observatoryUri
,
{
int
hostPort
,
required
Logger
logger
,
bool
ipv6
,
int
?
hostPort
,
bool
disableServiceAuthCodes
,
{
bool
?
ipv6
,
@required
Logger
logger
,
bool
?
disableServiceAuthCodes
,
})
async
{
})
async
{
final
Uri
ddsUri
=
Uri
(
final
Uri
ddsUri
=
Uri
(
scheme:
'http'
,
scheme:
'http'
,
host:
(
ipv6
?
host:
(
ipv6
==
true
?
io
.
InternetAddress
.
loopbackIPv6
:
io
.
InternetAddress
.
loopbackIPv4
).
host
,
io
.
InternetAddress
.
loopbackIPv6
:
io
.
InternetAddress
.
loopbackIPv4
).
host
,
port:
hostPort
??
0
,
port:
hostPort
??
0
,
);
);
logger
.
printTrace
(
logger
.
printTrace
(
...
@@ -55,15 +50,15 @@ class DartDevelopmentService {
...
@@ -55,15 +50,15 @@ class DartDevelopmentService {
_ddsInstance
=
await
ddsLauncherCallback
(
_ddsInstance
=
await
ddsLauncherCallback
(
observatoryUri
,
observatoryUri
,
serviceUri:
ddsUri
,
serviceUri:
ddsUri
,
enableAuthCodes:
!
disableServiceAuthCodes
,
enableAuthCodes:
disableServiceAuthCodes
!=
true
,
ipv6:
ipv6
,
ipv6:
ipv6
==
true
,
);
);
unawaited
(
_ddsInstance
.
done
.
whenComplete
(()
{
unawaited
(
_ddsInstance
?
.
done
.
whenComplete
(()
{
if
(!
_completer
.
isCompleted
)
{
if
(!
_completer
.
isCompleted
)
{
_completer
.
complete
();
_completer
.
complete
();
}
}
}));
}));
logger
.
printTrace
(
'DDS is listening at
${_ddsInstance.uri}
.'
);
logger
.
printTrace
(
'DDS is listening at
${_ddsInstance
?
.uri}
.'
);
}
on
dds
.
DartDevelopmentServiceException
catch
(
e
)
{
}
on
dds
.
DartDevelopmentServiceException
catch
(
e
)
{
logger
.
printTrace
(
'Warning: Failed to start DDS:
${e.message}
'
);
logger
.
printTrace
(
'Warning: Failed to start DDS:
${e.message}
'
);
if
(
e
.
errorCode
==
dds
.
DartDevelopmentServiceException
.
existingDdsInstanceError
)
{
if
(
e
.
errorCode
==
dds
.
DartDevelopmentServiceException
.
existingDdsInstanceError
)
{
...
...
packages/flutter_tools/lib/src/drive/drive_service.dart
View file @
2d550329
...
@@ -225,9 +225,9 @@ class FlutterDriverService extends DriverService {
...
@@ -225,9 +225,9 @@ class FlutterDriverService extends DriverService {
try
{
try
{
await
device
.
dds
.
startDartDevelopmentService
(
await
device
.
dds
.
startDartDevelopmentService
(
uri
,
uri
,
debuggingOptions
.
ddsPort
,
hostPort:
debuggingOptions
.
ddsPort
,
ipv6
,
ipv6
:
ipv6
,
debuggingOptions
.
disableServiceAuthCodes
,
d
isableServiceAuthCodes:
d
ebuggingOptions
.
disableServiceAuthCodes
,
logger:
_logger
,
logger:
_logger
,
);
);
_vmServiceUri
=
device
.
dds
.
uri
.
toString
();
_vmServiceUri
=
device
.
dds
.
uri
.
toString
();
...
...
packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart
View file @
2d550329
...
@@ -65,9 +65,9 @@ Future<void> _kDefaultDartDevelopmentServiceStarter(
...
@@ -65,9 +65,9 @@ Future<void> _kDefaultDartDevelopmentServiceStarter(
)
async
{
)
async
{
await
device
.
dds
.
startDartDevelopmentService
(
await
device
.
dds
.
startDartDevelopmentService
(
observatoryUri
,
observatoryUri
,
0
,
hostPort:
0
,
true
,
ipv6:
true
,
disableServiceAuthCodes
,
disableServiceAuthCodes
:
disableServiceAuthCodes
,
logger:
globals
.
logger
,
logger:
globals
.
logger
,
);
);
}
}
...
...
packages/flutter_tools/lib/src/resident_runner.dart
View file @
2d550329
...
@@ -263,9 +263,9 @@ class FlutterDevice {
...
@@ -263,9 +263,9 @@ class FlutterDevice {
try
{
try
{
await
device
.
dds
.
startDartDevelopmentService
(
await
device
.
dds
.
startDartDevelopmentService
(
observatoryUri
,
observatoryUri
,
ddsPort
,
hostPort:
ddsPort
,
ipv6
,
ipv6
:
ipv6
,
disableServiceAuthCodes
,
disableServiceAuthCodes
:
disableServiceAuthCodes
,
logger:
globals
.
logger
,
logger:
globals
.
logger
,
);
);
}
on
dds
.
DartDevelopmentServiceException
catch
(
e
,
st
)
{
}
on
dds
.
DartDevelopmentServiceException
catch
(
e
,
st
)
{
...
...
packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart
View file @
2d550329
...
@@ -767,11 +767,11 @@ class FakeDartDevelopmentService extends Fake implements DartDevelopmentService
...
@@ -767,11 +767,11 @@ class FakeDartDevelopmentService extends Fake implements DartDevelopmentService
@override
@override
Future
<
void
>
startDartDevelopmentService
(
Future
<
void
>
startDartDevelopmentService
(
Uri
observatoryUri
,
Uri
observatoryUri
,
{
@required
Logger
logger
,
int
hostPort
,
int
hostPort
,
bool
ipv6
,
bool
ipv6
,
bool
disableServiceAuthCodes
,
{
bool
disableServiceAuthCodes
,
@required
Logger
logger
,
})
async
{}
})
async
{}
@override
@override
...
...
packages/flutter_tools/test/general.shard/drive/drive_service_test.dart
View file @
2d550329
...
@@ -605,11 +605,11 @@ class FakeDartDevelopmentService extends Fake implements DartDevelopmentService
...
@@ -605,11 +605,11 @@ class FakeDartDevelopmentService extends Fake implements DartDevelopmentService
@override
@override
Future
<
void
>
startDartDevelopmentService
(
Future
<
void
>
startDartDevelopmentService
(
Uri
observatoryUri
,
Uri
observatoryUri
,
{
@required
Logger
logger
,
int
hostPort
,
int
hostPort
,
bool
ipv6
,
bool
ipv6
,
bool
disableServiceAuthCodes
,
{
bool
disableServiceAuthCodes
,
@required
Logger
logger
,
})
async
{
})
async
{
started
=
true
;
started
=
true
;
}
}
...
...
packages/flutter_tools/test/general.shard/fuchsia/fuchsia_device_test.dart
View file @
2d550329
...
@@ -1008,7 +1008,13 @@ class FakeFuchsiaSdk extends Fake implements FuchsiaSdk {
...
@@ -1008,7 +1008,13 @@ class FakeFuchsiaSdk extends Fake implements FuchsiaSdk {
class
FakeDartDevelopmentService
extends
Fake
implements
DartDevelopmentService
{
class
FakeDartDevelopmentService
extends
Fake
implements
DartDevelopmentService
{
@override
@override
Future
<
void
>
startDartDevelopmentService
(
Uri
observatoryUri
,
int
hostPort
,
bool
ipv6
,
bool
disableServiceAuthCodes
,
{
Logger
logger
})
async
{
}
Future
<
void
>
startDartDevelopmentService
(
Uri
observatoryUri
,
{
@required
Logger
logger
,
int
hostPort
,
bool
ipv6
,
bool
disableServiceAuthCodes
,
})
async
{}
@override
@override
Uri
get
uri
=>
Uri
.
parse
(
'example'
);
Uri
get
uri
=>
Uri
.
parse
(
'example'
);
...
...
packages/flutter_tools/test/general.shard/resident_runner_test.dart
View file @
2d550329
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
// @dart = 2.8
// @dart = 2.8
import
'dart:async'
;
import
'dart:async'
;
import
'dart:io'
;
import
'package:dds/dds.dart'
as
dds
;
import
'package:dds/dds.dart'
as
dds
;
import
'package:file/memory.dart'
;
import
'package:file/memory.dart'
;
...
@@ -1806,6 +1807,10 @@ void main() {
...
@@ -1806,6 +1807,10 @@ void main() {
final
FakeDevice
device
=
FakeDevice
()
final
FakeDevice
device
=
FakeDevice
()
..
dds
=
DartDevelopmentService
();
..
dds
=
DartDevelopmentService
();
ddsLauncherCallback
=
(
Uri
uri
,
{
bool
enableAuthCodes
,
bool
ipv6
,
Uri
serviceUri
})
{
ddsLauncherCallback
=
(
Uri
uri
,
{
bool
enableAuthCodes
,
bool
ipv6
,
Uri
serviceUri
})
{
expect
(
uri
,
Uri
(
scheme:
'foo'
,
host:
'bar'
));
expect
(
enableAuthCodes
,
isTrue
);
expect
(
ipv6
,
isFalse
);
expect
(
serviceUri
,
Uri
(
scheme:
'http'
,
host:
'127.0.0.1'
,
port:
0
));
throw
FakeDartDevelopmentServiceException
(
message:
throw
FakeDartDevelopmentServiceException
(
message:
'Existing VM service clients prevent DDS from taking control.'
,
'Existing VM service clients prevent DDS from taking control.'
,
);
);
...
@@ -1843,11 +1848,47 @@ void main() {
...
@@ -1843,11 +1848,47 @@ void main() {
})
async
=>
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]).
vmService
,
})
async
=>
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]).
vmService
,
}));
}));
testUsingContext
(
'Host VM service ipv6 defaults'
,
()
=>
testbed
.
run
(()
async
{
fakeVmServiceHost
=
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]);
final
FakeDevice
device
=
FakeDevice
()
..
dds
=
DartDevelopmentService
();
final
Completer
<
void
>
done
=
Completer
<
void
>();
ddsLauncherCallback
=
(
Uri
uri
,
{
bool
enableAuthCodes
,
bool
ipv6
,
Uri
serviceUri
})
async
{
expect
(
uri
,
Uri
(
scheme:
'foo'
,
host:
'bar'
));
expect
(
enableAuthCodes
,
isFalse
);
expect
(
ipv6
,
isTrue
);
expect
(
serviceUri
,
Uri
(
scheme:
'http'
,
host:
'::1'
,
port:
0
));
done
.
complete
();
return
null
;
};
final
TestFlutterDevice
flutterDevice
=
TestFlutterDevice
(
device
,
observatoryUris:
Stream
<
Uri
>.
value
(
testUri
),
);
await
flutterDevice
.
connect
(
allowExistingDdsInstance:
true
,
ipv6:
true
,
disableServiceAuthCodes:
true
);
await
done
.
future
;
},
overrides:
<
Type
,
Generator
>{
VMServiceConnector:
()
=>
(
Uri
httpUri
,
{
ReloadSources
reloadSources
,
Restart
restart
,
CompileExpression
compileExpression
,
GetSkSLMethod
getSkSLMethod
,
PrintStructuredErrorLogMethod
printStructuredErrorLogMethod
,
io
.
CompressionOptions
compression
,
Device
device
,
Logger
logger
,
})
async
=>
FakeVmServiceHost
(
requests:
<
VmServiceExpectation
>[]).
vmService
,
}));
testUsingContext
(
'Failed DDS start outputs error message'
,
()
=>
testbed
.
run
(()
async
{
testUsingContext
(
'Failed DDS start outputs error message'
,
()
=>
testbed
.
run
(()
async
{
// See https://github.com/flutter/flutter/issues/72385 for context.
// See https://github.com/flutter/flutter/issues/72385 for context.
final
FakeDevice
device
=
FakeDevice
()
final
FakeDevice
device
=
FakeDevice
()
..
dds
=
DartDevelopmentService
();
..
dds
=
DartDevelopmentService
();
ddsLauncherCallback
=
(
Uri
uri
,
{
bool
enableAuthCodes
,
bool
ipv6
,
Uri
serviceUri
})
{
ddsLauncherCallback
=
(
Uri
uri
,
{
bool
enableAuthCodes
,
bool
ipv6
,
Uri
serviceUri
})
{
expect
(
uri
,
Uri
(
scheme:
'foo'
,
host:
'bar'
));
expect
(
enableAuthCodes
,
isTrue
);
expect
(
ipv6
,
isFalse
);
expect
(
serviceUri
,
Uri
(
scheme:
'http'
,
host:
'127.0.0.1'
,
port:
0
));
throw
FakeDartDevelopmentServiceException
(
message:
'No URI'
);
throw
FakeDartDevelopmentServiceException
(
message:
'No URI'
);
};
};
final
TestFlutterDevice
flutterDevice
=
TestFlutterDevice
(
final
TestFlutterDevice
flutterDevice
=
TestFlutterDevice
(
...
...
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