ruboto 0.15.0 → 0.16.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.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +4 -1
  3. data/README.md +44 -43
  4. data/RELEASE_CANDICATE_DOC +10 -12
  5. data/RELEASE_DOC +69 -37
  6. data/Rakefile +47 -27
  7. data/assets/rakelib/ruboto.rake +69 -26
  8. data/assets/src/RubotoActivity.java +17 -4
  9. data/assets/src/RubotoService.java +18 -0
  10. data/assets/src/org/ruboto/EntryPointActivity.java +1 -1
  11. data/assets/src/org/ruboto/JRubyAdapter.java +3 -1
  12. data/assets/src/org/ruboto/ScriptLoader.java +27 -4
  13. data/assets/src/ruboto/activity.rb +4 -3
  14. data/assets/src/ruboto/activity/reload.rb +17 -12
  15. data/assets/src/ruboto/widget.rb +18 -18
  16. data/bin/elevate.exe +0 -0
  17. data/bin/elevate_32.exe +0 -0
  18. data/lib/java_class_gen/android_api.xml +1 -1
  19. data/lib/ruboto/commands/base.rb +3 -5
  20. data/lib/ruboto/util/build.rb +1 -1
  21. data/lib/ruboto/util/emulator.rb +31 -5
  22. data/lib/ruboto/util/setup.rb +183 -68
  23. data/lib/ruboto/util/update.rb +35 -42
  24. data/lib/ruboto/util/xml_element.rb +45 -33
  25. data/lib/ruboto/version.rb +1 -1
  26. data/test/activity/call_super_activity.rb +1 -1
  27. data/test/activity/dialog_fragment_activity.rb +37 -0
  28. data/test/activity/dialog_fragment_activity_test.rb +19 -0
  29. data/test/activity/image_button_activity.rb +2 -1
  30. data/test/activity/navigation_activity_test.rb +2 -1
  31. data/test/activity/no_on_create_activity.rb +17 -0
  32. data/test/activity/no_on_create_activity_test.rb +15 -0
  33. data/test/activity/spinner_activity.rb +51 -0
  34. data/test/activity/spinner_activity_test.rb +65 -0
  35. data/test/activity/stack_activity_test.rb +14 -7
  36. data/test/activity/startup_exception_activity.rb +7 -5
  37. data/test/activity/startup_exception_activity_test.rb +2 -2
  38. data/test/app_test_methods.rb +4 -0
  39. data/test/git_based_gem_test.rb +64 -0
  40. data/test/minimal_app_test.rb +12 -13
  41. data/test/rake_test.rb +1 -0
  42. data/test/ruboto_gen_test.rb +21 -15
  43. data/test/ruboto_update_test.rb +23 -6
  44. data/test/sqldroid_test.rb +0 -1
  45. data/test/test_helper.rb +37 -19
  46. metadata +25 -2
@@ -353,6 +353,10 @@ module Ruboto
353
353
 
354
354
  def update_core_classes(force = nil)
355
355
  generate_core_classes(:class => 'all', :method_base => 'on', :method_include => '', :method_exclude => '', :force => force, :implements => '')
356
+ if File.exists?('ruboto.yml')
357
+ FileUtils.touch 'ruboto.yml'
358
+ system 'rake jruby_adapter'
359
+ end
356
360
  end
357
361
 
358
362
  def read_ruboto_version
@@ -407,7 +411,7 @@ module Ruboto
407
411
  `jar -xf #{jruby_core}`
408
412
  raise "Unpacking jruby-core jar failed: #$?" unless $? == 0
409
413
  File.delete jruby_core
410
- if Gem::Version.new(jruby_core_version) >= Gem::Version.new('1.7.5.dev')
414
+ if Gem::Version.new(jruby_core_version) >= Gem::Version.new('9000.dev')
411
415
  #noinspection RubyLiteralArrayInspection
