meow_ui.a→9a8eb7ef; hello→fc299577; launcher→b33da20a; 宿主5套件+新test_notif_open+qemu分发 全过 出入: SDK符号用meow_ui_前缀防与launcher内同名冲突; 叠加会话真机待验; §10.5文档旧号段已过时
125 lines
5.6 KiB
C
125 lines
5.6 KiB
C
/* test_sb_collapse.c — 宿主验证「全屏状态栏收合」纯逻辑(agent-146,不依赖 /dev/fb0/字库):
|
||
* 1. 顶条模式上报:App 进程(system_mode=0)set_collapsed/set_fullscreen → 写 /tmp/meowapp_sbar
|
||
* ('0'展开/'1'收合/'2'隐藏),供 launcher 感知 App 运行时全屏/收合态。
|
||
* 2. 热区保留判定:状态栏激活(含收合)时 meow_ui_statusbar_hotzone()==MUI_SBAR_H(28)(收合≠禁热区,
|
||
* 渲染与热区事件分离);仅全屏隐藏(inset0)时缩到 MEOW_SBAR_HOTZONE_FS(4)。
|
||
* 3. 收合状态机:system_mode=1 + animate(200) + set_collapsed(1) → animating()==1,
|
||
* collapse_offset() 随时间推进 → 28(收合出屏);set_collapsed(0) → offset 回 0(恢复)。
|
||
* 4. 收合 inset:collapsed → meow_ui_statusbar_height()==MUI_SBAR_COLLAPSE_H(4)。
|
||
*
|
||
* 编译(宿主 gcc,链真实 gfx/sys/theme/vol/log + 打桩 font/global + meow_notify_ipc):
|
||
* gcc -o test_sb_collapse test_sb_collapse.c test_host_stub.c \
|
||
* meow_ui_gfx.c meow_ui_sys.c meow_ui_theme.c meow_ui_vol.c meow_ui_log.c meow_notify_ipc.c \
|
||
* -I. -I../meow_launcherd -DMEOW_UI_HOST_TEST -pthread
|
||
*/
|
||
#include "meow_ui.h"
|
||
#include "meow_ui_internal.h"
|
||
#include "meow_ui_sys.h"
|
||
|
||
#include <stdio.h>
|
||
#include <string.h>
|
||
#include <stdlib.h>
|
||
#include <unistd.h>
|
||
#include <fcntl.h>
|
||
#include <assert.h>
|
||
|
||
#define SBAR_MODE_FILE "/tmp/meowapp_sbar"
|
||
|
||
static int read_mode(void)
|
||
{
|
||
int fd = open(SBAR_MODE_FILE, O_RDONLY);
|
||
if (fd < 0) return -1;
|
||
char ch[8]; int n = read(fd, ch, sizeof ch - 1);
|
||
close(fd);
|
||
if (n <= 0) return -1;
|
||
return ch[0] == '1' ? 1 : (ch[0] == '2' ? 2 : 0);
|
||
}
|
||
|
||
int main(void)
|
||
{
|
||
meow_ui_opts o = { 480, 720 };
|
||
assert(meow_ui_init(&o) == 0);
|
||
/* 初始 App 模式(system_mode 默认 0) */
|
||
assert(meow_ui_sys_render_enabled() == 0);
|
||
|
||
/* ---- 1) 顶条模式上报 ---- */
|
||
meow_ui_set_fullscreen(0); meow_ui_statusbar_set_collapsed(0);
|
||
assert(read_mode() == 0); /* 展开 */
|
||
meow_ui_statusbar_set_collapsed(1);
|
||
assert(read_mode() == 1); /* 收合 */
|
||
meow_ui_statusbar_set_collapsed(0);
|
||
meow_ui_set_fullscreen(1);
|
||
assert(read_mode() == 2); /* 隐藏 */
|
||
meow_ui_set_fullscreen(0);
|
||
printf("PASS mode-file: app writes /tmp/meowapp_sbar (0=expanded 1=collapsed 2=hidden)\n");
|
||
|
||
/* ---- 2a) 激活(含收合)时热区保留 28 ---- */
|
||
meow_ui_statusbar_set_collapsed(1);
|
||
assert(meow_ui_statusbar_collapsed() == 1);
|
||
assert(meow_ui_statusbar_hotzone() == MUI_SBAR_H); /* 收合仍监听顶部 28px(渲染与热区分离) */
|
||
assert(meow_ui_statusbar_height() == MUI_SBAR_COLLAPSE_H); /* 收合 inset=4(提示线) */
|
||
assert(meow_ui_sys_statusbar_active() == 1); /* 收合仍视为状态栏激活 */
|
||
printf("PASS hotzone-retain: collapsed -> hotzone=%d(28) inset=%d(4) active\n",
|
||
meow_ui_statusbar_hotzone(), meow_ui_statusbar_height());
|
||
|
||
/* ---- 2b) 全屏隐藏(immersive)时热区缩小 ---- */
|
||
meow_ui_statusbar_set_collapsed(0);
|
||
meow_ui_set_fullscreen(1);
|
||
int fs_hot = meow_ui_statusbar_hotzone();
|
||
assert(fs_hot == MEOW_SBAR_HOTZONE_FS); /* inset0 → 4 */
|
||
printf("PASS hotzone-shrink: fullscreen-hidden -> hotzone=%d(fs=4)\n", fs_hot);
|
||
meow_ui_set_fullscreen(0);
|
||
meow_ui_statusbar_set_collapsed(0);
|
||
|
||
/* ---- 3) 收合状态机(launcher / system_mode=1)---- */
|
||
meow_ui_sys_set_system_mode(1);
|
||
assert(meow_ui_sys_render_enabled() == 1);
|
||
meow_ui_set_refresh_always_max(1); /* 宿主:绕过帧率门控,逐次 flush 可推进 */
|
||
|
||
meow_ui_statusbar_set_collapsed(0); /* 复位 */
|
||
meow_ui_set_fullscreen(0);
|
||
meow_ui_statusbar_animate(200); /* 上移过渡 200ms */
|
||
assert(meow_ui_statusbar_animating() == 0);
|
||
meow_ui_statusbar_set_collapsed(1); /* 目标收合 */
|
||
assert(meow_ui_statusbar_animating() == 1); /* 未到位 → 过渡中 */
|
||
assert(meow_ui_statusbar_collapse_offset() == 0);
|
||
|
||
/* 驱动 present(标顶条左上 1px 唤醒 + 上屏)并让时间流逝,验证 offset 推进 */
|
||
int off_prev = 0, progressed = 0;
|
||
for (int i = 0; i < 60; i++) {
|
||
meow_ui_flush_region(0, 0, 1, 1);
|
||
usleep(15000); /* ~15ms/帧,模拟过渡期高频刷 */
|
||
int off = meow_ui_statusbar_collapse_offset();
|
||
if (off > off_prev) progressed = 1;
|
||
off_prev = off;
|
||
if (!meow_ui_statusbar_animating()) break; /* 到 28 稳定 */
|
||
}
|
||
assert(progressed == 1);
|
||
assert(meow_ui_statusbar_collapse_offset() >= MUI_SBAR_H);
|
||
assert(meow_ui_statusbar_animating() == 0);
|
||
assert(meow_ui_statusbar_height() == MUI_SBAR_COLLAPSE_H); /* 收合稳定:inset=4 */
|
||
printf("PASS collapse-enter: offset 0->%d (animating 1->0)\n",
|
||
meow_ui_statusbar_collapse_offset());
|
||
|
||
/* 退出全屏(恢复):offset 回 0 */
|
||
meow_ui_statusbar_set_collapsed(0);
|
||
assert(meow_ui_statusbar_animating() == 1);
|
||
int back = 0;
|
||
for (int i = 0; i < 60; i++) {
|
||
meow_ui_flush_region(0, 0, 1, 1);
|
||
usleep(15000);
|
||
back = meow_ui_statusbar_collapse_offset();
|
||
if (!meow_ui_statusbar_animating()) break;
|
||
}
|
||
assert(back == 0 && meow_ui_statusbar_animating() == 0);
|
||
assert(meow_ui_statusbar_height() == MUI_SBAR_H); /* 恢复:inset=28 */
|
||
printf("PASS collapse-exit: offset ->0 (inset back to 28)\n");
|
||
|
||
/* 清理:宿主测试产物 */
|
||
unlink(SBAR_MODE_FILE);
|
||
|
||
printf("ALL PASS\n");
|
||
meow_ui_shutdown();
|
||
return 0;
|
||
}
|