ruboto 0.13.0 → 0.14.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.
@@ -128,11 +128,11 @@ module Ruboto
128
128
  end
129
129
 
130
130
  def update_jruby(force=nil, explicit = false)
131
- jruby_core = Dir.glob('libs/jruby-core-*.jar')[0]
132
- jruby_stdlib = Dir.glob('libs/jruby-stdlib-*.jar')[0]
131
+ installed_jruby_core = Dir.glob('libs/jruby-core-*.jar')[0]
132
+ installed_jruby_stdlib = Dir.glob('libs/jruby-stdlib-*.jar')[0]
133
133
 
134
134
  unless force
135
- if !jruby_core || !jruby_stdlib
135
+ if !installed_jruby_core || !installed_jruby_stdlib
136
136
  puts "Cannot find existing jruby jars in libs. Make sure you're in the root directory of your app." if explicit
137
137
  return false
138
138
  end
@@ -147,7 +147,7 @@ module Ruboto
147
147
  new_jruby_version = JRubyJars::VERSION
148
148
 
149
149
  unless force
150
- current_jruby_version = jruby_core ? jruby_core[16..-5] : 'None'
150
+ current_jruby_version = installed_jruby_core ? installed_jruby_core[16..-5] : 'None'
151
151
  if current_jruby_version == new_jruby_version
152
152
  puts "JRuby is up to date at version #{new_jruby_version}. Make sure you 'gem update jruby-jars' if there is a new version."
153
153
  return false
@@ -158,10 +158,10 @@ module Ruboto
158
158
  end
159
159
 
160
160
  copier = AssetCopier.new Ruboto::ASSETS, File.expand_path('.')
161
- log_action("Removing #{jruby_core}") { File.delete *Dir.glob('libs/jruby-core-*.jar') } if jruby_core
162
- log_action("Removing #{jruby_stdlib}") { File.delete *Dir.glob('libs/jruby-stdlib-*.jar') } if jruby_stdlib
163
- log_action("Copying #{JRubyJars::core_jar_path} to libs") { copier.copy_from_absolute_path JRubyJars::core_jar_path, 'libs' }
164
- log_action("Copying #{JRubyJars::stdlib_jar_path} to libs") { copier.copy_from_absolute_path JRubyJars::stdlib_jar_path, 'libs' }
161
+ log_action("Removing #{installed_jruby_core}") { File.delete *Dir.glob('libs/jruby-core-*.jar') } if installed_jruby_core
162
+ log_action("Removing #{installed_jruby_stdlib}") { File.delete *Dir.glob('libs/jruby-stdlib-*.jar') } if installed_jruby_stdlib
163
+ log_action("Copying #{JRubyJars::core_jar_path} to libs") { FileUtils.cp JRubyJars::core_jar_path, "libs/jruby-core-#{new_jruby_version}.jar" }
164
+ log_action("Copying #{JRubyJars::stdlib_jar_path} to libs") { FileUtils.cp JRubyJars::stdlib_jar_path, "libs/jruby-stdlib-#{new_jruby_version}.jar" }
165
165
 
166
166
  unless File.read('project.properties') =~ /^dex.force.jumbo=/
167
167
  log_action('Setting JUMBO dex file format') do
@@ -301,6 +301,10 @@ module Ruboto
301
301
  app_element.add_element 'activity', {'android:name' => 'org.ruboto.RubotoActivity', 'android:exported' => 'false'}
302
302
  end
303
303
 
304
+ unless app_element.elements["activity[@android:name='org.ruboto.SplashActivity']"]
305
+ app_element.add_element 'activity', {'android:name' => 'org.ruboto.SplashActivity', 'android:exported' => 'false', 'android:configChanges' => (target.to_i >= 13 ? 'orientation|screenSize' : 'orientation')}
306
+ end
307
+
304
308
  unless app_element.elements["activity[@android:name='org.ruboto.RubotoDialog']"]
305
309
  app_element.add_element 'activity', {'android:name' => 'org.ruboto.RubotoDialog', 'android:exported' => 'false', 'android:theme' => '@android:style/Theme.Dialog'}
306
310
  end
@@ -329,6 +333,18 @@ module Ruboto
329
333
  end
330
334
 
