电池模式下数字选词常上屏与所见不同的候选。链路是:TSF 只等 50ms 回复;Server 在回复前同步写调频,渲染同步 30ms 到点后按未绘制的页面 选词;超时后 TSF 断管重放按键,Server 又调一次频。 - server:选词调频(拼音/五笔/英文)改为 worker 队列任务,在回复之后、 下一键之前执行,不再占用回复时间。 - server:渲染同步改为条件变量,绘制回显即唤醒;上限 30ms 提到 80ms。 - windows:上屏类回复等待 300ms;请求已送达仍超时时视为投递不确定, 只重建前缀并丢弃上屏键,不再无条件重放。 - server:同一选择 3s 内在新连接上再次到达时跳过调频,避免重放重复计数。
24 lines
1.0 KiB
C++
24 lines
1.0 KiB
C++
#include "ipc/selection_replay_guard.h"
|
|
#include "tests/includes/test_framework.h"
|
|
|
|
TEST_CASE(selection_replay_guard_skips_a_replay_on_a_new_connection)
|
|
{
|
|
FanyImeIpc::SelectionRankingReplayGuard guard;
|
|
REQUIRE(guard.should_apply("p|ni|ni|A", 1, 1, 1000));
|
|
// Reconnected and replayed within the window: the pick already counted.
|
|
REQUIRE(!guard.should_apply("p|ni|ni|A", 2, 1, 1300));
|
|
REQUIRE(!guard.should_apply("p|ni|ni|A", 2, 5, 1400));
|
|
}
|
|
|
|
TEST_CASE(selection_replay_guard_counts_real_repeats)
|
|
{
|
|
FanyImeIpc::SelectionRankingReplayGuard guard;
|
|
REQUIRE(guard.should_apply("p|ni|ni|A", 1, 1, 1000));
|
|
// Same connection: the user picked the same candidate again.
|
|
REQUIRE(guard.should_apply("p|ni|ni|A", 1, 1, 1200));
|
|
// A different selection on a new connection is not a replay.
|
|
REQUIRE(guard.should_apply("p|ni|ni|B", 2, 1, 1300));
|
|
// The same selection long after the last one is not a replay either.
|
|
REQUIRE(guard.should_apply("p|ni|ni|B", 3, 1, 1300 + FanyImeIpc::kSelectionReplayWindowMs + 1));
|
|
}
|