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
d20242b7
Unverified
Commit
d20242b7
authored
Mar 19, 2020
by
Jonah Williams
Committed by
GitHub
Mar 19, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] refactor ios install/uninstall to new file (#52891)
parent
b21e780a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
186 additions
and
210 deletions
+186
-210
devices_test.dart
...es/flutter_tools/test/general.shard/ios/devices_test.dart
+0
-210
ios_device_install_test.dart
...tools/test/general.shard/ios/ios_device_install_test.dart
+186
-0
No files found.
packages/flutter_tools/test/general.shard/ios/devices_test.dart
View file @
d20242b7
...
...
@@ -215,90 +215,6 @@ void main() {
final
bool
result
=
await
device
.
isAppInstalled
(
mockApp
);
expect
(
result
,
false
);
});
testWithoutContext
(
'installApp() catches ProcessException from ios-deploy'
,
()
async
{
const
String
bundlePath
=
'/path/to/bundle'
;
final
MockIOSApp
mockApp
=
MockIOSApp
();
when
(
mockApp
.
id
).
thenReturn
(
appId
);
when
(
mockApp
.
deviceBundlePath
).
thenReturn
(
bundlePath
);
final
MockDirectory
mockDirectory
=
MockDirectory
();
when
(
mockFileSystem
.
directory
(
bundlePath
)).
thenReturn
(
mockDirectory
);
when
(
mockDirectory
.
existsSync
()).
thenReturn
(
true
);
when
(
mockDirectory
.
path
).
thenReturn
(
bundlePath
);
fakeProcessManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[
FakeCommand
(
command:
const
<
String
>[
iosDeployPath
,
'--id'
,
deviceId
,
'--bundle'
,
bundlePath
,
'--no-wifi'
,
],
onRun:
()
=>
throw
const
ProcessException
(
'ios-deploy'
,
<
String
>[]),
)
]);
iosDeploy
=
IOSDeploy
(
artifacts:
mockArtifacts
,
cache:
mockCache
,
logger:
logger
,
platform:
macPlatform
,
processManager:
fakeProcessManager
,
);
device
=
IOSDevice
(
deviceId
,
artifacts:
mockArtifacts
,
fileSystem:
mockFileSystem
,
logger:
logger
,
platform:
macPlatform
,
iosDeploy:
iosDeploy
,
name:
'iPhone 1'
,
sdkVersion:
'13.3'
,
cpuArchitecture:
DarwinArch
.
arm64
,
);
final
bool
result
=
await
device
.
installApp
(
mockApp
);
expect
(
result
,
false
);
});
testWithoutContext
(
'uninstallApp() catches ProcessException from ios-deploy'
,
()
async
{
final
MockIOSApp
mockApp
=
MockIOSApp
();
when
(
mockApp
.
id
).
thenReturn
(
appId
);
fakeProcessManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[
FakeCommand
(
command:
const
<
String
>[
iosDeployPath
,
'--id'
,
deviceId
,
'--uninstall_only'
,
'--bundle_id'
,
appId
,
],
onRun:
()
=>
throw
const
ProcessException
(
'ios-deploy'
,
<
String
>[]),
)
]);
iosDeploy
=
IOSDeploy
(
artifacts:
mockArtifacts
,
cache:
mockCache
,
logger:
logger
,
platform:
macPlatform
,
processManager:
fakeProcessManager
,
);
device
=
IOSDevice
(
deviceId
,
artifacts:
mockArtifacts
,
fileSystem:
mockFileSystem
,
logger:
logger
,
platform:
macPlatform
,
iosDeploy:
iosDeploy
,
name:
'iPhone 1'
,
sdkVersion:
'13.3'
,
cpuArchitecture:
DarwinArch
.
arm64
,
);
final
bool
result
=
await
device
.
uninstallApp
(
mockApp
);
expect
(
result
,
false
);
});
});
group
(
'.dispose()'
,
()
{
...
...
@@ -645,132 +561,6 @@ void main() {
},
);
});
group
(
'Process calls'
,
()
{
const
String
bundlePath
=
'/path/to/bundle'
;
FileSystem
fs
;
MockDirectory
directory
;
MockIOSApp
mockApp
;
MockArtifacts
mockArtifacts
;
MockCache
mockCache
;
MockFileSystem
mockFileSystem
;
MockProcessManager
mockProcessManager
;
Logger
logger
;
MockPlatform
mockPlatform
;
const
String
iosDeployPath
=
'/path/to/ios-deploy'
;
const
String
appId
=
'789'
;
const
String
deviceId
=
'123'
;
const
MapEntry
<
String
,
String
>
libraryEntry
=
MapEntry
<
String
,
String
>(
'DYLD_LIBRARY_PATH'
,
'/path/to/libraries'
,
);
IOSDeploy
iosDeploy
;
setUp
(()
{
mockFileSystem
=
MockFileSystem
();
directory
=
MockDirectory
();
when
(
mockFileSystem
.
directory
(
bundlePath
)).
thenReturn
(
directory
);
mockApp
=
MockIOSApp
();
when
(
mockApp
.
id
).
thenReturn
(
appId
);
when
(
mockApp
.
deviceBundlePath
).
thenReturn
(
bundlePath
);
when
(
directory
.
existsSync
()).
thenReturn
(
true
);
when
(
directory
.
path
).
thenReturn
(
bundlePath
);
mockArtifacts
=
MockArtifacts
();
mockCache
=
MockCache
();
logger
=
BufferLogger
.
test
();
mockPlatform
=
MockPlatform
();
when
(
mockPlatform
.
environment
).
thenReturn
(<
String
,
String
>{});
when
(
mockPlatform
.
isMacOS
).
thenReturn
(
true
);
when
(
mockArtifacts
.
getArtifactPath
(
Artifact
.
iosDeploy
,
platform:
anyNamed
(
'platform'
),
),
).
thenReturn
(
iosDeployPath
);
mockProcessManager
=
MockProcessManager
();
iosDeploy
=
IOSDeploy
(
artifacts:
mockArtifacts
,
cache:
mockCache
,
logger:
logger
,
platform:
mockPlatform
,
processManager:
mockProcessManager
,
);
when
(
mockCache
.
dyLdLibEntry
).
thenReturn
(
libraryEntry
);
mockFileSystem
=
MockFileSystem
();
final
MemoryFileSystem
memoryFileSystem
=
MemoryFileSystem
();
when
(
mockFileSystem
.
currentDirectory
)
.
thenReturn
(
memoryFileSystem
.
currentDirectory
);
});
testWithoutContext
(
'installApp() calls ios-deploy'
,
()
async
{
final
FakeProcessManager
fakeProcessManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[
const
FakeCommand
(
command:
<
String
>[
iosDeployPath
,
'--id'
,
deviceId
,
'--bundle'
,
bundlePath
,
'--no-wifi'
,
]),
]);
iosDeploy
=
IOSDeploy
(
artifacts:
mockArtifacts
,
cache:
mockCache
,
logger:
logger
,
platform:
mockPlatform
,
processManager:
fakeProcessManager
,
);
when
(
mockFileSystem
.
directory
(
bundlePath
)).
thenReturn
(
directory
);
final
IOSDevice
device
=
IOSDevice
(
deviceId
,
name:
'iPhone 1'
,
fileSystem:
mockFileSystem
,
sdkVersion:
'13.3'
,
cpuArchitecture:
DarwinArch
.
arm64
,
logger:
logger
,
platform:
mockPlatform
,
artifacts:
mockArtifacts
,
iosDeploy:
iosDeploy
,
);
await
device
.
installApp
(
mockApp
);
});
testWithoutContext
(
'uninstallApp() calls ios-deploy'
,
()
async
{
final
FakeProcessManager
fakeProcessManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[
const
FakeCommand
(
command:
<
String
>[
iosDeployPath
,
'--id'
,
deviceId
,
'--uninstall_only'
,
'--bundle_id'
,
appId
,
]),
]);
iosDeploy
=
IOSDeploy
(
artifacts:
mockArtifacts
,
cache:
mockCache
,
logger:
logger
,
platform:
mockPlatform
,
processManager:
fakeProcessManager
,
);
final
IOSDevice
device
=
IOSDevice
(
deviceId
,
name:
'iPhone 1'
,
fileSystem:
fs
,
sdkVersion:
'13.3'
,
cpuArchitecture:
DarwinArch
.
arm64
,
logger:
logger
,
platform:
mockPlatform
,
artifacts:
mockArtifacts
,
iosDeploy:
iosDeploy
,
);
await
device
.
uninstallApp
(
mockApp
);
});
});
});
group
(
'pollingGetDevices'
,
()
{
...
...
packages/flutter_tools/test/general.shard/ios/ios_device_install_test.dart
0 → 100644
View file @
d20242b7
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:file/memory.dart'
;
import
'package:flutter_tools/src/application_package.dart'
;
import
'package:flutter_tools/src/artifacts.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/io.dart'
;
import
'package:flutter_tools/src/base/logger.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:meta/meta.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:platform/platform.dart'
;
import
'../../src/common.dart'
;
import
'../../src/context.dart'
;
const
Map
<
String
,
String
>
kDyLdLibEntry
=
<
String
,
String
>{
'DYLD_LIBRARY_PATH'
:
'/path/to/libs'
,
};
void
main
(
)
{
testWithoutContext
(
'IOSDevice.installApp calls ios-deploy correctly'
,
()
async
{
final
FileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
IOSApp
iosApp
=
PrebuiltIOSApp
(
projectBundleId:
'app'
,
bundleDir:
fileSystem
.
currentDirectory
,
);
final
FakeProcessManager
processManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[
const
FakeCommand
(
command:
<
String
>[
'ios-deploy'
,
'--id'
,
'1234'
,
'--bundle'
,
'/'
,
'--no-wifi'
,
],
environment:
<
String
,
String
>{
'PATH'
:
'/usr/bin:null'
,
...
kDyLdLibEntry
,
})
]);
final
IOSDevice
device
=
setUpIOSDevice
(
processManager:
processManager
,
fileSystem:
fileSystem
,
);
final
bool
wasInstalled
=
await
device
.
installApp
(
iosApp
);
expect
(
wasInstalled
,
true
);
expect
(
processManager
.
hasRemainingExpectations
,
false
);
});
testWithoutContext
(
'IOSDevice.uninstallApp calls ios-deploy correctly'
,
()
async
{
final
IOSApp
iosApp
=
PrebuiltIOSApp
(
projectBundleId:
'app'
);
final
FakeProcessManager
processManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[
const
FakeCommand
(
command:
<
String
>[
'ios-deploy'
,
'--id'
,
'1234'
,
'--uninstall_only'
,
'--bundle_id'
,
'app'
,
],
environment:
<
String
,
String
>{
'PATH'
:
'/usr/bin:null'
,
...
kDyLdLibEntry
,
})
]);
final
IOSDevice
device
=
setUpIOSDevice
(
processManager:
processManager
);
final
bool
wasUninstalled
=
await
device
.
uninstallApp
(
iosApp
);
expect
(
wasUninstalled
,
true
);
expect
(
processManager
.
hasRemainingExpectations
,
false
);
});
testWithoutContext
(
'IOSDevice.isAppInstalled catches ProcessException from ios-deploy'
,
()
async
{
final
IOSApp
iosApp
=
PrebuiltIOSApp
(
projectBundleId:
'app'
);
final
FakeProcessManager
processManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[
FakeCommand
(
command:
const
<
String
>[
'ios-deploy'
,
'--id'
,
'1234'
,
'--exists'
,
'--bundle_id'
,
'app'
,
],
environment:
const
<
String
,
String
>{
'PATH'
:
'/usr/bin:null'
,
...
kDyLdLibEntry
,
},
onRun:
()
{
throw
const
ProcessException
(
'ios-deploy'
,
<
String
>[]);
})
]);
final
IOSDevice
device
=
setUpIOSDevice
(
processManager:
processManager
);
final
bool
isAppInstalled
=
await
device
.
isAppInstalled
(
iosApp
);
expect
(
isAppInstalled
,
false
);
expect
(
processManager
.
hasRemainingExpectations
,
false
);
});
testWithoutContext
(
'IOSDevice.installApp catches ProcessException from ios-deploy'
,
()
async
{
final
FileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
IOSApp
iosApp
=
PrebuiltIOSApp
(
projectBundleId:
'app'
,
bundleDir:
fileSystem
.
currentDirectory
,
);
final
FakeProcessManager
processManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[
FakeCommand
(
command:
const
<
String
>[
'ios-deploy'
,
'--id'
,
'1234'
,
'--bundle'
,
'/'
,
'--no-wifi'
,
],
environment:
const
<
String
,
String
>{
'PATH'
:
'/usr/bin:null'
,
...
kDyLdLibEntry
,
},
onRun:
()
{
throw
const
ProcessException
(
'ios-deploy'
,
<
String
>[]);
})
]);
final
IOSDevice
device
=
setUpIOSDevice
(
processManager:
processManager
);
final
bool
wasAppInstalled
=
await
device
.
installApp
(
iosApp
);
expect
(
wasAppInstalled
,
false
);
});
testWithoutContext
(
'IOSDevice.uninstallApp catches ProcessException from ios-deploy'
,
()
async
{
final
IOSApp
iosApp
=
PrebuiltIOSApp
(
projectBundleId:
'app'
);
final
FakeProcessManager
processManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[
FakeCommand
(
command:
const
<
String
>[
'ios-deploy'
,
'--id'
,
'1234'
,
'--uninstall_only'
,
'--bundle_id'
,
'app'
,
],
environment:
const
<
String
,
String
>{
'PATH'
:
'/usr/bin:null'
,
...
kDyLdLibEntry
,
},
onRun:
()
{
throw
const
ProcessException
(
'ios-deploy'
,
<
String
>[]);
})
]);
final
IOSDevice
device
=
setUpIOSDevice
(
processManager:
processManager
);
final
bool
wasAppUninstalled
=
await
device
.
uninstallApp
(
iosApp
);
expect
(
wasAppUninstalled
,
false
);
});
}
IOSDevice
setUpIOSDevice
(
{
@required
ProcessManager
processManager
,
FileSystem
fileSystem
,
})
{
final
FakePlatform
platform
=
FakePlatform
(
operatingSystem:
'macos'
,
environment:
<
String
,
String
>{},
);
final
MockArtifacts
artifacts
=
MockArtifacts
();
final
MockCache
cache
=
MockCache
();
when
(
cache
.
dyLdLibEntry
).
thenReturn
(
kDyLdLibEntry
.
entries
.
first
);
when
(
artifacts
.
getArtifactPath
(
Artifact
.
iosDeploy
,
platform:
anyNamed
(
'platform'
)))
.
thenReturn
(
'ios-deploy'
);
return
IOSDevice
(
'1234'
,
name:
'iPhone 1'
,
logger:
BufferLogger
.
test
(),
fileSystem:
fileSystem
??
MemoryFileSystem
.
test
(),
sdkVersion:
'13.3'
,
cpuArchitecture:
DarwinArch
.
arm64
,
platform:
platform
,
iosDeploy:
IOSDeploy
(
logger:
BufferLogger
.
test
(),
platform:
platform
,
processManager:
processManager
,
artifacts:
artifacts
,
cache:
cache
,
),
artifacts:
artifacts
,
);
}
class
MockArtifacts
extends
Mock
implements
Artifacts
{}
class
MockCache
extends
Mock
implements
Cache
{}
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