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
53e04de6
Unverified
Commit
53e04de6
authored
Oct 30, 2021
by
Jenn Magder
Committed by
GitHub
Oct 30, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate mdns_discovery and ios simulator to null safety (#92124)
parent
b0810bc9
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
214 additions
and
208 deletions
+214
-208
context_runner.dart
packages/flutter_tools/lib/src/context_runner.dart
+1
-1
globals.dart
packages/flutter_tools/lib/src/globals.dart
+0
-2
globals_null_migrated.dart
packages/flutter_tools/lib/src/globals_null_migrated.dart
+2
-0
simulators.dart
packages/flutter_tools/lib/src/ios/simulators.dart
+110
-134
mdns_discovery.dart
packages/flutter_tools/lib/src/mdns_discovery.dart
+23
-22
sksl_writer.dart
packages/flutter_tools/lib/src/sksl_writer.dart
+3
-5
simulators_test.dart
...flutter_tools/test/general.shard/ios/simulators_test.dart
+61
-28
mdns_discovery_test.dart
...flutter_tools/test/general.shard/mdns_discovery_test.dart
+14
-16
No files found.
packages/flutter_tools/lib/src/context_runner.dart
View file @
53e04de6
...
@@ -44,7 +44,7 @@ import 'flutter_features.dart';
...
@@ -44,7 +44,7 @@ import 'flutter_features.dart';
import
'fuchsia/fuchsia_device.dart'
show
FuchsiaDeviceTools
;
import
'fuchsia/fuchsia_device.dart'
show
FuchsiaDeviceTools
;
import
'fuchsia/fuchsia_sdk.dart'
show
FuchsiaSdk
,
FuchsiaArtifacts
;
import
'fuchsia/fuchsia_sdk.dart'
show
FuchsiaSdk
,
FuchsiaArtifacts
;
import
'fuchsia/fuchsia_workflow.dart'
show
FuchsiaWorkflow
,
fuchsiaWorkflow
;
import
'fuchsia/fuchsia_workflow.dart'
show
FuchsiaWorkflow
,
fuchsiaWorkflow
;
import
'globals.dart'
as
globals
;
import
'globals
_null_migrated
.dart'
as
globals
;
import
'ios/ios_workflow.dart'
;
import
'ios/ios_workflow.dart'
;
import
'ios/iproxy.dart'
;
import
'ios/iproxy.dart'
;
import
'ios/simulators.dart'
;
import
'ios/simulators.dart'
;
...
...
packages/flutter_tools/lib/src/globals.dart
View file @
53e04de6
...
@@ -6,9 +6,7 @@
...
@@ -6,9 +6,7 @@
import
'base/context.dart'
;
import
'base/context.dart'
;
import
'doctor.dart'
;
import
'doctor.dart'
;
import
'ios/simulators.dart'
;
export
'globals_null_migrated.dart'
;
export
'globals_null_migrated.dart'
;
Doctor
get
doctor
=>
context
.
get
<
Doctor
>();
Doctor
get
doctor
=>
context
.
get
<
Doctor
>();
IOSSimulatorUtils
get
iosSimulatorUtils
=>
context
.
get
<
IOSSimulatorUtils
>();
packages/flutter_tools/lib/src/globals_null_migrated.dart
View file @
53e04de6
...
@@ -31,6 +31,7 @@ import 'device.dart';
...
@@ -31,6 +31,7 @@ import 'device.dart';
import
'fuchsia/fuchsia_sdk.dart'
;
import
'fuchsia/fuchsia_sdk.dart'
;
import
'ios/ios_workflow.dart'
;
import
'ios/ios_workflow.dart'
;
import
'ios/plist_parser.dart'
;
import
'ios/plist_parser.dart'
;
import
'ios/simulators.dart'
;
import
'ios/xcodeproj.dart'
;
import
'ios/xcodeproj.dart'
;
import
'macos/cocoapods.dart'
;
import
'macos/cocoapods.dart'
;
import
'macos/cocoapods_validator.dart'
;
import
'macos/cocoapods_validator.dart'
;
...
@@ -54,6 +55,7 @@ Config get config => context.get<Config>()!;
...
@@ -54,6 +55,7 @@ Config get config => context.get<Config>()!;
CrashReporter
?
get
crashReporter
=>
context
.
get
<
CrashReporter
>();
CrashReporter
?
get
crashReporter
=>
context
.
get
<
CrashReporter
>();
DeviceManager
?
get
deviceManager
=>
context
.
get
<
DeviceManager
>();
DeviceManager
?
get
deviceManager
=>
context
.
get
<
DeviceManager
>();
HttpClientFactory
?
get
httpClientFactory
=>
context
.
get
<
HttpClientFactory
>();
HttpClientFactory
?
get
httpClientFactory
=>
context
.
get
<
HttpClientFactory
>();
IOSSimulatorUtils
?
get
iosSimulatorUtils
=>
context
.
get
<
IOSSimulatorUtils
>();
Logger
get
logger
=>
context
.
get
<
Logger
>()!;
Logger
get
logger
=>
context
.
get
<
Logger
>()!;
OperatingSystemUtils
get
os
=>
context
.
get
<
OperatingSystemUtils
>()!;
OperatingSystemUtils
get
os
=>
context
.
get
<
OperatingSystemUtils
>()!;
Signals
get
signals
=>
context
.
get
<
Signals
>()
??
LocalSignals
.
instance
;
Signals
get
signals
=>
context
.
get
<
Signals
>()
??
LocalSignals
.
instance
;
...
...
packages/flutter_tools/lib/src/ios/simulators.dart
View file @
53e04de6
...
@@ -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
'dart:math'
as
math
;
import
'dart:math'
as
math
;
...
@@ -34,7 +32,7 @@ const String iosSimulatorId = 'apple_ios_simulator';
...
@@ -34,7 +32,7 @@ const String iosSimulatorId = 'apple_ios_simulator';
class
IOSSimulators
extends
PollingDeviceDiscovery
{
class
IOSSimulators
extends
PollingDeviceDiscovery
{
IOSSimulators
({
IOSSimulators
({
@
required
IOSSimulatorUtils
iosSimulatorUtils
,
required
IOSSimulatorUtils
iosSimulatorUtils
,
})
:
_iosSimulatorUtils
=
iosSimulatorUtils
,
})
:
_iosSimulatorUtils
=
iosSimulatorUtils
,
super
(
'iOS simulators'
);
super
(
'iOS simulators'
);
...
@@ -44,10 +42,10 @@ class IOSSimulators extends PollingDeviceDiscovery {
...
@@ -44,10 +42,10 @@ class IOSSimulators extends PollingDeviceDiscovery {
bool
get
supportsPlatform
=>
globals
.
platform
.
isMacOS
;
bool
get
supportsPlatform
=>
globals
.
platform
.
isMacOS
;
@override
@override
bool
get
canListAnything
=>
globals
.
iosWorkflow
.
canListDevices
;
bool
get
canListAnything
=>
globals
.
iosWorkflow
?.
canListDevices
??
false
;
@override
@override
Future
<
List
<
Device
>>
pollingGetDevices
({
Duration
timeout
})
async
=>
_iosSimulatorUtils
.
getAttachedDevices
();
Future
<
List
<
Device
>>
pollingGetDevices
({
Duration
?
timeout
})
async
=>
_iosSimulatorUtils
.
getAttachedDevices
();
@override
@override
List
<
String
>
get
wellKnownIds
=>
const
<
String
>[];
List
<
String
>
get
wellKnownIds
=>
const
<
String
>[];
...
@@ -55,9 +53,9 @@ class IOSSimulators extends PollingDeviceDiscovery {
...
@@ -55,9 +53,9 @@ class IOSSimulators extends PollingDeviceDiscovery {
class
IOSSimulatorUtils
{
class
IOSSimulatorUtils
{
IOSSimulatorUtils
({
IOSSimulatorUtils
({
@
required
Xcode
xcode
,
required
Xcode
xcode
,
@
required
Logger
logger
,
required
Logger
logger
,
@
required
ProcessManager
processManager
,
required
ProcessManager
processManager
,
})
:
_simControl
=
SimControl
(
})
:
_simControl
=
SimControl
(
logger:
logger
,
logger:
logger
,
processManager:
processManager
,
processManager:
processManager
,
...
@@ -74,23 +72,33 @@ class IOSSimulatorUtils {
...
@@ -74,23 +72,33 @@ class IOSSimulatorUtils {
}
}
final
List
<
SimDevice
>
connected
=
await
_simControl
.
getConnectedDevices
();
final
List
<
SimDevice
>
connected
=
await
_simControl
.
getConnectedDevices
();
return
connected
.
map
<
IOSSimulator
>((
SimDevice
device
)
{
return
connected
.
map
<
IOSSimulator
?>((
SimDevice
device
)
{
final
String
?
udid
=
device
.
udid
;
final
String
?
name
=
device
.
name
;
if
(
udid
==
null
)
{
globals
.
printTrace
(
'Could not parse simulator udid'
);
return
null
;
}
if
(
name
==
null
)
{
globals
.
printTrace
(
'Could not parse simulator name'
);
return
null
;
}
return
IOSSimulator
(
return
IOSSimulator
(
device
.
udid
,
udid
,
name:
device
.
name
,
name:
name
,
simControl:
_simControl
,
simControl:
_simControl
,
simulatorCategory:
device
.
category
,
simulatorCategory:
device
.
category
,
);
);
}).
toList
();
}).
whereType
<
IOSSimulator
>().
toList
();
}
}
}
}
/// A wrapper around the `simctl` command line tool.
/// A wrapper around the `simctl` command line tool.
class
SimControl
{
class
SimControl
{
SimControl
({
SimControl
({
@
required
Logger
logger
,
required
Logger
logger
,
@
required
ProcessManager
processManager
,
required
ProcessManager
processManager
,
@
required
Xcode
xcode
,
required
Xcode
xcode
,
})
:
_logger
=
logger
,
})
:
_logger
=
logger
,
_xcode
=
xcode
,
_xcode
=
xcode
,
_processUtils
=
ProcessUtils
(
processManager:
processManager
,
logger:
logger
);
_processUtils
=
ProcessUtils
(
processManager:
processManager
,
logger:
logger
);
...
@@ -101,7 +109,7 @@ class SimControl {
...
@@ -101,7 +109,7 @@ class SimControl {
/// Runs `simctl list --json` and returns the JSON of the corresponding
/// Runs `simctl list --json` and returns the JSON of the corresponding
/// [section].
/// [section].
Future
<
Map
<
String
,
dynamic
>>
_list
(
SimControlListSection
section
)
async
{
Future
<
Map
<
String
,
Object
?
>>
_list
(
SimControlListSection
section
)
async
{
// Sample output from `simctl list --json`:
// Sample output from `simctl list --json`:
//
//
// {
// {
...
@@ -130,21 +138,21 @@ class SimControl {
...
@@ -130,21 +138,21 @@ class SimControl {
final
RunResult
results
=
await
_processUtils
.
run
(
command
);
final
RunResult
results
=
await
_processUtils
.
run
(
command
);
if
(
results
.
exitCode
!=
0
)
{
if
(
results
.
exitCode
!=
0
)
{
_logger
.
printError
(
'Error executing simctl:
${results.exitCode}
\n
${results.stderr}
'
);
_logger
.
printError
(
'Error executing simctl:
${results.exitCode}
\n
${results.stderr}
'
);
return
<
String
,
Map
<
String
,
dynamic
>>{};
return
<
String
,
Map
<
String
,
Object
?
>>{};
}
}
try
{
try
{
final
Object
decodeResult
=
(
json
.
decode
(
results
.
stdout
)
as
Map
<
String
,
dynamic
>)[
section
.
name
];
final
Object
?
decodeResult
=
(
json
.
decode
(
results
.
stdout
)
as
Map
<
String
,
Object
?
>)[
section
.
name
];
if
(
decodeResult
is
Map
<
String
,
dynamic
>)
{
if
(
decodeResult
is
Map
<
String
,
Object
?
>)
{
return
decodeResult
;
return
decodeResult
;
}
}
_logger
.
printError
(
'simctl returned unexpected JSON response:
${results.stdout}
'
);
_logger
.
printError
(
'simctl returned unexpected JSON response:
${results.stdout}
'
);
return
<
String
,
dynamic
>{};
return
<
String
,
Object
>{};
}
on
FormatException
{
}
on
FormatException
{
// We failed to parse the simctl output, or it returned junk.
// We failed to parse the simctl output, or it returned junk.
// One known message is "Install Started" isn't valid JSON but is
// One known message is "Install Started" isn't valid JSON but is
// returned sometimes.
// returned sometimes.
_logger
.
printError
(
'simctl returned non-JSON response:
${results.stdout}
'
);
_logger
.
printError
(
'simctl returned non-JSON response:
${results.stdout}
'
);
return
<
String
,
dynamic
>{};
return
<
String
,
Object
>{};
}
}
}
}
...
@@ -152,12 +160,12 @@ class SimControl {
...
@@ -152,12 +160,12 @@ class SimControl {
Future
<
List
<
SimDevice
>>
getDevices
()
async
{
Future
<
List
<
SimDevice
>>
getDevices
()
async
{
final
List
<
SimDevice
>
devices
=
<
SimDevice
>[];
final
List
<
SimDevice
>
devices
=
<
SimDevice
>[];
final
Map
<
String
,
dynamic
>
devicesSection
=
await
_list
(
SimControlListSection
.
devices
);
final
Map
<
String
,
Object
?
>
devicesSection
=
await
_list
(
SimControlListSection
.
devices
);
for
(
final
String
deviceCategory
in
devicesSection
.
keys
)
{
for
(
final
String
deviceCategory
in
devicesSection
.
keys
)
{
final
Object
devicesData
=
devicesSection
[
deviceCategory
];
final
Object
?
devicesData
=
devicesSection
[
deviceCategory
];
if
(
devicesData
!=
null
&&
devicesData
is
List
<
dynamic
>)
{
if
(
devicesData
!=
null
&&
devicesData
is
List
<
Object
?
>)
{
for
(
final
Map
<
String
,
dynamic
>
data
in
devicesData
.
map
<
Map
<
String
,
dynamic
>>(
castStringKeyedMap
))
{
for
(
final
Map
<
String
,
Object
?>
data
in
devicesData
.
map
<
Map
<
String
,
Object
?>?>(
castStringKeyedMap
).
whereType
<
Map
<
String
,
Object
?>>(
))
{
devices
.
add
(
SimDevice
(
deviceCategory
,
data
));
devices
.
add
(
SimDevice
(
deviceCategory
,
data
));
}
}
}
}
...
@@ -220,7 +228,7 @@ class SimControl {
...
@@ -220,7 +228,7 @@ class SimControl {
return
result
;
return
result
;
}
}
Future
<
RunResult
>
launch
(
String
deviceId
,
String
appIdentifier
,
[
List
<
String
>
launchArgs
])
async
{
Future
<
RunResult
>
launch
(
String
deviceId
,
String
appIdentifier
,
[
List
<
String
>
?
launchArgs
])
async
{
RunResult
result
;
RunResult
result
;
try
{
try
{
result
=
await
_processUtils
.
run
(
result
=
await
_processUtils
.
run
(
...
@@ -299,12 +307,12 @@ class SimDevice {
...
@@ -299,12 +307,12 @@ class SimDevice {
SimDevice
(
this
.
category
,
this
.
data
);
SimDevice
(
this
.
category
,
this
.
data
);
final
String
category
;
final
String
category
;
final
Map
<
String
,
dynamic
>
data
;
final
Map
<
String
,
Object
?
>
data
;
String
get
state
=>
data
[
'state'
]?.
toString
();
String
?
get
state
=>
data
[
'state'
]?.
toString
();
String
get
availability
=>
data
[
'availability'
]?.
toString
();
String
?
get
availability
=>
data
[
'availability'
]?.
toString
();
String
get
name
=>
data
[
'name'
]?.
toString
();
String
?
get
name
=>
data
[
'name'
]?.
toString
();
String
get
udid
=>
data
[
'udid'
]?.
toString
();
String
?
get
udid
=>
data
[
'udid'
]?.
toString
();
bool
get
isBooted
=>
state
==
'Booted'
;
bool
get
isBooted
=>
state
==
'Booted'
;
}
}
...
@@ -312,9 +320,9 @@ class SimDevice {
...
@@ -312,9 +320,9 @@ class SimDevice {
class
IOSSimulator
extends
Device
{
class
IOSSimulator
extends
Device
{
IOSSimulator
(
IOSSimulator
(
String
id
,
{
String
id
,
{
this
.
name
,
required
this
.
name
,
this
.
simulatorCategory
,
required
this
.
simulatorCategory
,
@
required
SimControl
simControl
,
required
SimControl
simControl
,
})
:
_simControl
=
simControl
,
})
:
_simControl
=
simControl
,
super
(
super
(
id
,
id
,
...
@@ -353,13 +361,13 @@ class IOSSimulator extends Device {
...
@@ -353,13 +361,13 @@ class IOSSimulator extends Device {
@override
@override
bool
supportsRuntimeMode
(
BuildMode
buildMode
)
=>
buildMode
==
BuildMode
.
debug
;
bool
supportsRuntimeMode
(
BuildMode
buildMode
)
=>
buildMode
==
BuildMode
.
debug
;
Map
<
ApplicationPackage
,
_IOSSimulatorLogReader
>
_logReaders
;
final
Map
<
IOSApp
?,
DeviceLogReader
>
_logReaders
=
<
IOSApp
?,
DeviceLogReader
>{}
;
_IOSSimulatorDevicePortForwarder
_portForwarder
;
_IOSSimulatorDevicePortForwarder
?
_portForwarder
;
@override
@override
Future
<
bool
>
isAppInstalled
(
Future
<
bool
>
isAppInstalled
(
ApplicationPackage
app
,
{
ApplicationPackage
app
,
{
String
userIdentifier
,
String
?
userIdentifier
,
})
{
})
{
return
_simControl
.
isInstalled
(
id
,
app
.
id
);
return
_simControl
.
isInstalled
(
id
,
app
.
id
);
}
}
...
@@ -370,7 +378,7 @@ class IOSSimulator extends Device {
...
@@ -370,7 +378,7 @@ class IOSSimulator extends Device {
@override
@override
Future
<
bool
>
installApp
(
Future
<
bool
>
installApp
(
covariant
IOSApp
app
,
{
covariant
IOSApp
app
,
{
String
userIdentifier
,
String
?
userIdentifier
,
})
async
{
})
async
{
try
{
try
{
final
IOSApp
iosApp
=
app
;
final
IOSApp
iosApp
=
app
;
...
@@ -384,7 +392,7 @@ class IOSSimulator extends Device {
...
@@ -384,7 +392,7 @@ class IOSSimulator extends Device {
@override
@override
Future
<
bool
>
uninstallApp
(
Future
<
bool
>
uninstallApp
(
ApplicationPackage
app
,
{
ApplicationPackage
app
,
{
String
userIdentifier
,
String
?
userIdentifier
,
})
async
{
})
async
{
try
{
try
{
await
_simControl
.
uninstall
(
id
,
app
.
id
);
await
_simControl
.
uninstall
(
id
,
app
.
id
);
...
@@ -411,7 +419,7 @@ class IOSSimulator extends Device {
...
@@ -411,7 +419,7 @@ class IOSSimulator extends Device {
return
true
;
return
true
;
}
}
String
_supportMessage
;
String
?
_supportMessage
;
@override
@override
String
supportMessage
()
{
String
supportMessage
()
{
...
@@ -425,13 +433,13 @@ class IOSSimulator extends Device {
...
@@ -425,13 +433,13 @@ class IOSSimulator extends Device {
@override
@override
Future
<
LaunchResult
>
startApp
(
Future
<
LaunchResult
>
startApp
(
covariant
IOSApp
package
,
{
covariant
IOSApp
package
,
{
String
mainPath
,
String
?
mainPath
,
String
route
,
String
?
route
,
DebuggingOptions
debuggingOptions
,
required
DebuggingOptions
debuggingOptions
,
Map
<
String
,
dynamic
>
platformArgs
,
Map
<
String
,
Object
?>
platformArgs
=
const
<
String
,
Object
?>{}
,
bool
prebuiltApplication
=
false
,
bool
prebuiltApplication
=
false
,
bool
ipv6
=
false
,
bool
ipv6
=
false
,
String
userIdentifier
,
String
?
userIdentifier
,
})
async
{
})
async
{
if
(!
prebuiltApplication
&&
package
is
BuildableIOSApp
)
{
if
(!
prebuiltApplication
&&
package
is
BuildableIOSApp
)
{
globals
.
printTrace
(
'Building
${package.name}
for
$id
.'
);
globals
.
printTrace
(
'Building
${package.name}
for
$id
.'
);
...
@@ -439,7 +447,7 @@ class IOSSimulator extends Device {
...
@@ -439,7 +447,7 @@ class IOSSimulator extends Device {
try
{
try
{
await
_setupUpdatedApplicationBundle
(
package
,
debuggingOptions
.
buildInfo
,
mainPath
);
await
_setupUpdatedApplicationBundle
(
package
,
debuggingOptions
.
buildInfo
,
mainPath
);
}
on
ToolExit
catch
(
e
)
{
}
on
ToolExit
catch
(
e
)
{
globals
.
printError
(
e
.
message
);
globals
.
printError
(
'
${e.message}
'
);
return
LaunchResult
.
failed
();
return
LaunchResult
.
failed
();
}
}
}
else
{
}
else
{
...
@@ -469,7 +477,7 @@ class IOSSimulator extends Device {
...
@@ -469,7 +477,7 @@ class IOSSimulator extends Device {
],
],
];
];
ProtocolDiscovery
observatoryDiscovery
;
ProtocolDiscovery
?
observatoryDiscovery
;
if
(
debuggingOptions
.
debuggingEnabled
)
{
if
(
debuggingOptions
.
debuggingEnabled
)
{
observatoryDiscovery
=
ProtocolDiscovery
.
observatory
(
observatoryDiscovery
=
ProtocolDiscovery
.
observatory
(
getLogReader
(
app:
package
),
getLogReader
(
app:
package
),
...
@@ -487,7 +495,11 @@ class IOSSimulator extends Device {
...
@@ -487,7 +495,11 @@ class IOSSimulator extends Device {
// parsing the xcodeproj or configuration files.
// parsing the xcodeproj or configuration files.
// See https://github.com/flutter/flutter/issues/31037 for more information.
// See https://github.com/flutter/flutter/issues/31037 for more information.
final
String
plistPath
=
globals
.
fs
.
path
.
join
(
package
.
simulatorBundlePath
,
'Info.plist'
);
final
String
plistPath
=
globals
.
fs
.
path
.
join
(
package
.
simulatorBundlePath
,
'Info.plist'
);
final
String
bundleIdentifier
=
globals
.
plistParser
.
getValueFromFile
(
plistPath
,
PlistParser
.
kCFBundleIdentifierKey
);
final
String
?
bundleIdentifier
=
globals
.
plistParser
.
getValueFromFile
(
plistPath
,
PlistParser
.
kCFBundleIdentifierKey
);
if
(
bundleIdentifier
==
null
)
{
globals
.
printError
(
'Invalid prebuilt iOS app. Info.plist does not contain bundle identifier'
);
return
LaunchResult
.
failed
();
}
await
_simControl
.
launch
(
id
,
bundleIdentifier
,
args
);
await
_simControl
.
launch
(
id
,
bundleIdentifier
,
args
);
}
on
Exception
catch
(
error
)
{
}
on
Exception
catch
(
error
)
{
...
@@ -504,7 +516,7 @@ class IOSSimulator extends Device {
...
@@ -504,7 +516,7 @@ class IOSSimulator extends Device {
globals
.
printTrace
(
'Waiting for observatory port to be available...'
);
globals
.
printTrace
(
'Waiting for observatory port to be available...'
);
try
{
try
{
final
Uri
deviceUri
=
await
observatoryDiscovery
.
uri
;
final
Uri
?
deviceUri
=
await
observatoryDiscovery
?
.
uri
;
if
(
deviceUri
!=
null
)
{
if
(
deviceUri
!=
null
)
{
return
LaunchResult
.
succeeded
(
observatoryUri:
deviceUri
);
return
LaunchResult
.
succeeded
(
observatoryUri:
deviceUri
);
}
}
...
@@ -520,7 +532,7 @@ class IOSSimulator extends Device {
...
@@ -520,7 +532,7 @@ class IOSSimulator extends Device {
return
LaunchResult
.
failed
();
return
LaunchResult
.
failed
();
}
}
Future
<
void
>
_setupUpdatedApplicationBundle
(
covariant
BuildableIOSApp
app
,
BuildInfo
buildInfo
,
String
mainPath
)
async
{
Future
<
void
>
_setupUpdatedApplicationBundle
(
covariant
BuildableIOSApp
app
,
BuildInfo
buildInfo
,
String
?
mainPath
)
async
{
// Step 1: Build the Xcode project.
// Step 1: Build the Xcode project.
// The build mode for the simulator is always debug.
// The build mode for the simulator is always debug.
assert
(
buildInfo
.
isDebug
);
assert
(
buildInfo
.
isDebug
);
...
@@ -550,17 +562,18 @@ class IOSSimulator extends Device {
...
@@ -550,17 +562,18 @@ class IOSSimulator extends Device {
@override
@override
Future
<
bool
>
stopApp
(
Future
<
bool
>
stopApp
(
ApplicationPackage
app
,
{
ApplicationPackage
app
,
{
String
userIdentifier
,
String
?
userIdentifier
,
})
async
{
})
async
{
// Currently we don't have a way to stop an app running on iOS.
// Currently we don't have a way to stop an app running on iOS.
return
false
;
return
false
;
}
}
String
get
logFilePath
{
String
get
logFilePath
{
return
globals
.
platform
.
environment
.
containsKey
(
'IOS_SIMULATOR_LOG_FILE_PATH'
)
final
String
?
logPath
=
globals
.
platform
.
environment
[
'IOS_SIMULATOR_LOG_FILE_PATH'
];
?
globals
.
platform
.
environment
[
'IOS_SIMULATOR_LOG_FILE_PATH'
].
replaceAll
(
'%{id}'
,
id
)
return
logPath
!=
null
?
logPath
.
replaceAll
(
'%{id}'
,
id
)
:
globals
.
fs
.
path
.
join
(
:
globals
.
fs
.
path
.
join
(
globals
.
fsUtils
.
homeDirPath
,
globals
.
fsUtils
.
homeDirPath
!
,
'Library'
,
'Library'
,
'Logs'
,
'Logs'
,
'CoreSimulator'
,
'CoreSimulator'
,
...
@@ -578,18 +591,16 @@ class IOSSimulator extends Device {
...
@@ -578,18 +591,16 @@ class IOSSimulator extends Device {
final
RegExp
_iosSdkRegExp
=
RegExp
(
r'iOS( |-)(\d+)'
);
final
RegExp
_iosSdkRegExp
=
RegExp
(
r'iOS( |-)(\d+)'
);
Future
<
int
>
get
sdkMajorVersion
async
{
Future
<
int
>
get
sdkMajorVersion
async
{
final
Match
sdkMatch
=
_iosSdkRegExp
.
firstMatch
(
await
sdkNameAndVersion
);
final
Match
?
sdkMatch
=
_iosSdkRegExp
.
firstMatch
(
await
sdkNameAndVersion
);
return
int
.
parse
(
sdkMatch
?.
group
(
2
)
??
'11'
);
return
int
.
parse
(
sdkMatch
?.
group
(
2
)
??
'11'
);
}
}
@override
@override
DeviceLogReader
getLogReader
({
DeviceLogReader
getLogReader
({
covariant
IOSApp
app
,
IOSApp
?
app
,
bool
includePastLogs
=
false
,
bool
includePastLogs
=
false
,
})
{
})
{
assert
(
app
==
null
||
app
is
IOSApp
);
assert
(!
includePastLogs
,
'Past log reading not supported on iOS simulators.'
);
assert
(!
includePastLogs
,
'Past log reading not supported on iOS simulators.'
);
_logReaders
??=
<
ApplicationPackage
,
_IOSSimulatorLogReader
>{};
return
_logReaders
.
putIfAbsent
(
app
,
()
=>
_IOSSimulatorLogReader
(
this
,
app
));
return
_logReaders
.
putIfAbsent
(
app
,
()
=>
_IOSSimulatorLogReader
(
this
,
app
));
}
}
...
@@ -630,11 +641,9 @@ class IOSSimulator extends Device {
...
@@ -630,11 +641,9 @@ class IOSSimulator extends Device {
@override
@override
Future
<
void
>
dispose
()
async
{
Future
<
void
>
dispose
()
async
{
_logReaders
?.
forEach
(
for
(
final
DeviceLogReader
logReader
in
_logReaders
.
values
)
{
(
ApplicationPackage
application
,
_IOSSimulatorLogReader
logReader
)
{
logReader
.
dispose
();
logReader
.
dispose
();
}
},
);
await
_portForwarder
?.
dispose
();
await
_portForwarder
?.
dispose
();
}
}
}
}
...
@@ -647,7 +656,7 @@ Future<Process> launchDeviceSystemLogTool(IOSSimulator device) async {
...
@@ -647,7 +656,7 @@ Future<Process> launchDeviceSystemLogTool(IOSSimulator device) async {
/// Launches the device log reader process on the host and parses unified logging.
/// Launches the device log reader process on the host and parses unified logging.
@visibleForTesting
@visibleForTesting
Future
<
Process
>
launchDeviceUnifiedLogging
(
IOSSimulator
device
,
String
appName
)
async
{
Future
<
Process
>
launchDeviceUnifiedLogging
(
IOSSimulator
device
,
String
?
appName
)
async
{
// Make NSPredicate concatenation easier to read.
// Make NSPredicate concatenation easier to read.
String
orP
(
List
<
String
>
clauses
)
=>
'(
${clauses.join(" OR ")}
)'
;
String
orP
(
List
<
String
>
clauses
)
=>
'(
${clauses.join(" OR ")}
)'
;
String
andP
(
List
<
String
>
clauses
)
=>
clauses
.
join
(
' AND '
);
String
andP
(
List
<
String
>
clauses
)
=>
clauses
.
join
(
' AND '
);
...
@@ -669,7 +678,7 @@ Future<Process> launchDeviceUnifiedLogging (IOSSimulator device, String appName)
...
@@ -669,7 +678,7 @@ Future<Process> launchDeviceUnifiedLogging (IOSSimulator device, String appName)
]);
]);
return
globals
.
processUtils
.
start
(<
String
>[
return
globals
.
processUtils
.
start
(<
String
>[
...
globals
.
xcode
.
xcrunCommand
(),
...
globals
.
xcode
!
.
xcrunCommand
(),
'simctl'
,
'simctl'
,
'spawn'
,
'spawn'
,
device
.
id
,
device
.
id
,
...
@@ -683,7 +692,7 @@ Future<Process> launchDeviceUnifiedLogging (IOSSimulator device, String appName)
...
@@ -683,7 +692,7 @@ Future<Process> launchDeviceUnifiedLogging (IOSSimulator device, String appName)
}
}
@visibleForTesting
@visibleForTesting
Future
<
Process
>
launchSystemLogTool
(
IOSSimulator
device
)
async
{
Future
<
Process
?
>
launchSystemLogTool
(
IOSSimulator
device
)
async
{
// Versions of iOS prior to 11 tail the simulator syslog file.
// Versions of iOS prior to 11 tail the simulator syslog file.
if
(
await
device
.
sdkMajorVersion
<
11
)
{
if
(
await
device
.
sdkMajorVersion
<
11
)
{
return
globals
.
processUtils
.
start
(<
String
>[
'tail'
,
'-n'
,
'0'
,
'-F'
,
'/private/var/log/system.log'
]);
return
globals
.
processUtils
.
start
(<
String
>[
'tail'
,
'-n'
,
'0'
,
'-F'
,
'/private/var/log/system.log'
]);
...
@@ -694,23 +703,20 @@ Future<Process> launchSystemLogTool(IOSSimulator device) async {
...
@@ -694,23 +703,20 @@ Future<Process> launchSystemLogTool(IOSSimulator device) async {
}
}
class
_IOSSimulatorLogReader
extends
DeviceLogReader
{
class
_IOSSimulatorLogReader
extends
DeviceLogReader
{
_IOSSimulatorLogReader
(
this
.
device
,
IOSApp
app
)
{
_IOSSimulatorLogReader
(
this
.
device
,
IOSApp
?
app
)
:
_appName
=
app
?.
name
?.
replaceAll
(
'.app'
,
''
);
_linesController
=
StreamController
<
String
>.
broadcast
(
onListen:
_start
,
onCancel:
_stop
,
);
_appName
=
app
?.
name
?.
replaceAll
(
'.app'
,
''
);
}
final
IOSSimulator
device
;
final
IOSSimulator
device
;
String
_appName
;
final
String
?
_appName
;
StreamController
<
String
>
_linesController
;
late
final
StreamController
<
String
>
_linesController
=
StreamController
<
String
>.
broadcast
(
onListen:
_start
,
onCancel:
_stop
,
);
// We log from two files: the device and the system log.
// We log from two files: the device and the system log.
Process
_deviceProcess
;
Process
?
_deviceProcess
;
Process
_systemProcess
;
Process
?
_systemProcess
;
@override
@override
Stream
<
String
>
get
logLines
=>
_linesController
.
stream
;
Stream
<
String
>
get
logLines
=>
_linesController
.
stream
;
...
@@ -722,27 +728,27 @@ class _IOSSimulatorLogReader extends DeviceLogReader {
...
@@ -722,27 +728,27 @@ class _IOSSimulatorLogReader extends DeviceLogReader {
// Unified logging iOS 11 and greater (introduced in iOS 10).
// Unified logging iOS 11 and greater (introduced in iOS 10).
if
(
await
device
.
sdkMajorVersion
>=
11
)
{
if
(
await
device
.
sdkMajorVersion
>=
11
)
{
_deviceProcess
=
await
launchDeviceUnifiedLogging
(
device
,
_appName
);
_deviceProcess
=
await
launchDeviceUnifiedLogging
(
device
,
_appName
);
_deviceProcess
.
stdout
.
transform
<
String
>(
utf8
.
decoder
).
transform
<
String
>(
const
LineSplitter
()).
listen
(
_onUnifiedLoggingLine
);
_deviceProcess
?
.
stdout
.
transform
<
String
>(
utf8
.
decoder
).
transform
<
String
>(
const
LineSplitter
()).
listen
(
_onUnifiedLoggingLine
);
_deviceProcess
.
stderr
.
transform
<
String
>(
utf8
.
decoder
).
transform
<
String
>(
const
LineSplitter
()).
listen
(
_onUnifiedLoggingLine
);
_deviceProcess
?
.
stderr
.
transform
<
String
>(
utf8
.
decoder
).
transform
<
String
>(
const
LineSplitter
()).
listen
(
_onUnifiedLoggingLine
);
}
else
{
}
else
{
// Fall back to syslog parsing.
// Fall back to syslog parsing.
await
device
.
ensureLogsExists
();
await
device
.
ensureLogsExists
();
_deviceProcess
=
await
launchDeviceSystemLogTool
(
device
);
_deviceProcess
=
await
launchDeviceSystemLogTool
(
device
);
_deviceProcess
.
stdout
.
transform
<
String
>(
utf8
.
decoder
).
transform
<
String
>(
const
LineSplitter
()).
listen
(
_onSysLogDeviceLine
);
_deviceProcess
?
.
stdout
.
transform
<
String
>(
utf8
.
decoder
).
transform
<
String
>(
const
LineSplitter
()).
listen
(
_onSysLogDeviceLine
);
_deviceProcess
.
stderr
.
transform
<
String
>(
utf8
.
decoder
).
transform
<
String
>(
const
LineSplitter
()).
listen
(
_onSysLogDeviceLine
);
_deviceProcess
?
.
stderr
.
transform
<
String
>(
utf8
.
decoder
).
transform
<
String
>(
const
LineSplitter
()).
listen
(
_onSysLogDeviceLine
);
}
}
// Track system.log crashes.
// Track system.log crashes.
// ReportCrash[37965]: Saved crash report for FlutterRunner[37941]...
// ReportCrash[37965]: Saved crash report for FlutterRunner[37941]...
_systemProcess
=
await
launchSystemLogTool
(
device
);
_systemProcess
=
await
launchSystemLogTool
(
device
);
if
(
_systemProcess
!=
null
)
{
if
(
_systemProcess
!=
null
)
{
_systemProcess
.
stdout
.
transform
<
String
>(
utf8
.
decoder
).
transform
<
String
>(
const
LineSplitter
()).
listen
(
_onSystemLine
);
_systemProcess
?
.
stdout
.
transform
<
String
>(
utf8
.
decoder
).
transform
<
String
>(
const
LineSplitter
()).
listen
(
_onSystemLine
);
_systemProcess
.
stderr
.
transform
<
String
>(
utf8
.
decoder
).
transform
<
String
>(
const
LineSplitter
()).
listen
(
_onSystemLine
);
_systemProcess
?
.
stderr
.
transform
<
String
>(
utf8
.
decoder
).
transform
<
String
>(
const
LineSplitter
()).
listen
(
_onSystemLine
);
}
}
// We don't want to wait for the process or its callback. Best effort
// We don't want to wait for the process or its callback. Best effort
// cleanup in the callback.
// cleanup in the callback.
unawaited
(
_deviceProcess
.
exitCode
.
whenComplete
(()
{
unawaited
(
_deviceProcess
?
.
exitCode
.
whenComplete
(()
{
if
(
_linesController
.
hasListener
)
{
if
(
_linesController
.
hasListener
)
{
_linesController
.
close
();
_linesController
.
close
();
}
}
...
@@ -764,19 +770,20 @@ class _IOSSimulatorLogReader extends DeviceLogReader {
...
@@ -764,19 +770,20 @@ class _IOSSimulatorLogReader extends DeviceLogReader {
// a multiline record
// a multiline record
bool
_lastLineMatched
=
false
;
bool
_lastLineMatched
=
false
;
String
_filterDeviceLine
(
String
string
)
{
String
?
_filterDeviceLine
(
String
string
)
{
final
Match
match
=
_mapRegex
.
matchAsPrefix
(
string
);
final
Match
?
match
=
_mapRegex
.
matchAsPrefix
(
string
);
if
(
match
!=
null
)
{
if
(
match
!=
null
)
{
// The category contains the text between the date and the PID. Depending on which version of iOS being run,
// The category contains the text between the date and the PID. Depending on which version of iOS being run,
// it can contain "hostname App Name" or just "App Name".
// it can contain "hostname App Name" or just "App Name".
final
String
category
=
match
.
group
(
1
);
final
String
?
category
=
match
.
group
(
1
);
final
String
tag
=
match
.
group
(
2
);
final
String
?
tag
=
match
.
group
(
2
);
final
String
content
=
match
.
group
(
3
);
final
String
?
content
=
match
.
group
(
3
);
// Filter out log lines from an app other than this one (category doesn't match the app name).
// Filter out log lines from an app other than this one (category doesn't match the app name).
// If the hostname is included in the category, check that it doesn't end with the app name.
// If the hostname is included in the category, check that it doesn't end with the app name.
if
(
_appName
!=
null
&&
!
category
.
endsWith
(
_appName
))
{
final
String
?
appName
=
_appName
;
if
(
appName
!=
null
&&
category
!=
null
&&
!
category
.
endsWith
(
appName
))
{
return
null
;
return
null
;
}
}
...
@@ -790,13 +797,13 @@ class _IOSSimulatorLogReader extends DeviceLogReader {
...
@@ -790,13 +797,13 @@ class _IOSSimulatorLogReader extends DeviceLogReader {
}
}
// assertion failed: 15G1212 13E230: libxpc.dylib + 57882 [66C28065-C9DB-3C8E-926F-5A40210A6D1B]: 0x7d
// assertion failed: 15G1212 13E230: libxpc.dylib + 57882 [66C28065-C9DB-3C8E-926F-5A40210A6D1B]: 0x7d
if
(
content
.
startsWith
(
'assertion failed: '
)
&&
content
.
contains
(
' libxpc.dylib '
))
{
if
(
content
!=
null
&&
content
.
startsWith
(
'assertion failed: '
)
&&
content
.
contains
(
' libxpc.dylib '
))
{
return
null
;
return
null
;
}
}
if
(
_
appName
==
null
)
{
if
(
appName
==
null
)
{
return
'
$category
:
$content
'
;
return
'
$category
:
$content
'
;
}
else
if
(
category
==
_appName
||
category
.
endsWith
(
'
$_appName
'
))
{
}
else
if
(
category
!=
null
&&
(
category
==
appName
||
category
.
endsWith
(
'
$appName
'
)
))
{
return
content
;
return
content
;
}
}
...
@@ -827,24 +834,24 @@ class _IOSSimulatorLogReader extends DeviceLogReader {
...
@@ -827,24 +834,24 @@ class _IOSSimulatorLogReader extends DeviceLogReader {
return
string
;
return
string
;
}
}
String
_lastLine
;
String
?
_lastLine
;
void
_onSysLogDeviceLine
(
String
line
)
{
void
_onSysLogDeviceLine
(
String
line
)
{
globals
.
printTrace
(
'[DEVICE LOG]
$line
'
);
globals
.
printTrace
(
'[DEVICE LOG]
$line
'
);
final
Match
multi
=
_lastMessageMultipleRegex
.
matchAsPrefix
(
line
);
final
Match
?
multi
=
_lastMessageMultipleRegex
.
matchAsPrefix
(
line
);
if
(
multi
!=
null
)
{
if
(
multi
!=
null
)
{
if
(
_lastLine
!=
null
)
{
if
(
_lastLine
!=
null
)
{
int
repeat
=
int
.
parse
(
multi
.
group
(
1
));
int
repeat
=
int
.
parse
(
multi
.
group
(
1
)
!
);
repeat
=
math
.
max
(
0
,
math
.
min
(
100
,
repeat
));
repeat
=
math
.
max
(
0
,
math
.
min
(
100
,
repeat
));
for
(
int
i
=
1
;
i
<
repeat
;
i
++)
{
for
(
int
i
=
1
;
i
<
repeat
;
i
++)
{
_linesController
.
add
(
_lastLine
);
_linesController
.
add
(
_lastLine
!
);
}
}
}
}
}
else
{
}
else
{
_lastLine
=
_filterDeviceLine
(
line
);
_lastLine
=
_filterDeviceLine
(
line
);
if
(
_lastLine
!=
null
)
{
if
(
_lastLine
!=
null
)
{
_linesController
.
add
(
_lastLine
);
_linesController
.
add
(
_lastLine
!
);
_lastLineMatched
=
true
;
_lastLineMatched
=
true
;
}
else
{
}
else
{
_lastLineMatched
=
false
;
_lastLineMatched
=
false
;
...
@@ -856,11 +863,11 @@ class _IOSSimulatorLogReader extends DeviceLogReader {
...
@@ -856,11 +863,11 @@ class _IOSSimulatorLogReader extends DeviceLogReader {
static
final
RegExp
_unifiedLoggingEventMessageRegex
=
RegExp
(
r'.*"eventMessage" : (".*")'
);
static
final
RegExp
_unifiedLoggingEventMessageRegex
=
RegExp
(
r'.*"eventMessage" : (".*")'
);
void
_onUnifiedLoggingLine
(
String
line
)
{
void
_onUnifiedLoggingLine
(
String
line
)
{
// The log command predicate handles filtering, so every log eventMessage should be decoded and added.
// The log command predicate handles filtering, so every log eventMessage should be decoded and added.
final
Match
eventMessageMatch
=
_unifiedLoggingEventMessageRegex
.
firstMatch
(
line
);
final
Match
?
eventMessageMatch
=
_unifiedLoggingEventMessageRegex
.
firstMatch
(
line
);
if
(
eventMessageMatch
!=
null
)
{
if
(
eventMessageMatch
!=
null
)
{
final
String
message
=
eventMessageMatch
.
group
(
1
);
final
String
message
=
eventMessageMatch
.
group
(
1
)
!
;
try
{
try
{
final
dynamic
decodedJson
=
jsonDecode
(
message
);
final
Object
?
decodedJson
=
jsonDecode
(
message
);
if
(
decodedJson
is
String
)
{
if
(
decodedJson
is
String
)
{
_linesController
.
add
(
decodedJson
);
_linesController
.
add
(
decodedJson
);
}
}
...
@@ -871,7 +878,7 @@ class _IOSSimulatorLogReader extends DeviceLogReader {
...
@@ -871,7 +878,7 @@ class _IOSSimulatorLogReader extends DeviceLogReader {
}
}
String
_filterSystemLog
(
String
string
)
{
String
_filterSystemLog
(
String
string
)
{
final
Match
match
=
_mapRegex
.
matchAsPrefix
(
string
);
final
Match
?
match
=
_mapRegex
.
matchAsPrefix
(
string
);
return
match
==
null
?
string
:
'
${match.group(1)}
:
${match.group(2)}
'
;
return
match
==
null
?
string
:
'
${match.group(1)}
:
${match.group(2)}
'
;
}
}
...
@@ -916,37 +923,6 @@ int compareIosVersions(String v1, String v2) {
...
@@ -916,37 +923,6 @@ int compareIosVersions(String v1, String v2) {
return
v1Fragments
.
length
.
compareTo
(
v2Fragments
.
length
);
return
v1Fragments
.
length
.
compareTo
(
v2Fragments
.
length
);
}
}
/// Matches on device type given an identifier.
///
/// Example device type identifiers:
///
/// - ✓ com.apple.CoreSimulator.SimDeviceType.iPhone-5
/// - ✓ com.apple.CoreSimulator.SimDeviceType.iPhone-6
/// - ✓ com.apple.CoreSimulator.SimDeviceType.iPhone-6s-Plus
/// - ✗ com.apple.CoreSimulator.SimDeviceType.iPad-2
/// - ✗ com.apple.CoreSimulator.SimDeviceType.Apple-Watch-38mm
final
RegExp
_iosDeviceTypePattern
=
RegExp
(
r'com.apple.CoreSimulator.SimDeviceType.iPhone-(\d+)(.*)'
);
int
compareIphoneVersions
(
String
id1
,
String
id2
)
{
final
Match
m1
=
_iosDeviceTypePattern
.
firstMatch
(
id1
);
final
Match
m2
=
_iosDeviceTypePattern
.
firstMatch
(
id2
);
final
int
v1
=
int
.
parse
(
m1
[
1
]);
final
int
v2
=
int
.
parse
(
m2
[
1
]);
if
(
v1
!=
v2
)
{
return
v1
.
compareTo
(
v2
);
}
// Sorted in the least preferred first order.
const
List
<
String
>
qualifiers
=
<
String
>[
'-Plus'
,
''
,
's-Plus'
,
's'
];
final
int
q1
=
qualifiers
.
indexOf
(
m1
[
2
]);
final
int
q2
=
qualifiers
.
indexOf
(
m2
[
2
]);
return
q1
.
compareTo
(
q2
);
}
class
_IOSSimulatorDevicePortForwarder
extends
DevicePortForwarder
{
class
_IOSSimulatorDevicePortForwarder
extends
DevicePortForwarder
{
_IOSSimulatorDevicePortForwarder
(
this
.
device
);
_IOSSimulatorDevicePortForwarder
(
this
.
device
);
...
@@ -958,7 +934,7 @@ class _IOSSimulatorDevicePortForwarder extends DevicePortForwarder {
...
@@ -958,7 +934,7 @@ class _IOSSimulatorDevicePortForwarder extends DevicePortForwarder {
List
<
ForwardedPort
>
get
forwardedPorts
=>
_ports
;
List
<
ForwardedPort
>
get
forwardedPorts
=>
_ports
;
@override
@override
Future
<
int
>
forward
(
int
devicePort
,
{
int
hostPort
})
async
{
Future
<
int
>
forward
(
int
devicePort
,
{
int
?
hostPort
})
async
{
if
(
hostPort
==
null
||
hostPort
==
0
)
{
if
(
hostPort
==
null
||
hostPort
==
0
)
{
hostPort
=
devicePort
;
hostPort
=
devicePort
;
}
}
...
...
packages/flutter_tools/lib/src/mdns_discovery.dart
View file @
53e04de6
...
@@ -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
'package:meta/meta.dart'
;
import
'package:meta/meta.dart'
;
import
'package:multicast_dns/multicast_dns.dart'
;
import
'package:multicast_dns/multicast_dns.dart'
;
...
@@ -24,9 +22,9 @@ class MDnsObservatoryDiscovery {
...
@@ -24,9 +22,9 @@ class MDnsObservatoryDiscovery {
/// automatically select which application to use if multiple are advertising
/// automatically select which application to use if multiple are advertising
/// Dart observatory ports.
/// Dart observatory ports.
MDnsObservatoryDiscovery
({
MDnsObservatoryDiscovery
({
MDnsClient
mdnsClient
,
MDnsClient
?
mdnsClient
,
@
required
Logger
logger
,
required
Logger
logger
,
@
required
Usage
flutterUsage
,
required
Usage
flutterUsage
,
}):
_client
=
mdnsClient
??
MDnsClient
(),
}):
_client
=
mdnsClient
??
MDnsClient
(),
_logger
=
logger
,
_logger
=
logger
,
_flutterUsage
=
flutterUsage
;
_flutterUsage
=
flutterUsage
;
...
@@ -38,7 +36,7 @@ class MDnsObservatoryDiscovery {
...
@@ -38,7 +36,7 @@ class MDnsObservatoryDiscovery {
@visibleForTesting
@visibleForTesting
static
const
String
dartObservatoryName
=
'_dartobservatory._tcp.local'
;
static
const
String
dartObservatoryName
=
'_dartobservatory._tcp.local'
;
static
MDnsObservatoryDiscovery
get
instance
=>
context
.
get
<
MDnsObservatoryDiscovery
>();
static
MDnsObservatoryDiscovery
?
get
instance
=>
context
.
get
<
MDnsObservatoryDiscovery
>();
/// Executes an mDNS query for a Dart Observatory.
/// Executes an mDNS query for a Dart Observatory.
///
///
...
@@ -59,7 +57,7 @@ class MDnsObservatoryDiscovery {
...
@@ -59,7 +57,7 @@ class MDnsObservatoryDiscovery {
/// it will return that instance's information regardless of what application
/// it will return that instance's information regardless of what application
/// the Observatory instance is for.
/// the Observatory instance is for.
@visibleForTesting
@visibleForTesting
Future
<
MDnsObservatoryDiscoveryResult
>
query
({
String
applicationId
,
int
deviceVmservicePort
})
async
{
Future
<
MDnsObservatoryDiscoveryResult
?>
query
({
String
?
applicationId
,
int
?
deviceVmservicePort
})
async
{
_logger
.
printTrace
(
'Checking for advertised Dart observatories...'
);
_logger
.
printTrace
(
'Checking for advertised Dart observatories...'
);
try
{
try
{
await
_client
.
start
();
await
_client
.
start
();
...
@@ -78,7 +76,7 @@ class MDnsObservatoryDiscovery {
...
@@ -78,7 +76,7 @@ class MDnsObservatoryDiscovery {
.
map
<
String
>((
PtrResourceRecord
record
)
=>
record
.
domainName
)
.
map
<
String
>((
PtrResourceRecord
record
)
=>
record
.
domainName
)
.
toSet
();
.
toSet
();
String
domainName
;
String
?
domainName
;
if
(
applicationId
!=
null
)
{
if
(
applicationId
!=
null
)
{
for
(
final
String
name
in
uniqueDomainNames
)
{
for
(
final
String
name
in
uniqueDomainNames
)
{
if
(
name
.
toLowerCase
().
startsWith
(
applicationId
.
toLowerCase
()))
{
if
(
name
.
toLowerCase
().
startsWith
(
applicationId
.
toLowerCase
()))
{
...
@@ -93,7 +91,7 @@ class MDnsObservatoryDiscovery {
...
@@ -93,7 +91,7 @@ class MDnsObservatoryDiscovery {
final
StringBuffer
buffer
=
StringBuffer
();
final
StringBuffer
buffer
=
StringBuffer
();
buffer
.
writeln
(
'There are multiple observatory ports available.'
);
buffer
.
writeln
(
'There are multiple observatory ports available.'
);
buffer
.
writeln
(
'Rerun this command with one of the following passed in as the appId:'
);
buffer
.
writeln
(
'Rerun this command with one of the following passed in as the appId:'
);
buffer
.
writeln
(
''
);
buffer
.
writeln
();
for
(
final
String
uniqueDomainName
in
uniqueDomainNames
)
{
for
(
final
String
uniqueDomainName
in
uniqueDomainNames
)
{
buffer
.
writeln
(
' flutter attach --app-id
${uniqueDomainName.replaceAll('.$dartObservatoryName', '')}
'
);
buffer
.
writeln
(
' flutter attach --app-id
${uniqueDomainName.replaceAll('.$dartObservatoryName', '')}
'
);
}
}
...
@@ -120,15 +118,18 @@ class MDnsObservatoryDiscovery {
...
@@ -120,15 +118,18 @@ class MDnsObservatoryDiscovery {
.
lookup
<
TxtResourceRecord
>(
.
lookup
<
TxtResourceRecord
>(
ResourceRecordQuery
.
text
(
domainName
),
ResourceRecordQuery
.
text
(
domainName
),
)
)
?
.
toList
();
.
toList
();
if
(
txt
==
null
||
txt
.
isEmpty
)
{
if
(
txt
==
null
||
txt
.
isEmpty
)
{
return
MDnsObservatoryDiscoveryResult
(
srv
.
first
.
port
,
''
);
return
MDnsObservatoryDiscoveryResult
(
srv
.
first
.
port
,
''
);
}
}
const
String
authCodePrefix
=
'authCode='
;
const
String
authCodePrefix
=
'authCode='
;
final
String
raw
=
txt
.
first
.
text
.
split
(
'
\n
'
).
firstWhere
(
String
?
raw
;
(
String
s
)
=>
s
.
startsWith
(
authCodePrefix
),
for
(
final
String
record
in
txt
.
first
.
text
.
split
(
'
\n
'
))
{
orElse:
()
=>
null
,
if
(
record
.
startsWith
(
authCodePrefix
))
{
);
raw
=
record
;
break
;
}
}
if
(
raw
==
null
)
{
if
(
raw
==
null
)
{
return
MDnsObservatoryDiscoveryResult
(
srv
.
first
.
port
,
''
);
return
MDnsObservatoryDiscoveryResult
(
srv
.
first
.
port
,
''
);
}
}
...
@@ -144,12 +145,12 @@ class MDnsObservatoryDiscovery {
...
@@ -144,12 +145,12 @@ class MDnsObservatoryDiscovery {
}
}
}
}
Future
<
Uri
>
getObservatoryUri
(
String
applicationId
,
Device
device
,
{
Future
<
Uri
?
>
getObservatoryUri
(
String
applicationId
,
Device
device
,
{
bool
usesIpv6
=
false
,
bool
usesIpv6
=
false
,
int
hostVmservicePort
,
int
?
hostVmservicePort
,
int
deviceVmservicePort
,
int
?
deviceVmservicePort
,
})
async
{
})
async
{
final
MDnsObservatoryDiscoveryResult
result
=
await
query
(
final
MDnsObservatoryDiscoveryResult
?
result
=
await
query
(
applicationId:
applicationId
,
applicationId:
applicationId
,
deviceVmservicePort:
deviceVmservicePort
,
deviceVmservicePort:
deviceVmservicePort
,
);
);
...
@@ -246,8 +247,8 @@ Future<Uri> buildObservatoryUri(
...
@@ -246,8 +247,8 @@ Future<Uri> buildObservatoryUri(
Device
device
,
Device
device
,
String
host
,
String
host
,
int
devicePort
,
[
int
devicePort
,
[
int
hostVmservicePort
,
int
?
hostVmservicePort
,
String
authCode
,
String
?
authCode
,
])
async
{
])
async
{
String
path
=
'/'
;
String
path
=
'/'
;
if
(
authCode
!=
null
)
{
if
(
authCode
!=
null
)
{
...
@@ -259,8 +260,8 @@ Future<Uri> buildObservatoryUri(
...
@@ -259,8 +260,8 @@ Future<Uri> buildObservatoryUri(
path
+=
'/'
;
path
+=
'/'
;
}
}
hostVmservicePort
??=
0
;
hostVmservicePort
??=
0
;
final
int
actualHostPort
=
hostVmservicePort
==
0
?
final
int
?
actualHostPort
=
hostVmservicePort
==
0
?
await
device
.
portForwarder
.
forward
(
devicePort
)
:
await
device
.
portForwarder
?
.
forward
(
devicePort
)
:
hostVmservicePort
;
hostVmservicePort
;
return
Uri
(
scheme:
'http'
,
host:
host
,
port:
actualHostPort
,
path:
path
);
return
Uri
(
scheme:
'http'
,
host:
host
,
port:
actualHostPort
,
path:
path
);
}
}
packages/flutter_tools/lib/src/sksl_writer.dart
View file @
53e04de6
...
@@ -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:file/file.dart'
;
import
'package:file/file.dart'
;
...
@@ -15,9 +13,9 @@ import 'convert.dart';
...
@@ -15,9 +13,9 @@ import 'convert.dart';
import
'device.dart'
;
import
'device.dart'
;
import
'globals_null_migrated.dart'
as
globals
;
import
'globals_null_migrated.dart'
as
globals
;
Future
<
String
>
sharedSkSlWriter
(
Device
device
,
Map
<
String
,
Object
>
data
,
{
Future
<
String
?
>
sharedSkSlWriter
(
Device
device
,
Map
<
String
,
Object
>
data
,
{
File
outputFile
,
File
?
outputFile
,
Logger
logger
,
Logger
?
logger
,
})
async
{
})
async
{
logger
??=
globals
.
logger
;
logger
??=
globals
.
logger
;
if
(
data
.
isEmpty
)
{
if
(
data
.
isEmpty
)
{
...
...
packages/flutter_tools/test/general.shard/ios/simulators_test.dart
View file @
53e04de6
...
@@ -59,7 +59,9 @@ void main() {
...
@@ -59,7 +59,9 @@ void main() {
testUsingContext
(
'dispose() does not throw an exception'
,
()
async
{
testUsingContext
(
'dispose() does not throw an exception'
,
()
async
{
final
IOSSimulator
simulator
=
IOSSimulator
(
final
IOSSimulator
simulator
=
IOSSimulator
(
'123'
,
'123'
,
name:
'iPhone 11'
,
simControl:
simControl
,
simControl:
simControl
,
simulatorCategory:
'com.apple.CoreSimulator.SimRuntime.iOS-14-4'
,
);
);
final
DevicePortForwarder
portForwarder
=
simulator
.
portForwarder
;
final
DevicePortForwarder
portForwarder
=
simulator
.
portForwarder
;
await
portForwarder
.
forward
(
123
);
await
portForwarder
.
forward
(
123
);
...
@@ -82,7 +84,9 @@ void main() {
...
@@ -82,7 +84,9 @@ void main() {
testUsingContext
(
'simulators only support debug mode'
,
()
async
{
testUsingContext
(
'simulators only support debug mode'
,
()
async
{
final
IOSSimulator
simulator
=
IOSSimulator
(
final
IOSSimulator
simulator
=
IOSSimulator
(
'123'
,
'123'
,
name:
'iPhone 11'
,
simControl:
FakeSimControl
(),
simControl:
FakeSimControl
(),
simulatorCategory:
'com.apple.CoreSimulator.SimRuntime.iOS-14-4'
,
);
);
expect
(
simulator
.
supportsRuntimeMode
(
BuildMode
.
debug
),
true
);
expect
(
simulator
.
supportsRuntimeMode
(
BuildMode
.
debug
),
true
);
...
@@ -106,7 +110,9 @@ void main() {
...
@@ -106,7 +110,9 @@ void main() {
osx
.
environment
[
'HOME'
]
=
'/foo/bar'
;
osx
.
environment
[
'HOME'
]
=
'/foo/bar'
;
final
IOSSimulator
simulator
=
IOSSimulator
(
final
IOSSimulator
simulator
=
IOSSimulator
(
'123'
,
'123'
,
name:
'iPhone 11'
,
simControl:
simControl
,
simControl:
simControl
,
simulatorCategory:
'com.apple.CoreSimulator.SimRuntime.iOS-14-4'
,
);
);
expect
(
simulator
.
logFilePath
,
'/foo/bar/Library/Logs/CoreSimulator/123/system.log'
);
expect
(
simulator
.
logFilePath
,
'/foo/bar/Library/Logs/CoreSimulator/123/system.log'
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
...
@@ -121,7 +127,9 @@ void main() {
...
@@ -121,7 +127,9 @@ void main() {
osx
.
environment
[
'IOS_SIMULATOR_LOG_FILE_PATH'
]
=
'/baz/qux/%{id}/system.log'
;
osx
.
environment
[
'IOS_SIMULATOR_LOG_FILE_PATH'
]
=
'/baz/qux/%{id}/system.log'
;
final
IOSSimulator
simulator
=
IOSSimulator
(
final
IOSSimulator
simulator
=
IOSSimulator
(
'456'
,
'456'
,
name:
'iPhone 11'
,
simControl:
simControl
,
simControl:
simControl
,
simulatorCategory:
'com.apple.CoreSimulator.SimRuntime.iOS-14-4'
,
);
);
expect
(
simulator
.
logFilePath
,
'/baz/qux/456/system.log'
);
expect
(
simulator
.
logFilePath
,
'/baz/qux/456/system.log'
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
...
@@ -154,33 +162,6 @@ void main() {
...
@@ -154,33 +162,6 @@ void main() {
});
});
});
});
group
(
'compareIphoneVersions'
,
()
{
testWithoutContext
(
'compares correctly'
,
()
{
// This list must be sorted in ascending preference order
final
List
<
String
>
testList
=
<
String
>[
'com.apple.CoreSimulator.SimDeviceType.iPhone-4s'
,
'com.apple.CoreSimulator.SimDeviceType.iPhone-5'
,
'com.apple.CoreSimulator.SimDeviceType.iPhone-5s'
,
'com.apple.CoreSimulator.SimDeviceType.iPhone-6strange'
,
'com.apple.CoreSimulator.SimDeviceType.iPhone-6-Plus'
,
'com.apple.CoreSimulator.SimDeviceType.iPhone-6'
,
'com.apple.CoreSimulator.SimDeviceType.iPhone-6s-Plus'
,
'com.apple.CoreSimulator.SimDeviceType.iPhone-6s'
,
];
for
(
int
i
=
0
;
i
<
testList
.
length
;
i
++)
{
expect
(
compareIphoneVersions
(
testList
[
i
],
testList
[
i
]),
0
);
}
for
(
int
i
=
0
;
i
<
testList
.
length
-
1
;
i
++)
{
for
(
int
j
=
i
+
1
;
j
<
testList
.
length
;
j
++)
{
expect
(
compareIphoneVersions
(
testList
[
i
],
testList
[
j
]),
lessThan
(
0
));
expect
(
compareIphoneVersions
(
testList
[
j
],
testList
[
i
]),
greaterThan
(
0
));
}
}
});
});
group
(
'sdkMajorVersion'
,
()
{
group
(
'sdkMajorVersion'
,
()
{
FakeSimControl
simControl
;
FakeSimControl
simControl
;
...
@@ -235,6 +216,7 @@ void main() {
...
@@ -235,6 +216,7 @@ void main() {
'x'
,
'x'
,
name:
'Apple TV'
,
name:
'Apple TV'
,
simControl:
simControl
,
simControl:
simControl
,
simulatorCategory:
'com.apple.CoreSimulator.SimRuntime.tvOS-14-5'
,
);
);
expect
(
simulator
.
isSupported
(),
false
);
expect
(
simulator
.
isSupported
(),
false
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
...
@@ -248,6 +230,7 @@ void main() {
...
@@ -248,6 +230,7 @@ void main() {
'x'
,
'x'
,
name:
'Apple Watch'
,
name:
'Apple Watch'
,
simControl:
simControl
,
simControl:
simControl
,
simulatorCategory:
'com.apple.CoreSimulator.SimRuntime.watchOS-8-0'
,
).
isSupported
(),
false
);
).
isSupported
(),
false
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
osx
,
Platform:
()
=>
osx
,
...
@@ -260,6 +243,7 @@ void main() {
...
@@ -260,6 +243,7 @@ void main() {
'x'
,
'x'
,
name:
'iPad 2'
,
name:
'iPad 2'
,
simControl:
simControl
,
simControl:
simControl
,
simulatorCategory:
'com.apple.CoreSimulator.SimRuntime.iOS-11-3'
,
).
isSupported
(),
true
);
).
isSupported
(),
true
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
osx
,
Platform:
()
=>
osx
,
...
@@ -272,6 +256,7 @@ void main() {
...
@@ -272,6 +256,7 @@ void main() {
'x'
,
'x'
,
name:
'iPad Retina'
,
name:
'iPad Retina'
,
simControl:
simControl
,
simControl:
simControl
,
simulatorCategory:
'com.apple.CoreSimulator.SimRuntime.iOS-11-3'
,
).
isSupported
(),
true
);
).
isSupported
(),
true
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
osx
,
Platform:
()
=>
osx
,
...
@@ -284,6 +269,7 @@ void main() {
...
@@ -284,6 +269,7 @@ void main() {
'x'
,
'x'
,
name:
'iPhone 5'
,
name:
'iPhone 5'
,
simControl:
simControl
,
simControl:
simControl
,
simulatorCategory:
'com.apple.CoreSimulator.SimRuntime.iOS-11-3'
,
).
isSupported
(),
true
);
).
isSupported
(),
true
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
osx
,
Platform:
()
=>
osx
,
...
@@ -296,6 +282,7 @@ void main() {
...
@@ -296,6 +282,7 @@ void main() {
'x'
,
'x'
,
name:
'iPhone 5s'
,
name:
'iPhone 5s'
,
simControl:
simControl
,
simControl:
simControl
,
simulatorCategory:
'com.apple.CoreSimulator.SimRuntime.iOS-11-3'
,
).
isSupported
(),
true
);
).
isSupported
(),
true
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
osx
,
Platform:
()
=>
osx
,
...
@@ -308,6 +295,7 @@ void main() {
...
@@ -308,6 +295,7 @@ void main() {
'x'
,
'x'
,
name:
'iPhone SE'
,
name:
'iPhone SE'
,
simControl:
simControl
,
simControl:
simControl
,
simulatorCategory:
'com.apple.CoreSimulator.SimRuntime.iOS-11-3'
,
).
isSupported
(),
true
);
).
isSupported
(),
true
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
osx
,
Platform:
()
=>
osx
,
...
@@ -320,6 +308,7 @@ void main() {
...
@@ -320,6 +308,7 @@ void main() {
'x'
,
'x'
,
name:
'iPhone 7 Plus'
,
name:
'iPhone 7 Plus'
,
simControl:
simControl
,
simControl:
simControl
,
simulatorCategory:
'com.apple.CoreSimulator.SimRuntime.iOS-11-3'
,
).
isSupported
(),
true
);
).
isSupported
(),
true
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
osx
,
Platform:
()
=>
osx
,
...
@@ -332,6 +321,7 @@ void main() {
...
@@ -332,6 +321,7 @@ void main() {
'x'
,
'x'
,
name:
'iPhone X'
,
name:
'iPhone X'
,
simControl:
simControl
,
simControl:
simControl
,
simulatorCategory:
'com.apple.CoreSimulator.SimRuntime.iOS-11-3'
,
).
isSupported
(),
true
);
).
isSupported
(),
true
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
osx
,
Platform:
()
=>
osx
,
...
@@ -368,6 +358,7 @@ void main() {
...
@@ -368,6 +358,7 @@ void main() {
'x'
,
'x'
,
name:
'iPhone SE'
,
name:
'iPhone SE'
,
simControl:
simControl
,
simControl:
simControl
,
simulatorCategory:
'com.apple.CoreSimulator.SimRuntime.iOS-11-3'
,
);
);
final
File
screenshot
=
MemoryFileSystem
.
test
().
file
(
'screenshot.png'
);
final
File
screenshot
=
MemoryFileSystem
.
test
().
file
(
'screenshot.png'
);
...
@@ -513,6 +504,7 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
...
@@ -513,6 +504,7 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
final
IOSSimulator
device
=
IOSSimulator
(
final
IOSSimulator
device
=
IOSSimulator
(
'123456'
,
'123456'
,
name:
'iPhone 11'
,
simulatorCategory:
'iOS 10.0'
,
simulatorCategory:
'iOS 10.0'
,
simControl:
simControl
,
simControl:
simControl
,
);
);
...
@@ -547,6 +539,7 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
...
@@ -547,6 +539,7 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
final
IOSSimulator
device
=
IOSSimulator
(
final
IOSSimulator
device
=
IOSSimulator
(
'123456'
,
'123456'
,
name:
'iPhone 11'
,
simulatorCategory:
'iOS 10.3'
,
simulatorCategory:
'iOS 10.3'
,
simControl:
simControl
,
simControl:
simControl
,
);
);
...
@@ -594,6 +587,7 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
...
@@ -594,6 +587,7 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
final
IOSSimulator
device
=
IOSSimulator
(
final
IOSSimulator
device
=
IOSSimulator
(
'123456'
,
'123456'
,
name:
'iPhone 11'
,
simulatorCategory:
'iOS 10.3'
,
simulatorCategory:
'iOS 10.3'
,
simControl:
simControl
,
simControl:
simControl
,
);
);
...
@@ -665,6 +659,7 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
...
@@ -665,6 +659,7 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
final
IOSSimulator
device
=
IOSSimulator
(
final
IOSSimulator
device
=
IOSSimulator
(
'123456'
,
'123456'
,
name:
'iPhone 11'
,
simulatorCategory:
'iOS 11.0'
,
simulatorCategory:
'iOS 11.0'
,
simControl:
simControl
,
simControl:
simControl
,
);
);
...
@@ -707,6 +702,7 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
...
@@ -707,6 +702,7 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
final
IOSSimulator
device
=
IOSSimulator
(
final
IOSSimulator
device
=
IOSSimulator
(
'123456'
,
'123456'
,
name:
'iPhone 11'
,
simulatorCategory:
'iOS 11.0'
,
simulatorCategory:
'iOS 11.0'
,
simControl:
simControl
,
simControl:
simControl
,
);
);
...
@@ -902,11 +898,13 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
...
@@ -902,11 +898,13 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
FakePlistParser
testPlistParser
;
FakePlistParser
testPlistParser
;
FakeSimControl
simControl
;
FakeSimControl
simControl
;
Xcode
xcode
;
Xcode
xcode
;
BufferLogger
logger
;
setUp
(()
{
setUp
(()
{
simControl
=
FakeSimControl
();
simControl
=
FakeSimControl
();
xcode
=
Xcode
.
test
(
processManager:
FakeProcessManager
.
any
());
xcode
=
Xcode
.
test
(
processManager:
FakeProcessManager
.
any
());
testPlistParser
=
FakePlistParser
();
testPlistParser
=
FakePlistParser
();
logger
=
BufferLogger
.
test
();
});
});
testUsingContext
(
"startApp uses compiled app's Info.plist to find CFBundleIdentifier"
,
()
async
{
testUsingContext
(
"startApp uses compiled app's Info.plist to find CFBundleIdentifier"
,
()
async
{
...
@@ -933,7 +931,7 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
...
@@ -933,7 +931,7 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
Xcode:
()
=>
xcode
,
Xcode:
()
=>
xcode
,
});
});
testUsingContext
(
'startApp
respects the enable software rendering flag
'
,
()
async
{
testUsingContext
(
'startApp
fails when cannot find CFBundleIdentifier
'
,
()
async
{
final
IOSSimulator
device
=
IOSSimulator
(
final
IOSSimulator
device
=
IOSSimulator
(
'x'
,
'x'
,
name:
'iPhone SE'
,
name:
'iPhone SE'
,
...
@@ -944,6 +942,33 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
...
@@ -944,6 +942,33 @@ Dec 20 17:04:32 md32-11-vm1 Another App[88374]: Ignore this text'''
final
Directory
mockDir
=
globals
.
fs
.
currentDirectory
;
final
Directory
mockDir
=
globals
.
fs
.
currentDirectory
;
final
IOSApp
package
=
PrebuiltIOSApp
(
projectBundleId:
'incorrect'
,
bundleName:
'name'
,
bundleDir:
mockDir
);
final
IOSApp
package
=
PrebuiltIOSApp
(
projectBundleId:
'incorrect'
,
bundleName:
'name'
,
bundleDir:
mockDir
);
const
BuildInfo
mockInfo
=
BuildInfo
(
BuildMode
.
debug
,
'flavor'
,
treeShakeIcons:
false
);
final
DebuggingOptions
mockOptions
=
DebuggingOptions
.
disabled
(
mockInfo
);
final
LaunchResult
result
=
await
device
.
startApp
(
package
,
prebuiltApplication:
true
,
debuggingOptions:
mockOptions
);
expect
(
result
.
started
,
isFalse
);
expect
(
simControl
.
requests
,
isEmpty
);
expect
(
logger
.
errorText
,
contains
(
'Invalid prebuilt iOS app. Info.plist does not contain bundle identifier'
));
},
overrides:
<
Type
,
Generator
>{
PlistParser:
()
=>
testPlistParser
,
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
Logger:
()
=>
logger
,
Xcode:
()
=>
xcode
,
});
testUsingContext
(
'startApp respects the enable software rendering flag'
,
()
async
{
final
IOSSimulator
device
=
IOSSimulator
(
'x'
,
name:
'iPhone SE'
,
simulatorCategory:
'iOS 11.2'
,
simControl:
simControl
,
);
testPlistParser
.
setProperty
(
'CFBundleIdentifier'
,
'correct'
);
final
Directory
mockDir
=
globals
.
fs
.
currentDirectory
;
final
IOSApp
package
=
PrebuiltIOSApp
(
projectBundleId:
'correct'
,
bundleName:
'name'
,
bundleDir:
mockDir
);
const
BuildInfo
mockInfo
=
BuildInfo
(
BuildMode
.
debug
,
'flavor'
,
treeShakeIcons:
false
);
const
BuildInfo
mockInfo
=
BuildInfo
(
BuildMode
.
debug
,
'flavor'
,
treeShakeIcons:
false
);
final
DebuggingOptions
mockOptions
=
DebuggingOptions
.
enabled
(
mockInfo
,
enableSoftwareRendering:
true
);
final
DebuggingOptions
mockOptions
=
DebuggingOptions
.
enabled
(
mockInfo
,
enableSoftwareRendering:
true
);
await
device
.
startApp
(
package
,
prebuiltApplication:
true
,
debuggingOptions:
mockOptions
);
await
device
.
startApp
(
package
,
prebuiltApplication:
true
,
debuggingOptions:
mockOptions
);
...
@@ -980,7 +1005,9 @@ flutter:
...
@@ -980,7 +1005,9 @@ flutter:
final
IOSSimulator
simulator
=
IOSSimulator
(
final
IOSSimulator
simulator
=
IOSSimulator
(
'test'
,
'test'
,
name:
'iPhone 11'
,
simControl:
simControl
,
simControl:
simControl
,
simulatorCategory:
'com.apple.CoreSimulator.SimRuntime.iOS-11-3'
,
);
);
expect
(
simulator
.
isSupportedForProject
(
flutterProject
),
true
);
expect
(
simulator
.
isSupportedForProject
(
flutterProject
),
true
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
...
@@ -998,7 +1025,9 @@ flutter:
...
@@ -998,7 +1025,9 @@ flutter:
final
IOSSimulator
simulator
=
IOSSimulator
(
final
IOSSimulator
simulator
=
IOSSimulator
(
'test'
,
'test'
,
name:
'iPhone 11'
,
simControl:
simControl
,
simControl:
simControl
,
simulatorCategory:
'com.apple.CoreSimulator.SimRuntime.iOS-11-3'
,
);
);
expect
(
simulator
.
isSupportedForProject
(
flutterProject
),
true
);
expect
(
simulator
.
isSupportedForProject
(
flutterProject
),
true
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
...
@@ -1014,7 +1043,9 @@ flutter:
...
@@ -1014,7 +1043,9 @@ flutter:
final
IOSSimulator
simulator
=
IOSSimulator
(
final
IOSSimulator
simulator
=
IOSSimulator
(
'test'
,
'test'
,
name:
'iPhone 11'
,
simControl:
simControl
,
simControl:
simControl
,
simulatorCategory:
'com.apple.CoreSimulator.SimRuntime.iOS-11-3'
,
);
);
expect
(
simulator
.
isSupportedForProject
(
flutterProject
),
false
);
expect
(
simulator
.
isSupportedForProject
(
flutterProject
),
false
);
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
...
@@ -1026,7 +1057,9 @@ flutter:
...
@@ -1026,7 +1057,9 @@ flutter:
testUsingContext
(
'createDevFSWriter returns a LocalDevFSWriter'
,
()
{
testUsingContext
(
'createDevFSWriter returns a LocalDevFSWriter'
,
()
{
final
IOSSimulator
simulator
=
IOSSimulator
(
final
IOSSimulator
simulator
=
IOSSimulator
(
'test'
,
'test'
,
name:
'iPhone 11'
,
simControl:
simControl
,
simControl:
simControl
,
simulatorCategory:
'com.apple.CoreSimulator.SimRuntime.iOS-11-3'
,
);
);
expect
(
simulator
.
createDevFSWriter
(
null
,
''
),
isA
<
LocalDevFSWriter
>());
expect
(
simulator
.
createDevFSWriter
(
null
,
''
),
isA
<
LocalDevFSWriter
>());
...
...
packages/flutter_tools/test/general.shard/mdns_discovery_test.dart
View file @
53e04de6
...
@@ -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
'package:flutter_tools/src/base/io.dart'
;
import
'package:flutter_tools/src/base/io.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/build_info.dart'
;
import
'package:flutter_tools/src/build_info.dart'
;
...
@@ -24,9 +22,9 @@ void main() {
...
@@ -24,9 +22,9 @@ void main() {
setUp
(()
{
setUp
(()
{
setNetworkInterfaceLister
(
setNetworkInterfaceLister
(
({
({
bool
includeLoopback
,
bool
?
includeLoopback
,
bool
includeLinkLocal
,
bool
?
includeLinkLocal
,
InternetAddressType
type
,
InternetAddressType
?
type
,
})
async
=>
<
NetworkInterface
>[],
})
async
=>
<
NetworkInterface
>[],
);
);
});
});
...
@@ -44,7 +42,7 @@ void main() {
...
@@ -44,7 +42,7 @@ void main() {
logger:
BufferLogger
.
test
(),
logger:
BufferLogger
.
test
(),
flutterUsage:
TestUsage
(),
flutterUsage:
TestUsage
(),
);
);
final
int
port
=
(
await
portDiscovery
.
query
())?.
port
;
final
int
?
port
=
(
await
portDiscovery
.
query
())?.
port
;
expect
(
port
,
isNull
);
expect
(
port
,
isNull
);
});
});
...
@@ -56,7 +54,7 @@ void main() {
...
@@ -56,7 +54,7 @@ void main() {
logger:
logger
,
logger:
logger
,
flutterUsage:
TestUsage
(),
flutterUsage:
TestUsage
(),
);
);
final
Uri
uri
=
await
portDiscovery
.
getObservatoryUri
(
final
Uri
?
uri
=
await
portDiscovery
.
getObservatoryUri
(
''
,
''
,
FakeIOSDevice
(),
FakeIOSDevice
(),
);
);
...
@@ -81,7 +79,7 @@ void main() {
...
@@ -81,7 +79,7 @@ void main() {
logger:
BufferLogger
.
test
(),
logger:
BufferLogger
.
test
(),
flutterUsage:
TestUsage
(),
flutterUsage:
TestUsage
(),
);
);
final
int
port
=
(
await
portDiscovery
.
query
())?.
port
;
final
int
?
port
=
(
await
portDiscovery
.
query
())?.
port
;
expect
(
port
,
123
);
expect
(
port
,
123
);
});
});
...
@@ -107,7 +105,7 @@ void main() {
...
@@ -107,7 +105,7 @@ void main() {
logger:
BufferLogger
.
test
(),
logger:
BufferLogger
.
test
(),
flutterUsage:
TestUsage
(),
flutterUsage:
TestUsage
(),
);
);
final
MDnsObservatoryDiscoveryResult
result
=
await
portDiscovery
.
query
();
final
MDnsObservatoryDiscoveryResult
?
result
=
await
portDiscovery
.
query
();
expect
(
result
?.
port
,
123
);
expect
(
result
?.
port
,
123
);
expect
(
result
?.
authCode
,
'xyz/'
);
expect
(
result
?.
authCode
,
'xyz/'
);
});
});
...
@@ -157,7 +155,7 @@ void main() {
...
@@ -157,7 +155,7 @@ void main() {
logger:
BufferLogger
.
test
(),
logger:
BufferLogger
.
test
(),
flutterUsage:
TestUsage
(),
flutterUsage:
TestUsage
(),
);
);
final
int
port
=
(
await
portDiscovery
.
query
(
applicationId:
'fiz'
))?.
port
;
final
int
?
port
=
(
await
portDiscovery
.
query
(
applicationId:
'fiz'
))?.
port
;
expect
(
port
,
321
);
expect
(
port
,
321
);
});
});
...
@@ -184,7 +182,7 @@ void main() {
...
@@ -184,7 +182,7 @@ void main() {
logger:
BufferLogger
.
test
(),
logger:
BufferLogger
.
test
(),
flutterUsage:
TestUsage
(),
flutterUsage:
TestUsage
(),
);
);
final
int
port
=
(
await
portDiscovery
.
query
(
applicationId:
'bar'
))?.
port
;
final
int
?
port
=
(
await
portDiscovery
.
query
(
applicationId:
'bar'
))?.
port
;
expect
(
port
,
1234
);
expect
(
port
,
1234
);
});
});
...
@@ -199,7 +197,7 @@ void main() {
...
@@ -199,7 +197,7 @@ void main() {
logger:
BufferLogger
.
test
(),
logger:
BufferLogger
.
test
(),
flutterUsage:
TestUsage
(),
flutterUsage:
TestUsage
(),
);
);
final
int
port
=
(
await
portDiscovery
.
query
(
applicationId:
'bar'
))?.
port
;
final
int
?
port
=
(
await
portDiscovery
.
query
(
applicationId:
'bar'
))?.
port
;
expect
(
port
,
isNull
);
expect
(
port
,
isNull
);
});
});
...
@@ -236,7 +234,7 @@ void main() {
...
@@ -236,7 +234,7 @@ void main() {
logger:
BufferLogger
.
test
(),
logger:
BufferLogger
.
test
(),
flutterUsage:
TestUsage
(),
flutterUsage:
TestUsage
(),
);
);
final
Uri
uri
=
await
portDiscovery
.
getObservatoryUri
(
'bar'
,
device
,
hostVmservicePort:
0
);
final
Uri
?
uri
=
await
portDiscovery
.
getObservatoryUri
(
'bar'
,
device
,
hostVmservicePort:
0
);
expect
(
uri
.
toString
(),
'http://127.0.0.1:123/'
);
expect
(
uri
.
toString
(),
'http://127.0.0.1:123/'
);
});
});
});
});
...
@@ -255,10 +253,10 @@ class FakeMDnsClient extends Fake implements MDnsClient {
...
@@ -255,10 +253,10 @@ class FakeMDnsClient extends Fake implements MDnsClient {
@override
@override
Future
<
void
>
start
({
Future
<
void
>
start
({
InternetAddress
listenAddress
,
InternetAddress
?
listenAddress
,
NetworkInterfacesFactory
interfacesFactory
,
NetworkInterfacesFactory
?
interfacesFactory
,
int
mDnsPort
=
5353
,
int
mDnsPort
=
5353
,
InternetAddress
mDnsAddress
,
InternetAddress
?
mDnsAddress
,
})
async
{
})
async
{
if
(
osErrorOnStart
)
{
if
(
osErrorOnStart
)
{
throw
const
OSError
(
'Operation not supported on socket'
,
102
);
throw
const
OSError
(
'Operation not supported on socket'
,
102
);
...
...
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