412
416
  excluded_core_packages = [
413
417
  '**/*Darwin*',
@@ -439,7 +443,6 @@ module Ruboto
439
443
  'jnr/posix/OpenBSD*',
440
444
  'jnr/x86asm',
441
445
  'org/jruby/ant',
442
- 'org/jruby/cext',
443
446
  # 'org/jruby/compiler', # Needed for initialization, but should not be necessary
444
447
  # 'org/jruby/compiler/impl', # Needed for initialization, but should not be necessary
445
448
  'org/jruby/compiler/impl/BaseBodyCompiler*',
@@ -448,11 +451,7 @@ module Ruboto
448
451
  'org/jruby/embed/bsf',
449
452
  'org/jruby/embed/jsr223',
450
453
  'org/jruby/embed/osgi',
451
- # 'org/jruby/ext/ffi', # Used by several JRuby core classes, but should not be needed unless we add FFI support
452
- 'org/jruby/ext/ffi/AbstractMemory*',
453
- 'org/jruby/ext/ffi/io',
454
- 'org/jruby/ext/ffi/jffi',
455
- 'org/jruby/ext/tracepoint',
454
+ # 'org/jruby/ext/tracepoint',
456
455
  'org/jruby/javasupport/bsf',
457
456
  # 'org/jruby/management', # should be excluded
458
457
  # 'org/jruby/runtime/invokedynamic', # Should be excluded
@@ -460,6 +459,8 @@ module Ruboto
460
459
  # 'org/jruby/runtime/opto/OptoFactory*', # What is this?
461
460
  'org/yecht',
462
461
  ]
462
+ elsif Gem::Version.new(jruby_core_version) >= Gem::Version.new('1.7.5')
463
+ excluded_core_packages = %w(**/*Darwin* **/*Solaris* **/*windows* **/*Windows* META-INF com/headius com/kenai/constantine com/kenai/jffi com/kenai/jnr/x86asm com/martiansoftware jni jnr/constants/platform/darwin jnr/constants/platform/fake jnr/constants/platform/freebsd jnr/constants/platform/openbsd jnr/constants/platform/sunos jnr/ffi/annotations jnr/ffi/byref jnr/ffi/mapper jnr/ffi/provider jnr/ffi/util jnr/ffi/Struct$* jnr/ffi/types jnr/posix/Aix* jnr/posix/FreeBSD* jnr/posix/MacOS* jnr/posix/OpenBSD* jnr/x86asm org/jruby/ant org/jruby/cext org/jruby/compiler/impl/BaseBodyCompiler* org/jruby/compiler/util org/jruby/demo org/jruby/embed/bsf org/jruby/embed/jsr223 org/jruby/embed/osgi org/jruby/ext/ffi/AbstractMemory* org/jruby/ext/ffi/io org/jruby/ext/ffi/jffi org/jruby/ext/tracepoint org/jruby/javasupport/bsf org/yecht)
463
464
  elsif Gem::Version.new(jruby_core_version) >= Gem::Version.new('1.7.4')
464
465
  excluded_core_packages = %w(**/*Darwin* **/*Solaris* **/*windows* **/*Windows* META-INF com/headius com/kenai/constantine com/kenai/jffi com/kenai/jnr/x86asm com/martiansoftware jline jni jnr/constants/platform/darwin jnr/constants/platform/fake jnr/constants/platform/freebsd jnr/constants/platform/openbsd jnr/constants/platform/sunos jnr/ffi/annotations jnr/ffi/byref jnr/ffi/mapper jnr/ffi/provider jnr/ffi/util jnr/ffi/Struct$* jnr/ffi/types jnr/posix/Aix* jnr/posix/FreeBSD* jnr/posix/MacOS* jnr/posix/OpenBSD* jnr/x86asm org/apache org/fusesource org/jruby/ant org/jruby/cext org/jruby/compiler/impl/BaseBodyCompiler* org/jruby/compiler/util org/jruby/demo org/jruby/embed/bsf org/jruby/embed/jsr223 org/jruby/embed/osgi org/jruby/ext/ffi/AbstractMemory* org/jruby/ext/ffi/io org/jruby/ext/ffi/jffi org/jruby/ext/ripper org/jruby/ext/tracepoint org/jruby/javasupport/bsf org/yecht)
465
466
  elsif Gem::Version.new(jruby_core_version) >= Gem::Version.new('1.7.3')
@@ -535,8 +536,8 @@ module Ruboto
535
536
  # - Moves ruby stdlib to the root of the jruby-stdlib jar
536
537
  def reconfigure_jruby_stdlib
