test/test_helper.rb in ruboto-1.3.0 vs test/test_helper.rb in ruboto-1.3.1

- old
+ new

@@ -15,11 +15,11 @@ include Ruboto::Util::Update PROJECT_DIR = File.expand_path('..', File.dirname(__FILE__)) $LOAD_PATH << PROJECT_DIR - unless File.writable?(ENV['GEM_HOME']) + unless ENV['GEM_HOME'] && File.writable?(ENV['GEM_HOME']) GEM_PATH = File.join PROJECT_DIR, 'tmp', 'gems' FileUtils.mkdir_p GEM_PATH ENV['GEM_HOME'] = GEM_PATH ENV['GEM_PATH'] = GEM_PATH ENV['PATH'] = "#{GEM_PATH}/bin:#{ENV['PATH']}" @@ -86,10 +86,19 @@ `gem query -i -n ^ruboto$ #{version_requirement}` system "gem install ruboto #{version_requirement} --no-ri --no-rdoc" unless $? == 0 raise "install of ruboto #{version} failed with return code #$?" unless $? == 0 end + # FIXME(uwe): Remove when stupid crash is resolved + def has_stupid_crash + require 'rbconfig' + ANDROID_OS <= 15 && + JRUBY_JARS_VERSION >= Gem::Version.new('1.7.19') && + RbConfig::CONFIG['host_os'].downcase.include?('linux') + end + # EMXIF + puts RUBY_DESCRIPTION ANDROID_OS = (ENV['ANDROID_OS'] || version_from_device).slice(/\d+/).to_i # FIXME(uwe): Remove when Android L has been released @@ -106,11 +115,11 @@ RUBOTO_PLATFORM = ENV['RUBOTO_PLATFORM'] || 'CURRENT' puts "RUBOTO_PLATFORM: #{RUBOTO_PLATFORM}" if RUBOTO_PLATFORM == 'CURRENT' - JRUBY_JARS_VERSION = Gem::Version.new('1.7.18') + JRUBY_JARS_VERSION = Gem::Version.new('1.7.19') elsif ENV['JRUBY_JARS_VERSION'] JRUBY_JARS_VERSION = Gem::Version.new(ENV['JRUBY_JARS_VERSION']) else # FIXME(uwe): Simplify when we stop supporting rubygems < 1.8.0 if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.8.0') @@ -242,13 +251,11 @@ end end end Dir.chdir APP_DIR do - File.write('AndroidManifest.xml', - File.read('AndroidManifest.xml').sub(%r{</manifest>}, - " <uses-permission android:name='android.permission.INTERNET'/>\n</manifest>")) + write_android_manifest File.write('res/layout/dummy_layout.xml', <<-EOF) <?xml version="1.0" encoding="utf-8"?> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/my_text" android:layout_width="wrap_content" android:layout_height="wrap_content" @@ -266,11 +273,11 @@ FileUtils.cp_r APP_DIR, template_dir, :preserve => true end end def update_app - system "#{RUBOTO_CMD} update app #{"--with-jruby #{JRUBY_JARS_VERSION}" if RUBOTO_PLATFORM == 'STANDALONE'}" + system "#{RUBOTO_CMD} update app -t #{ANDROID_TARGET} #{"--with-jruby #{JRUBY_JARS_VERSION}" if RUBOTO_PLATFORM == 'STANDALONE'}" assert_equal 0, $?, "update app failed with return code #$?" end def cleanup_app # FileUtils.rm_rf APP_DIR if File.exists? APP_DIR @@ -319,14 +326,28 @@ puts "Adding ruboto.yml:\n#{yml}" File.open('ruboto.yml', 'w') { |f| f << yml } end def write_gemfile(bundle) - gems = [*bundle].map{|g| g.is_a?(Symbol) ? g.to_s : g} + gems = [*bundle].map { |g| g.is_a?(Symbol) ? g.to_s : g } puts "Adding Gemfile.apk: #{gems.join(' ')}" File.open('Gemfile.apk', 'w') do |f| f << "source 'http://rubygems.org/'\n\n" gems.each { |g| f << "gem #{[*g].map { |gp| (gp.is_a?(Symbol) ? gp.to_s : gp).inspect }.join(', ')}\n" } end + end + + def write_project_properties(api_level) + puts "Write project.properties with api level #{api_level}" + properties_file = 'project.properties' + properties = File.read(properties_file) + properties.sub!(/^target=android-\d+/, "target=android-#{api_level}") + File.write(properties_file, properties) + end + + def write_android_manifest + File.write('AndroidManifest.xml', + File.read('AndroidManifest.xml').sub(%r{</manifest>}, + " <uses-permission android:name='android.permission.INTERNET'/>\n</manifest>")) end end