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
af5d4c68
Commit
af5d4c68
authored
Jul 01, 2018
by
Mark Fielbig
Committed by
Devon Carew
Jul 01, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix type errors in iOS simulator discovery. (#18960)
parent
7f7ea2d5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
85 additions
and
8 deletions
+85
-8
simulators.dart
packages/flutter_tools/lib/src/ios/simulators.dart
+9
-8
simulators_test.dart
packages/flutter_tools/test/ios/simulators_test.dart
+76
-0
No files found.
packages/flutter_tools/lib/src/ios/simulators.dart
View file @
af5d4c68
...
...
@@ -58,10 +58,7 @@ class SimControl {
/// Runs `simctl list --json` and returns the JSON of the corresponding
/// [section].
///
/// The return type depends on the [section] being listed but is usually
/// either a [Map] or a [List].
dynamic
_list
(
SimControlListSection
section
)
{
Map
<
String
,
dynamic
>
_list
(
SimControlListSection
section
)
{
// Sample output from `simctl list --json`:
//
// {
...
...
@@ -97,9 +94,8 @@ class SimControl {
final
Map
<
String
,
dynamic
>
devicesSection
=
_list
(
SimControlListSection
.
devices
);
for
(
String
deviceCategory
in
devicesSection
.
keys
)
{
final
List
<
Map
<
String
,
String
>>
devicesData
=
devicesSection
[
deviceCategory
];
for
(
Map
<
String
,
String
>
data
in
devicesData
)
{
final
List
<
dynamic
>
devicesData
=
devicesSection
[
deviceCategory
];
for
(
Map
<
String
,
dynamic
>
data
in
devicesData
.
map
(
_castStringKeyedMap
))
{
devices
.
add
(
new
SimDevice
(
deviceCategory
,
data
));
}
}
...
...
@@ -107,6 +103,11 @@ class SimControl {
return
devices
;
}
Map
<
String
,
dynamic
>
_castStringKeyedMap
(
dynamic
untyped
)
{
final
Map
<
dynamic
,
dynamic
>
map
=
untyped
;
return
map
.
cast
<
String
,
dynamic
>();
}
/// Returns all the connected simulator devices.
List
<
SimDevice
>
getConnectedDevices
()
{
return
getDevices
().
where
((
SimDevice
device
)
=>
device
.
isBooted
).
toList
();
...
...
@@ -182,7 +183,7 @@ class SimDevice {
SimDevice
(
this
.
category
,
this
.
data
);
final
String
category
;
final
Map
<
String
,
String
>
data
;
final
Map
<
String
,
dynamic
>
data
;
String
get
state
=>
data
[
'state'
];
String
get
availability
=>
data
[
'availability'
];
...
...
packages/flutter_tools/test/ios/simulators_test.dart
View file @
af5d4c68
...
...
@@ -329,4 +329,80 @@ void main() {
ProcessManager:
()
=>
mockProcessManager
,
});
});
group
(
'SimControl'
,
()
{
const
int
mockPid
=
123
;
const
String
validSimControlOutput
=
'''
{
"devices" : {
"watchOS 4.3" : [
{
"state" : "Shutdown",
"availability" : "(available)",
"name" : "Apple Watch - 38mm",
"udid" : "TEST-WATCH-UDID"
}
],
"iOS 11.4" : [
{
"state" : "Booted",
"availability" : "(available)",
"name" : "iPhone 5s",
"udid" : "TEST-PHONE-UDID"
}
],
"tvOS 11.4" : [
{
"state" : "Shutdown",
"availability" : "(available)",
"name" : "Apple TV",
"udid" : "TEST-TV-UDID"
}
]
}
}
'''
;
MockProcessManager
mockProcessManager
;
SimControl
simControl
;
setUp
(()
{
mockProcessManager
=
new
MockProcessManager
();
when
(
mockProcessManager
.
runSync
(
any
))
.
thenReturn
(
new
ProcessResult
(
mockPid
,
0
,
validSimControlOutput
,
''
));
simControl
=
new
SimControl
();
});
testUsingContext
(
'getDevices succeeds'
,
()
{
final
List
<
SimDevice
>
devices
=
simControl
.
getDevices
();
final
SimDevice
watch
=
devices
[
0
];
expect
(
watch
.
category
,
'watchOS 4.3'
);
expect
(
watch
.
state
,
'Shutdown'
);
expect
(
watch
.
availability
,
'(available)'
);
expect
(
watch
.
name
,
'Apple Watch - 38mm'
);
expect
(
watch
.
udid
,
'TEST-WATCH-UDID'
);
expect
(
watch
.
isBooted
,
isFalse
);
final
SimDevice
phone
=
devices
[
1
];
expect
(
phone
.
category
,
'iOS 11.4'
);
expect
(
phone
.
state
,
'Booted'
);
expect
(
phone
.
availability
,
'(available)'
);
expect
(
phone
.
name
,
'iPhone 5s'
);
expect
(
phone
.
udid
,
'TEST-PHONE-UDID'
);
expect
(
phone
.
isBooted
,
isTrue
);
final
SimDevice
tv
=
devices
[
2
];
expect
(
tv
.
category
,
'tvOS 11.4'
);
expect
(
tv
.
state
,
'Shutdown'
);
expect
(
tv
.
availability
,
'(available)'
);
expect
(
tv
.
name
,
'Apple TV'
);
expect
(
tv
.
udid
,
'TEST-TV-UDID'
);
expect
(
tv
.
isBooted
,
isFalse
);
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mockProcessManager
,
SimControl:
()
=>
simControl
,
});
});
}
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