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

Clean up andDo warnings and invocations #761

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
18 changes: 8 additions & 10 deletions packages/google_mobile_ads/ios/Tests/FLTAppOpenAdTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,15 @@ - (void)testLoadShowAppOpenAd:(FLTAdRequest *)request
request:[OCMArg any]
orientation:UIInterfaceOrientationPortrait
completionHandler:[OCMArg any]]))
.andDo(^(NSInvocation *invocation) {
void (^completionHandler)(GADAppOpenAd *ad, NSError *error);
[invocation getArgument:&completionHandler atIndex:5];
.andDo(^void(Class localSelf, NSString *unitID, GADRequest *request,
UIInterfaceOrientation orientation,
GADAppOpenAdLoadCompletionHandler completionHandler) {
completionHandler(appOpenClassMock, nil);
});
// Stub setting of FullScreenContentDelegate to invoke delegate callbacks.
NSError *error = OCMClassMock([NSError class]);
OCMStub([appOpenClassMock setFullScreenContentDelegate:[OCMArg any]])
.andDo(^(NSInvocation *invocation) {
id<GADFullScreenContentDelegate> delegate;
[invocation getArgument:&delegate atIndex:2];
.andDo(^void(GADAppOpenAd *localSelf, FLTAppOpenAd *delegate) {
XCTAssertEqual(delegate, ad);
[delegate adDidRecordImpression:appOpenClassMock];
[delegate adDidRecordClick:appOpenClassMock];
Expand Down Expand Up @@ -183,9 +181,9 @@ - (void)testFailedToLoad:(FLTAdRequest *)request {
request:[OCMArg any]
orientation:UIInterfaceOrientationLandscapeLeft
completionHandler:[OCMArg any]]))
.andDo(^(NSInvocation *invocation) {
void (^completionHandler)(GADAppOpenAd *ad, NSError *error);
[invocation getArgument:&completionHandler atIndex:5];
.andDo(^void(Class localSelf, NSString *unitID, GADRequest *request,
UIInterfaceOrientation orientation,
GADAppOpenAdLoadCompletionHandler completionHandler) {
completionHandler(nil, error);
});

Expand All @@ -200,4 +198,4 @@ - (void)testFailedToLoad:(FLTAdRequest *)request {
error:[OCMArg isEqual:error]]);
}

@end
@end
20 changes: 7 additions & 13 deletions packages/google_mobile_ads/ios/Tests/FLTGamInterstitialAdTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,13 @@ - (void)testLoadShowInterstitialAd {
loadWithAdManagerAdUnitID:[OCMArg any]
request:[OCMArg any]
completionHandler:[OCMArg any]]))
.andDo(^(NSInvocation *invocation) {
void (^completionHandler)(GAMInterstitialAd *ad, NSError *error);
[invocation getArgument:&completionHandler atIndex:4];
.andDo(^void(Class localSelf, NSString *unitID, GAMRequest *request,
GADInterstitialAdLoadCompletionHandler completionHandler) {
completionHandler(interstitialClassMock, nil);
});
NSError *error = OCMClassMock([NSError class]);
OCMStub([interstitialClassMock setFullScreenContentDelegate:[OCMArg any]])
.andDo(^(NSInvocation *invocation) {
id<GADFullScreenContentDelegate> delegate;
[invocation getArgument:&delegate atIndex:2];
.andDo(^void(GAMInterstitialAd *localSelf, id<GADFullScreenContentDelegate> delegate) {
XCTAssertEqual(delegate, ad);
[delegate adDidRecordImpression:interstitialClassMock];
[delegate adDidRecordClick:interstitialClassMock];
Expand All @@ -70,9 +67,7 @@ - (void)testLoadShowInterstitialAd {
});

OCMStub([interstitialClassMock setAppEventDelegate:[OCMArg any]])
.andDo(^(NSInvocation *invocation) {
id<GADAppEventDelegate> delegate;
[invocation getArgument:&delegate atIndex:2];
.andDo(^void(GAMInterstitialAd *localSelf, id<GADAppEventDelegate> delegate) {
XCTAssertEqual(delegate, ad);
[delegate interstitialAd:interstitialClassMock
didReceiveAppEvent:@"event"
Expand Down Expand Up @@ -160,9 +155,8 @@ - (void)testFailToLoad {
loadWithAdManagerAdUnitID:[OCMArg any]
request:[OCMArg any]
completionHandler:[OCMArg any]]))
.andDo(^(NSInvocation *invocation) {
void (^completionHandler)(GAMInterstitialAd *ad, NSError *error);
[invocation getArgument:&completionHandler atIndex:4];
.andDo(^void(Class localSelf, NSString *unitID, GAMRequest *request,
GADInterstitialAdLoadCompletionHandler completionHandler) {
completionHandler(nil, error);
});

Expand All @@ -176,4 +170,4 @@ - (void)testFailToLoad {
error:[OCMArg isEqual:error]]);
}

@end
@end
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,8 @@ - (void)testMobileAdsInitialize {
OCMClassMock([GADInitializationStatus class]);
OCMStub([mockInitStatus adapterStatusesByClassName]).andReturn(@{});
OCMStub([gadMobileAdsClassMock startWithCompletionHandler:[OCMArg any]])
.andDo(^(NSInvocation *invocation) {
.andDo(^void(GADMobileAds *localSelf, GADInitializationCompletionHandler completionHandler) {
// Invoke the init handler twice.
GADInitializationCompletionHandler completionHandler;
[invocation getArgument:&completionHandler atIndex:2];
completionHandler(mockInitStatus);
completionHandler(mockInitStatus);
});
Expand Down Expand Up @@ -381,9 +379,8 @@ - (void)testOpenAdInspectorSuccess {
OCMStub([gadMobileAdsClassMock
presentAdInspectorFromViewController:[OCMArg any]
completionHandler:[OCMArg any]])
.andDo(^(NSInvocation *invocation) {
GADAdInspectorCompletionHandler completionHandler;
[invocation getArgument:&completionHandler atIndex:3];
.andDo(^void(GADMobileAds *localSelf, UIViewController *viewController,
GADAdInspectorCompletionHandler completionHandler) {
completionHandler(nil);
});

Expand Down Expand Up @@ -419,9 +416,8 @@ - (void)testOpenAdInspectorError {
OCMStub([gadMobileAdsClassMock
presentAdInspectorFromViewController:[OCMArg any]
completionHandler:[OCMArg any]])
.andDo(^(NSInvocation *invocation) {
GADAdInspectorCompletionHandler completionHandler;
[invocation getArgument:&completionHandler atIndex:3];
.andDo(^void(GADMobileAds *localSelf, UIViewController *viewController,
GADAdInspectorCompletionHandler completionHandler) {
completionHandler(error);
});

Expand Down Expand Up @@ -668,4 +664,4 @@ - (void)testServerSideVerificationOptions_invalidAdType {
XCTAssertTrue(resultInvoked);
}

@end
@end
16 changes: 6 additions & 10 deletions packages/google_mobile_ads/ios/Tests/FLTInterstitialAdTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,13 @@ - (void)testLoadShowInterstitialAd {
OCMStub(ClassMethod([interstitialClassMock loadWithAdUnitID:[OCMArg any]
request:[OCMArg any]
completionHandler:[OCMArg any]]))
.andDo(^(NSInvocation *invocation) {
void (^completionHandler)(GADInterstitialAd *ad, NSError *error);
[invocation getArgument:&completionHandler atIndex:4];
.andDo(^void(Class localSelf, NSString *unitID, GADRequest *request,
GADInterstitialAdLoadCompletionHandler completionHandler) {
completionHandler(interstitialClassMock, nil);
});
NSError *error = OCMClassMock([NSError class]);
OCMStub([interstitialClassMock setFullScreenContentDelegate:[OCMArg any]])
.andDo(^(NSInvocation *invocation) {
id<GADFullScreenContentDelegate> delegate;
[invocation getArgument:&delegate atIndex:2];
.andDo(^void(GADInterstitialAd *localSelf, id<GADFullScreenContentDelegate> delegate) {
XCTAssertEqual(delegate, ad);
[delegate adDidRecordImpression:interstitialClassMock];
[delegate adDidRecordClick:interstitialClassMock];
Expand Down Expand Up @@ -143,9 +140,8 @@ - (void)testFailedToLoad {
OCMStub(ClassMethod([interstitialClassMock loadWithAdUnitID:[OCMArg any]
request:[OCMArg any]
completionHandler:[OCMArg any]]))
.andDo(^(NSInvocation *invocation) {
void (^completionHandler)(GADInterstitialAd *ad, NSError *error);
[invocation getArgument:&completionHandler atIndex:4];
.andDo(^void(Class localSelf, NSString *unitID, GADRequest *request,
GADInterstitialAdLoadCompletionHandler completionHandler) {
completionHandler(nil, error);
});

Expand All @@ -159,4 +155,4 @@ - (void)testFailedToLoad {
error:[OCMArg isEqual:error]]);
}

@end
@end
21 changes: 9 additions & 12 deletions packages/google_mobile_ads/ios/Tests/FLTRewardedAdTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,16 @@ - (void)testLoadShowRewardedAd:(FLTAdRequest *)request
OCMStub(ClassMethod([rewardedClassMock loadWithAdUnitID:[OCMArg any]
request:[OCMArg any]
completionHandler:[OCMArg any]]))
.andDo(^(NSInvocation *invocation) {
void (^completionHandler)(GADRewardedAd *ad, NSError *error);
[invocation getArgument:&completionHandler atIndex:4];
.andDo(^void(Class localSelf, NSString *unitID, GADRequest *request,
GADAppOpenAdLoadCompletionHandler completionHandler) {
completionHandler(rewardedClassMock, nil);
});
// Stub setting of FullScreenContentDelegate to invoke delegate callbacks.
NSError *error = OCMClassMock([NSError class]);
__block id<GADFullScreenContentDelegate> fullScreenContentDelegate;
OCMStub([rewardedClassMock setFullScreenContentDelegate:[OCMArg any]])
.andDo(^(NSInvocation *invocation) {
[invocation getArgument:&fullScreenContentDelegate atIndex:2];
.andDo(^void(GADRewardedAd *localSelf, id<GADFullScreenContentDelegate> delegate) {
fullScreenContentDelegate = delegate;
XCTAssertEqual(fullScreenContentDelegate, ad);
});
GADResponseInfo *responseInfo = OCMClassMock([GADResponseInfo class]);
Expand All @@ -86,9 +85,8 @@ - (void)testLoadShowRewardedAd:(FLTAdRequest *)request
OCMStub([rewardedClassMock adReward]).andReturn(mockReward);
OCMStub([rewardedClassMock presentFromRootViewController:[OCMArg any]
userDidEarnRewardHandler:[OCMArg any]])
.andDo(^(NSInvocation *invocation) {
GADUserDidEarnRewardHandler rewardHandler;
[invocation getArgument:&rewardHandler atIndex:3];
.andDo(^(GADRewardedAd *localSelf, UIViewController *viewController,
GADUserDidEarnRewardHandler rewardHandler) {
rewardHandler();
});

Expand Down Expand Up @@ -225,9 +223,8 @@ - (void)testFailedToLoad:(FLTAdRequest *)request {
OCMStub(ClassMethod([rewardedClassMock loadWithAdUnitID:[OCMArg any]
request:[OCMArg any]
completionHandler:[OCMArg any]]))
.andDo(^(NSInvocation *invocation) {
void (^completionHandler)(GADRewardedAd *ad, NSError *error);
[invocation getArgument:&completionHandler atIndex:4];
.andDo(^void(Class localSelf, NSString *unitID, GADRequest *request,
GADAppOpenAdLoadCompletionHandler completionHandler) {
completionHandler(nil, error);
});

Expand All @@ -240,4 +237,4 @@ - (void)testFailedToLoad:(FLTAdRequest *)request {
error:[OCMArg isEqual:error]]);
}

@end
@end
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,15 @@ - (void)testLoadShowRewardedInterstitialAd:(FLTAdRequest *)request
loadWithAdUnitID:[OCMArg any]
request:[OCMArg any]
completionHandler:[OCMArg any]]))
.andDo(^(NSInvocation *invocation) {
void (^completionHandler)(GADRewardedInterstitialAd *ad,
NSError *error);
[invocation getArgument:&completionHandler atIndex:4];
.andDo(^void(Class localSelf, NSString *unitID, GADRequest *request,
GADAppOpenAdLoadCompletionHandler completionHandler) {
completionHandler(rewardedInterstitialClassMock, nil);
});
// Stub setting of FullScreenContentDelegate to invoke delegate callbacks.
NSError *error = OCMClassMock([NSError class]);
OCMStub(
[rewardedInterstitialClassMock setFullScreenContentDelegate:[OCMArg any]])
.andDo(^(NSInvocation *invocation) {
id<GADFullScreenContentDelegate> delegate;
[invocation getArgument:&delegate atIndex:2];
.andDo(^void(GADRewardedInterstitialAd *localSelf, FLTRewardedInterstitialAd *delegate) {
XCTAssertEqual(delegate, ad);
[delegate adDidRecordImpression:rewardedInterstitialClassMock];
[delegate adDidRecordClick:rewardedInterstitialClassMock];
Expand All @@ -98,9 +94,8 @@ - (void)testLoadShowRewardedInterstitialAd:(FLTAdRequest *)request
OCMStub([rewardedInterstitialClassMock
presentFromRootViewController:[OCMArg any]
userDidEarnRewardHandler:[OCMArg any]])
.andDo(^(NSInvocation *invocation) {
GADUserDidEarnRewardHandler rewardHandler;
[invocation getArgument:&rewardHandler atIndex:3];
.andDo(^(GADRewardedInterstitialAd *localSelf, UIViewController *viewController,
GADUserDidEarnRewardHandler rewardHandler) {
rewardHandler();
});

Expand Down Expand Up @@ -215,10 +210,8 @@ - (void)testFailedToLoad:(FLTAdRequest *)request {
loadWithAdUnitID:[OCMArg any]
request:[OCMArg any]
completionHandler:[OCMArg any]]))
.andDo(^(NSInvocation *invocation) {
void (^completionHandler)(GADRewardedInterstitialAd *ad,
NSError *error);
[invocation getArgument:&completionHandler atIndex:4];
.andDo(^void(Class localSelf, NSString *unitID, GADRequest *request,
GADAppOpenAdLoadCompletionHandler completionHandler) {
completionHandler(nil, error);
});

Expand All @@ -232,4 +225,4 @@ - (void)testFailedToLoad:(FLTAdRequest *)request {
error:[OCMArg isEqual:error]]);
}

@end
@end