331
335
  def update_ruboto(force=nil)
336
+ source_files_pattern = 'ruboto{.rb,/**/*}'
337
+ new_sources_dir = Ruboto::GEM_ROOT + "/assets/#{SCRIPTS_DIR}"
338
+ new_sources = Dir.chdir(new_sources_dir) { Dir[source_files_pattern] }.
339
+ select { |f| !(File.directory?("#{new_sources_dir}/#{f}") || File.basename(f) == '.' || File.basename(f) == '..') }
340
+ old_sources = Dir.chdir("#{SCRIPTS_DIR}") { Dir[source_files_pattern] }.
341
+ select { |f| !(File.directory?("#{SCRIPTS_DIR}/#{f}") || File.basename(f) == '.' || File.basename(f) == '..') }
342
+ obsolete_sources = old_sources - new_sources - %w(ruboto/version.rb)
343
+ obsolete_sources.each do |f|
344
+ log_action("Deleting obsolete script #{f}") do
345
+ FileUtils.rm_f f
346
+ end
347
+ end
332
348
  log_action('Copying ruboto/version.rb') do
333
349
  from = File.expand_path(Ruboto::GEM_ROOT + '/lib/ruboto/version.rb')
334
350
  to = File.expand_path("./#{SCRIPTS_DIR}/ruboto/version.rb")
@@ -336,10 +352,10 @@ module Ruboto
336
352
  FileUtils.cp from, to
337
353
  end
338
354
  log_action('Copying additional ruboto script components') do
339
- Dir.glob(Ruboto::GEM_ROOT + "/assets/#{SCRIPTS_DIR}/ruboto/**/*.rb").each do |from|
340
- to = File.expand_path("./#{from.slice /#{SCRIPTS_DIR}\/ruboto\/.*\.rb/}")
355
+ new_sources.each do |from|
356
+ to = File.expand_path(from, SCRIPTS_DIR)
341
357
  FileUtils.mkdir_p File.dirname(to)
342
- FileUtils.cp from, to
358
+ FileUtils.cp "#{new_sources_dir}/#{from}", to
343
359
  end
344
360
  end
345
361
  end
@@ -353,8 +369,8 @@ module Ruboto
353
369
  # - Removes unneeded code from jruby-core
354
370
  # - Split into smaller jars that can be used separately
355
371
  def reconfigure_jruby_core(jruby_core_version)
356
- jruby_core = JRubyJars::core_jar_path.split('/')[-1]
357
372
  Dir.chdir 'libs' do
373
+ jruby_core = Dir['jruby-core-*.jar'][-1]
358
374
  log_action("Removing unneeded classes from #{jruby_core}") do
359
375
  FileUtils.rm_rf 'tmp'
360
376
  Dir.mkdir 'tmp'
@@ -363,7 +379,7 @@ module Ruboto
363
379
  `jar -xf #{jruby_core}`
364
380
  raise "Unpacking jruby-core jar failed: #$?" unless $? == 0
365
381
  File.delete jruby_core
366
- if Gem::Version.new(jruby_core_version) >= Gem::Version.new('1.7.4.dev')
382
+ if Gem::Version.new(jruby_core_version) >= Gem::Version.new('1.7.5.dev')
367
383
  #noinspection RubyLiteralArrayInspection