537
538
  min_sdk_version = verify_manifest.elements['uses-sdk'].attributes['android:minSdkVersion'].to_i
538
- included_stdlibs = verify_ruboto_config[:included_stdlibs]
539
- excluded_stdlibs = [*verify_ruboto_config[:excluded_stdlibs]].compact
539
+ included_stdlibs = verify_ruboto_config['included_stdlibs']
540
+ excluded_stdlibs = [*verify_ruboto_config['excluded_stdlibs']].compact
540
541
  Dir.chdir 'libs' do
541
542
  jruby_stdlib = Dir['jruby-stdlib-*.jar'][-1]
542
543
  log_action("Reformatting #{jruby_stdlib}") do
@@ -551,45 +552,37 @@ module Ruboto
551
552
  FileUtils.move 'old/META-INF/jruby.home/lib', 'new/jruby.home/lib'
552
553
  FileUtils.rm_rf 'new/jruby.home/lib/ruby/gems'
553
554
 
554
- jruby_stdlib_version = Gem::Version.new(JRubyJars::VERSION)
555
-
556
- if included_stdlibs
557
- lib_dirs = %w(1.8 1.9 2.0 shared)
558
-
559
- # FIXME(uwe): Remove when we stop testing JRuby < 1.7.4.dev
560
- lib_dirs.delete('2.0') if jruby_stdlib_version < Gem::Version.new('1.7.4.dev')
561
- # EMXIF
562
-
563
- print 'excluded...'
564
- lib_dirs.each do |ld|
565
- Dir.chdir "new/jruby.home/lib/ruby/#{ld}" do
566
- libs = Dir['*'].map { |d| d.sub /\.(rb|jar)$/, '' }.uniq
567
- libs.each do |d|
568
- next if included_stdlibs.include? d
569
- FileUtils.rm_rf d if File.exists? d
570
- file = "#{d}.rb"
571
- FileUtils.rm_rf file if File.exists? file
572
- jarfile = "#{d}.jar"
573
- FileUtils.rm_rf jarfile if File.exists? jarfile
574
- print "#{d}..."
555
+ Dir.chdir 'new/jruby.home/lib/ruby' do
556
+ ruby_stdlib_versions = Dir['*'] - %w(gems)
557
+ if included_stdlibs
558
+ print 'excluded...'
559
+ ruby_stdlib_versions.each do |ld|
560
+ Dir.chdir ld do
561
+ libs = Dir['*'].map { |d| d.sub /\.(rb|jar)$/, '' }.uniq
562
+ libs.each do |d|
563
+ next if included_stdlibs.include? d
564
+ FileUtils.rm_rf d if File.exists? d
565
+ file = "#{d}.rb"
566
+ FileUtils.rm_rf file if File.exists? file
567
+ jarfile = "#{d}.jar"
568
+ FileUtils.rm_rf jarfile if File.exists? jarfile
569
+ print "#{d}..."
570
+ end
575
571
  end
576
572
  end
577
573
  end
578
- end
579
574
 
580
- if excluded_stdlibs.any?
581
- %w(1.8 1.9 2.0 shared).each do |ld|
582
- # FIXME(uwe): Remove when we stop testing JRuby < 1.7.4.dev
583
- next if ld == '2.0' && jruby_stdlib_version < Gem::Version.new('1.7.4.dev')
584
- # EMXIF
585
- excluded_stdlibs.each do |d|
586
- dir = "new/jruby.home/lib/ruby/#{ld}/#{d}"
587
- FileUtils.rm_rf dir if File.exists? dir
588
- file = "#{dir}.rb"
589
- FileUtils.rm_rf file if File.exists? file
575
+ if excluded_stdlibs.any?
576
+ ruby_stdlib_versions.each do |ld|
577
+ excluded_stdlibs.each do |d|
578
+ dir = "#{ld}/#{d}"
579
+ FileUtils.rm_rf dir if File.exists? dir
580
+ file = "#{dir}.rb"
581
+ FileUtils.rm_rf file if File.exists? file
582
+ end
590
583
  end
584
+ print "excluded #{excluded_stdlibs.join(' ')}..."
591
585
  end
592
- print "excluded #{excluded_stdlibs.join(' ')}..."
593
586
  end
594
587
 
