Testing Applications with Xnee
Xnee is a GNU package, and the sources can be found at the Xnee home page. Download the latest source; as of this writing, the latest version is 1.0.6. Extract the package, and then configure, build and install it:
tar zxvf xnee-1.0.6.tar.gz cd xnee-1.0.6 ./configure make make install
RPM packages are available at the home page, and Xnee also is available in the FreeBSD ports tree. Xnee comes with a user manual and a developer manual in various formats. The TeX sources to the manuals are distributed with Xnee and covered under GNU FDL. Instead of building the documents yourself, you can download the format of your choice (PDF, HTML, INFO and TXT) from the Xnee home page. As of this writing, the Xnee documentation version is 1.0.4. Extract the documents:
tar zxvf xnee-doc-1.0.4.tar.gz
When running Xnee, make sure the RECORD extension is enabled. On XFree86 make sure the RECORD module is loaded. Open the XFree86 configuration file, typically /etc/X11/XF86Config-4, and look in the Module section. The following line should be included:
We don't go into any details about Xnee in this section, but rather begin slowly with a simple example. Start Xnee with the --all-events option. This sets up the recording of a few events. The option is not useful when doing serious Xneeing. It is intended to simplify your introduction to using Xnee:
When moving the mouse or pressing the buttons or keys, Xnee prints information about the action. We move on to record a simple session that we replay immediately. To record 20 mouse motions, start Xnee like this:
xnee --record --out session1.xnr \ --device-event-range MotionNotify --loops 20
The options on the command line mean use recording mode (--record), save output in a file called session1.xnr (--out session1.xnr), record the device-event MotionNotify (--device-event-range MotionNotify) and record 20 events (--loops 20).
To replay this event, start Xnee like this:
xnee --replay --file session1.xnr
The options on the command line mean use replay mode (--replay), and read data to replay from file session1.xnr (--file session1.xnr).
Xnee uses ranges to explain what is to be recorded. Ranges have a start value and a stop value. The following data can be recorded: core-requests, device-event, delivered-event, error, reply, extension requests and extension replies. We don't describe the above data in this article. If you want to read more, see the RECORD extension documents. When, for example, you want to record the device event MotionNotify, use:
To record the events from KeyPress up to MotionNotify and CreateNotify, use:
--device-event-range KeyPress-MotionNotify,\ CreateNotify
You can use the number corresponding to the event name instead of the name itself if you want shorter command lines. To find the number for the data you want to record, use Xnee's --print-data-name option:
You can stop recording by setting the number of the data to record (--loops option), or you can interrupt Xnee by sending a TERM signal (pressing Ctrl-C in the terminal window where you started Xnee). Alternatively, you can dedicate a modifier and key combination that won't be used to do anything else during recording. Setting the modifier and key is done with the --stop-key option. To set up Xnee so it stops recording when Ctrl-Alt-A are pressed, add the following to the command-line option:
But why even bother to record data other than device events when you can't replay it? Xnee uses that other data to synchronize, which is where things get complicated. Think of recording a session when using Galeon or any other Web browser. When recording, everything goes well and the network is up and running. But when replaying the Galeon session, you can't reach the Internet. If not for synchronization, Xnee might replay user events such as clicking on a link on the Web page. If Galeon could not load the page, it is not useful to continue the replay until the network is up and the page can be loaded.
When recording other data, we can use it to synchronize the session. For example, if we record the data sent when displaying the Web page in the Galeon window, we can wait for the same data to be sent when replaying. This ensures that the Web page is loaded before we go on and replay the coming events. In this example, we skip a lot of the X protocol data sent when recording in order to keep it simple (see Table 1). When replaying this simple session, Xnee uses the same events (see Table 2).
Table 1. X Events at the Start of a Galeon Test
|Protocol Data Name||User or Client Action|
|MotionNotify||The user moves the pointer to the Galeon launch icon.|
|ButtonPress||The user presses the button and Galeon starts.|
|CreateNotify||Galeon is started and the window is created.|
|VisibilityNotify||The start page is loaded and visible to the user.|
|MotionNotify||The user moves the pointer to a link on the loaded page.|
|ButtonPress||The user clicks on the link.|
|VisibilityNotify||The new page is loaded and visible to the user.|
Table 2. How Xnee Replays a Test Session
|Protocol Data Name||Xnee Action|
|MotionNotify||Xnee moves the pointer to the Galeon launch icon.|
|ButtonPress||Xnee presses the button and Galeon starts.|
|CreateNotify||Xnee waits for this event to be sent. When Xnee receives a CreateNotify notice, it continues with the next event in the file.|
|VisibilityNotify||Xnee waits for this event to be sent. Because the network is down and the page can't be loaded, this event isn't sent. Xnee continues to wait. Eventually the event is sent and Xnee can continue.|
|MotionNotify||Xnee moves the pointer to a link on the loaded page.|
|ButtonPress||Xnee clicks on this link.|
|VisibilityNotify||The new page is loaded and visible.|
Practical books for the most technical people on the planet. Newly available books include:
- Agile Product Development by Ted Schmidt
- Improve Business Processes with an Enterprise Job Scheduler by Mike Diehl
- Finding Your Way: Mapping Your Network to Improve Manageability by Bill Childers
- DIY Commerce Site by Reven Lerner
Plus many more.
- Download "Linux Management with Red Hat Satellite: Measuring Business Impact and ROI"
- Happy GPL Birthday VLC!
- Unikernels, Docker, and Why You Should Care
- Handheld Emulation: Achievement Unlocked!
- Controversy at the Linux Foundation
- Giving Silos Their Due
- Don't Burn Your Android Yet
- Firefox OS
- New Products