368
384
  excluded_core_packages = [
369
385
  '**/*Darwin*',
@@ -376,7 +392,7 @@ module Ruboto
376
392
  'com/kenai/jffi',
377
393
  'com/kenai/jnr/x86asm',
378
394
  'com/martiansoftware',
379
- 'jline', 'jni',
395
+ 'jni',
380
396
  'jnr/constants/platform/darwin',
381
397
  'jnr/constants/platform/fake',
382
398
  'jnr/constants/platform/freebsd',
@@ -394,8 +410,6 @@ module Ruboto
394
410
  'jnr/posix/MacOS*',
395
411
  'jnr/posix/OpenBSD*',
396
412
  'jnr/x86asm',
397
- 'org/apache',
398
- 'org/fusesource',
399
413
  'org/jruby/ant',
400
414
  'org/jruby/cext',
401
415
  # 'org/jruby/compiler', # Needed for initialization, but should not be necessary
@@ -410,20 +424,16 @@ module Ruboto
410
424
  'org/jruby/ext/ffi/AbstractMemory*',
411
425
  'org/jruby/ext/ffi/io',
412
426
  'org/jruby/ext/ffi/jffi',
413
- 'org/jruby/ext/ripper',
414
427
  'org/jruby/ext/tracepoint',
415
- #'org/jruby/ir/dataflow',
416
- #'org/jruby/ir/dataflow/analyses',
417
- #'org/jruby/ir/representations',
418
- #'org/jruby/ir/runtime',
419
- #'org/jruby/ir/targets',
420
- #'org/jruby/ir/transformations',
421
- #'org/jruby/ir/util',
422
428
  'org/jruby/javasupport/bsf',
423
429
  # 'org/jruby/management', # should be excluded
424
430
  # 'org/jruby/runtime/invokedynamic', # Should be excluded
431
+ # 'org/jruby/runtime/opto', # What is this?
432
+ # 'org/jruby/runtime/opto/OptoFactory*', # What is this?
425
433
  'org/yecht',
426
434
  ]
435
+ elsif Gem::Version.new(jruby_core_version) >= Gem::Version.new('1.7.4')
436
+ 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)
427
437
  elsif Gem::Version.new(jruby_core_version) >= Gem::Version.new('1.7.3')
428
438
  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/provider jnr/ffi/util jnr/ffi/Struct$* jnr/ffi/types 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/javasupport/bsf org/yecht)
429
439
  elsif Gem::Version.new(jruby_core_version) >= Gem::Version.new('1.7.2')
@@ -469,7 +479,7 @@ module Ruboto
469
479
  #end
470
480
 
471
481
  # Add our proxy class factory
472
- android_jar = Dir["#{ANDROID_HOME}/platforms/*/android.jar"][0]
482
+ android_jar = Dir["#{ANDROID_HOME.gsub("\\", "/")}/platforms/*/android.jar"][0]
473
483
  unless android_jar
474
484
  puts
475
485
  puts '*' * 80
@@ -500,7 +510,7 @@ module Ruboto
500
510
  included_stdlibs = verify_ruboto_config[:included_stdlibs]
501
511
  excluded_stdlibs = [*verify_ruboto_config[:excluded_stdlibs]].compact
502
512
  Dir.chdir 'libs' do
503
- jruby_stdlib = JRubyJars::stdlib_jar_path.split('/')[-1]
513
+ jruby_stdlib = Dir['jruby-stdlib-*.jar'][-1]
504
514
  log_action("Reformatting #{jruby_stdlib}") do
505
515
  FileUtils.mkdir_p 'tmp'
506
516
  Dir.chdir 'tmp' do
@@ -513,8 +523,7 @@ module Ruboto
513
523
  FileUtils.move 'old/META-INF/jruby.home/lib', 'new/jruby.home/lib'
514
524
  FileUtils.rm_rf 'new/jruby.home/lib/ruby/gems'
515
525
 
516
- raise "Unrecognized JRuby stdlib jar: #{jruby_stdlib}" unless jruby_stdlib =~ /jruby-stdlib-(.*).jar/
517
- jruby_stdlib_version = Gem::Version.new($1)
526
+ jruby_stdlib_version = Gem::Version.new(JRubyJars::VERSION)
518
527
 
519
528
  if included_stdlibs
520
529
  lib_dirs = %w(1.8 1.9 2.0 shared)
@@ -576,7 +585,7 @@ module Ruboto
576
585
  # EMXIF
577
586
 
578
587
  # FIXME(uwe): These should be included but break the 64K method count limit
579
- if j =~ /bcpkix-jdk15on-147|bcprov-jdk15on-147|jopenssl|kryptcore|kryptproviderjdk/
588
+ if j =~ /bcpkix-jdk15on-1\.?47|bcprov-jdk15on-1\.?47|jopenssl|kryptcore|kryptproviderjdk/
580
589
  FileUtils.rm j
581
590
  next
582
591
  end
@@ -1,4 +1,4 @@
1
1
  module Ruboto
2
- VERSION = '0.13.0'
2
+ VERSION = '0.14.0'
3
3
  UPDATE_VERSION_LIMIT = '0.7.0'
