| Add Flutter example app with Linux runner 7fdf712 nandi 8h ago | 1 | // Smoke test for the V bridge behind the UI. Runs on the host, so it loads |
| 2 | // the same libvflutter.so the desktop app does. |
| 3 | |
| 4 | import 'package:flutter_test/flutter_test.dart'; |
| 5 | |
| 6 | import 'package:vflutter_ffi_example/main.dart'; |
| 7 | |
| 8 | void main() { |
| 9 | testWidgets('renders results computed in V', (WidgetTester tester) async { |
| 10 | await tester.pumpWidget(const ExampleApp()); |
| 11 | |
| 12 | // vf_add across the C ABI. |
| 13 | expect(find.text('42'), findsOneWidget); |
| 14 | |
| 15 | // vf_greet round-trips a string and frees the V allocation. |
| 16 | expect(find.text('Hello, Flutter, from V!'), findsOneWidget); |
| 17 | }); |
| 18 | |
| 19 | testWidgets('background isolate returns the same answer', |
| 20 | (WidgetTester tester) async { |
| 21 | await tester.pumpWidget(const ExampleApp()); |
| 22 | |
| 23 | expect(find.text('(not run)'), findsNWidgets(2)); |
| 24 | |
| 25 | // greetAsync spawns a real isolate, which the default fake-async clock |
| 26 | // never lets complete — runAsync is required for the await to resolve. |
| 27 | await tester.runAsync(() async { |
| 28 | await tester.tap(find.text('run on background isolate')); |
| 29 | await Future<void>.delayed(const Duration(seconds: 2)); |
| 30 | }); |
| 31 | await tester.pump(); |
| 32 | |
| 33 | // Once on the sync row, once on the async row. |
| 34 | expect(find.text('Hello, Flutter, from V!'), findsNWidgets(2)); |
| 35 | }); |
| 36 | } |