595
588
  Dir.chdir 'new' do
@@ -44,12 +44,12 @@ module Ruboto
44
44
  def find_class_or_interface(klass, a_type)
45
45
  abort "ERROR: Can't parse package from #{klass}" unless klass.match(/([a-z.]+)\.([A-Z][A-Za-z.]+)/)
46
46
 
47
- package = self['package'].find{|i| i.attribute('name') == $1}
47
+ package = self['package'].find { |i| i.attribute('name') == $1 }
48
48
  abort "ERROR: Can't find package #{$1}" unless package
49
49
  if a_type == 'either'
50
- package['class'].find{|i| i.attribute('name') == $2} or package['interface'].find{|i| i.attribute('name') == $2}
50
+ package['class'].find { |i| i.attribute('name') == $2 } or package['interface'].find { |i| i.attribute('name') == $2 }
51
51
  else
52
- package[a_type].find{|i| i.attribute('name') == $2}
52
+ package[a_type].find { |i| i.attribute('name') == $2 }
53
53
  end
54
54
  end
55
55
 
@@ -63,37 +63,37 @@ module Ruboto
63
63
 
64
64
  def all_methods(method_base='all', method_include='', method_exclude='', implements='')
65
65
  # get all the methogs
66
- all_methods = get_elements('method').select{|m| m.attribute('static') != 'true'}
66
+ all_methods = get_elements('method').select { |m| m.attribute('static') != 'true' }
67
67
 
68
68
  # establish the base set of methods
69
69
  working_methods = case method_base.to_s
70
- when 'all' then
71
- all_methods
72
- when 'none' then
73
- []
74
- when 'abstract' then
75
- all_methods.select{|i| i.attribute('abstract') == 'true'}
76
- when 'on' then
77
- all_methods.select{|i| i.attribute('name').match(/^on[A-Z]/)}
78
- end
70
+ when 'all' then
71
+ all_methods
72
+ when 'none' then
73
+ []
74
+ when 'abstract' then
75
+ all_methods.select { |i| i.attribute('abstract') == 'true' }
76
+ when 'on' then
77
+ all_methods.select { |i| i.attribute('name').match(/^on[A-Z]/) }
78
+ end
79
79
 
80
80
  # make sure to include requested methods
81
81
  include_methods = method_include.split(',') if method_include.is_a?(String)
82
- all_methods.each{|i| working_methods << i if include_methods.include?(i.attribute('name'))}
82
+ all_methods.each { |i| working_methods << i if include_methods.include?(i.attribute('name')) }
83
83
 
84
84
  # make sure to exclude rejected methods
85
85
  exclude_methods = method_exclude.split(',') if method_exclude.is_a?(String)
86
- working_methods = working_methods.select{|i| not exclude_methods.include?(i.attribute('name'))}
86
+ working_methods = working_methods.select { |i| not exclude_methods.include?(i.attribute('name')) }
87
87
 
88
88
  # remove methods marked final
89
- working_methods = working_methods.select{|i| (not i.attribute('final')) or i.attribute('final') == 'false'}
89
+ working_methods = working_methods.select { |i| (not i.attribute('final')) or i.attribute('final') == 'false' }
90
90
 
91
91
  # get additional methods from parent
92
92
  if name =='class' and attribute('extends')
93
93
  parent = root.find_class(attribute('extends'))
94
94
  parent_methods = parent.all_methods(method_base, method_include, method_exclude)
95
95
  working_signatures = working_methods.map(&:method_signature)
96
- working_methods += parent_methods.select{|i| not working_signatures.include?(i.method_signature)}
96
+ working_methods += parent_methods.select { |i| not working_signatures.include?(i.method_signature) }
97
97
  end
98
98
 
99
99
  # get additional methods from interfaces
@@ -102,7 +102,7 @@ module Ruboto
102
102
  interface = root.find_interface(i)
103
103
  abort("Unkown interface: #{i}") unless interface
104
104
  working_signatures = working_methods.map(&:method_signature)
105
- working_methods += interface.all_methods.select{|j| not working_signatures.include?(j.method_signature)}
105
+ working_methods += interface.all_methods.select { |j| not working_signatures.include?(j.method_signature) }
106
106
  end
107
107
  end
