This commit is contained in:
lawrencelomax 2016-01-28 19:13:52 +00:00
Родитель c387e52e3e
Коммит e519a689dd
23 изменённых файлов: 89 добавлений и 414 удалений

Просмотреть файл

@ -118,9 +118,6 @@
AA95179C1C15F54600A89CAD /* FBProcessQuery+Simulators.m in Sources */ = {isa = PBXBuildFile; fileRef = AA95171E1C15F54600A89CAD /* FBProcessQuery+Simulators.m */; };
AA95179D1C15F54600A89CAD /* FBProcessQuery.h in Headers */ = {isa = PBXBuildFile; fileRef = AA95171F1C15F54600A89CAD /* FBProcessQuery.h */; settings = {ATTRIBUTES = (Public, ); }; };
AA95179E1C15F54600A89CAD /* FBProcessQuery.m in Sources */ = {isa = PBXBuildFile; fileRef = AA9517201C15F54600A89CAD /* FBProcessQuery.m */; };
AA9517A11C15F54600A89CAD /* FBSimulatorSession+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = AA9517241C15F54600A89CAD /* FBSimulatorSession+Private.h */; settings = {ATTRIBUTES = (Public, ); }; };
AA9517A21C15F54600A89CAD /* FBSimulatorSession.h in Headers */ = {isa = PBXBuildFile; fileRef = AA9517251C15F54600A89CAD /* FBSimulatorSession.h */; settings = {ATTRIBUTES = (Public, ); }; };
AA9517A31C15F54600A89CAD /* FBSimulatorSession.m in Sources */ = {isa = PBXBuildFile; fileRef = AA9517261C15F54600A89CAD /* FBSimulatorSession.m */; };
AA9517A41C15F54600A89CAD /* FBTask+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = AA9517281C15F54600A89CAD /* FBTask+Private.h */; settings = {ATTRIBUTES = (Public, ); }; };
AA9517A51C15F54600A89CAD /* FBTask.h in Headers */ = {isa = PBXBuildFile; fileRef = AA9517291C15F54600A89CAD /* FBTask.h */; settings = {ATTRIBUTES = (Public, ); }; };
AA9517A61C15F54600A89CAD /* FBTask.m in Sources */ = {isa = PBXBuildFile; fileRef = AA95172A1C15F54600A89CAD /* FBTask.m */; };
@ -924,9 +921,6 @@
AA95171E1C15F54600A89CAD /* FBProcessQuery+Simulators.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "FBProcessQuery+Simulators.m"; sourceTree = "<group>"; };
AA95171F1C15F54600A89CAD /* FBProcessQuery.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FBProcessQuery.h; sourceTree = "<group>"; };
AA9517201C15F54600A89CAD /* FBProcessQuery.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FBProcessQuery.m; sourceTree = "<group>"; };
AA9517241C15F54600A89CAD /* FBSimulatorSession+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "FBSimulatorSession+Private.h"; sourceTree = "<group>"; };
AA9517251C15F54600A89CAD /* FBSimulatorSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FBSimulatorSession.h; sourceTree = "<group>"; };
AA9517261C15F54600A89CAD /* FBSimulatorSession.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FBSimulatorSession.m; sourceTree = "<group>"; };
AA9517281C15F54600A89CAD /* FBTask+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "FBTask+Private.h"; sourceTree = "<group>"; };
AA9517291C15F54600A89CAD /* FBTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FBTask.h; sourceTree = "<group>"; };
AA95172A1C15F54600A89CAD /* FBTask.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FBTask.m; sourceTree = "<group>"; };
@ -1733,7 +1727,6 @@
AA95170A1C15F54600A89CAD /* Model */,
AA9517171C15F54600A89CAD /* Notifiers */,
AA95171C1C15F54600A89CAD /* Processes */,
AA9517211C15F54600A89CAD /* Session */,
AA9517271C15F54600A89CAD /* Tasks */,
AA9517321C15F54600A89CAD /* Tiling */,
AA9517391C15F54600A89CAD /* Utility */,
@ -1914,16 +1907,6 @@
path = Processes;
sourceTree = "<group>";
};
AA9517211C15F54600A89CAD /* Session */ = {
isa = PBXGroup;
children = (
AA9517241C15F54600A89CAD /* FBSimulatorSession+Private.h */,
AA9517251C15F54600A89CAD /* FBSimulatorSession.h */,
AA9517261C15F54600A89CAD /* FBSimulatorSession.m */,
);
path = Session;
sourceTree = "<group>";
};
AA9517271C15F54600A89CAD /* Tasks */ = {
isa = PBXGroup;
children = (
@ -2124,14 +2107,12 @@
AA7490051C4E6CBA00F3BDBA /* FBSimulatorLaunchConfiguration+Private.h in Headers */,
AA95179D1C15F54600A89CAD /* FBProcessQuery.h in Headers */,
AAD497851C50F0BB00ABC1A7 /* FBJSONSerializationDescribeable.h in Headers */,
AA9517A11C15F54600A89CAD /* FBSimulatorSession+Private.h in Headers */,
AA78DCDA1C5005D2006FAB41 /* FBSimulatorLaunchCtl.h in Headers */,
AA2219951C3E752800371B01 /* FBCoreSimulatorTerminationStrategy.h in Headers */,
AA9517871C15F54600A89CAD /* FBSimulatorPredicates.h in Headers */,
AA9517811C15F54600A89CAD /* FBSimulatorControl+PrincipalClass.h in Headers */,
AA9517BA1C15F54600A89CAD /* FBSimulatorLogger.h in Headers */,
AAB207C01C2099A9007C7908 /* FBSimulatorLoggingEventSink.h in Headers */,
AA9517A21C15F54600A89CAD /* FBSimulatorSession.h in Headers */,
AA2219911C3D868300371B01 /* FBProcessTerminationStrategy.h in Headers */,
AA4242F91C529280008ABD80 /* FBFramebufferDebugWindow.h in Headers */,
AA9517BC1C15F54600A89CAD /* NSRunLoop+SimulatorControlAdditions.h in Headers */,
@ -2289,7 +2270,6 @@
AA1D653F1C21A9690069F90D /* FBCollectionDescriptions.m in Sources */,
AA95174B1C15F54600A89CAD /* FBProcessLaunchConfiguration.m in Sources */,
AA1D65471C21CD2A0069F90D /* FBASLParser.m in Sources */,
AA9517A31C15F54600A89CAD /* FBSimulatorSession.m in Sources */,
AA9517BF1C15F54600A89CAD /* FBSimulatorVideoRecorder.m in Sources */,
AA95178F1C15F54600A89CAD /* FBSimulatorApplication.m in Sources */,
AAF2D3571C33EA3100434516 /* FBSimulatorInteraction+Lifecycle.m in Sources */,

Просмотреть файл

@ -78,8 +78,6 @@
#import <FBSimulatorControl/FBSimulatorPool.h>
#import <FBSimulatorControl/FBSimulatorPredicates.h>
#import <FBSimulatorControl/FBSimulatorResourceManager.h>
#import <FBSimulatorControl/FBSimulatorSession+Private.h>
#import <FBSimulatorControl/FBSimulatorSession.h>
#import <FBSimulatorControl/FBSimulatorTerminationStrategy.h>
#import <FBSimulatorControl/FBSimulatorVideoRecorder.h>
#import <FBSimulatorControl/FBSimulatorWindowHelpers.h>

Просмотреть файл

@ -16,8 +16,6 @@
#import "FBSimulatorHistory+Queries.h"
#import "FBSimulatorInteraction+Private.h"
#import "FBSimulatorLogs.h"
#import "FBSimulatorSession+Private.h"
#import "FBSimulatorSession.h"
#import "FBTaskExecutor.h"
#import "FBWritableLog.h"

Просмотреть файл

@ -35,7 +35,6 @@
#import "FBSimulatorLaunchConfiguration.h"
#import "FBSimulatorLogger.h"
#import "FBSimulatorPool.h"
#import "FBSimulatorSession+Private.h"
#import "FBSimulatorTerminationStrategy.h"
#import "FBTaskExecutor.h"

Просмотреть файл

@ -21,7 +21,6 @@
#import "FBSimulatorInteraction+Applications.h"
#import "FBSimulatorInteraction+Private.h"
#import "FBSimulatorPool.h"
#import "FBSimulatorSession.h"
#import "NSRunLoop+SimulatorControlAdditions.h"
@implementation FBSimulatorInteraction (Upload)

Просмотреть файл

@ -27,7 +27,6 @@
#import "FBSimulatorError.h"
#import "FBSimulatorEventSink.h"
#import "FBSimulatorPool.h"
#import "FBSimulatorSession+Private.h"
#import "FBSimulatorTerminationStrategy.h"
#import "FBTaskExecutor.h"

Просмотреть файл

@ -18,7 +18,6 @@
#import "FBProcessInfo.h"
#import "FBSimulator.h"
#import "FBSimulatorHistory+Queries.h"
#import "FBSimulatorSession.h"
#import "FBTaskExecutor.h"
#import "FBWritableLog.h"

Просмотреть файл

@ -14,7 +14,6 @@
@class FBSimulatorApplication;
@class FBSimulatorConfiguration;
@class FBSimulatorControlConfiguration;
@class FBSimulatorSession;
@protocol FBSimulatorLogger;
/**
@ -64,14 +63,14 @@
#pragma mark Session
/**
Creates and returns a new FBSimulatorSession instance. Does not launch the Simulator or any Applications.
Obtains a Simulator for the given configuration and allocation options from the pool.
@param simulatorConfiguration the Configuration of the Simulator to Launch.
@param options the options to for the allocation/freeing of the Simulator.
@param error an outparam for describing any error that occured during the creation of the Session.
@returns A new `FBSimulatorSession` instance, or nil if an error occured.
@returns A FBSimulator instance, or nil if an error occured.
*/
- (FBSimulatorSession *)createSessionForSimulatorConfiguration:(FBSimulatorConfiguration *)simulatorConfiguration options:(FBSimulatorAllocationOptions)options error:(NSError **)error;
- (FBSimulator *)obtainSimulatorWithConfiguration:(FBSimulatorConfiguration *)simulatorConfiguration options:(FBSimulatorAllocationOptions)options error:(NSError **)error;
#pragma mark Properties

Просмотреть файл

@ -26,7 +26,6 @@
#import "FBSimulatorHistory.h"
#import "FBSimulatorLogger.h"
#import "FBSimulatorPool.h"
#import "FBSimulatorSession.h"
@implementation FBSimulatorControl
@ -133,7 +132,7 @@
#pragma mark Sessions
- (FBSimulatorSession *)createSessionForSimulatorConfiguration:(FBSimulatorConfiguration *)simulatorConfiguration options:(FBSimulatorAllocationOptions)options error:(NSError **)error;
- (FBSimulator *)obtainSimulatorWithConfiguration:(FBSimulatorConfiguration *)simulatorConfiguration options:(FBSimulatorAllocationOptions)options error:(NSError **)error;
{
NSParameterAssert(simulatorConfiguration);
@ -142,7 +141,7 @@
if (!simulator) {
return [FBSimulatorError failWithError:innerError errorOut:error];
}
return [FBSimulatorSession sessionWithSimulator:simulator];
return simulator;
}
#pragma mark Private Methods

Просмотреть файл

@ -14,7 +14,6 @@
#import "FBProcessLaunchConfiguration.h"
#import "FBSimulator+Helpers.h"
#import "FBSimulatorApplication.h"
#import "FBSimulatorSession.h"
NSString *const FBSimulatorHistoryDiagnosticNameTerminationStatus = @"termination_status";

Просмотреть файл

@ -1,34 +0,0 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import <Foundation/Foundation.h>
#import <FBSimulatorControl/FBSimulatorHistoryGenerator.h>
#import <FBSimulatorControl/FBSimulatorSession.h>
@interface FBSimulatorSession ()
@property (nonatomic, strong, readwrite) FBSimulator *simulator;
@property (nonatomic, strong, readwrite) NSUUID *uuid;
- (void)fireNotificationNamed:(NSString *)name;
@end
@interface FBSimulatorSession_NotStarted : FBSimulatorSession
@end
@interface FBSimulatorSession_Started : FBSimulatorSession
@end
@interface FBSimulatorSession_Ended : FBSimulatorSession
@end

Просмотреть файл

@ -1,73 +0,0 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import <Foundation/Foundation.h>
@class FBSimulator;
@class FBSimulatorHistory;
@class FBSimulatorInteraction;
@class FBSimulatorSessionLogs;
typedef NS_ENUM(NSInteger, FBSimulatorSessionState) {
FBSimulatorSessionStateNotStarted,
FBSimulatorSessionStateStarted,
FBSimulatorSessionStateEnded
};
/**
Notification that is fired when a Session starts Successfully.
*/
extern NSString *const FBSimulatorSessionDidStartNotification;
/**
Notification that is fired when a Session ends.
*/
extern NSString *const FBSimulatorSessionDidEndNotification;
/**
Represents the lifecycle of a connection to a Simulator.
A Session is inert, until `start` is called.
*/
@interface FBSimulatorSession : NSObject
/**
Creates a new `FBSimulatorSession` with the provided parameters. Will not launch a session until `start:` is called.
@param simulator the Simulator to manage the session for.
@returns a new `FBSimulatorSession`.
*/
+ (instancetype)sessionWithSimulator:(FBSimulator *)simulator;
/**
The Simulator for this session
*/
@property (nonatomic, strong, readonly) FBSimulator *simulator;
/**
Returns the Session Information for the reciever.
*/
@property (nonatomic, strong, readonly) FBSimulatorHistory *history;
/**
Returns the state of the Session.
*/
@property (nonatomic, assign, readonly) FBSimulatorSessionState state;
/**
Returns an Interaction for Interacting with the Sessions.
*/
- (FBSimulatorInteraction *)interact;
/**
Terminates the Session, freeing any allocated resources.
*/
- (BOOL)terminateWithError:(NSError **)error;
@end

Просмотреть файл

@ -1,163 +0,0 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import "FBSimulatorSession.h"
#import "FBSimulatorSession+Private.h"
#import <objc/runtime.h>
#import "FBSimulator+Helpers.h"
#import "FBSimulator+Private.h"
#import "FBSimulator.h"
#import "FBSimulatorApplication.h"
#import "FBSimulatorControl.h"
#import "FBSimulatorControlConfiguration.h"
#import "FBSimulatorError.h"
#import "FBSimulatorEventRelay.h"
#import "FBSimulatorHistory+Private.h"
#import "FBSimulatorHistory.h"
#import "FBSimulatorInteraction.h"
#import "FBSimulatorLogs.h"
#import "FBSimulatorNotificationEventSink.h"
NSString *const FBSimulatorSessionDidStartNotification = @"FBSimulatorSessionDidStartNotification";
NSString *const FBSimulatorSessionDidEndNotification = @"FBSimulatorSessionDidEndNotification";
@implementation FBSimulatorSession_NotStarted
- (FBSimulatorInteraction *)interact
{
object_setClass(self, FBSimulatorSession_Started.class);
[self fireNotificationNamed:FBSimulatorSessionDidStartNotification];
return [self interact];
}
- (BOOL)terminateWithError:(NSError **)error
{
return [FBSimulatorError failBoolWithErrorMessage:@"Cannot Terminate an session that hasn't started" errorOut:error];
}
- (NSString *)description
{
return [NSString stringWithFormat:
@"Session (Not Started): Simulator %@",
self.simulator
];
}
- (FBSimulatorSessionState)state
{
return FBSimulatorSessionStateNotStarted;
}
@end
@implementation FBSimulatorSession_Started
- (FBSimulatorInteraction *)interact
{
return [FBSimulatorInteraction withSimulator:self.simulator];
}
- (BOOL)terminateWithError:(NSError **)error
{
object_setClass(self, FBSimulatorSession_Ended.class);
BOOL result = [self.simulator freeFromPoolWithError:error];
[self fireNotificationNamed:FBSimulatorSessionDidEndNotification];
return result;
}
- (NSString *)description
{
return [NSString stringWithFormat:
@"Session (Started): Simulator %@",
self.simulator
];
}
- (FBSimulatorSessionState)state
{
return FBSimulatorSessionStateStarted;
}
@end
@implementation FBSimulatorSession_Ended
- (BOOL)terminateWithError:(NSError **)error
{
return [FBSimulatorError failBoolWithErrorMessage:@"Cannot Terminate an already Ended session" errorOut:error];
}
- (NSString *)description
{
return [NSString stringWithFormat:
@"Session (Ended): Simulator %@",
self.simulator
];
}
- (FBSimulatorSessionState)state
{
return FBSimulatorSessionStateEnded;
}
@end
@implementation FBSimulatorSession
#pragma mark - Initializers
+ (instancetype)sessionWithSimulator:(FBSimulator *)simulator
{
return [[FBSimulatorSession_NotStarted alloc] initWithSimulator:simulator];
}
- (instancetype)initWithSimulator:(FBSimulator *)simulator
{
NSParameterAssert(simulator);
self = [super init];
if (!self) {
return nil;
}
_simulator = simulator;
_uuid = NSUUID.UUID;
return self;
}
#pragma mark - Public Interface
- (FBSimulatorHistory *)history
{
return self.simulator.history;
}
- (FBSimulatorInteraction *)interact
{
NSAssert(NO, @"-[%@ %@] is abstract and should be overridden", NSStringFromClass(self.class), NSStringFromSelector(_cmd));
return nil;
}
- (BOOL)terminateWithError:(NSError **)error
{
NSAssert(NO, @"-[%@ %@] is abstract and should be overridden", NSStringFromClass(self.class), NSStringFromSelector(_cmd));
return NO;
}
#pragma mark Private
- (void)fireNotificationNamed:(NSString *)name
{
[NSNotificationCenter.defaultCenter postNotificationName:name object:self];
}
@end

Просмотреть файл

@ -30,20 +30,18 @@
- (void)testGetsArgumentsOfSimulatorContainerProcess
{
FBSimulatorSession *session = [self createBootedSession];
FBSimulator *simulator = session.simulator;
FBSimulator *simulator = [self obtainBootedSimulator];
FBProcessInfo *containerProcess = simulator.containerApplication;
XCTAssertNotNil(containerProcess);
NSSet *arguments = [NSSet setWithArray:containerProcess.arguments];
XCTAssertTrue([arguments containsObject:session.simulator.udid]);
XCTAssertTrue([arguments containsObject:simulator.udid]);
}
- (void)testUpdatesContainerProcessOnTermination
{
FBSimulatorSession *session = [self createBootedSession];
FBSimulator *simulator = session.simulator;
FBSimulator *simulator = [self obtainBootedSimulator];
[NSRunLoop.currentRunLoop spinRunLoopWithTimeout:FBSimulatorControlGlobalConfiguration.fastTimeout untilTrue:^{
return NO;
@ -69,11 +67,11 @@
return;
}
FBSimulatorSession *session = [self createSession];
FBSimulator *simulator = [self obtainBootedSimulator];
[self assertInteractionSuccessful:[session.interact.bootSimulator launchApplication:self.safariAppLaunch]];
[self assertInteractionSuccessful:[simulator.interact.bootSimulator launchApplication:self.safariAppLaunch]];
FBProcessInfo *process = [session.history runningProcessForApplication:self.safariApplication];
FBProcessInfo *process = [simulator.history runningProcessForApplication:self.safariApplication];
XCTAssertNotNil(process);
if (!process) {
// Need to guard against continuing the test in case the PID is 0 or -1 to avoid nuking the machine.
@ -85,7 +83,7 @@
NSNotification *actual = [self.assert consumeNotification:FBSimulatorApplicationProcessDidTerminateNotification timeout:20];
XCTAssertFalse([actual.userInfo[FBSimulatorExpectedTerminationKey] boolValue]);
XCTAssertNil([session.history runningProcessForApplication:self.safariApplication]);
XCTAssertNil([simulator.history runningProcessForApplication:self.safariApplication]);
}
- (void)testNotifiedByExpectedApplicationTermination
@ -94,12 +92,12 @@
return;
}
FBSimulatorSession *session = [self createSession];
FBSimulator *simulator = [self obtainSimulator];
FBApplicationLaunchConfiguration *appLaunch = self.safariAppLaunch;
[self assertInteractionSuccessful:[session.interact.bootSimulator launchApplication:appLaunch]];
[self assertInteractionSuccessful:[simulator.interact.bootSimulator launchApplication:appLaunch]];
FBProcessInfo *process = [session.history runningProcessForApplication:self.safariApplication];
FBProcessInfo *process = [simulator.history runningProcessForApplication:self.safariApplication];
XCTAssertNotNil(process);
if (!process) {
// Need to guard against continuing the test in case the PID is 0 or -1 to avoid nuking the machine.
@ -107,11 +105,11 @@
}
[self.assert consumeAllNotifications];
[self assertInteractionSuccessful:[session.interact killProcess:process]];
[self assertInteractionSuccessful:[simulator.interact killProcess:process]];
NSNotification *actual = [self.assert consumeNotification:FBSimulatorApplicationProcessDidTerminateNotification timeout:20];
XCTAssertTrue([actual.userInfo[FBSimulatorExpectedTerminationKey] boolValue]);
XCTAssertNil([session.history runningProcessForApplication:self.safariApplication]);
XCTAssertNil([simulator.history runningProcessForApplication:self.safariApplication]);
}
@end

Просмотреть файл

@ -23,20 +23,20 @@
- (void)testPhotoUpload
{
FBSimulatorSession *session = [self createBootedSession];
[self assertInteractionSuccessful:[session.interact uploadPhotos:@[FBSimulatorControlFixtures.photo0Path, FBSimulatorControlFixtures.photo1Path]]];
FBSimulator *simulator = [self obtainBootedSimulator];
[self assertInteractionSuccessful:[simulator.interact uploadPhotos:@[FBSimulatorControlFixtures.photo0Path, FBSimulatorControlFixtures.photo1Path]]];
}
- (void)testVideoUploadSuccess
{
FBSimulatorSession *session = [self createBootedSession];
[self assertInteractionSuccessful:[session.interact uploadVideos:@[FBSimulatorControlFixtures.video0Path]]];
FBSimulator *simulator = [self obtainBootedSimulator];
[self assertInteractionSuccessful:[simulator.interact uploadVideos:@[FBSimulatorControlFixtures.video0Path]]];
}
- (void)testVideoUploadFailure
{
FBSimulatorSession *session = [self createBootedSession];
[self assertInteractionFailed:[session.interact uploadVideos:@[FBSimulatorControlFixtures.photo0Path]]];
FBSimulator *simulator = [self obtainBootedSimulator];
[self assertInteractionFailed:[simulator.interact uploadVideos:@[FBSimulatorControlFixtures.photo0Path]]];
}
@end

Просмотреть файл

@ -24,32 +24,32 @@
- (void)testLaunchesSafariApplication
{
FBSimulatorSession *session = [self createSession];
FBSimulator *simulator = [self obtainSimulator];
FBApplicationLaunchConfiguration *appLaunch = self.safariAppLaunch;
[self.assert consumeAllNotifications];
[self assertInteractionSuccessful:[[session.interact bootSimulator:self.simulatorLaunchConfiguration] launchApplication:appLaunch]];
[self assertInteractionSuccessful:[[simulator.interact bootSimulator:self.simulatorLaunchConfiguration] launchApplication:appLaunch]];
[self.assert bootingNotificationsFired];
[self.assert consumeNotification:FBSimulatorApplicationProcessDidLaunchNotification];
[self.assert noNotificationsToConsume];
[self assertSimulatorBooted:session.simulator];
[self assertSimulatorBooted:simulator];
}
- (void)testRelaunchesSafariApplication
{
FBSimulatorSession *session = [self createSession];
FBSimulator *simulator = [self obtainSimulator];
FBApplicationLaunchConfiguration *appLaunch = self.safariAppLaunch;
[self.assert consumeAllNotifications];
[self assertInteractionSuccessful:[[session.interact bootSimulator:self.simulatorLaunchConfiguration] launchApplication:appLaunch]];
[self assertInteractionSuccessful:[[simulator.interact bootSimulator:self.simulatorLaunchConfiguration] launchApplication:appLaunch]];
[self.assert bootingNotificationsFired];
[self.assert consumeNotification:FBSimulatorApplicationProcessDidLaunchNotification];
[self.assert noNotificationsToConsume];
[self assertSimulatorBooted:session.simulator];
[self assertSimulatorBooted:simulator];
[self assertInteractionSuccessful:session.interact.relaunchLastLaunchedApplication];
[self assertInteractionSuccessful:simulator.interact.relaunchLastLaunchedApplication];
[self.assert consumeNotification:FBSimulatorApplicationProcessDidTerminateNotification];
[self.assert consumeNotification:FBSimulatorApplicationProcessDidLaunchNotification];
@ -58,18 +58,18 @@
- (void)testLaunchesSampleApplication
{
FBSimulatorSession *session = [self createSession];
FBSimulator *simulator = [self obtainSimulator];
FBSimulatorApplication *application = self.tableSearchApplication;
FBApplicationLaunchConfiguration *appLaunch = self.tableSearchAppLaunch;
[self.assert consumeAllNotifications];
[self assertInteractionSuccessful:[[[session.interact bootSimulator:self.simulatorLaunchConfiguration] installApplication:application] launchApplication:appLaunch]];
[self assertLastLaunchedApplicationIsRunning:session.simulator];
[self assertInteractionSuccessful:[[[simulator.interact bootSimulator:self.simulatorLaunchConfiguration] installApplication:application] launchApplication:appLaunch]];
[self assertLastLaunchedApplicationIsRunning:simulator];
[self.assert bootingNotificationsFired];
[self.assert consumeNotification:FBSimulatorApplicationProcessDidLaunchNotification];
[self.assert noNotificationsToConsume];
[self assertSimulatorBooted:session.simulator];
[self assertSimulatorBooted:simulator];
}
- (void)testLaunchesSingleSimulator:(FBSimulatorConfiguration *)configuration
@ -80,19 +80,19 @@
return;
}
FBSimulatorSession *session = [self createSessionWithConfiguration:configuration];
FBSimulator *simulator = [self obtainSimulatorWithConfiguration:configuration];
[self.assert noNotificationsToConsume];
[self assertInteractionSuccessful:[session.interact bootSimulator:self.simulatorLaunchConfiguration]];
[self assertInteractionSuccessful:[simulator.interact bootSimulator:self.simulatorLaunchConfiguration]];
[self.assert bootingNotificationsFired];
[self.assert noNotificationsToConsume];
XCTAssertEqual(session.simulator.state, FBSimulatorStateBooted);
XCTAssertEqual(session.history.launchedAgentProcesses.count, 0u);
XCTAssertEqual(session.history.launchedApplicationProcesses.count, 0u);
[self assertSimulatorBooted:session.simulator];
XCTAssertEqual(simulator.state, FBSimulatorStateBooted);
XCTAssertEqual(simulator.history.launchedAgentProcesses.count, 0u);
XCTAssertEqual(simulator.history.launchedApplicationProcesses.count, 0u);
[self assertSimulatorBooted:simulator];
[self assertShutdownSimulatorAndTerminateSession:session];
[self assertShutdownSimulatorAndTerminateSession:simulator];
[self.assert shutdownNotificationsFired];
[self.assert noNotificationsToConsume];
}
@ -121,33 +121,28 @@
{
// Simulator Pool management is single threaded since it relies on unsynchronised mutable state
// Create the sessions in sequence, then boot them in paralell.
FBSimulatorSession *session1 = [self createSessionWithConfiguration:FBSimulatorConfiguration.iPhone5];
XCTAssertEqual(session1.state, FBSimulatorSessionStateNotStarted);
FBSimulatorSession *session2 = [self createSessionWithConfiguration:FBSimulatorConfiguration.iPhone5];
XCTAssertEqual(session2.state, FBSimulatorSessionStateNotStarted);
FBSimulatorSession *session3 = [self createSessionWithConfiguration:FBSimulatorConfiguration.iPad2];
XCTAssertEqual(session3.state, FBSimulatorSessionStateNotStarted);
FBSimulator *simulator1 = [self obtainSimulatorWithConfiguration:FBSimulatorConfiguration.iPhone5];
FBSimulator *simulator2 = [self obtainSimulatorWithConfiguration:FBSimulatorConfiguration.iPhone5];
FBSimulator *simulator3 = [self obtainSimulatorWithConfiguration:FBSimulatorConfiguration.iPad2];
XCTAssertEqual(self.control.simulatorPool.allocatedSimulators.count, 3u);
XCTAssertEqual(([[NSSet setWithArray:@[session1.simulator.udid, session2.simulator.udid, session3.simulator.udid]] count]), 3u);
XCTAssertEqual(([[NSSet setWithArray:@[simulator1.udid, simulator2.udid, simulator3.udid]] count]), 3u);
[self assertInteractionSuccessful:[session1.interact bootSimulator:self.simulatorLaunchConfiguration]];
[self assertInteractionSuccessful:[session2.interact bootSimulator:self.simulatorLaunchConfiguration]];
[self assertInteractionSuccessful:[session3.interact bootSimulator:self.simulatorLaunchConfiguration]];
[self assertInteractionSuccessful:[simulator1.interact bootSimulator:self.simulatorLaunchConfiguration]];
[self assertInteractionSuccessful:[simulator2.interact bootSimulator:self.simulatorLaunchConfiguration]];
[self assertInteractionSuccessful:[simulator3.interact bootSimulator:self.simulatorLaunchConfiguration]];
NSArray *sessions = @[session1, session2, session3];
for (FBSimulatorSession *session in sessions) {
XCTAssertEqual(session.history.launchedAgentProcesses.count, 0u);
XCTAssertEqual(session.history.launchedApplicationProcesses.count, 0u);
[self assertSimulatorBooted:session.simulator];
NSArray *simulators = @[simulator1, simulator2, simulator3];
for (FBSimulator *simulator in simulators) {
XCTAssertEqual(simulator.history.launchedAgentProcesses.count, 0u);
XCTAssertEqual(simulator.history.launchedApplicationProcesses.count, 0u);
[self assertSimulatorBooted:simulator];
}
XCTAssertEqual([NSSet setWithArray:[sessions valueForKeyPath:@"simulator.launchdSimProcess.processIdentifier"]].count, 3u);
XCTAssertEqual([NSSet setWithArray:[simulators valueForKeyPath:@"launchdSimProcess.processIdentifier"]].count, 3u);
for (FBSimulatorSession *session in sessions) {
[self assertShutdownSimulatorAndTerminateSession:session];
for (FBSimulator *simulator in simulators) {
[self assertShutdownSimulatorAndTerminateSession:simulator];
}
XCTAssertEqual(self.control.simulatorPool.allocatedSimulators.count, 0u);

Просмотреть файл

@ -42,15 +42,15 @@
return;
}
FBSimulatorSession *session = [self createBootedSession];
FBSimulator *simulator = [self obtainBootedSimulator];
FBApplicationLaunchConfiguration *appLaunch = [self.tableSearchAppLaunch.injectingShimulator withEnvironmentAdditions:@{@"SHIMULATOR_CRASH_AFTER" : @"1"}];
[self assertInteractionSuccessful:[[session.interact installApplication:self.tableSearchApplication] launchApplication:appLaunch]];
[self assertInteractionSuccessful:[[simulator.interact installApplication:self.tableSearchApplication] launchApplication:appLaunch]];
// Shimulator sends an unrecognized selector to NSFileManager to cause a crash.
// The CrashReporter service is a background service as it will symbolicate in a separate process.
[self assertFindsNeedle:@"-[NSFileManager stringWithFormat:]" fromHaystackBlock:^ NSString * {
return [[session.simulator.logs.userLaunchedProcessCrashesSinceLastLaunch firstObject] asString];
return [[simulator.logs.userLaunchedProcessCrashesSinceLastLaunch firstObject] asString];
}];
}
@ -60,10 +60,10 @@
return;
}
FBSimulatorSession *session = [self createBootedSession];
FBSimulator *simulator = [self obtainBootedSimulator];
[self assertFindsNeedle:@"syslogd" fromHaystackBlock:^ NSString * {
return session.simulator.logs.syslog.asString;
return simulator.logs.syslog.asString;
}];
}
@ -73,12 +73,12 @@
return;
}
FBSimulatorSession *session = [self createBootedSession];
FBSimulator *simulator = [self obtainBootedSimulator];
FBApplicationLaunchConfiguration *appLaunch = self.tableSearchAppLaunch.injectingShimulator;
[self assertInteractionSuccessful:[[session.interact installApplication:self.tableSearchApplication] launchApplication:appLaunch]];
[self assertInteractionSuccessful:[[simulator.interact installApplication:self.tableSearchApplication] launchApplication:appLaunch]];
[self assertFindsNeedle:@"Shimulator" fromHaystackBlock:^ NSString * {
return [[session.simulator.logs.launchedProcessLogs.allValues firstObject] asString];
return [[simulator.logs.launchedProcessLogs.allValues firstObject] asString];
}];
}

