Sha256: 9bb223a38374cd3501b9fa3f8387c1f8e779bdea71b9401b9c6dccde98be2143

Contents?: true

Size: 1.8 KB

Versions: 1

Compression:

Stored size: 1.8 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

include Autogui::Input
include Autogui::Logging

logger.level = Autogui::Logging::DEBUG

describe "FormMain" do
  before(:all) do
    @application = Myapp.new
    FileUtils.rm_rf(current_dir)
    #logger.debug "FormMain before(:all)" 
    #logger.debug "application:\n#{@application.inspect}\n" 
    #logger.debug "application.combined_text:\n #{@application.combined_text}\n" 
  end
  before(:each) do
    @application = Myapp.new unless @application.running?
    @application.should be_running
    @application.set_focus
  end
  after(:all) do
    if @application.running?
      @application.file_exit 
      # still running? force it to close
      @application.close(:wait_for_close => true)
      @application.should_not be_running
    end
  end
  after(:each) do
    if @application.running?
      keystroke(VK_N) if @application.message_dialog_confirm || @application.dialog_overwrite_confirm
      keystroke(VK_ESCAPE) if @application.error_dialog
    end
  end

  describe "after startup" do
    it "should have the title 'Myapp" do
      @application.main_window.title.should match(/MyApp/)
    end
  end

  describe "file exit (VK_MENU, VK_F, VK_X)" do
    it "should prompt and save with modified text" do
      type_in("anything")
      keystroke(VK_MENU, VK_F, VK_X) 
      @application.message_dialog_confirm.should_not be_nil
      @application.main_window.is_window?.should == true
      @application.should be_running
    end
    it "should not prompt to save with unmodified text" do
      keystroke(VK_MENU, VK_F, VK_X) 
      @application.message_dialog_confirm.should be_nil
      @application.main_window.is_window?.should == false
      @application.should_not be_running
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
win32-autogui-0.4.0 examples/skeleton/spec/myapp/form_main_spec.rb