108
108
 
@@ -110,37 +110,40 @@ module Ruboto
110
110
  end
111
111
 
112
112
  def parameters
113
- get_elements('parameter').map {|p| [p.attribute('name'), p.attribute('type').gsub('&lt;', '<').gsub('&gt;', '>')]}
113
+ get_elements('parameter').map { |p| [p.attribute('name'), p.attribute('type').gsub('&lt;', '<').gsub('&gt;', '>')] }
114
114
  end
115
115
 
116
116
  def method_signature
117
- "#{attribute('name')}(#{parameters.map{|i| i[1]}.join(',')})"
117
+ "#{attribute('name')}(#{parameters.map { |i| i[1] }.join(',')})"
118
118
  end
119
119
 
120
120
  def constant_string
121
- 'CB_' + attribute('name').gsub(/[A-Z]/) {|i| "_#{i}"}.upcase.gsub(/^ON_/, '')
121
+ 'CB_' + attribute('name').gsub(/[A-Z]/) { |i| "_#{i}" }.upcase.gsub(/^ON_/, '')
122
122
  end
123
123
 
124
124
  def super_string
125
125
  if attribute('api_added') and
126
- attribute('api_added').to_i > verify_min_sdk.to_i and
127
- attribute('api_added').to_i <= verify_target_sdk.to_i
126
+ attribute('api_added').to_i > verify_min_sdk.to_i and
127
+ attribute('api_added').to_i <= verify_target_sdk.to_i
128
128
  nil
129
129
  elsif attribute('abstract') == 'true'
130
130
  nil
131
131
  elsif name == 'method'
132
- "super.#{attribute('name')}(#{parameters.map{|i| i[0]}.join(', ')});"
132
+ "super.#{attribute('name')}(#{parameters.map { |i| i[0] }.join(', ')});"
133
133
  elsif name == 'constructor'
134
- "super(#{parameters.map{|i| i[0]}.join(', ')});"
134
+ "super(#{parameters.map { |i| i[0] }.join(', ')});"
135
135
  end
136
136
  end
137
137
 
138
138
  def default_return
139
139
  return nil unless attribute('return')
140
140
  case attribute('return')
141
- when 'boolean' then 'return false;'
142
- when 'int' then 'return 0;'
143
- when 'void' then nil
141
+ when 'boolean' then
142
+ 'return false;'
143
+ when 'int' then
144
+ 'return 0;'
145
+ when 'void' then
146
+ nil
144
147
  else
145
148
  'return null;'
146
149
  end
@@ -152,7 +155,7 @@ module Ruboto
152
155
  rv ? "return #{rv}" : default_return
153
156
  end
154
157
 
155
- def ruby_call(camelize = false)
158
+ def ruby_call(snake_case = false)
156
159
  params = parameters
157
160
  args = ''
158
161
  if params.size > 1
@@ -175,7 +178,7 @@ module Ruboto
175
178
  convert_return = "#{return_class.sub(/<.*>$/, '')}.class, "
176
179
  end
177
180
 
178
- method_name = camelize ? attribute('name') : snake_case_attribute
181
+ method_name = snake_case ? snake_case_attribute : attribute('name')
179
182
  ["#{return_cast}JRubyAdapter.runRubyMethod(#{convert_return}scriptInfo.getRubyInstance(), \"#{method_name}\"#{args});"]
180
183
  end
181
184
 
@@ -195,12 +198,21 @@ module Ruboto
195
198
  'String rubyClassName = scriptInfo.getRubyClassName();',
196
199
  "if (rubyClassName == null) #{super_return}",