4
4
  end
@@ -23,6 +23,7 @@ class NavigationActivity
23
23
  button :text => 'Ruby file activity', :width => :match_parent, :id => 49, :on_click_listener => proc { start_ruby_file_activity }
24
24
  button :text => 'RubotoActivity no config', :width => :match_parent, :id => 50, :on_click_listener => proc { start_ruboto_activity_no_config }
25
25
  button :text => 'RubotoActivity', :width => :match_parent, :id => 51, :on_click_listener => proc { start_ruboto_activity('RubyFileActivity') }
26
+ button :text => 'RubotoActivity with Extras', :width => :match_parent, :id => 52, :on_click_listener => proc { start_ruboto_activity('RubyFileActivity', :extras => {:extra_string => 'Started with string extra.'}) }
26
27
  end
27
28
  end
28
29
  end
@@ -75,6 +75,10 @@ test('start ruboto activity with class name', :ui => false) do |activity|
75
75
  button_activity_text 51, activity, 42, 'This is a Ruby file activity.'
76
76
  end
77
77
 
78
+ test('start ruboto activity with extras', :ui => false) do |activity|
79
+ button_activity_text 52, activity, 42, 'Started with string extra.'
80
+ end
81
+
78
82
  def start_activity_by_button(activity, button_id, activity_class_name = 'org.ruboto.RubotoActivity')
79
83
  monitor = add_monitor(activity_class_name, nil, false)
80
84
  begin
@@ -2,10 +2,11 @@ class RubyFileActivity
2
2
  def onCreate(bundle)
3
3
  super
4
4
  set_title 'Ruby file Activity'
5
+ display_text = intent.get_extra('extra_string') || 'This is a Ruby file activity.'
5
6
 
6
7
  self.content_view =
7
8
  linear_layout :orientation => :vertical, :gravity => :center_horizontal do
8
- text_view :text => 'This is a Ruby file activity.', :id => 42, :width => :match_parent,
9
+ text_view :text => display_text, :id => 42, :width => :match_parent,
9
10
  :gravity => :center, :text_size => 48.0
10
11
  end
11
12
  end
@@ -12,12 +12,15 @@ if RubotoTest::RUBOTO_PLATFORM == 'STANDALONE'
12
12
  cleanup_app
13
13
  end
14
14
 
15
- # APK was 4.7MB. JRuby: 1.7.0, ANDROID_TARGET: 15
16
- # APK was 4.5MB. JRuby: 1.7.2, ANDROID_TARGET: 10
17
- # APK was 4.5MB. JRuby: 1.7.2, ANDROID_TARGET: 15
18
- # APK was 4.3MB. JRuby: 1.7.3, ANDROID_TARGET: 10
19
- # APK was 4.2MB. JRuby: 1.7.3, ANDROID_TARGET: 15
20
- # APK was 4.4MB. JRuby: 1.7.4.dev, ANDROID_TARGET: 10
15
+ # APK was 4.7MB. JRuby: 1.7.0, ANDROID_TARGET: 15
16
+ # APK was 4.5MB. JRuby: 1.7.2, ANDROID_TARGET: 10
17
+ # APK was 4.5MB. JRuby: 1.7.2, ANDROID_TARGET: 15
18
+ # APK was 4.3MB. JRuby: 1.7.3, ANDROID_TARGET: 10
19
+ # APK was 4.2MB. JRuby: 1.7.3, ANDROID_TARGET: 15
20
+ # APK was 4.4MB. JRuby: 1.7.4, ANDROID_TARGET: 10
21
+ # APK was 4.3MB. JRuby: 1.7.5.dev, ANDROID_TARGET: 10
22
+ # APK was 4.2MB. JRuby: 1.7.5.dev, ANDROID_TARGET: 15
23
+ # APK was 4.3MB. JRuby: 1.7.5.dev, ANDROID_TARGET: 16
21
24
  def test_minimal_apk_is_within_limits
22
25
  apk_size = BigDecimal(File.size("#{APP_DIR}/bin/RubotoTestApp-debug.apk").to_s) / (1024 * 1024)
