[go: nahoru, domu]

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

[in_app_purchase_android] Add UserChoiceBilling mode. #6162

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3427813
Add generated code, create java and dart objects that hold user choic…
reidbaker Feb 15, 2024
b8dc1ed
Analyzer warnings, test compile fix
reidbaker Feb 15, 2024
8440a75
do not remove disconnect call
reidbaker Feb 15, 2024
bfd7786
return list of products update java test to use userchoicebilling
reidbaker Feb 19, 2024
939545d
verify method channel is called in callback
reidbaker Feb 19, 2024
613f5f0
Add test that mimics opening a connection, closing a connection then …
reidbaker Feb 19, 2024
4f2ab49
formatting
reidbaker Feb 19, 2024
8106192
Changelog
reidbaker Feb 19, 2024
6f583d0
Add product details list to test, add flags required for deep json co…
reidbaker Feb 20, 2024
4ca1aeb
Add breadcrumb to documentation
reidbaker Feb 20, 2024
b2e00ce
java formatting
reidbaker Feb 21, 2024
d88603e
Merge branch 'main' into i143004-in-app-purchase-user-choice-billing-…
reidbaker Feb 21, 2024
818e800
Add billing client manager test for stream
reidbaker Feb 22, 2024
e2d30da
Add test for platform addition
reidbaker Feb 22, 2024
02e7638
Create api objects, add test for platform addition
reidbaker Feb 22, 2024
024bbf5
Add translator test with positive cases
reidbaker Feb 22, 2024
818adf2
Merge branch 'main' into i143004-in-app-purchase-user-choice-billing-…
reidbaker Feb 22, 2024
10ad143
dart formatting
reidbaker Feb 22, 2024
3c0067a
Add example of details in main
reidbaker Feb 22, 2024
dda2a57
formatting
reidbaker Feb 22, 2024
2e20b70
code review feedback
reidbaker Mar 8, 2024
0e8bc5b
Merge branch 'main' into i143004-in-app-purchase-user-choice-billing-…
reidbaker Mar 8, 2024
7efca0f
formatting
reidbaker Mar 8, 2024
6b282f8
Correct missmatch between java and dart and add over the wire test to…
reidbaker Mar 8, 2024
43e00d7
Formatting
reidbaker Mar 8, 2024
3df9dd5
Update packages/in_app_purchase/in_app_purchase_android/lib/src/billi…
reidbaker Mar 8, 2024
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
Prev Previous commit
Next Next commit
Add test for platform addition
  • Loading branch information
reidbaker committed Feb 22, 2024
commit e2d30da2dd6be079049419807a77a1c936a9d91e
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:async';

import 'package:flutter/services.dart';
import 'package:in_app_purchase_platform_interface/in_app_purchase_platform_interface.dart';

Expand All @@ -14,7 +16,20 @@ class InAppPurchaseAndroidPlatformAddition
extends InAppPurchasePlatformAddition {
/// Creates a [InAppPurchaseAndroidPlatformAddition] which uses the supplied
/// `BillingClientManager` to provide Android specific features.
InAppPurchaseAndroidPlatformAddition(this._billingClientManager);
InAppPurchaseAndroidPlatformAddition(this._billingClientManager) {

_billingClientManager.userChoiceDetailsStream
.asyncMap(_getUserChoiceDetailsFromResult)
.listen(_userChoiceDetailsStreamController.add);
}

final StreamController<UserChoiceDetailsWrapper>
_userChoiceDetailsStreamController =
StreamController<UserChoiceDetailsWrapper>.broadcast();

/// [UserChoiceDetailsWrapper] emits each time user selects alternative billing.
late final Stream<UserChoiceDetailsWrapper> userChoiceDetailsStream =
_userChoiceDetailsStreamController.stream;

/// Whether pending purchase is enabled.
///
Expand Down Expand Up @@ -56,6 +71,11 @@ class InAppPurchaseAndroidPlatformAddition
);
}

Future<UserChoiceDetailsWrapper> _getUserChoiceDetailsFromResult(
UserChoiceDetailsWrapper resultWrapper) async {
return resultWrapper;
}

/// Query all previous purchases.
///
/// The `applicationUserName` should match whatever was sent in the initial
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,27 @@ void main() {
expect(arguments['feature'], equals('subscriptions'));
});
});

group('userChoiceDetails', () {
test('called', () async {
final Future<UserChoiceDetailsWrapper> futureDetails =
iapAndroidPlatformAddition.userChoiceDetailsStream.first;
const UserChoiceDetailsWrapper expected = UserChoiceDetailsWrapper(
originalExternalTransactionId: 'TransactionId',
externalTransactionToken: 'TransactionToken',
products: <UserChoiceDetailsProductWrapper>[
UserChoiceDetailsProductWrapper(
id: 'id1',
offerToken: 'offerToken1',
productType: ProductType.inapp),
UserChoiceDetailsProductWrapper(
id: 'id2',
offerToken: 'offerToken2',
productType: ProductType.inapp),
],
);
manager.onUserChoiceAlternativeBilling(expected);
expect(await futureDetails, expected);
});
});
}