diff --git a/client/electron/test/fixtures/aa-dump-l-single-theirs.txt b/client/electron/test/fixtures/aa-dump-l-single-theirs.txt new file mode 100644 index 0000000..3b150f4 --- /dev/null +++ b/client/electron/test/fixtures/aa-dump-l-single-theirs.txt @@ -0,0 +1,14 @@ +User ID #100 + current mission lists:{ + Mission ID #31 mission name #[#com.example.homeagent:entry:EntryAbility] lockedState #0 mission affinity #[] + AbilityRecord ID #31 + app name [com.example.homeagent] + main name [EntryAbility] + bundle name [com.example.homeagent] + ability type [PAGE] + state #FOREGROUND start time [82256] + app state #FOREGROUND + ready #1 window attached #0 launcher #0 + callee connections: + isKeepAlive: false + } diff --git a/client/electron/test/harmony-deviceprobe.test.mjs b/client/electron/test/harmony-deviceprobe.test.mjs index 3c2fac7..dbc9841 100644 --- a/client/electron/test/harmony-deviceprobe.test.mjs +++ b/client/electron/test/harmony-deviceprobe.test.mjs @@ -44,9 +44,9 @@ test('★ 同一份样本把状态对调 ⇒ 前台变成我们(判据只认 .map((l) => l.includes('#BACKGROUND') && l.trim().startsWith('state') && l.includes('start time [84231]') ? l.replace('#BACKGROUND', '#FOREGROUND') : l) .join('\n'); // 上面那步只保证"没有 FOREGROUND 了"或"换了另一个" —— 无论哪种,闸都必须给出**可判**的结论而不是假绿 - const v = C.foregroundVerdict(oursFront, OURS); - assert.ok(v === C.VERDICT_OURS || v === C.VERDICT_UNVERIFIED, - `状态被我改过之后,闸只能说 ours 或 unverified,绝不许在含糊时说 other/ours 之外的侥幸话(实际 ${v})`); + assert.equal(C.foregroundVerdict(oursFront, OURS), C.VERDICT_OURS, + '★ 正例必须严格成立:状态对调后前台是我们 ⇒ 必须是 ours。否则这道闸的失效方式是"永远说未验"(更安静的失效)'); + assert.equal(C.mayAssertOn(oursFront, OURS), true, 'ours ⇒ 允许断言(可用窗口不会也被判未验)'); }); test('★ 空 dump / 截断 / 格式变了 ⇒ unverified(缺证据 ≠ 没有那个现象)', () => { @@ -66,3 +66,17 @@ test('★ 闸只按 bundle 判:文案/控件名/标题撞车都不影响', () const tricky = real + '\n component: MailList\n windowTitle: 邮件\n'; assert.equal(C.foregroundVerdict(tricky, OURS), C.VERDICT_OTHER, '加上与我们要判控件同名同文案的东西,也不许变成 ours'); }); + +test('★ 第二份真样本:单 mission(**我们根本不在列表里**)⇒ other,不是 unverified', () => { + // 由第一份真样本删掉我们那块得到;形状与 pi 12:03 那份活 dump 一致(他信里也是单 mission) + const single = prose(join(HERE, 'fixtures', 'aa-dump-l-single-theirs.txt')); + assert.equal(C.parseMissions(single).length, 1); + assert.equal(C.foregroundVerdict(single, OURS), C.VERDICT_OTHER, + '有 FOREGROUND 且不是我们 ⇒ other。若这里报 unverified,就把"别人占着"和"没读到"混成一种了'); + assert.equal(C.mayAssertOn(single, OURS), false); +}); + +test('★ 把 state #FOREGROUND 全部删掉 ⇒ unverified(缺证据,不猜)', () => { + const noFg = real.split('\n').filter((l) => !l.includes('#FOREGROUND')).join('\n'); + assert.equal(C.foregroundVerdict(noFg, OURS), C.VERDICT_UNVERIFIED); +}); diff --git a/client/electron/test/run-all.mjs b/client/electron/test/run-all.mjs index 9916d36..904b2db 100644 --- a/client/electron/test/run-all.mjs +++ b/client/electron/test/run-all.mjs @@ -79,7 +79,7 @@ const SUITE = [ ['test/build-stamp.test.mjs', [], 7], ['test/packaging.test.mjs', [], 5], ['test/align-refs.test.mjs', [], 3], - ['test/harmony-deviceprobe.test.mjs', ['--experimental-strip-types', '--no-warnings'], 5], + ['test/harmony-deviceprobe.test.mjs', ['--experimental-strip-types', '--no-warnings'], 7], ['test/harmony-push.test.mjs', ['--experimental-strip-types', '--no-warnings'], 13], ['test/harmony-calendar.test.mjs', ['--experimental-strip-types', '--no-warnings'], 10], ['test/debt-visibility.test.mjs', [], 1],