require_relative 'test_helper' class ArjdbcTest < Minitest::Test def setup generate_app bundle: [ [:activerecord, '<4.2.0'], :'activerecord-jdbc-adapter', :sqldroid, ] end def teardown cleanup_app end def test_arjdbc Dir.chdir APP_DIR do File.open('src/ruboto_test_app_activity.rb', 'w') { |f| f << < 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 def onResume super db_file = "\#{application_context.files_dir}/sqlite" with_large_stack do ActiveRecord::Base.establish_connection( :adapter => 'sqlite3', :driver => 'org.sqldroid.SQLDroidDriver', :database => db_file, ) begin ActiveRecord::Base.connection.execute "DROP TABLE companions" rescue ActiveRecord::StatementInvalid # Table does not exist end ActiveRecord::Base.connection.execute "CREATE TABLE companions (id INTEGER PRIMARY KEY, name VARCHAR(20) NOT NULL)" ActiveRecord::Base.connection.execute "INSERT INTO companions VALUES (1, 'Frodo')" ActiveRecord::Base.connection.execute "INSERT INTO companions VALUES (2, 'Samwise')" ActiveRecord::Base.connection.execute "INSERT INTO companions VALUES (3, 'Meriadoc')" ActiveRecord::Base.connection.execute "INSERT INTO companions VALUES (4, 'Peregrin')" ActiveRecord::Base.connection.execute "INSERT INTO companions VALUES (5, 'Gandalf')" ActiveRecord::Base.connection.execute "INSERT INTO companions VALUES (6, 'Legolas')" ActiveRecord::Base.connection.execute "INSERT INTO companions VALUES (7, 'Gimli')" ActiveRecord::Base.connection.execute "INSERT INTO companions VALUES (8, 'Aragorn')" ActiveRecord::Base.connection.execute "INSERT INTO companions VALUES (9, 'Boromir')" companions = ActiveRecord::Base.connection.execute "SELECT name FROM companions" run_on_ui_thread { @adapter.add_all companions } end end end EOF File.open('test/src/ruboto_test_app_activity_test.rb', 'w') { |f| f << < 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 unless # FIXME(uwe): Weird total app crash when running these tests together # FIXME(uwe): Remove when we stop testing api level <= 15 # FIXME(uwe): or the stupid crash has been resolved RubotoTest::ANDROID_OS <= 15 || has_stupid_crash || # EMXIF # FIXME(uwe): remove when we stop supporting JRuby 1.7.22 # https://github.com/jruby/jruby/issues/3401 JRUBY_JARS_VERSION == Gem::Version.new('1.7.22') # EMXIF end