ruboto 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +1 -1
- data/Gemfile.lock +0 -2
- data/Rakefile +64 -1
- data/assets/rakelib/ruboto.rake +23 -2
- data/assets/res/layout/get_ruboto_core.xml +0 -2
- data/assets/samples/sample_activity.rb +3 -6
- data/assets/samples/sample_broadcast_receiver.rb +9 -5
- data/assets/samples/sample_service.rb +0 -3
- data/assets/src/InheritingActivity.java +1 -1
- data/assets/src/InheritingClass.java +10 -4
- data/assets/src/RubotoActivity.java +90 -20
- data/assets/src/RubotoBroadcastReceiver.java +59 -23
- data/assets/src/RubotoService.java +103 -51
- data/assets/src/org/ruboto/EntryPointActivity.java +2 -1
- data/assets/src/org/ruboto/JRubyAdapter.java +158 -115
- data/assets/src/org/ruboto/Script.java +23 -1
- data/assets/src/org/ruboto/test/ActivityTest.java +2 -2
- data/assets/src/org/ruboto/test/InstrumentationTestRunner.java +30 -16
- data/assets/src/ruboto.rb +1 -0
- data/assets/src/ruboto/activity.rb +2 -6
- data/assets/src/ruboto/base.rb +9 -7
- data/assets/src/ruboto/broadcast_receiver.rb +0 -8
- data/assets/src/ruboto/generate.rb +2 -2
- data/assets/src/ruboto/service.rb +0 -8
- data/assets/src/ruboto/widget.rb +17 -2
- data/lib/java_class_gen/android_api.xml +1 -1
- data/lib/ruboto/sdk_versions.rb +1 -1
- data/lib/ruboto/util/build.rb +11 -10
- data/lib/ruboto/util/code_formatting.rb +2 -2
- data/lib/ruboto/util/update.rb +20 -7
- data/lib/ruboto/util/xml_element.rb +42 -16
- data/lib/ruboto/version.rb +1 -1
- data/test/activity/call_super_activity.rb +28 -0
- data/test/activity/call_super_activity_test.rb +15 -0
- data/test/activity/image_button_activity.rb +2 -3
- data/test/activity/image_button_and_button_activity.rb +1 -2
- data/test/activity/margins_activity.rb +17 -0
- data/test/activity/margins_activity_test.rb +25 -0
- data/test/activity/navigation_activity.rb +85 -0
- data/test/activity/navigation_activity_test.rb +98 -0
- data/test/activity/option_menu_activity.rb +0 -2
- data/test/activity/psych_activity.rb +2 -3
- data/test/activity/stack_activity.rb +3 -2
- data/test/activity/stack_activity_test.rb +9 -7
- data/test/block_def_activity/margins_activity.rb +17 -0
- data/test/block_def_activity/margins_activity_test.rb +25 -0
- data/test/block_def_activity/option_menu_activity_test.rb +1 -2
- data/test/block_def_activity/stack_activity_test.rb +8 -5
- data/test/broadcast_receiver_test.rb +2 -2
- data/test/gem_test.rb +12 -0
- data/test/handle_activity/margins_activity.rb +15 -0
- data/test/handle_activity/margins_activity_test.rb +25 -0
- data/test/handle_activity/option_menu_activity.rb +4 -0
- data/test/handle_activity/stack_activity.rb +3 -0
- data/test/handle_activity/stack_activity_test.rb +9 -6
- data/test/minimal_app_test.rb +1 -1
- data/test/rake_test.rb +6 -7
- data/test/ruboto_gen_test.rb +54 -4
- data/test/ruboto_update_test.rb +12 -8
- data/test/service_test.rb +1 -6
- data/test/test_helper.rb +34 -11
- data/test/update_test_methods.rb +22 -0
- data/test/view_constants_test.rb +104 -0
- metadata +17 -5
data/lib/ruboto/version.rb
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'ruboto/activity'
|
2
|
+
require 'ruboto/widget'
|
3
|
+
|
4
|
+
ruboto_import_widgets :Button, :LinearLayout, :TextView
|
5
|
+
|
6
|
+
class CallSuperActivity
|
7
|
+
def on_create(bundle)
|
8
|
+
super
|
9
|
+
setTitle 'Default'
|
10
|
+
setTitle 'With Super', true
|
11
|
+
setTitle 'Without Super', false
|
12
|
+
|
13
|
+
self.content_view =
|
14
|
+
linear_layout :orientation => :vertical, :gravity => android.view.Gravity::CENTER do
|
15
|
+
text_view :id => 42, :text => title, :text_size => 48.0, :gravity => android.view.Gravity::CENTER
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def setTitle(title, call_super = true)
|
20
|
+
super(title) if call_super
|
21
|
+
end
|
22
|
+
|
23
|
+
# FIXME(uwe): We should test that super is not called implicitly
|
24
|
+
# def on_resume
|
25
|
+
# super
|
26
|
+
# end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
activity org.ruboto.test_app.CallSuperActivity
|
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('super called correctly') do |activity|
|
14
|
+
assert_equal 'With Super', activity.find_view_by_id(42).text.to_s
|
15
|
+
end
|
@@ -1,10 +1,9 @@
|
|
1
|
-
require 'ruboto/
|
1
|
+
require 'ruboto/util/toast'
|
2
|
+
require 'ruboto/widget'
|
2
3
|
|
3
4
|
ruboto_import_widgets :ImageButton, :LinearLayout, :TextView
|
4
5
|
|
5
6
|
class ImageButtonActivity
|
6
|
-
include Ruboto::Activity
|
7
|
-
|
8
7
|
def on_create(bundle)
|
9
8
|
set_title File.basename(__FILE__).chomp('_activity.rb').split('_').map { |s| "#{s[0..0].upcase}#{s[1..-1]}" }.join(' ')
|
10
9
|
|
@@ -1,10 +1,9 @@
|
|
1
1
|
require 'ruboto/activity'
|
2
|
+
require 'ruboto/widget'
|
2
3
|
|
3
4
|
ruboto_import_widgets :Button, :ImageButton, :LinearLayout, :TextView
|
4
5
|
|
5
6
|
class ImageButtonAndButtonActivity
|
6
|
-
include Ruboto::Activity
|
7
|
-
|
8
7
|
def on_create(bundle)
|
9
8
|
setTitle File.basename(__FILE__).chomp('_activity.rb').split('_').map { |s| "#{s[0..0].upcase}#{s[1..-1]}" }.join(' ')
|
10
9
|
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'ruboto/activity'
|
2
|
+
require 'ruboto/widget'
|
3
|
+
|
4
|
+
ruboto_import_widgets :LinearLayout, :TextView
|
5
|
+
|
6
|
+
class MarginsActivity
|
7
|
+
def on_create(bundle)
|
8
|
+
setTitle File.basename(__FILE__).chomp('_activity.rb').split('_').map { |s| "#{s[0..0].upcase}#{s[1..-1]}" }.join(' ')
|
9
|
+
|
10
|
+
self.content_view =
|
11
|
+
linear_layout :orientation => LinearLayout::VERTICAL do
|
12
|
+
@text_view_margins = text_view :text => 'What hath Matz wrought?', :id => 42, :margins => [100,0,0,0]
|
13
|
+
@text_view_layout = text_view :text => 'What hath Matz wrought?', :id => 43, :layout => {:set_margins => [100,0,0,0]}
|
14
|
+
@text_view_fieldset = text_view :text => 'What hath Matz wrought?', :id => 44, :layout => {:left_margin= => 100}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
activity Java::org.ruboto.test_app.MarginsActivity
|
2
|
+
|
3
|
+
setup do |activity|
|
4
|
+
start = Time.now
|
5
|
+
loop do
|
6
|
+
@text_view_margins = activity.findViewById(42)
|
7
|
+
@text_view_layout = activity.findViewById(43)
|
8
|
+
@text_view_fieldset = activity.findViewById(44)
|
9
|
+
break if (@text_view_margins && @text_view_layout && @text_view_fieldset) || (Time.now - start > 60)
|
10
|
+
sleep 1
|
11
|
+
end
|
12
|
+
assert @text_view_margins
|
13
|
+
assert @text_view_layout
|
14
|
+
assert @text_view_fieldset
|
15
|
+
end
|
16
|
+
|
17
|
+
def left_margin(view)
|
18
|
+
view.get_layout_params.leftMargin
|
19
|
+
end
|
20
|
+
|
21
|
+
%w(margins layout fieldset).each do |view_type|
|
22
|
+
test("margins are set through #{view_type}") do |activity|
|
23
|
+
assert_equal 100, left_margin(instance_variable_get("@text_view_#{view_type}"))
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'ruboto/activity'
|
2
|
+
require 'ruboto/widget'
|
3
|
+
|
4
|
+
ruboto_import_widgets :Button, :LinearLayout, :TextView
|
5
|
+
|
6
|
+
class NavigationActivity
|
7
|
+
def on_create(bundle)
|
8
|
+
set_title File.basename(__FILE__).chomp('_activity.rb').split('_').map { |s| "#{s[0..0].upcase}#{s[1..-1]}" }.join(' ')
|
9
|
+
|
10
|
+
self.content_view =
|
11
|
+
linear_layout :orientation => :vertical, :gravity => :center_horizontal do
|
12
|
+
text_view :text => 'What hath Matz wrought?', :id => 42, :width => :match_parent,
|
13
|
+
:gravity => :center, :text_size => 48.0
|
14
|
+
button :text => 'Next by Java class', :width => :match_parent, :id => 43, :on_click_listener => proc { start_next_java_activity }
|
15
|
+
button :text => 'Next by Ruby class', :width => :match_parent, :id => 44, :on_click_listener => proc { start_next_ruby_activity }
|
16
|
+
button :text => 'Next by script name', :width => :match_parent, :id => 45, :on_click_listener => proc { start_activity_by_script_name }
|
17
|
+
button :text => 'Inline block', :width => :match_parent, :id => 46, :on_click_listener => proc { start_inline_activity }
|
18
|
+
button :text => 'Infile class', :width => :match_parent, :id => 47, :on_click_listener => proc { start_infile_activity }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def start_next_java_activity
|
25
|
+
i = android.content.Intent.new
|
26
|
+
i.setClassName($package_name, 'org.ruboto.test_app.NavigationActivity')
|
27
|
+
startActivity(i)
|
28
|
+
end
|
29
|
+
|
30
|
+
def start_next_ruby_activity
|
31
|
+
i = android.content.Intent.new
|
32
|
+
i.setClassName($package_name, 'org.ruboto.RubotoActivity')
|
33
|
+
configBundle = android.os.Bundle.new
|
34
|
+
configBundle.put_string('ClassName', 'NavigationActivity')
|
35
|
+
i.putExtra('RubotoActivity Config', configBundle)
|
36
|
+
startActivity(i)
|
37
|
+
end
|
38
|
+
|
39
|
+
def start_activity_by_script_name
|
40
|
+
i = android.content.Intent.new
|
41
|
+
i.setClassName($package_name, 'org.ruboto.RubotoActivity')
|
42
|
+
configBundle = android.os.Bundle.new
|
43
|
+
configBundle.put_string('Script', 'navigation_activity.rb')
|
44
|
+
i.putExtra('RubotoActivity Config', configBundle)
|
45
|
+
startActivity(i)
|
46
|
+
end
|
47
|
+
|
48
|
+
def start_inline_activity
|
49
|
+
start_ruboto_activity('$inline_activity') do
|
50
|
+
def on_create(bundle)
|
51
|
+
set_title 'Inline Activity'
|
52
|
+
|
53
|
+
self.content_view =
|
54
|
+
linear_layout :orientation => :vertical, :gravity => :center_horizontal do
|
55
|
+
text_view :text => 'This is an inline activity.', :id => 42, :width => :match_parent,
|
56
|
+
:gravity => :center, :text_size => 48.0
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def start_infile_activity
|
63
|
+
i = android.content.Intent.new
|
64
|
+
i.setClassName($package_name, 'org.ruboto.RubotoActivity')
|
65
|
+
configBundle = android.os.Bundle.new
|
66
|
+
configBundle.put_string('ClassName', 'InfileActivity')
|
67
|
+
i.putExtra('RubotoActivity Config', configBundle)
|
68
|
+
startActivity(i)
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
class InfileActivity
|
74
|
+
include Ruboto::Activity
|
75
|
+
|
76
|
+
def on_create(bundle)
|
77
|
+
set_title 'Infile Activity'
|
78
|
+
|
79
|
+
self.content_view =
|
80
|
+
linear_layout :orientation => :vertical, :gravity => :center_horizontal do
|
81
|
+
text_view :text => 'This is an infile activity.', :id => 42, :width => :match_parent,
|
82
|
+
:gravity => :center, :text_size => 48.0
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
activity Java::org.ruboto.test_app.NavigationActivity
|
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('button starts Java activity', :ui => false) do |activity|
|
14
|
+
assert_equal "What hath Matz wrought?", @text_view.text
|
15
|
+
monitor = add_monitor('org.ruboto.test_app.NavigationActivity', nil, false)
|
16
|
+
begin
|
17
|
+
activity.run_on_ui_thread { activity.find_view_by_id(43).perform_click }
|
18
|
+
current_activity = wait_for_monitor_with_timeout(monitor, 5000)
|
19
|
+
assert current_activity
|
20
|
+
current_activity.run_on_ui_thread { current_activity.finish }
|
21
|
+
# FIXME(uwe): Replace sleep with proper monitor
|
22
|
+
sleep 3
|
23
|
+
ensure
|
24
|
+
puts "Removing monitor"
|
25
|
+
removeMonitor(monitor)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
test('button starts Ruby activity', :ui => false) do |activity|
|
30
|
+
assert_equal "What hath Matz wrought?", @text_view.text
|
31
|
+
monitor = add_monitor('org.ruboto.RubotoActivity', nil, false)
|
32
|
+
begin
|
33
|
+
activity.run_on_ui_thread { activity.find_view_by_id(44).perform_click }
|
34
|
+
current_activity = wait_for_monitor_with_timeout(monitor, 5000)
|
35
|
+
assert current_activity
|
36
|
+
current_activity.run_on_ui_thread { current_activity.finish }
|
37
|
+
# FIXME(uwe): Replace sleep with proper monitor
|
38
|
+
sleep 3
|
39
|
+
ensure
|
40
|
+
puts "Removing monitor"
|
41
|
+
removeMonitor(monitor)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
test('button starts activity by script name', :ui => false) do |activity|
|
46
|
+
assert_equal "What hath Matz wrought?", @text_view.text
|
47
|
+
monitor = add_monitor('org.ruboto.RubotoActivity', nil, false)
|
48
|
+
begin
|
49
|
+
activity.run_on_ui_thread { activity.find_view_by_id(45).perform_click }
|
50
|
+
current_activity = wait_for_monitor_with_timeout(monitor, 5000)
|
51
|
+
assert current_activity
|
52
|
+
current_activity.run_on_ui_thread { current_activity.finish }
|
53
|
+
# FIXME(uwe): Replace sleep with proper monitor
|
54
|
+
sleep 3
|
55
|
+
ensure
|
56
|
+
puts "Removing monitor"
|
57
|
+
removeMonitor(monitor)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
test('button starts inline activity', :ui => false) do |activity|
|
62
|
+
assert_equal "What hath Matz wrought?", @text_view.text
|
63
|
+
activity.run_on_ui_thread { activity.find_view_by_id(46).perform_click }
|
64
|
+
start = Time.now
|
65
|
+
loop do
|
66
|
+
@text_view = activity.find_view_by_id(42)
|
67
|
+
break if (@text_view && @text_view.text == 'This is an inline activity.') || (Time.now - start > 10)
|
68
|
+
puts 'wait for text'
|
69
|
+
sleep 0.5
|
70
|
+
end
|
71
|
+
assert @text_view
|
72
|
+
assert_equal 'This is an inline activity.', @text_view.text
|
73
|
+
end
|
74
|
+
|
75
|
+
test('button starts infile class activity', :ui => false) do |activity|
|
76
|
+
assert_equal "What hath Matz wrought?", @text_view.text
|
77
|
+
monitor = add_monitor('org.ruboto.RubotoActivity', nil, false)
|
78
|
+
begin
|
79
|
+
activity.run_on_ui_thread { activity.find_view_by_id(47).perform_click }
|
80
|
+
current_activity = wait_for_monitor_with_timeout(monitor, 5000)
|
81
|
+
ensure
|
82
|
+
removeMonitor(monitor)
|
83
|
+
end
|
84
|
+
assert current_activity
|
85
|
+
puts "new activity: #{current_activity}"
|
86
|
+
start = Time.now
|
87
|
+
loop do
|
88
|
+
@text_view = current_activity.find_view_by_id(42)
|
89
|
+
break if @text_view || (Time.now - start > 10)
|
90
|
+
puts 'wait for text'
|
91
|
+
sleep 1
|
92
|
+
end
|
93
|
+
assert @text_view
|
94
|
+
assert_equal 'This is an infile activity.', @text_view.text
|
95
|
+
current_activity.run_on_ui_thread { current_activity.finish }
|
96
|
+
# FIXME(uwe): Replace sleep with proper monitor
|
97
|
+
sleep 3
|
98
|
+
end
|
@@ -5,8 +5,6 @@ require 'ruboto/util/toast'
|
|
5
5
|
ruboto_import_widgets :LinearLayout, :TextView
|
6
6
|
|
7
7
|
class OptionMenuActivity
|
8
|
-
include Ruboto::Activity
|
9
|
-
|
10
8
|
def on_create(bundle)
|
11
9
|
set_title File.basename(__FILE__).chomp('_activity.rb').split('_').map { |s| "#{s[0..0].upcase}#{s[1..-1]}" }.join(' ')
|
12
10
|
|
@@ -8,18 +8,17 @@ if RUBY_VERSION < '1.9'
|
|
8
8
|
end
|
9
9
|
# TODO end
|
10
10
|
|
11
|
-
require 'ruboto/activity'
|
12
11
|
require 'ruboto/util/stack'
|
13
12
|
with_large_stack { require 'psych.rb' }
|
14
13
|
|
15
14
|
Psych::Parser
|
16
15
|
Psych::Handler
|
17
16
|
|
17
|
+
require 'ruboto/widget'
|
18
|
+
|
18
19
|
ruboto_import_widgets :Button, :LinearLayout, :TextView
|
19
20
|
|
20
21
|
class PsychActivity
|
21
|
-
include Ruboto::Activity
|
22
|
-
|
23
22
|
def on_create(bundle)
|
24
23
|
set_title File.basename(__FILE__).chomp('_activity.rb').split('_').map { |s| "#{s[0..0].upcase}#{s[1..-1]}" }.join(' ')
|
25
24
|
self.content_view =
|
@@ -1,13 +1,14 @@
|
|
1
1
|
STACK_DEPTH_SCRIPT = java.lang.Thread.current_thread.stack_trace.length.to_s
|
2
2
|
|
3
|
+
raise "Stack level: #{STACK_DEPTH_SCRIPT}" rescue puts $!.backtrace.join("\n")
|
4
|
+
|
3
5
|
require 'ruboto/activity'
|
6
|
+
require 'ruboto/widget'
|
4
7
|
|
5
8
|
ruboto_import_widgets :Button, :LinearLayout, :TextView
|
6
9
|
|
7
10
|
class StackActivity
|
8
11
|
STACK_DEPTH_CLASS = java.lang.Thread.current_thread.stack_trace.length.to_s
|
9
|
-
include Ruboto::Activity
|
10
|
-
|
11
12
|
def on_create(bundle)
|
12
13
|
stack_depth_on_create = java.lang.Thread.current_thread.stack_trace.length.to_s
|
13
14
|
setTitle File.basename(__FILE__).chomp('_activity.rb').split('_').map { |s| "#{s[0..0].upcase}#{s[1..-1]}" }.join(' ')
|
@@ -15,18 +15,20 @@ test('stack depth') do |activity|
|
|
15
15
|
if org.ruboto.JRubyAdapter.uses_platform_apk?
|
16
16
|
jruby_offset = {
|
17
17
|
'0.4.7' => [0, 0, 0, 0],
|
18
|
-
'0.4.8.dev' => [0, 0,
|
18
|
+
'0.4.8.dev' => [0, 0, -4, -4],
|
19
19
|
}[org.ruboto.JRubyAdapter.platform_version_name] || [0, 0, 0, 0]
|
20
20
|
else # STANDALONE
|
21
21
|
jruby_offset = {
|
22
22
|
'1.7.0.dev' => [1, 1, 1, 1],
|
23
|
-
'1.7.0.
|
24
|
-
'1.7.0.preview2.dev' => [0, 0, 0, 0],
|
23
|
+
'1.7.0.preview2' => [0, 0, -4, -4],
|
25
24
|
}[org.jruby.runtime.Constants::VERSION] || [0, 0, 0, 0]
|
26
25
|
end
|
27
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}"
|
28
|
-
assert_equal 43 + os_offset + jruby_offset[0],
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
assert_equal [43 + os_offset + jruby_offset[0],
|
28
|
+
48 + os_offset + jruby_offset[1],
|
29
|
+
49 + os_offset + jruby_offset[2],
|
30
|
+
66 + os_offset + jruby_offset[3]], [activity.find_view_by_id(42).text.to_i,
|
31
|
+
activity.find_view_by_id(43).text.to_i,
|
32
|
+
activity.find_view_by_id(44).text.to_i,
|
33
|
+
activity.find_view_by_id(45).text.to_i], version_message
|
32
34
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'ruboto'
|
2
|
+
|
3
|
+
ruboto_import_widgets :LinearLayout, :TextView
|
4
|
+
|
5
|
+
$activity.start_ruboto_activity do
|
6
|
+
setTitle File.basename(__FILE__).chomp('_activity.rb').split('_').map { |s| "#{s[0..0].upcase}#{s[1..-1]}" }.join(' ')
|
7
|
+
|
8
|
+
def on_create(bundle)
|
9
|
+
self.content_view =
|
10
|
+
linear_layout :orientation => LinearLayout::VERTICAL do
|
11
|
+
@text_view_margins = text_view :text => 'What hath Matz wrought?', :id => 42, :margins => [100,0,0,0]
|
12
|
+
@text_view_layout = text_view :text => 'What hath Matz wrought?', :id => 43, :layout => {:set_margins => [100,0,0,0]}
|
13
|
+
@text_view_fieldset = text_view :text => 'What hath Matz wrought?', :id => 44, :layout => {:left_margin= => 100}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
activity Java::org.ruboto.test_app.MarginsActivity
|
2
|
+
|
3
|
+
setup do |activity|
|
4
|
+
start = Time.now
|
5
|
+
loop do
|
6
|
+
@text_view_margins = activity.findViewById(42)
|
7
|
+
@text_view_layout = activity.findViewById(43)
|
8
|
+
@text_view_fieldset = activity.findViewById(44)
|
9
|
+
break if @text_view_margins || @text_view_layout || @text_view_fieldset || (Time.now - start > 60)
|
10
|
+
sleep 1
|
11
|
+
end
|
12
|
+
assert @text_view_margins
|
13
|
+
assert @text_view_layout
|
14
|
+
assert @text_view_fieldset
|
15
|
+
end
|
16
|
+
|
17
|
+
def left_margin(view)
|
18
|
+
view.get_layout_params.leftMargin
|
19
|
+
end
|
20
|
+
|
21
|
+
%w(margins layout fieldset).each do |view_type|
|
22
|
+
test("margins are set through #{view_type}") do |activity|
|
23
|
+
assert_equal 100, left_margin(instance_variable_get("@text_view_#{view_type}"))
|
24
|
+
end
|
25
|
+
end
|
@@ -13,6 +13,5 @@ end
|
|
13
13
|
test('option_menu changes text') do |activity|
|
14
14
|
assert_equal "What hath Matz wrought?", @text_view.text
|
15
15
|
activity.window.performPanelIdentifierAction(android.view.Window::FEATURE_OPTIONS_PANEL, 0, 0)
|
16
|
-
|
17
|
-
assert_equal("What hath Matz wrought!", @text_view.text) if RUBY_VERSION < '1.9'
|
16
|
+
assert_equal("What hath Matz wrought!", @text_view.text)
|
18
17
|
end
|
@@ -20,12 +20,15 @@ test('stack depth') do |activity|
|
|
20
20
|
else # STANDALONE
|
21
21
|
jruby_offset = {
|
22
22
|
'1.7.0.preview1' => [0, -1, -1, -1],
|
23
|
-
'1.7.0.preview2
|
23
|
+
'1.7.0.preview2' => [0, -1, 0, 0],
|
24
24
|
}[org.jruby.runtime.Constants::VERSION] || [0, 0, 0, 0]
|
25
25
|
end
|
26
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],
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
assert_equal [43 + os_offset + jruby_offset[0],
|
28
|
+
78 + os_offset + jruby_offset[1],
|
29
|
+
61 + os_offset + jruby_offset[2],
|
30
|
+
78 + os_offset + jruby_offset[3]], [activity.find_view_by_id(42).text.to_i,
|
31
|
+
activity.find_view_by_id(43).text.to_i,
|
32
|
+
activity.find_view_by_id(44).text.to_i,
|
33
|
+
activity.find_view_by_id(45).text.to_i], version_message
|
31
34
|
end
|