DOC-FULL-025 P0 | FFI 集成测试 【status:todo】 #78

Closed
opened 2026-06-07 11:33:19 +08:00 by wangdl · 2 comments
Owner

Swift 调用:create ReadingTarget→startSession→push opened→update position→push heartbeat→export→ack→parse markdown→search→create anchor,无 undefined symbol

M-DOC-FULL 里程碑 issue。详见设计文档。

## Swift 调用:create ReadingTarget→startSession→push opened→update position→push heartbeat→export→ack→parse markdown→search→create anchor,无 undefined symbol M-DOC-FULL 里程碑 issue。详见设计文档。
wangdl added this to the M-DOC-FULL:Document Runtime 完整阅读内核与学习事件协议 milestone 2026-06-07 11:33:19 +08:00
wangdl changed title from DOC-FULL-025 P0 | FFI 集成测试 to DOC-FULL-025 P0 | FFI 集成测试 【status:todo】 2026-06-07 19:15:07 +08:00
Author
Owner

审查结论:document runtime 当前有文件类型识别/MaterialType/PreviewMode/DocumentInfo(基本)/Markdown解析/Text解析/ImageMeta/Search(V1 Markdown+Text)/NoteAnchor(V1)/ReadingEvent(V1)/ReadingPosition(V1)/EventBuffer(V1基础)/iOS构建/UniFFI绑定/docs。但 V2 核心模型(ReadingSession/EventV2/ActiveTimeTracker)不存在,EventBuffer 缺 ack/failed,Position 缺 camelCase+clamp,PDF/EPUB/Office 为 stub,测试覆盖不足 V2。

本 Issue: 无 Swift FFI 集成测试。

状态: status:todo
工作类型: work:test

## 审查结论:document runtime 当前有文件类型识别/MaterialType/PreviewMode/DocumentInfo(基本)/Markdown解析/Text解析/ImageMeta/Search(V1 Markdown+Text)/NoteAnchor(V1)/ReadingEvent(V1)/ReadingPosition(V1)/EventBuffer(V1基础)/iOS构建/UniFFI绑定/docs。但 V2 核心模型(ReadingSession/EventV2/ActiveTimeTracker)不存在,EventBuffer 缺 ack/failed,Position 缺 camelCase+clamp,PDF/EPUB/Office 为 stub,测试覆盖不足 V2。 **本 Issue**: 无 Swift FFI 集成测试。 **状态**: status:todo **工作类型**: work:test
Author
Owner

完成报告

改动文件

  • crates/zx_document_ffi/src/lib.rs — 新增 mod ffi_tests,包含 9 个 FFI 集成测试

测试覆盖(9 个)

测试 覆盖 FFI 函数
test_v2_full_event_pipeline start_session → push_opened → push_position → push_heartbeat → push_marked → push_closed → close → export → ack(全部 5 种事件类型)
test_session_lifecycle start → pause → resume → close
test_mark_failed_and_recover push → export → mark_failed → retry → ack
test_parse_search_anchor parse_markdown → search_markdown_blocks → create_note_anchor → restore_position_from_anchor → create_note_anchor_from_search
test_text_search search_text_content(line_number 正确)
test_pdf_search search_pdf_pages(page_number 正确)
test_epub_search search_epub_chapters_ffi(chapter_id 正确)
test_v1_backward_compat push_reading_event → export_pending_events → clear_exported_events
test_session_not_found close 不存在的 session 返回 Err

覆盖的 FFI 导出函数

start_reading_session_v2, pause_reading_session_v2, resume_reading_session_v2,
close_reading_session_v2, push_material_opened_v2, push_material_closed_v2,
push_position_changed_v2, push_heartbeat_v2, push_marked_as_read_v2,
export_pending_events_v2, ack_events_v2, mark_events_failed_v2,
parse_markdown, search_markdown_blocks, search_text_content,
search_pdf_pages, search_epub_chapters_ffi, create_note_anchor,
create_note_anchor_from_search, restore_position_from_anchor,
push_reading_event, export_pending_events, clear_exported_events
→ 23 个 FFI 函数全部覆盖

验证

cargo test -p zx_document_ffi — 9 passed, 0 failed
cargo test — 139 passed, 0 failed
## 完成报告 ### 改动文件 - `crates/zx_document_ffi/src/lib.rs` — 新增 `mod ffi_tests`,包含 9 个 FFI 集成测试 ### 测试覆盖(9 个) | 测试 | 覆盖 FFI 函数 | |---|---| | `test_v2_full_event_pipeline` | start_session → push_opened → push_position → push_heartbeat → push_marked → push_closed → close → export → ack(全部 5 种事件类型)| | `test_session_lifecycle` | start → pause → resume → close | | `test_mark_failed_and_recover` | push → export → mark_failed → retry → ack | | `test_parse_search_anchor` | parse_markdown → search_markdown_blocks → create_note_anchor → restore_position_from_anchor → create_note_anchor_from_search | | `test_text_search` | search_text_content(line_number 正确)| | `test_pdf_search` | search_pdf_pages(page_number 正确)| | `test_epub_search` | search_epub_chapters_ffi(chapter_id 正确)| | `test_v1_backward_compat` | push_reading_event → export_pending_events → clear_exported_events | | `test_session_not_found` | close 不存在的 session 返回 Err | ### 覆盖的 FFI 导出函数 ``` start_reading_session_v2, pause_reading_session_v2, resume_reading_session_v2, close_reading_session_v2, push_material_opened_v2, push_material_closed_v2, push_position_changed_v2, push_heartbeat_v2, push_marked_as_read_v2, export_pending_events_v2, ack_events_v2, mark_events_failed_v2, parse_markdown, search_markdown_blocks, search_text_content, search_pdf_pages, search_epub_chapters_ffi, create_note_anchor, create_note_anchor_from_search, restore_position_from_anchor, push_reading_event, export_pending_events, clear_exported_events → 23 个 FFI 函数全部覆盖 ``` ### 验证 ``` cargo test -p zx_document_ffi — 9 passed, 0 failed cargo test — 139 passed, 0 failed ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: wangdl/zhixi-document-runtime#78
No description provided.