ruboto 0.11.0 → 0.12.0.rc.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. data/Gemfile.lock +1 -1
  2. data/README.md +7 -5
  3. data/Rakefile +3 -4
  4. data/assets/rakelib/ruboto.rake +138 -87
  5. data/assets/samples/sample_broadcast_receiver.rb +1 -1
  6. data/assets/src/InheritingActivity.java +0 -6
  7. data/assets/src/RubotoActivity.java +4 -1
  8. data/assets/src/RubotoBroadcastReceiver.java +2 -11
  9. data/assets/src/RubotoService.java +6 -52
  10. data/assets/src/org/ruboto/EntryPointActivity.java +276 -36
  11. data/assets/src/org/ruboto/JRubyAdapter.java +5 -152
  12. data/assets/src/org/ruboto/Script.java +1 -1
  13. data/assets/src/org/ruboto/ScriptLoader.java +26 -44
  14. data/assets/src/org/ruboto/test/InstrumentationTestRunner.java +4 -21
  15. data/bin/ruboto +0 -6
  16. data/lib/ruboto/commands/base.rb +58 -48
  17. data/lib/ruboto/sdk_locations.rb +23 -0
  18. data/lib/ruboto/sdk_versions.rb +1 -19
  19. data/lib/ruboto/util/build.rb +32 -32
  20. data/lib/ruboto/util/setup.rb +240 -0
  21. data/lib/ruboto/util/update.rb +12 -25
  22. data/lib/ruboto/util/verify.rb +7 -4
  23. data/lib/ruboto/util/xml_element.rb +62 -76
  24. data/lib/ruboto/version.rb +1 -1
  25. data/test/activity/image_button_activity_test.rb +2 -2
  26. data/test/activity/image_button_and_button_activity_test.rb +2 -2
  27. data/test/activity/json_activity.rb +1 -1
  28. data/test/activity/navigation_activity.rb +12 -12
  29. data/test/activity/navigation_activity_test.rb +7 -7
  30. data/test/activity/option_menu_activity.rb +0 -1
  31. data/test/activity/option_menu_activity_test.rb +2 -2
  32. data/test/activity/stack_activity_test.rb +10 -20
  33. data/test/app_test_methods.rb +0 -4
  34. data/test/broadcast_receiver_test.rb +16 -6
  35. data/test/minimal_app_test.rb +4 -12
  36. data/test/rake_test.rb +37 -23
  37. data/test/ruboto_gen_test.rb +12 -15
  38. data/test/sqldroid_test.rb +3 -6
  39. data/test/test_helper.rb +2 -0
  40. data/test/update_test_methods.rb +9 -9
  41. metadata +7 -11
@@ -41,19 +41,19 @@ test('button starts infile class activity', :ui => false) do |activity|
41
41
  button_activity_text 48, activity, 42, 'This is an infile activity.'
42
42
  end
43
43
 
44
- test("infile activity starts again", :ui => false) do |activity|
44
+ test('infile activity starts again', :ui => false) do |activity|
45
45
  button_activity_text 48, activity, 42, 'This is an infile activity.'
46
46
  end
47
47
 
48
- test("start ruby file activity", :ui => false) do |activity|
48
+ test('start ruby file activity', :ui => false) do |activity|
49
49
  button_activity_text 49, activity, 42, 'This is a Ruby file activity.'
50
50
  end
51
51
 
52
- test("start ruby file activity again", :ui => false) do |activity|
52
+ test('start ruby file activity again', :ui => false) do |activity|
53
53
  button_activity_text 49, activity, 42, 'This is a Ruby file activity.'
54
54
  end
55
55
 
56
- test("start ruboto activity without config", :ui => false) do |activity|
56
+ test('start ruboto activity without config', :ui => false) do |activity|
57
57
  a = start_activity_by_button activity, 50
58
58
  assert_equal 'Ruboto Test App', a.title
59
59
  end
