@buaa_smat/hometrans 26.0.0 → 26.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/README.md +7 -1
  2. package/package.json +11 -82
  3. package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/ets/pages/Index.ets +2 -2
  4. package/skills/a2h-arch-generate/scripts/module_create/har/src/main/ets/components/MainPage.ets +2 -2
  5. package/skills/a2h-arch-generate/scripts/module_create/hsp/src/main/ets/pages/Index.ets +2 -2
  6. package/skills/a2h-batch-ui-align/references/conversion-procedure.md +1 -1
  7. package/skills/a2h-batch-ui-align/references/state-mgmt/_/350/214/203/345/274/217/351/200/211/346/213/251/350/257/264/346/230/216.md +1 -1
  8. package/skills/a2h-batch-ui-align/references/step3-capture.md +3 -3
  9. package/skills/a2h-batch-ui-align/references/step4-prepare.md +1 -1
  10. package/skills/a2h-batch-ui-align/scripts/detect_paradigm.mjs +11 -6
  11. package/skills/a2h-batch-ui-align/scripts/export_ui_info.mjs +59 -21
  12. package/skills/a2h-batch-ui-align/scripts/group_pack.mjs +3 -3
  13. package/skills/a2h-batch-ui-align/scripts/group_queue.mjs +1 -1
  14. package/skills/a2h-batch-ui-align/scripts/static_check/core/scan.ts +1 -1
  15. package/skills/a2h-utg-explorer/SKILL.md +1 -1
  16. package/skills/a2h-utg-explorer/references/architecture.md +2 -2
  17. package/skills/a2h-utg-explorer/scripts/compile_tasks.mjs +36 -11
  18. package/skills/a2h-utg-explorer/scripts/device_health.mjs +91 -6
  19. package/skills/a2h-utg-explorer/scripts/final_utg.mjs +20 -2
  20. package/skills/a2h-utg-explorer/scripts/hint_check.mjs +64 -8
  21. package/skills/a2h-utg-explorer/scripts/hint_source.mjs +119 -0
  22. package/skills/a2h-utg-explorer/scripts/recover.mjs +7 -1
  23. package/skills/a2h-utg-explorer/scripts/recover_b.mjs +8 -1
  24. package/skills/a2h-utg-explorer/scripts/utg_explorer/adapters.mjs +89 -7
  25. package/skills/a2h-utg-explorer/scripts/utg_explorer/semantics.mjs +173 -4
  26. package/skills/a2h-utg-explorer/scripts/utg_explorer/task_runner.mjs +82 -14
  27. package/skills/a2h-utg-static/SKILL.md +1 -1
  28. package/skills/a2h-utg-static/references/view-interactions.md +1 -1
  29. package/skills/a2h-utg-static/scripts/assemble.mjs +6 -3
  30. package/skills/a2h-utg-static/scripts/compose_body_text.mjs +23 -5
  31. package/skills/a2h-utg-static/scripts/compose_overlay.mjs +29 -3
  32. package/skills/a2h-utg-static/scripts/compose_titles.mjs +10 -1
  33. package/skills/a2h-utg-static/scripts/label_resolve.mjs +51 -2
  34. package/skills/a2h-utg-static/scripts/static_prior.mjs +2 -1
  35. package/skills/a2h-utg-static/scripts/tests/_zipw.mjs +28 -0
  36. package/skills/a2h-utg-static/scripts/tests/probe_autoload.mjs +108 -0
  37. package/skills/a2h-utg-static/scripts/tests/probe_layout_fragments.mjs +90 -0
  38. package/skills/a2h-utg-static/scripts/tests/probe_unknown_scope.mjs +61 -0
  39. package/skills/a2h-utg-static/scripts/tests/regression_matrix.mjs +1261 -0
  40. package/skills/a2h-utg-static/scripts/tests/test_activity_alias_launcher.mjs +135 -0
  41. package/skills/a2h-utg-static/scripts/tests/test_activity_supertype_chain.mjs +106 -0
  42. package/skills/a2h-utg-static/scripts/tests/test_bottom_sheet_container.mjs +58 -0
  43. package/skills/a2h-utg-static/scripts/tests/test_branch_guard.mjs +19 -0
  44. package/skills/a2h-utg-static/scripts/tests/test_callee_string_default.mjs +30 -0
  45. package/skills/a2h-utg-static/scripts/tests/test_carry_answers.mjs +103 -0
  46. package/skills/a2h-utg-static/scripts/tests/test_chrome_tokens.mjs +60 -0
  47. package/skills/a2h-utg-static/scripts/tests/test_commented_out_trigger.mjs +111 -0
  48. package/skills/a2h-utg-static/scripts/tests/test_commit_scope.mjs +113 -0
  49. package/skills/a2h-utg-static/scripts/tests/test_compose_file_private_route.mjs +117 -0
  50. package/skills/a2h-utg-static/scripts/tests/test_compose_nested_graph.mjs +166 -0
  51. package/skills/a2h-utg-static/scripts/tests/test_compose_res_text.mjs +108 -0
  52. package/skills/a2h-utg-static/scripts/tests/test_compose_route_holder_collision.mjs +112 -0
  53. package/skills/a2h-utg-static/scripts/tests/test_compose_vm_nav.mjs +289 -0
  54. package/skills/a2h-utg-static/scripts/tests/test_custom_source_root.mjs +71 -0
  55. package/skills/a2h-utg-static/scripts/tests/test_defensive_null_guard.mjs +77 -0
  56. package/skills/a2h-utg-static/scripts/tests/test_dialog_orphan_entries.mjs +99 -0
  57. package/skills/a2h-utg-static/scripts/tests/test_dialog_page_owner.mjs +69 -0
  58. package/skills/a2h-utg-static/scripts/tests/test_dialogshow_builder_forms.mjs +96 -0
  59. package/skills/a2h-utg-static/scripts/tests/test_dialogshow_java_factory.mjs +37 -0
  60. package/skills/a2h-utg-static/scripts/tests/test_disabled_guard.mjs +42 -0
  61. package/skills/a2h-utg-static/scripts/tests/test_drawer_panel_gesture.mjs +140 -0
  62. package/skills/a2h-utg-static/scripts/tests/test_edge_dedupe_by_gesture.mjs +111 -0
  63. package/skills/a2h-utg-static/scripts/tests/test_edge_provenance_lint.mjs +70 -0
  64. package/skills/a2h-utg-static/scripts/tests/test_enclosing_gesture.mjs +69 -0
  65. package/skills/a2h-utg-static/scripts/tests/test_external_surface_roots.mjs +43 -0
  66. package/skills/a2h-utg-static/scripts/tests/test_find_package_indirect.mjs +67 -0
  67. package/skills/a2h-utg-static/scripts/tests/test_forwarding_wrapper.mjs +38 -0
  68. package/skills/a2h-utg-static/scripts/tests/test_fragment_containment.mjs +85 -0
  69. package/skills/a2h-utg-static/scripts/tests/test_fragment_helper_trigger.mjs +92 -0
  70. package/skills/a2h-utg-static/scripts/tests/test_fresh_branch_guard.mjs +49 -0
  71. package/skills/a2h-utg-static/scripts/tests/test_graph.mjs +55 -0
  72. package/skills/a2h-utg-static/scripts/tests/test_guard_clause.mjs +86 -0
  73. package/skills/a2h-utg-static/scripts/tests/test_hint_language.mjs +136 -0
  74. package/skills/a2h-utg-static/scripts/tests/test_host_kind_by_chain.mjs +68 -0
  75. package/skills/a2h-utg-static/scripts/tests/test_hybrid_bundle_attribution.mjs +74 -0
  76. package/skills/a2h-utg-static/scripts/tests/test_hybrid_bundled_pages.mjs +181 -0
  77. package/skills/a2h-utg-static/scripts/tests/test_hybrid_scope.mjs +293 -0
  78. package/skills/a2h-utg-static/scripts/tests/test_hybrid_title_renders.mjs +118 -0
  79. package/skills/a2h-utg-static/scripts/tests/test_i18n_term.mjs +155 -0
  80. package/skills/a2h-utg-static/scripts/tests/test_interaction_sites.mjs +272 -0
  81. package/skills/a2h-utg-static/scripts/tests/test_item_data_instance.mjs +51 -0
  82. package/skills/a2h-utg-static/scripts/tests/test_kotlin_fn_spans.mjs +69 -0
  83. package/skills/a2h-utg-static/scripts/tests/test_label_accessor_forms.mjs +187 -0
  84. package/skills/a2h-utg-static/scripts/tests/test_label_source.mjs +70 -0
  85. package/skills/a2h-utg-static/scripts/tests/test_launch_intent_guard.mjs +67 -0
  86. package/skills/a2h-utg-static/scripts/tests/test_layout_declared_fragment.mjs +103 -0
  87. package/skills/a2h-utg-static/scripts/tests/test_listener_call_forms.mjs +79 -0
  88. package/skills/a2h-utg-static/scripts/tests/test_listener_receiver_binding.mjs +47 -0
  89. package/skills/a2h-utg-static/scripts/tests/test_login_interceptor.mjs +328 -0
  90. package/skills/a2h-utg-static/scripts/tests/test_manifest_exported_default.mjs +40 -0
  91. package/skills/a2h-utg-static/scripts/tests/test_manifest_filters_modules.mjs +84 -0
  92. package/skills/a2h-utg-static/scripts/tests/test_manifest_srcfile.mjs +68 -0
  93. package/skills/a2h-utg-static/scripts/tests/test_mode_and_cb_param.mjs +172 -0
  94. package/skills/a2h-utg-static/scripts/tests/test_module_namespace.mjs +83 -0
  95. package/skills/a2h-utg-static/scripts/tests/test_module_strings.mjs +44 -0
  96. package/skills/a2h-utg-static/scripts/tests/test_multiple_entry_contracts.mjs +80 -0
  97. package/skills/a2h-utg-static/scripts/tests/test_nav_graph_xml.mjs +35 -0
  98. package/skills/a2h-utg-static/scripts/tests/test_nl_hint_grammar.mjs +42 -0
  99. package/skills/a2h-utg-static/scripts/tests/test_nl_hints_gate.mjs +85 -0
  100. package/skills/a2h-utg-static/scripts/tests/test_nl_hints_off_path.mjs +67 -0
  101. package/skills/a2h-utg-static/scripts/tests/test_node_id_collision.mjs +57 -0
  102. package/skills/a2h-utg-static/scripts/tests/test_non_gesture_step_flag.mjs +62 -0
  103. package/skills/a2h-utg-static/scripts/tests/test_out_of_scope_and_settings.mjs +72 -0
  104. package/skills/a2h-utg-static/scripts/tests/test_overload_and_climb.mjs +86 -0
  105. package/skills/a2h-utg-static/scripts/tests/test_pager_page_source.mjs +78 -0
  106. package/skills/a2h-utg-static/scripts/tests/test_pager_position_zero.mjs +65 -0
  107. package/skills/a2h-utg-static/scripts/tests/test_pager_variant_guard.mjs +172 -0
  108. package/skills/a2h-utg-static/scripts/tests/test_pipeline_llm_phases.mjs +107 -0
  109. package/skills/a2h-utg-static/scripts/tests/test_plain_dialog_nodes.mjs +167 -0
  110. package/skills/a2h-utg-static/scripts/tests/test_plaindialog_shared_anchor.mjs +117 -0
  111. package/skills/a2h-utg-static/scripts/tests/test_preference_click_nav.mjs +98 -0
  112. package/skills/a2h-utg-static/scripts/tests/test_preference_host_binding.mjs +87 -0
  113. package/skills/a2h-utg-static/scripts/tests/test_preference_nesting.mjs +183 -0
  114. package/skills/a2h-utg-static/scripts/tests/test_preference_widgets.mjs +48 -0
  115. package/skills/a2h-utg-static/scripts/tests/test_read_text_crlf.mjs +41 -0
  116. package/skills/a2h-utg-static/scripts/tests/test_resolver_tier_parity.mjs +126 -0
  117. package/skills/a2h-utg-static/scripts/tests/test_result_launcher.mjs +142 -0
  118. package/skills/a2h-utg-static/scripts/tests/test_review_fixes.mjs +135 -0
  119. package/skills/a2h-utg-static/scripts/tests/test_route_token_words.mjs +66 -0
  120. package/skills/a2h-utg-static/scripts/tests/test_same_name_decl_scope.mjs +236 -0
  121. package/skills/a2h-utg-static/scripts/tests/test_scope_utils.mjs +85 -0
  122. package/skills/a2h-utg-static/scripts/tests/test_sealed_dialog_state.mjs +148 -0
  123. package/skills/a2h-utg-static/scripts/tests/test_shared_overlay_split.mjs +63 -0
  124. package/skills/a2h-utg-static/scripts/tests/test_slug_parity.mjs +58 -0
  125. package/skills/a2h-utg-static/scripts/tests/test_starter_node_id.mjs +41 -0
  126. package/skills/a2h-utg-static/scripts/tests/test_state_guard_arity.mjs +109 -0
  127. package/skills/a2h-utg-static/scripts/tests/test_state_guard_commented_candidates.mjs +68 -0
  128. package/skills/a2h-utg-static/scripts/tests/test_state_guard_model_gates.mjs +127 -0
  129. package/skills/a2h-utg-static/scripts/tests/test_state_specific_hop.mjs +130 -0
  130. package/skills/a2h-utg-static/scripts/tests/test_synthetic_label_identity.mjs +51 -0
  131. package/skills/a2h-utg-static/scripts/tests/test_template_method_layout.mjs +81 -0
  132. package/skills/a2h-utg-static/scripts/tests/test_template_title.mjs +61 -0
  133. package/skills/a2h-utg-static/scripts/tests/test_trigger_id_spelling.mjs +68 -0
  134. package/skills/a2h-utg-static/scripts/tests/test_ui_elements_action_override.mjs +91 -0
  135. package/skills/a2h-utg-static/scripts/tests/test_ui_elements_flow_filter.mjs +110 -0
  136. package/skills/a2h-utg-static/scripts/tests/test_ui_elements_nl_hint_key.mjs +89 -0
  137. package/skills/a2h-utg-static/scripts/tests/test_uiless_host_fold.mjs +98 -0
  138. package/skills/a2h-utg-static/scripts/tests/test_uniapp_data_table.mjs +340 -0
  139. package/skills/a2h-utg-static/scripts/tests/test_uniapp_relative_url.mjs +125 -0
  140. package/skills/a2h-utg-static/scripts/tests/test_uniapp_source.mjs +231 -0
  141. package/skills/a2h-utg-static/scripts/tests/test_view_click_refs.mjs +104 -0
  142. package/skills/a2h-utg-static/scripts/tests/test_view_id_label.mjs +69 -0
  143. package/skills/a2h-utg-static/scripts/tests/test_view_interactions.mjs +346 -0
  144. package/skills/a2h-utg-static/scripts/tests/test_viewpage_nav.mjs +340 -0
  145. package/skills/a2h-utg-static/scripts/tests/test_vm_nav_helper_navigate.mjs +98 -0
  146. package/skills/a2h-utg-static/scripts/tests/test_widget_class_scope.mjs +92 -0
  147. package/skills/a2h-utg-static/scripts/tests/test_window_nav_kotlin.mjs +158 -0
  148. package/skills/a2h-utg-static/scripts/tests/test_worklist_parts.mjs +65 -0
