Sha256: 8caa67b6b6999be55f0ca062f0ec6d6f26865ee6d8a246c838033021355f9150

Contents?: true

Size: 1.65 KB

Versions: 1

Compression:

Stored size: 1.65 KB

Contents

activity org.ruboto.test_app.MytestActivity

setup do |activity|
  start = Time.now
  loop do
    @text_view = activity.findViewById(42)
    break if @text_view || (Time.now - start > 60)
    sleep 1
  end
  assert @text_view
end

def button_activity_text button_id, activity, expected_text_id, expected_text_string
  monitor = add_monitor('org.ruboto.RubotoActivity', nil, false)
  begin
    activity.run_on_ui_thread { activity.find_view_by_id(button_id).perform_click }
    current_activity = wait_for_monitor_with_timeout(monitor, 5000)
  ensure
    removeMonitor(monitor)
  end
  puts "new activity: #{current_activity.inspect}"
  assert current_activity
   assert current_activity.is_a? Java::OrgRuboto::RubotoActivity
  start = Time.now
  loop do
    @text_view = current_activity.find_view_by_id(expected_text_id)
    break if @text_view || (Time.now - start > 10)
    puts 'wait for text'
    sleep 1
  end
  assert @text_view
  assert_equal expected_text_string, @text_view.text
  current_activity.run_on_ui_thread { current_activity.finish }
  # FIXME(uwe):  Replace sleep with proper monitor
  sleep 3
end

test("infile activity starts once", :ui => false) do |activity|
  button_activity_text 48, activity, 42, 'This is an infile activity.'
end

test("infile activity starts again", :ui => false) do |activity|
  button_activity_text 48, activity, 42, 'This is an infile activity.'
end

test("otherfile activity starts once", :ui => false) do |activity|
  button_activity_text 49, activity, 42, 'This is an otherfile activity.'
end

test("otherfile activity starts again", :ui => false) do |activity|
  button_activity_text 49, activity, 42, 'This is an otherfile activity.'
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruboto-0.10.0.rc.0 test/activity/mytest_activity_test.rb