Skip to content

Commit

Permalink
Merge branch 'release/2.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
jmoody committed Sep 21, 2017
2 parents 0c54f5d + 851bc52 commit 81254a2
Show file tree
Hide file tree
Showing 12 changed files with 204 additions and 170 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,6 @@ DeviceAgent.iOS/

# Gemfile used in RunLoop tests
Tests/cucumber/Gemfile*

# Gemfile used in rspec tests for CLI
Gemfile.lock
13 changes: 10 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
### 2.1.1

* Enforce correct simulator state before app life cycle events #187

### 2.1.0

Supports Xcode 9 GM.
Support for Xcode 9/iOS 11.

* Simulator#launch: launches the simulator #185

calabash/FBSimulatorControl built from this tag:

Advancing the version to create a tag from which we can release
binaries built with Xcode 9 GM.
* https://github.com/calabash/FBSimulatorControl/releases/tag/0.4.0-2017.08.18-patch-CoreSim-linking

### 2.0.2

Expand Down
62 changes: 0 additions & 62 deletions Gemfile.lock

This file was deleted.

3 changes: 3 additions & 0 deletions Tests/Integration/Devices/SimulatorTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ - (void)testLaunchSimulatorRestartsIfSimulatorIsNotCorrect {

- (void)testBoot {
expect([self.simulator boot]).to.equal(YES);

// Safe to call in state Booted
expect([self.simulator boot]).to.equal(YES);
}

- (void)testInstallPathAndContainerPathForApplication {
Expand Down
62 changes: 0 additions & 62 deletions Tests/Integration/SimulatorCLIIntegrationTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,6 @@ - (NSString *)bundleVersionForInstalledTestApp {
return plist[@"CFBundleVersion"];
}

- (void)testSetLocation {
NSArray *args = @[kProgramName, @"kill-simulator", @"-d", defaultSimUDID];
XCTAssertEqual([CLI process:args], iOSReturnStatusCodeEverythingOkay);

//Should fail: device is dead
args = @[kProgramName, @"set-location", kStockholmCoord, @"-d", defaultSimUDID];
XCTAssertEqual([CLI process:args], iOSReturnStatusCodeGenericFailure);

args = @[kProgramName, @"launch-simulator", @"-d", defaultSimUDID];
XCTAssertEqual([CLI process:args], iOSReturnStatusCodeEverythingOkay);

//Should fail: invalid coordinates
args = @[kProgramName, @"set-location", @"Banana", @"-d", defaultSimUDID];
XCTAssertEqual([CLI process:args], iOSReturnStatusCodeInvalidArguments);

args = @[kProgramName, @"set-location", kStockholmCoord, @"-d", defaultSimUDID];
XCTAssertEqual([CLI process:args], iOSReturnStatusCodeEverythingOkay);
}

// Causes deadlock when run with other tests.
//
//- (void)testStartTest {
Expand All @@ -75,49 +56,6 @@ - (void)testSetLocation {
// XCTAssertEqual([CLI process:args], iOSReturnStatusCodeEverythingOkay);
//}

- (void)testUninstall {
NSArray *args = @[kProgramName, @"kill-simulator", @"-d", defaultSimUDID];
XCTAssertEqual([CLI process:args], iOSReturnStatusCodeEverythingOkay);

args = @[kProgramName, @"uninstall", testAppID, @"-d", defaultSimUDID];
XCTAssertEqual([CLI process:args], iOSReturnStatusCodeGenericFailure);

args = @[kProgramName, @"launch-simulator", @"-d", defaultSimUDID];
XCTAssertEqual([CLI process:args], iOSReturnStatusCodeEverythingOkay);

args = @[kProgramName, @"is-installed", testAppID, @"-d", defaultSimUDID];
if ([CLI process:args] == iOSReturnStatusCodeEverythingOkay) {
args = @[kProgramName, @"install", [self.resources TestAppPath:SIM], @"-d", defaultSimUDID];
XCTAssertEqual([CLI process:args], iOSReturnStatusCodeEverythingOkay);
}

args = @[kProgramName, @"uninstall", testAppID, @"-d", defaultSimUDID];
XCTAssertEqual([CLI process:args], iOSReturnStatusCodeEverythingOkay);
}

- (void)testInstall {
NSArray *args = @[kProgramName, @"kill-simulator", @"-d", defaultSimUDID];
XCTAssertEqual([CLI process:args], iOSReturnStatusCodeEverythingOkay);

args = @[kProgramName, @"launch-simulator", @"-d", defaultSimUDID];
XCTAssertEqual([CLI process:args], iOSReturnStatusCodeEverythingOkay);

args = @[kProgramName, @"is-installed", taskyAppID, @"-d", defaultSimUDID];
if ([CLI process:args] == iOSReturnStatusCodeEverythingOkay) {
args = @[kProgramName, @"uninstall", taskyAppID, @"-d", defaultSimUDID];
XCTAssertEqual([CLI process:args], iOSReturnStatusCodeEverythingOkay);
}

args = @[kProgramName, @"install", tasky(SIM), @"-d", defaultSimUDID];
XCTAssertEqual([CLI process:args], iOSReturnStatusCodeEverythingOkay);

args = @[kProgramName, @"is-installed", taskyAppID, @"-d", defaultSimUDID];
if ([CLI process:args] == iOSReturnStatusCodeEverythingOkay) {
args = @[kProgramName, @"uninstall", taskyAppID, @"-d", defaultSimUDID];
XCTAssertEqual([CLI process:args], iOSReturnStatusCodeEverythingOkay);
}
}

- (void)testAppInfo {
NSArray *args = @[kProgramName, @"kill-simulator", @"-d", defaultSimUDID];
XCTAssertEqual([CLI process:args], iOSReturnStatusCodeEverythingOkay);
Expand Down
1 change: 0 additions & 1 deletion bin/test/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,3 @@ fi

# Disabling because they take too long to run.
#bin/test/sim

1 change: 1 addition & 0 deletions bin/test/cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ set -e
source bin/log.sh

make build
bundle update
bundle exec rspec spec
2 changes: 1 addition & 1 deletion iOSDeviceManager/Commands/VersionCommand.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#import "IDMVersionDefines.h"
#import "JSONUtils.h"

static NSString *const VERSION = @"2.1.0";
static NSString *const VERSION = @"2.1.1";
static NSString *const JSON_VERSION_FLAG = @"-j";
static NSString *const JSON_VERSION_OPTION_NAME = @"json";

Expand Down
91 changes: 56 additions & 35 deletions iOSDeviceManager/Devices/Simulator.m
Original file line number Diff line number Diff line change
Expand Up @@ -297,20 +297,34 @@ - (BOOL)boot {
return NO;
}

NSDictionary *options = @{};
SimDevice *simDevice = [self.fbSimulator device];
if (![simDevice bootWithOptions:options error:&error]) {
ConsoleWriteErr(@"Could not boot simulator");
if (error) {
ConsoleWriteErr(@"%@", [error localizedDescription]);
FBSimulatorState state = self.state;
if (state == FBSimulatorStateBooted || state == FBSimulatorStateBooting) {
if (![self waitForSimulatorState:FBSimulatorStateBooted
timeout:30]) {
ConsoleWriteErr(@"Could not boot simulator");
return NO;
} else {
return YES;
}
return NO;
} else {
if (![self waitForSimulatorState:FBSimulatorStateBooted timeout:30]) {

NSDictionary *options = @{};
SimDevice *simDevice = [self.fbSimulator device];
if (![simDevice bootWithOptions:options
error:&error]) {
ConsoleWriteErr(@"Could not boot simulator");
if (error) {
ConsoleWriteErr(@"%@", [error localizedDescription]);
}
return NO;
} else {
if (![self waitForSimulatorState:FBSimulatorStateBooted
timeout:30]) {
ConsoleWriteErr(@"Could not boot simulator");
return NO;
}
return YES;
}
return YES;
}
}

Expand Down Expand Up @@ -395,17 +409,17 @@ - (iOSReturnStatusCode)installApp:(Application *)app
codesignIdentity:(CodesignIdentity *)codesignID
resourcesToInject:(NSArray<NSString *> *)resourcePaths
shouldUpdate:(BOOL)shouldUpdate {
NSError *error = nil;
if (!self.fbSimulator) { return iOSReturnStatusCodeDeviceNotFound; }

if (self.fbSimulator.state != FBSimulatorStateBooted) {
ConsoleWriteErr(@"Simulator %@ must be booted to install an app - found state: %@",
[self uuid], self.fbSimulator.stateString);
if (![self boot]) {
ConsoleWriteErr(@"Cannot install %@ on Simulator %@ because the device could not "
"be booted", app.bundleID, [self fbSimulator]);
return iOSReturnStatusCodeGenericFailure;
}

BOOL needsToInstall = YES;

NSError *error = nil;

FBInstalledApplication *installedApp;
installedApp = [self.fbSimulator installedApplicationWithBundleID:app.bundleID
error:&error];
Expand Down Expand Up @@ -510,18 +524,19 @@ - (iOSReturnStatusCode)installApp:(Application *)app

- (iOSReturnStatusCode)uninstallApp:(NSString *)bundleID {

if (self.fbSimulator == nil) {
ConsoleWriteErr(@"No such simulator exists!");
return iOSReturnStatusCodeDeviceNotFound;
}
// uninstalling an app when the Simulator.app is running will cause the
// app bundle to be removed, but CoreSimulator will report the app is
// still installed.
[Simulator killSimulatorApp];

if (self.fbSimulator.state == FBSimulatorStateShutdown ||
self.fbSimulator.state == FBSimulatorStateShuttingDown) {
ConsoleWriteErr(@"Simulator %@ is dead. Must launch before uninstalling apps.", [self uuid]);
if (![self boot]) {
ConsoleWriteErr(@"Cannot uninstall app %@ from %@ because the Simulator"
" failed to boot", bundleID, [self fbSimulator]);
return iOSReturnStatusCodeGenericFailure;
}

if (![self.fbSimulator installedApplicationWithBundleID:bundleID error:nil]) {
if (![self.fbSimulator installedApplicationWithBundleID:bundleID
error:nil]) {
ConsoleWriteErr(@"App %@ is not installed on %@", bundleID, [self uuid]);
return iOSReturnStatusCodeGenericFailure;
}
Expand All @@ -530,7 +545,8 @@ - (iOSReturnStatusCode)uninstallApp:(NSString *)bundleID {
applicationCommands = [Simulator applicationCommandsWithFBSimulator:self.fbSimulator];

NSError *error = nil;
if (![applicationCommands uninstallApplicationWithBundleID:bundleID error:&error]) {
if (![applicationCommands uninstallApplicationWithBundleID:bundleID
error:&error]) {
ConsoleWriteErr(@"Error uninstalling app: %@", error);
return iOSReturnStatusCodeInternalError;
} else {
Expand All @@ -541,21 +557,26 @@ - (iOSReturnStatusCode)uninstallApp:(NSString *)bundleID {
- (iOSReturnStatusCode)simulateLocationWithLat:(double)lat
lng:(double)lng {

if (self.fbSimulator == nil) {
ConsoleWriteErr(@"No such simulator exists!");
return iOSReturnStatusCodeDeviceNotFound;
}

if (self.fbSimulator.state == FBSimulatorStateShutdown ||
self.fbSimulator.state == FBSimulatorStateShuttingDown) {
ConsoleWriteErr(@"Sim is dead! Must boot first");
// Set the Location to a default location, when launched directly.
// This is effectively done by Simulator.app by a NSUserDefault with for the
// 'LocationMode', even when the location is 'None'. If the Location is set on the
// Simulator, then CLLocationManager will behave in a consistent manner inside
// launched Applications.
if (![self boot]) {
ConsoleWriteErr(@"Cannot set the location on the %@ simulator because the device "
"would not boot",
[self fbSimulator]);
return iOSReturnStatusCodeGenericFailure;
}

NSError *e = nil;
FBSimulatorBridge *bridge = [FBSimulatorBridge bridgeForSimulator:self.fbSimulator error:&e];
if (e || !bridge) {
ConsoleWriteErr(@"Unable to fetch simulator bridge: %@", e);
NSError *error = nil;
FBSimulatorBridge *bridge = [FBSimulatorBridge bridgeForSimulator:self.fbSimulator
error:&error];
if (!bridge) {
ConsoleWriteErr(@"Unable to fetch simulator bridge: %@");
if (error) {
ConsoleWriteErr(@"%@", [error localizedDescription]);
}
return iOSReturnStatusCodeInternalError;
}

Expand Down
20 changes: 14 additions & 6 deletions spec/resources.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ def default_simulator

def random_iphone
simctl.simulators.select do |sim|
sim.name[/iPhone/] && sim.version >= RunLoop::Version.new("10.0")
sim.name[/iPhone/] &&
sim.version >= RunLoop::Version.new("10.0") &&
sim.udid != default_simulator.udid
end.sample
end

Expand All @@ -91,17 +93,23 @@ def test_app(type)

case type
when :arm
app = File.join(resources_dir, "arm", "TestApp.app")
source = File.join(resources_dir, "arm", "TestApp.app")
target = File.join(tmp_dir("arm"), "TestApp.app")
when :x86
app = File.join(resources_dir, "sim", "TestApp.app")
source = File.join(resources_dir, "sim", "TestApp.app")
target = File.join(tmp_dir("sim"), "TestApp.app")
when :ipa
app = File.join(resources_dir, "arm", "TestApp.ipa")
source = File.join(resources_dir, "arm", "TestApp.ipa")
target = File.join(tmp_dir("arm"), "TestApp.ipa")
else
raise ArgumentError, "Expected :arm, :x86, or :ipa, found: #{type}"
end

@test_app_hash[type] = app
app
FileUtils.rm_rf(target)
FileUtils.cp_r(source, target)

@test_app_hash[type] = target
target
end

def device_compatible_with_xcode?(device, xcode)
Expand Down
Loading

0 comments on commit 81254a2

Please sign in to comment.