Directfb stress testing tool

Source: Internet
Author: User

Indicate the source and author's contact information during reprinting.
Contact information of the author: Li xianjing <xianjimli at Hotmail dot com>

Automated Testing of GUI applications has always been a problem. The common practice is to record the manual testing process and then replay the testing process. The main disadvantage of this method is that it is difficult to automatically check the correctness of the running results, so many people do not bother to use it. In fact, a tool always has its limitations. Whether it can play its due role depends on the flexible use of people. That is to say, you cannot rely too much on or blindly reject tools.

In the process of quality assurance, people are undoubtedly the most important. Nothing is more effective than writing high-quality code at a time. However, the fact is that, even with a sound architecture design, some bugs are still the fish of the Internet, thanks to some effective practices such as unit testing and code review. What's more, many teams have done this well. A single tool and method is difficult to cover all kinds of diseases, but the effects of combining various methods and tools are quite different.

Some time ago, a colleague developed a GUI automatic testing tool. We used it for Bug reproduction and stress testing and achieved good results. Here we will introduce how to record and Replay events in directfb:

Obtain the keyboard device:

Dfb_input_enumerate_devices (inputdevicecallback) device_callback,
& Context-> keyboard_device, dicaps_keys );

Get the mouse or touch screen device: dfb_input_enumerate_devices (inputdevicecallback) device_callback,
& Context-> mouse_device, dicaps_axes | dicaps_buttons );

Register the event listening function with the device: 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 );

Event listening function: static 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;

If (fwrite (msg_data, sizeof (dfbinputevent), 1, context-> file )! = 1)
{
Printf ("[% s]: fwrite error errno = % d
", _ FUNC __, errno );

G_main_loop_quit (context-> loop );
}
Fflush (context-> file );

Return rs_ OK;
}

Event Replay Function: static gboolean replay_one_event (gpointer user_data)
{
Dfbcontext * context = (dfbcontext *) user_data;
Off_t cur = 0;

Dfbinputevent event = context-> event;

If (event. type = diet_keypress | event. type = diet_keyrelease)
{
Dfb_input_dispatch (context-> keyboard_device, & event );
}
Else
{
Dfb_input_dispatch (context-> mouse_device, & event );
}

If (fread (& context-> event, sizeof (dfbinputevent), 1, context-> file) = 1)
{
Guint 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 );
}
Else
{
G_main_loop_quit (context-> loop );
}

Return false;
}

Note: pen point events in directfb are expressed in relative coordinates, so ensure that the replay time is marked at the same initial position. If directfb runs in multi-process mode, this program can be an independent process, otherwise it will be placed in the application process.

~~ End ~~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.