ruboto 1.0.3 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,33 +10,46 @@ module Ruboto
10
10
  include Ruboto::SdkVersions
11
11
  include Ruboto::SdkLocations
12
12
 
13
+ TARGET_VERSION_REGEXP = /^(target=android-)(\d+)$/
14
+
13
15
  ###########################################################################
14
16
  #
15
17
  # Updating components
16
18
  #
17
- def update_android
19
+
20
+ def update_android(target_level = nil)
18
21
  root = Dir.getwd
19
22
  build_xml_file = "#{root}/build.xml"
20
23
  if File.exists? build_xml_file
21
- name = REXML::Document.new(File.read(build_xml_file)).root.attributes['name']
24
+ ant_script = File.read(build_xml_file)
25
+ name = REXML::Document.new(ant_script).root.attributes['name']
22
26
  else
23
27
  name = File.basename(root)
24
28
  end
29
+ update_project_properties_target_level("#{root}/project.properties", target_level)
30
+ system "android update project -p #{root} -n #{name} --subprojects"
31
+ raise "android update project failed with return code #{$?}" unless $? == 0
32
+ end
25
33
 
26
- prop_file = "#{root}/project.properties"
27
- version_regexp = /^(target=android-)(\d+)$/
28
- if (project_property_file = File.read(prop_file)) =~ version_regexp
29
- if $2.to_i < MINIMUM_SUPPORTED_SDK_LEVEL
30
- puts "Upgrading project to target #{MINIMUM_SUPPORTED_SDK}"
31
- File.open(prop_file, 'w') { |f| f << project_property_file.gsub(version_regexp, "\\1#{MINIMUM_SUPPORTED_SDK_LEVEL}") }
34
+ def update_project_properties_target_level(prop_file, target_level)
35
+ if (project_property_file = File.read(prop_file)) =~ TARGET_VERSION_REGEXP
36
+ min_sdk = $2.to_i
37
+ if target_level
38
+ unless target_level == min_sdk
39
+ puts "Changing project target from #{min_sdk} to #{MINIMUM_SUPPORTED_SDK_LEVEL}."
40
+ new_target_level = target_level
41
+ end
42
+ elsif min_sdk < MINIMUM_SUPPORTED_SDK_LEVEL
43
+ puts "Upgrading project target from #{min_sdk} to #{MINIMUM_SUPPORTED_SDK_LEVEL}."
44
+ new_target_level = MINIMUM_SUPPORTED_SDK_LEVEL
45
+ end
46
+ if new_target_level
47
+ File.open(prop_file, 'w') { |f| f << project_property_file.gsub(TARGET_VERSION_REGEXP, "\\1#{new_target_level}") }
32
48
  end
33
49
  end
34
-
35
- system "android update project -p #{root} -n #{name} --subprojects"
36
- raise "android update project failed with return code #{$?}" unless $? == 0
37
50
  end
38
51
 
39
- def update_test(force = nil)
52
+ def update_test(force, target_level = nil)
40
53
  root = Dir.getwd
41
54
  if !File.exists?("#{root}/test") || !File.exists?("#{root}/test/AndroidManifest.xml") || !File.exists?("#{root}/test/ant.properties")
42
55
  name = verify_strings.root.elements['string'].text.gsub(' ', '')
@@ -47,6 +60,7 @@ module Ruboto
47
60
  end
48
61
 
49
62
  Dir.chdir File.join(root, 'test') do
63
+ update_project_properties_target_level('project.properties', target_level)
50
64
  instrumentation_property = "test.runner=org.ruboto.test.InstrumentationTestRunner\n"
51
65
  prop_file = 'ant.properties'
52
66
  prop_lines = (prop_lines_org = File.read(prop_file)).dup
@@ -132,21 +146,21 @@ module Ruboto
132
146
  end
133
147
  end
134
148
 
135
- def update_jruby(force=nil, explicit = false)
149
+ def update_jruby(force, version, explicit = false)
136
150
  installed_jruby_core = Dir.glob('libs/jruby-core-*.jar')[0]
137
151
  installed_jruby_stdlib = Dir.glob('libs/jruby-stdlib-*.jar')[0]
