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
8474f41e
Unverified
Commit
8474f41e
authored
Oct 19, 2021
by
Jenn Magder
Committed by
GitHub
Oct 19, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate xcdevice and ios devices to null safety (#92056)
parent
921cfebb
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
280 additions
and
257 deletions
+280
-257
artifacts.dart
packages/flutter_tools/lib/src/artifacts.dart
+0
-2
cache.dart
packages/flutter_tools/lib/src/cache.dart
+0
-1
globals.dart
packages/flutter_tools/lib/src/globals.dart
+0
-3
globals_null_migrated.dart
packages/flutter_tools/lib/src/globals_null_migrated.dart
+2
-0
devices.dart
packages/flutter_tools/lib/src/ios/devices.dart
+109
-106
mac.dart
packages/flutter_tools/lib/src/ios/mac.dart
+11
-1
xcdevice.dart
packages/flutter_tools/lib/src/macos/xcdevice.dart
+84
-84
devices_test.dart
...es/flutter_tools/test/general.shard/ios/devices_test.dart
+54
-53
ios_device_project_test.dart
...tools/test/general.shard/ios/ios_device_project_test.dart
+18
-5
xcode_test.dart
...es/flutter_tools/test/general.shard/macos/xcode_test.dart
+2
-2
No files found.
packages/flutter_tools/lib/src/artifacts.dart
View file @
8474f41e
...
...
@@ -3,7 +3,6 @@
// found in the LICENSE file.
import
'package:file/memory.dart'
;
import
'package:meta/meta.dart'
;
import
'package:process/process.dart'
;
import
'base/common.dart'
;
...
...
@@ -282,7 +281,6 @@ abstract class Artifacts {
/// If a [fileSystem] is not provided, creates a new [MemoryFileSystem] instance.
///
/// Creates a [LocalEngineArtifacts] if `localEngine` is non-null
@visibleForTesting
factory
Artifacts
.
test
({
String
?
localEngine
,
FileSystem
?
fileSystem
})
{
fileSystem
??=
MemoryFileSystem
.
test
();
if
(
localEngine
!=
null
)
{
...
...
packages/flutter_tools/lib/src/cache.dart
View file @
8474f41e
...
...
@@ -127,7 +127,6 @@ class Cache {
/// Defaults to a memory file system, fake platform,
/// buffer logger, and no accessible artifacts.
/// By default, the root cache directory path is "cache".
@visibleForTesting
factory
Cache
.
test
({
Directory
?
rootOverride
,
List
<
ArtifactSet
>?
artifacts
,
...
...
packages/flutter_tools/lib/src/globals.dart
View file @
8474f41e
...
...
@@ -7,11 +7,8 @@
import
'base/context.dart'
;
import
'doctor.dart'
;
import
'ios/simulators.dart'
;
import
'macos/xcdevice.dart'
;
export
'globals_null_migrated.dart'
;
Doctor
get
doctor
=>
context
.
get
<
Doctor
>();
IOSSimulatorUtils
get
iosSimulatorUtils
=>
context
.
get
<
IOSSimulatorUtils
>();
XCDevice
get
xcdevice
=>
context
.
get
<
XCDevice
>();
packages/flutter_tools/lib/src/globals_null_migrated.dart
View file @
8474f41e
...
...
@@ -34,6 +34,7 @@ import 'ios/plist_parser.dart';
import
'ios/xcodeproj.dart'
;
import
'macos/cocoapods.dart'
;
import
'macos/cocoapods_validator.dart'
;
import
'macos/xcdevice.dart'
;
import
'macos/xcode.dart'
;
import
'persistent_tool_state.dart'
;
import
'project.dart'
;
...
...
@@ -62,6 +63,7 @@ FlutterVersion get flutterVersion => context.get<FlutterVersion>()!;
FuchsiaArtifacts
?
get
fuchsiaArtifacts
=>
context
.
get
<
FuchsiaArtifacts
>();
Usage
get
flutterUsage
=>
context
.
get
<
Usage
>()!;
XcodeProjectInterpreter
?
get
xcodeProjectInterpreter
=>
context
.
get
<
XcodeProjectInterpreter
>();
XCDevice
?
get
xcdevice
=>
context
.
get
<
XCDevice
>();
Xcode
?
get
xcode
=>
context
.
get
<
Xcode
>();
IOSWorkflow
?
get
iosWorkflow
=>
context
.
get
<
IOSWorkflow
>();
LocalEngineLocator
?
get
localEngineLocator
=>
context
.
get
<
LocalEngineLocator
>();
...
...
packages/flutter_tools/lib/src/ios/devices.dart
View file @
8474f41e
This diff is collapsed.
Click to expand it.
packages/flutter_tools/lib/src/ios/mac.dart
View file @
8474f41e
...
...
@@ -45,6 +45,16 @@ class IMobileDevice {
_processUtils
=
ProcessUtils
(
logger:
logger
,
processManager:
processManager
),
_processManager
=
processManager
;
/// Create an [IMobileDevice] for testing.
factory
IMobileDevice
.
test
({
required
ProcessManager
processManager
})
{
return
IMobileDevice
(
artifacts:
Artifacts
.
test
(),
cache:
Cache
.
test
(
processManager:
processManager
),
processManager:
processManager
,
logger:
BufferLogger
.
test
(),
);
}
final
String
_idevicesyslogPath
;
final
String
_idevicescreenshotPath
;
final
MapEntry
<
String
,
String
>
_dyLdLibEntry
;
...
...
@@ -93,7 +103,7 @@ class IMobileDevice {
Future
<
XcodeBuildResult
>
buildXcodeProject
({
required
BuildableIOSApp
app
,
required
BuildInfo
buildInfo
,
required
String
targetOverride
,
String
?
targetOverride
,
EnvironmentType
environmentType
=
EnvironmentType
.
physical
,
DarwinArch
?
activeArch
,
bool
codesign
=
true
,
...
...
packages/flutter_tools/lib/src/macos/xcdevice.dart
View file @
8474f41e
This diff is collapsed.
Click to expand it.
packages/flutter_tools/test/general.shard/ios/devices_test.dart
View file @
8474f41e
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
import
'dart:io'
as
io
;
...
...
@@ -39,16 +37,17 @@ void main() {
group
(
'IOSDevice'
,
()
{
final
List
<
Platform
>
unsupportedPlatforms
=
<
Platform
>[
linuxPlatform
,
windowsPlatform
];
Cache
cache
;
Logger
logger
;
IOSDeploy
iosDeploy
;
IMobileDevice
iMobileDevice
;
FileSystem
nullF
ileSystem
;
late
Cache
cache
;
late
Logger
logger
;
late
IOSDeploy
iosDeploy
;
late
IMobileDevice
iMobileDevice
;
late
FileSystem
f
ileSystem
;
setUp
(()
{
final
Artifacts
artifacts
=
Artifacts
.
test
();
cache
=
Cache
.
test
(
processManager:
FakeProcessManager
.
any
());
logger
=
BufferLogger
.
test
();
fileSystem
=
MemoryFileSystem
.
test
();
iosDeploy
=
IOSDeploy
(
artifacts:
artifacts
,
cache:
cache
,
...
...
@@ -68,7 +67,7 @@ void main() {
IOSDevice
(
'device-123'
,
iProxy:
IProxy
.
test
(
logger:
logger
,
processManager:
FakeProcessManager
.
any
()),
fileSystem:
nullF
ileSystem
,
fileSystem:
f
ileSystem
,
logger:
logger
,
platform:
macPlatform
,
iosDeploy:
iosDeploy
,
...
...
@@ -84,7 +83,7 @@ void main() {
expect
(
IOSDevice
(
'device-123'
,
iProxy:
IProxy
.
test
(
logger:
logger
,
processManager:
FakeProcessManager
.
any
()),
fileSystem:
nullF
ileSystem
,
fileSystem:
f
ileSystem
,
logger:
logger
,
platform:
macPlatform
,
iosDeploy:
iosDeploy
,
...
...
@@ -97,7 +96,7 @@ void main() {
expect
(
IOSDevice
(
'device-123'
,
iProxy:
IProxy
.
test
(
logger:
logger
,
processManager:
FakeProcessManager
.
any
()),
fileSystem:
nullF
ileSystem
,
fileSystem:
f
ileSystem
,
logger:
logger
,
platform:
macPlatform
,
iosDeploy:
iosDeploy
,
...
...
@@ -110,7 +109,7 @@ void main() {
expect
(
IOSDevice
(
'device-123'
,
iProxy:
IProxy
.
test
(
logger:
logger
,
processManager:
FakeProcessManager
.
any
()),
fileSystem:
nullF
ileSystem
,
fileSystem:
f
ileSystem
,
logger:
logger
,
platform:
macPlatform
,
iosDeploy:
iosDeploy
,
...
...
@@ -123,7 +122,7 @@ void main() {
expect
(
IOSDevice
(
'device-123'
,
iProxy:
IProxy
.
test
(
logger:
logger
,
processManager:
FakeProcessManager
.
any
()),
fileSystem:
nullF
ileSystem
,
fileSystem:
f
ileSystem
,
logger:
logger
,
platform:
macPlatform
,
iosDeploy:
iosDeploy
,
...
...
@@ -136,7 +135,7 @@ void main() {
expect
(
IOSDevice
(
'device-123'
,
iProxy:
IProxy
.
test
(
logger:
logger
,
processManager:
FakeProcessManager
.
any
()),
fileSystem:
nullF
ileSystem
,
fileSystem:
f
ileSystem
,
logger:
logger
,
platform:
macPlatform
,
iosDeploy:
iosDeploy
,
...
...
@@ -152,7 +151,7 @@ void main() {
final
IOSDevice
device
=
IOSDevice
(
'device-123'
,
iProxy:
IProxy
.
test
(
logger:
logger
,
processManager:
FakeProcessManager
.
any
()),
fileSystem:
nullF
ileSystem
,
fileSystem:
f
ileSystem
,
logger:
logger
,
platform:
macPlatform
,
iosDeploy:
iosDeploy
,
...
...
@@ -170,7 +169,7 @@ void main() {
final
IOSDevice
device
=
IOSDevice
(
'device-123'
,
iProxy:
IProxy
.
test
(
logger:
logger
,
processManager:
FakeProcessManager
.
any
()),
fileSystem:
nullF
ileSystem
,
fileSystem:
f
ileSystem
,
logger:
logger
,
platform:
macPlatform
,
iosDeploy:
iosDeploy
,
...
...
@@ -194,7 +193,7 @@ void main() {
IOSDevice
(
'device-123'
,
iProxy:
IProxy
.
test
(
logger:
logger
,
processManager:
FakeProcessManager
.
any
()),
fileSystem:
nullF
ileSystem
,
fileSystem:
f
ileSystem
,
logger:
logger
,
platform:
platform
,
iosDeploy:
iosDeploy
,
...
...
@@ -211,21 +210,21 @@ void main() {
}
group
(
'.dispose()'
,
()
{
IOSDevice
device
;
FakeIOSApp
appPackage1
;
FakeIOSApp
appPackage2
;
IOSDeviceLogReader
logReader1
;
IOSDeviceLogReader
logReader2
;
FakeProcess
process1
;
FakeProcess
process2
;
FakeProcess
process3
;
IOSDevicePortForwarder
portForwarder
;
ForwardedPort
forwardedPort
;
Cache
cache
;
Logger
logger
;
IOSDeploy
iosDeploy
;
FileSystem
nullF
ileSystem
;
IProxy
iproxy
;
late
IOSDevice
device
;
late
FakeIOSApp
appPackage1
;
late
FakeIOSApp
appPackage2
;
late
IOSDeviceLogReader
logReader1
;
late
IOSDeviceLogReader
logReader2
;
late
FakeProcess
process1
;
late
FakeProcess
process2
;
late
FakeProcess
process3
;
late
IOSDevicePortForwarder
portForwarder
;
late
ForwardedPort
forwardedPort
;
late
Cache
cache
;
late
Logger
logger
;
late
IOSDeploy
iosDeploy
;
late
FileSystem
f
ileSystem
;
late
IProxy
iproxy
;
IOSDevicePortForwarder
createPortForwarder
(
ForwardedPort
forwardedPort
,
...
...
@@ -235,7 +234,7 @@ void main() {
id:
device
.
id
,
logger:
logger
,
operatingSystemUtils:
OperatingSystemUtils
(
fileSystem:
nullF
ileSystem
,
fileSystem:
f
ileSystem
,
logger:
logger
,
platform:
FakePlatform
(
operatingSystem:
'macos'
),
processManager:
FakeProcessManager
.
any
(),
...
...
@@ -253,7 +252,7 @@ void main() {
final
IOSDeviceLogReader
logReader
=
IOSDeviceLogReader
.
create
(
device:
device
,
app:
appPackage
,
iMobileDevice:
null
,
// not used by this test.
iMobileDevice:
IMobileDevice
.
test
(
processManager:
FakeProcessManager
.
any
()),
);
logReader
.
idevicesyslogProcess
=
process
;
return
logReader
;
...
...
@@ -269,6 +268,8 @@ void main() {
cache
=
Cache
.
test
(
processManager:
FakeProcessManager
.
any
(),
);
fileSystem
=
MemoryFileSystem
.
test
();
logger
=
BufferLogger
.
test
();
iosDeploy
=
IOSDeploy
(
artifacts:
Artifacts
.
test
(),
cache:
cache
,
...
...
@@ -282,7 +283,7 @@ void main() {
device
=
IOSDevice
(
'123'
,
iProxy:
IProxy
.
test
(
logger:
logger
,
processManager:
FakeProcessManager
.
any
()),
fileSystem:
nullF
ileSystem
,
fileSystem:
f
ileSystem
,
logger:
logger
,
platform:
macPlatform
,
iosDeploy:
iosDeploy
,
...
...
@@ -309,15 +310,15 @@ void main() {
});
group
(
'polling'
,
()
{
FakeXcdevice
xcdevice
;
Cache
cache
;
FakeProcessManager
fakeProcessManager
;
BufferLogger
logger
;
IOSDeploy
iosDeploy
;
IMobileDevice
iMobileDevice
;
IOSWorkflow
iosWorkflow
;
IOSDevice
device1
;
IOSDevice
device2
;
late
FakeXcdevice
xcdevice
;
late
Cache
cache
;
late
FakeProcessManager
fakeProcessManager
;
late
BufferLogger
logger
;
late
IOSDeploy
iosDeploy
;
late
IMobileDevice
iMobileDevice
;
late
IOSWorkflow
iosWorkflow
;
late
IOSDevice
device1
;
late
IOSDevice
device2
;
setUp
(()
{
xcdevice
=
FakeXcdevice
();
...
...
@@ -414,22 +415,22 @@ void main() {
await
iosDevices
.
startPolling
();
expect
(
xcdevice
.
getAvailableIOSDevicesCount
,
1
);
expect
(
iosDevices
.
deviceNotifier
.
items
,
isEmpty
);
expect
(
iosDevices
.
deviceNotifier
!
.
items
,
isEmpty
);
expect
(
xcdevice
.
deviceEventController
.
hasListener
,
isTrue
);
xcdevice
.
deviceEventController
.
add
(<
XCDeviceEvent
,
String
>{
XCDeviceEvent
.
attach
:
'd83d5bc53967baa0ee18626ba87b6254b2ab5418'
});
await
added
.
future
;
expect
(
iosDevices
.
deviceNotifier
.
items
.
length
,
2
);
expect
(
iosDevices
.
deviceNotifier
.
items
,
contains
(
device1
));
expect
(
iosDevices
.
deviceNotifier
.
items
,
contains
(
device2
));
expect
(
iosDevices
.
deviceNotifier
!
.
items
.
length
,
2
);
expect
(
iosDevices
.
deviceNotifier
!
.
items
,
contains
(
device1
));
expect
(
iosDevices
.
deviceNotifier
!
.
items
,
contains
(
device2
));
xcdevice
.
deviceEventController
.
add
(<
XCDeviceEvent
,
String
>{
XCDeviceEvent
.
detach
:
'd83d5bc53967baa0ee18626ba87b6254b2ab5418'
});
await
removed
.
future
;
expect
(
iosDevices
.
deviceNotifier
.
items
,
<
Device
>[
device2
]);
expect
(
iosDevices
.
deviceNotifier
!
.
items
,
<
Device
>[
device2
]);
// Remove stream will throw over-completion if called more than once
// which proves this is ignored.
...
...
@@ -489,7 +490,7 @@ void main() {
xcdevice
.
devices
.
add
(<
IOSDevice
>[]);
await
iosDevices
.
startPolling
();
expect
(
iosDevices
.
deviceNotifier
.
items
,
isEmpty
);
expect
(
iosDevices
.
deviceNotifier
!
.
items
,
isEmpty
);
expect
(
xcdevice
.
deviceEventController
.
hasListener
,
isTrue
);
iosDevices
.
dispose
();
...
...
@@ -531,9 +532,9 @@ void main() {
});
group
(
'getDiagnostics'
,
()
{
FakeXcdevice
xcdevice
;
IOSWorkflow
iosWorkflow
;
Logger
logger
;
late
FakeXcdevice
xcdevice
;
late
IOSWorkflow
iosWorkflow
;
late
Logger
logger
;
setUp
(()
{
xcdevice
=
FakeXcdevice
();
...
...
@@ -601,7 +602,7 @@ class FakeXcdevice extends Fake implements XCDevice {
}
@override
Future
<
List
<
IOSDevice
>>
getAvailableIOSDevices
({
Duration
timeout
})
async
{
Future
<
List
<
IOSDevice
>>
getAvailableIOSDevices
({
Duration
?
timeout
})
async
{
return
devices
[
getAvailableIOSDevicesCount
++];
}
}
...
...
packages/flutter_tools/test/general.shard/ios/ios_device_project_test.dart
View file @
8474f41e
...
...
@@ -5,12 +5,16 @@
// @dart = 2.8
import
'package:file/memory.dart'
;
import
'package:flutter_tools/src/artifacts.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/build_info.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/ios/devices.dart'
;
import
'package:flutter_tools/src/ios/ios_deploy.dart'
;
import
'package:flutter_tools/src/ios/iproxy.dart'
;
import
'package:flutter_tools/src/ios/mac.dart'
;
import
'package:flutter_tools/src/project.dart'
;
import
'../../src/common.dart'
;
...
...
@@ -76,17 +80,26 @@ flutter:
}
IOSDevice
setUpIOSDevice
(
FileSystem
fileSystem
)
{
final
Platform
platform
=
FakePlatform
(
operatingSystem:
'macos'
);
final
Logger
logger
=
BufferLogger
.
test
();
final
ProcessManager
processManager
=
FakeProcessManager
.
any
();
return
IOSDevice
(
'test'
,
fileSystem:
fileSystem
,
logger:
BufferLogger
.
test
(),
iosDeploy:
null
,
// not used in this test
iMobileDevice:
null
,
// not used in this test
platform:
FakePlatform
(
operatingSystem:
'macos'
),
logger:
logger
,
iosDeploy:
IOSDeploy
(
platform:
platform
,
logger:
logger
,
processManager:
processManager
,
artifacts:
Artifacts
.
test
(),
cache:
Cache
.
test
(
processManager:
processManager
),
),
iMobileDevice:
IMobileDevice
.
test
(
processManager:
processManager
),
platform:
platform
,
name:
'iPhone 1'
,
sdkVersion:
'13.3'
,
cpuArchitecture:
DarwinArch
.
arm64
,
iProxy:
IProxy
.
test
(
logger:
BufferLogger
.
test
(),
processManager:
FakeProcessManager
.
any
()
),
iProxy:
IProxy
.
test
(
logger:
logger
,
processManager:
processManager
),
interfaceType:
IOSDeviceConnectionInterface
.
usb
,
);
}
packages/flutter_tools/test/general.shard/macos/xcode_test.dart
View file @
8474f41e
...
...
@@ -326,7 +326,7 @@ void main() {
processManager:
fakeProcessManager
,
logger:
logger
,
xcode:
xcode
,
platform:
null
,
platform:
FakePlatform
(
operatingSystem:
'macos'
)
,
artifacts:
Artifacts
.
test
(),
cache:
Cache
.
test
(
processManager:
FakeProcessManager
.
any
()),
iproxy:
IProxy
.
test
(
logger:
logger
,
processManager:
fakeProcessManager
),
...
...
@@ -354,7 +354,7 @@ void main() {
processManager:
fakeProcessManager
,
logger:
logger
,
xcode:
xcode
,
platform:
null
,
platform:
FakePlatform
(
operatingSystem:
'macos'
)
,
artifacts:
Artifacts
.
test
(),
cache:
Cache
.
test
(
processManager:
FakeProcessManager
.
any
()),
iproxy:
IProxy
.
test
(
logger:
logger
,
processManager:
fakeProcessManager
),
...
...
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