Skip to content

Commit 3a4b34c

Browse files
committed
Updated tests
1 parent ff8d082 commit 3a4b34c

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed

example/lib/main.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class _MyAppState extends State<MyApp> {
127127

128128
try {
129129
errorDialogFragmentShown =
130-
await GoogleApiAvailability.instance.showErrorDialogFragment();
130+
await GoogleApiAvailability.instance.showErrorDialogFragment();
131131
} on PlatformException {
132132
errorDialogFragmentShown = false;
133133
}
@@ -202,7 +202,9 @@ class _MyAppState extends State<MyApp> {
202202
child: const Text('Show error dialog fragment'),
203203
color: Colors.red,
204204
),
205-
Center(child: Text('Error dialog shown: $_errorDialogFragmentShown\n')),
205+
Center(
206+
child:
207+
Text('Error dialog shown: $_errorDialogFragmentShown\n')),
206208
],
207209
)),
208210
);

test/google_api_availability_test.dart

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,4 +231,45 @@ void main() {
231231
expect(showErrorNotification, true);
232232
});
233233
});
234+
235+
group('showErrorDialogFragment', () {
236+
test('Should receive false if not Android', () async {
237+
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
238+
239+
final showErrorDialogFragment =
240+
await const GoogleApiAvailability.private().showErrorDialogFragment();
241+
242+
expect(showErrorDialogFragment, false);
243+
244+
debugDefaultTargetPlatformOverride = null;
245+
});
246+
247+
test('Should receive false when showErrorDialogFragment is null', () async {
248+
const showErrorDialogFragment = null;
249+
250+
MethodChannelMock(
251+
channelName: 'flutter.baseflow.com/google_api_availability/methods',
252+
method: 'showErrorDialogFragment',
253+
result: showErrorDialogFragment,
254+
);
255+
256+
final showErrorDialogFragmentResult =
257+
await const GoogleApiAvailability.private().showErrorDialogFragment();
258+
259+
expect(showErrorDialogFragmentResult, false);
260+
});
261+
262+
test('Should receive true when error dialog fragment is shown', () async {
263+
MethodChannelMock(
264+
channelName: 'flutter.baseflow.com/google_api_availability/methods',
265+
method: 'showErrorDialogFragment',
266+
result: true,
267+
);
268+
269+
final showErrorDialogFragment =
270+
await const GoogleApiAvailability.private().showErrorDialogFragment();
271+
272+
expect(showErrorDialogFragment, true);
273+
});
274+
});
234275
}

0 commit comments

Comments
 (0)