138
152
 
139
- unless force
140
- if !installed_jruby_core || !installed_jruby_stdlib
141
- puts "Cannot find existing jruby jars in libs. Make sure you're in the root directory of your app." if explicit
142
- return false
143
- end
153
+ unless force || (installed_jruby_core && installed_jruby_stdlib)
154
+ puts "Cannot find existing jruby jars in libs. Make sure you're in the root directory of your app." if explicit
155
+ return false
144
156
  end
145
157
 
146
- install_jruby_jars_gem
158
+ install_jruby_jars_gem(version)
147
159
  begin
160
+ gem('jruby-jars', version) if version
148
161
  require 'jruby-jars'
149
162
  rescue LoadError
163
+ puts $!
150
164
  puts "Could not find the jruby-jars gem. You need it to include JRuby in your app. Please install it using\n\n gem install jruby-jars\n\n"
151
165
  return false
152
166
  end
@@ -167,7 +181,6 @@ module Ruboto
167
181
  log_action("Removing #{installed_jruby_core}") { File.delete *Dir.glob('libs/jruby-core-*.jar') } if installed_jruby_core
168
182
  log_action("Removing #{installed_jruby_stdlib}") { File.delete *Dir.glob('libs/jruby-stdlib-*.jar') } if installed_jruby_stdlib
169
183
  log_action("Copying #{JRubyJars::core_jar_path} to libs") { FileUtils.cp JRubyJars::core_jar_path, "libs/jruby-core-#{new_jruby_version}.jar" }
170
- log_action("Copying #{JRubyJars::stdlib_jar_path} to libs") { FileUtils.cp JRubyJars::stdlib_jar_path, "libs/jruby-stdlib-#{new_jruby_version}.jar" }
171
184
 
172
185
  unless File.read('project.properties') =~ /^dex.force.jumbo=/
173
186
  log_action('Setting JUMBO dex file format') do
@@ -185,14 +198,14 @@ module Ruboto
185
198
  true
186
199
  end
187
200
 
188
- def install_jruby_jars_gem
189
- if (jars_version_from_env = ENV['JRUBY_JARS_VERSION'])
190
- version_requirement = " -v #{jars_version_from_env}"
201
+ def install_jruby_jars_gem(jruby_jars_version = ENV['JRUBY_JARS_VERSION'])
202
+ if jruby_jars_version
203
+ version_requirement = " -v #{jruby_jars_version}"
191
204
  end
192
205
  `gem query -i -n jruby-jars#{version_requirement}`
193
206
  unless $? == 0
194
207
  local_gem_dir = ENV['LOCAL_GEM_DIR'] || Dir.getwd
195
- local_gem_file = "#{local_gem_dir}/jruby-jars-#{jars_version_from_env}.gem"
208
+ local_gem_file = "#{local_gem_dir}/jruby-jars-#{jruby_jars_version}.gem"
196
209
  if File.exists?(local_gem_file)
197
210
  system "gem install -l #{local_gem_file} --no-ri --no-rdoc"
198
211
  else
@@ -200,14 +213,6 @@ module Ruboto
200
213
  end
201
214
  end
202
215
  raise "install of jruby-jars failed with return code #$?" unless $? == 0
