Background of the Invention
1. Field of the Invention
The present invention relates to the field of computer systems. More specifically, the present invention relates to the simulation of input events in a windowed environment.
2. Background
Today, many computer systems utilize direct manipulation graphical user interfaces in which many previously coded programming commands are replaced by graphic images, or icons, on a computer display. These graphic images, or icons, symbolically represent a variety of objects or operations the computer system will execute if the graphic images, or icons, are chosen. A user interacts with the computer by choosing and manipulating these graphic images, or icons, using keyboard and cursor control devices such as a "mouse" or a track ball.
Additionally, many direct manipulation graphical user interfaces utilize multiple windows displayed on the computer display for the applications to convey information to a user. The information is presented in a combination of text and graphics in these windows. Each window may take the form of a variety of objects such as a file folder, loose-leaf binder, or simple rectangle, and the windows may overlap one another with the "top" window fully visible and constituting the current "work file". The user may delete information from a window, move data from one window to another, and generally operate on the window as if an actual file in an office is being used. Thus, the user is permitted to operate on and manipulate the window contents, and the window itself, as if the image constituted an actual object.
For further description of specific implementations of direct manipulation graphical user interfaces, for example, OpenWindows.TM., by SUN Microsystems, Inc., or others by manufacturers such as International Business Machines, and Apple Computer, Inc., and their window subsystems, the reader is directed to technical literature provided by these companies.
Windowed applications with graphical user interfaces tend to be large and complex, requiring a large amount of testing. This testing can be time consuming as it involves many possible combinations of actions and many possible situations. Most of this work is redundant and error-prone when performed by humans. These problems are typically avoided by creating automated tests. There are two basic approaches for writing automated tests, a capture/replay approach, and a programmatic approach. Most tools use a combination of both approaches. The capture/replay approach requires the tester to do a series of actions while the test tool records the actions. The sequence can then be played back to reproduce the user actions. The resulting tests are typically very hard to edit because they are simply lists of actions with no structure. The resulting tests also cannot respond to what is happening on the screen when the test is replayed. Thus, the capture/replay approach is only suitable for the very simple test cases. Under the programmatic approach, the tester writes a script or a program that describes the actions to be taken by an emulator. A journaling interface to the window server is provided to simulate user actions. The programmatic approach allows the resulting tests to respond to what is happening on the screen provided that the appropriate dynamic decision makings are supported by the emulator of user actions. As a result, the programmatic approach tends to be more powerful than the capture/replay approach.
However, because of the tight coupling between the prior art journaling interface to the window server, the prior art journaling interface tends to be unreliable, especially for development versions of the window subsystem. Under the prior art approach, the journaling interface also tends to change for different releases of the window server, requiring changes to the automation tool. An alternative approach is to use standard extensions to the window server. However, this alternative approach has the disadvantage of causing the testing platform to be fundamentally different from the operational platform.
Thus, it is desirable to be able to simulate user actions in a windowed environment in a reliable manner. Additionally, it is further desirable that the user input emulator be able to support dynamic decision makings. As will be disclosed, the present invention provides for such a method and apparatus that advantageously achieves the desired results.
Summary of the Invention
Under the present invention, the desired results are advantageously achieved by providing an input device emulator comprising an interpreter and a router. The interpreter reads and interprets commands of a first application program, such as testing commands of a test script program, and generates simulated input device messages. The router routes the simulated input device messages to a window server. Additionally, the router also routes real input and output (I/O) device messages between the I/O devices and the window server. At initialization, instances of the router are pushed onto the operating system's various input/output device streams, in front of the window server from an upstream perspective, connecting the interpreter and the I/O devices to the window server. As a result, the input device emulator of the present invention is not tightly coupled to the window server, thereby improving its reliability, and requiring no modification to the window server.
Under the presently preferred embodiment, the input device emulator of the present invention also supports a number of dynamic decision makings by making appropriate queries and requests to the window server, including opening a window if the targeted window of a command is not open, and relocating a window if the targeted window of a command is only partially visible on the screen.
Brief Description of the Drawings
FIG. 1 illustrates an exemplary computer system incorporating the teachings of the present invention.
FIG. 2 illustrates the display of FIG. 1 in further detail.
FIG. 3 illustrates the key software elements of the exemplary computer system of FIG. 1, including the input device emulator of the present invention.
FIG. 4 illustrates a generic I/O stream of the operating system connecting an I/O device to a process.
FIG. 5 illustrates the input device emulator of the present invention in further detail, including its relationship to the stream modules, the application programs, and the window server.
FIG. 6 illustrates the position of the router of the input device emulator of the present invention on the I/O stream connecting the window server to the keyboard as well as the cursor control device.
FIG. 7 illustrates the data format for the write "channel" and the operation logic of the router of the present invention.
FIG. 8 illustrates a number of exemplary command code and values for simulating a number of input events.
FIGS. 9a-9b illustrates exemplary additional dynamic decision makings supported by the input device emulator of the present invention.
Detailed Description
In the following description, for purposes of explanation, specific numbers, materials and configurations are set forth in order to provide a thorough understanding of the present invention. However, it will be apparent to one skilled in the art that the present invention may be practiced without the specific details. In other instances, well known systems are shown in diagrammatic or block diagram form in order not to obscure the present invention unnecessarily.
Referring now to FIG. 1, a block diagram illustrating an exemplary computer system incorporating the teachings of the present invention is shown. The exemplary computer system 10 comprises a central processing unit (CPU) 12, a memory unit 14, and input/output (I/O) circuitry 16 connected to each other as shown. Additionally, the system 10 further comprises mass storage 18, a display unit 20, a keyboard 22, and a cursor control device 24 coupled to the I/O circuitry 16. Except for the teachings of the present invention as incorporated, these elements 12-24 are intended to represent a broad category of CPUs, memory units, etc., found in many computer systems. They are well known in the art and will not be further described.
Referring now to FIG. 2, a block diagram illustrating the display of FIG. 1 in further detail is shown. The display 20 comprises a number of windows 26 for conveying information from the applications to the user and receiving inputs from the user. The user moves from one window to another by positioning the cursor 28 using a cursor control device 24. Inputs are provided to the owner application of the current window 26 by selecting menu items displayed in the window using the cursor control device 24 or by entering them using a keyboard 22. As will be described in more detail below, an input device emulator is provided to facilitate simulation of these keyboard and cursor control device input events for the application programs. The windowed environment is intended to represent a broad category of window environments found in many computer systems. They are well known in the art and will not be further described.
Referring now to FIG. 3, a block diagram of the key software components of the exemplary computer system of FIG. 1 in further detail is shown. Shown is an operating system 30, a window server 32, a collection of tools and libraries 34, the input device emulator of the present invention 36, and a number of application programs 38, architecturally related to each other as shown.
The operating system 30 provides system services such as memory management, input/output services to the window server 32, the input device emulator 36, etc. The operating system 30 comprises a hardware interface 42 for accessing the various I/O devices, including the display 20, the keyboard 22, and the cursor control device 24. The operating system 30 also comprises a number of device drivers 44 for controlling these accesses. Additionally, the operating system 30 comprises a number of stream modules 48 for performing stream I/O accesses. As will be explained in more detail below, with the exception of the input device emulator 36, in general, these services are available to the window server 32, the input device emulator 34, etc. through the software interface 50.
The window server 32 provides window services such as I/O device resource control, and translation of I/O device messages into I/O event for the input device emulator 36, the application programs 38, etc. The tools and libraries 34 provide common application services such as event notifications to the application programs 38. The input device emulator 36 of the present invention generates and provides simulated input device messages to the window server 32. The input device emulator 36 also routes real I/O device messages between the I/O devices 20-24 and the window server 32.
Except for the input device emulator 36 of the present invention and the manner in which the other elements 30-34 and 38 cooperate with the input device emulator 36, the other elements 30-34 and 38-40 are intended to represent a broad category of operating systems, window servers, etc., found in many computer systems. They are well known in the art, and will not be otherwise further described.
Referring now to FIG. 4, a block diagram illustrating a generic I/O stream is shown. An I/O stream is a fully-duplex connection between a process 32-38 and an I/O device, such as the keyboard 22 and the cursor control device 24. The I/O stream consists of a set of linearly linked device specific and non-device specific modules 47 and 49. Each linked module 44, 47, etc. has a read "channel" and a write "channel". When a process 32-38 writes data, the write "channel" of each linked module 44, 47, etc. sends the data downstream to a receiving device 22 or 24. When a device 22 or 24 inputs data, the read "channel" of each linked module 44, 47 sends the data upstream to a reading process 32-38. A particular example of an operating system having such an I/O stream is the UNIX.RTM. system, which is well known in the art. (UNIX is a registered trademark of the UNIX System Laboratory.)
Referring now to FIG. 5, a block diagram illustrating the input device emulator of the present invention in further detail is shown. As illustrated, the input device emulator 36 comprises an interpreter 60 and a router 62. The interpreter 60 reads and interprets commands of an application program 38a, such as testing commands of a test script program, and generates simulated input device messages. In the presently preferred embodiment, the interpreter 60 also supports a number of dynamic decision makings. The router 62 routes the simulated input device messages to the window server 32. Additionally, the router 62 also routes real I/O device messages between the stream modules 48 and the window server 32.
The interpreter 60 generates the simulated input device messages in accordance with a format expected by the router 62, which will be described in further detail below. The dynamic decision makings supported by the interpreter 60 will also be described in further detail below. Otherwise, the interpreter 60 may offer any number of application dependent interpretation functions to programs. Since interpreter technology is well known in the art, the interpreter 60 will not be otherwise further described.
The router 62 comprises a write "channel" 56, and a read "channel" 58. The write "channel" 56 receives the simulated input device messages from the interpreter 60, and real output device messages from the window server 32. The simulated input device messages received from the interpreter 60 are redirected to the read "channel" 58, whereas, the real output device messages received from the window server 32 are passed to the stream modules 48. The read "channel" 58 receives simulated input device messages redirected from the write "channel" 56, and real input device messages from the stream modules 48. In either case, the simulated input device messages received from the write "channel" 56 as well as the real input device messages received from the stream modules 48 are passed to the window server 32, and in due course to the targeted application program 38b.
Referring now to FIG. 6, two block diagrams illustrating the keyboard and the cursor control I/O streams in further detail are shown. As illustrated, at initialization, an instance of the router 62 is pushed onto each of the keyboard and cursor control I/O streams in front of the window server 32 from the upstream perspective, but behind the keyboard/cursor control module 65 and 66 and the teletype module 64. At termination, both instances of the router 62 are popped from the respective I/O streams. As a result, the program 38a being interpreted can cause simulated input events to be provided to the targeted application program 38b through the window server 32 in a transparent manner. As far as the target application program 38 and the window server 32 are concerned, the simulated input events and the simulated input device messages are indistinguishable from the real input events and the real input device messages respectively. Neither the window server 32, nor any of the input/output devices 22-24 are aware of the interposing of the router 62 of the input device emulator 36 of the present invention between them. More importantly, the simulated input events are provided to the window server 32 without requiring of a journaling interface that is tightly coupled to the window server 32, thereby improving the reliability of the input device emulator 36, and without requiring modification to the window server 32.
Referring now to FIG. 7, a block diagram illustrating the data format of the write "channel" and the operational logic of the router of the input device emulator of the present invention is shown. As illustrated by the "msg" data structure 68, the write "channel" of the router 62 expects a simulated input event to be presented as a message having a predetermined value (also known as magic number in the art) for the variable "emul" denoting the message to be a simulated input event. The predetermined value is to be followed by a command code, a first, and a second command value, which will be described in further detail below.
As illustrated by the code segment 70, for each message the router 62 receives, the router 62 checks to determine if the message size of the message received equals the expected size of a message for a simulated input event. Additionally, the router 62 checks to determine if the starting value for the variable "emul" equals the predetermined value. If both conditions are met, the message is a simulated input message. The message is then redirected to the read "channel" to be forwarded upstream to the window server 32 (qreply (sim.sub.-- message)"), and then to the targeted application program 38b. If at least one of the two conditions is not met, the message is a real output device message. The message is then forwarded downstream to the device driver modules 44 (putnext(message)"), and then to the device 22 or 24.
Referring now to FIG. 8, a block diagram illustrating a number of exemplary command codes and values for simulating a number of input events is shown. The input events illustrated include a "keystation up event", a "keystation down event", a "mouse movement event", a "mouse button down event", and a "mouse button up event". A key station is a unique numeric identifier for each key on the keyboard. The first command value represents either a keystation value, an amount of change in the x-direction, or a button identifier for the mouse. The second command value is normally not used, except when simulating a mouse movement event. In that case, the second command value represents the amount of change in the y-direction.
Referring now to FIGS. 9a-9b, two block diagrams illustrating two exemplary dynamic decision makings supported by the input device emulator of the present invention are shown. FIG. 9a illustrates the support for opening a window if the targeted window of a request is not open. FIG. 9b illustrates the support for relocating a window if the targeted window of a request is partially off screen.
As illustrated in FIG. 9a, if the input event to be simulated is a mouse button clicking event on a menu button of a window 26, step 76, the interpreter 60 determines whether the target window 26 of the mouse button clicking event is open, step 78. The interpreter 60 makes the determination by querying the window server 32. If the targeted window 26 is not open, the interpreter 60 first locates the icon, block 82, and then simulates a mouse move, step 83, and then a mouse button double click event, step 84, to open the window 26. The interpreter 60 also locates the icon by querying the window server 32.
Upon ascertaining that the target window 26 of the simulated mouse button clicking event is open, the interpreter 60 generates the simulated mouse button clicking event, step 80. The location of the simulated mouse button clicking event is computed based on offset coordinates (rx, ry) of the menu button provided by the application program 38 being executed by the interpreter, and the base coordinates (x0, y0) of the target window 26 provided by the window server 32.
As illustrated in FIG. 9b, if the command involves using a window 26, the interpreter 60 determines if the target window 26 is partially off screen 20 by checking whether the sums of the base coordinates (x0, y0) and the dimensions (w1, h1) of the target window 26 exceed the dimensions (w0, h0) of the screen 20, steps 84 and 88. In each case, if the sum is greater than the corresponding dimension of the screen 20, i.e. (x1+w1)>w0 or (y1+h1)>h0, a delta movement amount (xd or yd) is computed, i.e. xd=w0-(x1+w1) or yd=h0 -(y1 +h1), step 86 or 90. The interpreter 60 obtains (x0, y0), (w0, h0), and (w1, h1) from the window server 32.
Upon making these checking and conditionally computing the delta movement amounts (xd, yd), the interpreter 60 checks to determine if either xd or yd is less than zero, step 92. If either xd or yd is less than zero, the interpreter 60 first generates a simulated mouse movement event to drag the target window 26 to the new base coordinates ((x1+xd), (y1+yd)). Upon ascertaining that the target window 26 is not partially off screen 20, the interpreter 60 then proceeds to perform the use request, generating the necessary simulated input events, step 96.
While the present invention has been described in terms of presently preferred and alternate embodiments, those skilled in the art will recognize that the invention is not limited to the embodiments described. The method and apparatus of the present invention can be practiced with modification and alteration within the spirit and scope of the appended claims. The description is thus to be regarded as illustrative of, and not limiting the scope of the present invention.