Просмотреть файл

@ -47,12 +47,12 @@
FBSimulatorAllocationOptions options = self.allocationOptions;
self.allocationOptions = options | FBSimulatorAllocationOptionsEraseOnFree;
FBSimulator *simulator = [self createSession].simulator;
FBSimulator *simulator = [self obtainSimulator];
NSString *simulatorUUID = simulator.udid;
[self addTemporaryFileToSimulator:simulator];
[self assertFreesSimulator:simulator];
simulator = [self createSession].simulator;
simulator = [self obtainSimulator];
XCTAssertEqualObjects(simulatorUUID, simulator.udid);
[self assertTemporaryFileForSimulator:simulator exists:NO];
[self assertFreesSimulator:simulator];
@ -63,11 +63,11 @@
FBSimulatorAllocationOptions options = self.allocationOptions;
self.allocationOptions = options | FBSimulatorAllocationOptionsDeleteOnFree;
FBSimulator *simulator = [self createSession].simulator;
FBSimulator *simulator = [self obtainSimulator];
NSString *simulatorUUID = simulator.udid;
[self assertFreesSimulator:simulator];
simulator = [self createSession].simulator;
simulator = [self obtainSimulator];
XCTAssertNotEqualObjects(simulatorUUID, simulator.udid);
[self assertFreesSimulator:simulator];
}
@ -77,7 +77,7 @@
FBSimulatorAllocationOptions options = self.allocationOptions;
self.allocationOptions = options | FBSimulatorAllocationOptionsDeleteOnFree;
FBSimulator *simulator = [self createSession].simulator;
FBSimulator *simulator = [self obtainSimulator];
NSString *simulatorUUID = simulator.udid;
[self assertFreesSimulator:simulator];
@ -91,7 +91,7 @@
NSMutableSet *simulatorUUIDs = [NSMutableSet set];
for (NSInteger index = 0; index < 4; index++) {
FBSimulator *simulator = [self createSession].simulator;
FBSimulator *simulator = [self obtainSimulator];
[simulators addObject:simulator];
[simulatorUUIDs addObject:simulator.udid];
}