203
- if jars_version_from_env
204
- exclusion_clause = %Q{-v "!=#{jars_version_from_env}"}
205
- `gem query -i -n jruby-jars #{exclusion_clause}`
206
- if $? == 0
207
- system %Q{gem uninstall jruby-jars --all #{exclusion_clause}}
208
- raise "Uninstall of jruby-jars failed with return code #$?" unless $? == 0
209
- end
210
- end
211
216
  Gem.refresh
212
217
  end
213
218
 
@@ -234,6 +239,12 @@ module Ruboto
234
239
  weak_copier = Ruboto::Util::AssetCopier.new Ruboto::ASSETS, '.', false
235
240
  %w{.gitignore Rakefile ruboto.yml}.each { |f| log_action(f) { weak_copier.copy f } }
236
241
 
242
+ # FIXME(uwe): Only present in Ruboto 1.0.3. Remove when we stop supporting updating from Ruboto 1.0.3
243
+ FileUtils.mv('rakelib/stdlib.rake', 'rakelib/ruboto.stdlib.rake') if File.exists?('rakelib/stdlib.rake')
244
+ FileUtils.mv('rakelib/stdlib.yml', 'rakelib/ruboto.stdlib.yml') if File.exists?('rakelib/stdlib.yml')
245
+ FileUtils.mv('rakelib/stdlib_dependencies.rb', 'ruboto.stdlib.rb') if File.exists?('rakelib/stdlib_dependencies.rb')
246
+ # EMXIF
247
+
237
248
  copier = Ruboto::Util::AssetCopier.new Ruboto::ASSETS, '.'
238
249
  %w{assets rakelib res/layout test}.each do |f|
239
250
  log_action(f) { copier.copy f }
@@ -324,10 +335,12 @@ module Ruboto
324
335
  app_element = verify_manifest.elements['application']
325
336
  app_element.attributes['android:icon'] ||= '@drawable/ic_launcher'
326
337
 
338
+ # FIXME(uwe): Simplify when we stop supporting Android 2.3.x
327
339
  if min_sdk.to_i >= 11
328
340
  app_element.attributes['android:hardwareAccelerated'] ||= 'true'
329
341
  app_element.attributes['android:largeHeap'] ||= 'true'
330
342
  end
343
+ # EMXIF
331
344
 
332
345
  unless app_element.elements["activity[@android:name='org.ruboto.RubotoActivity']"]
333
346
  app_element.add_element 'activity', {'android:name' => 'org.ruboto.RubotoActivity', 'android:exported' => 'false'}
@@ -360,7 +373,7 @@ module Ruboto
360
373
  if File.exists?('ruboto.yml')
361
374
  sleep 1
362
375
  FileUtils.touch 'ruboto.yml'
363
- system 'rake jruby_adapter'
376
+ system 'rake build_xml jruby_adapter'
364
377
  end
365
378
  end
366
379
 
@@ -397,14 +410,15 @@ module Ruboto
397
410
  end
398
411
  end
399
412
 
400
- def reconfigure_jruby_libs(jruby_core_version)
401
- reconfigure_jruby_core(jruby_core_version)
402
- reconfigure_jruby_stdlib
413
+ def reconfigure_jruby_libs(jruby_version)
414
+ reconfigure_jruby_core(jruby_version)
415
+ reconfigure_jruby_stdlib(jruby_version)
403
416
  reconfigure_dx_jar
404
417
  end
405
418
 
406
419
  # - Removes unneeded code from jruby-core
407
420
  # - Split into smaller jars that can be used separately
421
+ # FIXME(uwe): Refactor to take a Gem::Version as the parameter.
408
422
  def reconfigure_jruby_core(jruby_core_version)
409
423
  Dir.chdir 'libs' do
410
424
  jruby_core = Dir['jruby-core-*.jar'][-1]
@@ -416,7 +430,7 @@ module Ruboto
416
430
  `jar -xf #{jruby_core}`
417
431
  raise "Unpacking jruby-core jar failed: #$?" unless $? == 0
418
432
  File.delete jruby_core
419
- gem_version = Gem::Version.new(jruby_core_version.tr('-', '.'))
433
+ gem_version = Gem::Version.new(jruby_core_version.to_s.tr('-', '.'))
420
434
  if gem_version >= Gem::Version.new('9000.dev')
421
435
  #noinspection RubyLiteralArrayInspection
422
436
  excluded_core_packages = [
@@ -432,12 +446,14 @@ module Ruboto
432
446
  'com/kenai/jffi',
433
447
  'com/kenai/jnr/x86asm',
434
448
  'com/martiansoftware',
449
+ 'com/oracle/truffle',
435
450
  'jni',
436
451
  'jnr/constants/platform/darwin',
437
452
  'jnr/constants/platform/fake',
438
453
  'jnr/constants/platform/freebsd',
439
454
  'jnr/constants/platform/openbsd',
440
455
  'jnr/constants/platform/sunos',
456
+ 'jnr/enxio',
441
457
  'jnr/ffi/annotations',
442
458
  'jnr/ffi/byref',
443
459
  'jnr/ffi/mapper',
@@ -445,6 +461,7 @@ module Ruboto
445
461
  'jnr/ffi/util',
446
462
  'jnr/ffi/Struct$*',
447
463
  'jnr/ffi/types',
464
+ # 'jnr/netdb',
448
465
  'jnr/posix/Aix*',
449
466
  'jnr/posix/FreeBSD*',
450
467
  'jnr/posix/MacOS*',
@@ -459,6 +476,7 @@ module Ruboto
459
476
  'org/jruby/embed/bsf',
460
477
  'org/jruby/embed/jsr223',
461
478
  'org/jruby/embed/osgi',
479
+ 'org/jruby/ext/ffi/Enums*',
462
480
  # 'org/jruby/ext/tracepoint',
463
481
  'org/jruby/javasupport/bsf',
464
482
  # 'org/jruby/management', # should be excluded
@@ -467,18 +485,24 @@ module Ruboto
467
485
  # 'org/jruby/runtime/opto/OptoFactory*', # What is this?
468
486
  'org/jruby/truffle',
469
487
  'org/yecht',
488
+ 'yaml.rb', # This looks like 1.8 stdlib...
470
489
  ]
471
490
  elsif gem_version >= Gem::Version.new('1.7.12')
472
- excluded_core_packages = %w(**/*Darwin* **/*Solaris* **/*windows* **/*Windows* META-INF 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)
491
+ excluded_core_packages = %w(**/*Darwin* **/*Solaris* **/*windows* **/*Windows* META-INF com/headius/invokebinder com/headius/options/example 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/enxio 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/Enums* org/jruby/ext/ffi/io org/jruby/ext/ffi/jffi org/jruby/ext/tracepoint org/jruby/javasupport/bsf org/yecht yaml.rb)
473
492
  elsif gem_version >= Gem::Version.new('1.7.5')
493
+ # TODO(uwe): Remove when we stop supporting jruby-jars 1.7.5
474
494
  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)
