test Package

test Package

User interface: Testing

This is a framework for testing graphical applications. The two main parts of the framework are the L{Player<kiwi.ui.test.player.Player>} and the L{Recorder<kiwi.ui.test.recorder.Recorder>}.

The recorder listens to certain events happening inside the application and writes a script which later on can be played back by the player.

To record a test:

kiwi-ui-test --record=script.py application [arguments]

To play back a recorded test:

kiwi-ui-test script.py

common Module

Common routines used by other parts of the ui test framework.

class kiwi.ui.test.common.WidgetIntrospecter[source]

Bases: gobject._gobject.GObject

GtkContainer(toplevel, container)[source]

Called when a GtkContainer is about to be traversed

Parsers all the children and listens for new children, which may be added at a later point.

GtkDialog(toplevel, dialog)[source]

Called when a GtkDialog is about to be traversed

Just parses the widgets embedded in the dialogs.

GtkMenuItem(toplevel, item)[source]

Called when a GtkMenuItem is about to be traversed

It does some magic to tie a stronger connection between toplevel menuitems and submenus, which later will be used.

GtkSeparatorMenuItem(toplevel, gobj)
GtkTearoffMenuItem(toplevel, gobj)
GtkToolButton(toplevel, item)[source]
GtkWidget(toplevel, widget)[source]

Called when a GtkWidget is about to be traversed

ignore(toplevel, gobj)[source]
parse_one(toplevel, gobj)[source]
register_event_handler()[source]

main Module

Kiwi UI Test: command line interface

kiwi.ui.test.main.main(args)[source]

recorder Module

User interface event recorder and serializer.

This module provides an interface for creating, listening to and saving events. It uses the gobject introspection base class kiwi.ui.test.common.WidgetIntrospecter to gather widgets, windows and other objects.

The user interfaces are saved in a format so they can easily be played back by simply executing the script through a standard python interpreter.

class kiwi.ui.test.recorder.ButtonClickedEvent(object, name, args)[source]

Bases: kiwi.ui.test.recorder.SignalEvent

This event represents a button click. Note that this will also work for GtkToggleButton, GtkRadioButton and GtkCheckButton.

object_type

alias of Button

serialize()[source]
signal_name = 'clicked'
class kiwi.ui.test.recorder.EntryActivateEvent(object, name, args)[source]

Bases: kiwi.ui.test.recorder.SignalEvent

This event represents an activate event for a GtkEntry, eg when the user presses enter in a GtkEntry.

object_type

alias of Entry

serialize()[source]
signal_name = 'activate'
class kiwi.ui.test.recorder.EntrySetTextEvent(object, name, args)[source]

Bases: kiwi.ui.test.recorder.SignalEvent

This event represents a content modification of a GtkEntry. When the user deletes, clears, adds, modifies the text this event will be created.

object_type

alias of Entry

serialize()[source]
signal_name = 'notify::text'
class kiwi.ui.test.recorder.Event(object, name=None)[source]

Bases: object

Event is a base class for all events. An event represent a user change of an interactive widget. :cvar object_type: subclass for type, Recorder uses this to

automatically attach events to objects when they appear
get_toplevel(widget)[source]

This fetches the toplevel widget for a specific object, by default it assumes it’s a wiget subclass and calls get_toplevel() for the widget

Override this in a subclass.

object_type = None
serialize()[source]

Serialize the widget, write the code here which is used to reproduce the event, for a button which is clicked the implementation looks like this:

>>> def serialize(self):
>>> ... return '%s.clicked' % self.name
Returns:string to reproduce event

Override this in a subclass.

class kiwi.ui.test.recorder.ImageMenuItemButtonReleaseEvent(object, name, args)[source]

Bases: kiwi.ui.test.recorder.SignalEvent

This event represents a click on a normal menu entry It’s sort of a hack to use button-press-event, instea of listening to activate, but we’ll get the active callback after the user specified callbacks are called, at which point it is already too late.

get_toplevel(widget)[source]
object_type

alias of ImageMenuItem