Просмотреть файл

@ -29,10 +29,10 @@
return;
}
FBSimulatorSession *session = [self createBootedSession];
FBSimulator *simulator = [self obtainBootedSimulator];
FBSimulatorWindowTiler *tiler = [FBSimulatorWindowTiler
withSimulator:session.simulator
strategy:[FBSimulatorWindowTilingStrategy horizontalOcclusionStrategy:session.simulator]];
withSimulator:simulator
strategy:[FBSimulatorWindowTilingStrategy horizontalOcclusionStrategy:simulator]];
NSError *error = nil;
CGRect position = [tiler placeInForegroundWithError:&error];

Просмотреть файл

@ -12,7 +12,6 @@
@class FBSimulator;
@class FBSimulatorControl;
@class FBSimulatorPool;
@class FBSimulatorSession;
@protocol FBInteraction;
/**
@ -37,7 +36,7 @@
/**
Assertion failure if the Session fails to terminate
*/
- (void)assertShutdownSimulatorAndTerminateSession:(FBSimulatorSession *)session;
- (void)assertShutdownSimulatorAndTerminateSession:(FBSimulator *)simulator;
#pragma mark Strings

Просмотреть файл

@ -35,16 +35,15 @@
#pragma mark Sessions
- (void)assertShutdownSimulatorAndTerminateSession:(FBSimulatorSession *)session
- (void)assertShutdownSimulatorAndTerminateSession:(FBSimulator *)simulator
{
[self assertInteractionSuccessful:session.interact.shutdownSimulator];
[self assertInteractionSuccessful:simulator.interact.shutdownSimulator];
NSError *error = nil;
BOOL success = [session terminateWithError:&error];
BOOL success = [simulator.pool freeSimulator:simulator error:&error];
XCTAssertNil(error);
XCTAssertTrue(success);
[self assertSimulatorShutdown:session.simulator];
[self assertSimulatorShutdown:simulator];
}
#pragma mark Strings