475
495
  elsif gem_version >= Gem::Version.new('1.7.4')
496
+ # TODO(uwe): Remove when we stop supporting jruby-jars 1.7.4
476
497
  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)
477
498
  elsif gem_version >= Gem::Version.new('1.7.3')
499
+ # TODO(uwe): Remove when we stop supporting jruby-jars 1.7.3
478
500
  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)
479
501
  elsif gem_version >= Gem::Version.new('1.7.2')
502
+ # TODO(uwe): Remove when we stop supporting jruby-jars 1.7.2
480
503
  excluded_core_packages = %w(**/*Darwin* **/*Ruby20* **/*Solaris* **/*windows* **/*Windows* META-INF com/headius com/kenai/constantine com/kenai/jffi 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/MacOS* jnr/posix/OpenBSD* org/apache org/fusesource org/jruby/ant org/jruby/cext org/jruby/compiler/util org/jruby/demo org/jruby/embed/bsf org/jruby/embed/jsr223 org/jruby/embed/osgi org/jruby/ext/ffi/io org/jruby/ext/ffi/jffi org/jruby/javasupport/bsf)
481
504
  elsif gem_version >= Gem::Version.new('1.7.1')
505
+ # TODO(uwe): Remove when we stop supporting jruby-jars 1.7.1
482
506
  excluded_core_packages = %w(**/*Darwin* **/*Ruby20* **/*Solaris* **/*windows* **/*Windows* META-INF com/headius com/kenai/constantine com/kenai/jffi 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/MacOS* jnr/posix/OpenBSD* org/apache org/fusesource org/jruby/ant org/jruby/cext org/jruby/compiler/util org/jruby/demo org/jruby/embed/bsf org/jruby/embed/jsr223 org/jruby/embed/osgi org/jruby/ext/ffi/io org/jruby/ext/ffi/jffi org/jruby/ext/openssl org/jruby/javasupport/bsf org/jruby/org/bouncycastle)
483
507
  elsif gem_version >= Gem::Version.new('1.7.0')
484
508
  # TODO(uwe): Remove when we stop supporting jruby-jars 1.7.0
