-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[in_app_purchase_storekit] backfill native tests for more complete test coverage #6209
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
a834469
initial commit
LouiseHsu 8a9faf5
more tests
LouiseHsu f5e19e2
ugh
LouiseHsu b3d6706
expose private methods in seperate head file, more tests
LouiseHsu 6e4c13a
formating, remove redundant file, fix test flakiness
LouiseHsu de4e798
Merge branch 'main' into backfill-iap-tests
LouiseHsu d2a5f68
update tests
LouiseHsu a6cddd6
Merge branch 'backfill-iap-tests' of github.com:LouiseHsu/packages in…
LouiseHsu 4ebc324
Merge branch 'main' into backfill-iap-tests
LouiseHsu f80f221
update version
LouiseHsu 35f12a7
random white space removal + remove dev team
LouiseHsu aa35c6c
spelled "initializer wrong" 😔
LouiseHsu f0fbdbc
pr comements!
LouiseHsu 4221167
Merge branch 'main' into backfill-iap-tests
LouiseHsu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
...es/in_app_purchase/in_app_purchase_storekit/darwin/Classes/InAppPurchasePlugin+TestOnly.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| #import <StoreKit/StoreKit.h> | ||
| #import "FIAPRequestHandler.h" | ||
| #import "InAppPurchasePlugin.h" | ||
|
|
||
| @interface InAppPurchasePlugin () | ||
|
|
||
| // Holding strong references to FIAPRequestHandlers. Remove the handlers from the set after | ||
| // the request is finished. | ||
| @property(strong, nonatomic, readonly) NSMutableSet *requestHandlers; | ||
|
|
||
| // Callback channel to dart used for when a function from the transaction observer is triggered. | ||
| @property(strong, nonatomic) FlutterMethodChannel *transactionObserverCallbackChannel; | ||
|
|
||
| // Transaction observer methods | ||
| - (void)handleTransactionsUpdated:(NSArray<SKPaymentTransaction *> *)transactions; | ||
| - (void)handleTransactionsRemoved:(NSArray<SKPaymentTransaction *> *)transactions; | ||
| - (void)handleTransactionRestoreFailed:(NSError *)error; | ||
| - (void)restoreCompletedTransactionsFinished; | ||
| - (BOOL)shouldAddStorePayment:(SKPayment *)payment product:(SKProduct *)product; | ||
|
|
||
| // Dependency Injection | ||
| - (FIAPRequestHandler *)getHandler:(SKRequest *)request; | ||
|
|
||
| @end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of creating a method that will be overwritten with a partial mock I think you should pass in a factory to the constructor InAppPurchasePlugin.
You were concerned about fiddling with the init method since it has users. You can get around that by adding this new initializer to InAppPurchasePlugin+TestOnly.h and calling it from the existing
initWithRequest:initializer.Partial mocks are something we should try hard to avoid. We've had to use them in the past because of oddities that disallow us to test without crashing. That isn't the case here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'm misunderstanding something sorry - so for example
packages/packages/in_app_purchase/in_app_purchase_storekit/darwin/Classes/InAppPurchasePlugin.m
Lines 114 to 115 in de4e798
What will these lines then look like? How do I reference the handlerFactory and ask it to please spit out another handler?
Additionally, the
requestparam is only available withinstartProductRequestProductIdentifiers:, so how would I be able to call it inside theinitWithRequest:initializer?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They would look like this:
You don't want to call the block in your init method. You want to hold on to it so that whenever you want a handler you can call it.
This is going to help: http://fuckingblocksyntax.com/ ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doneeee