Просмотреть файл

@ -17,7 +17,6 @@
@class FBSimulatorControl;
@class FBSimulatorControlNotificationAssertions;
@class FBSimulatorLaunchConfiguration;
@class FBSimulatorSession;
/**
Environment Keys and Values for how the Simulator should be launched.
@ -32,25 +31,20 @@ extern NSString *const FBSimulatorControlTestsLaunchTypeDirect;
*/
@interface FBSimulatorControlTestCase : XCTestCase
/**
Allocates a Simulator with a default configuration.
*/
- (FBSimulator *)allocateSimulator;
/**
Creates a Session with the provided configuration.
*/
- (FBSimulatorSession *)createSessionWithConfiguration:(FBSimulatorConfiguration *)configuration;
- (FBSimulator *)obtainSimulatorWithConfiguration:(FBSimulatorConfiguration *)configuration;
/**
Creates a Session with the default configuration.
*/
- (FBSimulatorSession *)createSession;
- (FBSimulator *)obtainSimulator;
/**
Create a Session with a booted Simulator of the default configuration.
*/
- (FBSimulatorSession *)createBootedSession;
- (FBSimulator *)obtainBootedSimulator;
/**
The Per-TestCase Management Options for created FBSimulatorControl instances.

Просмотреть файл

@ -66,34 +66,25 @@ static NSString *const DirectLaunchEnableVideoRecording = @"FBSIMULATORCONTROL_R
#pragma mark Helper Actions
- (FBSimulator *)allocateSimulator
- (FBSimulator *)obtainSimulatorWithConfiguration:(FBSimulatorConfiguration *)configuration
{
NSError *error = nil;
FBSimulator *simulator = [self.control.simulatorPool allocateSimulatorWithConfiguration:self.simulatorConfiguration options:self.allocationOptions error:&error];
FBSimulator *simulator = [self.control obtainSimulatorWithConfiguration:configuration options:self.allocationOptions error:&error];
XCTAssertNil(error);
XCTAssertNotNil(simulator);
return simulator;
}
- (FBSimulatorSession *)createSessionWithConfiguration:(FBSimulatorConfiguration *)configuration
- (FBSimulator *)obtainSimulator
{
NSError *error = nil;
FBSimulatorSession *session = [self.control createSessionForSimulatorConfiguration:configuration options:self.allocationOptions error:&error];
XCTAssertNil(error);
XCTAssertNotNil(session);
return session;
return [self obtainSimulatorWithConfiguration:self.simulatorConfiguration];
}
- (FBSimulatorSession *)createSession
- (FBSimulator *)obtainBootedSimulator
{
return [self createSessionWithConfiguration:self.simulatorConfiguration];
}
- (FBSimulatorSession *)createBootedSession
{
FBSimulatorSession *session = [self createSession];
[self assertInteractionSuccessful:session.interact.bootSimulator];
return session;
FBSimulator *simulator = [self obtainSimulator];
[self assertInteractionSuccessful:simulator.interact.bootSimulator];
return simulator;
}
+ (BOOL)isRunningOnTravis