@@ -545,8 +569,14 @@ module Ruboto
545
569
  end
546
570
 
547
571
  # - Moves ruby stdlib to the root of the jruby-stdlib jar
548
- def reconfigure_jruby_stdlib
549
- abort "cannot find rakelib/stdlib.rake; make sure you update your app (ruboto update app)" unless File.exists?("rakelib/stdlib.rake")
572
+ def reconfigure_jruby_stdlib(jruby_version)
573
+ # FIXME(uwe): Introduced in Ruboto 1.0.3. Remove when we stop supporting upgrading from Ruboto 1.0.3.
574
+ unless File.exists?('rakelib/ruboto.stdlib.rake') || File.exists?('rakelib/stdlib.rake')
575
+ abort 'cannot find rakelib/ruboto.stdlib.rake; make sure you update your app (ruboto update app)'
576
+ end
577
+ # EMXIF
578
+
579
+ ENV['JRUBY_JARS_VERSION'] = jruby_version
550
580
  system 'rake libs:reconfigure_stdlib'
551
581
  end
552
582
 
@@ -1,4 +1,4 @@
1
1
  module Ruboto
2
- VERSION = '1.0.3'
2
+ VERSION = '1.1.0'
3
3
  UPDATE_VERSION_LIMIT = '0.7.0'
4
4
  end
@@ -87,7 +87,9 @@ 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
+ puts 'waitForIdleSync'
90
91
  waitForIdleSync
92
+ puts 'wait_for_monitor_with_timeout'
91
93
  current_activity = wait_for_monitor_with_timeout(monitor, 10000)
92
94
  ensure
93
95
  removeMonitor(monitor)
@@ -8,24 +8,41 @@ class SslActivity
8
8
  super
9
9
  puts 'start thread'
10
10
  @thread = Thread.with_large_stack { require 'net/https' }
11
+ @open_uri_thread = Thread.with_large_stack { require 'open-uri' }
11
12
  puts 'thread started'
12
13
  set_title File.basename(__FILE__).chomp('_activity.rb').split('_').map { |s| "#{s[0..0].upcase}#{s[1..-1]}" }.join(' ')
13
14
  self.content_view =
14
15
  linear_layout :orientation => LinearLayout::VERTICAL, :gravity => android.view.Gravity::CENTER do
15
- @text_view = text_view :id => 42, :text => 'net/https loading...',
16
- :text_size => 48.0, :gravity => android.view.Gravity::CENTER
16
+ @text_view = text_view text: 'net/https loading...',
17
+ text_size: 48.0, gravity: :center, id: 42
18
+ @response_view = text_view text: 'net/https loading...',
19
+ text_size: 48.0, gravity: :center, id: 43
17
20
  end
18
21
  end
19
22
 
20
23
  def onResume
21
24
  super
22
- puts 'on resume my lord'
23
- Thread.start do
24
- puts 'joining thread'
25
- @thread.join
26
- puts 'thread joined'
27
- run_on_ui_thread{@text_view.text = 'net/https loaded OK!'}
28
- puts 'text updated'
25
+ Thread.with_large_stack do
26
+ begin
27
+ @thread.join
28
+ run_on_ui_thread { @text_view.text = 'net/https loaded OK!' }
29
+ @open_uri_thread.join
30
+ run_on_ui_thread { @response_view.text = 'open-uri loaded OK!' }
31
+ puts 'before open'
32
+ ENV['TMPDIR'] = files_dir.absolute_path
33
+ open('https://google.com/', ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE) do |f|
34
+ puts 'inside open'
35
+ body = f.read
36
+ puts 'body'
37
+ puts body
38
+ heading = body[%r{<title>.*?</title>}]
39
+ puts heading.inspect
40
+ run_on_ui_thread { @response_view.text = heading }
41
+ end
42
+ rescue Exception
43
+ puts "Exception resdum: #{$!.class} #{$!.message}"
44
+ run_on_ui_thread { @response_view.text = $!.to_s }
45
+ end
29
46
  end
30
47
  end
31
48
  end
@@ -4,19 +4,27 @@ setup do |activity|
4
4
  start = Time.now
