This repository was archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[in_app_purchase] platform interface improvement #3821
Merged
Merged
Changes from 4 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
674bddd
platform interface improvement
875d3f1
format
06daea2
review
7f1653f
review
0f3d0b9
update docs
899bafb
asert and test
8a7341d
tupo
a697f09
fix analyzer errors
b8774b6
review
2d9c2ae
Merge branch 'master' into iap_platform_interface
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,7 +18,7 @@ class ProductDetailsResponse { | |
|
|
||
| /// The list of identifiers that are in the `identifiers` of [InAppPurchasePlatform.queryProductDetails] but failed to be fetched. | ||
| /// | ||
| /// There's multiple platform specific reasons that product information could fail to be fetched, | ||
| /// There's multiple platform-specific reasons that product information could fail to be fetched, | ||
|
||
| /// ranging from products not being correctly configured in the storefront to the queried IDs not existing. | ||
| final List<String> notFoundIDs; | ||
|
|
||
|
|
||
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 |
|---|---|---|
|
|
@@ -11,22 +11,18 @@ void main() { | |
| TestWidgetsFlutterBinding.ensureInitialized(); | ||
|
|
||
| group('$InAppPurchasePlatform', () { | ||
| test('Default instance should return null', () { | ||
| expect(InAppPurchasePlatform.instance, null); | ||
| }); | ||
|
|
||
| test('Cannot be implemented with `implements`', () { | ||
| expect(() { | ||
| InAppPurchasePlatform.setInstance(ImplementsInAppPurchasePlatform()); | ||
| InAppPurchasePlatform.instance = ImplementsInAppPurchasePlatform(); | ||
| }, throwsNoSuchMethodError); | ||
| }); | ||
|
|
||
| test('Can be extended', () { | ||
| InAppPurchasePlatform.setInstance(ExtendsInAppPurchasePlatform()); | ||
| InAppPurchasePlatform.instance = ExtendsInAppPurchasePlatform(); | ||
| }); | ||
|
|
||
| test('Can be mocked with `implements`', () { | ||
| InAppPurchasePlatform.setInstance(MockInAppPurchasePlatform()); | ||
| InAppPurchasePlatform.instance = MockInAppPurchasePlatform(); | ||
| }); | ||
|
|
||
| test( | ||
|
|
@@ -124,6 +120,48 @@ void main() { | |
| ); | ||
| }); | ||
| }); | ||
|
|
||
| group('$InAppPurchasePlatformAddition', () { | ||
| setUp(() { | ||
| InAppPurchasePlatformAddition.instance = null; | ||
| }); | ||
|
|
||
| test('Cannot be implemented with `implements`', () { | ||
| expect(InAppPurchasePlatformAddition.instance, isNull); | ||
| }); | ||
|
|
||
| test('Can be implemented.', () { | ||
| InAppPurchasePlatformAddition.instance = | ||
| ImplementsInAppPurchasePlatformAddition(); | ||
| }); | ||
|
|
||
| test('InAppPurchasePlatformAddition Can be extended', () { | ||
| InAppPurchasePlatformAddition.instance = | ||
| ExtendsInAppPurchasePlatformAddition(); | ||
| }); | ||
|
|
||
| test('Can be mocked with `implements`', () { | ||
| InAppPurchasePlatformAddition.instance = | ||
| MockInAppPurchasePlatformAddition(); | ||
| }); | ||
|
|
||
| test('Provider can provide', () { | ||
| ImplementsInAppPurchasePlatformAdditionProvider.register(); | ||
| final ImplementsInAppPurchasePlatformAdditionProvider provider = | ||
| ImplementsInAppPurchasePlatformAdditionProvider(); | ||
| final InAppPurchasePlatformAddition? addition = | ||
| provider.getPlatformAddition(); | ||
| expect(addition.runtimeType, ExtendsInAppPurchasePlatformAddition); | ||
| }); | ||
|
|
||
| test('Provider can provide `null`', () { | ||
| final ImplementsInAppPurchasePlatformAdditionProvider provider = | ||
| ImplementsInAppPurchasePlatformAdditionProvider(); | ||
| final InAppPurchasePlatformAddition? addition = | ||
| provider.getPlatformAddition(); | ||
| expect(addition, isNull); | ||
| }); | ||
| }); | ||
| } | ||
|
|
||
| class ImplementsInAppPurchasePlatform implements InAppPurchasePlatform { | ||
|
|
@@ -143,3 +181,32 @@ class ExtendsInAppPurchasePlatform extends InAppPurchasePlatform {} | |
| class MockPurchaseParam extends Mock implements PurchaseParam {} | ||
|
|
||
| class MockPurchaseDetails extends Mock implements PurchaseDetails {} | ||
|
|
||
| class ImplementsInAppPurchasePlatformAddition | ||
| implements InAppPurchasePlatformAddition { | ||
| @override | ||
| dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | ||
| } | ||
|
|
||
| class MockInAppPurchasePlatformAddition extends Mock | ||
| with | ||
| // ignore: prefer_mixin | ||
| MockPlatformInterfaceMixin | ||
|
||
| implements | ||
| InAppPurchasePlatformAddition {} | ||
|
|
||
| class ExtendsInAppPurchasePlatformAddition | ||
| extends InAppPurchasePlatformAddition {} | ||
|
|
||
| class ImplementsInAppPurchasePlatformAdditionProvider | ||
| implements InAppPurchasePlatformAdditionProvider { | ||
| static void register() { | ||
| InAppPurchasePlatformAddition.instance = | ||
| ExtendsInAppPurchasePlatformAddition(); | ||
| } | ||
|
|
||
| @override | ||
| T getPlatformAddition<T extends InAppPurchasePlatformAddition?>() { | ||
| return InAppPurchasePlatformAddition.instance as T; | ||
| } | ||
| } | ||
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.
s/replace ... with/set ... to/ (by default there's no instance, so there's nothing to replace)
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.
done