@@ -0,0 +1,96 @@
1
+ // dialogshow_nav / fragfactory_nav: preference-dialog bases, nested supertypes, builder-built
2
+ // dialogs, and the base-typed contract of the fragment-factory SANITY line.
3
+ import { test } from 'node:test';
4
+ import assert from 'node:assert/strict';
5
+ import { _CLASS_DECL_RE, buildFragmentSet } from '../fragment_nav.mjs';
6
+ import * as ds from '../dialogshow_nav.mjs';
7
+ import * as ff from '../fragfactory_nav.mjs';
8
+
9
+ const P = '/proj';
10
+ const f = (rel, text) => [`${P}/${rel}`, text];
11
+
12
+ const SOURCES = [
13
+ f('app/src/main/java/a/AlertDialogFragment.java', `package a;
14
+ public class AlertDialogFragment extends DialogFragment {
15
+ public static class Builder { public AlertDialogFragment create() { return new AlertDialogFragment(); } }
16
+ }`),
17
+ f('app/src/main/java/a/EditTextDialog.java', `package a;
18
+ public class EditTextDialog extends AlertDialogFragment {
19
+ public static abstract class Callback { }
20
+ public static class Builder { public Builder setTitle(int t) { return this; } public EditTextDialog create() { return null; } }
21
+ }`),
22
+ f('app/src/main/java/a/StorageDialog.kt', `package a
23
+ class StorageDialog : PreferenceDialogFragmentCompat(), TextWatcher {
24
+ companion object { fun newInstance(key: String): StorageDialog { return StorageDialog() } }
25
+ }`),
26
+ f('app/src/main/java/a/HostActivity.java', `package a;
27
+ public class HostActivity extends AppCompatActivity {
28
+ private EditTextDialog addDialog;
29
+ void open() {
30
+ addDialog = new EditTextDialog.Builder()
31
+ .setTitle(R.string.t)
32
+ .create();
33
+ addDialog.show(getSupportFragmentManager(), "tag");
34
+ }
35
+ void prefs() {
36
+ StorageDialog fragment = StorageDialog.newInstance("k");
37
+ fragment.show(getSupportFragmentManager(), "pref");
38
+ }
39
+ private class AddCallback extends EditTextDialog.Callback { }
40
+ }`),
41
+ f('app/src/main/java/a/HostFragment.kt', `package a
42
+ class HostFragment : Fragment() {
43
+ fun ask() {
44
+ EditTextDialog.Builder()
45
+ .setTitle(R.string.t)
46
+ .create().show(childFragmentManager, null)
47
+ }
48
+ }`),
49
+ ];
50
+
51
+ test('fragment set: preference-dialog base is a dialog; a nested supertype is not truncated', () => {
52
+ const [frags] = buildFragmentSet(SOURCES, P);
53
+ assert.equal(frags.get('StorageDialog')?.kind, 'dialog', 'PreferenceDialogFragmentCompat subclass is a dialog');
54
+ assert.ok(!frags.has('AddCallback'), '`extends EditTextDialog.Callback` must not read as `extends EditTextDialog`');
55
+ assert.equal(frags.get('EditTextDialog')?.kind, 'dialog');
56
+ });
57
+
58
+ test('a nested Builder supertype names its OUTER type (`extends AlertDialog.Builder` builds an AlertDialog)', () => {
59
+ const pick = (s) => new RegExp(_CLASS_DECL_RE.source, _CLASS_DECL_RE.flags.replace('d', '')).exec(s)?.[2];
60
+ assert.equal(pick('public class M3Builder extends AlertDialog.Builder {'), 'AlertDialog');
61
+ assert.equal(pick('class M3Builder extends android.app.AlertDialog.Builder {'), 'AlertDialog');
62
+ assert.equal(pick('class Cb extends EditTextDialog.Callback {'), 'Callback', 'other nested types keep the last segment');
63
+ assert.equal(pick('class D : androidx.fragment.app.DialogFragment() {'), 'DialogFragment');
64
+ });
65
+
66
+ test('dialogshow: builder-built and typed-local receivers resolve', () => {
67
+ const [frags] = buildFragmentSet(SOURCES, P);
68
+ const fragNames = new Set(frags.keys());
69
+ const dialogNames = new Set([...frags].filter(([, i]) => i.kind === 'dialog').map(([n]) => n));
70
+ const [factories, ambiguous] = ds.buildFactoryIndex(SOURCES, dialogNames, P);
71
+ const [edges, unresolved] = ds.detectEdges(SOURCES, P, fragNames, dialogNames, factories, new Map(), ambiguous);
72
+ const pairs = new Set(edges.map((e) => `${e.source}->${e.target}`));
73
+ assert.ok(pairs.has('activity:HostActivity->fragment:EditTextDialog'), 'field assigned from `new X.Builder()...create()`');
74
+ assert.ok(pairs.has('activity:HostActivity->fragment:StorageDialog'), 'Java typed local from a factory');
75
+ assert.ok(pairs.has('fragment:HostFragment->fragment:EditTextDialog'), '`X.Builder()...create().show(` chain');
76
+ assert.deepEqual(unresolved, []);
77
+ });
78
+
79
+ test('fragfactory: only base-typed factories count toward the SANITY floor', () => {
80
+ const src = [
81
+ f('app/src/main/java/b/DetailFragment.kt', `package b
82
+ class DetailFragment : Fragment() {
83
+ companion object { fun getInstance(id: Long): DetailFragment { return DetailFragment() } }
84
+ }`),
85
+ f('app/src/main/java/b/Pages.kt', `package b
86
+ fun newDetail(id: Long): Fragment = DetailFragment()
87
+ fun newOther(): Fragment { return DetailFragment() }
88
+ `),
89
+ ];
90
+ const [frags] = buildFragmentSet(src, P);
91
+ const pages = new Set([...frags].filter(([, i]) => i.kind !== 'dialog').map(([n]) => n));
92
+ const [index, , , baseTyped] = ff.buildFactoryIndex(src, pages, P, new Set());
93
+ assert.ok(index.has('getInstance'), 'concrete-typed factory is still indexed (no edge loss)');
94
+ assert.ok(!baseTyped.has('getInstance'), 'a factory declared to return its concrete page is not base-typed');
95
+ assert.ok(baseTyped.has('newDetail') && baseTyped.has('newOther'), 'factories typed as a base fragment are');
96
+ });
@@ -0,0 +1,37 @@
1
+ // Port of test_dialogshow_java_factory.py: Java DialogFragment factories produce open-overlay edges.
2
+ import { test } from 'node:test';
3
+ import assert from 'node:assert/strict';
4
+ import * as dsn from '../dialogshow_nav.mjs';
5
+
6
+ test('java dialog factory', () => {
7
+ const project = '/project';
8
+ const factory = ['/project/src/main/java/example/ConfirmDialog.java', `
9
+ package example;
10
+ public class ConfirmDialog extends DialogFragment {
11
+ public static ConfirmDialog newInstance(String value) {
12
+ return new ConfirmDialog();
13
+ }
14
+ }
15
+ `];
16
+ const page = ['/project/src/main/java/example/DetailFragment.java', `
17
+ package example;
18
+ public class DetailFragment extends Fragment {
19
+ void bind() {
20
+ row.setOnClickListener(v -> ConfirmDialog.newInstance("x")
21
+ .show(getParentFragmentManager(), "confirm"));
22
+ }
23
+ }
24
+ `];
25
+ const sources = [factory, page];
26
+ const [factories, ambiguous] = dsn.buildFactoryIndex(sources, new Set(['ConfirmDialog']), project);
27
+ assert.equal(factories.get('newInstance'), 'ConfirmDialog');
28
+ assert.equal(ambiguous.size, 0);
29
+ const [edges, unresolved, refused] = dsn.detectEdges(sources, project,
30
+ new Set(['ConfirmDialog', 'DetailFragment']), new Set(['ConfirmDialog']), factories, new Map(), ambiguous);
31
+ assert.equal(unresolved.length, 0);
32
+ assert.equal(refused.length, 0);
33
+ assert.equal(edges.length, 1);
34
+ assert.equal(edges[0].source, 'fragment:DetailFragment');
35
+ assert.equal(edges[0].target, 'fragment:ConfirmDialog');
36
+ assert.equal(edges[0].mechanism, 'open-overlay');
37
+ });
@@ -0,0 +1,42 @@
1
+ // Port of test_disabled_guard.py — the crawler-side checks only: build-flavor maps to env:build
2
+ // and env:build lands in a BYPASS phase (static_prior.mjs / phase_planner.mjs), plus the
3
+ // end-to-end consequence that a build-flavor-guarded node is planned as BYPASS_env.
4
+ // The _disabled_expr / _BUILD_CALL_RE / _CONTENT_TEST_RE / _branch_guard checks exercise
5
+ // assemble.py; they belong to the batch that ports assemble.py.
6
+ import { test } from 'node:test';
7
+ import assert from 'node:assert/strict';
8
+ import { _GUARD_AXIS, StaticPrior } from '../static_prior.mjs';
9
+ import { PHASES, LEVEL_BYPASS, classify, plan } from '../phase_planner.mjs';
10
+ import { nodeLinkGraph } from '../_graph.mjs';
11
+
12
+ test('build-flavor maps to the env:build axis', () => {
13
+ assert.equal(_GUARD_AXIS['build-flavor'], 'env:build');
14
+ });
15
+
16
+ test('env:build lands in a BYPASS phase (not attempted on this build)', () => {
17
+ const axis = _GUARD_AXIS['build-flavor'];
18
+ assert.ok(PHASES.some((p) => p.level === LEVEL_BYPASS && p.axes.has(axis)));
19
+ });
20
+
21
+ test('a node reachable only through a build-flavor guard is planned BYPASS_env', () => {
22
+ const g = nodeLinkGraph({
23
+ directed: true, multigraph: true,
24
+ nodes: [
25
+ { id: 'activity:MainActivity', kind: 'activity', launch_hint: { is_launcher: true } },
26
+ { id: 'compose-route:LANGUAGE_SETTINGS', kind: 'compose-route' },
27
+ { id: 'compose-route:CHANGE_LANGUAGE', kind: 'compose-route' },
28
+ ],
29
+ links: [
30
+ { source: 'activity:MainActivity', target: 'compose-route:LANGUAGE_SETTINGS', args: { label: '语言' } },
31
+ { source: 'compose-route:LANGUAGE_SETTINGS', target: 'compose-route:CHANGE_LANGUAGE',
32
+ guard: { kind: 'build-flavor', text: 'enabled = !notSupportUserDefinedLanguage' },
33
+ args: { label: '改变语言' } },
34
+ ],
35
+ }, { edges: 'links' });
36
+ const prior = new StaticPrior(g);
37
+ assert.deepEqual([...prior.requiredState('compose-route:CHANGE_LANGUAGE')], ['env:build']);
38
+ assert.equal(classify(prior.requiredState('compose-route:CHANGE_LANGUAGE')), 'BYPASS_env');
39
+ assert.equal(classify(prior.requiredState('compose-route:LANGUAGE_SETTINGS')), 'P0_fresh');
40
+ const names = plan(prior.targetsShallowFirst()).map((p) => p.name);
41
+ assert.deepEqual(names, ['P0_fresh', 'BYPASS_env']);
42
+ });
@@ -0,0 +1,140 @@
1
+ // Port of test_drawer_panel_gesture.py: a fragment committed into a DrawerLayout panel needs a SWIPE,
2
+ // inherits the host's lock condition, and view_widgets.nodeLayoutNames is class-scoped.
3
+ import { test } from 'node:test';
4
+ import assert from 'node:assert/strict';
5
+ import * as fs from 'node:fs';
6
+ import * as os from 'node:os';
7
+ import * as path from 'node:path';
8
+ import * as fn from '../fragment_nav.mjs';
9
+ import * as vw from '../view_widgets.mjs';
10
+ import * as cp from '../click_paths.mjs';
11
+
12
+ const MAIN_XML = `<?xml version="1.0" encoding="utf-8"?>
13
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android">
14
+ <androidx.drawerlayout.widget.DrawerLayout android:id="@+id/drawer_layout">
15
+ <androidx.coordinatorlayout.widget.CoordinatorLayout
16
+ android:id="@+id/content_coordinator">
17
+ <FrameLayout android:id="@+id/main_content_view"/>
18
+ <Button android:id="@+id/deep_button" android:layout_gravity="start"/>
19
+ </androidx.coordinatorlayout.widget.CoordinatorLayout>
20
+ <androidx.fragment.app.FragmentContainerView
21
+ android:id="@+id/navDrawerFragment"
22
+ android:layout_gravity="start"/>
23
+ </androidx.drawerlayout.widget.DrawerLayout>
24
+ </LinearLayout>
25
+ `;
26
+ const NAV_LIST_XML = `<?xml version="1.0" encoding="utf-8"?>
27
+ <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android">
28
+ <LinearLayout android:id="@+id/nav_settings" android:contentDescription="Settings"/>
29
+ <androidx.recyclerview.widget.RecyclerView android:id="@+id/nav_list"/>
30
+ </RelativeLayout>
31
+ `;
32
+ const MAIN_JAVA = `package com.x;
33
+ public class MainActivity extends AppCompatActivity {
34
+ private DrawerLayout drawerLayout;
35
+ protected void onCreate(Bundle b) {
36
+ drawerLayout = findViewById(R.id.drawer_layout);
37
+ if (UserPreferences.isBottomNavigationEnabled()) {
38
+ drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
39
+ drawerLayout = null;
40
+ }
41
+ NavDrawerFragment navDrawerFragment = new NavDrawerFragment();
42
+ transaction.replace(R.id.navDrawerFragment, navDrawerFragment,
43
+ NavDrawerFragment.TAG);
44
+ transaction.replace(R.id.main_content_view, new HomeFragment());
45
+ }
46
+ }
47
+ `;
48
+ const NAV_JAVA = `package com.x;
49
+ public class NavDrawerFragment extends Fragment {
50
+ public View onCreateView(LayoutInflater inflater, ViewGroup c, Bundle s) {
51
+ View root = inflater.inflate(R.layout.nav_list, c, false);
52
+ return root;
53
+ }
54
+ public static class RemoveFeedDialogClose extends RemoveFeedDialog {
55
+ void go() { }
56
+ }
57
+ }
58
+ `;
59
+ const HOME_JAVA = `package com.x;
60
+ public class HomeFragment extends Fragment {
61
+ public View onCreateView(LayoutInflater i, ViewGroup c, Bundle s) {
62
+ return i.inflate(R.layout.nav_list, c, false);
63
+ }
64
+ }
65
+ `;
66
+
67
+ function build(root) {
68
+ for (const [rel, body] of [['app/src/main/res/layout/main.xml', MAIN_XML],
69
+ ['app/src/main/res/layout/nav_list.xml', NAV_LIST_XML],
70
+ ['app/src/main/java/com/x/MainActivity.java', MAIN_JAVA],
71
+ ['app/src/main/java/com/x/NavDrawerFragment.java', NAV_JAVA],
72
+ ['app/src/main/java/com/x/HomeFragment.java', HOME_JAVA]]) {
73
+ const p = path.join(root, ...rel.split('/'));
74
+ fs.mkdirSync(path.dirname(p), { recursive: true });
75
+ fs.writeFileSync(p, body, 'utf8');
76
+ }
77
+ }
78
+
79
+ test('drawer panel gesture and widget scoping', () => {
80
+ const root = fs.mkdtempSync(path.join(os.tmpdir(), 'drw_'));
81
+ try {
82
+ build(root);
83
+ // drawer container detection
84
+ const ids = fn._drawerContainerIds(root);
85
+ assert.equal(ids.get('navDrawerFragment'), 'start', "the DrawerLayout's gravity-bearing child is a drawer container");
86
+ assert.ok(!ids.has('content_coordinator'), 'the main-content sibling (no gravity) is not a drawer');
87
+ assert.ok(!ids.has('deep_button'), 'a layout_gravity three levels down is not a drawer container');
88
+ assert.ok(!ids.has('drawer_layout'), 'the DrawerLayout itself is not one of its own drawers');
89
+
90
+ // host condition
91
+ const cond = fn._drawerDisabledCondition(MAIN_JAVA);
92
+ assert.equal(cond, 'UserPreferences.isBottomNavigationEnabled()', 'the lock is attributed to its enclosing if');
93
+ assert.equal(fn._drawerDisabledCondition('void f() { drawerLayout.setDrawerLockMode(X); }'), null,
94
+ 'an unconditional lock yields no guard (nothing to satisfy)');
95
+ assert.equal(fn._resolveLocalType(MAIN_JAVA, 'navDrawerFragment'), 'NavDrawerFragment',
96
+ 'a variable receiver resolves back to its declared type');
97
+
98
+ // edges
99
+ const sources = [...fn.walkSources(root)];
100
+ const frag = new Set(['NavDrawerFragment', 'HomeFragment']);
101
+ const edges = fn.detectEdges(sources, root, frag, { widget_labels: new Map(), dialog_names: new Set(), drawer_ids: ids });
102
+ const drawer = edges.filter((e) => e.target === 'fragment:NavDrawerFragment');
103
+ const home = edges.filter((e) => e.target === 'fragment:HomeFragment');
104
+ assert.ok(drawer.length > 0, 'the drawer panel is reached at all');
105
+ assert.ok(drawer.every((e) => e.args.action === 'swipe'), 'every drawer sighting is a swipe, not an already-visible default');
106
+ assert.ok(drawer.every((e) => e.args.gesture === 'open-drawer'), 'the gesture is named on each');
107
+ assert.ok(drawer.every((e) => e.args.drawer_gravity === 'start'), 'its edge is recorded on each');
108
+ const guards = drawer.map((e) => e.guard || {});
109
+ assert.ok(guards.every((g) => g.kind === 'device-env'), `the host's lock condition became a guard (${JSON.stringify(guards[0])})`);
110
+ assert.ok(guards.every((g) => (g.text || '').includes('isBottomNavigationEnabled')), 'and the raw condition is kept as evidence');
111
+ assert.ok(home.length > 0 && home.every((e) => e.args.action === 'default'),
112
+ 'a fragment in the MAIN container is still a lifecycle auto-load');
113
+ assert.ok(home.every((e) => e.guard === null || e.guard === undefined), 'and carries no drawer guard');
114
+ assert.ok(!home.some((e) => e.args.gesture), 'and no swipe is invented for it');
115
+
116
+ // prose
117
+ const steps = [{ action: 'launch', target_id: 'activity:MainActivity', target_kind: 'activity' },
118
+ { action: 'swipe', label: '抽屉菜单', gesture: 'open-drawer', drawer_gravity: 'start',
119
+ target_id: 'fragment:NavDrawerFragment', target_kind: 'fragment',
120
+ guard: { text: '需要 X 为 false', kind: 'device-env' } }];
121
+ const nodes = new Map([['activity:MainActivity', { kind: 'activity', label: 'Main' }],
122
+ ['fragment:NavDrawerFragment', { kind: 'fragment', label: 'NavDrawer' }]]);
123
+ const txt = cp._renderPathText(steps, nodes);
124
+ assert.ok(txt.includes('左侧边缘'), `the swipe names the edge it starts from (${txt})`);
125
+ assert.ok(!txt.includes('切换到'), 'and is not narrated as a pager tab change');
126
+ assert.ok(txt.includes('前置条件'), 'the guard reaches the prose');
127
+
128
+ // widget scoping
129
+ const host = { id: 'fragment:NavDrawerFragment', label: 'NavDrawerFragment',
130
+ declared_at: 'app/src/main/java/com/x/NavDrawerFragment.java:2' };
131
+ const nested = { id: 'fragment:RemoveFeedDialogClose', label: 'RemoveFeedDialogClose',
132
+ declared_at: 'app/src/main/java/com/x/NavDrawerFragment.java:7' };
133
+ const cache = new Map();
134
+ assert.deepEqual(vw.nodeLayoutNames(host, root, cache), ['nav_list'], 'the host still resolves its own layout');
135
+ assert.deepEqual(vw.nodeLayoutNames(nested, root, cache), [], 'a class declared beside it inherits nothing from the file');
136
+ const menu = { id: 'menu:nav_feed_context@NavDrawerFragment', label: 'nav_feed_context (overflow)',
137
+ declared_at: 'app/src/main/java/com/x/NavDrawerFragment.java:7' };
138
+ assert.deepEqual(vw.nodeLayoutNames(menu, root, cache), [], 'nor does a menu node hosted in that file');
139
+ } finally { fs.rmSync(root, { recursive: true, force: true }); }
140
+ });
@@ -0,0 +1,111 @@
1
+ // Port of test_edge_dedupe_by_gesture.py — assemble's dedupe keyed on the trigger STRING,
2
+ // so several distinct controls reaching one target through a shared helper were folded
3
+ // into one edge on the way into utg.json.
4
+ //
5
+ // Every View extractor that resolves the listener -> private helper hop (`plaindialog_nav`,
6
+ // `activity_nav`, `hybrid_scope`) writes the navigation's own `file:line` as the trigger,
7
+ // because that IS where the navigation is written. Two tiles that both call
8
+ // `startOpenUnimp(...)` therefore produce two edges with two different `trigger_id`s and
9
+ // ONE identical trigger string:
10
+ //
11
+ // src=HomeFragment dst=hybrid:UniMP trigger=showUniMP@Home.java:779 tid=cl_wechat_virtual
12
+ // src=HomeFragment dst=hybrid:UniMP trigger=showUniMP@Home.java:779 tid=cl_alipay_virtual
13
+ //
14
+ // `key = (source, target, mechanism, trigger)` makes those duplicates and keeps one. The
15
+ // loss is invisible in every counter: `edges.jsonl` has both, the extractor's own summary
16
+ // line counts both, and only `utg.json` (the artifact click_paths, the HTML export and the
17
+ // crawler all actually read) has one. Measured on one app: six distinct gestures dropped
18
+ // between the two files, across three extractors, including a home screen's two
19
+ // mini-program tiles that had just been fixed to be distinguishable.
20
+ //
21
+ // `args.trigger_id` names the control that fires the edge. Two different controls are two
22
+ // different edges. Pinned below:
23
+ // 1. two records differing only in `trigger_id` both survive into utg.json;
24
+ // 2. a true duplicate (same trigger_id) is still collapsed;
25
+ // 3. an ANONYMOUS record is folded away when a named sibling exists, otherwise it would
26
+ // survive beside the named ones as a phantom extra door (the "keep the richest
27
+ // duplicate" rule fragment_nav already applies inside its own dedupe);
28
+ // 4. an anonymous record with no named sibling is kept: an edge nobody could name is
29
+ // still an edge.
30
+ //
31
+ // Runs the real stage as a child process (`node assemble.mjs <ws>`), as the Python test ran
32
+ // `python assemble.py <ws>`.
33
+ import { test } from 'node:test';
34
+ import assert from 'node:assert/strict';
35
+ import * as fs from 'node:fs';
36
+ import * as os from 'node:os';
37
+ import * as path from 'node:path';
38
+ import { spawnSync } from 'node:child_process';
39
+ import { fileURLToPath } from 'node:url';
40
+
41
+ const HERE = path.dirname(fileURLToPath(import.meta.url));
42
+ const ASSEMBLE = path.join(HERE, '..', 'assemble.mjs');
43
+
44
+ const NODES = [
45
+ { id: 'fragment:HomeFragment', kind: 'fragment', label: 'HomeFragment' },
46
+ { id: 'hybrid:UniMP', kind: 'hybrid', label: 'UniMP', denominator: false },
47
+ { id: 'dialog:CommonSimpleDialog', kind: 'dialog', label: 'CommonSimpleDialog' },
48
+ ];
49
+
50
+ const TRIG = 'showUniMP@app/src/main/java/Home.java:779';
51
+
52
+ function edge(target, tid, trigger = TRIG, mech = 'open-overlay') {
53
+ const args = { action: 'tap', via: 'hybrid-runtime' };
54
+ if (tid) args.trigger_id = tid;
55
+ return {
56
+ source: 'fragment:HomeFragment', target, mechanism: mech, trigger, guard: null,
57
+ args, provenance: 'static:homegraph', status: 'static-only', confidence: 0.8,
58
+ };
59
+ }
60
+
61
+ function run(edges) {
62
+ const ws = fs.mkdtempSync(path.join(os.tmpdir(), 'edge_dedupe_'));
63
+ try {
64
+ fs.writeFileSync(path.join(ws, 'nodes.jsonl'), NODES.map((n) => JSON.stringify(n) + '\n').join(''), 'utf8');
65
+ fs.writeFileSync(path.join(ws, 'edges.jsonl'), edges.map((e) => JSON.stringify(e) + '\n').join(''), 'utf8');
66
+ const r = spawnSync(process.execPath, [ASSEMBLE, ws], { encoding: 'utf8' });
67
+ assert.equal(r.status, 0, r.stderr);
68
+ return JSON.parse(fs.readFileSync(path.join(ws, 'utg.json'), 'utf8')).links;
69
+ } finally {
70
+ fs.rmSync(ws, { recursive: true, force: true });
71
+ }
72
+ }
73
+
74
+ const tids = (links, target) =>
75
+ links.filter((e) => e.target === target)
76
+ .map((e) => String((e.args || {}).trigger_id ?? 'None'))
77
+ .sort();
78
+
79
+ test('two controls reaching one target through a shared helper stay two edges', () => {
80
+ const links = run([
81
+ edge('hybrid:UniMP', 'cl_wechat_virtual'),
82
+ edge('hybrid:UniMP', 'cl_alipay_virtual'),
83
+ edge('hybrid:UniMP', 'cl_wechat_virtual'), // exact duplicate
84
+ edge('hybrid:UniMP', 'uniMenuAdapter'),
85
+ ]);
86
+ assert.deepEqual(tids(links, 'hybrid:UniMP'), ['cl_alipay_virtual', 'cl_wechat_virtual', 'uniMenuAdapter']);
87
+ });
88
+
89
+ test('an anonymous duplicate does not survive beside named ones', () => {
90
+ const links = run([
91
+ edge('dialog:CommonSimpleDialog', 'tv_phone_bind'),
92
+ edge('dialog:CommonSimpleDialog', 'tv_wechat_bind'),
93
+ edge('dialog:CommonSimpleDialog', null),
94
+ ]);
95
+ assert.deepEqual(tids(links, 'dialog:CommonSimpleDialog'), ['tv_phone_bind', 'tv_wechat_bind']);
96
+ });
97
+
98
+ test('an anonymous edge with no named sibling is kept', () => {
99
+ const links = run([edge('dialog:CommonSimpleDialog', null)]);
100
+ assert.equal(links.filter((e) => e.target === 'dialog:CommonSimpleDialog').length, 1);
101
+ });
102
+
103
+ // The distinction must be the GESTURE, not merely "two records": a different trigger
104
+ // string was always enough, and must stay enough.
105
+ test('two different trigger strings still make two edges', () => {
106
+ const links = run([
107
+ edge('hybrid:UniMP', null, 'openUniMP@app/src/main/java/A.java:10'),
108
+ edge('hybrid:UniMP', null, 'openUniMP@app/src/main/java/A.java:20'),
109
+ ]);
110
+ assert.equal(links.filter((e) => e.target === 'hybrid:UniMP').length, 2);
111
+ });
@@ -0,0 +1,70 @@
1
+ // Port of test_edge_provenance_lint.py — invariant lock for assemble's edge-provenance lint.
2
+ // The corpus-graph invariant scans workspace dirs listed in UTG_WORKSPACES (path-delimited);
3
+ // it skips cleanly when none are given (the Python version reads them from argv).
4
+ import { test } from 'node:test';
5
+ import assert from 'node:assert/strict';
6
+ import * as fs from 'node:fs';
7
+ import * as path from 'node:path';
8
+ import { lintEdgeProvenance, _MENTION_TRIGGER_PREFIXES } from '../assemble.mjs';
9
+
10
+ const edge = (source, target, mechanism, trigger) => ({ source, target, mechanism, trigger });
11
+
12
+ test('mention edges dropped', () => {
13
+ const nodes = { 'activity:Main': { id: 'activity:Main', entry: true }, 'compose-route:A': { id: 'compose-route:A' } };
14
+ const edges = [
15
+ edge('compose-route:A', 'activity:Main', 'startActivity-explicit', 'ref@app/src/main/java/x/SongItem.kt:165'),
16
+ edge('compose-route:A', 'activity:Main', 'startActivity-explicit', 'ref@app/src/main/java/x/Dialog.kt:34'),
17
+ ];
18
+ assert.deepEqual(lintEdgeProvenance(edges, nodes), [], 'both mention-derived (ref@) edges dropped');
19
+ });
20
+
21
+ test('real call-site edges survive', () => {
22
+ const nodes = { a: { id: 'a' }, b: { id: 'b' } };
23
+ const shapes = [
24
+ ['onClick@x/Screen.kt:69', 'compose-navigate'], ['onClick@x/Row.kt:12', 'open-overlay'],
25
+ ['onClick@x/Btn.kt:40', 'startActivity-explicit'], ['onClick@x/List.kt:126', 'enter-mode'],
26
+ ['startDestination@x/Nav.kt:155', 'compose-navigate'], ['render-branch', 'data-variant'],
27
+ ['pager@x/Pager.kt:20', 'pager-swipe'], ['createFragment@x/Adapter.kt:31', 'pager-swipe'],
28
+ ['FxActivity@x/FxActivity.kt:102', 'fragment-transaction'], ['AudioFxV3Fragment@x/F.kt:55', 'fragment-transaction'],
29
+ ['auto-load@x/Host.kt:44', 'fragment-transaction'],
30
+ ];
31
+ const kept = lintEdgeProvenance(shapes.map(([t, m]) => edge('a', 'b', m, t)), nodes);
32
+ assert.equal(kept.length, shapes.length, `all ${shapes.length} call-site/render trigger shapes survive (kept ${kept.length})`);
33
+ });
34
+
35
+ test('missing trigger survives', () => {
36
+ const kept = lintEdgeProvenance([edge('a', 'b', 'open-overlay', null)], { a: { id: 'a' }, b: { id: 'b' } });
37
+ assert.equal(kept.length, 1, 'edge with absent trigger is kept, not dropped');
38
+ });
39
+
40
+ test('launcher fan-in warns, not drops', () => {
41
+ const nodes = { 'activity:Main': { id: 'activity:Main', launch_hint: { is_launcher: true } },
42
+ a: { id: 'a' }, b: { id: 'b' }, c: { id: 'c' } };
43
+ const edges = ['a', 'b', 'c'].map((s) => edge(s, 'activity:Main', 'startActivity-explicit', `onClick@x/${s}.kt:10`));
44
+ assert.equal(lintEdgeProvenance(edges, nodes).length, 3, 'launcher fan-in warns but keeps all 3 edges');
45
+ });
46
+
47
+ test('denylist is narrow', () => {
48
+ assert.deepEqual(_MENTION_TRIGGER_PREFIXES, ['ref@'], "denylist is exactly ('ref@',) — narrow by design");
49
+ });
50
+
51
+ test('corpus graph invariant', (t) => {
52
+ const roots = (process.env.UTG_WORKSPACES || '').split(path.delimiter).filter((r) => r && fs.existsSync(r) && fs.statSync(r).isDirectory());
53
+ if (!roots.length) { t.skip('no workspace dirs passed; graph invariant not checked'); return; }
54
+ let checked = 0;
55
+ const walk = (d) => {
56
+ let ents; try { ents = fs.readdirSync(d, { withFileTypes: true }); } catch { return; }
57
+ if (ents.some((e) => e.isFile() && e.name === 'utg.json')) {
58
+ let g = null;
59
+ try { g = JSON.parse(fs.readFileSync(path.join(d, 'utg.json'), 'utf8')); } catch { g = null; }
60
+ if (g) {
61
+ checked++;
62
+ const bad = (g.links || []).filter((e) => _MENTION_TRIGGER_PREFIXES.some((p) => String(e.trigger || '').startsWith(p)));
63
+ assert.equal(bad.length, 0, `${path.basename(d)}: no ref@ edges survive in utg.json (found ${bad.length})`);
64
+ }
65
+ }
66
+ for (const e of ents) { if (e.isDirectory()) { walk(path.join(d, e.name)); } }
67
+ };
68
+ roots.forEach(walk);
69
+ if (!checked) { t.skip('no utg.json found under the given roots'); }
70
+ });
@@ -0,0 +1,69 @@
1
+ // Port of test_enclosing_gesture.py: which gesture parameter's lambda encloses a trigger.
2
+ import { test } from 'node:test';
3
+ import assert from 'node:assert/strict';
4
+ import { enclosingGesture } from '../label_resolve.mjs';
5
+
6
+ const PLAIN_ONCLICK = `
7
+ Box(
8
+ modifier = Modifier.combinedClickable(
9
+ onClick = {
10
+ navController.navigate(ScreenRoute.PLAIN)
11
+ },
12
+ onLongClick = {}
13
+ )
14
+ ) { Text("Label") }
15
+ `;
16
+ const DOUBLE_CLICK = `
17
+ Box(
18
+ modifier = Modifier.combinedClickable(
19
+ onClick = {},
20
+ onLongClick = {},
21
+ onDoubleClick = {
22
+ navController.navigate(ScreenRoute.HIDDEN_DEV)
23
+ }
24
+ )
25
+ ) { Text("App Title") }
26
+ `;
27
+ const LONG_CLICK = `
28
+ Box(
29
+ modifier = Modifier.combinedClickable(
30
+ onClick = {},
31
+ onLongClick = {
32
+ navController.navigate(ScreenRoute.CONTEXT_MENU)
33
+ }
34
+ )
35
+ ) { Text("Row Item") }
36
+ `;
37
+ const NESTED_INNERMOST = `
38
+ Box(
39
+ modifier = Modifier.combinedClickable(
40
+ onLongClick = {
41
+ showMenu = true
42
+ }
43
+ )
44
+ ) {
45
+ DropdownMenu(expanded = showMenu) {
46
+ DropdownMenuItem(
47
+ onClick = {
48
+ navController.navigate(ScreenRoute.SUBMENU_TARGET)
49
+ }
50
+ )
51
+ }
52
+ }
53
+ `;
54
+ const NO_NAMED_GESTURE = `
55
+ Box(
56
+ modifier = Modifier.clickable {
57
+ navController.navigate(ScreenRoute.PLAIN_CLICKABLE)
58
+ }
59
+ ) { Text("Item") }
60
+ `;
61
+ const at = (t) => t.indexOf('navController.navigate');
62
+
63
+ test("plain onClick resolves to 'tap'", () => assert.equal(enclosingGesture(PLAIN_ONCLICK, at(PLAIN_ONCLICK)), 'tap'));
64
+ test("onDoubleClick resolves to 'double_tap'", () => assert.equal(enclosingGesture(DOUBLE_CLICK, at(DOUBLE_CLICK)), 'double_tap'));
65
+ test("onLongClick resolves to 'long_press'", () => assert.equal(enclosingGesture(LONG_CLICK, at(LONG_CLICK)), 'long_press'));
66
+ test('nested case: innermost onClick wins over outer onLongClick',
67
+ () => assert.equal(enclosingGesture(NESTED_INNERMOST, at(NESTED_INNERMOST)), 'tap'));
68
+ test("no named gesture parameter falls back to 'tap'",
69
+ () => assert.equal(enclosingGesture(NO_NAMED_GESTURE, at(NO_NAMED_GESTURE)), 'tap'));
@@ -0,0 +1,43 @@
1
+ // Regression (mirror of a2h-utg-crawler tests/test_external_surface_roots.py): an
2
+ // `external-surface` entry is not a crawl root, so a page reachable only through a widget is
3
+ // `orphan` rather than P0; shell-launchable secondary entries stay roots. Also: the cached
4
+ // single-source solve returns the same path as dijkstraPath.
5
+ import { test } from 'node:test';
6
+ import assert from 'node:assert/strict';
7
+ import { StaticPrior } from '../static_prior.mjs';
8
+ import { MultiDiGraph, dijkstraPath } from '../_graph.mjs';
9
+
10
+ function prior() {
11
+ const g = new MultiDiGraph();
12
+ g.addNode('activity:Main', { kind: 'activity', is_launcher: true, launch: { type: 'component', component_fqn: 'x.Main' } });
13
+ g.addNode('activity:Widget', { kind: 'activity', entry: true });
14
+ g.addNode('fragment:WidgetOnly', { kind: 'fragment' });
15
+ g.addNode('activity:Share', { kind: 'activity', entry: true, launch: { type: 'intent-action', action: 'android.intent.action.SEND' } });
16
+ g.addNode('fragment:ShareOnly', { kind: 'fragment' });
17
+ g.addNode('fragment:Home', { kind: 'fragment' });
18
+ g.addEdge('activity:Main', 'fragment:Home');
19
+ g.addEdge('activity:Widget', 'fragment:WidgetOnly');
20
+ g.addEdge('activity:Share', 'fragment:ShareOnly');
21
+ return new StaticPrior(g, {
22
+ root: 'activity:Main', entry_roots: ['activity:Widget', 'activity:Share'],
23
+ entries: { 'activity:Main': { type: 'component', component_fqn: 'x.Main' },
24
+ 'activity:Widget': { type: 'external-surface' },
25
+ 'activity:Share': { type: 'intent-action', action: 'android.intent.action.SEND' } },
26
+ });
27
+ }
28
+
29
+ test('external-surface entries are not roots', () => {
30
+ const p = prior();
31
+ assert.deepEqual(p._roots, ['activity:Main', 'activity:Share']);
32
+ assert.deepEqual([...p.requiredState('fragment:Home')], []);
33
+ assert.deepEqual([...p.requiredState('fragment:ShareOnly')], []);
34
+ assert.ok(p.requiredState('fragment:WidgetOnly').has('orphan'));
35
+ });
36
+
37
+ test('cached solve equals dijkstraPath and sees later graph edits', () => {
38
+ const p = prior();
39
+ assert.deepEqual(p._shortestPath('fragment:Home'),
40
+ dijkstraPath(p.g, 'activity:Main', 'fragment:Home', (u, v) => p._edgeCost(u, v)));
41
+ p.g.addEdge('activity:Main', 'fragment:WidgetOnly');
42
+ assert.deepEqual([...p.requiredState('fragment:WidgetOnly')], []);
43
+ });