5
5
  loop do
6
6
  @text_view = activity.findViewById(42)
7
- break if @text_view || (Time.now - start > 60)
7
+ @response_view = activity.findViewById(43)
8
+ break if (@text_view && @response_view)|| (Time.now - start > 60)
8
9
  sleep 1
9
10
  end
10
- assert @text_view
11
+ assert @text_view && @response_view
11
12
  end
12
13
 
13
14
  test('load net/https', :ui => false) do |activity|
14
15
  start = Time.now
15
- expected = 'net/https loaded OK'
16
+ expected = 'net/https loaded OK!'
17
+ response_expected = '<title>Google</title>'
18
+ result = response = nil
16
19
  loop do
17
- result = activity.run_on_ui_thread { activity.find_view_by_id(42).text.to_s }
18
- break if result == expected || (Time.now - start > 120)
19
- sleep 5
20
+ activity.run_on_ui_thread do
21
+ result = @text_view.text.to_s
22
+ response = @response_view.text.to_s
23
+ end
24
+ break if (result == expected && response == response_expected) ||
25
+ (Time.now - start > 60)
26
+ sleep 0.5
20
27
  end
21
28
  assert_equal expected, result
29
+ assert_equal response_expected, response
22
30
  end
@@ -16,6 +16,7 @@ module AppTestMethods
16
16
  assert_code 'YamlLoads', "require 'yaml'"
17
17
 
18
18
  assert_code 'ReadSourceFile', 'File.read(__FILE__)'
19
+ # noinspection RubyExpressionInStringInspection
19
20
  assert_code 'DirListsFilesInApk', 'Dir["#{File.dirname(__FILE__)}/*"].each{|f| raise "File #{f.inspect} not found" unless File.exists?(f)}'
20
21
  assert_code 'RepeatRubotoImportWidget', 'ruboto_import_widget :TextView ; ruboto_import_widget :TextView'
21
22
  end
@@ -37,8 +38,12 @@ module AppTestMethods
37
38
 
38
39
  def run_activity_tests(activity_dir)
39
40
  Dir[File.expand_path("#{activity_dir}/*", File.dirname(__FILE__))].each do |file|
40
- # FIXME(uwe): Remove when we include jopenssl and bouncycastle
41
- next if file =~ /ssl/
41
+ # FIXME(uwe): Remove when we stop testing api level < 16
42
+ # FIXME(uwe): Remove when we release RubotoCore with SSL included
43
+ next if file =~ /ssl/ && (ANDROID_OS < 16 ||
44
+ RUBOTO_PLATFORM == 'CURRENT' || RUBOTO_PLATFORM == 'FROM_GEM' ||
45
+ JRUBY_JARS_VERSION < Gem::Version.new('1.7.13') ||
46
+ JRUBY_JARS_VERSION < Gem::Version.new('9000')) # FIXME(uwe): JRuby 9K should contain the SSLSocket fix.
42
47
  # EMXIF
43
48
 
44
49
  # FIXME(uwe): Remove when we stop testing JRuby < 1.7.4.dev
@@ -61,7 +66,7 @@ module AppTestMethods
61
66
  end
62
67
  elsif !File.exists? "#{file.chomp('.rb')}'_test.rb'"
63
68
  Dir.chdir APP_DIR do
64
- FileUtils.cp file, "src/"
69
+ FileUtils.cp file, 'src/'
65
70
  end
66
71
  end
67
72
  end
@@ -52,7 +52,9 @@ class RubotoGenTest < Test::Unit::TestCase
52
52
  # APK was 59.6KB. PLATFORM: CURRENT, ANDROID_TARGET: 10
53
53
  # APK was 60.2KB. PLATFORM: CURRENT, ANDROID_TARGET: 15
54
54
  # APK was 74.9KB. PLATFORM: CURRENT, ANDROID_TARGET: 16
