From 4912aa1ab09b0db46cf7a65de344f1af24d58dc5 Mon Sep 17 00:00:00 2001 From: lingjhf Date: Sat, 10 Oct 2026 22:43:28 +0800 Subject: [PATCH] test: align property fixtures with scrollable inspector layout Host PictureProperties in the same scrolling layout used by the inspector, scope scrub labels and transform field assertions to the controls under test, and compare resolved temporary paths in tool tests on macOS. Validation: full application analysis, 1261 Flutter tests passed (9 skipped), generated-code verification, and 171 tool tests. --- test/timeline_session_test.dart | 97 +++++++++++++++----------- tool/tests/common_tools_test.py | 2 +- tool/tests/local_flutter_test.py | 9 +-- tool/windows/test_native_cache_unit.py | 2 +- 4 files changed, 63 insertions(+), 47 deletions(-) diff --git a/test/timeline_session_test.dart b/test/timeline_session_test.dart index c911a29..4612329 100644 --- a/test/timeline_session_test.dart +++ b/test/timeline_session_test.dart @@ -1186,13 +1186,15 @@ void main() { home: Scaffold( body: SizedBox( width: 225, - child: PictureProperties( - projectId: projectId, - timelineId: 'project', - session: session, - sequence: id, - clip: base.query().element( - base.query().elementById(ElementId('clip'))!, + child: SingleChildScrollView( + child: PictureProperties( + projectId: projectId, + timelineId: 'project', + session: session, + sequence: id, + clip: base.query().element( + base.query().elementById(ElementId('clip'))!, + ), ), ), ), @@ -1205,7 +1207,10 @@ void main() { await tester.tap(find.byKey(const Key('picture-lock'))); await tester.pumpAndSettle(); } - final label = find.text(labelText); + final label = find.descendant( + of: find.byKey(ValueKey(fieldKey)), + matching: find.text(labelText), + ); final gesture = await tester.startGesture( tester.getCenter(label), kind: PointerDeviceKind.mouse, @@ -1364,12 +1369,16 @@ void main() { home: Scaffold( body: SizedBox( width: 225, - child: PictureProperties( - projectId: projectId, - timelineId: 'project', - session: session, - sequence: id, - clip: base.query().element(base.query().elementById(clipId)!), + child: SingleChildScrollView( + child: PictureProperties( + projectId: projectId, + timelineId: 'project', + session: session, + sequence: id, + clip: base.query().element( + base.query().elementById(clipId)!, + ), + ), ), ), ), @@ -1377,15 +1386,23 @@ void main() { ), ); await tester.pumpAndSettle(); - String text(String key) => tester - .widget( - find.descendant( - of: find.byKey(ValueKey(key)), - matching: find.byType(TextField), - ), - ) - .controller! - .text; + TextField field(String key) => tester.widget( + find.descendant( + of: find.byKey(ValueKey(key)), + matching: find.byType(TextField), + ), + ); + String text(String key) => field(key).controller!.text; + Iterable transformFields() => [ + for (final key in [ + 'picture-x', + 'picture-y', + 'picture-scale-x', + 'picture-scale-y', + 'picture-rotation', + ]) + field(key), + ]; PreviewVisual visual(ClipTransform value) => PreviewVisual( layerId: 'video', elementId: clipId, @@ -1499,9 +1516,7 @@ void main() { ), ); await tester.pump(); - for (final field in tester.widgetList( - find.byType(TextField), - )) { + for (final field in transformFields()) { expect(field.enabled, isTrue); expect(field.readOnly, isTrue); expect(field.canRequestFocus, isFalse); @@ -1523,9 +1538,7 @@ void main() { } await edit.end(); await tester.pump(); - for (final field in tester.widgetList( - find.byType(TextField), - )) { + for (final field in transformFields()) { expect(field.enabled, isTrue); expect(field.readOnly, isFalse); expect(field.canRequestFocus, isTrue); @@ -1790,18 +1803,20 @@ void main() { home: Scaffold( body: SizedBox( width: 225, - child: ListenableBuilder( - listenable: view, - builder: (_, _) { - final query = view.version.kernelVersion.query(); - return PictureProperties( - projectId: projectId, - timelineId: 'project', - session: session, - sequence: id, - clip: query.element(query.elementById(clipId)!), - ); - }, + child: SingleChildScrollView( + child: ListenableBuilder( + listenable: view, + builder: (_, _) { + final query = view.version.kernelVersion.query(); + return PictureProperties( + projectId: projectId, + timelineId: 'project', + session: session, + sequence: id, + clip: query.element(query.elementById(clipId)!), + ); + }, + ), ), ), ), diff --git a/tool/tests/common_tools_test.py b/tool/tests/common_tools_test.py index f8a742c..bc0d16e 100644 --- a/tool/tests/common_tools_test.py +++ b/tool/tests/common_tools_test.py @@ -21,7 +21,7 @@ class CommonToolsTests(unittest.TestCase): result = run([sys.executable, '-c', code, *arguments], cwd=directory, env={'CUTDEX_TEST': 'child'}, capture_output=True, text=True) lines = result.stdout.splitlines() - self.assertEqual(Path(lines[0]), Path(directory)) + self.assertEqual(Path(lines[0]).resolve(), Path(directory).resolve()) self.assertEqual(lines[1], 'child') self.assertEqual(lines[2], repr(arguments)) diff --git a/tool/tests/local_flutter_test.py b/tool/tests/local_flutter_test.py index bdb11a3..7edf0cc 100644 --- a/tool/tests/local_flutter_test.py +++ b/tool/tests/local_flutter_test.py @@ -86,7 +86,7 @@ sys.exit(7 if 'fail' in sys.argv else 0) self.assertEqual(data['parent'], 'parent') self.assertEqual(data['android'], 'C:/My SDK/cutdex_android') self.assertEqual(data['input'], 'daemon-request') - self.assertEqual(Path(data['cwd']), self.root) + self.assertEqual(Path(data['cwd']).resolve(), self.root.resolve()) self.assertEqual(result.stderr.strip(), 'flutter-diagnostic') def test_ide_shim_uses_the_same_loader_and_preserves_arguments(self): @@ -168,7 +168,7 @@ sys.exit(7 if 'fail' in sys.argv else 0) text=True, encoding='utf-8', timeout=40) self.assertEqual(result.returncode, 0, result.stderr) data = json.loads(result.stdout) - self.assertEqual(Path(data['cwd']), source) + self.assertEqual(Path(data['cwd']).resolve(), source.resolve()) self.assertEqual(data['file'], 'main-project') self.assertEqual(data['args'], ['build', 'windows']) @@ -228,7 +228,8 @@ sys.exit(7 if 'fail' in sys.argv else 0) capture_output=True, text=True, encoding='utf-8', timeout=40) self.assertEqual(result.returncode, 0, result.stderr) data = json.loads(result.stdout) - self.assertEqual(Path(data['cwd']), self.root if cwd is None else cwd) + expected_cwd = self.root if cwd is None else cwd + self.assertEqual(Path(data['cwd']).resolve(), expected_cwd.resolve()) self.assertEqual(data['file'], 'selected-project') self.assertEqual(data['input'], 'request') self.assertEqual(data['args'], ['build', 'macos', '--release', '--flavor', 'production', @@ -262,7 +263,7 @@ sys.exit(7 if 'fail' in sys.argv else 0) result = subprocess.run([sys.executable, str(self.root / 'tool/project_tools.py'), 'dart', str(probe)], cwd=package, env=self.environment, capture_output=True, text=True, timeout=40) self.assertEqual(result.returncode, 0, result.stderr) - self.assertEqual(Path(result.stdout.strip()), package) + self.assertEqual(Path(result.stdout.strip()).resolve(), package.resolve()) if __name__ == '__main__': diff --git a/tool/windows/test_native_cache_unit.py b/tool/windows/test_native_cache_unit.py index 523f669..3005981 100644 --- a/tool/windows/test_native_cache_unit.py +++ b/tool/windows/test_native_cache_unit.py @@ -198,7 +198,7 @@ class NativeCacheTests(unittest.TestCase): with patch.object(cache, 'download_archive', side_effect=self.download): archive = cache.prepare(environment=environment) self.assertEqual(output.read_text(), f'EXISTING=value\nDESKUP_VELOPACK_ARCHIVE={archive.as_posix()}\n') - self.assertEqual(archive.parent, self.root / 'Cutdex/ci-tools/native') + self.assertEqual(archive.parent.resolve(), (self.root / 'Cutdex/ci-tools/native').resolve()) def test_failed_verification_cannot_export_an_archive(self): output = self.root / 'github-env'