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

Commit ef9effe

Browse files
authored
[google_sign_in, in_app_purchase_android] Add availability to mock models (#5642)
1 parent e360a5f commit ef9effe

File tree

9 files changed

+72
-8
lines changed

9 files changed

+72
-8
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,4 @@ Rahul Raj <[email protected]>
6767
Daniel Roek <[email protected]>
6868
TheOneWithTheBraid <[email protected]>
6969
Rulong Chen(陈汝龙) <[email protected]>
70+
Hwanseok Kang <[email protected]>

packages/google_sign_in/google_sign_in/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
## NEXT
1+
## 5.3.2
22

3+
* Enables mocking models by changing overridden operator == parameter type from `dynamic` to `Object`.
34
* Updates tests to use a mock platform instead of relying on default
45
method channel implementation internals.
56
* Removes example workaround to build for arm64 iOS simulators.

packages/google_sign_in/google_sign_in/lib/google_sign_in.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class GoogleSignInAccount implements GoogleIdentity {
129129
}
130130

131131
@override
132-
bool operator ==(dynamic other) {
132+
bool operator ==(Object other) {
133133
if (identical(this, other)) {
134134
return true;
135135
}

packages/google_sign_in/google_sign_in/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: Flutter plugin for Google Sign-In, a secure authentication system
33
for signing in with a Google account on Android and iOS.
44
repository: https://github.com/flutter/plugins/tree/main/packages/google_sign_in/google_sign_in
55
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+google_sign_in%22
6-
version: 5.3.1
6+
version: 5.3.2
77

88

99
environment:

packages/google_sign_in/google_sign_in/test/google_sign_in_test.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ import 'package:google_sign_in/google_sign_in.dart';
99
import 'package:google_sign_in_platform_interface/google_sign_in_platform_interface.dart';
1010
import 'package:mockito/annotations.dart';
1111
import 'package:mockito/mockito.dart';
12-
1312
import 'google_sign_in_test.mocks.dart';
1413

14+
/// Verify that [GoogleSignInAccount] can be mocked even though it's unused
15+
// ignore: must_be_immutable
16+
class MockGoogleSignInAccount extends Mock implements GoogleSignInAccount {}
17+
1518
@GenerateMocks(<Type>[GoogleSignInPlatform])
1619
void main() {
1720
late MockGoogleSignInPlatform mockPlatform;

packages/in_app_purchase/in_app_purchase_android/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.2.2+6
2+
3+
* Enables mocking models by changing overridden operator == parameter type from `dynamic` to `Object`.
4+
15
## 0.2.2+5
26

37
* Minor fixes for new analysis options.

packages/in_app_purchase/in_app_purchase_android/lib/src/billing_client_wrappers/sku_details_wrapper.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class SkuDetailsWrapper {
135135
final int originalPriceAmountMicros;
136136

137137
@override
138-
bool operator ==(dynamic other) {
138+
bool operator ==(Object other) {
139139
if (other.runtimeType != runtimeType) {
140140
return false;
141141
}
@@ -203,7 +203,7 @@ class SkuDetailsResponseWrapper {
203203
final List<SkuDetailsWrapper> skuDetailsList;
204204

205205
@override
206-
bool operator ==(dynamic other) {
206+
bool operator ==(Object other) {
207207
if (other.runtimeType != runtimeType) {
208208
return false;
209209
}
@@ -248,7 +248,7 @@ class BillingResultWrapper {
248248
final String? debugMessage;
249249

250250
@override
251-
bool operator ==(dynamic other) {
251+
bool operator ==(Object other) {
252252
if (other.runtimeType != runtimeType) {
253253
return false;
254254
}

packages/in_app_purchase/in_app_purchase_android/pubspec.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: in_app_purchase_android
22
description: An implementation for the Android platform of the Flutter `in_app_purchase` plugin. This uses the Android BillingClient APIs.
33
repository: https://github.com/flutter/plugins/tree/main/packages/in_app_purchase/in_app_purchase_android
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+in_app_purchase%22
5-
version: 0.2.2+5
5+
version: 0.2.2+6
66

77
environment:
88
sdk: ">=2.14.0 <3.0.0"
@@ -28,4 +28,5 @@ dev_dependencies:
2828
flutter_test:
2929
sdk: flutter
3030
json_serializable: ^6.0.0
31+
mockito: ^5.1.0
3132
test: ^1.16.0

packages/in_app_purchase/in_app_purchase_android/test/billing_client_wrappers/sku_details_wrapper_test.dart

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,60 @@ void main() {
125125
expect(billingResult.debugMessage, kInvalidBillingResultErrorMessage);
126126
expect(billingResult.responseCode, BillingResponse.error);
127127
});
128+
129+
test('operator == of SkuDetailsWrapper works fine', () {
130+
const SkuDetailsWrapper firstSkuDetailsInstance = SkuDetailsWrapper(
131+
description: 'description',
132+
freeTrialPeriod: 'freeTrialPeriod',
133+
introductoryPrice: 'introductoryPrice',
134+
introductoryPriceAmountMicros: 990000,
135+
introductoryPriceCycles: 1,
136+
introductoryPricePeriod: 'introductoryPricePeriod',
137+
price: 'price',
138+
priceAmountMicros: 1000,
139+
priceCurrencyCode: 'priceCurrencyCode',
140+
priceCurrencySymbol: r'$',
141+
sku: 'sku',
142+
subscriptionPeriod: 'subscriptionPeriod',
143+
title: 'title',
144+
type: SkuType.inapp,
145+
originalPrice: 'originalPrice',
146+
originalPriceAmountMicros: 1000,
147+
);
148+
const SkuDetailsWrapper secondSkuDetailsInstance = SkuDetailsWrapper(
149+
description: 'description',
150+
freeTrialPeriod: 'freeTrialPeriod',
151+
introductoryPrice: 'introductoryPrice',
152+
introductoryPriceAmountMicros: 990000,
153+
introductoryPriceCycles: 1,
154+
introductoryPricePeriod: 'introductoryPricePeriod',
155+
price: 'price',
156+
priceAmountMicros: 1000,
157+
priceCurrencyCode: 'priceCurrencyCode',
158+
priceCurrencySymbol: r'$',
159+
sku: 'sku',
160+
subscriptionPeriod: 'subscriptionPeriod',
161+
title: 'title',
162+
type: SkuType.inapp,
163+
originalPrice: 'originalPrice',
164+
originalPriceAmountMicros: 1000,
165+
);
166+
expect(firstSkuDetailsInstance == secondSkuDetailsInstance, isTrue);
167+
});
168+
169+
test('operator == of BillingResultWrapper works fine', () {
170+
const BillingResultWrapper firstBillingResultInstance =
171+
BillingResultWrapper(
172+
responseCode: BillingResponse.ok,
173+
debugMessage: 'debugMessage',
174+
);
175+
const BillingResultWrapper secondBillingResultInstance =
176+
BillingResultWrapper(
177+
responseCode: BillingResponse.ok,
178+
debugMessage: 'debugMessage',
179+
);
180+
expect(firstBillingResultInstance == secondBillingResultInstance, isTrue);
181+
});
128182
});
129183
}
130184

0 commit comments

Comments
 (0)