197
200
  if_else(
198
- "(Boolean)JRubyAdapter.runScriptlet(rubyClassName + \".instance_methods(false).any?{|m| m.to_sym == :#{snake_case_attribute}}\")",
201
+ "(Boolean)JRubyAdapter.runScriptlet(rubyClassName + \".instance_methods(false).any?{|m| m.to_sym == :#{attribute('name')}}\")",
199
202
  ruby_call,
200
203
  if_else(
201
- "(Boolean)JRubyAdapter.runScriptlet(rubyClassName + \".instance_methods(false).any?{|m| m.to_sym == :#{attribute('name')}}\")",
204
+ "(Boolean)JRubyAdapter.runScriptlet(rubyClassName + \".instance_methods(false).any?{|m| m.to_sym == :#{snake_case_attribute}}\")",
202
205
  ruby_call(true),
203
- [super_return]
206
+ if_else(
207
+ "(Boolean)JRubyAdapter.runScriptlet(rubyClassName + \".instance_methods(true).any?{|m| m.to_sym == :#{snake_case_attribute}}\")",
208
+ ruby_call(true),
209
+ # FIXME(uwe): Can the method be unimplemented? Is the Ruby instance always an instance of this class?
210
+ #if_else(
211
+ # "(Boolean)JRubyAdapter.runScriptlet(rubyClassName + \".instance_methods(true).any?{|m| m.to_sym == :#{attribute('name')}}\")",
212
+ ruby_call,
213
+ # [super_return]
214
+ #)
215
+ )
204
216
  )
205
217
  )
206
218
  ]
@@ -1,4 +1,4 @@
1
1
  module Ruboto
2
- VERSION = '0.15.0'
2
+ VERSION = '0.16.0'
3
3
  UPDATE_VERSION_LIMIT = '0.7.0'
4
4
  end
@@ -20,7 +20,7 @@ class CallSuperActivity
20
20
  end
21
21
 
22
22
  # FIXME(uwe): We should test that super is not called implicitly
23
- # def on_resume
23
+ # def onResume
24
24
  # super
25
25
  # end
26
26
 
@@ -0,0 +1,37 @@
1
+ require 'ruboto/widget'
2
+
3
+ ruboto_import_widgets :LinearLayout, :TextView
4
+
5
+ class DialogFragmentActivity
6
+ def onCreate(bundle)
7
+ super
8
+ set_title 'Dialog Fragment Test'
9
+
10
+ self.content_view =
11
+ linear_layout :orientation => :vertical, :gravity => :center do
12
+ text_view :id => 42, :text => title, :text_size => 48.0,
13
+ :gravity => :center
14
+ end
15
+ ft = getFragmentManager.beginTransaction
16
+ ft.addToBackStack(nil)
17
+ ExampleDialogFragment.new.show(ft, 'example_dialog')
18
+ end
19
+ end
20
+
21
+ class ExampleDialogFragment < android.app.DialogFragment
22
+ def onCreate(bundle)
23
+ super
24
+ @some_var = 'Ruboto does fragments!'
25
+ end
26
+
27
+ def onCreateView(inflater, container, bundle)
28
+ dialog.title = @some_var
29
+
30
+ linear_layout :orientation => :vertical do
31
+ linear_layout :gravity => :center, :layout => {:width= => :fill_parent} do
32
+ text_view :text => @some_var, :id => 43, :text_size => 40.0,
33
+ :gravity => :center
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,19 @@
1
+ activity org.ruboto.test_app.DialogFragmentActivity
2
+
3
+ setup do |activity|
4
+ start = Time.now
5
+ loop do
6
+ @text_view = activity.findViewById(42)
7
+ wait_for_idle_sync
8
+ fragment = activity.fragment_manager.findFragmentByTag('example_dialog')
9
+ @fragment_text = fragment.view.findViewById(43) if fragment
10
+ break if (@text_view && @fragment_text) || (Time.now - start > 60)
11
+ sleep 1
12
+ end
13
+ assert @text_view && @fragment_text
14
+ end
15
+
16
+ test 'start fragment', :ui => false do |activity|
17
+ assert_equal 'Dialog Fragment Test', @text_view.text.to_s
18
+ assert_equal 'Ruboto does fragments!', @fragment_text.text.to_s
19
+ end
@@ -6,7 +6,8 @@ ruboto_import_widgets :ImageButton, :LinearLayout, :TextView
6
6
  class ImageButtonActivity
7
7
  def onCreate(bundle)
8
8
  super
9
- set_title File.basename(__FILE__).chomp('_activity.rb').split('_').map { |s| "#{s[0..0].upcase}#{s[1..-1]}" }.join(' ')
9
+ set_title File.basename(__FILE__).chomp('_activity.rb').split('_').
10
+ map { |s| "#{s[0..0].upcase}#{s[1..-1]}" }.join(' ')
10
11
 
