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
35
36
|
// Smoke test for the V bridge behind the UI. Runs on the host, so it loads
// the same libvflutter.so the desktop app does.
import 'package:flutter_test/flutter_test.dart';
import 'package:vflutter_ffi_example/main.dart';
void main() {
testWidgets('renders results computed in V', (WidgetTester tester) async {
await tester.pumpWidget(const ExampleApp());
// vf_add across the C ABI.
expect(find.text('42'), findsOneWidget);
// vf_greet round-trips a string and frees the V allocation.
expect(find.text('Hello, Flutter, from V!'), findsOneWidget);
});
testWidgets('background isolate returns the same answer',
(WidgetTester tester) async {
await tester.pumpWidget(const ExampleApp());
expect(find.text('(not run)'), findsNWidgets(2));
// greetAsync spawns a real isolate, which the default fake-async clock
// never lets complete — runAsync is required for the await to resolve.
await tester.runAsync(() async {
await tester.tap(find.text('run on background isolate'));
await Future<void>.delayed(const Duration(seconds: 2));
});
await tester.pump();
// Once on the sync row, once on the async row.
expect(find.text('Hello, Flutter, from V!'), findsNWidgets(2));
});
}
|