ruboto 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +13 -49
- data/Rakefile +26 -26
- data/assets/rakelib/ruboto.rake +29 -9
- data/assets/res/drawable-hdpi/{icon.png → ic_launcher.png} +0 -0
- data/assets/res/drawable-ldpi/{icon.png → ic_launcher.png} +0 -0
- data/assets/res/drawable-mdpi/{icon.png → ic_launcher.png} +0 -0
- data/assets/samples/sample_activity.rb +19 -9
- data/assets/samples/sample_broadcast_receiver.rb +3 -1
- data/assets/samples/sample_service.rb +9 -9
- data/assets/src/InheritingActivity.java +1 -1
- data/assets/src/InheritingBroadcastReceiver.java +4 -4
- data/assets/src/InheritingClass.java +1 -1
- data/assets/src/InheritingService.java +2 -1
- data/assets/src/RubotoActivity.java +26 -17
- data/assets/src/RubotoBroadcastReceiver.java +32 -11
- data/assets/src/RubotoService.java +23 -13
- data/assets/src/org/ruboto/EntryPointActivity.java +18 -26
- data/assets/src/org/ruboto/JRubyAdapter.java +468 -0
- data/assets/src/org/ruboto/Log.java +22 -0
- data/assets/src/org/ruboto/Script.java +113 -587
- data/assets/src/org/ruboto/test/ActivityTest.java +7 -7
- data/assets/src/org/ruboto/test/InstrumentationTestRunner.java +27 -12
- data/assets/src/ruboto.rb +1 -1
- data/assets/src/ruboto/activity.rb +10 -1
- data/assets/src/ruboto/base.rb +0 -12
- data/assets/src/ruboto/broadcast_receiver.rb +12 -0
- data/assets/src/ruboto/menu.rb +0 -1
- data/assets/src/ruboto/package.rb +11 -0
- data/assets/src/ruboto/service.rb +9 -0
- data/lib/ruboto/commands/base.rb +1 -1
- data/lib/ruboto/util/build.rb +1 -1
- data/lib/ruboto/util/update.rb +35 -27
- data/lib/ruboto/util/xml_element.rb +25 -12
- data/lib/ruboto/version.rb +2 -2
- data/test/activity/image_button_activity.rb +14 -11
- data/test/activity/image_button_activity_test.rb +2 -6
- data/test/activity/image_button_and_button_activity.rb +15 -17
- data/test/activity/image_button_and_button_activity_test.rb +4 -8
- data/test/activity/option_menu_activity.rb +17 -12
- data/test/activity/option_menu_activity_test.rb +1 -4
- data/test/activity/psych_activity.rb +20 -13
- data/test/activity/psych_activity_test.rb +3 -1
- data/test/activity/stack_activity.rb +17 -14
- data/test/activity/stack_activity_test.rb +13 -12
- data/test/app_test_methods.rb +25 -19
- data/test/block_def_activity/image_button_activity.rb +23 -0
- data/test/block_def_activity/image_button_activity_test.rb +21 -0
- data/test/block_def_activity/image_button_and_button_activity.rb +20 -0
- data/test/block_def_activity/image_button_and_button_activity_test.rb +27 -0
- data/test/block_def_activity/option_menu_activity.rb +26 -0
- data/test/block_def_activity/option_menu_activity_test.rb +18 -0
- data/test/block_def_activity/psych_activity.rb +35 -0
- data/test/block_def_activity/psych_activity_test.rb +16 -0
- data/test/block_def_activity/stack_activity.rb +25 -0
- data/test/block_def_activity/stack_activity_test.rb +31 -0
- data/test/broadcast_receiver_test.rb +2 -2
- data/test/handle_activity/image_button_activity.rb +21 -0
- data/test/handle_activity/image_button_activity_test.rb +21 -0
- data/test/handle_activity/image_button_and_button_activity.rb +24 -0
- data/test/handle_activity/image_button_and_button_activity_test.rb +27 -0
- data/test/handle_activity/option_menu_activity.rb +21 -0
- data/test/handle_activity/option_menu_activity_test.rb +20 -0
- data/test/handle_activity/psych_activity.rb +31 -0
- data/test/handle_activity/psych_activity_test.rb +16 -0
- data/test/handle_activity/stack_activity.rb +21 -0
- data/test/handle_activity/stack_activity_test.rb +32 -0
- data/test/minimal_app_test.rb +4 -4
- data/test/rake_test.rb +15 -1
- data/test/ruboto_gen_test.rb +7 -4
- data/test/service_test.rb +110 -21
- data/test/test_helper.rb +17 -14
- data/test/updated_example_test_methods.rb +5 -14
- metadata +30 -7
@@ -0,0 +1,27 @@
|
|
1
|
+
activity Java::org.ruboto.test_app.ImageButtonAndButtonActivity
|
2
|
+
|
3
|
+
setup do |activity|
|
4
|
+
start = Time.now
|
5
|
+
loop do
|
6
|
+
@text_view = activity.find_view_by_id 42
|
7
|
+
break if @text_view || (Time.now - start > 60)
|
8
|
+
sleep 1
|
9
|
+
end
|
10
|
+
assert @text_view
|
11
|
+
end
|
12
|
+
|
13
|
+
test('initial setup') do |activity|
|
14
|
+
assert_equal "What hath Matz wrought?", @text_view.text
|
15
|
+
end
|
16
|
+
|
17
|
+
test('button changes text') do |activity|
|
18
|
+
button = activity.find_view_by_id 44
|
19
|
+
button.perform_click
|
20
|
+
assert_equal 'Button pressed', @text_view.text
|
21
|
+
end
|
22
|
+
|
23
|
+
test('image button changes text') do |activity|
|
24
|
+
image_button = activity.find_view_by_id 43
|
25
|
+
image_button.perform_click
|
26
|
+
assert_equal 'Image button pressed', @text_view.text
|
27
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'ruboto/activity'
|
2
|
+
require 'ruboto/widget'
|
3
|
+
require 'ruboto/util/toast'
|
4
|
+
|
5
|
+
ruboto_import_widgets :LinearLayout, :TextView
|
6
|
+
|
7
|
+
$activity.start_ruboto_activity do
|
8
|
+
setTitle File.basename(__FILE__).chomp('_activity.rb').split('_').map{|s| "#{s[0..0].upcase}#{s[1..-1]}" }.join(' ')
|
9
|
+
|
10
|
+
def on_create(bundle)
|
11
|
+
self.content_view =
|
12
|
+
linear_layout :orientation => LinearLayout::VERTICAL do
|
13
|
+
@text_view = text_view :text => 'What hath Matz wrought?', :id => 42
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def on_create_options_menu(menu)
|
18
|
+
mi = menu.add('Test')
|
19
|
+
mi.setIcon($package.R::drawable::get_ruboto_core)
|
20
|
+
mi.set_on_menu_item_click_listener do |menu_item|
|
21
|
+
@text_view.text = 'What hath Matz wrought!'
|
22
|
+
toast 'Flipped a bit via butterfly'
|
23
|
+
end
|
24
|
+
true
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
activity Java::org.ruboto.test_app.OptionMenuActivity
|
2
|
+
|
3
|
+
setup do |activity|
|
4
|
+
start = Time.now
|
5
|
+
loop do
|
6
|
+
@text_view = activity.findViewById(42)
|
7
|
+
break if @text_view || (Time.now - start > 60)
|
8
|
+
sleep 1
|
9
|
+
end
|
10
|
+
assert @text_view
|
11
|
+
end
|
12
|
+
|
13
|
+
test('option_menu changes text') do |activity|
|
14
|
+
assert_equal "What hath Matz wrought?", @text_view.text
|
15
|
+
activity.window.performPanelIdentifierAction(android.view.Window::FEATURE_OPTIONS_PANEL, 0, 0)
|
16
|
+
# FIXME(rscottm): Does not work in Ruby 1.9 mode
|
17
|
+
assert_equal("What hath Matz wrought!", @text_view.text) if RUBY_VERSION < '1.9'
|
18
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# TODO(uwe): Remove when we stop supporting psych with Ruby 1.8 mode
|
2
|
+
if RUBY_VERSION < '1.9'
|
3
|
+
require 'jruby'
|
4
|
+
require 'rbconfig'
|
5
|
+
org.jruby.ext.psych.PsychLibrary.new.load(JRuby.runtime, false)
|
6
|
+
$LOADED_FEATURES << 'psych.so'
|
7
|
+
$LOAD_PATH << File.join(Config::CONFIG['libdir'], 'ruby/1.9')
|
8
|
+
end
|
9
|
+
# TODO end
|
10
|
+
|
11
|
+
require 'ruboto/activity'
|
12
|
+
require 'ruboto/widget'
|
13
|
+
require 'ruboto/util/stack'
|
14
|
+
require 'ruboto/util/toast'
|
15
|
+
|
16
|
+
with_large_stack { require 'psych.rb' }
|
17
|
+
|
18
|
+
Psych::Parser
|
19
|
+
Psych::Handler
|
20
|
+
|
21
|
+
ruboto_import_widgets :Button, :LinearLayout, :TextView
|
22
|
+
|
23
|
+
$activity.start_ruboto_activity do
|
24
|
+
setTitle File.basename(__FILE__).chomp('_activity.rb').split('_').map { |s| "#{s[0..0].upcase}#{s[1..-1]}" }.join(' ')
|
25
|
+
|
26
|
+
def on_create(bundle)
|
27
|
+
self.content_view =
|
28
|
+
linear_layout :orientation => LinearLayout::VERTICAL do
|
29
|
+
@decoded_view = text_view :id => 42, :text => with_large_stack{Psych.load('--- foo')}
|
30
|
+
# TODO(uwe): Simplify when we stop supporting Psych in Ruby 1.8 mode
|
31
|
+
@encoded_view = text_view(:id => 43, :text => with_large_stack{Psych.dump('foo')}) unless RUBY_VERSION < '1.9'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
activity org.ruboto.test_app.PsychActivity
|
2
|
+
|
3
|
+
setup do |activity|
|
4
|
+
start = Time.now
|
5
|
+
loop do
|
6
|
+
@text_view = activity.findViewById(42)
|
7
|
+
break if @text_view || (Time.now - start > 60)
|
8
|
+
sleep 1
|
9
|
+
end
|
10
|
+
assert @text_view
|
11
|
+
end
|
12
|
+
|
13
|
+
test('psych_encode_decode') do |activity|
|
14
|
+
assert_equal 'foo', activity.find_view_by_id(42).text.to_s
|
15
|
+
#assert_equal "--- foo\n...\n", activity.find_view_by_id(43).text.to_s
|
16
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
STACK_DEPTH_SCRIPT = java.lang.Thread.current_thread.stack_trace.length.to_s
|
2
|
+
require 'ruboto/activity'
|
3
|
+
require 'ruboto/widget'
|
4
|
+
require 'ruboto/util/toast'
|
5
|
+
|
6
|
+
ruboto_import_widgets :Button, :LinearLayout, :TextView
|
7
|
+
|
8
|
+
$activity.start_ruboto_activity do
|
9
|
+
STACK_DEPTH_START_RUBOTO_ACTIVITY = java.lang.Thread.current_thread.stack_trace.length.to_s
|
10
|
+
|
11
|
+
def on_create(bundle)
|
12
|
+
stack_depth_on_create = java.lang.Thread.current_thread.stack_trace.length.to_s
|
13
|
+
setTitle File.basename(__FILE__).chomp('_activity.rb').split('_').map { |s| "#{s[0..0].upcase}#{s[1..-1]}" }.join(' ')
|
14
|
+
|
15
|
+
self.content_view =
|
16
|
+
linear_layout :orientation => LinearLayout::VERTICAL do
|
17
|
+
stack_depth_linear_layout = java.lang.Thread.current_thread.stack_trace.length.to_s
|
18
|
+
text_view :id => 42, :text => STACK_DEPTH_SCRIPT
|
19
|
+
text_view :id => 43, :text => STACK_DEPTH_START_RUBOTO_ACTIVITY
|
20
|
+
text_view :id => 44, :text => stack_depth_on_create
|
21
|
+
text_view :id => 45, :text => stack_depth_linear_layout
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
activity org.ruboto.test_app.StackActivity
|
2
|
+
|
3
|
+
setup do |activity|
|
4
|
+
start = Time.now
|
5
|
+
loop do
|
6
|
+
@text_view = activity.findViewById(42)
|
7
|
+
break if @text_view || (Time.now - start > 60)
|
8
|
+
sleep 1
|
9
|
+
end
|
10
|
+
assert @text_view
|
11
|
+
end
|
12
|
+
|
13
|
+
test('stack depth') do |activity|
|
14
|
+
os_offset = {13 => 1, 15 => 1, 16 => 1}[android.os.Build::VERSION::SDK_INT].to_i
|
15
|
+
if org.ruboto.JRubyAdapter.uses_platform_apk?
|
16
|
+
jruby_offset = {
|
17
|
+
'0.4.7' => [0, 0, 0, 0],
|
18
|
+
'0.4.8.dev' => [0, -1, 0, 0],
|
19
|
+
}[org.ruboto.JRubyAdapter.platform_version_name] || [0, 0, 0, 0]
|
20
|
+
else # STANDALONE
|
21
|
+
jruby_offset = {
|
22
|
+
'1.7.0.preview1' => [0, -1, -1, -1],
|
23
|
+
'1.7.0.preview2.dev' => [0, -1, 0, 0],
|
24
|
+
}[org.jruby.runtime.Constants::VERSION] || [0, 0, 0, 0]
|
25
|
+
end
|
26
|
+
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}"
|
27
|
+
assert_equal 43 + os_offset + jruby_offset[0], activity.find_view_by_id(42).text.to_i, version_message
|
28
|
+
assert_equal 78 + os_offset + jruby_offset[1], activity.find_view_by_id(43).text.to_i, version_message
|
29
|
+
assert_equal 61 + os_offset + jruby_offset[2], activity.find_view_by_id(44).text.to_i, version_message
|
30
|
+
assert_equal 78 + os_offset + jruby_offset[3], activity.find_view_by_id(45).text.to_i, version_message
|
31
|
+
end
|
@@ -36,8 +36,8 @@ class BroadcastReceiverTest < Test::Unit::TestCase
|
|
36
36
|
end
|
37
37
|
EOF
|
38
38
|
|
39
|
-
assert activity_content.sub!(/
|
40
|
-
|
39
|
+
assert activity_content.sub!(/ def butterfly\n.*? end\n/m, <<EOF)
|
40
|
+
def butterfly
|
41
41
|
intent = android.content.Intent.new
|
42
42
|
intent.set_action '#{action_name}'
|
43
43
|
send_broadcast(intent)
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'ruboto'
|
2
|
+
|
3
|
+
ruboto_import_widgets :ImageButton, :LinearLayout, :TextView
|
4
|
+
|
5
|
+
$activity.handle_create do |bundle|
|
6
|
+
setTitle File.basename(__FILE__).chomp('_activity.rb').split('_').map{|s| "#{s[0..0].upcase}#{s[1..-1]}" }.join(' ')
|
7
|
+
|
8
|
+
setup_content do
|
9
|
+
linear_layout :orientation => LinearLayout::VERTICAL do
|
10
|
+
@text_view = text_view :text => 'What hath Matz wrought?', :id => 42
|
11
|
+
image_button :image_resource => $package.R::drawable::get_ruboto_core, :width => :wrap_content, :id => 43
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
handle_click do |view|
|
16
|
+
if view.id == 43
|
17
|
+
@text_view.setText 'What hath Matz wrought!'
|
18
|
+
toast 'Flipped a bit via butterfly'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
activity Java::org.ruboto.test_app.ImageButtonActivity
|
2
|
+
|
3
|
+
setup do |activity|
|
4
|
+
start = Time.now
|
5
|
+
loop do
|
6
|
+
@text_view = activity.findViewById(42)
|
7
|
+
break if @text_view || (Time.now - start > 60)
|
8
|
+
sleep 1
|
9
|
+
end
|
10
|
+
assert @text_view
|
11
|
+
end
|
12
|
+
|
13
|
+
test('initial setup') do |activity|
|
14
|
+
assert_equal "What hath Matz wrought?", @text_view.text
|
15
|
+
end
|
16
|
+
|
17
|
+
test('button changes text') do |activity|
|
18
|
+
button = activity.findViewById(43)
|
19
|
+
button.performClick
|
20
|
+
assert_equal "What hath Matz wrought!", @text_view.text
|
21
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'ruboto'
|
2
|
+
|
3
|
+
ruboto_import_widgets :Button, :ImageButton, :LinearLayout, :TextView
|
4
|
+
|
5
|
+
$activity.handle_create do |bundle|
|
6
|
+
setTitle File.basename(__FILE__).chomp('_activity.rb').split('_').map{|s| "#{s[0..0].upcase}#{s[1..-1]}" }.join(' ')
|
7
|
+
|
8
|
+
setup_content do
|
9
|
+
linear_layout :orientation => LinearLayout::VERTICAL do
|
10
|
+
@text_view = text_view :text => 'What hath Matz wrought?', :id => 42
|
11
|
+
button :text => 'Button', :width => :wrap_content, :id => 44
|
12
|
+
image_button :image_resource => $package.R::drawable::get_ruboto_core, :width => :wrap_content, :id => 43
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
handle_click do |view|
|
17
|
+
if view.id == 43
|
18
|
+
@text_view.text = 'Image button pressed'
|
19
|
+
elsif view.id == 44
|
20
|
+
@text_view.text = 'Button pressed'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
activity Java::org.ruboto.test_app.ImageButtonAndButtonActivity
|
2
|
+
|
3
|
+
setup do |activity|
|
4
|
+
start = Time.now
|
5
|
+
loop do
|
6
|
+
@text_view = activity.find_view_by_id 42
|
7
|
+
break if @text_view || (Time.now - start > 60)
|
8
|
+
sleep 1
|
9
|
+
end
|
10
|
+
assert @text_view
|
11
|
+
end
|
12
|
+
|
13
|
+
test('initial setup') do |activity|
|
14
|
+
assert_equal "What hath Matz wrought?", @text_view.text
|
15
|
+
end
|
16
|
+
|
17
|
+
test('button changes text') do |activity|
|
18
|
+
button = activity.find_view_by_id 44
|
19
|
+
button.perform_click
|
20
|
+
assert_equal 'Button pressed', @text_view.text
|
21
|
+
end
|
22
|
+
|
23
|
+
test('image button changes text') do |activity|
|
24
|
+
image_button = activity.find_view_by_id 43
|
25
|
+
image_button.perform_click
|
26
|
+
assert_equal 'Image button pressed', @text_view.text
|
27
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'ruboto'
|
2
|
+
|
3
|
+
ruboto_import_widgets :ImageButton, :LinearLayout, :TextView
|
4
|
+
|
5
|
+
$activity.handle_create do |bundle|
|
6
|
+
setTitle File.basename(__FILE__).chomp('_activity.rb').split('_').map{|s| "#{s[0..0].upcase}#{s[1..-1]}" }.join(' ')
|
7
|
+
|
8
|
+
setup_content do
|
9
|
+
linear_layout :orientation => LinearLayout::VERTICAL do
|
10
|
+
@text_view = text_view :text => 'What hath Matz wrought?', :id => 42
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
handle_create_options_menu do |menu|
|
15
|
+
add_menu('Test') do
|
16
|
+
@text_view.setText 'What hath Matz wrought!'
|
17
|
+
toast 'Flipped a bit via butterfly'
|
18
|
+
end
|
19
|
+
true
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
activity Java::org.ruboto.test_app.OptionMenuActivity
|
2
|
+
|
3
|
+
setup do |activity|
|
4
|
+
start = Time.now
|
5
|
+
loop do
|
6
|
+
@text_view = activity.findViewById(42)
|
7
|
+
break if @text_view || (Time.now - start > 60)
|
8
|
+
sleep 1
|
9
|
+
end
|
10
|
+
assert @text_view
|
11
|
+
end
|
12
|
+
|
13
|
+
test('initial setup') do |activity|
|
14
|
+
assert_equal "What hath Matz wrought?", @text_view.text
|
15
|
+
end
|
16
|
+
|
17
|
+
test('option_menu changes text') do |activity|
|
18
|
+
activity.window.performPanelIdentifierAction(android.view.Window::FEATURE_OPTIONS_PANEL, 0, 0)
|
19
|
+
assert_equal "What hath Matz wrought!", @text_view.text
|
20
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# TODO(uwe): Remove when we stop supporting psych with Ruby 1.8 mode
|
2
|
+
if RUBY_VERSION < '1.9'
|
3
|
+
require 'jruby'
|
4
|
+
require 'rbconfig'
|
5
|
+
org.jruby.ext.psych.PsychLibrary.new.load(JRuby.runtime, false)
|
6
|
+
$LOADED_FEATURES << 'psych.so'
|
7
|
+
$LOAD_PATH << File.join(Config::CONFIG['libdir'], 'ruby/1.9')
|
8
|
+
end
|
9
|
+
# TODO end
|
10
|
+
|
11
|
+
with_large_stack { require 'psych.rb' }
|
12
|
+
|
13
|
+
Psych::Parser
|
14
|
+
Psych::Handler
|
15
|
+
|
16
|
+
require 'ruboto'
|
17
|
+
|
18
|
+
ruboto_import_widgets :Button, :LinearLayout, :TextView
|
19
|
+
|
20
|
+
$activity.handle_create do |bundle|
|
21
|
+
setTitle File.basename(__FILE__).chomp('_activity.rb').split('_').map { |s| "#{s[0..0].upcase}#{s[1..-1]}" }.join(' ')
|
22
|
+
|
23
|
+
setup_content do
|
24
|
+
linear_layout :orientation => LinearLayout::VERTICAL do
|
25
|
+
@decoded_view = text_view :id => 42, :text => with_large_stack { Psych.load('--- foo') }
|
26
|
+
# TODO(uwe): Simplify when we stop supporting Psych in Ruby 1.8 mode
|
27
|
+
@encoded_view = text_view(:id => 43, :text => with_large_stack { Psych.dump('foo') }) unless RUBY_VERSION < '1.9'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
activity org.ruboto.test_app.PsychActivity
|
2
|
+
|
3
|
+
setup do |activity|
|
4
|
+
start = Time.now
|
5
|
+
loop do
|
6
|
+
@text_view = activity.findViewById(42)
|
7
|
+
break if @text_view || (Time.now - start > 60)
|
8
|
+
sleep 1
|
9
|
+
end
|
10
|
+
assert @text_view
|
11
|
+
end
|
12
|
+
|
13
|
+
test('psych_encode_decode') do |activity|
|
14
|
+
assert_equal 'foo', activity.find_view_by_id(42).text.to_s
|
15
|
+
#assert_equal "--- foo\n...\n", activity.find_view_by_id(43).text.to_s
|
16
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
STACK_DEPTH_SCRIPT = java.lang.Thread.current_thread.stack_trace.length.to_s
|
2
|
+
require 'ruboto'
|
3
|
+
|
4
|
+
ruboto_import_widgets :Button, :LinearLayout, :TextView
|
5
|
+
|
6
|
+
$activity.handle_create do |bundle|
|
7
|
+
STACK_DEPTH_HANDLE_CREATE = java.lang.Thread.current_thread.stack_trace.length.to_s
|
8
|
+
setTitle File.basename(__FILE__).chomp('_activity.rb').split('_').map{|s| "#{s[0..0].upcase}#{s[1..-1]}" }.join(' ')
|
9
|
+
|
10
|
+
setup_content do
|
11
|
+
STACK_DEPTH_SETUP_CONTENT = java.lang.Thread.current_thread.stack_trace.length.to_s
|
12
|
+
linear_layout :orientation => LinearLayout::VERTICAL do
|
13
|
+
STACK_DEPTH_LINEAR_LAYOUT = java.lang.Thread.current_thread.stack_trace.length.to_s
|
14
|
+
@script_view = text_view :id => 42, :text => STACK_DEPTH_SCRIPT
|
15
|
+
@handle_create_view = text_view :id => 43, :text => STACK_DEPTH_HANDLE_CREATE
|
16
|
+
@setup_content_view = text_view :id => 44, :text => STACK_DEPTH_SETUP_CONTENT
|
17
|
+
@linear_layout_view = text_view :id => 45, :text => STACK_DEPTH_LINEAR_LAYOUT
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
activity org.ruboto.test_app.StackActivity
|
2
|
+
|
3
|
+
setup do |activity|
|
4
|
+
start = Time.now
|
5
|
+
loop do
|
6
|
+
@text_view = activity.findViewById(42)
|
7
|
+
break if @text_view || (Time.now - start > 60)
|
8
|
+
sleep 1
|
9
|
+
end
|
10
|
+
assert @text_view
|
11
|
+
end
|
12
|
+
|
13
|
+
test('stack depth') do |activity|
|
14
|
+
os_offset = {13 => 1, 15 => 1, 16 => 1}[android.os.Build::VERSION::SDK_INT].to_i
|
15
|
+
if org.ruboto.JRubyAdapter.uses_platform_apk?
|
16
|
+
jruby_offset = {
|
17
|
+
'0.4.7' => [0, 0, 0, 0],
|
18
|
+
'0.4.8.dev' => [0, -1, -1, -1],
|
19
|
+
}[org.ruboto.JRubyAdapter.platform_version_name] || [0, 0, 0, 0]
|
20
|
+
else
|
21
|
+
jruby_offset = {
|
22
|
+
'1.7.0.dev' => [1, 1, 1, 1],
|
23
|
+
'1.7.0.preview1' => [0, -1, -1, -1],
|
24
|
+
'1.7.0.preview2.dev' => [0, -1, -1, -1],
|
25
|
+
}[org.jruby.runtime.Constants::VERSION] || [0, 0, 0, 0]
|
26
|
+
end
|
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}"
|
28
|
+
assert_equal 43 + os_offset + jruby_offset[0], activity.find_view_by_id(42).text.to_i, version_message
|
29
|
+
assert_equal 67 + os_offset + jruby_offset[1], activity.find_view_by_id(43).text.to_i, version_message
|
30
|
+
assert_equal 76 + os_offset + jruby_offset[2], activity.find_view_by_id(44).text.to_i, version_message
|
31
|
+
assert_equal 92 + os_offset + jruby_offset[3], activity.find_view_by_id(45).text.to_i, version_message
|
32
|
+
end
|