Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions SquirrelTests/SQRLUpdaterSpec.m
Original file line number Diff line number Diff line change
Expand Up @@ -663,15 +663,17 @@ bool isRunningOnReadOnlyVolumeImp(id self, SEL _cmd)
}];

NSRunningApplication *testApplication = launchWithEnvironment(nil);
expect(@(testApplication.terminated)).withTimeout(SQRLLongTimeout).toEventually(beTruthy());

// The app has run to completion; every state notification has been
// posted (with deliverImmediately:YES). Allow notifyd a moment to
// deliver any in-flight notifications before asserting the sequence.
NSArray *expectedStates = @[
@(SQRLUpdaterStateIdle),
@(SQRLUpdaterStateCheckingForUpdate),
@(SQRLUpdaterStateIdle),
];
expect(states).toEventually(equal(expectedStates));

expect(@(testApplication.terminated)).withTimeout(SQRLLongTimeout).toEventually(beTruthy());
expect(states).withTimeout(SQRLLongTimeout).toEventually(equal(expectedStates));
});

it(@"should transition through idle, checking, downloading and awaiting relaunch, when there is an update", ^{
Expand All @@ -693,16 +695,18 @@ bool isRunningOnReadOnlyVolumeImp(id self, SEL _cmd)
writeUpdate(update);

NSRunningApplication *testApplication = launchWithEnvironment(nil);
expect(@(testApplication.terminated)).withTimeout(SQRLLongTimeout).toEventually(beTruthy());

// The app has run to completion; every state notification has been
// posted (with deliverImmediately:YES). Allow notifyd a moment to
// deliver any in-flight notifications before asserting the sequence.
NSArray *expectedStates = @[
@(SQRLUpdaterStateIdle),
@(SQRLUpdaterStateCheckingForUpdate),
@(SQRLUpdaterStateDownloadingUpdate),
@(SQRLUpdaterStateAwaitingRelaunch),
];
expect(states).withTimeout(SQRLLongTimeout).toEventually(equal(expectedStates));

expect(@(testApplication.terminated)).withTimeout(SQRLLongTimeout).toEventually(beTruthy());
});
});

Expand Down
2 changes: 1 addition & 1 deletion TestApplication/TestAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
[RACObserve(self.updater, state) subscribeNext:^(NSNumber *state) {
NSLog(@"State transition: %@", state);

[NSDistributedNotificationCenter.defaultCenter postNotificationName:SQRLTestAppUpdaterStateTransitionNotificationName object:nil userInfo:@{ SQRLTestAppUpdaterStateKey: state }];
[NSDistributedNotificationCenter.defaultCenter postNotificationName:SQRLTestAppUpdaterStateTransitionNotificationName object:nil userInfo:@{ SQRLTestAppUpdaterStateKey: state } deliverImmediately:YES];
}];

__block NSUInteger updateCheckCount = 1;
Expand Down
Loading