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
d85ea513
Unverified
Commit
d85ea513
authored
Jan 29, 2020
by
Jenn Magder
Committed by
GitHub
Jan 29, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move iMobileDevice to globals (#49724)
parent
a52de68b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
35 deletions
+34
-35
globals.dart
packages/flutter_tools/lib/src/globals.dart
+2
-0
devices.dart
packages/flutter_tools/lib/src/ios/devices.dart
+8
-8
mac.dart
packages/flutter_tools/lib/src/ios/mac.dart
+0
-3
devices_test.dart
...es/flutter_tools/test/general.shard/ios/devices_test.dart
+14
-14
mac_test.dart
packages/flutter_tools/test/general.shard/ios/mac_test.dart
+10
-10
No files found.
packages/flutter_tools/lib/src/globals.dart
View file @
d85ea513
...
...
@@ -14,6 +14,7 @@ import 'base/io.dart';
import
'base/logger.dart'
;
import
'base/terminal.dart'
;
import
'cache.dart'
;
import
'ios/mac.dart'
;
import
'macos/xcode.dart'
;
import
'version.dart'
;
...
...
@@ -44,6 +45,7 @@ Platform get platform => context.get<Platform>() ?? _kLocalPlatform;
Xcode
get
xcode
=>
context
.
get
<
Xcode
>();
FlutterVersion
get
flutterVersion
=>
context
.
get
<
FlutterVersion
>();
IMobileDevice
get
iMobileDevice
=>
context
.
get
<
IMobileDevice
>();
/// Display an error level message to the user. Commands should use this if they
/// fail in some way.
...
...
packages/flutter_tools/lib/src/ios/devices.dart
View file @
d85ea513
...
...
@@ -174,20 +174,20 @@ class IOSDevice extends Device {
if
(!
globals
.
platform
.
isMacOS
)
{
throw
UnsupportedError
(
'Control of iOS devices or simulators only supported on Mac OS.'
);
}
if
(!
iMobileDevice
.
isInstalled
)
{
if
(!
globals
.
iMobileDevice
.
isInstalled
)
{
return
<
IOSDevice
>[];
}
final
List
<
IOSDevice
>
devices
=
<
IOSDevice
>[];
for
(
String
id
in
(
await
iMobileDevice
.
getAvailableDeviceIDs
()).
split
(
'
\n
'
))
{
for
(
String
id
in
(
await
globals
.
iMobileDevice
.
getAvailableDeviceIDs
()).
split
(
'
\n
'
))
{
id
=
id
.
trim
();
if
(
id
.
isEmpty
)
{
continue
;
}
try
{
final
String
deviceName
=
await
iMobileDevice
.
getInfoForDevice
(
id
,
'DeviceName'
);
final
String
sdkVersion
=
await
iMobileDevice
.
getInfoForDevice
(
id
,
'ProductVersion'
);
final
String
deviceName
=
await
globals
.
iMobileDevice
.
getInfoForDevice
(
id
,
'DeviceName'
);
final
String
sdkVersion
=
await
globals
.
iMobileDevice
.
getInfoForDevice
(
id
,
'ProductVersion'
);
devices
.
add
(
IOSDevice
(
id
,
name:
deviceName
,
sdkVersion:
sdkVersion
));
}
on
IOSDeviceNotFoundError
catch
(
error
)
{
// Unable to find device with given udid. Possibly a network device.
...
...
@@ -283,7 +283,7 @@ class IOSDevice extends Device {
String
cpuArchitecture
;
try
{
cpuArchitecture
=
await
iMobileDevice
.
getInfoForDevice
(
id
,
'CPUArchitecture'
);
cpuArchitecture
=
await
globals
.
iMobileDevice
.
getInfoForDevice
(
id
,
'CPUArchitecture'
);
}
on
IOSDeviceNotFoundError
catch
(
e
)
{
globals
.
printError
(
e
.
message
);
return
LaunchResult
.
failed
();
...
...
@@ -460,11 +460,11 @@ class IOSDevice extends Device {
void
clearLogs
()
{
}
@override
bool
get
supportsScreenshot
=>
iMobileDevice
.
isInstalled
;
bool
get
supportsScreenshot
=>
globals
.
iMobileDevice
.
isInstalled
;
@override
Future
<
void
>
takeScreenshot
(
File
outputFile
)
async
{
await
iMobileDevice
.
takeScreenshot
(
outputFile
);
await
globals
.
iMobileDevice
.
takeScreenshot
(
outputFile
);
}
@override
...
...
@@ -610,7 +610,7 @@ class IOSDeviceLogReader extends DeviceLogReader {
if
(
device
.
majorSdkVersion
>=
_minimumUniversalLoggingSdkVersion
)
{
return
;
}
iMobileDevice
.
startLogger
(
device
.
id
).
then
<
void
>((
Process
process
)
{
globals
.
iMobileDevice
.
startLogger
(
device
.
id
).
then
<
void
>((
Process
process
)
{
process
.
stdout
.
transform
<
String
>(
utf8
.
decoder
).
transform
<
String
>(
const
LineSplitter
()).
listen
(
_newSyslogLineHandler
());
process
.
stderr
.
transform
<
String
>(
utf8
.
decoder
).
transform
<
String
>(
const
LineSplitter
()).
listen
(
_newSyslogLineHandler
());
process
.
exitCode
.
whenComplete
(()
{
...
...
packages/flutter_tools/lib/src/ios/mac.dart
View file @
d85ea513
...
...
@@ -9,7 +9,6 @@ import 'package:meta/meta.dart';
import
'../application_package.dart'
;
import
'../artifacts.dart'
;
import
'../base/common.dart'
;
import
'../base/context.dart'
;
import
'../base/file_system.dart'
;
import
'../base/io.dart'
;
import
'../base/logger.dart'
;
...
...
@@ -26,8 +25,6 @@ import '../reporting/reporting.dart';
import
'code_signing.dart'
;
import
'xcodeproj.dart'
;
IMobileDevice
get
iMobileDevice
=>
context
.
get
<
IMobileDevice
>();
/// Specialized exception for expected situations where the ideviceinfo
/// tool responds with exit code 255 / 'No device found' message
class
IOSDeviceNotFoundError
implements
Exception
{
...
...
packages/flutter_tools/test/general.shard/ios/devices_test.dart
View file @
d85ea513
...
...
@@ -770,8 +770,8 @@ void main() {
});
testUsingContext
(
'returns no devices if none are attached'
,
()
async
{
when
(
iMobileDevice
.
isInstalled
).
thenReturn
(
true
);
when
(
iMobileDevice
.
getAvailableDeviceIDs
())
when
(
globals
.
iMobileDevice
.
isInstalled
).
thenReturn
(
true
);
when
(
globals
.
iMobileDevice
.
getAvailableDeviceIDs
())
.
thenAnswer
((
Invocation
invocation
)
=>
Future
<
String
>.
value
(
''
));
final
List
<
IOSDevice
>
devices
=
await
IOSDevice
.
getAttachedDevices
();
expect
(
devices
,
isEmpty
);
...
...
@@ -783,8 +783,8 @@ void main() {
final
List
<
Platform
>
unsupportedPlatforms
=
<
Platform
>[
linuxPlatform
,
windowsPlatform
];
for
(
final
Platform
platform
in
unsupportedPlatforms
)
{
testUsingContext
(
'throws Unsupported Operation exception on
${platform.operatingSystem}
'
,
()
async
{
when
(
iMobileDevice
.
isInstalled
).
thenReturn
(
false
);
when
(
iMobileDevice
.
getAvailableDeviceIDs
())
when
(
globals
.
iMobileDevice
.
isInstalled
).
thenReturn
(
false
);
when
(
globals
.
iMobileDevice
.
getAvailableDeviceIDs
())
.
thenAnswer
((
Invocation
invocation
)
=>
Future
<
String
>.
value
(
''
));
expect
(
()
async
{
await
IOSDevice
.
getAttachedDevices
();
},
...
...
@@ -797,19 +797,19 @@ void main() {
}
testUsingContext
(
'returns attached devices'
,
()
async
{
when
(
iMobileDevice
.
isInstalled
).
thenReturn
(
true
);
when
(
iMobileDevice
.
getAvailableDeviceIDs
())
when
(
globals
.
iMobileDevice
.
isInstalled
).
thenReturn
(
true
);
when
(
globals
.
iMobileDevice
.
getAvailableDeviceIDs
())
.
thenAnswer
((
Invocation
invocation
)
=>
Future
<
String
>.
value
(
'''
98206e7a4afd4aedaff06e687594e089dede3c44
f577a7903cc54959be2e34bc4f7f80b7009efcf4
'''
));
when
(
iMobileDevice
.
getInfoForDevice
(
'98206e7a4afd4aedaff06e687594e089dede3c44'
,
'DeviceName'
))
when
(
globals
.
iMobileDevice
.
getInfoForDevice
(
'98206e7a4afd4aedaff06e687594e089dede3c44'
,
'DeviceName'
))
.
thenAnswer
((
_
)
=>
Future
<
String
>.
value
(
'La tele me regarde'
));
when
(
iMobileDevice
.
getInfoForDevice
(
'98206e7a4afd4aedaff06e687594e089dede3c44'
,
'ProductVersion'
))
when
(
globals
.
iMobileDevice
.
getInfoForDevice
(
'98206e7a4afd4aedaff06e687594e089dede3c44'
,
'ProductVersion'
))
.
thenAnswer
((
_
)
=>
Future
<
String
>.
value
(
'10.3.2'
));
when
(
iMobileDevice
.
getInfoForDevice
(
'f577a7903cc54959be2e34bc4f7f80b7009efcf4'
,
'DeviceName'
))
when
(
globals
.
iMobileDevice
.
getInfoForDevice
(
'f577a7903cc54959be2e34bc4f7f80b7009efcf4'
,
'DeviceName'
))
.
thenAnswer
((
_
)
=>
Future
<
String
>.
value
(
'Puits sans fond'
));
when
(
iMobileDevice
.
getInfoForDevice
(
'f577a7903cc54959be2e34bc4f7f80b7009efcf4'
,
'ProductVersion'
))
when
(
globals
.
iMobileDevice
.
getInfoForDevice
(
'f577a7903cc54959be2e34bc4f7f80b7009efcf4'
,
'ProductVersion'
))
.
thenAnswer
((
_
)
=>
Future
<
String
>.
value
(
'11.0'
));
final
List
<
IOSDevice
>
devices
=
await
IOSDevice
.
getAttachedDevices
();
expect
(
devices
,
hasLength
(
2
));
...
...
@@ -823,15 +823,15 @@ f577a7903cc54959be2e34bc4f7f80b7009efcf4
});
testUsingContext
(
'returns attached devices and ignores devices that cannot be found by ideviceinfo'
,
()
async
{
when
(
iMobileDevice
.
isInstalled
).
thenReturn
(
true
);
when
(
iMobileDevice
.
getAvailableDeviceIDs
())
when
(
globals
.
iMobileDevice
.
isInstalled
).
thenReturn
(
true
);
when
(
globals
.
iMobileDevice
.
getAvailableDeviceIDs
())
.
thenAnswer
((
Invocation
invocation
)
=>
Future
<
String
>.
value
(
'''
98206e7a4afd4aedaff06e687594e089dede3c44
f577a7903cc54959be2e34bc4f7f80b7009efcf4
'''
));
when
(
iMobileDevice
.
getInfoForDevice
(
'98206e7a4afd4aedaff06e687594e089dede3c44'
,
'DeviceName'
))
when
(
globals
.
iMobileDevice
.
getInfoForDevice
(
'98206e7a4afd4aedaff06e687594e089dede3c44'
,
'DeviceName'
))
.
thenAnswer
((
_
)
=>
Future
<
String
>.
value
(
'La tele me regarde'
));
when
(
iMobileDevice
.
getInfoForDevice
(
'f577a7903cc54959be2e34bc4f7f80b7009efcf4'
,
'DeviceName'
))
when
(
globals
.
iMobileDevice
.
getInfoForDevice
(
'f577a7903cc54959be2e34bc4f7f80b7009efcf4'
,
'DeviceName'
))
.
thenThrow
(
const
IOSDeviceNotFoundError
(
'Device not found'
));
final
List
<
IOSDevice
>
devices
=
await
IOSDevice
.
getAttachedDevices
();
expect
(
devices
,
hasLength
(
1
));
...
...
packages/flutter_tools/test/general.shard/ios/mac_test.dart
View file @
d85ea513
...
...
@@ -60,7 +60,7 @@ void main() {
when
(
mockProcessManager
.
runSync
(
<
String
>[
ideviceIdPath
,
'-h'
],
environment:
anyNamed
(
'environment'
),
)).
thenReturn
(
ProcessResult
(
123
,
1
,
''
,
''
));
expect
(
await
iMobileDevice
.
isWorking
,
false
);
expect
(
await
globals
.
iMobileDevice
.
isWorking
,
false
);
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mockProcessManager
,
Artifacts:
()
=>
mockArtifacts
,
...
...
@@ -71,7 +71,7 @@ void main() {
<
String
>[
ideviceIdPath
,
'-l'
],
environment:
<
String
,
String
>{
'DYLD_LIBRARY_PATH'
:
libimobiledevicePath
},
)).
thenThrow
(
ProcessException
(
ideviceIdPath
,
<
String
>[
'-l'
]));
expect
(()
async
=>
await
iMobileDevice
.
getAvailableDeviceIDs
(),
throwsToolExit
());
expect
(()
async
=>
await
globals
.
iMobileDevice
.
getAvailableDeviceIDs
(),
throwsToolExit
());
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mockProcessManager
,
Cache:
()
=>
mockCache
,
...
...
@@ -83,7 +83,7 @@ void main() {
<
String
>[
ideviceIdPath
,
'-l'
],
environment:
<
String
,
String
>{
'DYLD_LIBRARY_PATH'
:
libimobiledevicePath
},
)).
thenAnswer
((
_
)
=>
Future
<
ProcessResult
>.
value
(
ProcessResult
(
1
,
1
,
''
,
'Sad today'
)));
expect
(()
async
=>
await
iMobileDevice
.
getAvailableDeviceIDs
(),
throwsToolExit
());
expect
(()
async
=>
await
globals
.
iMobileDevice
.
getAvailableDeviceIDs
(),
throwsToolExit
());
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mockProcessManager
,
Cache:
()
=>
mockCache
,
...
...
@@ -95,7 +95,7 @@ void main() {
<
String
>[
ideviceIdPath
,
'-l'
],
environment:
<
String
,
String
>{
'DYLD_LIBRARY_PATH'
:
libimobiledevicePath
},
)).
thenAnswer
((
_
)
=>
Future
<
ProcessResult
>.
value
(
ProcessResult
(
1
,
0
,
'foo'
,
''
)));
expect
(
await
iMobileDevice
.
getAvailableDeviceIDs
(),
'foo'
);
expect
(
await
globals
.
iMobileDevice
.
getAvailableDeviceIDs
(),
'foo'
);
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mockProcessManager
,
Cache:
()
=>
mockCache
,
...
...
@@ -108,7 +108,7 @@ void main() {
<
String
>[
ideviceInfoPath
,
'-u'
,
'foo'
,
'-k'
,
'bar'
],
environment:
<
String
,
String
>{
'DYLD_LIBRARY_PATH'
:
libimobiledevicePath
},
)).
thenAnswer
((
_
)
=>
Future
<
ProcessResult
>.
value
(
ProcessResult
(
1
,
255
,
'No device found with udid foo, is it plugged in?'
,
''
)));
expect
(()
async
=>
await
iMobileDevice
.
getInfoForDevice
(
'foo'
,
'bar'
),
throwsA
(
isA
<
IOSDeviceNotFoundError
>()));
expect
(()
async
=>
await
globals
.
iMobileDevice
.
getInfoForDevice
(
'foo'
,
'bar'
),
throwsA
(
isA
<
IOSDeviceNotFoundError
>()));
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mockProcessManager
,
Cache:
()
=>
mockCache
,
...
...
@@ -129,7 +129,7 @@ void main() {
);
return
Future
<
ProcessResult
>.
value
(
result
);
});
expect
(()
async
=>
await
iMobileDevice
.
getInfoForDevice
(
'foo'
,
'bar'
),
throwsA
(
isA
<
IOSDeviceNotTrustedError
>()));
expect
(()
async
=>
await
globals
.
iMobileDevice
.
getInfoForDevice
(
'foo'
,
'bar'
),
throwsA
(
isA
<
IOSDeviceNotTrustedError
>()));
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mockProcessManager
,
Cache:
()
=>
mockCache
,
...
...
@@ -150,7 +150,7 @@ void main() {
);
return
Future
<
ProcessResult
>.
value
(
result
);
});
expect
(()
async
=>
await
iMobileDevice
.
getInfoForDevice
(
'foo'
,
'bar'
),
throwsToolExit
());
expect
(()
async
=>
await
globals
.
iMobileDevice
.
getInfoForDevice
(
'foo'
,
'bar'
),
throwsToolExit
());
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mockProcessManager
,
Cache:
()
=>
mockCache
,
...
...
@@ -171,7 +171,7 @@ void main() {
);
return
Future
<
ProcessResult
>.
value
(
result
);
});
expect
(()
async
=>
await
iMobileDevice
.
getInfoForDevice
(
'foo'
,
'bar'
),
throwsA
(
isA
<
IOSDeviceNotTrustedError
>()));
expect
(()
async
=>
await
globals
.
iMobileDevice
.
getInfoForDevice
(
'foo'
,
'bar'
),
throwsA
(
isA
<
IOSDeviceNotTrustedError
>()));
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mockProcessManager
,
Cache:
()
=>
mockCache
,
...
...
@@ -198,7 +198,7 @@ void main() {
workingDirectory:
null
,
)).
thenAnswer
((
_
)
=>
Future
<
ProcessResult
>.
value
(
ProcessResult
(
4
,
1
,
''
,
''
)));
expect
(()
async
=>
await
iMobileDevice
.
takeScreenshot
(
mockOutputFile
),
throwsA
(
anything
));
expect
(()
async
=>
await
globals
.
iMobileDevice
.
takeScreenshot
(
mockOutputFile
),
throwsA
(
anything
));
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mockProcessManager
,
Platform:
()
=>
osx
,
...
...
@@ -210,7 +210,7 @@ void main() {
when
(
mockProcessManager
.
run
(
any
,
environment:
anyNamed
(
'environment'
),
workingDirectory:
null
)).
thenAnswer
(
(
Invocation
invocation
)
=>
Future
<
ProcessResult
>.
value
(
ProcessResult
(
4
,
0
,
''
,
''
)));
await
iMobileDevice
.
takeScreenshot
(
mockOutputFile
);
await
globals
.
iMobileDevice
.
takeScreenshot
(
mockOutputFile
);
verify
(
mockProcessManager
.
run
(<
String
>[
idevicescreenshotPath
,
outputPath
],
environment:
<
String
,
String
>{
'DYLD_LIBRARY_PATH'
:
libimobiledevicePath
},
workingDirectory:
null
,
...
...
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