Skip to content

Commit 50967f0

Browse files
committed
Add scene reload test
1 parent 42f31aa commit 50967f0

File tree

4 files changed

+73
-1
lines changed

4 files changed

+73
-1
lines changed

lib/ui/BUILD.gn

+4
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,10 @@ if (enable_unittests) {
216216
"fixtures/FontManifest.json",
217217
"//flutter/third_party/txt/third_party/fonts/Roboto-Medium.ttf",
218218
]
219+
220+
if (impeller_enable_3d) {
221+
deps += [ "//flutter/impeller/fixtures:scene_fixtures" ]
222+
}
219223
}
220224

221225
executable("ui_benchmarks") {

testing/dart/observatory/BUILD.gn

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Use of this source code is governed by a BSD-style license that can be
33
# found in the LICENSE file.
44

5+
import("//flutter/impeller/tools/impeller.gni")
56
import("//flutter/testing/dart/compile_test.gni")
67

78
tests = [
@@ -11,6 +12,10 @@ tests = [
1112
"vmservice_methods_test.dart",
1213
]
1314

15+
if (impeller_enable_3d) {
16+
tests += [ "scene_reload_test.dart" ]
17+
}
18+
1419
foreach(test, tests) {
1520
compile_flutter_dart_test("compile_$test") {
1621
dart_file = test

testing/dart/observatory/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ Tests in this folder need to be run with the observatory enabled, e.g. to make
22
VM service method calls.
33

44
The `run_tests.py` script disables the observatory for other tests in the
5-
parent directory.
5+
parent directory.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'dart:developer' as developer;
6+
import 'dart:typed_data';
7+
import 'dart:ui';
8+
9+
import 'package:litetest/litetest.dart';
10+
import 'package:vm_service/vm_service.dart' as vms;
11+
import 'package:vm_service/vm_service_io.dart';
12+
13+
void main() {
14+
test('ipscenes can be re-initialized', () async {
15+
vms.VmService? vmService;
16+
SceneShader? shader;
17+
try {
18+
final Float64List transform = Float64List(16);
19+
transform[0] = 1.0; // Scale X
20+
transform[5] = 1.0; // Scale Y
21+
transform[10] = 1.0; // Scale Z
22+
transform[12] = 2.0; // Translation X
23+
transform[13] = 6.0; // Translation Y
24+
transform[14] = 6.0; // Translation Z
25+
transform[15] = 1.0;
26+
final SceneNode sceneNode = await SceneNode.fromAsset(
27+
'flutter_logo.glb.ipscene',
28+
)..setTransform(transform);
29+
shader = sceneNode.sceneShader();
30+
_use(shader);
31+
32+
final developer.ServiceProtocolInfo info = await developer.Service.getInfo();
33+
34+
if (info.serverUri == null) {
35+
fail('This test must not be run with --disable-observatory.');
36+
}
37+
38+
vmService = await vmServiceConnectUri(
39+
'ws://localhost:${info.serverUri!.port}${info.serverUri!.path}ws',
40+
);
41+
final vms.VM vm = await vmService.getVM();
42+
43+
expect(vm.isolates!.isNotEmpty, true);
44+
for (final vms.IsolateRef isolateRef in vm.isolates!) {
45+
final vms.Response response = await vmService.callServiceExtension(
46+
'ext.ui.window.reinitializeScene',
47+
isolateId: isolateRef.id,
48+
args: <String, Object>{
49+
'assetKey': 'flutter_logo.glb.ipscene',
50+
},
51+
);
52+
expect(response.type == 'Success', true);
53+
}
54+
} finally {
55+
await vmService?.dispose();
56+
shader?.dispose();
57+
}
58+
});
59+
}
60+
61+
void _use(Shader shader) {
62+
63+
}

0 commit comments

Comments
 (0)