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
9bd2e400
Unverified
Commit
9bd2e400
authored
Jul 19, 2019
by
Christopher Fujino
Committed by
GitHub
Jul 19, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Throw exception if instantiating IOSDevice on non-mac os platform (#36288)
parent
a52f0f77
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
133 additions
and
85 deletions
+133
-85
devices.dart
packages/flutter_tools/lib/src/ios/devices.dart
+5
-4
devices_test.dart
...es/flutter_tools/test/general.shard/ios/devices_test.dart
+128
-81
No files found.
packages/flutter_tools/lib/src/ios/devices.dart
View file @
9bd2e400
...
...
@@ -125,14 +125,12 @@ class IOSDevice extends Device {
ephemeral:
true
,
)
{
if
(!
platform
.
isMacOS
)
{
printError
(
'Cannot control iOS devices or simulators. ideviceinstaller and iproxy are not available on your platform.'
);
_installerPath
=
null
;
_iproxyPath
=
null
;
assert
(
false
,
'Control of iOS devices or simulators only supported on Mac OS.'
);
return
;
}
_installerPath
=
artifacts
.
getArtifactPath
(
Artifact
.
ideviceinstaller
,
platform:
TargetPlatform
.
ios
platform:
TargetPlatform
.
ios
,
)
??
'ideviceinstaller'
;
// TODO(fujino): remove fallback once g3 updated
_iproxyPath
=
artifacts
.
getArtifactPath
(
Artifact
.
iproxy
,
...
...
@@ -168,6 +166,9 @@ class IOSDevice extends Device {
bool
get
supportsStartPaused
=>
false
;
static
Future
<
List
<
IOSDevice
>>
getAttachedDevices
()
async
{
if
(!
platform
.
isMacOS
)
{
throw
UnsupportedError
(
'Control of iOS devices or simulators only supported on Mac OS.'
);
}
if
(!
iMobileDevice
.
isInstalled
)
return
<
IOSDevice
>[];
...
...
packages/flutter_tools/test/general.shard/ios/devices_test.dart
View file @
9bd2e400
...
...
@@ -38,6 +38,30 @@ class MockProcess extends Mock implements Process {}
void
main
(
)
{
final
FakePlatform
macPlatform
=
FakePlatform
.
fromPlatform
(
const
LocalPlatform
());
macPlatform
.
operatingSystem
=
'macos'
;
final
FakePlatform
linuxPlatform
=
FakePlatform
.
fromPlatform
(
const
LocalPlatform
());
linuxPlatform
.
operatingSystem
=
'linux'
;
final
FakePlatform
windowsPlatform
=
FakePlatform
.
fromPlatform
(
const
LocalPlatform
());
windowsPlatform
.
operatingSystem
=
'windows'
;
group
(
'IOSDevice'
,
()
{
final
List
<
Platform
>
unsupportedPlatforms
=
<
Platform
>[
linuxPlatform
,
windowsPlatform
];
testUsingContext
(
'successfully instantiates on Mac OS'
,
()
{
IOSDevice
(
'device-123'
);
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
macPlatform
,
});
for
(
Platform
platform
in
unsupportedPlatforms
)
{
testUsingContext
(
'throws UnsupportedError exception if instantiated on
${platform.operatingSystem}
'
,
()
{
expect
(
()
{
IOSDevice
(
'device-123'
);
},
throwsA
(
isInstanceOf
<
AssertionError
>())
);
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
platform
,
});
}
group
(
'Process calls'
,
()
{
MockIOSApp
mockApp
;
...
...
@@ -126,6 +150,7 @@ void main() {
ProcessManager:
()
=>
mockProcessManager
,
});
});
});
group
(
'getAttachedDevices'
,
()
{
MockIMobileDevice
mockIMobileDevice
;
...
...
@@ -139,6 +164,7 @@ void main() {
expect
(
await
IOSDevice
.
getAttachedDevices
(),
isEmpty
);
},
overrides:
<
Type
,
Generator
>{
IMobileDevice:
()
=>
mockIMobileDevice
,
Platform:
()
=>
macPlatform
,
});
testUsingContext
(
'returns no devices if none are attached'
,
()
async
{
...
...
@@ -149,8 +175,25 @@ void main() {
expect
(
devices
,
isEmpty
);
},
overrides:
<
Type
,
Generator
>{
IMobileDevice:
()
=>
mockIMobileDevice
,
Platform:
()
=>
macPlatform
,
});
final
List
<
Platform
>
unsupportedPlatforms
=
<
Platform
>[
linuxPlatform
,
windowsPlatform
];
for
(
Platform
platform
in
unsupportedPlatforms
)
{
testUsingContext
(
'throws Unsupported Operation exception on
${platform.operatingSystem}
'
,
()
async
{
when
(
iMobileDevice
.
isInstalled
).
thenReturn
(
false
);
when
(
iMobileDevice
.
getAvailableDeviceIDs
())
.
thenAnswer
((
Invocation
invocation
)
=>
Future
<
String
>.
value
(
''
));
expect
(
()
async
{
await
IOSDevice
.
getAttachedDevices
();
},
throwsA
(
isInstanceOf
<
UnsupportedError
>()),
);
},
overrides:
<
Type
,
Generator
>{
IMobileDevice:
()
=>
mockIMobileDevice
,
Platform:
()
=>
platform
,
});
}
testUsingContext
(
'returns attached devices'
,
()
async
{
when
(
iMobileDevice
.
isInstalled
).
thenReturn
(
true
);
when
(
iMobileDevice
.
getAvailableDeviceIDs
())
...
...
@@ -174,6 +217,7 @@ f577a7903cc54959be2e34bc4f7f80b7009efcf4
expect
(
devices
[
1
].
name
,
'Puits sans fond'
);
},
overrides:
<
Type
,
Generator
>{
IMobileDevice:
()
=>
mockIMobileDevice
,
Platform:
()
=>
macPlatform
,
});
testUsingContext
(
'returns attached devices and ignores devices that cannot be found by ideviceinfo'
,
()
async
{
...
...
@@ -193,6 +237,7 @@ f577a7903cc54959be2e34bc4f7f80b7009efcf4
expect
(
devices
[
0
].
name
,
'La tele me regarde'
);
},
overrides:
<
Type
,
Generator
>{
IMobileDevice:
()
=>
mockIMobileDevice
,
Platform:
()
=>
macPlatform
,
});
});
...
...
@@ -244,8 +289,8 @@ f577a7903cc54959be2e34bc4f7f80b7009efcf4
expect
(
lines
,
<
String
>[
'A is for ari'
,
'I is for ichigo'
]);
},
overrides:
<
Type
,
Generator
>{
IMobileDevice:
()
=>
mockIMobileDevice
,
Platform:
()
=>
macPlatform
,
});
testUsingContext
(
'includes multi-line Flutter logs in the output'
,
()
async
{
when
(
mockIMobileDevice
.
startLogger
(
'123456'
)).
thenAnswer
((
Invocation
invocation
)
{
final
Process
mockProcess
=
MockProcess
();
...
...
@@ -280,9 +325,9 @@ f577a7903cc54959be2e34bc4f7f80b7009efcf4
expect
(
device
.
category
,
Category
.
mobile
);
},
overrides:
<
Type
,
Generator
>{
IMobileDevice:
()
=>
mockIMobileDevice
,
Platform:
()
=>
macPlatform
,
});
});
testUsingContext
(
'IOSDevice.isSupportedForProject is true on module project'
,
()
async
{
fs
.
file
(
'pubspec.yaml'
)
..
createSync
()
...
...
@@ -298,8 +343,8 @@ flutter:
expect
(
IOSDevice
(
'test'
).
isSupportedForProject
(
flutterProject
),
true
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
MemoryFileSystem
(),
Platform:
()
=>
macPlatform
,
});
testUsingContext
(
'IOSDevice.isSupportedForProject is true with editable host app'
,
()
async
{
fs
.
file
(
'pubspec.yaml'
).
createSync
();
fs
.
file
(
'.packages'
).
createSync
();
...
...
@@ -309,6 +354,7 @@ flutter:
expect
(
IOSDevice
(
'test'
).
isSupportedForProject
(
flutterProject
),
true
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
MemoryFileSystem
(),
Platform:
()
=>
macPlatform
,
});
testUsingContext
(
'IOSDevice.isSupportedForProject is false with no host app and no module'
,
()
async
{
...
...
@@ -319,5 +365,6 @@ flutter:
expect
(
IOSDevice
(
'test'
).
isSupportedForProject
(
flutterProject
),
false
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
MemoryFileSystem
(),
Platform:
()
=>
macPlatform
,
});
}
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