55
- # APK was 57.1KB. PLATFORM: FROM_GEM, ANDROID_TARGET: 10
55
+ # APK was 80.4KB. PLATFORM: CURRENT, ANDROID_TARGET: 19
56
+ # APK was 65.0KB. PLATFORM: FROM_GEM, ANDROID_TARGET: 10
57
+ # APK was 80.2KB. PLATFORM: FROM_GEM, ANDROID_TARGET: 17
56
58
  # APK was 8428.4KB. PLATFORM: STANDALONE, ANDROID_TARGET: 10, JRuby: 1.7.4
57
59
  # APK was 7405.8KB. PLATFORM: STANDALONE, ANDROID_TARGET: 15, JRuby: 1.7.4
58
60
  # APK was 7420.9KB. PLATFORM: STANDALONE, ANDROID_TARGET: 16, JRuby: 1.7.4
@@ -64,10 +66,12 @@ class RubotoGenTest < Test::Unit::TestCase
64
66
  # APK was 8791.2KB. PLATFORM: STANDALONE, ANDROID_TARGET: 16, JRuby: 1.7.10
65
67
  # APK was 8575.0KB. PLATFORM: STANDALONE, ANDROID_TARGET: 10, JRuby: 1.7.11
66
68
  # APK was 8793.4KB. PLATFORM: STANDALONE, ANDROID_TARGET: 16, JRuby: 1.7.11
67
- # APK was 8820.3KB. PLATFORM: STANDALONE, ANDROID_TARGET: 19, JRuby: 1.7.12
69
+ # APK was 9743.3KB. PLATFORM: STANDALONE, ANDROID_TARGET: 16, JRuby: 1.7.12
70
+ # APK was 9123.8KB. PLATFORM: STANDALONE, ANDROID_TARGET: 19, JRuby: 1.7.12
68
71
  # APK was 6689.5KB. PLATFORM: STANDALONE, ANDROID_TARGET: 10, JRuby: 9000.dev
69
72
  # APK was 7012.2KB. PLATFORM: STANDALONE, ANDROID_TARGET: 16, JRuby: 9000.dev
70
- # APK was 7201.1KB. PLATFORM: STANDALONE, ANDROID_TARGET: 17, JRuby: 9000.dev
73
+ # APK was 8015.9KB. PLATFORM: STANDALONE, ANDROID_TARGET: 17, JRuby: 9000.dev
74
+ # APK was 7386.1KB. PLATFORM: STANDALONE, ANDROID_TARGET: 19, JRuby: 9000.dev
71
75
  def test_new_apk_size_is_within_limits
72
76
  apk_size = BigDecimal(File.size("#{APP_DIR}/bin/RubotoTestApp-debug.apk").to_s) / 1024
73
77
  version = " PLATFORM: #{RUBOTO_PLATFORM}"
@@ -81,15 +85,17 @@ class RubotoGenTest < Test::Unit::TestCase
81
85
  '1.7.9' => 8800.0,
82
86
  '1.7.10' => 8800.0,
83
87
  '1.7.11' => 8800.0,
84
- '1.7.12' => 8900.0,
85
- '9000.dev' => 7300.0,
88
+ '1.7.12' => 9800.0,
89
+ '9000.dev' => 8100.0,
86
90
  }[JRUBY_JARS_VERSION.to_s] || 0.0
87
91
  version << ", JRuby: #{JRUBY_JARS_VERSION.to_s}"
88
92
  else
89
93
  upper_limit = {
90
- 10 => 60.0,
94
+ 10 => 66.0,
91
95
  15 => 62.0,
92
96
  16 => 75.0,
97
+ 17 => 81.0,
98
+ 19 => 81.0,
93
99
  }[ANDROID_TARGET] || 75.0
94
100
  end
95
101
  lower_limit = upper_limit * 0.7
@@ -274,7 +280,7 @@ EOF
274
280
  if RUBOTO_PLATFORM == 'FROM_GEM'
275
281
  def test_gen_jruby
276
282
  Dir.chdir APP_DIR do
277
- system "#{RUBOTO_CMD} gen jruby"
283
+ system "#{RUBOTO_CMD} gen jruby #{JRUBY_JARS_VERSION}"
278
284
  assert_equal 0, $?.exitstatus
