Skip to content

Instantly share code, notes, and snippets.

@daveray
Created June 14, 2011 00:42
Show Gist options
  • Save daveray/1024097 to your computer and use it in GitHub Desktop.
Save daveray/1024097 to your computer and use it in GitHub Desktop.
Seesaw Tests
Namespaces
seesaw.test.event
#'seesaw.event/unappend-listener
can remove a listener
#'seesaw.event/listen
can install a mouse-clicked listener
returns a function that will remove the installed listener
can install two mouse-clicked listeners
can install a document listener
can register for a class of events
can register for multiple events
can register handlers on multiple targets
can register for window events on a frame
registers events on all buttons in a ButtonGroup
can register a ListSelectionListener on a JList with :selection key
can register a ListSelectionListener on a JTable with :selection key
can register a TreeSelectionListener on a JTree with :selection key
can register an ActionListener on a JComboBox with :selection key
can register an ItemListener on an ItemSelectable (like a checkbox) with :selection key
#'seesaw.event/reify-listener
for ComponentListener
instantiates a ComponentListener instance
makes an instance that does nothing when there's no handler
makes an instance that calls expected methods
for ChangeListener
instantiates a ChangeListener instance
makes an instance that does nothing when there's no handler
makes an instance that calls :state-changed
for ItemListener
instantiates an ItemListener instance
makes an instance that does nothing when there's no handler
makes an instance that calls :item-state-changed
for MouseListener
instantiates an MouseListener instance
makes an instance that does nothing when there's no handlers
makes an instance that calls expected methods
for MouseMotionListener
instantiates an MouseMotionListener instance
makes an instance that does nothing when there's no handlers
makes an instance that calls expected methods
#'seesaw.event/append-listener
inserts necessary keys and creates an initial list
can insert additional listeners
seesaw.test.timer
#'seesaw.timer/timer
Creates a timer for a handler function and calls it
Sets timer properties
seesaw.test.behave
#'seesaw.behave/when-focused-select-all
causes all text in a text field to be selected when it gains focus
seesaw.test.util
#'seesaw.util/apply-options
throws IllegalArgumentException if properties aren't event
throws IllegalArgumentException for an unknown property
#'seesaw.util/check-args
returns true if the condition is true
returns throws IllegalArgumentException if condition is false
#'seesaw.util/atom?
should return true for an atom
should return false for a non-atom
#'seesaw.util/to-insets
should throw an exception if it doesn't know what to do
should return its input if its already an Insets
should return uniform insets from a number
should return insets from a 4-element [top, left, bottom, right] vector
should return insets from a 2-element [top/bottom, left/right] vector
#'seesaw.util/cond-doto
only executes forms with true conditions
#'seesaw.util/to-dimension
should throw an exception if it doesn't know what to do
should return its input if its already a Dimension
should return a new Dimension if input is [width :by height]
#'seesaw.util/boolean?
returns true for true
returns true for false
returns false for nil
returns false for non-boolean
#'seesaw.util/to-seq
makes a non-seq into a single-element seq
makes a collection into a seq
#'seesaw.util/try-cast
returns its input if cast succeeds
returns nil if input is nil
returns nil if cast fails
#'seesaw.util/camelize
turns dashes into camel humps
#'seesaw.util/to-url
returns a URL if (str input) is a valid URL
returns nil if (str input is not a valid URL
seesaw.test.mig
#'seesaw.mig/mig-panel
should create a panel with a MigLayout
should set MigLayout layout constraints
#'seesaw.core/replace!
when called on a panel with a mid layout
replaces the given widget with a new widget and maintains constraints
seesaw.test.font
#'seesaw.font/default-font
retrieves a named from from the UIManager
#'seesaw.font/to-font
returns nil if its input is nil
returns its input if its a font
returns a new font if its input is a font spec
returns a new font if its input is a map
#'seesaw.font/font
can create a font from a font-spec
can create a bold font
can create a plain font
can create an italic font
can create a font with a specific size
can create a monospace font
can create a serif font
can create a sans-serif font
can create a font with a specific typeface
can derive a font from another
seesaw.test.table
#'seesaw.table/table-model
should create a table model
should create columns from a list of keys
should create columns from a list of maps and keys
should create rows from a list of maps
should create row from a map with extraneous fields without crashing
should create rows from a list of vectors
makes column metadata available through (.getValueAt model -1 -1)
returns false for isCellEditable
#'seesaw.table/column-count
retrievies number of columns in a table
#'seesaw.table/update-at!
updates a row with the same format as :rows option of (table-model)
updates a only the columns specified in a row
updates multiple rows with the same format as :rows option of (table-model)
#'seesaw.table/value-at
gets the value of a single row index as a map
gets the value of a row as a map (indexed by integers) if model was not
created with (table-model)
gets the value of a sequence of row indices as a list of maps
#'seesaw.table/clear!
removes all rows from a table
#'seesaw.table/insert-at!
inserts a row with the same format as :rows option of (table-model)
inserts multiple rows with the same format as :rows option of (table-model)
#'seesaw.table/remove-at!
removes a row
removes multiple rows, assuming that they are sorted!
#'seesaw.table/row-count
retrievies number of rows in a table
seesaw.test.cells
#'seesaw.cells/default-tree-cell-renderer
proxies a DefaultTreeCellRenderer which dispatches to a function
#'seesaw.cells/default-list-cell-renderer
proxies a DefaultListCellRenderer which dispatches to a function
#'seesaw.cells/to-cell-renderer
throws an exception if it can't make a renderer for a component
creates a tree cell renderer for a JTree
creates a list cell renderer for a JList
creates a list cell renderer for a JComboBox
seesaw.test.core
#'seesaw.core/form-panel
should create a JPanel with a GridBagLayout
should add an item with grid bag constraints
#'seesaw.core/select
should throw an exception if selector is not a vector
when performing an #id query
should return a single widget
should return a single widget
#'seesaw.core/editor-pane
should create a JEditorPane
#'seesaw.core/horizontal-panel
should create a horizontal box of :items list
#'seesaw.core/to-root
should convert a widget to its parent applet
should convert a widget to its parent frame
should return nil for an un-parented widget
#'seesaw.core/assert-ui-thread
should throw an IllegalStateException if not called on the Swing UI thread
#'seesaw.core/border-panel
should create a BorderLayout with given h and v gaps
should create a BorderLayout using direction options
should create a BorderLayout using list of items with direction constraints
#'seesaw.core/hide!
hides a widget and returns it
#'seesaw.core/text
should throw IllegalArgumentException if argument is nil
should return the text of a single text widget argument
should return the text of a text Document argument
should return the text of a button argument
should return the text of a label argument
should return the text of a seq of widget arguments
should create a text field given a string argument
should create a text field by default
should create a text area when multi-line? is true
should default line wrapping to false
should enable line wrapping on words when :wrap-lines? is true
should set tab size with :tab-size
should set number of rows with :rows
should honor the editable property
#'seesaw.core/slider
should sync the value of the atom with the slider value, if slider value changed
should sync the value of the slider with the atom value, if atom value changed
for an arbitrary widget
should support the :font property
#'seesaw.core/replace!
when called on a panel with a generic layout (e.g. flow)
replaces the given widget with a new widget
when called on a panel with a border layout
replaces the given widget with a new widget and maintains constraints
#'seesaw.core/menubar
should create a JMenuBar
should create a JMenuBar with the given items
#'seesaw.core/add!
When called on a panel with a FlowLayout
adds a widget to the end of the panel
adds a widget to the end of the panel
When called on a panel with a BoxLayout
adds a widget to the end of the panel
When called on a panel with a BorderLayout
adds a widget at the given location
#'seesaw.core/listbox
should create a JList
should create a JList using a seq as its model
should set the list's cell renderer, if given
#'seesaw.core/dialog
should block until dialog is being disposed of
should not block
return-from-dialog
should return value passed to RETURN-FROM-DIALOG from clicking on cancel button
#'seesaw.core/to-frame
should be an alias for to-root
#'seesaw.core/checkbox
should create a JCheckBox
should honor the :selected property
#'seesaw.core/grid-panel
should default to 1 column
should set number of rows
should set the hgap and vgap
should add the given items to the panel
#'seesaw.core/with-password*
should call the handler with the password in a character array
should return the return value of the handler
should fill the password character array with zeroes after then handler has completed
#'seesaw.core/move!
should move the widget to the back of the z order
should move the widget to the front of the z order
should set the absolute location of a widget with a vector
should set the absolute location of a widget with a vector, where :* means to keep the old value
should set the absolute location of a widget with a Point
should set the absolute location of a widget with the upper left corner of a Rectangle
should set the relative location of a widget with a vector
should set the relative location of a widget with a Point
#'seesaw.core/paintable
creates a paintable javax.swing.JPanel for (paintable flow-panel :paint nil)
creates a paintable javax.swing.JLabel for (paintable label :paint nil)
creates a paintable javax.swing.JButton for (paintable button :paint nil)
creates a paintable javax.swing.JToggleButton for (paintable toggle :paint nil)
creates a paintable javax.swing.JCheckBox for (paintable checkbox :paint nil)
creates a paintable javax.swing.JRadioButton for (paintable radio :paint nil)
creates a paintable javax.swing.JTextField for (paintable text :paint nil)
creates a paintable javax.swing.JPasswordField for (paintable password :paint nil)
creates a paintable javax.swing.JEditorPane for (paintable editor-pane :paint nil)
creates a paintable javax.swing.JList for (paintable listbox :paint nil)
creates a paintable javax.swing.JTable for (paintable table :paint nil)
creates a paintable javax.swing.JTree for (paintable tree :paint nil)
creates a paintable javax.swing.JComboBox for (paintable combobox :paint nil)
creates a paintable javax.swing.JSeparator for (paintable separator :paint nil)
creates a paintable javax.swing.JMenu for (paintable menu :paint nil)
creates a paintable javax.swing.JPopupMenu for (paintable popup :paint nil)
creates a paintable javax.swing.JMenuBar for (paintable menubar :paint nil)
creates a paintable javax.swing.JToolBar for (paintable toolbar :paint nil)
creates a paintable javax.swing.JTabbedPane for (paintable tabbed-panel :paint nil)
creates a paintable javax.swing.JSlider for (paintable slider :paint nil)
creates a paintable javax.swing.JProgressBar for (paintable progress-bar :paint nil)
creates a paintable subclass given a class name
creates a label subclass given the label function and args.
creates a button subclass
#'seesaw.core/button
should create a JButton
should handle the :margin option with to-insets
should add the button to a button group specified with the :group option
should create a button from an action
#'seesaw.core/tree
should create a JTree
should set the tree's model from a TreeModel
#'seesaw.core/dispose!
should dispose of a JFrame
should dispose of a JDialog
#'seesaw.core/label
should create an empty label
should create a label with tooltip
should create a label with text when given a single argument
should create a label with text
should create a label with horizontal alignment
should create a label with horizontal text position
should create a label with vertical text position
should create a label with vertical alignment
#'seesaw.core/with-widget
throws an exception if the factory class does not create the expected type
throws an exception if the factory function does not create the expected type
throws an exception if the given instance is not the expected type
uses a function as a factory and applies a constructor function to the result
can handle a form with nested widget creation functions
uses a class literal as a factory and applies a constructor function to it
applies a constructor function to an existing widget instance
#'seesaw.core/popup
should create a JPopupMenu
should create a JPopupMenu with the given items
#'seesaw.core/id-for
returns nil if a widget doesn't have an id
cerces to a widget before getting the id
returns the correct id if a widget has an id
#'seesaw.core/remove!
removes widgets from a container
#'seesaw.core/to-widget
returns nil if input is nil
returns input if it's already a widget
returns input if it's a JFrame
does not create a new widget if create? param is false
returns a label for text input
returns a button if input is an Action
creates a separator for :separator
creates horizontal glue for :fill-h
creates vertical glue for :fill-v
creates a vertical strut for [:fill-v N]
creates a horizontal strut for [:fill-h N]
creates a rigid area for a Dimension
creates a rigid area for a [N :by N]
converts an event to its source
Applying default options
the :id option
does nothing when omitted
sets the component's name if given
throws IllegalStateException if the widget's id is already set
the :class option
does nothing when omitted
sets the class of the widget
sets the classes of a widget
the :focusable? option
makes a widget focusable
the :preferred-size option
set the component's preferred size using to-dimension
atom for option PreferredSize
should set the component's PreferredSize using an atom
should update the PreferredSize to value of atom
should update the atom to PreferredSize
the :minimum-size option
set the component's minimum size using to-dimension
atom for option MinimumSize
should set the component's MinimumSize using an atom
should update the MinimumSize to value of atom
should update the atom to MinimumSize
the :maximum-size option
set the component's maximum size using to-dimension
atom for option MaximumSize
should set the component's MaximumSize using an atom
should update the MaximumSize to value of atom
should update the atom to MaximumSize
the :size option
set the component's min, max, and preferred size using to-dimension
the :location option
sets the component's location with a two-element vector
sets the component's location with a two-element vector, where :* means keep the old value
sets the component's location with a java.awt.Point
sets the component's location with a java.awt.Rectangle
the :bounds option
sets the component's bounds with a [x y width height] vector
sets the component's bounds with a [x y width height] vector, where :* means keep the old value
sets the component's bounds to its preferred size if given :preferred, preserving x and y
sets the component's bounds with a java.awt.Dimension, preserving x and y
sets the component's bounds with a java.awt.Rectangle
the :cursor option
sets the widget's cursor when given a cursor
sets the widget's cursor when given a cursor type keyword
atom for option Foreground
should set the component's Foreground using an atom
should update the Foreground to value of atom
should update the atom to Foreground
atom for option Background
should set the component's Background using an atom
should update the Background to value of atom
should update the atom to Background
atom for option Font
should set the component's Font using an atom
should update the Font to value of atom
should update the atom to Font
atom for option ToolTipText
should set the component's ToolTipText using an atom
should update the ToolTipText to value of atom
should update the atom to ToolTipText
setting enabled option
does nothing when omitted
sets enabled when provided
sets enabled when provided a truthy value
sets enabled when provided a falsey value
setting visible? option
does nothing when omitted
sets visible when provided
sets visible when provided a truthy value
sets not visible when provided a falsey value
setting opaque? option
does nothing when omitted
sets opacity when provided
atom for option Opaque
should set the component's Opaque using an atom
should update the Opaque to value of atom
should update the atom to Opaque
the :model property
sets the model when provided
sets background using to-color when provided
sets opaque when background provided
sets foreground when provided
sets border when provided using to-border
#'seesaw.core/selection!
should set the selection of a button-group
#'seesaw.core/combobox
should create a JComboBox
the :editable? property
should create a non-editable JComboBox when false
should create an editable JComboBox when true
should set the combobox's cell renderer, if given
should create a JComboBox using a seq as its model
#'seesaw.core/to-document
returns nil if input is nil
returns input if it's already a document
returns the document of text component
#'seesaw.core/text!
should set the text of a text Document
#'seesaw.core/toolbar
should create a JToolBar with the given items
should set the floatable? property
should set the floatable property to false
should set the orientation property
can create a toolbar separator with the :separator keyword
#'seesaw.core/selection
should get the selection from a button-group
#'seesaw.core/show!
makes a widget visible and returns it
#'seesaw.core/vertical-panel
should create a vertical box of :items list
#'seesaw.core/width
returns the width of a widget
#'seesaw.core/menu
should create a JMenu
should create a JMenu with the given items
#'seesaw.core/xyz-panel
should create a JPanel
should create a JPanel with a nil layout
should add items
#'seesaw.core/config!
configures the properties given to it on a single target
configures the properties given to it on a multiple targets
configures a target with type-specific properties
can configure a frame
can configure a dialog
can configure an action
#'seesaw.core/progress-bar
should sync the value of the atom with the progress-bar value, if progress-bar value changed
should sync the value of the progress-bar with the atom value, if atom value changed
#'seesaw.core/frame
should create a frame with an id
should create a JFrame and set its title, width, and height
should set the frame's size with the :size option
should set the frame's default close operation
should create a JFrame and make is not resizable
should create a JFrame and set its menu bar
should create a JFrame and set its content pane
#'seesaw.core/button-group
should create a ButtonGroup
should create a button group with a list of buttons
#'seesaw.core/canvas
should create a subclass of JPanel with no layout manager
should call :before and :after functions given to the :paint property
should call a single function given to the :paint property
#'seesaw.core/flow-panel
should create a FlowLayout of :items list
should throw IllegalArgumentException if a nil item is given
#'seesaw.core/menu-item
should create a JMenuItem
should create a menu item with an accelerator key
should create a JMenuItem from an action
#'seesaw.core/scrollable
should create a JScrollPane
should create a scroll pane with horizontal policy
should create a scroll pane with vertical policy
should create a JScrollPane with options
#'seesaw.core/separator
should create a horizontal JSeparator by default
should create a horizontal JSeparator when :orientation is specified
should create a vertical JSeparator when :orientation is specified
#'seesaw.core/tabbed-panel
should create a JTabbedPane with desired tab placement and layout
should add tabs from the tabs property
#'seesaw.core/password
should create a JPasswordField
should set the initial text
should set the columns
should set the echo char with a char
#'seesaw.core/radio
should create a JRadioButton
should honor the :selected property
#'seesaw.core/table
should create a JTable
should fill viewport height by default
should set the table's model from a TableModel
should set the table's model using seesaw.table/table-model
#'seesaw.core/splitter
should create a JSplitPane with with two panes
should set the divider location to an absolute pixel location with an int
should set the divider location to a percentage location with a double (eventually)
should set the divider location to a percentage location with a rational (eventually)
#'seesaw.core/height
returns the height of a widget
#'seesaw.core/toggle
should create a JToggleButton
should honor the :selected property
#'seesaw.core/realize-grid-bag-constraints
should return a vector of widget/constraint pairs
#'seesaw.core/custom-dialog
argument passing
should create a dialog with an id
should create a JDialog and set its title, width, and height
should set the dialog's default close operation
should create a JDialog and make is not resizable
should create a JDialog that is modal
should create a JDialog that is not modal
should create a JDialog and set its menu bar
should create a JDialog and set its content pane
blocking
should block until dialog is being disposed of
should not block if :modal? is false
should return value passed to RETURN-FROM-DIALOG
seesaw.test.meta
#'seesaw.meta/put-meta!
when called on a JComponent
stores metadata in the component's client properties
when called on an Action
stores metadata in the actions property map
when called on Object
stores metadata somewhere, retrievable by get-meta
#'seesaw.meta/get-meta
when called on a JComponent
returns nil if the key is not found
when called on an Action
returns nil if the key is not found
when called on an arbitrary object
returns nil if the key is not found
seesaw.test.tree
#'seesaw.tree/simple-tree-model
should create a read-only tree model from branch? and children functions
should return the root
should return isLeaf
should return the child count
should return a child by index
should retrieve the index of a child
seesaw.test.graphics
#'seesaw.graphics/pie
creates an pie shape with corner, width, height and angle
#'seesaw.graphics/anti-alias
turns on anti-aliasing on a graphics object
#'seesaw.graphics/arc
creates an arc shape with corner, width, height and angle
#'seesaw.graphics/rounded-rect
creates a rounded rectangle shape with give corner, width and height and radii
creates a rounded rectangle shape with give corner, width and height and radius
#'seesaw.graphics/circle
creates a circle with center and radius
#'seesaw.graphics/stroke
creates a default stroke of width 1 with no args
creates a stroke with the given properties
#'seesaw.graphics/rect
creates a rectangle shape with give corner, width and height
creates a square with give corner, and side length
#'seesaw.graphics/chord
creates an chord shape with corner, width, height and angle
#'seesaw.graphics/draw
should call Draw/draw* with graphics, shape and style
should call Draw/draw* with graphics, and multiple shapes and styles
#'seesaw.graphics/to-stroke
throws IllegalArgumentException if it doesn't know what to do
returns nil for nil input
returns a stroke of a given width if input is a number
returns input if it's a stroke
#'seesaw.graphics/ellipse
creates an elliptical shape with give corner, width and height
creates a square with give corner, and side length
#'seesaw.graphics/line
creates a line shape with given end points
seesaw.test.pref
#'seesaw.pref/preference-atom
should return an atom with nil as its default value
should return an atom with the specified default value
should keep pref in sync with atom
seesaw.test.cursor
#'seesaw.cursor/cursor
creating a built-in cursor
should create a :default cursor
should create a :text cursor
should create a :ne-resize cursor
should create a :se-resize cursor
should create a :sw-resize cursor
should create a :hand cursor
should create a :move cursor
should create a :e-resize cursor
should create a :nw-resize cursor
should create a :w-resize cursor
should create a :s-resize cursor
should create a :crosshair cursor
should create a :wait cursor
should create a :n-resize cursor
should return its input if given a cursor
should create a custom cursor from an image with hotspot (0, 0)
should create a custom cursor from an image with an [x y] hotspot
should create a custom cursor from an icon with an [x y] hotspot
seesaw.test.bind
#'seesaw.bind/bind-atom-to-range-model
Updates an atom when the model changes
Updates the model when the atom changes
seesaw.test.action
#'seesaw.action/action
sets the name and tooltip
calls the handler when actionPerformed is called
does nothing when actionPerformed is called and no handler is installed
handles the :key option
handles the :enabled? option
handles the :selected? option
seesaw.test.keystroke
#'seesaw.keystroke/keystroke
creates a keystroke from a descriptor string
#'seesaw.keystroke/keystroke
returns nil for nil input
returns input if it's a KeyStroke
returns a keystroke for a string
substitute platform-specific menu modifier for "menu" modifier
returns a keystroke for a char
seesaw.test.color
#'seesaw.color/to-color
returns nil for nil input
returns its input if its a color
#'seesaw.color/get-rgba
returns vector [r g b a] as integers
#'seesaw.color/color
can create a color from rgb integers
can create a color from rgba integers
can create a color from a #-prefixed rgb hex string
can create a color from a #-prefixed rgb hex string and alpha
#'seesaw.color/default-color
retrieve a default color from the UIManager
seesaw.test.selector
#'seesaw.selector/select
should find a widget by type, loosely allowing for sub-classing
should find a widget by type, strictly
should find a widget by Java class name
should find a widget by class name
should find all descendants of a widget
should find direct children of a widget
should find a frame by #id and return it
should find a widget by #id and returns it
should find menu items by id in a frame's menubar
should select all of the components in a tree with :*
seesaw.test.selection
#'seesaw.selection/selection
when given an Action
returns nil when the action is not selected
returns a single-element seq with true if the action is selected and multi? is given
returns a single-element seq with true if the action is selected
when given an AbstractButton (e.g. toggle or checkbox)
returns nil when the button is not selected
returns a single-element seq with the text of the button if it's selected and multi? is true
when given a ButtonGroup
returns nil when no button is selected
returns the first selected button in the group
when given a ComboBox
returns nil when nothing is selected
returns a single-element seq with the selected value when multi? is true
when given a JTree
returns nil when the selection is empty
returns the selection as a seq of paths when it isn't empty
when given a JList
returns nil when the selection is empty
returns the selection when it isn't empty
when given a JSlider
returns the current value
when given a JTable
returns nil when no rows are selected
returns a seq of selected model row indices when selection is non-empty
#'seesaw.selection/selection!
when given an AbstractButton (e.g. toggle or checkbox) and an argument
deselects the button if the argument is nil
selects the button if the argument is truthy
when given a ButtonGroup and an argument
deselects the button if the argument is nil
selects a button if the argument is a button
when given a ComboBox and an argument
sets the selection to that argument
when given a JSlider and an argument
sets the slider value to that argument
when given a JTree and an argument
Clears the selection when the argument is nil
when given a JList and an argument
Clears the selection when the argument is nil
Selects the given *values* when argument is a non-empty seq
when given a JTable and an argument
Clears the row selection when the argument is nil
selects the given rows when argument is a non-empty seq of row indices
seesaw.test.invoke
#'seesaw.invoke/invoke-now
should execute code on the swing thread, wait, and return the result
seesaw.test.border
#'seesaw.border/to-border
returns input if it's already a border
creates an empty border with specified thickness for a number
returns a titled border using str if it doesn't know what to do
creates a compound border out of multiple args
creates a compound border out of a collection arg
#'seesaw.border/line-border
creates a black, one pixel border by default
creates a border with desired color (using to-color) and thickness
creates a matte border with specified sides and color
creates a matte border with specified sides, defaulting to 0
#'seesaw.border/compound-border
creates nested compound borders inner to outer
#'seesaw.border/empty-border
creates a 1 pixel border by default
creates a border with same thickness on all sides
creates a border with specified sides
creates a border with specified sides, defaulting to 0
Ran 513 test cases.
0 failures.
Done.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment