ruboto 0.10.0.rc.0 → 0.10.0.rc.1

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.
File without changes
data/Rakefile CHANGED
@@ -2,6 +2,7 @@ $:.unshift('lib') unless $:.include?('lib')
2
2
  require 'rake/clean'
3
3
  require 'rexml/document'
4
4
  require 'ruboto/version'
5
+ require 'ruboto/description'
5
6
  require 'ruboto/sdk_versions'
6
7
  require 'uri'
7
8
  require 'net/http'
Binary file
@@ -0,0 +1,5 @@
1
+ /.idea
2
+ bin
3
+ gen
4
+ tmp
5
+ local.properties
Binary file
@@ -194,9 +194,7 @@ namespace :test do
194
194
  task :quick => :update_scripts do
195
195
  Dir.chdir('test') do
196
196
  puts 'Running quick tests'
197
- sh "#{ANT_CMD} instrument"
198
- sh "#{ANT_CMD} installi"
199
- sh "#{ANT_CMD} run-tests-quick"
197
+ sh "#{ANT_CMD} instrument install run-tests-quick"
200
198
  end
201
199
  end
202
200
  end
Binary file
@@ -35,21 +35,28 @@ public class ScriptLoader {
35
35
  + component.getScriptInfo().getRubyClassName() + ".*");
36
36
  boolean hasBackingJavaClass = component.getScriptInfo().getRubyClassName()
37
37
  .equals(component.getClass().getSimpleName());
38
- if (scriptContainsClass && !hasBackingJavaClass) {
39
- System.out.println("Script defines methods on meta class");
40
-
41
- // FIXME(uwe): Simplify when we stop support for RubotoCore 0.4.7
42
- if (JRubyAdapter.isJRubyPreOneSeven() || JRubyAdapter.isRubyOneEight()) {
43
- JRubyAdapter.put("$java_instance", component);
44
- rubyClass = JRubyAdapter.runScriptlet("class << $java_instance; self; end");
45
- } else if (JRubyAdapter.isJRubyOneSeven() && JRubyAdapter.isRubyOneNine()) {
46
- JRubyAdapter.runScriptlet("Java::" + component.getClass().getName() + ".__persistent__ = true");
47
- rubyClass = JRubyAdapter.runRubyMethod(component, "singleton_class");
38
+ if (scriptContainsClass) {
39
+ if (hasBackingJavaClass) {
40
+ if (rubyClass != null && !rubyClass.toString().startsWith("Java::")) {
41
+ System.out.println("Found Ruby class instead of Java class. Reloading.");
42
+ rubyClass = null;
43
+ }
48
44
  } else {
49
- throw new RuntimeException("Unknown JRuby/Ruby version: " + JRubyAdapter.get("JRUBY_VERSION") + "/" + JRubyAdapter.get("RUBY_VERSION"));
50
- }
51
- // EMXIF
45
+ System.out.println("Script defines methods on meta class");
52
46
 
47
+ // FIXME(uwe): Simplify when we stop support for RubotoCore 0.4.7
48
+ if (JRubyAdapter.isJRubyPreOneSeven() || JRubyAdapter.isRubyOneEight()) {
49
+ JRubyAdapter.put("$java_instance", component);
50
+ rubyClass = JRubyAdapter.runScriptlet("class << $java_instance; self; end");
51
+ } else if (JRubyAdapter.isJRubyOneSeven() && JRubyAdapter.isRubyOneNine()) {
52
+ JRubyAdapter.runScriptlet("Java::" + component.getClass().getName() + ".__persistent__ = true");
53
+ rubyClass = JRubyAdapter.runRubyMethod(component, "singleton_class");
54
+ } else {
55
+ throw new RuntimeException("Unknown JRuby/Ruby version: " + JRubyAdapter.get("JRUBY_VERSION") + "/" + JRubyAdapter.get("RUBY_VERSION"));
56
+ }
57
+ // EMXIF
58
+
59
+ }
53
60
  }
54
61
  if (rubyClass == null || !hasBackingJavaClass) {
55
62
  System.out.println("Loading script: " + component.getScriptInfo().getScriptName());
@@ -4,8 +4,8 @@ import java.io.ByteArrayOutputStream;
4
4
  import java.io.OutputStreamWriter;
5
5
 
6
6
  import com.android.dx.cf.iface.ParseException;
7
- // import com.android.dx.dex.DexFormat;
8
- // import com.android.dx.dex.DexOptions;
7
+ import com.android.dx.dex.DexFormat;
8
+ import com.android.dx.dex.DexOptions;
9
9
  import com.android.dx.dex.cf.CfOptions;
10
10
  import com.android.dx.dex.cf.CfTranslator;
11
11
  import com.android.dx.dex.code.PositionList;
@@ -15,15 +15,14 @@ import com.android.dx.dex.file.DexFile;
15
15
  public class DexClient {
16
16
  /** {@code non-null;} output file in-progress */
17
17
  private static DexFile outputDex;
18
- // private static DexOptions dexOptions = new DexOptions();
19
- // static {
20
- // dexOptions.targetApiLevel = DexFormat.API_NO_EXTENDED_OPCODES;
21
- // }
18
+ private static DexOptions dexOptions = new DexOptions();
19
+ static {
20
+ dexOptions.targetApiLevel = DexFormat.API_NO_EXTENDED_OPCODES;
21
+ }
22
22
  private final CfOptions cfOptions;
23
23
 
24
24
  public DexClient() {
25
- outputDex = new DexFile();
26
- // outputDex = new DexFile(dexOptions);
25
+ outputDex = new DexFile(dexOptions);
27
26
  cfOptions = new CfOptions();
28
27
 
29
28
  cfOptions.positionInfo = PositionList.LINES;
@@ -58,8 +57,7 @@ public class DexClient {
58
57
  private boolean processClass(String name, byte[] bytes) {
59
58
  try {
60
59
  ClassDefItem clazz;
61
- clazz = CfTranslator.translate(name, bytes, cfOptions);
62
- // clazz = CfTranslator.translate(name, bytes, cfOptions, dexOptions);
60
+ clazz = CfTranslator.translate(name, bytes, cfOptions, dexOptions);
63
61
  outputDex.add(clazz);
64
62
  return true;
65
63
  } catch (ParseException ex) {
@@ -0,0 +1,8 @@
1
+ module Ruboto
2
+ DESCRIPTION = <<EOF
3
+ Ruboto (JRuby on Android) is a platform for developing full stand-alone apps for
4
+ Android using the Ruby language and libraries. It includes support libraries
5
+ and generators for creating projects, classes, tests, and more. The complete
6
+ APIs of Android, Java, and Ruby is available to you using the Ruby language.
7
+ EOF
8
+ end
@@ -24,4 +24,4 @@ module Ruboto
24
24
  end
25
25
  end
26
26
  end
27
- end
27
+ end
@@ -362,30 +362,26 @@ module Ruboto
362
362
  `jar -xf #{jruby_core}`
363
363
  raise "Unpacking jruby-core jar failed: #$?" unless $? == 0
364
364
  File.delete jruby_core
365
- if jruby_core_version >= '1.7.0'
365
+ if Gem::Version.new(jruby_core_version) >= Gem::Version.new('1.7.1.dev')
366
366
  excluded_core_packages = [
367
367
  '**/*Darwin*',
368
+ '**/*Ruby20*',
368
369
  '**/*Solaris*',
369
370
  '**/*windows*',
370
371
  '**/*Windows*',
371
- 'META-INF', 'cext',
372
- 'com/headius', # included since we are trying to use DexClient
373
- 'com/headius/invokebinder',
372
+ 'META-INF',
373
+ 'com/headius',
374
374
  'com/kenai/constantine', 'com/kenai/jffi', 'com/martiansoftware',
375
- 'ext',
376
- 'java',
377
375
  'jline', 'jni',
378
376
  'jnr/constants/platform/darwin', 'jnr/constants/platform/fake', 'jnr/constants/platform/freebsd',
379
- 'jnr/constants/platform/openbsd', 'jnr/constants/platform/sunos', 'jnr/constants/platform/windows',
377
+ 'jnr/constants/platform/openbsd', 'jnr/constants/platform/sunos',
380
378
  'jnr/ffi/annotations', 'jnr/ffi/byref',
381
379
  'jnr/ffi/provider', 'jnr/ffi/util',
382
- 'jnr/ffi/posix/util',
383
380
  'jnr/ffi/Struct$*',
384
381
  'jnr/ffi/types',
385
382
  'jnr/posix/MacOS*',
386
383
  'jnr/posix/OpenBSD*',
387
384
  'org/apache',
388
- 'org/bouncycastle', # TODO(uwe): Issue #154 Add back when we add jruby-openssl. The bouncycastle included in Android is cripled.
389
385
  'org/fusesource',
390
386
  'org/jruby/ant',
391
387
  'org/jruby/cext',
@@ -408,10 +404,44 @@ module Ruboto
408
404
 
409
405
  # 'org/jruby/runtime/invokedynamic', # Should be excluded
410
406
  ]
411
-
412
- # TODO(uwe): Remove when we stop supporting jruby-jars < 1.7.0
413
- else
414
- print 'Retaining com.kenai.constantine and removing jnr for JRuby < 1.7.0...'
407
+ elsif Gem::Version.new(jruby_core_version) >= Gem::Version.new('1.7.0')
408
+ # TODO(uwe): Remove when we stop supporting jruby-jars 1.7.0
409
+ excluded_core_packages = [
410
+ '**/*Darwin*',
411
+ '**/*Solaris*',
412
+ '**/*windows*',
413
+ '**/*Windows*',
414
+ 'META-INF',
415
+ 'com/headius',
416
+ 'com/kenai/constantine', 'com/kenai/jffi', 'com/martiansoftware',
417
+ 'jline', 'jni',
418
+ 'jnr/constants/platform/darwin', 'jnr/constants/platform/fake', 'jnr/constants/platform/freebsd',
419
+ 'jnr/constants/platform/openbsd', 'jnr/constants/platform/sunos',
420
+ 'jnr/ffi/annotations', 'jnr/ffi/byref',
421
+ 'jnr/ffi/provider', 'jnr/ffi/util',
422
+ 'jnr/ffi/Struct$*',
423
+ 'jnr/ffi/types',
424
+ 'jnr/posix/MacOS*',
425
+ 'jnr/posix/OpenBSD*',
426
+ 'org/apache',
427
+ 'org/bouncycastle',
428
+ 'org/fusesource',
429
+ 'org/jruby/ant',
430
+ 'org/jruby/cext',
431
+ 'org/jruby/compiler/util',
432
+ 'org/jruby/demo',
433
+ 'org/jruby/embed/bsf',
434
+ 'org/jruby/embed/jsr223',
435
+ 'org/jruby/embed/osgi',
436
+ 'org/jruby/ext/ffi/io',
437
+ 'org/jruby/ext/ffi/jffi',
438
+ 'org/jruby/ext/openssl',
439
+ 'org/jruby/javasupport/bsf',
440
+ ]
441
+ # ODOT
442
+ elsif Gem::Version.new(jruby_core_version) =~ Gem::Version.new('~>1.6.0')
443
+ # TODO(uwe): Remove when we stop supporting jruby-jars 1.6.x
444
+ print 'Retaining com.kenai.constantine and removing jnr for JRuby 1.6.x...'
415
445
  excluded_core_packages = [
416
446
  'META-INF', 'cext',
417
447
  'com/kenai/jffi', 'com/martiansoftware', 'ext', 'java',
@@ -429,6 +459,8 @@ module Ruboto
429
459
  'org/jruby/runtime/invokedynamic',
430
460
  ]
431
461
  # ODOT
462
+ else
463
+ raise "Unsupported JRuby version: #{jruby_core_version.inspect}."
432
464
  end
433
465
 
434
466
  excluded_core_packages.each do |i|
@@ -544,7 +576,7 @@ module Ruboto
544
576
  File.delete dx_jar
545
577
  excluded_core_packages = [
546
578
  'com/android/dx/command',
547
- 'com/android/dx/ssa',
579
+ # 'com/android/dx/ssa', # Tests run OK without this package, but we may loose some optimizations.
548
580
  'junit',
549
581
  ]
550
582
  excluded_core_packages.each do |i|
@@ -1,10 +1,4 @@
1
1
  module Ruboto
2
- DESCRIPTION = <<EOF
3
- Ruboto (JRuby on Android) is a platform for developing full stand-alone apps for
4
- Android using the Ruby language and libraries. It includes support libraries
5
- and generators for creating projects, classes, tests, and more. The complete
6
- APIs of Android, Java, and Ruby is available to you using the Ruby language.
7
- EOF
8
- VERSION = '0.10.0.rc.0'
2
+ VERSION = '0.10.0.rc.1'
9
3
  UPDATE_VERSION_LIMIT = '0.7.0'
10
4
  end
@@ -10,39 +10,40 @@ class NavigationActivity
10
10
 
11
11
  self.content_view =
12
12
  linear_layout :orientation => :vertical, :gravity => :center_horizontal do
13
- text_view :text => 'What hath Matz wrought?', :id => 42, :width => :match_parent,
13
+ text_view :text => 'Navigation', :id => 42, :width => :match_parent,
14
14
  :gravity => :center, :text_size => 48.0
15
- button :text => 'Next by Java class', :width => :match_parent, :id => 43, :on_click_listener => proc { start_next_java_activity }
16
- button :text => 'Next by Ruby class', :width => :match_parent, :id => 44, :on_click_listener => proc { start_next_ruby_activity }
17
- button :text => 'Next by script name', :width => :match_parent, :id => 45, :on_click_listener => proc { start_activity_by_script_name }
15
+ button :text => 'Java backed by Java class', :width => :match_parent, :id => 43, :on_click_listener => proc { java_backed_by_java_class }
16
+ button :text => 'Java backed by Ruby class', :width => :match_parent, :id => 44, :on_click_listener => proc { java_backed_by_ruby_class }
17
+ button :text => 'Java backed by script name', :width => :match_parent, :id => 45, :on_click_listener => proc { java_backed_by_script_name }
18
18
  button :text => 'Inline block', :width => :match_parent, :id => 46, :on_click_listener => proc { start_inline_activity }
19
19
  button :text => 'Inline block with options', :width => :match_parent, :id => 47, :on_click_listener => proc { start_inline_activity_with_options }
20
20
  button :text => 'Infile class', :width => :match_parent, :id => 48, :on_click_listener => proc { start_infile_activity }
21
+ button :text => 'Ruby file activity', :width => :match_parent, :id => 49, :on_click_listener => proc { start_ruby_file_activity }
21
22
  end
22
23
  end
23
24
 
24
25
  private
25
26
 
26
- def start_next_java_activity
27
+ def java_backed_by_java_class
27
28
  i = android.content.Intent.new
28
- i.setClassName($package_name, 'org.ruboto.test_app.NavigationActivity')
29
+ i.setClassName($package_name, 'org.ruboto.test_app.NavigationTargetActivity')
29
30
  startActivity(i)
30
31
  end
31
32
 
32
- def start_next_ruby_activity
33
+ def java_backed_by_ruby_class
33
34
  i = android.content.Intent.new
34
35
  i.setClassName($package_name, 'org.ruboto.RubotoActivity')
35
36
  configBundle = android.os.Bundle.new
36
- configBundle.put_string('ClassName', 'NavigationActivity')
37
+ configBundle.put_string('ClassName', 'NavigationTargetActivity')
37
38
  i.putExtra('RubotoActivity Config', configBundle)
38
39
  startActivity(i)
39
40
  end
40
41
 
41
- def start_activity_by_script_name
42
+ def java_backed_by_script_name
42
43
  i = android.content.Intent.new
43
44
  i.setClassName($package_name, 'org.ruboto.RubotoActivity')
44
45
  configBundle = android.os.Bundle.new
45
- configBundle.put_string('Script', 'navigation_activity.rb')
46
+ configBundle.put_string('Script', 'navigation_target_activity.rb')
46
47
  i.putExtra('RubotoActivity Config', configBundle)
47
48
  startActivity(i)
48
49
  end
@@ -84,13 +85,21 @@ class NavigationActivity
84
85
  startActivity(i)
85
86
  end
86
87
 
88
+ def start_ruby_file_activity
89
+ i = android.content.Intent.new
90
+ i.setClassName($package_name, 'org.ruboto.RubotoActivity')
91
+ configBundle = android.os.Bundle.new
92
+ configBundle.put_string('ClassName', 'RubyFileActivity')
93
+ i.putExtra('RubotoActivity Config', configBundle)
94
+ startActivity(i)
95
+ end
96
+
87
97
  end
88
98
 
89
99
  class InfileActivity
90
100
  def on_create(bundle)
91
101
  super
92
102
  set_title 'Infile Activity'
93
-
94
103
  self.content_view =
95
104
  linear_layout :orientation => :vertical, :gravity => :center_horizontal do
96
105
  text_view :text => 'This is an infile activity.', :id => 42, :width => :match_parent,
@@ -10,9 +10,17 @@ setup do |activity|
10
10
  assert @text_view
11
11
  end
12
12
 
13
+ test('Java backed activity is reloaded if source already loaded', :ui => false) do |activity|
14
+ require 'navigation_target_activity'
15
+ #::NavigationTargetActivity = ::RubyFileActivity
16
+ #Object.const_set(:NavigationTargetActivity, RubyFileActivity)
17
+ #Kernel.const_set(:NavigationTargetActivity, RubyFileActivity)
18
+ button_activity_text 43, activity, 42, 'This is the navigation target activity.',
19
+ 'org.ruboto.test_app.NavigationTargetActivity'
20
+ end
21
+
13
22
  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)
23
+ monitor = add_monitor('org.ruboto.test_app.NavigationTargetActivity', nil, false)
16
24
  begin
17
25
  activity.run_on_ui_thread { activity.find_view_by_id(43).perform_click }
18
26
  current_activity = wait_for_monitor_with_timeout(monitor, 5000)
@@ -27,7 +35,6 @@ test('button starts Java activity', :ui => false) do |activity|
27
35
  end
28
36
 
29
37
  test('button starts Ruby activity', :ui => false) do |activity|
30
- assert_equal "What hath Matz wrought?", @text_view.text
31
38
  monitor = add_monitor('org.ruboto.RubotoActivity', nil, false)
32
39
  begin
33
40
  activity.run_on_ui_thread { activity.find_view_by_id(44).perform_click }
@@ -43,7 +50,6 @@ test('button starts Ruby activity', :ui => false) do |activity|
43
50
  end
44
51
 
45
52
  test('button starts activity by script name', :ui => false) do |activity|
46
- assert_equal "What hath Matz wrought?", @text_view.text
47
53
  monitor = add_monitor('org.ruboto.RubotoActivity', nil, false)
48
54
  begin
49
55
  activity.run_on_ui_thread { activity.find_view_by_id(45).perform_click }
@@ -59,7 +65,6 @@ test('button starts activity by script name', :ui => false) do |activity|
59
65
  end
60
66
 
61
67
  test('button starts inline activity', :ui => false) do |activity|
62
- assert_equal "What hath Matz wrought?", @text_view.text
63
68
  monitor = add_monitor('org.ruboto.RubotoActivity', nil, false)
64
69
  begin
65
70
  activity.run_on_ui_thread { activity.find_view_by_id(46).perform_click }
@@ -85,7 +90,6 @@ test('button starts inline activity', :ui => false) do |activity|
85
90
  end
86
91
 
87
92
  test('button starts inline activity with options', :ui => false) do |activity|
88
- assert_equal "What hath Matz wrought?", @text_view.text
89
93
  monitor = add_monitor('org.ruboto.RubotoActivity', nil, false)
90
94
  begin
91
95
  activity.run_on_ui_thread { activity.find_view_by_id(47).perform_click }
@@ -111,7 +115,6 @@ test('button starts inline activity with options', :ui => false) do |activity|
111
115
  end
112
116
 
113
117
  test('button starts infile class activity', :ui => false) do |activity|
114
- assert_equal "What hath Matz wrought?", @text_view.text
115
118
  monitor = add_monitor('org.ruboto.RubotoActivity', nil, false)
116
119
  begin
117
120
  activity.run_on_ui_thread { activity.find_view_by_id(48).perform_click }
@@ -135,3 +138,44 @@ test('button starts infile class activity', :ui => false) do |activity|
135
138
  # FIXME(uwe): Replace sleep with proper monitor
136
139
  sleep 3
137
140
  end
141
+
142
+
143
+ test("infile activity starts again", :ui => false) do |activity|
144
+ button_activity_text 48, activity, 42, 'This is an infile activity.'
145
+ end
146
+
147
+ test("start ruby file activity", :ui => false) do |activity|
148
+ button_activity_text 49, activity, 42, 'This is a Ruby file activity.'
149
+ end
150
+
151
+ test("start ruby file activity again", :ui => false) do |activity|
152
+ button_activity_text 49, activity, 42, 'This is a Ruby file activity.'
153
+ end
154
+
155
+ def button_activity_text button_id, activity, expected_text_id, expected_text_string,
156
+ activity_class_name = 'org.ruboto.RubotoActivity'
157
+ monitor = add_monitor(activity_class_name, nil, false)
158
+ begin
159
+ activity.run_on_ui_thread { activity.find_view_by_id(button_id).perform_click }
160
+ current_activity = wait_for_monitor_with_timeout(monitor, 5000)
161
+ ensure
162
+ removeMonitor(monitor)
163
+ end
164
+ puts "new activity: #{current_activity.inspect}"
165
+ assert current_activity.is_a? Java::OrgRuboto::RubotoActivity
166
+ start = Time.now
167
+ loop do
168
+ @text_view = current_activity.find_view_by_id(expected_text_id)
169
+ break if @text_view || (Time.now - start > 10)
170
+ puts 'wait for text'
171
+ sleep 1
172
+ end
173
+ assert @text_view
174
+ assert_equal expected_text_string, @text_view.text
175
+ ensure
176
+ if current_activity
177
+ current_activity.run_on_ui_thread { current_activity.finish }
178
+ # FIXME(uwe): Replace sleep with proper monitor
179
+ sleep 3
180
+ end
181
+ end
@@ -0,0 +1,12 @@
1
+ class NavigationTargetActivity
2
+ def on_create(bundle)
3
+ super
4
+ set_title 'Navigation Target Activity'
5
+
6
+ self.content_view =
7
+ linear_layout :orientation => :vertical, :gravity => :center_horizontal do
8
+ text_view :text => 'This is the navigation target activity.', :id => 42, :width => :match_parent,
9
+ :gravity => :center, :text_size => 48.0
10
+ end
11
+ end
12
+ end
@@ -1,11 +1,11 @@
1
- class MytestOtherfileActivity
1
+ class RubyFileActivity
2
2
  def on_create(bundle)
3
3
  super
4
- set_title 'Otherfile Activity'
4
+ set_title 'Ruby file Activity'
5
5
 
6
6
  self.content_view =
7
7
  linear_layout :orientation => :vertical, :gravity => :center_horizontal do
8
- text_view :text => 'This is an otherfile activity.', :id => 42, :width => :match_parent,
8
+ text_view :text => 'This is a Ruby file activity.', :id => 42, :width => :match_parent,
9
9
  :gravity => :center, :text_size => 48.0
10
10
  end
11
11
  end
@@ -24,9 +24,30 @@ class MyObject < java.lang.Object
24
24
  super()
25
25
  @my_param = my_param
26
26
  end
27
+
28
+ def equals(x)
29
+ !super
30
+ end
27
31
  end
28
32
 
29
33
  test('add constructor with parameter') do
30
34
  o = MyObject.new('It works!')
31
35
  assert_equal 'It works!', o.my_param
32
36
  end
37
+
38
+ test('call instance method super') do
39
+ o = MyObject.new('It works!')
40
+ assert !o.equals(o)
41
+ end
42
+
43
+ class MyJRubyAdapter < org.ruboto.JRubyAdapter
44
+ def self.isDebugBuild
45
+ !super
46
+ end
47
+ end
48
+
49
+ test('call super from static subclass method') do
50
+ a = org.ruboto.JRubyAdapter
51
+ b = MyJRubyAdapter
52
+ assert a.isDebugBuild != b.isDebugBuild
53
+ end
@@ -38,7 +38,7 @@ module AppTestMethods
38
38
  def run_activity_tests(activity_dir)
39
39
  Dir[File.expand_path("#{activity_dir}/*", File.dirname(__FILE__))].each do |file|
40
40
  # FIXME(uwe): Remove when we stop testing JRuby < 1.7.0.rc1
41
- next if file =~ /subclass/ && (RUBOTO_PLATFORM == 'CURRENT' || JRUBY_JARS_VERSION < Gem::Version.new('1.7.0.rc1'))
41
+ next if file =~ /subclass/ && (RUBOTO_PLATFORM == 'CURRENT' || JRUBY_JARS_VERSION < Gem::Version.new('1.7.1.dev'))
42
42
 
43
43
  if file =~ /_test.rb$/
44
44
  next unless file =~ /#{ENV['ACTIVITY_TEST_PATTERN']}/
@@ -13,7 +13,7 @@ class BroadcastReceiverTest < Test::Unit::TestCase
13
13
  end
14
14
 
15
15
  def test_generated_broadcast_receiver
16
- action_name ='org.ruboto.example.click_broadcast'
16
+ action_name = 'org.ruboto.example.click_broadcast'
17
17
  message = 'Broadcast received!'
18
18
  Dir.chdir APP_DIR do
19
19
  activity_filename = 'src/ruboto_test_app_activity.rb'
@@ -57,7 +57,7 @@ EOF
57
57
  Log.d "RUBOTO TEST", "Changing UI text"
58
58
  context.run_on_ui_thread{$broadcast_test_activity.find_view_by_id(42).text = '#{message}'}
59
59
  Log.d "RUBOTO TEST", "UI text changed OK!"
60
- rescue
60
+ rescue Exception
61
61
  Log.e "RUBOTO TEST", "Exception changing UI text: \#{$!.message}"
62
62
  Log.e "RUBOTO TEST", $!.message
63
63
  Log.e "RUBOTO TEST", $!.backtrace.join("\\n")
@@ -13,6 +13,12 @@ class RubotoGenTest < Test::Unit::TestCase
13
13
  cleanup_app
14
14
  end
15
15
 
16
+ def test_gitignore_is_included_in_new_project
17
+ Dir.chdir APP_DIR do
18
+ assert File.exists? '.gitignore'
19
+ end
20
+ end
21
+
16
22
  def test_icons_are_updated
17
23
  Dir.chdir APP_DIR do
18
24
  assert_equal 4032, File.size('res/drawable-hdpi/ic_launcher.png')
@@ -39,7 +39,8 @@ module RubotoTest
39
39
  '2.3.3' => 'android-10', '2.3.4' => 'android-10',
40
40
  '3.0' => 'android-11', '3.1' => 'android-12', '3.2' => 'android-13',
41
41
  '4.0.1' => 'android-14', '4.0.3' => 'android-15', '4.0.4' => 'android-15',
42
- '4.1' => 'android-16', '4.1.1' => 'android-16'
42
+ '4.1' => 'android-16', '4.1.1' => 'android-16',
43
+ '4.2' => 'android-17',
43
44
  }
44
45
 
45
46
  def self.version_from_device
@@ -29,35 +29,39 @@ module UpdateTestMethods
29
29
  end
30
30
  end
31
31
 
32
- def test_broadcast_receiver
33
- Dir.chdir APP_DIR do
34
- puts "Adding a broadcast receiver"
35
- install_ruboto_gem @old_ruboto_version
36
- system "ruboto _#{@old_ruboto_version}_ gen class BroadcastReceiver --name DummyReceiver"
37
- fail "Creation of broadcast receiver failed" if $? != 0
38
- assert File.exists? 'src/org/ruboto/test_app/DummyReceiver.java'
39
- assert File.exists? 'src/dummy_receiver.rb'
40
- test_file = 'test/src/dummy_receiver_test.rb'
41
- assert File.exists? test_file
42
- update_app
32
+ # FIXME(uwe): Older projects generated code that is no longer compatible/correct
33
+ # FIXME(uwe): Remove check when we stop support for updating from Ruboto 0.10.0.rc.0 and older
34
+ unless Gem::Version.new(@old_ruboto_version) <= Gem::Version.new('0.10.0.rc.0')
35
+ def test_broadcast_receiver
36
+ Dir.chdir APP_DIR do
37
+ puts "Adding a broadcast receiver"
38
+ install_ruboto_gem @old_ruboto_version
39
+ system "ruboto _#{@old_ruboto_version}_ gen class BroadcastReceiver --name DummyReceiver"
40
+ fail "Creation of broadcast receiver failed" if $? != 0
41
+ assert File.exists? 'src/org/ruboto/test_app/DummyReceiver.java'
42
+ assert File.exists? 'src/dummy_receiver.rb'
43
+ test_file = 'test/src/dummy_receiver_test.rb'
44
+ assert File.exists? test_file
45
+ update_app
46
+ end
47
+ run_app_tests
43
48
  end
44
- run_app_tests
45
- end
46
49
 
47
- def test_broadcast_receiver_updated_twice
48
- Dir.chdir APP_DIR do
49
- puts "Adding a broadcast receiver"
50
- install_ruboto_gem @old_ruboto_version
51
- system "ruboto _#{@old_ruboto_version}_ gen class BroadcastReceiver --name DummyReceiver"
52
- fail "Creation of broadcast receiver failed" if $? != 0
53
- assert File.exists? 'src/org/ruboto/test_app/DummyReceiver.java'
54
- assert File.exists? 'src/dummy_receiver.rb'
55
- test_file = 'test/src/dummy_receiver_test.rb'
56
- assert File.exists? test_file
57
- update_app
58
- update_app
50
+ def test_broadcast_receiver_updated_twice
51
+ Dir.chdir APP_DIR do
52
+ puts "Adding a broadcast receiver"
53
+ install_ruboto_gem @old_ruboto_version
54
+ system "ruboto _#{@old_ruboto_version}_ gen class BroadcastReceiver --name DummyReceiver"
55
+ fail "Creation of broadcast receiver failed" if $? != 0
56
+ assert File.exists? 'src/org/ruboto/test_app/DummyReceiver.java'
57
+ assert File.exists? 'src/dummy_receiver.rb'
58
+ test_file = 'test/src/dummy_receiver_test.rb'
59
+ assert File.exists? test_file
60
+ update_app
61
+ update_app
62
+ end
63
+ run_app_tests
59
64
  end
60
- run_app_tests
61
65
  end
62
66
 
63
67
  def test_subclass_is_updated
@@ -82,7 +86,7 @@ module UpdateTestMethods
82
86
  private
83
87
 
84
88
  def assert_code(code)
85
- filename = "src/ruboto_test_app_activity.rb"
89
+ filename = "src/ruboto_test_app_activity.rb"
86
90
  Dir.chdir APP_DIR do
87
91
  s = File.read(filename)
88
92
  raise "Code injection failed!" unless s.gsub!(/(require 'ruboto\/widget')/, "\\1\n#{code}")
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruboto
3
3
  version: !ruby/object:Gem::Version
4
- hash: -86398566
4
+ hash: -2372293602
5
5
  prerelease: 7
6
6
  segments:
7
7
  - 0
8
8
  - 10
9
9
  - 0
10
10
  - rc
11
- - 0
12
- version: 0.10.0.rc.0
11
+ - 1
12
+ version: 0.10.0.rc.1
13
13
  platform: ruby
14
14
  authors:
15
15
  - Daniel Jackoway
@@ -20,7 +20,7 @@ autorequire:
20
20
  bindir: bin
21
21
  cert_chain: []
22
22
 
23
- date: 2012-11-21 00:00:00 Z
23
+ date: 2012-11-28 00:00:00 Z
24
24
  dependencies:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: main
@@ -59,9 +59,9 @@ extensions: []
59
59
  extra_rdoc_files: []
60
60
 
61
61
  files:
62
- - COPYING
63
62
  - Gemfile
64
63
  - Gemfile.lock
64
+ - LICENSE
65
65
  - Rakefile
66
66
  - README.md
67
67
  - assets/libs/dx.jar
@@ -107,6 +107,10 @@ files:
107
107
  - assets/src/RubotoBroadcastReceiver.java
108
108
  - assets/src/RubotoService.java
109
109
  - assets/test/src/test_helper.rb
110
+ - assets/.DS_Store
111
+ - assets/.gitignore
112
+ - assets/res/.DS_Store
113
+ - assets/res/drawable/.DS_Store
110
114
  - bin/ruboto
111
115
  - lib/DalvikProxyClassFactory.java
112
116
  - lib/DexClient.java
@@ -115,6 +119,7 @@ files:
115
119
  - lib/ruboto/commands/base.rb
116
120
  - lib/ruboto/core_ext/array.rb
117
121
  - lib/ruboto/core_ext/object.rb
122
+ - lib/ruboto/description.rb
118
123
  - lib/ruboto/sdk_versions.rb
119
124
  - lib/ruboto/util/asset_copier.rb
120
125
  - lib/ruboto/util/build.rb
@@ -136,15 +141,15 @@ files:
136
141
  - test/activity/image_button_and_button_activity_test.rb
137
142
  - test/activity/margins_activity.rb
138
143
  - test/activity/margins_activity_test.rb
139
- - test/activity/mytest_activity.rb
140
- - test/activity/mytest_activity_test.rb
141
- - test/activity/mytest_otherfile_activity.rb
142
144
  - test/activity/navigation_activity.rb
143
145
  - test/activity/navigation_activity_test.rb
146
+ - test/activity/navigation_target_activity.rb
147
+ - test/activity/navigation_target_activity_test.rb
144
148
  - test/activity/option_menu_activity.rb
145
149
  - test/activity/option_menu_activity_test.rb
146
150
  - test/activity/psych_activity.rb
147
151
  - test/activity/psych_activity_test.rb
152
+ - test/activity/ruby_file_activity.rb
148
153
  - test/activity/stack_activity.rb
149
154
  - test/activity/stack_activity_test.rb
150
155
  - test/activity/subclass_activity.rb
@@ -1,56 +0,0 @@
1
- require 'ruboto/activity'
2
- require 'ruboto/widget'
3
-
4
- ruboto_import_widgets :Button, :LinearLayout, :TextView
5
-
6
- class MytestActivity < Java::OrgRuboto::EntryPointActivity
7
- def on_create(bundle)
8
- super
9
- set_title File.basename(__FILE__).chomp('_activity.rb').split('_').
10
- map { |s| "#{s[0..0].upcase}#{s[1..-1]}" }.join(' ')
11
-
12
- self.content_view =
13
- linear_layout :orientation => :vertical, :gravity => :center_horizontal do
14
- text_view :text => 'What hath Matz wrought?', :id => 42, :width => :match_parent,
15
- :gravity => :center, :text_size => 48.0
16
- button :text => 'Infile class', :width => :match_parent, :id => 48,
17
- :on_click_listener => proc { start_infile_activity }
18
- button :text => 'Otherfile class', :width => :match_parent, :id => 49,
19
- :on_click_listener => proc { start_otherfile_activity }
20
- end
21
- end
22
-
23
- private
24
-
25
- def start_infile_activity
26
- i = android.content.Intent.new
27
- i.setClassName($package_name, 'org.ruboto.RubotoActivity')
28
- configBundle = android.os.Bundle.new
29
- configBundle.put_string('ClassName', 'MytestInfileActivity')
30
- i.putExtra('RubotoActivity Config', configBundle)
31
- startActivity(i)
32
- end
33
-
34
- def start_otherfile_activity
35
- i = android.content.Intent.new
36
- i.setClassName($package_name, 'org.ruboto.RubotoActivity')
37
- configBundle = android.os.Bundle.new
38
- configBundle.put_string('ClassName', 'MytestOtherfileActivity')
39
- i.putExtra('RubotoActivity Config', configBundle)
40
- startActivity(i)
41
- end
42
-
43
- end
44
-
45
- class MytestInfileActivity
46
- def on_create(bundle)
47
- super
48
- set_title 'Infile Activity'
49
-
50
- self.content_view =
51
- linear_layout :orientation => :vertical, :gravity => :center_horizontal do
52
- text_view :text => 'This is an infile activity.', :id => 42, :width => :match_parent,
53
- :gravity => :center, :text_size => 48.0
54
- end
55
- end
56
- end
@@ -1,52 +0,0 @@
1
- activity org.ruboto.test_app.MytestActivity
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
- def button_activity_text button_id, activity, expected_text_id, expected_text_string
14
- monitor = add_monitor('org.ruboto.RubotoActivity', nil, false)
15
- begin
16
- activity.run_on_ui_thread { activity.find_view_by_id(button_id).perform_click }
17
- current_activity = wait_for_monitor_with_timeout(monitor, 5000)
18
- ensure
19
- removeMonitor(monitor)
20
- end
21
- puts "new activity: #{current_activity.inspect}"
22
- assert current_activity
23
- assert current_activity.is_a? Java::OrgRuboto::RubotoActivity
24
- start = Time.now
25
- loop do
26
- @text_view = current_activity.find_view_by_id(expected_text_id)
27
- break if @text_view || (Time.now - start > 10)
28
- puts 'wait for text'
29
- sleep 1
30
- end
31
- assert @text_view
32
- assert_equal expected_text_string, @text_view.text
33
- current_activity.run_on_ui_thread { current_activity.finish }
34
- # FIXME(uwe): Replace sleep with proper monitor
35
- sleep 3
36
- end
37
-
38
- test("infile activity starts once", :ui => false) do |activity|
39
- button_activity_text 48, activity, 42, 'This is an infile activity.'
40
- end
41
-
42
- test("infile activity starts again", :ui => false) do |activity|
43
- button_activity_text 48, activity, 42, 'This is an infile activity.'
44
- end
45
-
46
- test("otherfile activity starts once", :ui => false) do |activity|
47
- button_activity_text 49, activity, 42, 'This is an otherfile activity.'
48
- end
49
-
50
- test("otherfile activity starts again", :ui => false) do |activity|
51
- button_activity_text 49, activity, 42, 'This is an otherfile activity.'
52
- end