Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues shown by OCMock 3.5 #1518

Merged
merged 2 commits into from Jan 8, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 1 addition & 7 deletions SmartDeviceLinkTests/DevAPISpecs/SDLChoiceSetManagerSpec.m
Expand Up @@ -222,8 +222,7 @@ @interface SDLChoiceSetManager()

beforeEach(^{
pendingPreloadOp = [[SDLPreloadChoicesOperation alloc] init];
OCMPartialMock(pendingPreloadOp);
OCMStub([pendingPreloadOp removeChoicesFromUpload:[OCMArg any]]);

[testManager.transactionQueue addOperation:pendingPreloadOp];

testManager.pendingMutablePreloadChoices = [NSMutableSet setWithObject:testCell1];
Expand All @@ -232,11 +231,6 @@ @interface SDLChoiceSetManager()
});

it(@"should properly start the deletion", ^{
OCMStub([pendingPreloadOp removeChoicesFromUpload:[OCMArg checkWithBlock:^BOOL(id obj) {
NSArray<SDLChoiceCell *> *choices = (NSArray<SDLChoiceCell *> *)obj;
return (choices.count == 1) && ([choices.firstObject isEqual:testCell1]);
}]]);

expect(testManager.pendingPreloadChoices).to(beEmpty());
expect(testManager.transactionQueue.operationCount).to(equal(1)); // No delete operation
});
Expand Down
104 changes: 82 additions & 22 deletions SmartDeviceLinkTests/ProxySpecs/SDLHapticManagerSpec.m
Expand Up @@ -51,7 +51,7 @@ @interface SDLFocusableItemLocator ()
__block SDLFocusableItemLocator *hapticManager;
__block SDLSendHapticData* sentHapticRequest;

__block id sdlLifecycleManager = OCMClassMock([SDLLifecycleManager class]);
__block id<SDLConnectionManagerType> sdlLifecycleManager = nil;
__block SDLStreamingVideoScaleManager *sdlStreamingVideoScaleManager = nil;
__block CGRect viewRect1;
__block CGRect viewRect2;
Expand All @@ -61,17 +61,11 @@ @interface SDLFocusableItemLocator ()
uiViewController = [[UIViewController alloc] init];
uiWindow.rootViewController = uiViewController;

sdlLifecycleManager = OCMProtocolMock(@protocol(SDLConnectionManagerType));

hapticManager = nil;
sentHapticRequest = nil;
sdlStreamingVideoScaleManager = [[SDLStreamingVideoScaleManager alloc] initWithScale:1.0 displayViewportResolution:uiViewController.view.frame.size];

OCMExpect([[sdlLifecycleManager stub] sendConnectionManagerRequest:[OCMArg checkWithBlock:^BOOL(id value){
BOOL isFirstArg = [value isKindOfClass:[SDLSendHapticData class]];
if(isFirstArg) {
sentHapticRequest = value;
}
return YES;
}] withResponseHandler:[OCMArg any]]);
});

context(@"when disabled", ^{
Expand All @@ -86,7 +80,13 @@ @interface SDLFocusableItemLocator ()
});

it(@"should have no views", ^{
OCMVerify(sdlLifecycleManager);
OCMReject([sdlLifecycleManager sendConnectionManagerRequest:[OCMArg checkWithBlock:^BOOL(id value){
BOOL isFirstArg = [value isKindOfClass:[SDLSendHapticData class]];
if(isFirstArg) {
sentHapticRequest = value;
}
return YES;
}] withResponseHandler:[OCMArg any]]);

expect(sentHapticRequest).to(beNil());
});
Expand All @@ -99,7 +99,13 @@ @interface SDLFocusableItemLocator ()
});

it(@"should have no focusable view", ^{
OCMVerify(sdlLifecycleManager);
OCMReject([sdlLifecycleManager sendConnectionManagerRequest:[OCMArg checkWithBlock:^BOOL(id value){
BOOL isFirstArg = [value isKindOfClass:[SDLSendHapticData class]];
if(isFirstArg) {
sentHapticRequest = value;
}
return YES;
}] withResponseHandler:[OCMArg any]]);
expect(sentHapticRequest.hapticRectData.count).to(equal(0));
});
});
Expand All @@ -116,7 +122,13 @@ @interface SDLFocusableItemLocator ()
});

it(@"should have one view", ^{
OCMVerify(sdlLifecycleManager);
OCMVerify([sdlLifecycleManager sendConnectionManagerRequest:[OCMArg checkWithBlock:^BOOL(id value){
BOOL isFirstArg = [value isKindOfClass:[SDLSendHapticData class]];
if(isFirstArg) {
sentHapticRequest = value;
}
return YES;
}] withResponseHandler:[OCMArg any]]);

int expectedCount = 1;
expect(sentHapticRequest.hapticRectData.count).to(equal(expectedCount));
Expand All @@ -143,7 +155,13 @@ @interface SDLFocusableItemLocator ()
});

it(@"should have one view", ^{
OCMVerify(sdlLifecycleManager);
OCMVerify([sdlLifecycleManager sendConnectionManagerRequest:[OCMArg checkWithBlock:^BOOL(id value){
BOOL isFirstArg = [value isKindOfClass:[SDLSendHapticData class]];
if(isFirstArg) {
sentHapticRequest = value;
}
return YES;
}] withResponseHandler:[OCMArg any]]);

int expectedCount = 1;
expect(sentHapticRequest.hapticRectData.count).to(equal(expectedCount));
Expand Down Expand Up @@ -176,7 +194,13 @@ @interface SDLFocusableItemLocator ()
});

