From b8562dfdd932788b04effd7a781ad99642f6e7b6 Mon Sep 17 00:00:00 2001 From: kdletters Date: Sat, 20 Jun 2026 04:17:17 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E9=BD=90=E7=A7=BB=E5=8A=A8=E5=A3=B3?= =?UTF-8?q?=E5=89=AA=E8=B4=B4=E6=9D=BFUnicode=E6=88=AA=E6=96=AD=E8=A6=86?= =?UTF-8?q?=E7=9B=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移动壳剪贴板测试覆盖多字节文本按共享上限截断 移动壳配置检查反查剪贴板 Unicode 截断用例 --- apps/mobile-shell/scripts/check-config.mjs | 3 +++ apps/mobile-shell/src/host-bridge/bridge.test.ts | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/apps/mobile-shell/scripts/check-config.mjs b/apps/mobile-shell/scripts/check-config.mjs index 77ee460cd..56faf7445 100644 --- a/apps/mobile-shell/scripts/check-config.mjs +++ b/apps/mobile-shell/scripts/check-config.mjs @@ -1797,6 +1797,9 @@ for (const snippet of [ throw new Error(`mobile shell clipboard module is missing ${snippet}`); } } +if (!bridgeTestSource.includes("'猫'.repeat(100000)")) { + throw new Error('mobile shell clipboard tests must cover Unicode truncation'); +} if ( !hapticsSource.includes('normalizeHostBridgeHapticsImpactStyle(rawStyle)') || diff --git a/apps/mobile-shell/src/host-bridge/bridge.test.ts b/apps/mobile-shell/src/host-bridge/bridge.test.ts index 7b64f608b..e16da2256 100644 --- a/apps/mobile-shell/src/host-bridge/bridge.test.ts +++ b/apps/mobile-shell/src/host-bridge/bridge.test.ts @@ -709,6 +709,17 @@ describe('handleMobileHostBridgeMessage', () => { expect(expectOk(response).result).toBe(true); expect(Clipboard.setStringAsync).toHaveBeenCalledWith('a'.repeat(100000)); + + vi.mocked(Clipboard.setStringAsync).mockClear(); + + const unicodeResponse = await send( + request('clipboard.writeText', { + text: '猫'.repeat(100010), + }), + ); + + expect(expectOk(unicodeResponse).result).toBe(true); + expect(Clipboard.setStringAsync).toHaveBeenCalledWith('猫'.repeat(100000)); }); test('clipboard.readText 读取失败时返回 host_error', async () => {