directfb:DirectFB压力测试工具来源: 发布时间:星期六, 2008年12月13日 浏览:11次 评论:0
在质量保证过程中人无疑是最重要没有什么比次性写出高质量代码就有效了但事实是即使有良好架构设计辅的于单元测试和代码评审等些有效实战仍然有些BUG成为漏网的鱼更何况很多团队(Team)这些工作做得并到位单工具和思路方法很难包医百病但各种思路方法和工具综合起来使用效果就大不样了
前段时间位同事开发了个GUI自动测试工具我们把它用于BUG重现和压力测试中取得了不错效果这里介绍下DirectFB里面事件录制和重放思路方法: 获得键盘设备: dfb_input_enumerate_devices ((InputDeviceCallback)device_callback, &context->keyboard_device, DICAPS_KEYS); 获得鼠标或触摸屏设备: dfb_input_enumerate_devices ((InputDeviceCallback)device_callback, &context->mouse_device, DICAPS_AXES | DICAPS_BUTTONS); 向设备注册事件监听: dfb_input_attach (context->mouse_device, input_device_listener, context, &context->mouse_reaction); dfb_input_attach (context->keyboard_device, input_device_listener, context, &context->keyboard_reaction); 事件监听: ReactionResult input_device_listener (const void *msg_data, void *ctx) ...{ DFBContext *context = (DFBContext*)ctx; DFBInputEvent *event = (DFBInputEvent*)msg_data; event->locks = 0; event->flags &= ~DIEF_LOCKS; (fwrite (msg_data, (DFBInputEvent), 1, context->file) != 1) ...{ prf ("[%s]: fwrite Error errno = %d ", __func__, errno); g__loop_quit (context->loop); } fflush(context->file); RS_OK; } 事件重放: gboolean replay_one_event (gpoer user_data) ...{ DFBContext *context = (DFBContext*)user_data; off_t cur = 0; DFBInputEvent event = context->event; (event.type DIET_KEYPRESS || event.type DIET_KEYRELEASE) ...{ dfb_input_dispatch (context->keyboard_device, &event); } ...{ dfb_input_dispatch (context->mouse_device, &event); } (fread (&context->event, (DFBInputEvent), 1, context->file) 1) ...{ gu ms = (context->event.timestamp.tv_sec - event.timestamp.tv_sec) * 1000 + (context->event.timestamp.tv_usec - event.timestamp.tv_usec)/1000; g_timeout_add (ms, replay_one_event, user_data); } ...{ g__loop_quit (context->loop); } FALSE; } 注意:DirectFB中笔点事件是以相对坐标方式表示所以要保证重放时光标在同样位置如果DirectFB以多进程方式运行这个可以是个独立进程否则要放到应用进程中才行 0
相关文章
读者评论
发表评论 |