serialize()[source]
signal_name = 'button-release-event'
class kiwi.ui.test.recorder.MenuItemActivateEvent(object, name, args)[source]

Bases: kiwi.ui.test.recorder.SignalEvent

This event represents a user click on a menu item. It could be a toplevel or a normal entry in a submenu.

object_type

alias of MenuItem

serialize()[source]
signal_name = 'activate'
class kiwi.ui.test.recorder.ObjectListDoubleClick(objectlist, name, args)[source]

Bases: kiwi.ui.test.recorder.SignalEvent

This event represents a double click on a row in objectlist

classmethod connect(orig, signal_name, cb)[source]
object_type

alias of ObjectList

serialize()[source]
signal_name = 'button-press-event'
class kiwi.ui.test.recorder.ObjectListSelectionChanged(objectlist, name, args)[source]

Bases: kiwi.ui.test.recorder.SignalEvent

This event represents a selection change on a kiwi.ui.objectlist.ObjectList, eg when the user selects or unselects a row. It is actually tied to the signal changed on GtkTreeSelection object.

classmethod connect(orig, signal_name, cb)[source]
get_toplevel(widget)[source]
object_type

alias of ObjectList

serialize()[source]
signal_name = 'changed'
class kiwi.ui.test.recorder.Recorder(filename)[source]

Bases: kiwi.ui.test.common.WidgetIntrospecter

Recorder takes care of attaching events to widgets, when the appear, and creates the events when the user is interacting with some widgets. When the tracked program is closed the events are serialized into a script which can be played back with help of kiwi.ui.test.player.Player.

execute(args)[source]
parse_one(toplevel, gobj)[source]
save()[source]

Collect events and serialize them into a script and save the script. This should be called when the tracked program has finished executing.

window_removed(wi, window, name)[source]
class kiwi.ui.test.recorder.SignalEvent(object, name, args)[source]

Bases: kiwi.ui.test.recorder.Event

A SignalEvent is an Event which is tied to a GObject signal, Recorder uses this to automatically attach itself to a signal at which point this object will be instantiated.

Variables:signal_name – signal to listen to
classmethod connect(object, signal_name, cb)[source]

Calls connect on I{object} for signal I{signal_name}.

Parameters:
  • object – object to connect on
  • signal_name – signal name to listen to
  • cb – callback
signal_name = None
exception kiwi.ui.test.recorder.SkipEvent[source]

Bases: exceptions.Exception

class kiwi.ui.test.recorder.ToolButtonReleaseEvent(object, name, args)[source]

Bases: kiwi.ui.test.recorder.SignalEvent

This event represents a click on a normal toolbar button Hackish, see ImageMenuItemButtonReleaseEvent for more details.

object_type

alias of Button

serialize()[source]
signal_name = 'button-release-event'
class kiwi.ui.test.recorder.WindowDeleteEvent(object, name=None)[source]

Bases: kiwi.ui.test.recorder.Event

This event represents a user click on the close button in the window manager.

kiwi.ui.test.recorder.get_event_types()[source]

Returns the collection of event types. :returns: the event types.

kiwi.ui.test.recorder.register_event_type(event_type)[source]

Add an event type to a list of event types.

Parameters:event_type – a Event subclass

runner Module

Runner - executes recorded scripts

class kiwi.ui.test.runner.MagicWindowWrapper(window, ns)[source]

Bases: object

delete()[source]
exception kiwi.ui.test.runner.MissingWidget[source]

Bases: exceptions.KeyError

exception kiwi.ui.test.runner.NotReadyYet[source]

Bases: exceptions.Exception

class kiwi.ui.test.runner.Runner(filename)[source]

Bases: object

Create a new Runner object. :ivar parser:

error()[source]
quit()[source]
sleep(duration)[source]
start()[source]
waitclose(window_name)[source]

Wait to close an window. :param window_name:

waitopen(window_name)[source]

Wait to open an window. :param window_name:

kiwi.ui.test.runner.play_file(script, filename=None, args=None)[source]

Run an script. :param script: :param filename: :param args:

Table Of Contents

Previous topic

ui Package

Next topic

widgets Package

This Page