@@ -8,15 +8,13 @@ void main() {
88 TestWidgetsFlutterBinding .ensureInitialized ();
99
1010 group ('checkGooglePlayServiceAvailability' , () {
11- test ('Should receive notAvailableOnPlatform if not Android' , () async {
11+ test ('Should throw UnsuppertedError if not Android' , () async {
1212 debugDefaultTargetPlatformOverride = TargetPlatform .iOS;
1313
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 >()));
2018
2119 debugDefaultTargetPlatformOverride = null ;
2220 });
@@ -59,63 +57,26 @@ void main() {
5957 });
6058
6159 group ('makeGooglePlayServicesAvailable' , () {
62- test ('Should receive false if not Android' , () async {
60+ test ('Should throw UnsuppertedError if not Android' , () async {
6361 debugDefaultTargetPlatformOverride = TargetPlatform .iOS;
6462
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 >()));
7067
7168 debugDefaultTargetPlatformOverride = null ;
7269 });
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- });
10770 });
10871
10972 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 {
11374 debugDefaultTargetPlatformOverride = TargetPlatform .iOS;
11475
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 >()) );
11980
12081 debugDefaultTargetPlatformOverride = null ;
12182 });
@@ -151,13 +112,13 @@ void main() {
151112 });
152113
153114 group ('isUserResolvable' , () {
154- test ('Should receive false if not Android' , () async {
115+ test ('Should throw UnsuppertedError if not Android' , () async {
155116 debugDefaultTargetPlatformOverride = TargetPlatform .iOS;
156117
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 >()) );
161122
162123 debugDefaultTargetPlatformOverride = null ;
163124 });
@@ -192,54 +153,26 @@ void main() {
192153 });
193154
194155 group ('showErrorNotification' , () {
195- test ('Should receive false if not Android' , () async {
156+ test ('Should throw UnsuppertedError if not Android' , () async {
196157 debugDefaultTargetPlatformOverride = TargetPlatform .iOS;
197158
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 >()) );
202163
203164 debugDefaultTargetPlatformOverride = null ;
204165 });
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- });
233166 });
234167
235168 group ('showErrorDialogFragment' , () {
236- test ('Should receive false if not Android' , () async {
169+ test ('Should throw UnsuppertedError if not Android' , () async {
237170 debugDefaultTargetPlatformOverride = TargetPlatform .iOS;
238171
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 >()) );
243176
244177 debugDefaultTargetPlatformOverride = null ;
245178 });
0 commit comments