-
Notifications
You must be signed in to change notification settings - Fork 307
/
Copy pathcustom_handler_test.dart
34 lines (30 loc) · 1.02 KB
/
custom_handler_test.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import 'package:flutter_rust_bridge/flutter_rust_bridge.dart';
import 'package:frb_example_pure_dart/src/rust/api/simple.dart';
import 'package:frb_example_pure_dart/src/rust/frb_generated.dart';
import 'package:test/test.dart';
Future<void> main() async {
final customHandler = _MyHandler();
await RustLib.init(handler: customHandler);
test('can use custom handler', () async {
expect(customHandler.logs, <String>[
'executeNormal init_app',
'executeNormal my_init_one',
'executeNormal my_init_two',
]);
expect(await simpleAdderTwinNormal(a: 1, b: 2), 3);
expect(customHandler.logs, [
'executeNormal init_app',
'executeNormal my_init_one',
'executeNormal my_init_two',
'executeNormal simple_adder_twin_normal',
]);
});
}
class _MyHandler extends BaseHandler {
final logs = <String>[];
@override
Future<S> executeNormal<S, E extends Object>(NormalTask<S, E> task) {
logs.add('executeNormal ${task.constMeta.debugName}');
return super.executeNormal(task);
}
}