Sha256: bae0bc548a440e4be5085419cad9b0e6eb79bd2b7158b07deed6a4b78a76ecd8

Contents?: true

Size: 1.29 KB

Versions: 5

Compression:

Stored size: 1.29 KB

Contents

require "spec_helper"

describe "Glimmer Listeners" do
  include Glimmer

	include_package 'org.eclipse.swt'
	include_package 'org.eclipse.swt.widgets'
	include_package 'org.eclipse.swt.layout'

  before do
    dsl :swt
  end

	after do
  	@target.display.dispose if @target.display
	end

  class Person
    attr_accessor :name, :age, :adult
  end

  it "tests text widget verify listener" do
    @target = shell {
      composite {
        @text = text {
          text "Howdy"
          on_verify_text do |verify_event|
            verify_event.doit = false if verify_event.text == "Hello"
          end
        }
      }
    }

    @text.widget.setText("Hi")
    expect(@text.widget.getText).to eq("Hi")

    @text.widget.setText("Hello")
    expect(@text.widget.getText).to eq("Hi")
  end

  def test_button_widget_selection_listener
    person = Person.new
    person.name = "Bruce Ting"

    @target = shell {
      composite {
        @button = button {
          on_widget_selected do
            person.name = "Bruce Lao"
          end
        }
      }
    }
    expect(person.name).to eq("Bruce Ting")
    @button.widget.setSelection(true)
    @button.widget.notifyListeners(SWT::Selection, nil)
    expect(person.name).to eq("Bruce Lao")
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
glimmer-0.1.11.SWT4.14 spec/lib/glimmer__listeners__spec.rb
glimmer-0.1.11.470 spec/lib/glimmer__listeners__spec.rb
glimmer-0.1.10.470 spec/lib/glimmer__listeners__spec.rb
glimmer-0.1.9.470 spec/lib/glimmer__listeners__spec.rb
glimmer-0.1.8.470 spec/lib/glimmer__listeners__spec.rb