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
data/lib/ruboto/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module Ruboto
|
2
|
-
VERSION = '0.
|
3
|
-
end
|
2
|
+
VERSION = '0.7.0'
|
3
|
+
end
|
@@ -1,21 +1,24 @@
|
|
1
|
-
require 'ruboto'
|
1
|
+
require 'ruboto/activity'
|
2
2
|
|
3
3
|
ruboto_import_widgets :ImageButton, :LinearLayout, :TextView
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
class ImageButtonActivity
|
6
|
+
include Ruboto::Activity
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
@text_view = text_view :text => 'What hath Matz wrought?', :id => 42
|
11
|
-
image_button :image_resource => $package.R::drawable::icon, :width => :wrap_content, :id => 43
|
12
|
-
end
|
13
|
-
end
|
8
|
+
def on_create(bundle)
|
9
|
+
set_title File.basename(__FILE__).chomp('_activity.rb').split('_').map { |s| "#{s[0..0].upcase}#{s[1..-1]}" }.join(' ')
|
14
10
|
|
15
|
-
|
16
|
-
if view.id == 43
|
11
|
+
click_handler = proc do |view|
|
17
12
|
@text_view.setText 'What hath Matz wrought!'
|
18
13
|
toast 'Flipped a bit via butterfly'
|
19
14
|
end
|
15
|
+
|
16
|
+
self.content_view =
|
17
|
+
linear_layout :orientation => LinearLayout::VERTICAL, :gravity => android.view.Gravity::CENTER_HORIZONTAL do
|
18
|
+
@text_view = text_view :text => 'What hath Matz wrought?', :id => 42, :width => :fill_parent,
|
19
|
+
:gravity => android.view.Gravity::CENTER, :text_size => 48.0
|
20
|
+
image_button :image_resource => $package.R::drawable::get_ruboto_core, :width => :wrap_content, :id => 43,
|
21
|
+
:on_click_listener => click_handler
|
22
|
+
end
|
20
23
|
end
|
21
24
|
end
|
@@ -10,12 +10,8 @@ setup do |activity|
|
|
10
10
|
assert @text_view
|
11
11
|
end
|
12
12
|
|
13
|
-
test('initial setup') do |activity|
|
14
|
-
assert_equal "What hath Matz wrought?", @text_view.text
|
15
|
-
end
|
16
|
-
|
17
13
|
test('button changes text') do |activity|
|
18
|
-
|
19
|
-
|
14
|
+
assert_equal "What hath Matz wrought?", @text_view.text
|
15
|
+
activity.findViewById(43).performClick
|
20
16
|
assert_equal "What hath Matz wrought!", @text_view.text
|
21
17
|
end
|
@@ -1,24 +1,22 @@
|
|
1
|
-
require 'ruboto'
|
1
|
+
require 'ruboto/activity'
|
2
2
|
|
3
3
|
ruboto_import_widgets :Button, :ImageButton, :LinearLayout, :TextView
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
class ImageButtonAndButtonActivity
|
6
|
+
include Ruboto::Activity
|
7
7
|
|
8
|
-
|
9
|
-
|
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::icon, :width => :wrap_content, :id => 43
|
13
|
-
end
|
14
|
-
end
|
8
|
+
def on_create(bundle)
|
9
|
+
setTitle File.basename(__FILE__).chomp('_activity.rb').split('_').map { |s| "#{s[0..0].upcase}#{s[1..-1]}" }.join(' ')
|
15
10
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
11
|
+
self.content_view =
|
12
|
+
linear_layout :orientation => LinearLayout::VERTICAL, :gravity => android.view.Gravity::CENTER_HORIZONTAL do
|
13
|
+
@text_view = text_view :text => 'What hath Matz wrought?', :id => 42, :text_size => 48.0,
|
14
|
+
:width => :fill_parent, :gravity => android.view.Gravity::CENTER
|
15
|
+
button :text => 'Button', :id => 44, :text_size => 48.0,
|
16
|
+
:width => :fill_parent, :gravity => android.view.Gravity::CENTER,
|
17
|
+
:on_click_listener => proc { @text_view.text = 'Button pressed' }
|
18
|
+
image_button :image_resource => $package.R::drawable::get_ruboto_core, :id => 43, :width => :wrap_content,
|
19
|
+
:on_click_listener => proc { @text_view.text = 'Image button pressed' }
|
20
|
+
end
|
22
21
|
end
|
23
|
-
|
24
22
|
end
|
@@ -10,18 +10,14 @@ setup do |activity|
|
|
10
10
|
assert @text_view
|
11
11
|
end
|
12
12
|
|
13
|
-
test('initial setup') do |activity|
|
14
|
-
assert_equal "What hath Matz wrought?", @text_view.text
|
15
|
-
end
|
16
|
-
|
17
13
|
test('button changes text') do |activity|
|
18
|
-
|
19
|
-
|
14
|
+
assert_equal "What hath Matz wrought?", @text_view.text
|
15
|
+
activity.find_view_by_id(44).perform_click
|
20
16
|
assert_equal 'Button pressed', @text_view.text
|
21
17
|
end
|
22
18
|
|
23
19
|
test('image button changes text') do |activity|
|
24
|
-
|
25
|
-
|
20
|
+
assert_equal "What hath Matz wrought?", @text_view.text
|
21
|
+
activity.find_view_by_id(43).perform_click
|
26
22
|
assert_equal 'Image button pressed', @text_view.text
|
27
23
|
end
|
@@ -1,23 +1,28 @@
|
|
1
1
|
require 'ruboto/activity'
|
2
2
|
require 'ruboto/widget'
|
3
|
-
require 'ruboto/legacy'
|
4
|
-
require 'ruboto/menu'
|
5
3
|
require 'ruboto/util/toast'
|
6
4
|
|
7
|
-
ruboto_import_widgets :
|
5
|
+
ruboto_import_widgets :LinearLayout, :TextView
|
8
6
|
|
9
|
-
|
10
|
-
|
7
|
+
class OptionMenuActivity
|
8
|
+
include Ruboto::Activity
|
11
9
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
10
|
+
def on_create(bundle)
|
11
|
+
set_title File.basename(__FILE__).chomp('_activity.rb').split('_').map { |s| "#{s[0..0].upcase}#{s[1..-1]}" }.join(' ')
|
12
|
+
|
13
|
+
self.content_view =
|
14
|
+
linear_layout :orientation => LinearLayout::VERTICAL do
|
15
|
+
@text_view = text_view :text => 'What hath Matz wrought?', :id => 42, :text_size => 48.0,
|
16
|
+
:width => :fill_parent, :gravity => android.view.Gravity::CENTER
|
17
|
+
end
|
16
18
|
end
|
17
19
|
|
18
|
-
|
19
|
-
|
20
|
-
|
20
|
+
def on_create_options_menu(menu)
|
21
|
+
mi = menu.add('Test')
|
22
|
+
# mi.icon = $package.R::drawable::get_ruboto_core
|
23
|
+
mi.setIcon($package.R::drawable::get_ruboto_core)
|
24
|
+
mi.set_on_menu_item_click_listener do |menu_item|
|
25
|
+
@text_view.text = 'What hath Matz wrought!'
|
21
26
|
toast 'Flipped a bit via butterfly'
|
22
27
|
end
|
23
28
|
true
|
@@ -10,11 +10,8 @@ setup do |activity|
|
|
10
10
|
assert @text_view
|
11
11
|
end
|
12
12
|
|
13
|
-
test('initial setup') do |activity|
|
14
|
-
assert_equal "What hath Matz wrought?", @text_view.text
|
15
|
-
end
|
16
|
-
|
17
13
|
test('option_menu changes text') do |activity|
|
14
|
+
assert_equal "What hath Matz wrought?", @text_view.text
|
18
15
|
activity.window.performPanelIdentifierAction(android.view.Window::FEATURE_OPTIONS_PANEL, 0, 0)
|
19
16
|
assert_equal "What hath Matz wrought!", @text_view.text
|
20
17
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
# TODO(uwe): Remove when we stop supporting Ruby 1.8 mode
|
2
|
-
if RUBY_VERSION <
|
1
|
+
# TODO(uwe): Remove when we stop supporting psych with Ruby 1.8 mode
|
2
|
+
if RUBY_VERSION < '1.9'
|
3
3
|
require 'jruby'
|
4
4
|
require 'rbconfig'
|
5
5
|
org.jruby.ext.psych.PsychLibrary.new.load(JRuby.runtime, false)
|
@@ -8,23 +8,30 @@ if RUBY_VERSION < "1.9"
|
|
8
8
|
end
|
9
9
|
# TODO end
|
10
10
|
|
11
|
-
|
11
|
+
require 'ruboto/activity'
|
12
|
+
require 'ruboto/util/stack'
|
13
|
+
with_large_stack { require 'psych.rb' }
|
12
14
|
|
13
15
|
Psych::Parser
|
14
16
|
Psych::Handler
|
15
17
|
|
16
|
-
require 'ruboto'
|
17
|
-
|
18
18
|
ruboto_import_widgets :Button, :LinearLayout, :TextView
|
19
19
|
|
20
|
-
|
21
|
-
|
20
|
+
class PsychActivity
|
21
|
+
include Ruboto::Activity
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
23
|
+
def on_create(bundle)
|
24
|
+
set_title File.basename(__FILE__).chomp('_activity.rb').split('_').map { |s| "#{s[0..0].upcase}#{s[1..-1]}" }.join(' ')
|
25
|
+
self.content_view =
|
26
|
+
linear_layout :orientation => LinearLayout::VERTICAL, :gravity => android.view.Gravity::CENTER do
|
27
|
+
@decoded_view = text_view :id => 42, :text => with_large_stack { Psych.load('--- foo') },
|
28
|
+
:text_size => 48.0, :gravity => android.view.Gravity::CENTER
|
29
29
|
|
30
|
+
# TODO(uwe): Simplify when we stop supporting Psych in Ruby 1.8 mode
|
31
|
+
if RUBY_VERSION >= '1.9'
|
32
|
+
@encoded_view = text_view :id => 43, :text => with_large_stack { Psych.dump('foo') },
|
33
|
+
:text_size => 48.0, :gravity => android.view.Gravity::CENTER
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
30
37
|
end
|
@@ -12,5 +12,7 @@ end
|
|
12
12
|
|
13
13
|
test('psych_encode_decode') do |activity|
|
14
14
|
assert_equal 'foo', activity.find_view_by_id(42).text.to_s
|
15
|
-
|
15
|
+
if RUBY_VERSION >= '1.9'
|
16
|
+
assert_equal "--- foo\n", activity.find_view_by_id(43).text.to_s
|
17
|
+
end
|
16
18
|
end
|
@@ -1,21 +1,24 @@
|
|
1
1
|
STACK_DEPTH_SCRIPT = java.lang.Thread.current_thread.stack_trace.length.to_s
|
2
|
-
|
2
|
+
|
3
|
+
require 'ruboto/activity'
|
3
4
|
|
4
5
|
ruboto_import_widgets :Button, :LinearLayout, :TextView
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
7
|
+
class StackActivity
|
8
|
+
STACK_DEPTH_CLASS = java.lang.Thread.current_thread.stack_trace.length.to_s
|
9
|
+
include Ruboto::Activity
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
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
|
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(' ')
|
20
14
|
|
15
|
+
self.content_view =
|
16
|
+
linear_layout :orientation => :vertical, :gravity => android.view.Gravity::CENTER 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, :text_size => 48.0, :gravity => android.view.Gravity::CENTER
|
19
|
+
text_view :id => 43, :text => STACK_DEPTH_CLASS, :text_size => 48.0, :gravity => android.view.Gravity::CENTER
|
20
|
+
text_view :id => 44, :text => stack_depth_on_create, :text_size => 48.0, :gravity => android.view.Gravity::CENTER
|
21
|
+
text_view :id => 45, :text => stack_depth_linear_layout, :text_size => 48.0, :gravity => android.view.Gravity::CENTER
|
22
|
+
end
|
23
|
+
end
|
21
24
|
end
|
@@ -11,21 +11,22 @@ setup do |activity|
|
|
11
11
|
end
|
12
12
|
|
13
13
|
test('stack depth') do |activity|
|
14
|
-
os_offset = {13 => 1, 15 => 1}[android.os.Build::VERSION::SDK_INT].to_i
|
15
|
-
if org.ruboto.
|
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
16
|
jruby_offset = {
|
17
17
|
'0.4.7' => [0, 0, 0, 0],
|
18
|
-
'0.4.8.dev' => [0,
|
19
|
-
}[org.ruboto.
|
20
|
-
else
|
18
|
+
'0.4.8.dev' => [0, 0, 0, 0],
|
19
|
+
}[org.ruboto.JRubyAdapter.platform_version_name] || [0, 0, 0, 0]
|
20
|
+
else # STANDALONE
|
21
21
|
jruby_offset = {
|
22
|
-
'1.
|
23
|
-
'1.7.0.
|
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, 0, 0, 0],
|
24
25
|
}[org.jruby.runtime.Constants::VERSION] || [0, 0, 0, 0]
|
25
26
|
end
|
26
|
-
version_message ="ANDROID: #{android.os.Build::VERSION::SDK_INT}, PLATFORM: #{org.ruboto.
|
27
|
-
assert_equal
|
28
|
-
assert_equal
|
29
|
-
assert_equal
|
30
|
-
assert_equal
|
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 48 + os_offset + jruby_offset[1], activity.find_view_by_id(43).text.to_i, version_message
|
30
|
+
assert_equal 46 + os_offset + jruby_offset[2], activity.find_view_by_id(44).text.to_i, version_message
|
31
|
+
assert_equal 79 + os_offset + jruby_offset[3], activity.find_view_by_id(45).text.to_i, version_message
|
31
32
|
end
|
data/test/app_test_methods.rb
CHANGED
@@ -4,37 +4,30 @@ module AppTestMethods
|
|
4
4
|
include RubotoTest
|
5
5
|
|
6
6
|
def test_activity_tests
|
7
|
-
|
8
|
-
if Test::Unit::TestCase::ON_JRUBY_JARS_1_5_6
|
9
|
-
puts "Skipping YAML tests on jruby-jars-1.5.6"
|
10
|
-
else
|
11
|
-
assert_code 'YamlLoads', "with_large_stack{require 'yaml'}"
|
12
|
-
end
|
13
|
-
|
7
|
+
assert_code 'YamlLoads', "with_large_stack{require 'yaml'}"
|
14
8
|
assert_code 'ReadSourceFile', 'File.read(__FILE__)'
|
15
9
|
assert_code 'DirListsFilesInApk', 'Dir["#{File.dirname(__FILE__)}/*"].each{|f| raise "File #{f.inspect} not found" unless File.exists?(f)}'
|
16
10
|
assert_code 'RepeatRubotoImport', 'ruboto_import :TextView ; ruboto_import :TextView'
|
11
|
+
run_activity_tests('activity')
|
12
|
+
end
|
17
13
|
|
18
|
-
|
19
|
-
|
20
|
-
|
14
|
+
def test_block_def_activity_tests
|
15
|
+
run_activity_tests('block_def_activity')
|
16
|
+
end
|
21
17
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
FileUtils.cp "#{snake_name}.rb", "src/"
|
27
|
-
FileUtils.cp test_src, "test/src/"
|
28
|
-
end
|
18
|
+
def test_handle_activity_tests
|
19
|
+
Dir.chdir APP_DIR do
|
20
|
+
FileUtils.rm "src/ruboto_test_app_activity.rb"
|
21
|
+
FileUtils.rm "test/src/ruboto_test_app_activity_test.rb"
|
29
22
|
end
|
30
|
-
|
23
|
+
run_activity_tests('handle_activity')
|
31
24
|
end
|
32
25
|
|
33
26
|
private
|
34
27
|
|
35
28
|
def assert_code(activity_name, code)
|
36
29
|
snake_name = activity_name.scan(/[A-Z]+[a-z]+/).map { |s| s.downcase }.join('_')
|
37
|
-
filename
|
30
|
+
filename = "src/#{snake_name}_activity.rb"
|
38
31
|
Dir.chdir APP_DIR do
|
39
32
|
system "#{RUBOTO_CMD} gen class Activity --name #{activity_name}Activity"
|
40
33
|
s = File.read(filename)
|
@@ -43,4 +36,17 @@ module AppTestMethods
|
|
43
36
|
end
|
44
37
|
end
|
45
38
|
|
39
|
+
def run_activity_tests(activity_dir)
|
40
|
+
Dir[File.expand_path("#{activity_dir}/*_test.rb", File.dirname(__FILE__))].each do |test_src|
|
41
|
+
snake_name = test_src.chomp('_test.rb')
|
42
|
+
activity_name = File.basename(snake_name).split('_').map { |s| "#{s[0..0].upcase}#{s[1..-1]}" }.join
|
43
|
+
Dir.chdir APP_DIR do
|
44
|
+
system "#{RUBOTO_CMD} gen class Activity --name #{activity_name}"
|
45
|
+
FileUtils.cp "#{snake_name}.rb", "src/"
|
46
|
+
FileUtils.cp test_src, "test/src/"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
run_app_tests
|
50
|
+
end
|
51
|
+
|
46
52
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'ruboto/activity'
|
2
|
+
require 'ruboto/widget'
|
3
|
+
require 'ruboto/util/toast'
|
4
|
+
|
5
|
+
ruboto_import_widgets :ImageButton, :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
|
+
click_handler = proc do |view|
|
12
|
+
@text_view.setText 'What hath Matz wrought!'
|
13
|
+
toast 'Flipped a bit via butterfly'
|
14
|
+
end
|
15
|
+
|
16
|
+
self.content_view =
|
17
|
+
linear_layout :orientation => LinearLayout::VERTICAL do
|
18
|
+
@text_view = text_view :text => 'What hath Matz wrought?', :id => 42
|
19
|
+
image_button :image_resource => $package.R::drawable::get_ruboto_core, :width => :wrap_content, :id => 43,
|
20
|
+
:on_click_listener => click_handler
|
21
|
+
end
|
22
|
+
end
|
23
|
+
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,20 @@
|
|
1
|
+
require 'ruboto/activity'
|
2
|
+
require 'ruboto/widget'
|
3
|
+
require 'ruboto/util/toast'
|
4
|
+
|
5
|
+
ruboto_import_widgets :Button, :ImageButton, :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
|
+
button :text => 'Button', :width => :wrap_content, :id => 44,
|
15
|
+
:on_click_listener => proc { @text_view.text = 'Button pressed' }
|
16
|
+
image_button :image_resource => $package.R::drawable::get_ruboto_core, :width => :wrap_content, :id => 43,
|
17
|
+
:on_click_listener => proc { @text_view.text = 'Image button pressed' }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|