@@ -75,8 +75,8 @@ def start_activity_by_button(activity, button_id, activity_class_name = 'org.rub
75
75
  current_activity
76
76
  end
77
77
 
78
- def button_activity_text button_id, activity, expected_text_id, expected_text_string,
79
- activity_class_name = 'org.ruboto.RubotoActivity'
78
+ def button_activity_text(button_id, activity, expected_text_id, expected_text_string,
79
+ activity_class_name = 'org.ruboto.RubotoActivity')
80
80
  current_activity = start_activity_by_button(activity, button_id, activity_class_name)
81
81
  start = Time.now
82
82
  loop do
@@ -91,7 +91,7 @@ ensure
91
91
  if current_activity
92
92
  finish_at = Time.now
93
93
  finished = false
94
- current_activity.run_on_ui_thread { current_activity.finish ; finished = true }
94
+ current_activity.run_on_ui_thread { current_activity.finish; finished = true }
95
95
  loop do
96
96
  break if finished || (Time.now - finish_at > 10)
97
97
  puts 'wait for finish'
@@ -17,7 +17,6 @@ class OptionMenuActivity
17
17
 
18
18
  def onCreateOptionsMenu(menu)
19
19
  mi = menu.add('Test')
20
- # mi.icon = $package.R::drawable::get_ruboto_core
21
20
  mi.setIcon($package.R::drawable::get_ruboto_core)
22
21
  mi.set_on_menu_item_click_listener do |menu_item|
23
22
  @text_view.text = 'What hath Matz wrought!'
@@ -11,7 +11,7 @@ setup do |activity|
11
11
  end
12
12
 
13
13
  test('option_menu changes text') do |activity|
14
- assert_equal "What hath Matz wrought?", @text_view.text
14
+ assert_equal 'What hath Matz wrought?', @text_view.text
15
15
  activity.window.performPanelIdentifierAction(android.view.Window::FEATURE_OPTIONS_PANEL, 0, 0)
16
- assert_equal "What hath Matz wrought!", @text_view.text
16
+ assert_equal 'What hath Matz wrought!', @text_view.text
17
17
  end
@@ -10,30 +10,20 @@ setup do |activity|
10
10
  assert @text_view
11
11
  end
12
12
 
13
- # ANDROID: 10, PLATFORM: 0.4.7, JRuby: 1.7.0.dev '28334966' expected, but got '28335067'
14
- # ANDROID: 15, PLATFORM: STANDALONE, JRuby: 1.7.0 '[28, 33, 51, 68]' expected, but got '[28, 33, 47, 64]'
15
- # ANDROID: 16, PLATFORM: 0.4.8.dev, JRuby: 1.7.0.preview2 '[29, 34, 47, 64]' expected, but got '[28, 33, 47, 64]'
13
+ # ANDROID: 10, PLATFORM: 0.5.3, JRuby: 1.7.3 '[28, 33, 46, 63]' expected, but got '[43, 48, 45, 62]'
14
+ # ANDROID: 10, PLATFORM: 0.5.4, JRuby: 1.7.3 '[28, 33, 45, 62]' expected, but got '[28, 33, 44, 61]'
15
+ # ANDROID: 15, PLATFORM: STANDALONE, JRuby: 1.7.0 '[28, 33, 51, 68]' expected, but got '[28, 33, 47, 64]'
16
16
  test('stack depth') do |activity|
17
17
  os_offset = {
18
18
  10 => [0, 0, -1, -1],
19
19
  13 => [1, 1, 0, 0],
20
20
  }[android.os.Build::VERSION::SDK_INT] || [0, 0, 0, 0]
21
- if org.ruboto.JRubyAdapter.uses_platform_apk?
22
- jruby_offset = {
23
- '0.4.7' => [0, 0, 4, 4],
24
- }[org.ruboto.JRubyAdapter.platform_version_name] || [0, 0, 0, 0]
25
- else # STANDALONE
26
- jruby_offset = {
27
- /^1\.6/ => [0, 0, 4, 4],
28
- // => [0, 0, 0, 0],
29
- }.find{|k,v| org.jruby.runtime.Constants::VERSION =~ k}[1]
30
- end
31
21
  version_message ="ANDROID: #{android.os.Build::VERSION::SDK_INT}, PLATFORM: #{org.ruboto.JRubyAdapter.uses_platform_apk ? org.ruboto.JRubyAdapter.platform_version_name : 'STANDALONE'}, JRuby: #{org.jruby.runtime.Constants::VERSION}"
32
- assert_equal [28 + os_offset[0] + jruby_offset[0],
33
- 33 + os_offset[1] + jruby_offset[1],
34
- 47 + os_offset[2] + jruby_offset[2],
35
- 64 + os_offset[3] + jruby_offset[3]], [activity.find_view_by_id(42).text.to_i,
36
- activity.find_view_by_id(43).text.to_i,
37
- activity.find_view_by_id(44).text.to_i,
38
- activity.find_view_by_id(45).text.to_i], version_message
22
+ assert_equal [28 + os_offset[0],
23
+ 33 + os_offset[1],
24
+ 45 + os_offset[2],
25
+ 62 + os_offset[3]], [activity.find_view_by_id(42).text.to_i,
26
+ activity.find_view_by_id(43).text.to_i,
27
+ activity.find_view_by_id(44).text.to_i,
28
+ activity.find_view_by_id(45).text.to_i], version_message
39
29
  end
@@ -37,10 +37,6 @@ module AppTestMethods
37
37
 
38
38
  def run_activity_tests(activity_dir)
39
39
  Dir[File.expand_path("#{activity_dir}/*", File.dirname(__FILE__))].each do |file|
40
- # FIXME(uwe): Remove when we stop testing JRuby < 1.7.0.rc1
41
- next if file =~ /subclass/ && (RUBOTO_PLATFORM == 'CURRENT' || JRUBY_JARS_VERSION < Gem::Version.new('1.7.1.dev'))
42
- # EMXIF
43
-
44
40
  # FIXME(uwe): Remove when we include jopenssl and bouncycastle
45
41
  next if file =~ /ssl/
46
42
  # EMXIF
@@ -1,4 +1,4 @@
1
- require File.expand_path("test_helper", File.dirname(__FILE__))
1
+ require File.expand_path('test_helper', File.dirname(__FILE__))
2
2
  require 'fileutils'
3
3
 
4
4
  class BroadcastReceiverTest < Test::Unit::TestCase
@@ -38,6 +38,15 @@ class BroadcastReceiverTest < Test::Unit::TestCase
38
38
  end
39
39
  EOF
40
40
 
41
+ assert activity_content.sub!(/^ private$/m, <<EOF)
42
+ def onDestroy
43
+ super
44
+ unregisterReceiver(@receiver)
45
+ end
46
+
47
+ private
48
+ EOF
49
+
41
50
  assert activity_content.sub!(/ def butterfly\n.*? end\n/m, <<EOF)
42
51
  def butterfly
43
52
  intent = android.content.Intent.new
@@ -45,6 +54,7 @@ EOF
45
54
  send_broadcast(intent)
46
55
  end
47
56
  EOF
57
+
48
58
  File.open(activity_filename, 'w') { |f| f << activity_content }
49
59
 
50
60
  system "#{RUBOTO_CMD} gen class BroadcastReceiver --name ClickReceiver"
@@ -54,13 +64,13 @@ EOF
54
64
 
55
65
  assert receiver_content.sub!(/ def onReceive\(context, intent\)\n.*?^ end\n/m, <<EOF)
56
66
  def onReceive(context, intent)
57
- Log.d "RUBOTO TEST", "Changing UI text"
67
+ Log.d 'RUBOTO TEST', 'Changing UI text'
58
68
  context.run_on_ui_thread{$broadcast_test_activity.find_view_by_id(42).text = '#{message}'}
59
- Log.d "RUBOTO TEST", "UI text changed OK!"
69
+ Log.d 'RUBOTO TEST', 'UI text changed OK!'
60
70
  rescue Exception
61
- Log.e "RUBOTO TEST", "Exception changing UI text: \#{$!.message}"
62
- Log.e "RUBOTO TEST", $!.message
63
- Log.e "RUBOTO TEST", $!.backtrace.join("\\n")
71
+ Log.e 'RUBOTO TEST', "Exception changing UI text: \#{$!.message}"
72
+ Log.e 'RUBOTO TEST', $!.message
73
+ Log.e 'RUBOTO TEST', $!.backtrace.join("\\n")
64
74
  end
65
75
  EOF
66
76
  File.open(receiver_filename, 'w') { |f| f << receiver_content }
@@ -12,21 +12,15 @@ if RubotoTest::RUBOTO_PLATFORM == 'STANDALONE'
12
12
  cleanup_app
13
13
  end
14
14
 
15
- # APK was 3.5MB. JRuby: 1.6.7, ANDROID_TARGET: 15
16
- # APK was 3.3MB. JRuby: 1.6.7.2, ANDROID_TARGET: 10
17
15
  # APK was 4.7MB. JRuby: 1.7.0, ANDROID_TARGET: 15
18
16
  # APK was 4.5MB. JRuby: 1.7.2, ANDROID_TARGET: 10
19
17
  # APK was 4.5MB. JRuby: 1.7.2, ANDROID_TARGET: 15
20
18
  # APK was 4.3MB. JRuby: 1.7.3, ANDROID_TARGET: 10
21
19
  # APK was 4.2MB. JRuby: 1.7.3, ANDROID_TARGET: 15
22
20
  # APK was 4.4MB. JRuby: 1.7.4.dev, ANDROID_TARGET: 10
23
-
24
21
  def test_minimal_apk_is_within_limits
25
22
  apk_size = BigDecimal(File.size("#{APP_DIR}/bin/RubotoTestApp-debug.apk").to_s) / (1024 * 1024)
26
23
  upper_limit = {
27
- '1.6.7' => 3.5,
28
- '1.6.7.2' => 3.5,
29
- '1.6.8' => 3.5,
30
24
  '1.7.0' => ANDROID_TARGET < 15 ? 4.7 : 4.9,
31
25
  '1.7.1' => ANDROID_TARGET < 15 ? 4.7 : 4.9,
32
26
  '1.7.2' => ANDROID_TARGET < 15 ? 4.6 : 4.9,
@@ -42,26 +36,24 @@ if RubotoTest::RUBOTO_PLATFORM == 'STANDALONE'
42
36
  run_app_tests
43
37
  end
44
38
 
45
- # APK was 3.5MB. JRuby: 1.6.7, ANDROID_TARGET: 15.
46
- # APK was 3.3MB. JRuby: 1.6.7.2, ANDROID_TARGET: 10.
47
39
  # APK was 4.7MB. JRuby: 1.7.0, ANDROID_TARGET: 15.
48
40
  # APK was 4.5MB. JRuby: 1.7.2, ANDROID_TARGET: 10.
49
41
  # APK was 4.5MB. JRuby: 1.7.2, ANDROID_TARGET: 15.
42
+ # APK was 4.5MB. JRuby: 1.7.3, ANDROID_TARGET: 10
50
43
  # APK was 4.6MB. JRuby: 1.7.3.dev, ANDROID_TARGET: 10.
51
44
  # APK was 4.5MB. JRuby: 1.7.3.dev, ANDROID_TARGET: 15.
45
+ # APK was 5.0MB. JRuby: 1.7.4.dev, ANDROID_TARGET: 10
52
46
  # FIXME(uwe): Remove when we remove the exclude feature
53
47
  def test_minimal_apk_with_excludes_is_less_than_5_mb
54
48
  generate_app :excluded_stdlibs => %w{ant cgi digest dl drb ffi irb net optparse racc rbconfig rdoc rexml rinda rss
55
49
  rubygems runit shell soap test uri webrick win32 wsdl xmlrpc xsd ../1.9}
56
50
  apk_size = BigDecimal(File.size("#{APP_DIR}/bin/RubotoTestApp-debug.apk").to_s) / (1024 * 1024)
57
51
  upper_limit = {
58
- '1.6.7' => 3.5,
59
- '1.6.7.2' => 3.5,
60
- '1.6.8' => 3.5,
61
52
  '1.7.0' => ANDROID_TARGET < 15 ? 4.7 : 4.9,
62
53
  '1.7.1' => ANDROID_TARGET < 15 ? 4.7 : 4.9,
63
54
  '1.7.2' => ANDROID_TARGET < 15 ? 4.6 : 4.9,
64
- }[JRUBY_JARS_VERSION.to_s] || 4.7
55
+ '1.7.3' => ANDROID_TARGET < 15 ? 4.6 : 4.9,
56
+ }[JRUBY_JARS_VERSION.to_s] || 5.0
65
57
  lower_limit = upper_limit * 0.9
66
58
  version_message ="JRuby: #{JRUBY_JARS_VERSION}, ANDROID_TARGET: #{ANDROID_TARGET}"
67
59
  assert apk_size <= upper_limit, "APK was larger than #{'%.1f' % upper_limit}MB: #{'%.1f' % apk_size.ceil(1)}MB. #{version_message}"
data/test/rake_test.rb CHANGED
@@ -9,32 +9,27 @@ class RakeTest < Test::Unit::TestCase
9
9
  cleanup_app
10
10
  end
11
11
 
12
- # FIXME(uwe): Remove condition when we stop supporting android-7
13
- if ANDROID_OS == 7
14
- puts 'Skipping sdcard test since files on sdcard are not removed on android-7 on app uninstall'
15
- else
16
- def test_that_update_scripts_task_copies_files_to_sdcard_and_are_read_by_activity
17
- Dir.chdir APP_DIR do
18
- activity_filename = 'src/ruboto_test_app_activity.rb'
19
- s = File.read(activity_filename)
20
- s.gsub!(/What hath Matz wrought\?/, 'This text was changed by script!')
21
- File.open(activity_filename, 'w') { |f| f << s }
12
+ def test_that_update_scripts_task_copies_files_to_sdcard_and_are_read_by_activity
13
+ Dir.chdir APP_DIR do
14
+ activity_filename = 'src/ruboto_test_app_activity.rb'
15
+ s = File.read(activity_filename)
16
+ s.gsub!(/What hath Matz wrought\?/, 'This text was changed by script!')
17
+ File.open(activity_filename, 'w') { |f| f << s }
22
18
 
23
- test_filename = 'test/src/ruboto_test_app_activity_test.rb'
24
- s2 = File.read(test_filename)
25
- s2.gsub!(/What hath Matz wrought\?/, 'This text was changed by script!')
26
- File.open(test_filename, 'w') { |f| f << s2 }
19
+ test_filename = 'test/src/ruboto_test_app_activity_test.rb'
20
+ s2 = File.read(test_filename)
21
+ s2.gsub!(/What hath Matz wrought\?/, 'This text was changed by script!')
22
+ File.open(test_filename, 'w') { |f| f << s2 }
27
23
 
28
- apk_timestamp = File.ctime("bin/#{APP_NAME}-debug.apk")
29
- end
30
- run_app_tests
24
+ apk_timestamp = File.ctime("bin/#{APP_NAME}-debug.apk")
25
+ end
26
+ run_app_tests
31
27
 
32
- # FIXME(uwe): Uncomment this when we can build the test package without building the main package
33
- # assert_equal apk_timestamp, File.ctime("bin/#{APP_NAME}-debug.apk"), 'APK should not have been rebuilt'
34
- # EMXIF
28
+ # FIXME(uwe): Uncomment this when we can build the test package without building the main package
29
+ # assert_equal apk_timestamp, File.ctime("bin/#{APP_NAME}-debug.apk"), 'APK should not have been rebuilt'
30
+ # EMXIF
35
31
 
36
- assert_match %r{^/sdcard/Android/data/#{PACKAGE}/files/scripts$}, `adb shell ls -d /sdcard/Android/data/#{PACKAGE}/files/scripts`.chomp
37
- end
32
+ assert_match %r{^/sdcard/Android/data/#{PACKAGE}/files/scripts$}, `adb shell ls -d /sdcard/Android/data/#{PACKAGE}/files/scripts`.chomp
38
33
  end
39
34
 
40
35
  def test_that_apk_is_built_if_only_one_ruby_source_file_has_changed
@@ -53,7 +48,7 @@ class RakeTest < Test::Unit::TestCase
53
48
  assert_equal "android:minSdkVersion='#{ANDROID_TARGET}'", manifest.slice(/android:minSdkVersion='\d+'/)
54
49
  assert_equal "android:targetSdkVersion='#{ANDROID_TARGET}'", manifest.slice(/android:targetSdkVersion='\d+'/)
55
50
  prop_file = File.read('project.properties')
56
- File.open('project.properties', 'w'){|f| f << prop_file.sub(/target=android-#{ANDROID_TARGET}/, 'target=android-6')}
51
+ File.open('project.properties', 'w') { |f| f << prop_file.sub(/target=android-#{ANDROID_TARGET}/, 'target=android-6') }
57
52
  system 'rake debug'
58
53
  manifest = File.read('AndroidManifest.xml')
59
54
  assert_equal "android:minSdkVersion='6'", manifest.slice(/android:minSdkVersion='\d+'/)
@@ -61,4 +56,23 @@ class RakeTest < Test::Unit::TestCase
61
56
  end
62
57
  end
63
58
 
59
+ def test_install_with_space_in_project_name
60
+ app_dir = "#{APP_DIR} with_space"
61
+ FileUtils.mv APP_DIR, app_dir
62
+ Dir.chdir app_dir do
63
+ system 'rake install'
64
+ raise "'rake install' exited with code #$?" unless $? == 0
65
+ end
66
+ ensure
67
+ FileUtils.rm_rf app_dir
68
+ end
69
+
70
+ def test_install_when_adb_server_is_stopped
71
+ Dir.chdir APP_DIR do
72
+ system 'adb kill-server'
73
+ system 'rake install'
74
+ raise "'rake install' exited with code #$?" unless $? == 0
75
+ end
76
+ end
77
+
64
78
  end
@@ -1,4 +1,4 @@
1
- require File.expand_path("test_helper", File.dirname(__FILE__))
1
+ require File.expand_path('test_helper', File.dirname(__FILE__))
2
2
  require 'bigdecimal'
3
3
  require 'test/app_test_methods'
4
4
 
@@ -49,16 +49,16 @@ class RubotoGenTest < Test::Unit::TestCase
49
49
  end
50
50
  end
51
51
 
52
- # APK was 56.4KB. PLATFORM: CURRENT, ANDROID_TARGET: 7
53
- # APK was 61.9KB. PLATFORM: CURRENT, ANDROID_TARGET: 10
54
- # APK was 67.2KB. PLATFORM: CURRENT, ANDROID_TARGET: 15
52
+ # APK was 57.1KB. PLATFORM: CURRENT, ANDROID_TARGET: 10
53
+ # APK was 58.3KB. PLATFORM: CURRENT, ANDROID_TARGET: 15
55
54
  # APK was 73.1KB. PLATFORM: CURRENT, ANDROID_TARGET: 16
56
- # APK was 5879.2KB. PLATFORM: STANDALONE, ANDROID_TARGET: 15, JRuby: 1.6.7
55
+ # APK was 57.1KB. PLATFORM: FROM_GEM, ANDROID_TARGET: 10
57
56
  # APK was 7380.0KB. PLATFORM: STANDALONE, ANDROID_TARGET: 15, JRuby: 1.7.0
58
57
  # APK was 7310.1KB. PLATFORM: STANDALONE, ANDROID_TARGET: 10, JRuby: 1.7.2
59
- # APK was 7337.0KB. PLATFORM: STANDALONE, ANDROID_TARGET: 15, JRuby: 1.7.2.
58
+ # APK was 7337.0KB. PLATFORM: STANDALONE, ANDROID_TARGET: 15, JRuby: 1.7.2
60
59
  # APK was 7317.4KB. PLATFORM: STANDALONE, ANDROID_TARGET: 15, JRuby: 1.7.3
61
60
  # APK was 7332.1KB. PLATFORM: STANDALONE, ANDROID_TARGET: 16, JRuby: 1.7.3
61
+ # APK was 8428.4KB. PLATFORM: STANDALONE, ANDROID_TARGET: 10, JRuby: 1.7.4.dev
62
62
  # APK was 7405.8KB. PLATFORM: STANDALONE, ANDROID_TARGET: 15, JRuby: 1.7.4.dev
63
63
  # APK was 7420.9KB. PLATFORM: STANDALONE, ANDROID_TARGET: 16, JRuby: 1.7.4.dev
64
64
  def test_new_apk_size_is_within_limits
@@ -67,19 +67,16 @@ class RubotoGenTest < Test::Unit::TestCase
67
67
  version << ", ANDROID_TARGET: #{ANDROID_TARGET}"
68
68
  if RUBOTO_PLATFORM == 'STANDALONE'
69
69
  upper_limit = {
70
- '1.6.7' => 5900.0,
71
- '1.6.8' => 5900.0,
72
70
  '1.7.0' => ANDROID_TARGET < 15 ? 7400.0 : 7600.0,
73
71
  '1.7.1' => ANDROID_TARGET < 15 ? 7400.0 : 7600.0,
74
72
  '1.7.2' => 7400.0,
75
73
  '1.7.3' => 7400.0,
76
- }[JRUBY_JARS_VERSION.to_s] || 7500.0
74
+ }[JRUBY_JARS_VERSION.to_s] || 8500.0
77
75
  version << ", JRuby: #{JRUBY_JARS_VERSION.to_s}"
78
76
  else
79
77
  upper_limit = {
80
- 7 => 62.0,
81
- 10 => 62.0,
82
- 15 => 63.0,
78
+ 10 => 58.0,
79
+ 15 => 59.0,
83
80
  16 => 74.0,
84
81
  }[ANDROID_TARGET] || 74.0
85
82
  end
@@ -109,7 +106,7 @@ class RubotoGenTest < Test::Unit::TestCase
109
106
 
110
107
  # FIXME(uwe): Workaround for Ruboto Issue #246
111
108
  java_source = File.read(java_source_file)
112
- File.open(java_source_file, 'w'){|f| f << java_source.gsub(/^(public class .*ArrayAdapter) (.*ArrayAdapter)/, '\1<T>\2<T>').gsub(/T.class/, 'Object.class')}
109
+ File.open(java_source_file, 'w'){|f| f << java_source.gsub(/^(public class .*ArrayAdapter) (.*ArrayAdapter)/, '\1<T> \2<T>').gsub(/T.class/, 'Object.class')}
113
110
  # EMXIF
114
111
 
115
112
  assert File.exists?('src/ruboto_array_adapter.rb')
@@ -267,8 +264,8 @@ EOF
267
264
  Dir.chdir APP_DIR do
268
265
  system "#{RUBOTO_CMD} gen jruby"
269
266
  assert_equal 0, $?.exitstatus
270
- assert_equal ["libs/jruby-core-#{JRUBY_JARS_VERSION.to_s.downcase}.jar"], Dir["libs/jruby-core-*.jar"].map(&:downcase)
271
- assert_equal ["libs/jruby-stdlib-#{JRUBY_JARS_VERSION.to_s.downcase}.jar"], Dir["libs/jruby-stdlib-*.jar"].map(&:downcase)
267
+ assert_equal %W(libs/jruby-core-#{JRUBY_JARS_VERSION.to_s.downcase}.jar), Dir['libs/jruby-core-*.jar'].map(&:downcase)
268
+ assert_equal %W(libs/jruby-stdlib-#{JRUBY_JARS_VERSION.to_s.downcase}.jar), Dir['libs/jruby-stdlib-*.jar'].map(&:downcase)
272
269
  end
273
270
  end
274
271
  end
@@ -1,9 +1,7 @@
1
- require File.expand_path("test_helper", File.dirname(__FILE__))
1
+ require File.expand_path('test_helper', File.dirname(__FILE__))
2
2
 
3
- # FIXME(uwe): Remove check when we stop supporting JRuby older than 1.7.0.rc1
4
3
  # FIXME(uwe): Remove check when we stop supporting Android < 4.0.3
5
- if RubotoTest::JRUBY_JARS_VERSION >= Gem::Version.new('1.7.0.rc1') &&
6
- (RubotoTest::ANDROID_OS >= 15 || RubotoTest::RUBOTO_PLATFORM != 'STANDALONE')
4
+ if RubotoTest::ANDROID_OS >= 15 || RubotoTest::RUBOTO_PLATFORM != 'STANDALONE'
7
5
 
8
6
  require 'bigdecimal'
9
7
  require 'test/app_test_methods'
@@ -28,14 +26,13 @@ ruboto_import_widgets :LinearLayout, :ListView, :TextView
28
26
 
29
27
  class MyArrayAdapter < android.widget.ArrayAdapter
30
28
  def get_view(position, convert_view, parent)
31
- puts "IN get_view!!!"
32
29
  @inflater ||= context.getSystemService(Context::LAYOUT_INFLATER_SERVICE)
33
30
  row = convert_view ? convert_view : @inflater.inflate(mResource, nil)
34
31
  row.findViewById(mFieldId).text = get_item(position)
35
32
  row
36
33
  rescue Exception
37
34
  puts "Exception getting list item view: \#$!"
38
- puts $!.backtrace.join("\n")
35
+ puts $!.backtrace.join("\\n")
39
36
  convert_view
40
37
  end
41
38
  end
data/test/test_helper.rb CHANGED
@@ -5,9 +5,11 @@ require 'rubygems'
5
5
  require 'fileutils'
6
6
  require 'yaml'
7
7
  require 'ruboto/sdk_versions'
8
+ require 'ruboto/sdk_locations'
8
9
 
9
10
  module RubotoTest
10
11
  include Ruboto::SdkVersions
12
+ include Ruboto::SdkLocations
11
13
 
12
14
  PROJECT_DIR = File.expand_path('..', File.dirname(__FILE__))
13
15
  $LOAD_PATH << PROJECT_DIR
@@ -1,4 +1,4 @@
1
- require File.expand_path("test_helper", File.dirname(__FILE__))
1
+ require File.expand_path('test_helper', File.dirname(__FILE__))
2
2
  require 'test/app_test_methods'
3
3
 
4
4
  module UpdateTestMethods
@@ -34,10 +34,10 @@ module UpdateTestMethods
34
34
  unless Gem::Version.new(@old_ruboto_version) <= Gem::Version.new('0.10.0.rc.0')
35
35
  def test_broadcast_receiver
36
36
  Dir.chdir APP_DIR do
37
- puts "Adding a broadcast receiver"
37
+ puts 'Adding a broadcast receiver'
38
38
  install_ruboto_gem @old_ruboto_version
39
39
  system "ruboto _#{@old_ruboto_version}_ gen class BroadcastReceiver --name DummyReceiver"
40
- fail "Creation of broadcast receiver failed" if $? != 0
40
+ fail 'Creation of broadcast receiver failed' if $? != 0
41
41
  assert File.exists? 'src/org/ruboto/test_app/DummyReceiver.java'
42
42
  assert File.exists? 'src/dummy_receiver.rb'
43
43
  test_file = 'test/src/dummy_receiver_test.rb'
@@ -49,10 +49,10 @@ module UpdateTestMethods
49
49
 
50
50
  def test_broadcast_receiver_updated_twice
51
51
  Dir.chdir APP_DIR do
52
- puts "Adding a broadcast receiver"
52
+ puts 'Adding a broadcast receiver'
53
53
  install_ruboto_gem @old_ruboto_version
54
54
  system "ruboto _#{@old_ruboto_version}_ gen class BroadcastReceiver --name DummyReceiver"
55
- fail "Creation of broadcast receiver failed" if $? != 0
55
+ fail 'Creation of broadcast receiver failed' if $? != 0
56
56
  assert File.exists? 'src/org/ruboto/test_app/DummyReceiver.java'
57
57
  assert File.exists? 'src/dummy_receiver.rb'
58
58
  test_file = 'test/src/dummy_receiver_test.rb'
@@ -66,10 +66,10 @@ module UpdateTestMethods
66
66
 
67
67
  def test_subclass_is_updated
68
68
  Dir.chdir APP_DIR do
69
- puts "Adding a subclass"
69
+ puts 'Adding a subclass'
70
70
  install_ruboto_gem @old_ruboto_version
71
71
  system "ruboto _#{@old_ruboto_version}_ gen subclass android.database.sqlite.SQLiteOpenHelper --name MyDatabaseHelper --method_base on"
72
- fail "Creation of subclass failed" if $? != 0
72
+ fail 'Creation of subclass failed' if $? != 0
73
73
  assert File.exists? 'src/org/ruboto/test_app/MyDatabaseHelper.java'
74
74
  if Gem::Version.new(@old_ruboto_version) >= Gem::Version.new('0.8.1.rc.0')
75
75
  assert File.exists? 'src/my_database_helper.rb'
@@ -86,10 +86,10 @@ module UpdateTestMethods
86
86
  private
87
87
 
88
88
  def assert_code(code)
89
- filename = "src/ruboto_test_app_activity.rb"
89
+ filename = 'src/ruboto_test_app_activity.rb'
90
90
  Dir.chdir APP_DIR do
91
91
  s = File.read(filename)
92
- raise "Code injection failed!" unless s.gsub!(/(require 'ruboto\/widget')/, "\\1\n#{code}")
92
+ raise 'Code injection failed!' unless s.gsub!(/(require 'ruboto\/widget')/, "\\1\n#{code}")
93
93
  File.open(filename, 'w') { |f| f << s }
94
94
  end
95
95
  end