ruboto 0.15.0 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -1
- data/README.md +44 -43
- data/RELEASE_CANDICATE_DOC +10 -12
- data/RELEASE_DOC +69 -37
- data/Rakefile +47 -27
- data/assets/rakelib/ruboto.rake +69 -26
- data/assets/src/RubotoActivity.java +17 -4
- data/assets/src/RubotoService.java +18 -0
- data/assets/src/org/ruboto/EntryPointActivity.java +1 -1
- data/assets/src/org/ruboto/JRubyAdapter.java +3 -1
- data/assets/src/org/ruboto/ScriptLoader.java +27 -4
- data/assets/src/ruboto/activity.rb +4 -3
- data/assets/src/ruboto/activity/reload.rb +17 -12
- data/assets/src/ruboto/widget.rb +18 -18
- data/bin/elevate.exe +0 -0
- data/bin/elevate_32.exe +0 -0
- data/lib/java_class_gen/android_api.xml +1 -1
- data/lib/ruboto/commands/base.rb +3 -5
- data/lib/ruboto/util/build.rb +1 -1
- data/lib/ruboto/util/emulator.rb +31 -5
- data/lib/ruboto/util/setup.rb +183 -68
- data/lib/ruboto/util/update.rb +35 -42
- data/lib/ruboto/util/xml_element.rb +45 -33
- data/lib/ruboto/version.rb +1 -1
- data/test/activity/call_super_activity.rb +1 -1
- data/test/activity/dialog_fragment_activity.rb +37 -0
- data/test/activity/dialog_fragment_activity_test.rb +19 -0
- data/test/activity/image_button_activity.rb +2 -1
- data/test/activity/navigation_activity_test.rb +2 -1
- data/test/activity/no_on_create_activity.rb +17 -0
- data/test/activity/no_on_create_activity_test.rb +15 -0
- data/test/activity/spinner_activity.rb +51 -0
- data/test/activity/spinner_activity_test.rb +65 -0
- data/test/activity/stack_activity_test.rb +14 -7
- data/test/activity/startup_exception_activity.rb +7 -5
- data/test/activity/startup_exception_activity_test.rb +2 -2
- data/test/app_test_methods.rb +4 -0
- data/test/git_based_gem_test.rb +64 -0
- data/test/minimal_app_test.rb +12 -13
- data/test/rake_test.rb +1 -0
- data/test/ruboto_gen_test.rb +21 -15
- data/test/ruboto_update_test.rb +23 -6
- data/test/sqldroid_test.rb +0 -1
- data/test/test_helper.rb +37 -19
- metadata +25 -2
@@ -0,0 +1,65 @@
|
|
1
|
+
activity Java::org.ruboto.test_app.SpinnerActivity
|
2
|
+
|
3
|
+
class Java::AndroidWidget::ArrayAdapter
|
4
|
+
field_reader :mResource, :mDropDownResource, :mFieldId
|
5
|
+
end
|
6
|
+
|
7
|
+
setup do |activity|
|
8
|
+
start = Time.now
|
9
|
+
loop do
|
10
|
+
@text_view = activity.findViewById(69)
|
11
|
+
break if @text_view || (Time.now - start > 60)
|
12
|
+
sleep 1
|
13
|
+
end
|
14
|
+
assert @text_view
|
15
|
+
end
|
16
|
+
|
17
|
+
test('default', :ui => false) do |activity|
|
18
|
+
assert_spinner_selection(activity, 42, 'List Spinner')
|
19
|
+
end
|
20
|
+
|
21
|
+
test('plain', :ui => false) do |activity|
|
22
|
+
assert_spinner_selection(activity, 43, 'Plain Item')
|
23
|
+
end
|
24
|
+
|
25
|
+
test('adapter', :ui => false) do |activity|
|
26
|
+
assert_spinner_selection(activity, 44, 'Adapter Item')
|
27
|
+
end
|
28
|
+
|
29
|
+
test('list', :ui => false) do |activity|
|
30
|
+
assert_spinner_selection(activity, 45, 'List Item')
|
31
|
+
end
|
32
|
+
|
33
|
+
test('list spinner view resources') do |activity|
|
34
|
+
activity.run_on_ui_thread do
|
35
|
+
spinner = activity.findViewById(45)
|
36
|
+
assert_equal R::layout::simple_spinner_item, spinner.adapter.mResource
|
37
|
+
assert_equal R::layout::simple_spinner_item, spinner.adapter.mDropDownResource
|
38
|
+
assert_equal 0, spinner.adapter.mFieldId
|
39
|
+
|
40
|
+
spinner = activity.findViewById(46)
|
41
|
+
assert_equal R::layout::simple_spinner_dropdown_item, spinner.adapter.mResource
|
42
|
+
assert_equal R::layout::simple_spinner_dropdown_item, spinner.adapter.mDropDownResource
|
43
|
+
assert_equal 0, spinner.adapter.mFieldId
|
44
|
+
|
45
|
+
spinner = activity.findViewById(47)
|
46
|
+
assert_equal R::layout::simple_spinner_dropdown_item, spinner.adapter.mResource
|
47
|
+
assert_equal R::layout::simple_spinner_item, spinner.adapter.mDropDownResource
|
48
|
+
assert_equal 0, spinner.adapter.mFieldId
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def assert_spinner_selection(activity, spinner_id, expected_text)
|
53
|
+
activity.run_on_ui_thread do
|
54
|
+
activity.findViewById(spinner_id).setSelection(1, true)
|
55
|
+
end
|
56
|
+
start_time = Time.now
|
57
|
+
text = nil
|
58
|
+
loop do
|
59
|
+
activity.run_on_ui_thread { text = @text_view.text }
|
60
|
+
break if text == expected_text || (Time.now - start_time) > 4
|
61
|
+
sleep 0.1
|
62
|
+
end
|
63
|
+
activity.run_on_ui_thread { assert_equal expected_text, text }
|
64
|
+
end
|
65
|
+
|
@@ -12,18 +12,25 @@ end
|
|
12
12
|
|
13
13
|
# ANDROID: 10, PLATFORM: 0.5.3, JRuby: 1.7.3 '[28, 33, 46, 63]' expected, but got '[43, 48, 45, 62]'
|
14
14
|
# ANDROID: 10, PLATFORM: 0.5.4, JRuby: 1.7.3 '[28, 33, 45, 62]' expected, but got '[28, 33, 44, 61]'
|
15
|
+
# ANDROID: 16, PLATFORM: 0.6.0, JRuby: 9000.dev '[28, 33, 45, 62]' expected, but got '[28, 33, 45, 63]'
|
15
16
|
# ANDROID: 15, PLATFORM: STANDALONE, JRuby: 1.7.0 '[28, 33, 51, 68]' expected, but got '[28, 33, 47, 64]'
|
16
17
|
test('stack depth') do |activity|
|
17
18
|
os_offset = {
|
18
19
|
10 => [0, 0, -1, -1],
|
19
20
|
13 => [1, 1, 0, 0],
|
20
21
|
}[android.os.Build::VERSION::SDK_INT] || [0, 0, 0, 0]
|
22
|
+
jruby_offset = {
|
23
|
+
/^1\.7/ => [0, 0, 0, -1],
|
24
|
+
/^9000/ => [0, 0, 0, 0],
|
25
|
+
// => [0, 0, 0, 0],
|
26
|
+
}.find { |k, v| org.jruby.runtime.Constants::VERSION =~ k }[1]
|
21
27
|
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}"
|
22
|
-
assert_equal [28 + os_offset[0],
|
23
|
-
33 + os_offset[1],
|
24
|
-
45 + os_offset[2],
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
28
|
+
assert_equal [28 + os_offset[0] + jruby_offset[0],
|
29
|
+
33 + os_offset[1] + jruby_offset[1],
|
30
|
+
45 + os_offset[2] + jruby_offset[2],
|
31
|
+
63 + os_offset[3] + jruby_offset[3]], [
|
32
|
+
activity.find_view_by_id(42).text.to_i,
|
33
|
+
activity.find_view_by_id(43).text.to_i,
|
34
|
+
activity.find_view_by_id(44).text.to_i,
|
35
|
+
activity.find_view_by_id(45).text.to_i], version_message
|
29
36
|
end
|
@@ -5,17 +5,19 @@ ruboto_import_widgets :LinearLayout, :TextView
|
|
5
5
|
class StartupExceptionActivity
|
6
6
|
def onCreate(bundle)
|
7
7
|
super
|
8
|
-
setTitle File.basename(__FILE__).chomp('_activity.rb').split('_').
|
8
|
+
setTitle File.basename(__FILE__).chomp('_activity.rb').split('_').
|
9
|
+
map { |s| "#{s[0..0].upcase}#{s[1..-1]}" }.join(' ')
|
9
10
|
|
10
11
|
self.content_view =
|
11
|
-
linear_layout :orientation => :vertical, :gravity =>
|
12
|
-
@text_view = text_view :id => 42, :text => title, :text_size => 48.0,
|
12
|
+
linear_layout :orientation => :vertical, :gravity => :center do
|
13
|
+
@text_view = text_view :id => 42, :text => title, :text_size => 48.0,
|
14
|
+
:gravity => :center
|
13
15
|
end
|
14
16
|
intent = android.content.Intent.new
|
15
|
-
intent.setClassName($package_name, 'com.example.
|
17
|
+
intent.setClassName($package_name, 'com.example.UndeclaredActivity')
|
16
18
|
startActivity(intent)
|
17
19
|
rescue Exception
|
18
|
-
puts "
|
20
|
+
puts "Expected exception creating activity: #{$!}"
|
19
21
|
puts $!.backtrace.join("\n")
|
20
22
|
end
|
21
23
|
|
@@ -10,6 +10,6 @@ setup do |activity|
|
|
10
10
|
assert @text_view
|
11
11
|
end
|
12
12
|
|
13
|
-
test('
|
14
|
-
assert_equal 'Startup OK',
|
13
|
+
test('activity starts with caught exception') do |activity|
|
14
|
+
assert_equal 'Startup OK', @text_view.text.to_s
|
15
15
|
end
|
data/test/app_test_methods.rb
CHANGED
@@ -45,6 +45,10 @@ module AppTestMethods
|
|
45
45
|
next if file =~ /dir_and_file/ && (RUBOTO_PLATFORM == 'CURRENT' || JRUBY_JARS_VERSION < Gem::Version.new('1.7.4.dev'))
|
46
46
|
# EMXIF
|
47
47
|
|
48
|
+
# FIXME(uwe): Remove when we stop testing api level < 11
|
49
|
+
next if file =~ /fragment/ && ANDROID_OS < 11
|
50
|
+
# EMXIF
|
51
|
+
|
48
52
|
if file =~ /_test.rb$/
|
49
53
|
next unless file =~ /#{ENV['ACTIVITY_TEST_PATTERN']}/
|
50
54
|
snake_name = file.chomp('_test.rb')
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require File.expand_path('test_helper', File.dirname(__FILE__))
|
2
|
+
require 'bigdecimal'
|
3
|
+
require 'test/app_test_methods'
|
4
|
+
|
5
|
+
class GitBasedGemTest < Test::Unit::TestCase
|
6
|
+
def setup
|
7
|
+
generate_app
|
8
|
+
Dir.chdir APP_DIR do
|
9
|
+
File.open('Gemfile.apk', 'w') do |f|
|
10
|
+
f << "source 'http://rubygems.org/'\n\n"
|
11
|
+
f << "gem 'uri_shortener', :git => 'https://github.com/Nyangawa/UriShortener.git'"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def teardown
|
17
|
+
cleanup_app
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_uri_shortener
|
21
|
+
Dir.chdir APP_DIR do
|
22
|
+
File.open('src/ruboto_test_app_activity.rb', 'w') { |f| f << <<EOF }
|
23
|
+
require 'ruboto/widget'
|
24
|
+
require 'uri_shortener'
|
25
|
+
|
26
|
+
ruboto_import_widgets :LinearLayout, :ListView, :TextView
|
27
|
+
|
28
|
+
class RubotoTestAppActivity
|
29
|
+
def onCreate(bundle)
|
30
|
+
super
|
31
|
+
setTitle 'uri_shortener loaded OK!'
|
32
|
+
|
33
|
+
self.content_view =
|
34
|
+
linear_layout :orientation => :vertical, :gravity => :center do
|
35
|
+
text_view :id => 42, :text => title, :text_size => 48.0, :gravity => :center
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
EOF
|
40
|
+
|
41
|
+
File.open('test/src/ruboto_test_app_activity_test.rb', 'w') { |f| f << <<EOF }
|
42
|
+
activity Java::org.ruboto.test_app.RubotoTestAppActivity
|
43
|
+
|
44
|
+
setup do |activity|
|
45
|
+
start = Time.now
|
46
|
+
loop do
|
47
|
+
@text_view = activity.findViewById(42)
|
48
|
+
break if @text_view || (Time.now - start > 60)
|
49
|
+
sleep 1
|
50
|
+
end
|
51
|
+
assert @text_view
|
52
|
+
end
|
53
|
+
|
54
|
+
test("activity starts") do |activity|
|
55
|
+
assert_equal 'uri_shortener loaded OK!', @text_view.text.to_s
|
56
|
+
end
|
57
|
+
EOF
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
run_app_tests
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
data/test/minimal_app_test.rb
CHANGED
@@ -12,24 +12,23 @@ if RubotoTest::RUBOTO_PLATFORM == 'STANDALONE'
|
|
12
12
|
cleanup_app
|
13
13
|
end
|
14
14
|
|
15
|
-
# APK was 4.7MB. JRuby: 1.7.0, ANDROID_TARGET: 15
|
16
|
-
# APK was 4.5MB. JRuby: 1.7.2, ANDROID_TARGET: 10
|
17
|
-
# APK was 4.5MB. JRuby: 1.7.2, ANDROID_TARGET: 15
|
18
|
-
# APK was 4.3MB. JRuby: 1.7.3, ANDROID_TARGET: 10
|
19
|
-
# APK was 4.2MB. JRuby: 1.7.3, ANDROID_TARGET: 15
|
20
15
|
# APK was 4.4MB. JRuby: 1.7.4, ANDROID_TARGET: 10
|
21
|
-
# APK was 4.3MB. JRuby: 1.7.
|
22
|
-
# APK was 4.
|
23
|
-
# APK was 4.
|
16
|
+
# APK was 4.3MB. JRuby: 1.7.4, ANDROID_TARGET: 16
|
17
|
+
# APK was 4.3MB. JRuby: 1.7.5, ANDROID_TARGET: 10
|
18
|
+
# APK was 4.2MB. JRuby: 1.7.5, ANDROID_TARGET: 15
|
19
|
+
# APK was 4.3MB. JRuby: 1.7.5, ANDROID_TARGET: 16
|
20
|
+
# APK was 8.4MB. JRuby: 1.7.8, ANDROID_TARGET: 10
|
21
|
+
# APK was 4.3MB. JRuby: 1.7.8, ANDROID_TARGET: 16
|
22
|
+
# APK was 4.2MB. JRuby: 9000.dev, ANDROID_TARGET: 10
|
23
|
+
# APK was 4.2MB. JRuby: 9000.dev, ANDROID_TARGET: 15
|
24
|
+
# APK was 4.3MB. JRuby: 9000.dev, ANDROID_TARGET: 16
|
24
25
|
def test_minimal_apk_is_within_limits
|
25
26
|
apk_size = BigDecimal(File.size("#{APP_DIR}/bin/RubotoTestApp-debug.apk").to_s) / (1024 * 1024)
|
26
27
|
upper_limit = {
|
27
|
-
'1.7.0' => ANDROID_TARGET < 15 ? 4.7 : 4.9,
|
28
|
-
'1.7.1' => ANDROID_TARGET < 15 ? 4.7 : 4.9,
|
29
|
-
'1.7.2' => ANDROID_TARGET < 15 ? 4.6 : 4.9,
|
30
|
-
'1.7.3' => ANDROID_TARGET < 15 ? 4.3 : 4.4,
|
31
28
|
'1.7.4' => 4.4,
|
32
|
-
|
29
|
+
'1.7.8' => 4.3,
|
30
|
+
'9000.dev' => 4.3,
|
31
|
+
}[JRUBY_JARS_VERSION.to_s] || 4.3
|
33
32
|
lower_limit = upper_limit * 0.9
|
34
33
|
version_message ="JRuby: #{JRUBY_JARS_VERSION}, ANDROID_TARGET: #{ANDROID_TARGET}"
|
35
34
|
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
data/test/ruboto_gen_test.rb
CHANGED
@@ -49,21 +49,24 @@ class RubotoGenTest < Test::Unit::TestCase
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
# APK was
|
53
|
-
# APK was
|
54
|
-
# APK was
|
52
|
+
# APK was 59.6KB. PLATFORM: CURRENT, ANDROID_TARGET: 10
|
53
|
+
# APK was 60.2KB. PLATFORM: CURRENT, ANDROID_TARGET: 15
|
54
|
+
# APK was 74.9KB. PLATFORM: CURRENT, ANDROID_TARGET: 16
|
55
55
|
# APK was 57.1KB. PLATFORM: FROM_GEM, ANDROID_TARGET: 10
|
56
56
|
# APK was 7380.0KB. PLATFORM: STANDALONE, ANDROID_TARGET: 15, JRuby: 1.7.0
|
57
57
|
# APK was 7310.1KB. PLATFORM: STANDALONE, ANDROID_TARGET: 10, JRuby: 1.7.2
|
58
58
|
# APK was 7337.0KB. PLATFORM: STANDALONE, ANDROID_TARGET: 15, JRuby: 1.7.2
|
59
59
|
# APK was 7317.4KB. PLATFORM: STANDALONE, ANDROID_TARGET: 15, JRuby: 1.7.3
|
60
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
|
62
|
-
# APK was 7405.8KB. PLATFORM: STANDALONE, ANDROID_TARGET: 15, JRuby: 1.7.4
|
63
|
-
# APK was 7420.9KB. PLATFORM: STANDALONE, ANDROID_TARGET: 16, JRuby: 1.7.4
|
64
|
-
# APK was 8755.5KB. PLATFORM: STANDALONE, ANDROID_TARGET: 15, JRuby: 1.7.5
|
65
|
-
# APK was 8770.2KB. PLATFORM: STANDALONE, ANDROID_TARGET: 16, JRuby: 1.7.5
|
66
|
-
|
61
|
+
# APK was 8428.4KB. PLATFORM: STANDALONE, ANDROID_TARGET: 10, JRuby: 1.7.4
|
62
|
+
# APK was 7405.8KB. PLATFORM: STANDALONE, ANDROID_TARGET: 15, JRuby: 1.7.4
|
63
|
+
# APK was 7420.9KB. PLATFORM: STANDALONE, ANDROID_TARGET: 16, JRuby: 1.7.4
|
64
|
+
# APK was 8755.5KB. PLATFORM: STANDALONE, ANDROID_TARGET: 15, JRuby: 1.7.5
|
65
|
+
# APK was 8770.2KB. PLATFORM: STANDALONE, ANDROID_TARGET: 16, JRuby: 1.7.5
|
66
|
+
# APK was 8766.1KB. PLATFORM: STANDALONE, ANDROID_TARGET: 16, JRuby: 1.7.6
|
67
|
+
# APK was 8781.6KB. PLATFORM: STANDALONE, ANDROID_TARGET: 16, JRuby: 1.7.8
|
68
|
+
# APK was 6337.3KB. PLATFORM: STANDALONE, ANDROID_TARGET: 10, JRuby: 9000.dev
|
69
|
+
# APK was 6556.7KB. PLATFORM: STANDALONE, ANDROID_TARGET: 16, JRuby: 9000.dev
|
67
70
|
def test_new_apk_size_is_within_limits
|
68
71
|
apk_size = BigDecimal(File.size("#{APP_DIR}/bin/RubotoTestApp-debug.apk").to_s) / 1024
|
69
72
|
version = " PLATFORM: #{RUBOTO_PLATFORM}"
|
@@ -75,15 +78,18 @@ class RubotoGenTest < Test::Unit::TestCase
|
|
75
78
|
'1.7.2' => 7400.0,
|
76
79
|
'1.7.3' => 7400.0,
|
77
80
|
'1.7.4' => 8500.0,
|
78
|
-
'1.7.5
|
79
|
-
|
81
|
+
'1.7.5' => 8800.0,
|
82
|
+
'1.7.6' => 8800.0,
|
83
|
+
'1.7.8' => 8800.0,
|
84
|
+
'9000.dev' => 6600.0,
|
85
|
+
}[JRUBY_JARS_VERSION.to_s] || 6600.0
|
80
86
|
version << ", JRuby: #{JRUBY_JARS_VERSION.to_s}"
|
81
87
|
else
|
82
88
|
upper_limit = {
|
83
|
-
10 =>
|
84
|
-
15 =>
|
85
|
-
16 =>
|
86
|
-
}[ANDROID_TARGET] ||
|
89
|
+
10 => 60.0,
|
90
|
+
15 => 62.0,
|
91
|
+
16 => 75.0,
|
92
|
+
}[ANDROID_TARGET] || 75.0
|
87
93
|
end
|
88
94
|
lower_limit = upper_limit * 0.9
|
89
95
|
assert apk_size <= upper_limit, "APK was larger than #{'%.1f' % upper_limit}KB: #{'%.1f' % apk_size.ceil(1)}KB.#{version}"
|
data/test/ruboto_update_test.rb
CHANGED
@@ -11,23 +11,23 @@ require File.expand_path('update_test_methods', File.dirname(__FILE__))
|
|
11
11
|
# TODO(uwe): Delete obsolete examples when we stop supporting updating from them.
|
12
12
|
Dir.chdir "#{RubotoTest::PROJECT_DIR}/examples/" do
|
13
13
|
example_archives = Dir["#{RubotoTest::APP_NAME}_*_tools_r*.tgz"]
|
14
|
-
example_archives = example_archives.sort_by{|a| Gem::Version.new(a[RubotoTest::APP_NAME.size + 1..-1].slice(/(.*)(?=_tools_)/).gsub('_', '.'))}
|
14
|
+
example_archives = example_archives.sort_by { |a| Gem::Version.new(a[RubotoTest::APP_NAME.size + 1..-1].slice(/(.*)(?=_tools_)/).gsub('_', '.')) }
|
15
15
|
example_archives = example_archives.last(example_limit) if example_limit
|
16
16
|
|
17
17
|
# TODO(gf): Track APIs compatible with update examples
|
18
|
-
EXAMPLE_COMPATIBLE_APIS = {
|
19
|
-
|
18
|
+
EXAMPLE_COMPATIBLE_APIS = {(Gem::Version.new('0.7.0')..Gem::Version.new('0.10.99')) => [8],
|
19
|
+
(Gem::Version.new('0.11.0')..Gem::Version.new('0.13.0')) => [10, 11, 12, 13, 14, 15, 16, 17]}
|
20
20
|
|
21
21
|
installed_apis = `android list target --compact`.lines.grep(/^android-/) { |s| s.match(/\d+/).to_s.to_i }
|
22
22
|
examples = example_archives.collect { |f| f.match /^#{RubotoTest::APP_NAME}_(?<ruboto_version>.*)_tools_r(?<tools_version>.*)\.tgz$/ }.compact
|
23
23
|
|
24
24
|
missing_apis = false
|
25
25
|
puts "Backward compatibility update tests: #{examples.size}"
|
26
|
-
examples.each_with_index do |m,i|
|
26
|
+
examples.each_with_index do |m, i|
|
27
27
|
example_gem_version = Gem::Version.new m[:ruboto_version]
|
28
|
-
compatible_apis = EXAMPLE_COMPATIBLE_APIS[
|
28
|
+
compatible_apis = EXAMPLE_COMPATIBLE_APIS[EXAMPLE_COMPATIBLE_APIS.keys.detect { |gem_range| gem_range.cover? example_gem_version }]
|
29
29
|
if compatible_apis
|
30
|
-
if (
|
30
|
+
if (installed_apis & compatible_apis).empty?
|
31
31
|
puts "Update test #{example_archives[i]} needs a missing compatible API: #{compatible_apis.join(',')}"
|
32
32
|
missing_apis = true
|
33
33
|
end
|
@@ -66,3 +66,20 @@ EOF
|
|
66
66
|
end
|
67
67
|
|
68
68
|
end
|
69
|
+
|
70
|
+
class RubotoUpdateTest < Test::Unit::TestCase
|
71
|
+
def setup
|
72
|
+
generate_app :heap_alloc => 16, :update => true
|
73
|
+
end
|
74
|
+
|
75
|
+
def teardown
|
76
|
+
cleanup_app
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_jruby_adapter_heap_alloc
|
80
|
+
Dir.chdir APP_DIR do
|
81
|
+
assert_match /^\s*byte\[\] arrayForHeapAllocation = new byte\[16 \* 1024 \* 1024\];/,
|
82
|
+
File.read('src/org/ruboto/JRubyAdapter.java')
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
data/test/sqldroid_test.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -147,20 +147,28 @@ class Test::Unit::TestCase
|
|
147
147
|
end
|
148
148
|
|
149
149
|
def generate_app(options = {})
|
150
|
-
|
150
|
+
bundle = options.delete(:bundle)
|
151
151
|
example = options.delete(:example) || false
|
152
|
-
|
152
|
+
|
153
153
|
# FIXME(uwe): Remove exclusion feature
|
154
154
|
excluded_stdlibs = options.delete(:excluded_stdlibs)
|
155
|
+
# EMXIF
|
156
|
+
|
157
|
+
heap_alloc = options.delete(:heap_alloc)
|
155
158
|
included_stdlibs = options.delete(:included_stdlibs)
|
156
|
-
|
157
|
-
|
159
|
+
package = options.delete(:package) || PACKAGE
|
160
|
+
standalone = options.delete(:standalone) || !!included_stdlibs || !!excluded_stdlibs || ENV['RUBOTO_PLATFORM'] == 'STANDALONE'
|
161
|
+
update = options.delete(:update) || false
|
158
162
|
raise "Unknown options: #{options.inspect}" unless options.empty?
|
163
|
+
|
164
|
+
raise "Inclusion/exclusion of libs requires standalone mode." if (included_stdlibs || excluded_stdlibs) && !standalone
|
165
|
+
|
159
166
|
Dir.mkdir TMP_DIR unless File.exists? TMP_DIR
|
160
167
|
|
161
168
|
FileUtils.rm_rf APP_DIR if File.exists? APP_DIR
|
162
169
|
template_dir = "#{APP_DIR}_template_#{$$}"
|
163
170
|
template_dir << "_package_#{package}" if package != PACKAGE
|
171
|
+
template_dir << "_heap_alloc_#{heap_alloc}" if heap_alloc
|
164
172
|
template_dir << "_example_#{example}" if example
|
165
173
|
template_dir << "_bundle_#{[*bundle].join('_')}" if bundle
|
166
174
|
template_dir << '_updated' if update
|
@@ -179,14 +187,13 @@ class Test::Unit::TestCase
|
|
179
187
|
File.open('local.properties', 'w') { |f| f.puts "sdk.dir=#{ANDROID_HOME}" }
|
180
188
|
File.open('test/local.properties', 'w') { |f| f.puts "sdk.dir=#{ANDROID_HOME}" }
|
181
189
|
if standalone
|
182
|
-
|
190
|
+
write_ruboto_yml(included_stdlibs, excluded_stdlibs, heap_alloc) if included_stdlibs || excluded_stdlibs || heap_alloc
|
183
191
|
FileUtils.touch 'libs/jruby-core-x.x.x.jar'
|
184
192
|
FileUtils.touch 'libs/jruby-stdlib-x.x.x.jar'
|
185
193
|
install_jruby_jars_gem
|
186
194
|
else
|
187
195
|
FileUtils.rm(Dir['libs/{jruby-*.jar,dx.jar}'])
|
188
196
|
end
|
189
|
-
update_app if update
|
190
197
|
end
|
191
198
|
else
|
192
199
|
if standalone
|
@@ -202,9 +209,8 @@ class Test::Unit::TestCase
|
|
202
209
|
end
|
203
210
|
Dir.chdir APP_DIR do
|
204
211
|
write_gemfile(bundle) if bundle
|
212
|
+
write_ruboto_yml(included_stdlibs, excluded_stdlibs, heap_alloc) if included_stdlibs || excluded_stdlibs || heap_alloc
|
205
213
|
if standalone
|
206
|
-
include_stdlibs(included_stdlibs) if included_stdlibs
|
207
|
-
exclude_stdlibs(excluded_stdlibs) if excluded_stdlibs
|
208
214
|
system "#{RUBOTO_CMD} gen jruby"
|
209
215
|
raise "update jruby failed with return code #$?" if $? != 0
|
210
216
|
end
|
@@ -221,8 +227,11 @@ class Test::Unit::TestCase
|
|
221
227
|
#end
|
222
228
|
# EMXIF
|
223
229
|
|
224
|
-
|
225
|
-
|
230
|
+
Dir.chdir APP_DIR do
|
231
|
+
if update
|
232
|
+
update_app
|
233
|
+
end
|
234
|
+
if update || !example
|
226
235
|
system 'rake patch_dex' # Ensure dx heap space is sufficient.
|
227
236
|
assert_equal 0, $?
|
228
237
|
Dir.chdir 'test' do
|
@@ -247,10 +256,19 @@ class Test::Unit::TestCase
|
|
247
256
|
|
248
257
|
def run_app_tests
|
249
258
|
check_platform_installation
|
259
|
+
test_completed = false
|
260
|
+
Thread.start do
|
261
|
+
loop do
|
262
|
+
sleep 60
|
263
|
+
break if test_completed
|
264
|
+
print '-'
|
265
|
+
end
|
266
|
+
end
|
250
267
|
Dir.chdir APP_DIR do
|
251
268
|
system 'rake test:quick'
|
252
269
|
assert_equal 0, $?, "tests failed with return code #$?"
|
253
270
|
end
|
271
|
+
test_completed = true
|
254
272
|
end
|
255
273
|
|
256
274
|
def check_platform_installation
|
@@ -269,14 +287,14 @@ class Test::Unit::TestCase
|
|
269
287
|
end
|
270
288
|
end
|
271
289
|
|
272
|
-
def
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
290
|
+
def write_ruboto_yml(included_stdlibs, excluded_stdlibs, heap_alloc)
|
291
|
+
yml = YAML.dump({'included_stdlibs' => included_stdlibs,
|
292
|
+
'excluded_stdlibs' => excluded_stdlibs,
|
293
|
+
'heap_alloc' => heap_alloc})
|
294
|
+
puts "Adding ruboto.yml:\n#{yml}"
|
295
|
+
File.open('ruboto.yml', 'w') do |f|
|
296
|
+
f << yml
|
297
|
+
end
|
280
298
|
end
|
281
299
|
|
282
300
|
def write_gemfile(bundle)
|
@@ -284,7 +302,7 @@ class Test::Unit::TestCase
|
|
284
302
|
puts "Adding Gemfile.apk: #{gems.join(' ')}"
|
285
303
|
File.open('Gemfile.apk', 'w') do |f|
|
286
304
|
f << "source 'http://rubygems.org/'\n\n"
|
287
|
-
gems.each{|g| f << "gem '#{g}'\n"}
|
305
|
+
gems.each { |g| f << "gem '#{g}'\n" }
|
288
306
|
end
|
289
307
|
end
|
290
308
|
|