Sha256: 6a3499c09a5a5101a654c309ec748ccb1789f28c741d9668cdb4dd9b984ff660

Contents?: true

Size: 1.99 KB

Versions: 2

Compression:

Stored size: 1.99 KB

Contents

require File.expand_path('test_helper', File.dirname(__FILE__))

class SqldroidTest < Minitest::Test
  def setup
    generate_app :bundle => :sqldroid
  end

  def teardown
    cleanup_app
  end

  def test_sqldroid
    Dir.chdir APP_DIR do
      File.open('src/ruboto_test_app_activity.rb', 'w'){|f| f << <<EOF}
require 'ruboto/widget'
require 'sqldroid'

ruboto_import_widgets :LinearLayout, :ListView, :TextView

class MyArrayAdapter < android.widget.ArrayAdapter
  def get_view(position, convert_view, parent)
    @inflater ||= context.getSystemService(Context::LAYOUT_INFLATER_SERVICE)
    row = convert_view ? convert_view : @inflater.inflate(mResource, nil)
    row.findViewById(mFieldId).text = get_item(position)
    row
  rescue Exception
    puts "Exception getting list item view: \#$!"
    puts $!.backtrace.join("\\n")
    convert_view
  end
end

class RubotoTestAppActivity
  def onCreate(bundle)
    super
    setTitle File.basename(__FILE__).chomp('_activity.rb').split('_').map { |s| "\#{s[0..0].upcase}\#{s[1..-1]}" }.join(' ')

    adapter = MyArrayAdapter.new(self, android.R.layout.simple_list_item_1 , android.R.id.text1, ['Record one', 'Record two'])

    self.content_view =
        linear_layout :orientation => LinearLayout::VERTICAL do
          @text_view_margins = text_view :text => 'What hath Matz wrought?', :id => 42
          @list_view = list_view :adapter => adapter, :id => 43
        end
  end
end
EOF

      File.open('test/src/ruboto_test_app_activity_test.rb', 'w'){|f| f << <<EOF}
activity Java::org.ruboto.test_app.RubotoTestAppActivity

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

test("activity starts") do |activity|
  assert true
end
EOF

    end

    run_app_tests
  end

end if RubotoTest::ANDROID_OS != 24 # FIXME: (uwe) Remove check when the proxy compile is fixed

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ruboto-1.6.1 test/sqldroid_test.rb
ruboto-1.6.0 test/sqldroid_test.rb