279
285
  assert_equal %W(libs/jruby-core-#{JRUBY_JARS_VERSION.to_s.downcase}.jar), Dir['libs/jruby-core-*.jar'].map(&:downcase)
280
286
  assert_equal %W(libs/jruby-stdlib-#{JRUBY_JARS_VERSION.to_s.downcase}.jar), Dir['libs/jruby-stdlib-*.jar'].map(&:downcase)
@@ -0,0 +1,21 @@
1
+ require File.expand_path('test_helper', File.dirname(__FILE__))
2
+ require 'net/http'
3
+
4
+ class SetupTest < Test::Unit::TestCase
5
+ SDK_DOWNLOAD_PAGE = 'http://developer.android.com/sdk/index.html?hl=sk'
6
+
7
+ def test_if_page_still_exists
8
+ uri = URI.parse(SDK_DOWNLOAD_PAGE)
9
+ res = Net::HTTP.get_response(uri)
10
+
11
+ assert_equal 200, res.code.to_i
12
+ end
13
+
14
+ def test_if_regex_still_applies_to_sdk
15
+ regex = '(\>installer_.*.exe)'
16
+ page_content = Net::HTTP.get(URI.parse(SDK_DOWNLOAD_PAGE))
17
+ link = page_content.scan(/#{regex}/).to_s
18
+ assert_match /(\d+).(\d+).(\d+)/, link
19
+ end
20
+
21
+ end
@@ -13,36 +13,34 @@ Dir.chdir "#{RubotoTest::PROJECT_DIR}/examples/" do
13
13
  example_archives = Dir["#{RubotoTest::APP_NAME}_*_tools_r*.tgz"]
14
14
  example_archives = example_archives.sort_by { |a| Gem::Version.new(a[RubotoTest::APP_NAME.size + 1..-1].slice(/(.*)(?=_tools_)/).gsub('_', '.')) }
15
15
  example_archives = example_archives.last(example_limit) if example_limit
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
16
  examples = example_archives.collect { |f| f.match /^#{RubotoTest::APP_NAME}_(?<ruboto_version>.*)_tools_r(?<tools_version>.*)\.tgz$/ }.compact
23
17
 
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 #{example_archives[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
18
+ # TODO(gf): Track APIs compatible with update examples
19
+ # EXAMPLE_COMPATIBLE_APIS = {(Gem::Version.new('0.7.0')..Gem::Version.new('0.10.99')) => [8],
20
+ # (Gem::Version.new('0.11.0')..Gem::Version.new('0.13.0')) => [10, 11, 12, 13, 14, 15, 16, 17]}
21
+ # installed_apis = `android list target --compact`.lines.grep(/^android-/) { |s| s.match(/\d+/).to_s.to_i }
22
+ # missing_apis = false
23
+ # puts "Backward compatibility update tests: #{examples.size}"
24
+ # examples.each_with_index do |m, i|
25
+ # example_gem_version = Gem::Version.new m[:ruboto_version]
26
+ # compatible_apis = EXAMPLE_COMPATIBLE_APIS[EXAMPLE_COMPATIBLE_APIS.keys.detect { |gem_range| gem_range.cover? example_gem_version }]
27
+ # if compatible_apis
28
+ # if (installed_apis & compatible_apis).empty?
29
+ # puts "Update test #{example_archives[i]} needs a missing compatible API: #{compatible_apis.join(',')}"
30
+ # # missing_apis = true
31
+ # end
32
+ # end
33
+ # end
34
+ #
35
+ # if missing_apis
36
+ # puts '----------------------------------------------------------------------------------------------------'
37
+ # puts 'Required android APIs are missing, resolution options are:'
38
+ # puts '* Install a needed android API with "android update sdk --no-ui --all --filter android-XX"'
39
+ # puts '* Skip all backward compatibility update tests with "SKIP_RUBOTO_UPDATE_TEST=DEFINED rake test"'
40
+ # puts '* Limit number of backward compatibility update tests to N with "RUBOTO_UPDATE_EXAMPLES=N rake test"'
41
+ # puts 'Quitting...'
42
+ # exit false
43
+ # end
46
44
 
47
45
  examples.each do |m|
48
46
  ruboto_version = m[:ruboto_version]