it(@"should have two views", ^{
OCMVerify(sdlLifecycleManager);
OCMVerify([sdlLifecycleManager sendConnectionManagerRequest:[OCMArg checkWithBlock:^BOOL(id value){
BOOL isFirstArg = [value isKindOfClass:[SDLSendHapticData class]];
if(isFirstArg) {
sentHapticRequest = value;
}
return YES;
}] withResponseHandler:[OCMArg any]]);

int expectedCount = 2;
expect(sentHapticRequest.hapticRectData.count).to(equal(expectedCount));
Expand Down Expand Up @@ -214,7 +238,13 @@ @interface SDLFocusableItemLocator ()
});

it(@"should have only leaf views added", ^{
OCMVerify(sdlLifecycleManager);
OCMVerify([sdlLifecycleManager sendConnectionManagerRequest:[OCMArg checkWithBlock:^BOOL(id value){
BOOL isFirstArg = [value isKindOfClass:[SDLSendHapticData class]];
if(isFirstArg) {
sentHapticRequest = value;
}
return YES;
}] withResponseHandler:[OCMArg any]]);

int expectedCount = 2;
expect(sentHapticRequest.hapticRectData.count).to(equal(expectedCount));
Expand Down Expand Up @@ -252,7 +282,13 @@ @interface SDLFocusableItemLocator ()
});

it(@"should have only leaf views added", ^{
OCMVerify(sdlLifecycleManager);
OCMVerify([sdlLifecycleManager sendConnectionManagerRequest:[OCMArg checkWithBlock:^BOOL(id value){
BOOL isFirstArg = [value isKindOfClass:[SDLSendHapticData class]];
if(isFirstArg) {
sentHapticRequest = value;
}
return YES;
}] withResponseHandler:[OCMArg any]]);

int expectedCount = 2;
expect(sentHapticRequest.hapticRectData.count).to(equal(expectedCount));
Expand All @@ -273,6 +309,14 @@ @interface SDLFocusableItemLocator ()

context(@"when initialized with two views and then updated with one view removed", ^{
beforeEach(^{
OCMStub([sdlLifecycleManager sendConnectionManagerRequest:[OCMArg checkWithBlock:^BOOL(id value){
BOOL isFirstArg = [value isKindOfClass:[SDLSendHapticData class]];
if(isFirstArg) {
sentHapticRequest = value;
}
return YES;
}] withResponseHandler:[OCMArg any]]);

viewRect1 = CGRectMake(101, 101, 50, 50);
UITextField *textField1 = [[UITextField alloc] initWithFrame:viewRect1];
[uiViewController.view addSubview:textField1];
Expand All @@ -291,8 +335,6 @@ @interface SDLFocusableItemLocator ()
});

it(@"should have one view", ^{
OCMVerify(sdlLifecycleManager);

int expectedCount = 1;
expect(sentHapticRequest.hapticRectData.count).to(equal(expectedCount));

Expand All @@ -308,6 +350,14 @@ @interface SDLFocusableItemLocator ()

context(@"when initialized with one view and notified after adding one more view", ^{
beforeEach(^{
OCMStub([sdlLifecycleManager sendConnectionManagerRequest:[OCMArg checkWithBlock:^BOOL(id value){
BOOL isFirstArg = [value isKindOfClass:[SDLSendHapticData class]];
if(isFirstArg) {
sentHapticRequest = value;
}
return YES;
}] withResponseHandler:[OCMArg any]]);

viewRect1 = CGRectMake(101, 101, 50, 50);
UITextField *textField1 = [[UITextField alloc] initWithFrame:viewRect1];
[uiViewController.view addSubview:textField1];
Expand All @@ -324,8 +374,6 @@ @interface SDLFocusableItemLocator ()
});

it(@"should have two views", ^{
OCMVerify(sdlLifecycleManager);

int expectedCount = 2;
expect(sentHapticRequest.hapticRectData.count).toEventually(equal(expectedCount));

Expand Down Expand Up @@ -422,7 +470,13 @@ @interface SDLFocusableItemLocator ()
});

it(@"should have sent one view that has been scaled", ^{
OCMVerify(sdlLifecycleManager);
OCMVerify([sdlLifecycleManager sendConnectionManagerRequest:[OCMArg checkWithBlock:^BOOL(id value){
BOOL isFirstArg = [value isKindOfClass:[SDLSendHapticData class]];
if(isFirstArg) {
sentHapticRequest = value;
}
return YES;
}] withResponseHandler:[OCMArg any]]);

int expectedCount = 1;
expect(sentHapticRequest.hapticRectData.count).to(equal(expectedCount));
Expand All @@ -445,7 +499,13 @@ @interface SDLFocusableItemLocator ()
});

it(@"should have sent one view that has not been scaled", ^{
OCMVerify(sdlLifecycleManager);
OCMVerify([sdlLifecycleManager sendConnectionManagerRequest:[OCMArg checkWithBlock:^BOOL(id value){
BOOL isFirstArg = [value isKindOfClass:[SDLSendHapticData class]];
if(isFirstArg) {
sentHapticRequest = value;
}
return YES;
}] withResponseHandler:[OCMArg any]]);

int expectedCount = 1;
expect(sentHapticRequest.hapticRectData.count).to(equal(expectedCount));
Expand Down