23
26
  upper_limit = {
@@ -25,7 +28,8 @@ if RubotoTest::RUBOTO_PLATFORM == 'STANDALONE'
25
28
  '1.7.1' => ANDROID_TARGET < 15 ? 4.7 : 4.9,
26
29
  '1.7.2' => ANDROID_TARGET < 15 ? 4.6 : 4.9,
27
30
  '1.7.3' => ANDROID_TARGET < 15 ? 4.3 : 4.4,
28
- }[JRUBY_JARS_VERSION.to_s] || 4.4
31
+ '1.7.4' => 4.4,
32
+ }[JRUBY_JARS_VERSION.to_s] || {10 => 4.3, 16 => 4.3}[ANDROID_TARGET] || 4.3
29
33
  lower_limit = upper_limit * 0.9
30
34
  version_message ="JRuby: #{JRUBY_JARS_VERSION}, ANDROID_TARGET: #{ANDROID_TARGET}"
31
35
  assert apk_size <= upper_limit, "APK was larger than #{'%.1f' % upper_limit}MB: #{'%.1f' % apk_size.ceil(1)}MB. #{version_message}"
@@ -36,29 +40,5 @@ if RubotoTest::RUBOTO_PLATFORM == 'STANDALONE'
36
40
  run_app_tests
37
41
  end
38
42
 
39
- # APK was 4.7MB. JRuby: 1.7.0, ANDROID_TARGET: 15.
40
- # APK was 4.5MB. JRuby: 1.7.2, ANDROID_TARGET: 10.
41
- # APK was 4.5MB. JRuby: 1.7.2, ANDROID_TARGET: 15.
42
- # APK was 4.5MB. JRuby: 1.7.3, ANDROID_TARGET: 10
43
- # APK was 4.6MB. JRuby: 1.7.3.dev, ANDROID_TARGET: 10.
44
- # APK was 4.5MB. JRuby: 1.7.3.dev, ANDROID_TARGET: 15.
45
- # APK was 5.0MB. JRuby: 1.7.4.dev, ANDROID_TARGET: 10
46
- # FIXME(uwe): Remove when we remove the exclude feature
47
- def test_minimal_apk_with_excludes_is_less_than_5_mb
48
- generate_app :excluded_stdlibs => %w{ant cgi digest dl drb ffi irb net optparse racc rbconfig rdoc rexml rinda rss
49
- rubygems runit shell soap test uri webrick win32 wsdl xmlrpc xsd ../1.9}
50
- apk_size = BigDecimal(File.size("#{APP_DIR}/bin/RubotoTestApp-debug.apk").to_s) / (1024 * 1024)
51
- upper_limit = {
52
- '1.7.0' => ANDROID_TARGET < 15 ? 4.7 : 4.9,
53
- '1.7.1' => ANDROID_TARGET < 15 ? 4.7 : 4.9,
54
- '1.7.2' => ANDROID_TARGET < 15 ? 4.6 : 4.9,
55
- '1.7.3' => ANDROID_TARGET < 15 ? 4.6 : 4.9,
56
- }[JRUBY_JARS_VERSION.to_s] || 5.0
57
- lower_limit = upper_limit * 0.9
58
- version_message ="JRuby: #{JRUBY_JARS_VERSION}, ANDROID_TARGET: #{ANDROID_TARGET}"
59
- assert apk_size <= upper_limit, "APK was larger than #{'%.1f' % upper_limit}MB: #{'%.1f' % apk_size.ceil(1)}MB. #{version_message}"
60
- assert apk_size >= lower_limit, "APK was smaller than #{'%.1f' % lower_limit}MB: #{'%.1f' % apk_size.floor(1)}MB. You should lower the limit. #{version_message}"
61
- end
62
-
63
43
  end
64
44
  end
@@ -21,9 +21,9 @@ class RubotoGenTest < Test::Unit::TestCase
21
21
 
22
22
  def test_icons_are_updated
23
23
  Dir.chdir APP_DIR do
24
- assert_equal 4032, File.size('res/drawable-hdpi/ic_launcher.png')
25
- assert_equal 2548, File.size('res/drawable-mdpi/ic_launcher.png')
26
- assert_equal 1748, File.size('res/drawable-ldpi/ic_launcher.png')
24
+ assert_equal 3834, File.size('res/drawable-hdpi/ic_launcher.png')
25
+ assert_equal 2513, File.size('res/drawable-mdpi/ic_launcher.png')
26
+ assert_equal 1689, File.size('res/drawable-ldpi/ic_launcher.png')
27
27
  end
