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

Commit beef9a8

Browse files
author
Chris Yang
authored
[android_intent] move unit test to nullsafety (#3659)
1 parent b90e42b commit beef9a8

File tree

3 files changed

+74
-7
lines changed

3 files changed

+74
-7
lines changed

packages/android_intent/pubspec.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ dependencies:
1717
meta: ^1.3.0
1818
dev_dependencies:
1919
test: ^1.16.3
20-
mockito: ^5.0.0-nullsafety.7
20+
mockito: ^5.0.0
2121
flutter_test:
2222
sdk: flutter
2323
pedantic: ^1.10.0
24+
build_runner: ^1.11.1
2425

2526
environment:
2627
sdk: ">=2.12.0-259.9.beta <3.0.0"

packages/android_intent/test/android_intent_test.dart

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,27 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
// @dart = 2.9
6-
75
import 'package:android_intent/flag.dart';
86
import 'package:flutter/services.dart';
97
import 'package:flutter_test/flutter_test.dart';
108
import 'package:android_intent/android_intent.dart';
9+
import 'package:mockito/annotations.dart';
1110
import 'package:mockito/mockito.dart';
1211
import 'package:platform/platform.dart';
1312

13+
import 'android_intent_test.mocks.dart';
14+
15+
@GenerateMocks([MethodChannel])
1416
void main() {
15-
AndroidIntent androidIntent;
16-
MockMethodChannel mockChannel;
17+
late AndroidIntent androidIntent;
18+
late MockMethodChannel mockChannel;
1719

1820
setUp(() {
1921
mockChannel = MockMethodChannel();
2022
when(mockChannel.invokeMethod<bool>('canResolveActivity', any))
2123
.thenAnswer((realInvocation) async => true);
24+
when(mockChannel.invokeMethod<void>('launch', any))
25+
.thenAnswer((realInvocation) async => {});
2226
});
2327

2428
group('AndroidIntent', () {
@@ -178,5 +182,3 @@ void main() {
178182
});
179183
});
180184
}
181-
182-
class MockMethodChannel extends Mock implements MethodChannel {}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// Mocks generated by Mockito 5.0.0 from annotations
2+
// in android_intent/test/android_intent_test.dart.
3+
// Do not manually edit this file.
4+
5+
import 'dart:async' as _i5;
6+
7+
import 'package:flutter/src/services/binary_messenger.dart' as _i3;
8+
import 'package:flutter/src/services/message_codec.dart' as _i2;
9+
import 'package:flutter/src/services/platform_channel.dart' as _i4;
10+
import 'package:mockito/mockito.dart' as _i1;
11+
12+
// ignore_for_file: comment_references
13+
// ignore_for_file: unnecessary_parenthesis
14+
15+
class _FakeMethodCodec extends _i1.Fake implements _i2.MethodCodec {}
16+
17+
class _FakeBinaryMessenger extends _i1.Fake implements _i3.BinaryMessenger {}
18+
19+
/// A class which mocks [MethodChannel].
20+
///
21+
/// See the documentation for Mockito's code generation for more information.
22+
class MockMethodChannel extends _i1.Mock implements _i4.MethodChannel {
23+
MockMethodChannel() {
24+
_i1.throwOnMissingStub(this);
25+
}
26+
27+
@override
28+
String get name =>
29+
(super.noSuchMethod(Invocation.getter(#name), returnValue: '') as String);
30+
@override
31+
_i2.MethodCodec get codec => (super.noSuchMethod(Invocation.getter(#codec),
32+
returnValue: _FakeMethodCodec()) as _i2.MethodCodec);
33+
@override
34+
_i3.BinaryMessenger get binaryMessenger =>
35+
(super.noSuchMethod(Invocation.getter(#binaryMessenger),
36+
returnValue: _FakeBinaryMessenger()) as _i3.BinaryMessenger);
37+
@override
38+
_i5.Future<T?> invokeMethod<T>(String? method, [dynamic arguments]) =>
39+
(super.noSuchMethod(Invocation.method(#invokeMethod, [method, arguments]),
40+
returnValue: Future.value(null)) as _i5.Future<T?>);
41+
@override
42+
_i5.Future<List<T>?> invokeListMethod<T>(String? method,
43+
[dynamic arguments]) =>
44+
(super.noSuchMethod(
45+
Invocation.method(#invokeListMethod, [method, arguments]),
46+
returnValue: Future.value(<T>[])) as _i5.Future<List<T>?>);
47+
@override
48+
_i5.Future<Map<K, V>?> invokeMapMethod<K, V>(String? method,
49+
[dynamic arguments]) =>
50+
(super.noSuchMethod(
51+
Invocation.method(#invokeMapMethod, [method, arguments]),
52+
returnValue: Future.value(<K, V>{})) as _i5.Future<Map<K, V>?>);
53+
@override
54+
bool checkMethodCallHandler(
55+
_i5.Future<dynamic> Function(_i2.MethodCall)? handler) =>
56+
(super.noSuchMethod(Invocation.method(#checkMethodCallHandler, [handler]),
57+
returnValue: false) as bool);
58+
@override
59+
bool checkMockMethodCallHandler(
60+
_i5.Future<dynamic> Function(_i2.MethodCall)? handler) =>
61+
(super.noSuchMethod(
62+
Invocation.method(#checkMockMethodCallHandler, [handler]),
63+
returnValue: false) as bool);
64+
}

0 commit comments

Comments
 (0)