initial work to split into dart_filament and flutter_filament
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:ec2a9627f23ffe07750323c25afa78c6c7fcb7d26b5ed36d119363ced0b60f29
|
||||
size 258304
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:53256c9443c6d36edfb8c1234711173c847126e888d714151ae026c57495fe6b
|
||||
size 1875814
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:b0c715cadbf84c2161099e8373a404c7d6dbb093faf4157aa0e0aa3825c28217
|
||||
size 1868778
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:56a431b561db7038ad7fe92d025fc2fe2806dfa2cf68c29a0380c3cbd2b66fb5
|
||||
size 1742539
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:14193a392baf348f77895ca7bfb8cee160407c762d03c01bf1f7b5b771a9b1ab
|
||||
size 2282401
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:77badd0b2a59122949e497297052064c403006272daa4488db43e492d60093e2
|
||||
size 1959141
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:bdf63e19e5a992f2c848cf71b55ceddf8930d6a9368c9b3adcc13e7c478c7146
|
||||
size 1889777
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:651c19434ae3753488eb840695955b98db9d66a20b79bee1e21b3384c2358025
|
||||
size 1609541
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:f11462c0fdf30d101b6ed6c430734adcf6451818f3c7824126c8423014836773
|
||||
size 2060944
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:beb941d33777ad2e1d6ef3704ba6a63b3a5608ca885a516a1c9e807a31b533fc
|
||||
size 1608407
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:2bcae11fd2eb593c419a62731e1799f7340408b28ad56575fab5f79db608ae17
|
||||
size 2062339
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:dc3b3c5e0678a5b71728cea8961925e6c0fb44a59340aa2d77d4ea92a24cc7d6
|
||||
size 316763
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:6dbbb518a86c546f188134c1d369762664f188dd6b9a38ec13963b6187cb4b25
|
||||
size 1456648
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:2d7951418e5875da7c7ed8dea482dbf1cbe81a42b47d255db7f1b6e11c16a193
|
||||
size 1876507
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:80cd11f5be75012cfdf953569e409a355826ca23af35feba41aac78f0e3d35d8
|
||||
size 1874857
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:e605bb18426ea657b9352ecca51f0b55daac904b15dba3afdcffc412a445548a
|
||||
size 1941423
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:c026e8723922a6c56ab8e28f99a29805c53627ff5a659971590c95d89d7ac6bd
|
||||
size 1940845
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:fffa285edd2c5474e16475cafc67d2519e000b74178ce1a0f8d88229827cfabf
|
||||
size 1937116
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:1db7a2f831d83e75e42dfe4f0547e9ed1f171152f45103e8f250d2b52ee3a8e1
|
||||
size 1937776
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:00c70e7e77b98e4e72d0dde82482066096ebd502d25cccfada9cb87de332ecac
|
||||
size 1941844
|
||||
@@ -0,0 +1,190 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:integration_test/integration_test.dart';
|
||||
import 'package:flutter_filament/widgets/filament_widget.dart';
|
||||
import '../lib/main.dart' as app;
|
||||
|
||||
void main() {
|
||||
final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized()
|
||||
as IntegrationTestWidgetsFlutterBinding;
|
||||
|
||||
late String platformIdentifier;
|
||||
if (Platform.isIOS) {
|
||||
platformIdentifier = "ios";
|
||||
} else if (Platform.isAndroid) {
|
||||
platformIdentifier = "android";
|
||||
} else if (Platform.isMacOS) {
|
||||
platformIdentifier = "macos";
|
||||
} else if (Platform.isWindows) {
|
||||
platformIdentifier = "windows";
|
||||
} else if (Platform.isLinux) {
|
||||
platformIdentifier = "linux";
|
||||
} else {
|
||||
throw Exception("Unexpected platform");
|
||||
}
|
||||
|
||||
int _counter = 0;
|
||||
|
||||
Future _snapshot(WidgetTester tester, String label, [int seconds = 0]) async {
|
||||
await tester.pumpAndSettle(Duration(milliseconds: 16));
|
||||
for (int i = 0; i < seconds; i++) {
|
||||
await Future.delayed(Duration(seconds: 1));
|
||||
await tester.pumpAndSettle(Duration(milliseconds: 16));
|
||||
}
|
||||
await tester.pumpAndSettle(Duration(milliseconds: 16));
|
||||
var screenshotPath = '$platformIdentifier/${_counter}_$label';
|
||||
if (Platform.isIOS) {
|
||||
// this is currently hanging on Android
|
||||
// see https://github.com/flutter/flutter/issues/127306
|
||||
// it is also not yet implemented on Windows or MacOS
|
||||
await binding.convertFlutterSurfaceToImage();
|
||||
final bytes = await binding.takeScreenshot(screenshotPath);
|
||||
}
|
||||
_counter++;
|
||||
}
|
||||
|
||||
Future tap(WidgetTester tester, String label, [int seconds = 0]) async {
|
||||
var target = find.text(label, skipOffstage: false);
|
||||
|
||||
if (!target.hasFound) {
|
||||
print("Couldn't find target, waiting 100ms");
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
target = find.text(label);
|
||||
}
|
||||
|
||||
await tester.tap(target.first);
|
||||
await _snapshot(tester, label.replaceAll(RegExp("[ -:]"), ""), seconds);
|
||||
}
|
||||
|
||||
Future<void> pumpUntilFound(
|
||||
WidgetTester tester,
|
||||
Finder finder, {
|
||||
Duration timeout = const Duration(seconds: 30),
|
||||
}) async {
|
||||
bool timerDone = false;
|
||||
final timer = Timer(
|
||||
timeout, () => throw TimeoutException("Pump until has timed out"));
|
||||
while (timerDone != true) {
|
||||
await tester.pump();
|
||||
|
||||
final found = tester.any(finder);
|
||||
if (found) {
|
||||
timerDone = true;
|
||||
}
|
||||
}
|
||||
timer.cancel();
|
||||
}
|
||||
|
||||
testWidgets('test', (WidgetTester tester) async {
|
||||
app.main();
|
||||
await pumpUntilFound(tester, find.byType(app.ExampleWidget));
|
||||
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await _snapshot(tester, "fresh");
|
||||
|
||||
await tap(tester, "Controller / Viewer");
|
||||
await tap(tester, "Create FlutterFilamentPlugin (default ubershader)");
|
||||
await tap(tester, "Controller / Viewer");
|
||||
await tap(tester, "Create FilamentViewer",
|
||||
4); // on older devices this may take a while, so let's insert a length delay
|
||||
|
||||
await tap(tester, "Scene");
|
||||
await tap(tester, "Rendering");
|
||||
await tap(tester, "Set continuous rendering to true");
|
||||
|
||||
await tap(tester, "Scene");
|
||||
await tap(tester, "Assets");
|
||||
await tap(tester, "Shapes");
|
||||
await tap(tester, "Load GLB");
|
||||
|
||||
await tester.pump();
|
||||
|
||||
await tap(tester, "Scene");
|
||||
await tap(tester, "Assets");
|
||||
await tap(tester, "Load skybox", 1);
|
||||
|
||||
await tap(tester, "Scene");
|
||||
await tap(tester, "Assets");
|
||||
await tap(tester, "Load IBL", 1);
|
||||
|
||||
final Offset pointerLocation =
|
||||
tester.getCenter(find.byType(FilamentWidget));
|
||||
TestPointer testPointer = TestPointer(1, PointerDeviceKind.mouse);
|
||||
|
||||
// scroll/zoom
|
||||
testPointer.hover(pointerLocation);
|
||||
await tester.sendEventToBinding(testPointer.scroll(const Offset(0.0, 1.0)));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.sendEventToBinding(testPointer.scroll(const Offset(0.0, 1.0)));
|
||||
await tester.pumpAndSettle();
|
||||
await _snapshot(tester, "zoomin");
|
||||
|
||||
// rotate
|
||||
testPointer =
|
||||
TestPointer(1, PointerDeviceKind.mouse, null, kTertiaryButton);
|
||||
testPointer.hover(pointerLocation);
|
||||
await tester.sendEventToBinding(testPointer.down(pointerLocation));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.sendEventToBinding(
|
||||
testPointer.move(pointerLocation + Offset(10.0, 10.0)));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.sendEventToBinding(
|
||||
testPointer.move(pointerLocation + Offset(20.0, 20.0)));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.sendEventToBinding(testPointer.up());
|
||||
|
||||
await _snapshot(tester, "rotate", 2);
|
||||
|
||||
// pan
|
||||
testPointer = TestPointer(1, PointerDeviceKind.mouse, null, kPrimaryButton);
|
||||
testPointer.hover(pointerLocation);
|
||||
await tester.sendEventToBinding(testPointer.down(pointerLocation));
|
||||
await tester
|
||||
.sendEventToBinding(testPointer.move(pointerLocation + Offset(0, 1.0)));
|
||||
|
||||
for (int i = 0; i < 60; i++) {
|
||||
await tester.sendEventToBinding(testPointer
|
||||
.move(pointerLocation + Offset(i.toDouble() * 2, i.toDouble() * 2)));
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
await tester.sendEventToBinding(testPointer.up());
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await _snapshot(tester, "pan");
|
||||
|
||||
await tap(tester, "Scene");
|
||||
await tap(tester, "Assets");
|
||||
await tap(tester, "Shapes");
|
||||
await tap(tester, "Transform to unit cube");
|
||||
|
||||
await tap(tester, "Scene");
|
||||
await tap(tester, "Assets");
|
||||
await tap(tester, "Shapes");
|
||||
await tap(tester, "Set position to 1, 1, -1");
|
||||
|
||||
await tap(tester, "Scene");
|
||||
await tap(tester, "Camera");
|
||||
await tap(tester, "Disable frustum culling");
|
||||
|
||||
await tap(tester, "Scene");
|
||||
await tap(tester, "Rendering");
|
||||
await tap(tester, "Set tone mapping to linear");
|
||||
|
||||
await tap(tester, "Scene");
|
||||
await tap(tester, "Camera");
|
||||
await tap(tester, 'Set to first camera in last added asset');
|
||||
|
||||
await tap(tester, "Move to last added asset");
|
||||
await tap(tester, "Move to 1, 1, -1");
|
||||
|
||||
await tap(tester, 'Toggle viewport size', 1);
|
||||
await tap(tester, 'Toggle viewport size', 1);
|
||||
await tap(tester, 'Toggle viewport size', 1);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user