Sha256: f2d65afef481a023fc962713bf54fc318867f972d347ef2e7f47561aa085461d

Contents?: true

Size: 1.11 KB

Versions: 6

Compression:

Stored size: 1.11 KB

Contents

#---
# Excerpted from "Scripted GUI Testing With Ruby",
# published by The Pragmatic Bookshelf.
# Copyrights apply to this code. It may not be used to create training material, 
# courses, books, articles, and the like. Contact us if you are in doubt.
# We make no guarantees that this code is fit for any purpose. 
# Visit http://www.pragmaticprogrammer.com/titles/idgtr for more book information.
#---
require 'java'
require 'jemmy.jar'

include_class 'org.netbeans.jemmy.JemmyProperties'
include_class 'org.netbeans.jemmy.TestOut'

JemmyProperties.set_current_output TestOut.get_null_output

%w(Frame TextArea MenuBar Dialog Button).each do |o|
  include_class "org.netbeans.jemmy.operators.J#{o}Operator"
end


class JDialogOperator
  def click(title)
    b = JButtonOperator.new self, title.gsub('_', '') #(1)
    b.push
  end
end



module SwingGui
  def dialog(title, seconds=3)
    JemmyProperties.set_current_timeout \
      'DialogWaiter.WaitDialogTimeout', seconds * 1000
    
    begin
      d = JDialogOperator.new title
      yield d #(2)
      d.wait_closed
      
      true
    rescue NativeException
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
win_gui-0.1.6 book_code/simplify/swing_gui.rb
win_gui-0.1.4 book_code/simplify/swing_gui.rb
win_gui-0.1.3 book_code/simplify/swing_gui.rb
win_gui-0.1.2 book_code/simplify/swing_gui.rb
win_gui-0.1.1 book_code/simplify/swing_gui.rb
win_gui-0.1.0 book_code/simplify/swing_gui.rb