11
12
  click_handler = proc do |view|
12
13
  @text_view.setText 'What hath Matz wrought!'
@@ -87,7 +87,8 @@ def start_activity_by_button(activity, button_id, activity_class_name = 'org.rub
87
87
  btn.request_focus
88
88
  btn.perform_click
89
89
  end
90
- current_activity = wait_for_monitor_with_timeout(monitor, 5000)
90
+ waitForIdleSync
91
+ current_activity = wait_for_monitor_with_timeout(monitor, 10000)
91
92
  ensure
92
93
  removeMonitor(monitor)
93
94
  end
@@ -0,0 +1,17 @@
1
+ require 'ruboto/widget'
2
+
3
+ ruboto_import_widgets :LinearLayout, :TextView
4
+
5
+ class NoOnCreateActivity
6
+ def onResume
7
+ super
8
+ set_title File.basename(__FILE__).chomp('_activity.rb').split('_').
9
+ map { |s| "#{s[0..0].upcase}#{s[1..-1]}" }.join(' ')
10
+
11
+ self.content_view = linear_layout :orientation => :vertical,
12
+ :gravity => android.view.Gravity::CENTER do
13
+ text_view :id => 42, :text => title, :text_size => 48.0,
14
+ :gravity => android.view.Gravity::CENTER
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,15 @@
1
+ activity org.ruboto.test_app.NoOnCreateActivity
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('activity starts without onCreate implemented') do |activity|
14
+ assert_equal 'No On Create', @text_view.text.to_s
15
+ end
@@ -0,0 +1,51 @@
1
+ require 'ruboto/widget'
2
+
3
+ ruboto_import_widgets :LinearLayout, :Spinner, :TextView
4
+
5
+ class SpinnerActivity
6
+ def onCreate(bundle)
7
+ super
8
+ set_title File.basename(__FILE__).chomp('_activity.rb').split('_').
9
+ map { |s| "#{s[0..0].upcase}#{s[1..-1]}" }.join(' ')
10
+
11
+ click_handler = proc do |parent, view, position, id|
12
+ @text_view.text = parent.adapter.get_item(position)
13
+ end
14
+
15
+ self.content_view =
16
+ linear_layout :orientation => :vertical, :gravity => :center_horizontal do
17
+ spinner :width => :match_parent, :id => 42
18
+ plain_spinner = spinner :width => :match_parent, :id => 43,
19
+ :on_item_selected_listener => click_handler
20
+ plain_spinner.adapter = android.widget.ArrayAdapter.new(self, R::layout::simple_spinner_item)
21
+
22
+ # FIXME(uwe): Simplify when we stop supporting Android < 4.0.3
23
+ if android.os.Build::VERSION::SDK_INT < 11
24
+ ['Plain Spinner', 'Plain Item'].each do |i|
25
+ plain_spinner.adapter.add(i)
26
+ end
27
+ else
28
+ plain_spinner.adapter.add_all(['Plain Spinner', 'Plain Item'])
29
+ end
30
+ # EMXIF
31
+
32
+ spinner :width => :match_parent, :id => 44,
33
+ :on_item_selected_listener => click_handler,
34
+ :adapter => android.widget.ArrayAdapter.new(self, R::layout::simple_spinner_item, ['Adapter Spinner', 'Adapter Item'])
35
+ spinner :width => :match_parent, :id => 45 ,
36
+ :on_item_selected_listener => click_handler,
37
+ :list => ['List Spinner', 'List Item']
38
+ spinner :width => :match_parent, :id => 46 ,
39
+ :on_item_selected_listener => click_handler,
40
+ :list => ['List Spinner', 'List Item'],
41
+ :item_layout => R::layout::simple_spinner_dropdown_item
42
+ spinner :width => :match_parent, :id => 47 ,
43
+ :on_item_selected_listener => click_handler,
44
+ :list => ['List Spinner', 'List Item'],
45
+ :item_layout => R::layout::simple_spinner_dropdown_item,
46
+ :dropdown_layout => R::layout::simple_spinner_item
47
+ @text_view = text_view :text => 'Spinning?', :id => 69, :width => :match_parent,
48
+ :gravity => :center, :text_size => 48.0
49
+ end
50
+ end
51
+ end