Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[in_app_purchase] Added serviceTimeout code for google iab (test) #3000

Closed
wants to merge 11 commits into from
Closed
4 changes: 4 additions & 0 deletions packages/in_app_purchase/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.3.4+6

* Android: Fixed bug due to code -3 (SERVICE_TIMEOUT) in `BillingResponse`

## 0.3.4+5

* Added necessary README docs for getting started with Android.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,9 @@ enum BillingResponse {
// WARNING: Changes to this class need to be reflected in our generated code.
// Run `flutter packages pub run build_runner watch` to rebuild and watch for
// further changes.
@JsonValue(-3)
serviceTimeout,

@JsonValue(-2)
featureNotSupported,

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
// Copyright 2019 The Chromium 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 'package:test/test.dart';
import 'package:in_app_purchase/billing_client_wrappers.dart';
import 'package:in_app_purchase/src/billing_client_wrappers/enum_converters.dart';

void main() {
group('BillingResponse', () {
test('serviceTimeout', () {
final BillingResponse parsed = BillingResponse.serviceTimeout;
final BillingResponse expected = BillingResponseConverter().fromJson(-3);

expect(parsed, equals(expected));
});

test('featureNotSupported', () {
final BillingResponse parsed = BillingResponse.featureNotSupported;
final BillingResponse expected = BillingResponseConverter().fromJson(-2);

expect(parsed, equals(expected));
});

test('serviceDisconnected', () {
final BillingResponse parsed = BillingResponse.serviceDisconnected;
final BillingResponse expected = BillingResponseConverter().fromJson(-1);

expect(parsed, equals(expected));
});

test('ok', () {
final BillingResponse parsed = BillingResponse.ok;
final BillingResponse expected = BillingResponseConverter().fromJson(0);

expect(parsed, equals(expected));
});

test('userCanceled', () {
final BillingResponse parsed = BillingResponse.userCanceled;
final BillingResponse expected = BillingResponseConverter().fromJson(1);

expect(parsed, equals(expected));
});

test('serviceUnavailable', () {
final BillingResponse parsed = BillingResponse.serviceUnavailable;
final BillingResponse expected = BillingResponseConverter().fromJson(2);

expect(parsed, equals(expected));
});

test('billingUnavailable', () {
final BillingResponse parsed = BillingResponse.billingUnavailable;
final BillingResponse expected = BillingResponseConverter().fromJson(3);

expect(parsed, equals(expected));
});

test('itemUnavailable', () {
final BillingResponse parsed = BillingResponse.itemUnavailable;
final BillingResponse expected = BillingResponseConverter().fromJson(4);

expect(parsed, equals(expected));
});

test('developerError', () {
final BillingResponse parsed = BillingResponse.developerError;
final BillingResponse expected = BillingResponseConverter().fromJson(5);

expect(parsed, equals(expected));
});

test('error', () {
final BillingResponse parsed = BillingResponse.error;
final BillingResponse expected = BillingResponseConverter().fromJson(6);

expect(parsed, equals(expected));
});

test('itemAlreadyOwned', () {
final BillingResponse parsed = BillingResponse.itemAlreadyOwned;
final BillingResponse expected = BillingResponseConverter().fromJson(7);

expect(parsed, equals(expected));
});

test('itemNotOwned', () {
final BillingResponse parsed = BillingResponse.itemNotOwned;
final BillingResponse expected = BillingResponseConverter().fromJson(8);

expect(parsed, equals(expected));
});
});
}