@@ -8,15 +8,13 @@ void main() {
8
8
TestWidgetsFlutterBinding .ensureInitialized ();
9
9
10
10
group ('checkGooglePlayServiceAvailability' , () {
11
- test ('Should receive notAvailableOnPlatform if not Android' , () async {
11
+ test ('Should throw UnsuppertedError if not Android' , () async {
12
12
debugDefaultTargetPlatformOverride = TargetPlatform .iOS;
13
13
14
- final googlePlayServiceAvailability =
15
- await const GoogleApiAvailability .private ()
16
- .checkGooglePlayServicesAvailability ();
17
-
18
- expect (googlePlayServiceAvailability,
19
- GooglePlayServicesAvailability .notAvailableOnPlatform);
14
+ expect (
15
+ () async => await const GoogleApiAvailability .private ()
16
+ .checkGooglePlayServicesAvailability (),
17
+ throwsA (isA <UnsupportedError >()));
20
18
21
19
debugDefaultTargetPlatformOverride = null ;
22
20
});
@@ -59,63 +57,26 @@ void main() {
59
57
});
60
58
61
59
group ('makeGooglePlayServicesAvailable' , () {
62
- test ('Should receive false if not Android' , () async {
60
+ test ('Should throw UnsuppertedError if not Android' , () async {
63
61
debugDefaultTargetPlatformOverride = TargetPlatform .iOS;
64
62
65
- final googlePlayServiceAvailability =
66
- await const GoogleApiAvailability .private ()
67
- .makeGooglePlayServicesAvailable ();
68
-
69
- expect (googlePlayServiceAvailability, false );
63
+ expect (
64
+ () async => await const GoogleApiAvailability .private ()
65
+ .makeGooglePlayServicesAvailable (),
66
+ throwsA (isA <UnsupportedError >()));
70
67
71
68
debugDefaultTargetPlatformOverride = null ;
72
69
});
73
-
74
- test ('Should receive false when availability is null' , () async {
75
- const availability = null ;
76
-
77
- MethodChannelMock (
78
- channelName: 'flutter.baseflow.com/google_api_availability/methods' ,
79
- method: 'makeGooglePlayServicesAvailable' ,
80
- result: availability,
81
- );
82
-
83
- final googlePlayServiceAvailability =
84
- await const GoogleApiAvailability .private ()
85
- .makeGooglePlayServicesAvailable ();
86
-
87
- expect (googlePlayServiceAvailability, false );
88
- });
89
-
90
- test (
91
- 'Should receive true when device is able to set Google Play Services to available' ,
92
- () async {
93
- const availability = true ;
94
-
95
- MethodChannelMock (
96
- channelName: 'flutter.baseflow.com/google_api_availability/methods' ,
97
- method: 'makeGooglePlayServicesAvailable' ,
98
- result: availability,
99
- );
100
-
101
- final makeGooglePlayServiceAvailability =
102
- await const GoogleApiAvailability .private ()
103
- .makeGooglePlayServicesAvailable ();
104
-
105
- expect (makeGooglePlayServiceAvailability, true );
106
- });
107
70
});
108
71
109
72
group ('getErrorString' , () {
110
- test (
111
- 'Should receive "Not available on non Android devices" if not on Android' ,
112
- () async {
73
+ test ('Should throw UnsuppertedError if not on Android' , () async {
113
74
debugDefaultTargetPlatformOverride = TargetPlatform .iOS;
114
75
115
- final errorString =
116
- await const GoogleApiAvailability . private (). getErrorString ();
117
-
118
- expect (errorString, "Not available on non Android devices" );
76
+ expect (
77
+ () async =>
78
+ await const GoogleApiAvailability . private (). getErrorString (),
79
+ throwsA ( isA < UnsupportedError >()) );
119
80
120
81
debugDefaultTargetPlatformOverride = null ;
121
82
});
@@ -151,13 +112,13 @@ void main() {
151
112
});
152
113
153
114
group ('isUserResolvable' , () {
154
- test ('Should receive false if not Android' , () async {
115
+ test ('Should throw UnsuppertedError if not Android' , () async {
155
116
debugDefaultTargetPlatformOverride = TargetPlatform .iOS;
156
117
157
- final isUserResolvable =
158
- await const GoogleApiAvailability . private (). isUserResolvable ();
159
-
160
- expect (isUserResolvable, false );
118
+ expect (
119
+ () async =>
120
+ await const GoogleApiAvailability . private (). isUserResolvable (),
121
+ throwsA ( isA < UnsupportedError >()) );
161
122
162
123
debugDefaultTargetPlatformOverride = null ;
163
124
});
@@ -192,54 +153,26 @@ void main() {
192
153
});
193
154
194
155
group ('showErrorNotification' , () {
195
- test ('Should receive false if not Android' , () async {
156
+ test ('Should throw UnsuppertedError if not Android' , () async {
196
157
debugDefaultTargetPlatformOverride = TargetPlatform .iOS;
197
158
198
- final showErrorNotification =
199
- await const GoogleApiAvailability .private (). showErrorNotification ();
200
-
201
- expect (showErrorNotification, false );
159
+ expect (
160
+ () async => await const GoogleApiAvailability .private ()
161
+ . showErrorNotification (),
162
+ throwsA ( isA < UnsupportedError >()) );
202
163
203
164
debugDefaultTargetPlatformOverride = null ;
204
165
});
205
-
206
- test ('Should receive false when showErrorNotification is null' , () async {
207
- const showErrorNotification = null ;
208
-
209
- MethodChannelMock (
210
- channelName: 'flutter.baseflow.com/google_api_availability/methods' ,
211
- method: 'showErrorNotification' ,
212
- result: showErrorNotification,
213
- );
214
-
215
- final showErrorNotificationResult =
216
- await const GoogleApiAvailability .private ().showErrorNotification ();
217
-
218
- expect (showErrorNotificationResult, false );
219
- });
220
-
221
- test ('Should receive true when notification is shown' , () async {
222
- MethodChannelMock (
223
- channelName: 'flutter.baseflow.com/google_api_availability/methods' ,
224
- method: 'showErrorNotification' ,
225
- result: true ,
226
- );
227
-
228
- final showErrorNotification =
229
- await const GoogleApiAvailability .private ().showErrorNotification ();
230
-
231
- expect (showErrorNotification, true );
232
- });
233
166
});
234
167
235
168
group ('showErrorDialogFragment' , () {
236
- test ('Should receive false if not Android' , () async {
169
+ test ('Should throw UnsuppertedError if not Android' , () async {
237
170
debugDefaultTargetPlatformOverride = TargetPlatform .iOS;
238
171
239
- final showErrorDialogFragment =
240
- await const GoogleApiAvailability .private (). showErrorDialogFragment ();
241
-
242
- expect (showErrorDialogFragment, false );
172
+ expect (
173
+ () async => await const GoogleApiAvailability .private ()
174
+ . showErrorDialogFragment (),
175
+ throwsA ( isA < UnsupportedError >()) );
243
176
244
177
debugDefaultTargetPlatformOverride = null ;
245
178
});
0 commit comments