Skip to content

Commit

Permalink
[google_sign_in, in_app_purchase_android] Add availability to mock mo…
Browse files Browse the repository at this point in the history
…dels (flutter#5642)
  • Loading branch information
Hwan-seok authored and yutaaraki-toydium committed Jun 4, 2022
1 parent 6b7ecea commit 8d674f2
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 8 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,4 @@ Rahul Raj <[email protected]>
Daniel Roek <[email protected]>
TheOneWithTheBraid <[email protected]>
Rulong Chen(陈汝龙) <[email protected]>
Hwanseok Kang <[email protected]>
3 changes: 2 additions & 1 deletion packages/google_sign_in/google_sign_in/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## NEXT
## 5.3.2

* Enables mocking models by changing overridden operator == parameter type from `dynamic` to `Object`.
* Updates tests to use a mock platform instead of relying on default
method channel implementation internals.
* Removes example workaround to build for arm64 iOS simulators.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class GoogleSignInAccount implements GoogleIdentity {
}

@override
bool operator ==(dynamic other) {
bool operator ==(Object other) {
if (identical(this, other)) {
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/google_sign_in/google_sign_in/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Flutter plugin for Google Sign-In, a secure authentication system
for signing in with a Google account on Android and iOS.
repository: https://github.com/flutter/plugins/tree/main/packages/google_sign_in/google_sign_in
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+google_sign_in%22
version: 5.3.1
version: 5.3.2


environment:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ import 'package:google_sign_in/google_sign_in.dart';
import 'package:google_sign_in_platform_interface/google_sign_in_platform_interface.dart';
import 'package:mockito/annotations.dart';
import 'package:mockito/mockito.dart';

import 'google_sign_in_test.mocks.dart';

/// Verify that [GoogleSignInAccount] can be mocked even though it's unused
// ignore: must_be_immutable
class MockGoogleSignInAccount extends Mock implements GoogleSignInAccount {}

@GenerateMocks(<Type>[GoogleSignInPlatform])
void main() {
late MockGoogleSignInPlatform mockPlatform;
Expand Down
4 changes: 4 additions & 0 deletions packages/in_app_purchase/in_app_purchase_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.2.2+6

* Enables mocking models by changing overridden operator == parameter type from `dynamic` to `Object`.

## 0.2.2+5

* Minor fixes for new analysis options.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class SkuDetailsWrapper {
final int originalPriceAmountMicros;

@override
bool operator ==(dynamic other) {
bool operator ==(Object other) {
if (other.runtimeType != runtimeType) {
return false;
}
Expand Down Expand Up @@ -203,7 +203,7 @@ class SkuDetailsResponseWrapper {
final List<SkuDetailsWrapper> skuDetailsList;

@override
bool operator ==(dynamic other) {
bool operator ==(Object other) {
if (other.runtimeType != runtimeType) {
return false;
}
Expand Down Expand Up @@ -248,7 +248,7 @@ class BillingResultWrapper {
final String? debugMessage;

@override
bool operator ==(dynamic other) {
bool operator ==(Object other) {
if (other.runtimeType != runtimeType) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: in_app_purchase_android
description: An implementation for the Android platform of the Flutter `in_app_purchase` plugin. This uses the Android BillingClient APIs.
repository: https://github.com/flutter/plugins/tree/main/packages/in_app_purchase/in_app_purchase_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+in_app_purchase%22
version: 0.2.2+5
version: 0.2.2+6

environment:
sdk: ">=2.14.0 <3.0.0"
Expand All @@ -28,4 +28,5 @@ dev_dependencies:
flutter_test:
sdk: flutter
json_serializable: ^6.0.0
mockito: ^5.1.0
test: ^1.16.0
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,60 @@ void main() {
expect(billingResult.debugMessage, kInvalidBillingResultErrorMessage);
expect(billingResult.responseCode, BillingResponse.error);
});

test('operator == of SkuDetailsWrapper works fine', () {
const SkuDetailsWrapper firstSkuDetailsInstance = SkuDetailsWrapper(
description: 'description',
freeTrialPeriod: 'freeTrialPeriod',
introductoryPrice: 'introductoryPrice',
introductoryPriceAmountMicros: 990000,
introductoryPriceCycles: 1,
introductoryPricePeriod: 'introductoryPricePeriod',
price: 'price',
priceAmountMicros: 1000,
priceCurrencyCode: 'priceCurrencyCode',
priceCurrencySymbol: r'$',
sku: 'sku',
subscriptionPeriod: 'subscriptionPeriod',
title: 'title',
type: SkuType.inapp,
originalPrice: 'originalPrice',
originalPriceAmountMicros: 1000,
);
const SkuDetailsWrapper secondSkuDetailsInstance = SkuDetailsWrapper(
description: 'description',
freeTrialPeriod: 'freeTrialPeriod',
introductoryPrice: 'introductoryPrice',
introductoryPriceAmountMicros: 990000,
introductoryPriceCycles: 1,
introductoryPricePeriod: 'introductoryPricePeriod',
price: 'price',
priceAmountMicros: 1000,
priceCurrencyCode: 'priceCurrencyCode',
priceCurrencySymbol: r'$',
sku: 'sku',
subscriptionPeriod: 'subscriptionPeriod',
title: 'title',
type: SkuType.inapp,
originalPrice: 'originalPrice',
originalPriceAmountMicros: 1000,
);
expect(firstSkuDetailsInstance == secondSkuDetailsInstance, isTrue);
});

test('operator == of BillingResultWrapper works fine', () {
const BillingResultWrapper firstBillingResultInstance =
BillingResultWrapper(
responseCode: BillingResponse.ok,
debugMessage: 'debugMessage',
);
const BillingResultWrapper secondBillingResultInstance =
BillingResultWrapper(
responseCode: BillingResponse.ok,
debugMessage: 'debugMessage',
);
expect(firstBillingResultInstance == secondBillingResultInstance, isTrue);
});
});
}

Expand Down

0 comments on commit 8d674f2

Please sign in to comment.