公开 SDK 落后主仓的一批 bugfix(主仓是固件构建源,这些修复已在设备上跑过)。 本次只做「主仓 → 公开仓」单向同步,图像栈方向由主仓侧另一单处理。 时钟 ABI(M16 第二弹,原文件自认「残余未修」): - meow_ui_time.c 147→345 行:futex 相对超时接管(__timedwait/_cp)、 timerfd_create/settime/gettime 的 itimerspec 64↔32 双向转换、 __clock_settime64 越界返 ENOTSUP,另有 4 个纯换算函数 - meow_ui_internal.h:struct meow_time32 / meow_itimerspec32 契约移入内部头 - CLOCK_ABI.md:补接管机制、验证配方与 objdump 证据 - 新增 test_meow_time64.c IME bug3(成对才有意义): - meow_ui_ime.c:IME_TAP_COOLDOWN_MS 200 冷却窗 + 打开时二次 drain - meow_ui_input.c:meow_input_touch_reset() 并在 drain 内调用(复位触摸状态机) - test_ime_fix.c:新增用例④ stray-tap 列表行高(M15,修用户可见 bug): - meow_ui_widget.c:listv_item_h() 由主题字体行高派生,不再写死 56 (两行列表 62 > 56 会让首行标题被裁剪守卫整条跳过) - include/meow_ui_widgets.h:新增 meow_listview_item_h() - 新增 test_meow_ui_listview_rowh.c 其余:meow_select.c / meow_ui_dialog.c 统一 MD3 形状 token; include/meow_ipc.h 补 MSG_KEY_PAGEUP/PAGEDOWN 枚举; meow_ui_sys.c / meow_cachegov.c 取时统一走 meow_ui_time_ms()。 测试辅助函数标定:tuku/test/test_settings_lock_host.c 的注入前等待 150ms→350ms。 该等待按修复前 IME 标定,新冷却窗下首键 dt_open≈114ms 会被当迟到抬起吞掉, 只录到 "68" 两位。仅改等待时长,断言原样保留。 验证:tuku 四套脚本全绿(run_tests 644 PASS / zip 106 / cbz 296 / webtoon PASS); 12 个源文件与主仓逐字节一致;sdk/build_sdk.sh 34 成员; tuku/build_tuku.sh 产出静态 MIPS32r2 ELF。
211 lines
9.4 KiB
C
211 lines
9.4 KiB
C
/* test_meow_ui_swipe.c — 宿主验证列表行左滑删除(§5.5,M7.3 缺口 #9):
|
||
* T1 滑动手势判定与冲突消解:begin 命中可滑行返回 1;横向小位移 = swipe(move 返回 1 消费);
|
||
* 纵向大位移 = 滚动手势优先(move 返回 0 并取消本行 swipe);非启用行 begin 返回 0。
|
||
* T2 左滑超阈值 → 删除动画(meow_anim 滑出),结束后 on_delete 回调恰一次 + swipe 状态复位。
|
||
* T3 未超阈值 → 回弹,on_delete 不触发,swipe_dx 回到 0。
|
||
* T4 点按(无位移):begin 后 end(未 started)返回 0(App 走 tap_at),不触发 on_delete。
|
||
* T5 右露删除区像素:滑动中重绘列表 → 右露区画主题 error 底 + 行内容左移。
|
||
*
|
||
* 编译(宿主 gcc):
|
||
* gcc -o test_meow_ui_swipe test_meow_ui_swipe.c test_host_stub.c \
|
||
* meow_ui_gfx.c meow_ui_time.c meow_ui_sys.c meow_ui_theme.c meow_ui_vol.c meow_ui_log.c \
|
||
* meow_ui_widget.c meow_ui_input.c meow_ui_activity.c meow_ui_dialog.c meow_ui_ime.c meow_ui_str.c \
|
||
* meow_pinyin.c meow_ui_draw.c meow_ui_view.c meow_ui_box.c meow_ui_anim.c meow_ui_scroll.c \
|
||
* meow_ui_img.c meow_ui_media.c meow_notify_ipc.c stb_image.c meow_ui_nav.c \
|
||
* -I. -Iinclude -DMEOW_UI_HOST_TEST -pthread -lm
|
||
* 运行:./test_meow_ui_swipe
|
||
*/
|
||
#include "meow_ui.h"
|
||
#include "meow_ui_internal.h"
|
||
#include <stdio.h>
|
||
#include <stdlib.h>
|
||
#include <string.h>
|
||
#include <unistd.h>
|
||
|
||
static int g_pass = 0, g_fail = 0;
|
||
#define CHECK(cond, ...) do { \
|
||
if (cond) { g_pass++; } \
|
||
else { g_fail++; printf("FAIL %s:%d ", __FILE__, __LINE__); printf(__VA_ARGS__); printf("\n"); } \
|
||
} while (0)
|
||
|
||
static void rd_px(int x, int y, int *r, int *g, int *b)
|
||
{
|
||
unsigned char *bb = meow_ui_back_buf();
|
||
int line = meow_ui_back_buf_pitch(), bpp = meow_ui_back_buf_bpp();
|
||
if (!bb || x < 0 || y < 0) { *r = *g = *b = 0; return; }
|
||
if (bpp == 16) {
|
||
uint16_t px = *(uint16_t *)(bb + (size_t)y * line + (size_t)x * 2);
|
||
*r = (((px >> 11) & 0x1F) << 3) | ((px >> 11) & 0x1F) >> 2;
|
||
*g = (((px >> 5) & 0x3F) << 2) | ((px >> 5) & 0x3F) >> 4;
|
||
*b = ((px & 0x1F) << 3) | ((px & 0x1F) >> 2);
|
||
} else {
|
||
uint32_t px = *(uint32_t *)(bb + (size_t)y * line + (size_t)x * 4);
|
||
*r = (px >> 16) & 0xFF; *g = (px >> 8) & 0xFF; *b = px & 0xFF;
|
||
}
|
||
}
|
||
static int near2(int a, int b) { int d = a - b; if (d < 0) d = -d; return d <= 14; }
|
||
static int px_near(int x, int y, int r, int g, int b)
|
||
{
|
||
int rr, gg, bb; rd_px(x, y, &rr, &gg, &bb);
|
||
return near2(rr, r) && near2(gg, g) && near2(bb, b);
|
||
}
|
||
static int region_has(int x, int y, int w, int h, int r, int g, int b)
|
||
{
|
||
int cnt = 0;
|
||
for (int dy = 0; dy < h; dy++)
|
||
for (int dx = 0; dx < w; dx++)
|
||
if (px_near(x + dx, y + dy, r, g, b)) cnt++;
|
||
return cnt;
|
||
}
|
||
#define UNPK(c, rr, gg, bb) do { (rr) = ((c) >> 16) & 0xFF; (gg) = ((c) >> 8) & 0xFF; (bb) = (c) & 0xFF; } while (0)
|
||
|
||
#define LVX 20
|
||
#define LVY 50
|
||
#define LVW 440
|
||
#define LVH 300
|
||
#define ITEM 56
|
||
#define CNT 10
|
||
|
||
static int del_count; /* on_delete 回调次数 */
|
||
static int del_idx; /* 最后一次删除 idx */
|
||
static void on_delete(int idx, void *ctx) { (void)ctx; del_count++; del_idx = idx; }
|
||
|
||
static int scount(void *ctx) { (void)ctx; return CNT; }
|
||
static void sbind(int idx, meow_lv_item *it, void *ctx)
|
||
{
|
||
(void)ctx;
|
||
memset(it, 0, sizeof *it);
|
||
static char t[32];
|
||
snprintf(t, sizeof t, "notif %d", idx);
|
||
it->title = t; it->icon_kind = MEOW_LIST_ICON_NONE; it->right = MEOW_LIST_RIGHT_NONE;
|
||
it->enabled = 1;
|
||
}
|
||
|
||
static meow_widget *make_list(void)
|
||
{
|
||
meow_widget *lv = meow_listview_create(LVX, LVY, LVW, LVH, 0, NULL, NULL, MEOW_LIST_SEL_NONE);
|
||
meow_listview_set_item_h(lv, ITEM);
|
||
meow_listview_set_vsource(lv, scount, sbind, NULL);
|
||
meow_listview_set_item_renderer(lv, 2, 0, 0); /* 双行、无图标、无尾件 */
|
||
meow_listview_set_swipe_delete(lv, 1, on_delete, NULL);
|
||
return lv;
|
||
}
|
||
|
||
/* 推进 meow_anim 直到 swipe 动画结束(模拟 on_tick 节拍)。 */
|
||
static void pump_swipe(meow_widget *lv)
|
||
{
|
||
int guard = 0;
|
||
while (meow_listview_swipe_active(lv) && guard++ < 80) {
|
||
meow_anim_tick();
|
||
usleep(10000);
|
||
}
|
||
meow_anim_tick();
|
||
}
|
||
|
||
int main(void)
|
||
{
|
||
meow_ui_opts o = { 480, 720 };
|
||
if (meow_ui_init(&o) != 0) { printf("init failed\n"); return 1; }
|
||
const meow_theme *th = meow_theme_get();
|
||
int err_r, err_g, err_b; UNPK(th->error, err_r, err_g, err_b);
|
||
|
||
int row0y = LVY + ITEM / 2; /* 行 0 中心 y(scroll=0) */
|
||
|
||
/* ============ T1 手势判定 / 冲突消解 ============ */
|
||
{
|
||
meow_widget *lv = make_list();
|
||
/* begin 命中可滑行行 → 1 */
|
||
CHECK(meow_listview_swipe_begin(lv, 100, row0y) == 1, "T1 begin on swipe row = 1");
|
||
/* 横向小位移 → 裁定 swipe,move 返回 1(消费) */
|
||
CHECK(meow_listview_swipe_move(lv, 40, row0y) == 1, "T1 move horizontal = 1 (consumed)");
|
||
int dx = meow_listview_swipe_offset(lv);
|
||
CHECK(dx == -60, "T1 dx=-60 got %d", dx);
|
||
/* 又一小位移(不超容差也不改变方向) */
|
||
CHECK(meow_listview_swipe_move(lv, 30, row0y) == 1, "T1 move horizontal 2 = 1");
|
||
CHECK(meow_listview_swipe_end(lv, 30, row0y) == 1, "T1 end started swipe = 1 (bounce)");
|
||
pump_swipe(lv);
|
||
CHECK(meow_listview_swipe_offset(lv) == 0, "T1 bounce back dx=0 got %d", meow_listview_swipe_offset(lv));
|
||
CHECK(del_count == 0, "T1 no delete on bounce");
|
||
meow_widget_free(lv);
|
||
}
|
||
{
|
||
/* 纵向大位移 → 滚动手势优先(move 返回 0 + 取消) */
|
||
meow_widget *lv = make_list();
|
||
CHECK(meow_listview_swipe_begin(lv, 100, row0y) == 1, "T1 begin2 = 1");
|
||
CHECK(meow_listview_swipe_move(lv, 100, row0y + 80) == 0, "T1 vertical move = 0 (yield to scroll)");
|
||
CHECK(meow_listview_swipe_active(lv) == 0, "T1 vertical cancels swipe");
|
||
CHECK(meow_listview_swipe_offset(lv) == 0, "T1 vertical dx=0");
|
||
meow_widget_free(lv);
|
||
}
|
||
{
|
||
/* 非启用行 begin → 0 */
|
||
meow_widget *lv = make_list();
|
||
meow_listview_set_swipe_delete(lv, 0, NULL, NULL);
|
||
CHECK(meow_listview_swipe_begin(lv, 100, row0y) == 0, "T1 disabled begin = 0");
|
||
meow_widget_free(lv);
|
||
}
|
||
|
||
/* ============ T2 超阈值 → 删除动画 + on_delete ============ */
|
||
{
|
||
del_count = 0; del_idx = -1;
|
||
meow_widget *lv = make_list();
|
||
CHECK(meow_listview_swipe_begin(lv, 100, row0y) == 1, "T2 begin = 1");
|
||
/* 左滑 200px(阈值=LVW*2/5=176)→ 超阈值 */
|
||
CHECK(meow_listview_swipe_move(lv, 100 - 200, row0y) == 1, "T2 move big left = 1");
|
||
CHECK(meow_listview_swipe_end(lv, 100 - 200, row0y) == 1, "T2 end = 1 (delete anim)");
|
||
CHECK(meow_listview_swipe_active(lv) == 1, "T2 delete anim active");
|
||
pump_swipe(lv);
|
||
CHECK(del_count == 1, "T2 on_delete fired once got %d", del_count);
|
||
CHECK(del_idx == 0, "T2 on_delete idx0 got %d", del_idx);
|
||
CHECK(meow_listview_swipe_active(lv) == 0, "T2 state reset inactive");
|
||
CHECK(meow_listview_swipe_offset(lv) == 0, "T2 dx reset 0 got %d", meow_listview_swipe_offset(lv));
|
||
meow_widget_free(lv);
|
||
}
|
||
|
||
/* ============ T3 未超阈值 → 回弹,on_delete 不触发 ============ */
|
||
{
|
||
del_count = 0;
|
||
meow_widget *lv = make_list();
|
||
CHECK(meow_listview_swipe_begin(lv, 100, row0y) == 1, "T3 begin = 1");
|
||
CHECK(meow_listview_swipe_move(lv, 55, row0y) == 1, "T3 move left 45px = 1");
|
||
CHECK(meow_listview_swipe_offset(lv) == -45, "T3 dx=-45 got %d", meow_listview_swipe_offset(lv));
|
||
CHECK(meow_listview_swipe_end(lv, 55, row0y) == 1, "T3 end = 1 (bounce anim)");
|
||
CHECK(meow_listview_swipe_active(lv) == 1, "T3 bounce active");
|
||
pump_swipe(lv);
|
||
CHECK(del_count == 0, "T3 on_delete NOT fired got %d", del_count);
|
||
CHECK(meow_listview_swipe_offset(lv) == 0, "T3 bounce dx=0 got %d", meow_listview_swipe_offset(lv));
|
||
CHECK(meow_listview_swipe_active(lv) == 0, "T3 inactive after bounce");
|
||
meow_widget_free(lv);
|
||
}
|
||
|
||
/* ============ T4 点按(无位移)= 行点击,end 返回 0 ============ */
|
||
{
|
||
del_count = 0;
|
||
meow_widget *lv = make_list();
|
||
CHECK(meow_listview_swipe_begin(lv, 100, row0y) == 1, "T4 begin = 1");
|
||
CHECK(meow_listview_swipe_end(lv, 100, row0y) == 0, "T4 tap end = 0 (let App tap_at)");
|
||
CHECK(del_count == 0, "T4 no delete on tap");
|
||
CHECK(meow_listview_swipe_active(lv) == 0, "T4 inactive after tap");
|
||
meow_widget_free(lv);
|
||
}
|
||
|
||
/* ============ T5 右露删除区像素(默认 renderer) ============ */
|
||
{
|
||
meow_widget *lv = make_list();
|
||
CHECK(meow_listview_swipe_begin(lv, 100, row0y) == 1, "T5 begin = 1");
|
||
CHECK(meow_listview_swipe_move(lv, 100 - 200, row0y) == 1, "T5 move big left = 1");
|
||
meow_ui_clear(th->bg);
|
||
meow_widget_draw(lv);
|
||
/* 右露区 [LVX+LVW+dx, row0, -dx, ITEM] = [260,50,200,56] → error 底 */
|
||
CHECK(region_has(270, row0y - ITEM / 2 + 4, 180, ITEM - 8, err_r, err_g, err_b) > 50,
|
||
"T5 delete reveal error bg got %d", region_has(270, row0y - ITEM / 2 + 4, 180, ITEM - 8, err_r, err_g, err_b));
|
||
meow_listview_swipe_end(lv, 100 - 200, row0y);
|
||
pump_swipe(lv);
|
||
meow_widget_free(lv);
|
||
}
|
||
|
||
meow_ui_shutdown();
|
||
printf("swipe: %d pass / %d fail\n", g_pass, g_fail);
|
||
return g_fail ? 1 : 0;
|
||
}
|