add integration tests and update README
This commit is contained in:
3
example/integration_test/goldens/ios/0_fresh.png
Normal file
3
example/integration_test/goldens/ios/0_fresh.png
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:556955b3ea80e461ab1d19de856276b286e964ea6ffbf5b4f788b03b4d1f1d41
|
||||
size 258315
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:7eaf3e2e5faab0fff2947e6747f44a29a27441fed30dfa5af586f5d18e4c313f
|
||||
size 1876179
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:1abf2fbc19655ce0d99f15a5659268a16c1ef6d2cf2554e07b70fc06505c22e1
|
||||
size 1867991
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:91f82e50232a672de1604da9555c4a62996c577a9ec9d7a037dfcc989b27a2c2
|
||||
size 1743987
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:3c4408b417f5e6fd119c0d7edc6cfd66d44fb1d6d1f03943b7485ab131d3fcbb
|
||||
size 2283182
|
||||
3
example/integration_test/goldens/ios/14_movecamerato.png
Normal file
3
example/integration_test/goldens/ios/14_movecamerato.png
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:4347cade24c7c55b0ca449b3a346fa4bae0fc8c43ca0018d622b8393ad4d7f5c
|
||||
size 1957365
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:eb73e1d9d7c5dfa5cef180d1f1d930da417f9b164e237399c8a7394dd60415e8
|
||||
size 1892497
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:4f7d232df983168399a0aae4b5424d6493ce460794101015f05c07a929268698
|
||||
size 310421
|
||||
3
example/integration_test/goldens/ios/2_loadskybox.png
Normal file
3
example/integration_test/goldens/ios/2_loadskybox.png
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:891223fabbace04e3394dd15852180e443460111cf96a92b7f3a45d5600318cf
|
||||
size 306407
|
||||
3
example/integration_test/goldens/ios/3_loadIBL.png
Normal file
3
example/integration_test/goldens/ios/3_loadIBL.png
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:df8157a13a07023837f36645a517a77e837fa5983ddd3a92b883cf96b8098f65
|
||||
size 304380
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:4e85d3916e42afe77a9854c3297d5d85ce1fa8f973883f5d48bf5efd99bf60e9
|
||||
size 309699
|
||||
3
example/integration_test/goldens/ios/5_loadshapesGLB.png
Normal file
3
example/integration_test/goldens/ios/5_loadshapesGLB.png
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:ad4b4bd59ff6ffa870d3fffb0f9151ccc51392906a6fbdc8832e31b4965c64d6
|
||||
size 300230
|
||||
3
example/integration_test/goldens/ios/6_zoomin.png
Normal file
3
example/integration_test/goldens/ios/6_zoomin.png
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:a297bad3e356e06fb68c53b8718a72924dfd88ca2c5ed1f486fffe5780c77084
|
||||
size 1944342
|
||||
3
example/integration_test/goldens/ios/7_rotate.png
Normal file
3
example/integration_test/goldens/ios/7_rotate.png
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:19bc90955c575a28d9b8e4112c24fe9b65f3ba6df7a3579f036761fe6a54d065
|
||||
size 1937031
|
||||
3
example/integration_test/goldens/ios/8_pan.png
Normal file
3
example/integration_test/goldens/ios/8_pan.png
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:72b73825e31bf5d6ae3c880a17fe578f9351749d68a9b1fc710b838985b833fa
|
||||
size 1938760
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:a3a78e7ec65d33d62105938de4a14f50a91ed4009beed588f17379ad3d7df9b6
|
||||
size 1941399
|
||||
@@ -1,25 +1,152 @@
|
||||
// This is a basic Flutter integration test.
|
||||
//
|
||||
// Since integration tests run in a full Flutter application, they can interact
|
||||
// with the host side of a plugin implementation, unlike Dart unit tests.
|
||||
//
|
||||
// For more information about Flutter integration tests, please see
|
||||
// https://docs.flutter.dev/cookbook/testing/integration/introduction
|
||||
|
||||
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:polyvox_filament/polyvox_filament.dart';
|
||||
import 'package:golden_toolkit/golden_toolkit.dart';
|
||||
import 'package:polyvox_filament/widgets/filament_widget.dart';
|
||||
import '../lib/main.dart' as app;
|
||||
|
||||
void main() {
|
||||
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||
final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized()
|
||||
as IntegrationTestWidgetsFlutterBinding;
|
||||
|
||||
testWidgets('getPlatformVersion test', (WidgetTester tester) async {
|
||||
final PolyvoxFilament plugin = PolyvoxFilament();
|
||||
final String? version = await plugin.getPlatformVersion();
|
||||
// The version string depends on the host platform running the test, so
|
||||
// just assert that some non-empty string is returned.
|
||||
expect(version?.isNotEmpty, true);
|
||||
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, Device device, String label,
|
||||
[int seconds = 0]) async {
|
||||
for (int i = 0; i < seconds; i++) {
|
||||
await Future.delayed(Duration(seconds: 1));
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
await Future.delayed(Duration(milliseconds: 100));
|
||||
await tester.pumpAndSettle();
|
||||
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++;
|
||||
}
|
||||
|
||||
late Device device;
|
||||
|
||||
Future tap(WidgetTester tester, String label, [int seconds = 0]) async {
|
||||
var target = find.text(label).first;
|
||||
await tester.dragUntilVisible(
|
||||
target,
|
||||
find.byType(SingleChildScrollView),
|
||||
// widget you want to scroll
|
||||
const Offset(0, 500), // delta to move
|
||||
duration: Duration(milliseconds: 10));
|
||||
await tester.tap(target);
|
||||
await _snapshot(
|
||||
tester, device, 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();
|
||||
}
|
||||
|
||||
testGoldens('test', (WidgetTester tester) async {
|
||||
app.main();
|
||||
await pumpUntilFound(tester, find.byType(app.ExampleWidget));
|
||||
device = Device(size: Size(800, 600), name: "desktop");
|
||||
await _snapshot(tester, device, "fresh");
|
||||
await tap(tester, "create viewer (default ubershader)", 4);
|
||||
|
||||
await tap(tester, "load skybox");
|
||||
await tap(tester, "load IBL");
|
||||
await tap(tester, "Rendering: false");
|
||||
await tap(tester, "load shapes GLB");
|
||||
|
||||
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, device, "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, device, "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, device, "pan");
|
||||
|
||||
await tap(tester, "transform to unit cube");
|
||||
await tap(tester, "set shapes position to 1, 1, -1");
|
||||
await tap(tester, "Disable frustum culling");
|
||||
await tap(tester, "Set tone mapping to linear");
|
||||
await tap(tester, "Move camera to asset");
|
||||
await tap(tester, "move camera to 1, 1, -1");
|
||||
await tap(tester, 'set camera to first camera in shapes GLB');
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user