nandi/vflutter_ffipublic Fork 0
f7c3825dc671305345e20a62ea6ac8facbc903bb
Commits
Clone
git clone https://git.rickub.com/nandi/vflutter_ffi.git
git clone ssh://git@rickub.com/nandi/vflutter_ffi.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Add a Mandelbrot example app, and a V kernel worth demonstrating 81540bb · on f7c3825dc671305345e20a62ea6ac8facbc903bb · nandithebull · 10h ago
explorer_test.dart · 71 lines · 2.7 KBDart Blame HistoryRaw
 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Widget-level checks on the explorer. These need the native library on the
// loader path:
//
//   cd example && LD_LIBRARY_PATH=../build flutter test
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:vflutter_ffi_example/main.dart';

/// pumpAndSettle cannot be used here: the in-flight-render spinner animates
/// indefinitely, and rendering runs on real isolates outside the fake clock.
Future<void> settle(WidgetTester tester) async {
  for (var i = 0; i < 20; i++) {
    await tester.pump(const Duration(milliseconds: 50));
  }
}

void main() {
  /// The side panel only exists in the wide layout, so size the surface like a
  /// desktop window rather than the 800x600 test default.
  Future<void> pumpWide(WidgetTester tester) async {
    tester.view.physicalSize = const Size(1400, 900);
    tester.view.devicePixelRatio = 1.0;
    addTearDown(tester.view.reset);
    await tester.pumpWidget(const ExampleApp());
    await tester.pump(const Duration(milliseconds: 100));
  }

  testWidgets('starts at the documented defaults, not the slider maxima',
      (tester) async {
    await pumpWide(tester);

    final sliders = tester.widgetList<Slider>(find.byType(Slider)).toList();
    expect(sliders, hasLength(2));
    expect(sliders[0].value, 400, reason: 'iterations should default to 400');
    expect(sliders[1].value, 4, reason: 'isolates should default to 4');
  });

  testWidgets('reset restores the framing without touching iterations',
      (tester) async {
    await pumpWide(tester);

    // Move the iteration slider off its default, then reset the view.
    await tester.drag(find.byType(Slider).first, const Offset(200, 0));
    await settle(tester);
    final changed =
        tester.widgetList<Slider>(find.byType(Slider)).first.value;
    expect(changed, greaterThan(400),
        reason: 'the drag should have raised the iteration count');

    await tester.tap(find.text('Reset view'));
    await settle(tester);

    // Reset owns pan/zoom only: the iteration setting must survive it.
    expect(tester.widgetList<Slider>(find.byType(Slider)).first.value, changed);
    expect(find.textContaining('zoom 1.0x'), findsOneWidget);
  });

  testWidgets('narrow layout lays out without overflowing', (tester) async {
    // Regression guard: the controls used to be a ListView nested inside the
    // page's ListView, which threw "Vertical viewport was given unbounded
    // height" and broke the whole mobile layout.
    tester.view.physicalSize = const Size(420, 900);
    tester.view.devicePixelRatio = 1.0;
    addTearDown(tester.view.reset);

    await tester.pumpWidget(const ExampleApp());
    await tester.pump(const Duration(milliseconds: 100));

    expect(tester.takeException(), isNull);
  });
}