28
28
  end
29
29
 
@@ -61,6 +61,7 @@ class RubotoGenTest < Test::Unit::TestCase
61
61
  # APK was 8428.4KB. PLATFORM: STANDALONE, ANDROID_TARGET: 10, JRuby: 1.7.4.dev
62
62
  # APK was 7405.8KB. PLATFORM: STANDALONE, ANDROID_TARGET: 15, JRuby: 1.7.4.dev
63
63
  # APK was 7420.9KB. PLATFORM: STANDALONE, ANDROID_TARGET: 16, JRuby: 1.7.4.dev
64
+ # APK was 8512.7KB. PLATFORM: STANDALONE, ANDROID_TARGET: 16, JRuby: 1.7.5.dev
64
65
  def test_new_apk_size_is_within_limits
65
66
  apk_size = BigDecimal(File.size("#{APP_DIR}/bin/RubotoTestApp-debug.apk").to_s) / 1024
66
67
  version = " PLATFORM: #{RUBOTO_PLATFORM}"
@@ -71,14 +72,15 @@ class RubotoGenTest < Test::Unit::TestCase
71
72
  '1.7.1' => ANDROID_TARGET < 15 ? 7400.0 : 7600.0,
72
73
  '1.7.2' => 7400.0,
73
74
  '1.7.3' => 7400.0,
74
- }[JRUBY_JARS_VERSION.to_s] || 8500.0
75
+ '1.7.4' => 8500.0,
76
+ }[JRUBY_JARS_VERSION.to_s] || 8600.0
75
77
  version << ", JRuby: #{JRUBY_JARS_VERSION.to_s}"
76
78
  else
77
79
  upper_limit = {
78
80
  10 => 58.0,
79
- 15 => 59.0,
80
- 16 => 74.0,
81
- }[ANDROID_TARGET] || 74.0
81
+ 15 => 59.1,
82
+ 16 => 74.2,
83
+ }[ANDROID_TARGET] || 74.2
82
84
  end
83
85
  lower_limit = upper_limit * 0.9
84
86
  assert apk_size <= upper_limit, "APK was larger than #{'%.1f' % upper_limit}KB: #{'%.1f' % apk_size.ceil(1)}KB.#{version}"
@@ -9,24 +9,54 @@ require File.expand_path('updated_example_test_methods', File.dirname(__FILE__))
9
9
  require File.expand_path('update_test_methods', File.dirname(__FILE__))
10
10
 
11
11
  # TODO(uwe): Delete obsolete examples when we stop supporting updating from them.
12
-
13
12
  Dir.chdir "#{RubotoTest::PROJECT_DIR}/examples/" do
14
13
  example_archives = Dir["#{RubotoTest::APP_NAME}_*_tools_r*.tgz"]
15
14
  example_archives = example_archives.sort_by{|a| Gem::Version.new a[RubotoTest::APP_NAME.size + 1..-1].slice(/(.*)(?=_tools_)/)}
16
15
  example_archives = example_archives.last(example_limit) if example_limit
