From f0c1d2a224d8369364a731f390ef75180b56ea20 Mon Sep 17 00:00:00 2001 From: rdlabo Date: Mon, 16 Nov 2026 18:31:06 +0900 Subject: [PATCH] refactor: simplify capture docs and test guardrails --- .../engine/NativeUIEngineTest.kt | 29 ++-- .../engine/NativeUIProjectionContactTest.kt | 8 +- docs/README.md | 2 +- docs/advanced/native-handoff.md | 17 +- docs/advanced/preinteraction-capture.md | 160 ++++++++++++------ docs/configuration/README.md | 2 +- docs/configuration/capture.md | 40 ++--- docs/maintenance.md | 18 +- docs/reference/platforms.md | 21 ++- .../CapturePlannerTests.swift | 66 -------- .../SnapshotEventInterceptionTests.swift | 69 ++++++++ .../native-ui-covered-snapshot.spec.ts | 158 +++++------------ tests/native/bridge.spec.ts | 46 +++++ tests/projection/web.spec.ts | 64 ++++--- 14 files changed, 369 insertions(+), 331 deletions(-) create mode 100644 ios/Tests/WebViewNativeUIEngineTests/SnapshotEventInterceptionTests.swift create mode 100644 tests/native/bridge.spec.ts diff --git a/android/src/androidTest/java/io/github/webview_native_ui/engine/NativeUIEngineTest.kt b/android/src/androidTest/java/io/github/webview_native_ui/engine/NativeUIEngineTest.kt index a0bf23b..44636de 100644 --- a/android/src/androidTest/java/io/github/webview_native_ui/engine/NativeUIEngineTest.kt +++ b/android/src/androidTest/java/io/github/webview_native_ui/engine/NativeUIEngineTest.kt @@ -1989,24 +1989,17 @@ class NativeUIEngineTest { val cssWidth = js("innerWidth").toFloat() main { assertEquals(View.VISIBLE, native.visibility) - if (mode == NativeUIProjection.CaptureMode.COMPOSITED) - assertEquals( - (20 + iteration * 20) * activity.web.width / cssWidth, - native.translationY, - 0.05f, - ) // CSS layout quantization stays below 0.05 physical px. - else { - val location = IntArray(2) - val origin = IntArray(2) - native.getLocationInWindow(location) - activity.web.getLocationInWindow(origin) - assertEquals( - (120 + iteration * 20 + (if (authoritativePlacement) 20 else 0)) * - activity.web.width / cssWidth, - (location[1] - origin[1]).toFloat(), - 1f, - ) - } + val location = IntArray(2) + val origin = IntArray(2) + native.getLocationInWindow(location) + activity.web.getLocationInWindow(origin) + assertEquals( + "Restored view must match the DOM host within one physical pixel", + (120 + iteration * 20 + (if (authoritativePlacement) 20 else 0)) * + activity.web.width / cssWidth, + (location[1] - origin[1]).toFloat(), + 1f, + ) } } if (auditReuse) { diff --git a/android/src/androidTest/java/io/github/webview_native_ui/engine/NativeUIProjectionContactTest.kt b/android/src/androidTest/java/io/github/webview_native_ui/engine/NativeUIProjectionContactTest.kt index 56c53f3..f35f82d 100644 --- a/android/src/androidTest/java/io/github/webview_native_ui/engine/NativeUIProjectionContactTest.kt +++ b/android/src/androidTest/java/io/github/webview_native_ui/engine/NativeUIProjectionContactTest.kt @@ -67,7 +67,6 @@ class NativeUIProjectionContactTest { js( """ JSON.stringify({events:nativeEvents.filter(e=>!e.capturePolicy).slice(-25), - transactions:nativeRequests.filter(e=>!['change','track'].includes(e.request.action)).slice(-30).map(e=>({...e,reply:nativeReplies.find(r=>r.key===e.key)})), virtualChanges,attributes:[...document.querySelector('#slot').attributes].map(a=>[a.name,a.value]), images:[...document.querySelectorAll('#slot img')].map(i=>({src:i.src,complete:i.complete,width:i.naturalWidth,opacity:getComputedStyle(i).opacity,display:getComputedStyle(i).display}))}) """ @@ -195,14 +194,11 @@ class NativeUIProjectionContactTest { """