17
- example_archives.each do |f|
18
- next unless f =~ /^#{RubotoTest::APP_NAME}_(.*)_tools_r(.*)\.tgz$/
19
- ruboto_version = $1
20
- tools_version = $2
16
+
17
+ # TODO(gf): Track APIs compatible with update examples
18
+ EXAMPLE_COMPATIBLE_APIS = { (Gem::Version.new('0.7.0')..Gem::Version.new('0.10.99')) => [8],
19
+ (Gem::Version.new('0.11.0')..Gem::Version.new('0.13.0')) => [10,11,12,13,14,15,16,17] }
20
+
21
+ installed_apis = `android list target --compact`.lines.grep(/^android-/) { |s| s.match(/\d+/).to_s.to_i }
22
+ examples = example_archives.collect { |f| f.match /^#{RubotoTest::APP_NAME}_(?<ruboto_version>.*)_tools_r(?<tools_version>.*)\.tgz$/ }.compact
23
+
24
+ missing_apis = false
25
+ puts "Backward compatibility update tests: #{examples.size}"
26
+ examples.each_with_index do |m,i|
27
+ example_gem_version = Gem::Version.new m[:ruboto_version]
28
+ compatible_apis = EXAMPLE_COMPATIBLE_APIS[ EXAMPLE_COMPATIBLE_APIS.keys.detect { |gem_range| gem_range.cover? example_gem_version } ]
29
+ if compatible_apis
30
+ if ( installed_apis & compatible_apis ).empty?
31
+ puts "Update test #{examples[i]} needs a missing compatible API: #{compatible_apis.join(',')}"
32
+ missing_apis = true
33
+ end
34
+ end
35
+ end
36
+
37
+ if missing_apis
38
+ puts '----------------------------------------------------------------------------------------------------'
39
+ puts 'Required android APIs are missing, resolution options are:'
40
+ puts '* Install a needed android API with "android update sdk --no-ui --all --filter android-XX"'
41
+ puts '* Skip all backward compatibility update tests with "SKIP_RUBOTO_UPDATE_TEST=DEFINED rake test"'
42
+ puts '* Limit number of backward compatibility update tests to N with "RUBOTO_UPDATE_EXAMPLES=N rake test"'
43
+ puts 'Quitting...'
44
+ exit false
45
+ end
46
+
47
+ examples.each do |m|
48
+ ruboto_version = m[:ruboto_version]
49
+ tools_version = m[:tools_version]
50
+ ruboto_version_no_dots = ruboto_version.gsub('.', '_')
21
51
  self.class.class_eval <<EOF
22
- class RubotoUpdatedExample#{ruboto_version.gsub('.', '_')}Tools#{tools_version}Test < Test::Unit::TestCase
52
+ class RubotoUpdatedExample#{ruboto_version_no_dots}Tools#{tools_version}Test < Test::Unit::TestCase
23
53
  include UpdatedExampleTestMethods
24
54
  def setup
25
55
  super('#{ruboto_version}', '#{tools_version}')
26
56
  end
27
57
  end
28
58
 
29
- class RubotoUpdate#{ruboto_version.gsub('.', '_')}Tools#{tools_version}Test < Test::Unit::TestCase
59
+ class RubotoUpdate#{ruboto_version_no_dots}Tools#{tools_version}Test < Test::Unit::TestCase
30
60
  include UpdateTestMethods
31
61
  def setup
32
62
  super('#{ruboto_version}', '#{tools_version}')
@@ -34,4 +64,5 @@ class RubotoUpdate#{ruboto_version.gsub('.', '_')}Tools#{tools_version}Test < Te
34
64
  end
35
65
  EOF
36
66
  end
67
+
37
68
  end
@@ -0,0 +1,50 @@
1
+ require File.expand_path('test_helper', File.dirname(__FILE__))
2
+
3
+ require 'bigdecimal'
4
+ require 'test/app_test_methods'
5
+
6
+ class SplashTest < Test::Unit::TestCase
7
+ def setup
8
+ generate_app
9
+ end
10
+
11
+ def teardown
12
+ cleanup_app
13
+ end
14
+
15
+ def test_splash
16
+ Dir.chdir APP_DIR do
17
+ File.open('res/layout/splash.xml', 'w'){|f| f << <<EOF}
18
+ <?xml version="1.0" encoding="utf-8"?>
19
+ <LinearLayout
20
+ xmlns:android="http://schemas.android.com/apk/res/android"
21
+ android:layout_width="fill_parent"
22
+ android:layout_height="fill_parent"
23
+ android:orientation="vertical"
24
+ android:gravity="center_horizontal|center_vertical"
25
+ android:background="#30587c"
26
+ >
27
+ <!--Specify your splash image here-->
28
+ <ImageView
29
+ android:layout_width="fill_parent"
30
+ android:layout_height="fill_parent"
31
+ android:src="@drawable/logo"
32
+ android:scaleType="fitCenter"
33
+ android:layout_weight="1"
34
+ />
35
+ <TextView android:id="@+id/text"
36
+ android:layout_width="wrap_content"
37
+ android:layout_height="wrap_content"
38
+ android:text="Please wait..."
39
+ android:color="#000000"
40
+ />
41
+ </LinearLayout>
42
+ EOF
43
+
44
+ FileUtils.cp '../../icons/ruboto-logo_512x512.png', 'res/drawable/logo.png'
45
+ end
46
+
47
+ run_app_tests
48
+ end
49
+
50
+ end
data/test/test_helper.rb CHANGED
@@ -164,6 +164,7 @@ class Test::Unit::TestCase
164
164
  end
165
165
 
166
166
  def generate_app(options = {})
167
+ package = options.delete(:package) || PACKAGE
167
168
  example = options.delete(:example) || false
168
169
  update = options.delete(:update) || false
169
170
  # FIXME(uwe): Remove exclusion feature
@@ -176,6 +177,7 @@ class Test::Unit::TestCase
176
177
 
177
178
  FileUtils.rm_rf APP_DIR if File.exists? APP_DIR
178
179
  template_dir = "#{APP_DIR}_template_#{$$}"
180
+ template_dir << "_package_#{package}" if package != PACKAGE
179
181
  template_dir << "_example_#{example}" if example
180
182
  template_dir << "_bundle_#{[*bundle].join('_')}" if bundle
181
183
  template_dir << '_updated' if update
@@ -207,7 +209,7 @@ class Test::Unit::TestCase
207
209
  else
208
210
  uninstall_jruby_jars_gem unless standalone
209
211
  puts "Generating app #{APP_DIR}"
210
- system "#{RUBOTO_CMD} gen app --package #{PACKAGE} --path #{APP_DIR} --name #{APP_NAME} --target android-#{ANDROID_TARGET}"
212
+ system "#{RUBOTO_CMD} gen app --package #{package} --path #{APP_DIR} --name #{APP_NAME} --target android-#{ANDROID_TARGET}"
211
213
  if $? != 0
212
214
  FileUtils.rm_rf APP_DIR
213
215
  raise "gen app failed with return code #$?"
@@ -235,8 +237,12 @@ class Test::Unit::TestCase
235
237
 
236
238
  unless example && !update
237
239
  Dir.chdir APP_DIR do
238
- system 'rake debug'
240
+ system 'rake patch_dex' # Ensure dx heap space is sufficient.
239
241
  assert_equal 0, $?
242
+ Dir.chdir 'test' do
243
+ system 'ant instrument' # This will also build the main project.
244
+ assert_equal 0, $?
245
+ end
240
246
  end
241
247
  end
242
248
  puts "Storing app as template #{template_dir}"
@@ -0,0 +1,16 @@
1
+ require File.expand_path('test_helper', File.dirname(__FILE__))
2
+
3
+ class UppercasePackageNameTest < Test::Unit::TestCase
4
+
5
+ def setup
6
+ generate_app :package => 'org.ruboto.TestApp'
7
+ end
8
+
9
+ def teardown
10
+ cleanup_app
11
+ end
12
+
13
+ def test_gen_package_with_uppercase_name
14
+ run_app_tests
15
+ end
16
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruboto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Jackoway
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2013-06-09 00:00:00.000000000 Z
14
+ date: 2013-08-31 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: main
@@ -108,6 +108,7 @@ files:
108
108
  - assets/src/org/ruboto/Script.java
109
109
  - assets/src/org/ruboto/ScriptInfo.java
110
110
  - assets/src/org/ruboto/ScriptLoader.java
111
+ - assets/src/org/ruboto/SplashActivity.java
111
112
  - assets/src/org/ruboto/test/ActivityTest.java
112
113
  - assets/src/org/ruboto/test/InstrumentationTestRunner.java
113
114
  - assets/src/ruboto/activity.rb
@@ -188,10 +189,12 @@ files:
188
189
  - test/ruboto_gen_test.rb
189
190
  - test/ruboto_update_test.rb
190
191
  - test/service_test.rb
192
+ - test/splash_test.rb
191
193
  - test/sqldroid_test.rb
192
194
  - test/test_helper.rb
193
195
  - test/update_test_methods.rb
194
196
  - test/updated_example_test_methods.rb
197
+ - test/uppercase_package_name_test.rb
195
198
  homepage: http://ruboto.org/
196
199
  licenses:
197
200
  - MIT