ruboto 0.5.2 → 0.5.3
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.
- data/Gemfile.lock +5 -5
- data/README.md +2 -2
- data/Rakefile +5 -6
- data/assets/Rakefile +32 -11
- data/assets/res/drawable/get_ruboto_core.png +0 -0
- data/assets/res/layout/get_ruboto_core.xml +1 -1
- data/assets/samples/sample_activity.rb +13 -11
- data/assets/samples/sample_broadcast_receiver.rb +6 -3
- data/assets/samples/sample_service.rb +10 -7
- data/assets/src/InheritingActivity.java +1 -186
- data/assets/src/RubotoActivity.java +9 -11
- data/assets/src/RubotoBroadcastReceiver.java +34 -27
- data/assets/src/RubotoService.java +9 -2
- data/assets/src/org/ruboto/EntryPointActivity.java +194 -0
- data/assets/src/org/ruboto/Script.java +29 -15
- data/assets/src/org/ruboto/test/InstrumentationTestRunner.java +17 -16
- data/assets/src/ruboto.rb +11 -608
- data/assets/src/ruboto/activity.rb +84 -0
- data/assets/src/ruboto/base.rb +88 -0
- data/assets/src/ruboto/broadcast_receiver.rb +31 -0
- data/assets/src/ruboto/legacy.rb +223 -0
- data/assets/src/ruboto/menu.rb +89 -0
- data/assets/src/ruboto/preference.rb +78 -0
- data/assets/src/ruboto/service.rb +74 -0
- data/assets/src/ruboto/util/stack.rb +34 -0
- data/assets/src/ruboto/util/toast.rb +18 -0
- data/assets/src/ruboto/widget.rb +188 -0
- data/assets/test/{assets/scripts → src}/test_helper.rb +4 -0
- data/bin/ruboto +7 -0
- data/lib/ruboto/commands/base.rb +4 -18
- data/lib/ruboto/util/build.rb +1 -2
- data/lib/ruboto/util/update.rb +77 -70
- data/lib/ruboto/version.rb +1 -1
- data/test/activity/psych_activity.rb +25 -0
- data/test/activity/psych_activity_test.rb +16 -0
- data/test/activity/stack_activity_test.rb +1 -1
- data/test/app_test_methods.rb +8 -4
- data/test/minimal_app_test.rb +6 -3
- data/test/rake_test.rb +1 -1
- data/test/ruboto_gen_test.rb +10 -1
- data/test/test_helper.rb +3 -5
- data/test/update_test_methods.rb +2 -2
- metadata +20 -8
- data/test/ruboto_gen_with_psych_test.rb +0 -16
- data/test/ruboto_update_with_psych_test.rb +0 -18
data/lib/ruboto/util/build.rb
CHANGED
@@ -186,10 +186,9 @@ module Ruboto
|
|
186
186
|
puts "Added file #{script_file}."
|
187
187
|
end
|
188
188
|
|
189
|
-
test_file = File.expand_path("test/
|
189
|
+
test_file = File.expand_path("test/src/#{script_name.chomp('.rb')}_test.rb", dest)
|
190
190
|
if !File.exists? test_file
|
191
191
|
sample_test_source = File.read(File.join(Ruboto::ASSETS, "samples/sample_#{underscore klass}_test.rb")).gsub("THE_PACKAGE", package).gsub("Sample#{klass}", name)
|
192
|
-
FileUtils.mkdir_p File.join(dest, 'test/assets/scripts')
|
193
192
|
File.open test_file, "a" do |f|
|
194
193
|
f << sample_test_source
|
195
194
|
end
|
data/lib/ruboto/util/update.rb
CHANGED
@@ -119,10 +119,19 @@ EOF
|
|
119
119
|
ant_script.gsub!(/\s*<!-- BEGIN added by ruboto(?:-core)? -->.*?<!-- END added by ruboto(?:-core)? -->\s*/m, '')
|
120
120
|
raise "Bad ANT script" unless ant_script.gsub!(ant_setup_line, "#{run_tests_override}\n\n\\1")
|
121
121
|
File.open('build.xml', 'w'){|f| f << ant_script}
|
122
|
+
|
123
|
+
# FIXME(uwe): Remove when we stop supporting update from Ruboto <= 0.5.2
|
124
|
+
if File.directory? 'assets/scripts'
|
125
|
+
log_action 'Moving test scripts to the "src" directory.' do
|
126
|
+
FileUtils.mv Dir['assets/scripts/*'], 'src'
|
127
|
+
FileUtils.rm_rf 'assets/scripts'
|
128
|
+
end
|
129
|
+
end
|
130
|
+
# FIXME end
|
122
131
|
end
|
123
132
|
end
|
124
133
|
|
125
|
-
def update_jruby(force=nil
|
134
|
+
def update_jruby(force=nil)
|
126
135
|
jruby_core = Dir.glob("libs/jruby-core-*.jar")[0]
|
127
136
|
jruby_stdlib = Dir.glob("libs/jruby-stdlib-*.jar")[0]
|
128
137
|
new_jruby_version = JRubyJars::VERSION
|
@@ -149,7 +158,7 @@ EOF
|
|
149
158
|
log_action("Copying #{JRubyJars::core_jar_path} to libs") {copier.copy_from_absolute_path JRubyJars::core_jar_path, "libs"}
|
150
159
|
log_action("Copying #{JRubyJars::stdlib_jar_path} to libs") {copier.copy_from_absolute_path JRubyJars::stdlib_jar_path, "libs"}
|
151
160
|
|
152
|
-
reconfigure_jruby_libs(new_jruby_version
|
161
|
+
reconfigure_jruby_libs(new_jruby_version)
|
153
162
|
|
154
163
|
puts "JRuby version is now: #{new_jruby_version}"
|
155
164
|
true
|
@@ -177,6 +186,7 @@ EOF
|
|
177
186
|
copier = Ruboto::Util::AssetCopier.new Ruboto::ASSETS, '.', force
|
178
187
|
log_action('icons') do
|
179
188
|
copier.copy 'res/drawable*/icon.png'
|
189
|
+
copier.copy 'res/drawable/get_ruboto_core.png'
|
180
190
|
copier.copy 'res/drawable*/icon.png', 'test'
|
181
191
|
end
|
182
192
|
end
|
@@ -212,7 +222,7 @@ EOF
|
|
212
222
|
end
|
213
223
|
|
214
224
|
def update_manifest(min_sdk, target, force = false)
|
215
|
-
log_action("\nAdding
|
225
|
+
log_action("\nAdding RubotoActivity, RubotoDialog, RubotoService, and SDK versions to the manifest") do
|
216
226
|
if sdk_element = verify_manifest.elements['uses-sdk']
|
217
227
|
min_sdk ||= sdk_element.attributes["android:minSdkVersion"]
|
218
228
|
target ||= sdk_element.attributes["android:targetSdkVersion"]
|
@@ -220,22 +230,27 @@ EOF
|
|
220
230
|
min_sdk ||= MINIMUM_SUPPORTED_SDK
|
221
231
|
target ||= MINIMUM_SUPPORTED_SDK
|
222
232
|
end
|
233
|
+
|
223
234
|
app_element = verify_manifest.elements['application']
|
224
235
|
app_element.attributes['android:icon'] ||= '@drawable/icon'
|
236
|
+
|
225
237
|
if min_sdk.to_i >= 11
|
226
238
|
app_element.attributes['android:hardwareAccelerated'] ||= 'true'
|
227
239
|
app_element.attributes['android:largeHeap'] ||= 'true'
|
228
240
|
end
|
229
|
-
|
230
|
-
|
231
|
-
else
|
241
|
+
|
242
|
+
if !app_element.elements["activity[@android:name='org.ruboto.RubotoActivity']"]
|
232
243
|
app_element.add_element 'activity', {"android:name" => "org.ruboto.RubotoActivity", 'android:exported' => 'false'}
|
233
244
|
end
|
234
|
-
|
235
|
-
|
236
|
-
else
|
245
|
+
|
246
|
+
if !app_element.elements["activity[@android:name='org.ruboto.RubotoDialog']"]
|
237
247
|
app_element.add_element 'activity', {"android:name" => "org.ruboto.RubotoDialog", 'android:exported' => 'false', "android:theme" => "@android:style/Theme.Dialog"}
|
238
248
|
end
|
249
|
+
|
250
|
+
if !app_element.elements["service[@android:name='org.ruboto.RubotoService']"]
|
251
|
+
app_element.add_element 'service', {"android:name" => "org.ruboto.RubotoService", 'android:exported' => 'false'}
|
252
|
+
end
|
253
|
+
|
239
254
|
if sdk_element
|
240
255
|
sdk_element.attributes["android:minSdkVersion"] = min_sdk
|
241
256
|
sdk_element.attributes["android:targetSdkVersion"] = target
|
@@ -262,11 +277,25 @@ EOF
|
|
262
277
|
FileUtils.mkdir_p File.dirname(to)
|
263
278
|
FileUtils.cp from, to
|
264
279
|
end
|
280
|
+
log_action("Copying additional ruboto script components") do
|
281
|
+
Dir.glob(Ruboto::GEM_ROOT + "/assets/#{SCRIPTS_DIR}/ruboto/*.rb").each do |i|
|
282
|
+
from = File.expand_path(i)
|
283
|
+
to = File.expand_path("./#{SCRIPTS_DIR}/ruboto/#{File.basename(i)}")
|
284
|
+
FileUtils.mkdir_p File.dirname(to)
|
285
|
+
FileUtils.cp from, to
|
286
|
+
end
|
287
|
+
Dir.glob(Ruboto::GEM_ROOT + "/assets/#{SCRIPTS_DIR}/ruboto/util/*.rb").each do |i|
|
288
|
+
from = File.expand_path(i)
|
289
|
+
to = File.expand_path("./#{SCRIPTS_DIR}/ruboto/util/#{File.basename(i)}")
|
290
|
+
FileUtils.mkdir_p File.dirname(to)
|
291
|
+
FileUtils.cp from, to
|
292
|
+
end
|
293
|
+
end
|
265
294
|
end
|
266
295
|
|
267
|
-
def reconfigure_jruby_libs(jruby_core_version
|
296
|
+
def reconfigure_jruby_libs(jruby_core_version)
|
268
297
|
reconfigure_jruby_core(jruby_core_version)
|
269
|
-
reconfigure_jruby_stdlib
|
298
|
+
reconfigure_jruby_stdlib
|
270
299
|
end
|
271
300
|
|
272
301
|
# - Removes unneeded code from jruby-core
|
@@ -331,76 +360,54 @@ EOF
|
|
331
360
|
end
|
332
361
|
|
333
362
|
# - Moves ruby stdlib to the root of the jruby-stdlib jar
|
334
|
-
|
335
|
-
|
336
|
-
excluded_stdlibs = %w{} + (verify_ruboto_config[:excluded_stdlibs] || [])
|
363
|
+
def reconfigure_jruby_stdlib
|
364
|
+
excluded_stdlibs = [*verify_ruboto_config[:excluded_stdlibs]].compact
|
337
365
|
Dir.chdir 'libs' do
|
338
366
|
jruby_stdlib = JRubyJars::stdlib_jar_path.split('/')[-1]
|
339
|
-
stdlib_1_8_files = nil
|
340
367
|
log_action("Reformatting #{jruby_stdlib}") do
|
341
|
-
FileUtils.mkdir_p
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
FileUtils.move "META-INF/jruby.home/lib/ruby/1.8", "../new/lib/ruby"
|
349
|
-
Dir["META-INF/jruby.home/lib/ruby/site_ruby/1.8/*"].each do |f|
|
350
|
-
next if File.basename(f) =~ /^..?$/
|
351
|
-
FileUtils.move f, "../new/lib/ruby/1.8/" + File.basename(f)
|
352
|
-
end
|
353
|
-
Dir["META-INF/jruby.home/lib/ruby/site_ruby/shared/*"].each do |f|
|
354
|
-
next if File.basename(f) =~ /^..?$/
|
355
|
-
FileUtils.move f, "../new/lib/ruby/1.8/" + File.basename(f)
|
368
|
+
FileUtils.mkdir_p 'tmp'
|
369
|
+
Dir.chdir 'tmp' do
|
370
|
+
FileUtils.mkdir_p 'old'
|
371
|
+
FileUtils.mkdir_p 'new'
|
372
|
+
Dir.chdir 'old' do
|
373
|
+
`jar -xf ../../#{jruby_stdlib}`
|
356
374
|
end
|
357
|
-
|
358
|
-
|
375
|
+
FileUtils.move 'old/META-INF/jruby.home/lib', 'new'
|
376
|
+
|
377
|
+
FileUtils.rm_rf 'new/lib/ruby/gems'
|
378
|
+
|
359
379
|
if excluded_stdlibs.any?
|
360
|
-
excluded_stdlibs.each { |d| FileUtils.rm_rf d }
|
361
|
-
print "excluded #{excluded_stdlibs.join(' ')}..."
|
362
|
-
end
|
363
|
-
stdlib_1_8_files = Dir['**/*']
|
364
|
-
end
|
365
|
-
Dir.chdir "tmp/new" do
|
366
|
-
# Uncomment this part to split the stdlib into one jar per directory
|
367
|
-
# Dir['*'].select{|f| File.directory? f}.each do |d|
|
368
|
-
# `jar -cf ../jruby-stdlib-#{d}-#{JRubyJars::VERSION}.jar #{d}`
|
369
|
-
# FileUtils.rm_rf d
|
370
|
-
# end
|
371
|
-
|
372
|
-
`jar -cf ../../#{jruby_stdlib} .`
|
373
|
-
end
|
374
|
-
end
|
375
380
|
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
FileUtils.mkdir_p File.dirname(psych_dir)
|
384
|
-
FileUtils.move "tmp/old/META-INF/jruby.home/lib/ruby/1.9", psych_dir
|
385
|
-
Dir.chdir psych_dir do
|
386
|
-
if excluded_stdlibs.any?
|
387
|
-
excluded_stdlibs.each { |d| FileUtils.rm_rf d }
|
388
|
-
print "excluded #{excluded_stdlibs.join(' ')}..."
|
381
|
+
# TODO(uwe): Simplify when we stop supporting JRuby < 1.7.0
|
382
|
+
raise "Unrecognized JRuby stdlib jar: #{jruby_stdlib}" unless jruby_stdlib =~ /jruby-stdlib-(.*).jar/
|
383
|
+
jruby_version = Gem::Version.new($1)
|
384
|
+
if Gem::Requirement.new('< 1.7.0.dev') =~ jruby_version
|
385
|
+
lib_dirs = ['1.8', '1.9', 'site_ruby/1.8', 'site_ruby/1.9', 'site_ruby/shared']
|
386
|
+
else
|
387
|
+
lib_dirs = ['1.8', '1.9', 'shared']
|
389
388
|
end
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
389
|
+
# TODO end
|
390
|
+
|
391
|
+
lib_dirs.each do |ld|
|
392
|
+
excluded_stdlibs.each do |d|
|
393
|
+
dir = "new/lib/ruby/#{ld}/#{d}"
|
394
|
+
FileUtils.rm_rf dir if File.exists? dir
|
395
|
+
file = "#{dir}.rb"
|
396
|
+
FileUtils.rm_rf file if File.exists? file
|
397
397
|
end
|
398
398
|
end
|
399
|
+
print "excluded #{excluded_stdlibs.join(' ')}..."
|
399
400
|
end
|
400
|
-
|
401
|
-
|
401
|
+
|
402
|
+
Dir.chdir "new" do
|
403
|
+
# Uncomment this part to split the stdlib into one jar per directory
|
404
|
+
# Dir['*'].select{|f| File.directory? f}.each do |d|
|
405
|
+
# `jar -cf ../jruby-stdlib-#{d}-#{JRubyJars::VERSION}.jar #{d}`
|
406
|
+
# FileUtils.rm_rf d
|
407
|
+
# end
|
408
|
+
|
409
|
+
`jar -cf ../../#{jruby_stdlib} .`
|
402
410
|
end
|
403
|
-
FileUtils.remove_dir psych_dir, true
|
404
411
|
end
|
405
412
|
end
|
406
413
|
|
data/lib/ruboto/version.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'jruby'
|
2
|
+
require 'rbconfig'
|
3
|
+
org.jruby.ext.psych.PsychLibrary.new.load(JRuby.runtime, false)
|
4
|
+
$LOADED_FEATURES << 'psych.so'
|
5
|
+
$LOAD_PATH << File.join(Config::CONFIG['libdir'], 'ruby/1.9')
|
6
|
+
require 'psych.rb'
|
7
|
+
|
8
|
+
Psych::Parser
|
9
|
+
Psych::Handler
|
10
|
+
|
11
|
+
require 'ruboto'
|
12
|
+
|
13
|
+
ruboto_import_widgets :Button, :LinearLayout, :TextView
|
14
|
+
|
15
|
+
$activity.handle_create do |bundle|
|
16
|
+
setTitle File.basename(__FILE__).chomp('_activity.rb').split('_').map { |s| "#{s[0..0].upcase}#{s[1..-1]}" }.join(' ')
|
17
|
+
|
18
|
+
setup_content do
|
19
|
+
linear_layout :orientation => LinearLayout::VERTICAL do
|
20
|
+
@decoded_view = text_view :id => 42, :text => Psych.load('--- foo')
|
21
|
+
# @encoded_view = text_view :id => 43, :text => Psych.dump("foo")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
activity org.ruboto.test_app.PsychActivity
|
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('psych_encode_decode') do |activity|
|
14
|
+
assert_equal 'foo', activity.find_view_by_id(42).text.to_s
|
15
|
+
#assert_equal "--- foo\n...\n", activity.find_view_by_id(43).text.to_s
|
16
|
+
end
|
@@ -19,5 +19,5 @@ test('stack depth') do |activity|
|
|
19
19
|
assert_equal 44 + os_offset + jruby_offset[0], activity.find_view_by_id(42).text.to_i, version_message
|
20
20
|
assert_equal 68 + os_offset + jruby_offset[1], activity.find_view_by_id(43).text.to_i, version_message
|
21
21
|
assert_equal 77 + os_offset + jruby_offset[2], activity.find_view_by_id(44).text.to_i, version_message
|
22
|
-
assert_equal
|
22
|
+
assert_equal 93 + os_offset + jruby_offset[3], activity.find_view_by_id(45).text.to_i, version_message
|
23
23
|
end
|
data/test/app_test_methods.rb
CHANGED
@@ -4,22 +4,26 @@ module AppTestMethods
|
|
4
4
|
include RubotoTest
|
5
5
|
|
6
6
|
def test_activity_tests
|
7
|
-
|
8
|
-
|
9
|
-
else
|
7
|
+
# TODO(uwe): Remove check when we stop supporting jruby-jars 1.5.6
|
8
|
+
if ON_JRUBY_JARS_1_5_6
|
10
9
|
puts "Skipping YAML tests on jruby-jars-1.5.6"
|
10
|
+
else
|
11
|
+
assert_code 'YamlLoads', "with_large_stack{require 'yaml'}"
|
11
12
|
end
|
12
13
|
|
13
14
|
assert_code 'ReadSourceFile', "File.read(__FILE__)"
|
14
15
|
assert_code 'DirListsFilesInApk', 'Dir["#{File.dirname(__FILE__)}/*"].each{|f| raise "File #{f.inspect} not found" unless File.exists?(f)}'
|
15
16
|
|
16
17
|
Dir[File.expand_path('activity/*_test.rb', File.dirname(__FILE__))].each do |test_src|
|
18
|
+
# TODO(uwe): Remove check when we stop supporting jruby-jars 1.5.6
|
19
|
+
next if ON_JRUBY_JARS_1_5_6 && test_src =~ /psych_activity_test.rb$/
|
20
|
+
|
17
21
|
snake_name = test_src.chomp('_test.rb')
|
18
22
|
activity_name = File.basename(snake_name).split('_').map { |s| "#{s[0..0].upcase}#{s[1..-1]}" }.join
|
19
23
|
Dir.chdir APP_DIR do
|
20
24
|
system "#{RUBOTO_CMD} gen class Activity --name #{activity_name}"
|
21
25
|
FileUtils.cp "#{snake_name}.rb", "src/"
|
22
|
-
FileUtils.cp test_src, "test/
|
26
|
+
FileUtils.cp test_src, "test/src/"
|
23
27
|
end
|
24
28
|
end
|
25
29
|
run_app_tests
|
data/test/minimal_app_test.rb
CHANGED
@@ -3,7 +3,8 @@ require 'bigdecimal'
|
|
3
3
|
|
4
4
|
class MinimalAppTest < Test::Unit::TestCase
|
5
5
|
def setup
|
6
|
-
generate_app :excluded_stdlibs => %w{ant cgi digest dl drb ffi irb net optparse racc rbconfig rdoc rexml rinda rss
|
6
|
+
generate_app :excluded_stdlibs => %w{ant cgi digest dl drb ffi irb net optparse racc rbconfig rdoc rexml rinda rss
|
7
|
+
rubygems runit shell soap test uri webrick win32 wsdl xmlrpc xsd ../1.9}
|
7
8
|
end
|
8
9
|
|
9
10
|
def teardown
|
@@ -12,8 +13,10 @@ class MinimalAppTest < Test::Unit::TestCase
|
|
12
13
|
|
13
14
|
def test_minimal_apk_is_less_than_3_mb
|
14
15
|
apk_size = BigDecimal(File.size("#{APP_DIR}/bin/RubotoTestApp-debug.apk").to_s) / (1024 * 1024)
|
15
|
-
|
16
|
-
|
16
|
+
upper_limit = 3.0
|
17
|
+
lower_limit = upper_limit * 0.85
|
18
|
+
assert apk_size <= upper_limit, "APK was larger than #{'%.1f' % upper_limit}MB: #{'%.1f' % apk_size.ceil(1)}MB"
|
19
|
+
assert apk_size >= lower_limit, "APK was smaller than #{'%.1f' % lower_limit}MB: #{'%.1f' % apk_size.floor(1)}MB. You should lower the limit."
|
17
20
|
end
|
18
21
|
|
19
22
|
def test_minimal_apk_succeeds_tests
|
data/test/rake_test.rb
CHANGED
@@ -19,7 +19,7 @@ class RakeTest < Test::Unit::TestCase
|
|
19
19
|
s.gsub!(/What hath Matz wrought\?/, "This text was changed by script!")
|
20
20
|
File.open(activity_filename, 'w') { |f| f << s }
|
21
21
|
|
22
|
-
test_filename = "test/
|
22
|
+
test_filename = "test/src/ruboto_test_app_activity_test.rb"
|
23
23
|
s2 = File.read(test_filename)
|
24
24
|
s2.gsub!(/What hath Matz wrought\?/, "This text was changed by script!")
|
25
25
|
File.open(test_filename, 'w') { |f| f << s2 }
|
data/test/ruboto_gen_test.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require File.expand_path("test_helper", File.dirname(__FILE__))
|
2
|
+
require 'bigdecimal'
|
2
3
|
require 'test/app_test_methods'
|
3
4
|
|
4
5
|
class RubotoGenTest < Test::Unit::TestCase
|
@@ -24,9 +25,17 @@ class RubotoGenTest < Test::Unit::TestCase
|
|
24
25
|
assert_equal 1, $?.exitstatus
|
25
26
|
assert !File.exists?('src/org/ruboto/test_app/VeryNewActivity.java')
|
26
27
|
assert !File.exists?('src/very_new_activity.rb')
|
27
|
-
assert !File.exists?('test/
|
28
|
+
assert !File.exists?('test/src/very_new_activity_test.rb')
|
28
29
|
assert File.read('AndroidManifest.xml') !~ /VeryNewActivity/
|
29
30
|
end
|
30
31
|
end
|
31
32
|
|
33
|
+
def test_new_apk_size_is_within_limits
|
34
|
+
apk_size = BigDecimal(File.size("#{APP_DIR}/bin/RubotoTestApp-debug.apk").to_s) / 1024
|
35
|
+
upper_limit = 54.0
|
36
|
+
lower_limit = upper_limit * 0.9
|
37
|
+
assert apk_size <= upper_limit, "APK was larger than #{'%.1f' % upper_limit}KB: #{'%.1f' % apk_size.ceil(1)}KB"
|
38
|
+
assert apk_size >= lower_limit, "APK was smaller than #{'%.1f' % lower_limit}KB: #{'%.1f' % apk_size.ceil(1)}KB. You should lower the limit."
|
39
|
+
end
|
40
|
+
|
32
41
|
end
|
data/test/test_helper.rb
CHANGED
@@ -91,13 +91,12 @@ class Test::Unit::TestCase
|
|
91
91
|
end
|
92
92
|
|
93
93
|
def generate_app(options = {})
|
94
|
-
with_psych = options.delete(:with_psych) || false
|
95
94
|
update = options.delete(:update) || false
|
96
95
|
excluded_stdlibs = options.delete(:excluded_stdlibs)
|
97
96
|
raise "Unknown options: #{options.inspect}" unless options.empty?
|
98
97
|
Dir.mkdir TMP_DIR unless File.exists? TMP_DIR
|
99
98
|
|
100
|
-
if
|
99
|
+
if excluded_stdlibs
|
101
100
|
system 'rake platform:uninstall'
|
102
101
|
else
|
103
102
|
system 'rake platform:install'
|
@@ -108,7 +107,7 @@ class Test::Unit::TestCase
|
|
108
107
|
end
|
109
108
|
|
110
109
|
FileUtils.rm_rf APP_DIR if File.exists? APP_DIR
|
111
|
-
template_dir = "#{APP_DIR}_template_#{$$}#{'
|
110
|
+
template_dir = "#{APP_DIR}_template_#{$$}#{'_updated' if update}#{"_without_#{excluded_stdlibs.map{|ed| ed.gsub(/[.\/]/, '_')}.join('_')}" if excluded_stdlibs}"
|
112
111
|
if File.exists?(template_dir)
|
113
112
|
puts "Copying app from template #{template_dir}"
|
114
113
|
FileUtils.cp_r template_dir, APP_DIR, :preserve => true
|
@@ -125,14 +124,13 @@ class Test::Unit::TestCase
|
|
125
124
|
Dir.chdir APP_DIR do
|
126
125
|
File.open('local.properties', 'w') { |f| f.puts "sdk.dir=#{android_home}" }
|
127
126
|
File.open('test/local.properties', 'w') { |f| f.puts "sdk.dir=#{android_home}" }
|
128
|
-
FileUtils.touch "libs/psych.jar" if with_psych
|
129
127
|
exclude_stdlibs(excluded_stdlibs) if excluded_stdlibs
|
130
128
|
system "#{RUBOTO_CMD} update app"
|
131
129
|
assert_equal 0, $?, "update app failed with return code #$?"
|
132
130
|
end
|
133
131
|
else
|
134
132
|
puts "Generating app #{APP_DIR}"
|
135
|
-
system "#{RUBOTO_CMD} gen app --package #{PACKAGE} --path #{APP_DIR} --name #{APP_NAME} --target #{ANDROID_TARGET}
|
133
|
+
system "#{RUBOTO_CMD} gen app --package #{PACKAGE} --path #{APP_DIR} --name #{APP_NAME} --target #{ANDROID_TARGET}"
|
136
134
|
if $? != 0
|
137
135
|
FileUtils.rm_rf APP_DIR
|
138
136
|
raise "gen app failed with return code #$?"
|
data/test/update_test_methods.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruboto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 0.5.
|
9
|
+
- 3
|
10
|
+
version: 0.5.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Daniel Jackoway
|
@@ -18,7 +18,7 @@ autorequire:
|
|
18
18
|
bindir: bin
|
19
19
|
cert_chain: []
|
20
20
|
|
21
|
-
date:
|
21
|
+
date: 2012-01-16 00:00:00 Z
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|
24
24
|
name: main
|
@@ -45,7 +45,7 @@ dependencies:
|
|
45
45
|
version_requirements: *id001
|
46
46
|
description: |-
|
47
47
|
Ruboto - JRuby on Android
|
48
|
-
A generator and framework for developing full stand-alone apps for Android
|
48
|
+
A generator and framework for developing full stand-alone apps for Android using the Ruby language and libraries.
|
49
49
|
email: ruboto@googlegroups.com
|
50
50
|
executables:
|
51
51
|
- ruboto
|
@@ -60,6 +60,7 @@ files:
|
|
60
60
|
- Rakefile
|
61
61
|
- README.md
|
62
62
|
- assets/Rakefile
|
63
|
+
- assets/res/drawable/get_ruboto_core.png
|
63
64
|
- assets/res/drawable-hdpi/icon.png
|
64
65
|
- assets/res/drawable-ldpi/icon.png
|
65
66
|
- assets/res/drawable-mdpi/icon.png
|
@@ -74,15 +75,26 @@ files:
|
|
74
75
|
- assets/src/InheritingBroadcastReceiver.java
|
75
76
|
- assets/src/InheritingClass.java
|
76
77
|
- assets/src/InheritingService.java
|
78
|
+
- assets/src/org/ruboto/EntryPointActivity.java
|
77
79
|
- assets/src/org/ruboto/RubotoDialog.java
|
78
80
|
- assets/src/org/ruboto/Script.java
|
79
81
|
- assets/src/org/ruboto/test/ActivityTest.java
|
80
82
|
- assets/src/org/ruboto/test/InstrumentationTestRunner.java
|
83
|
+
- assets/src/ruboto/activity.rb
|
84
|
+
- assets/src/ruboto/base.rb
|
85
|
+
- assets/src/ruboto/broadcast_receiver.rb
|
86
|
+
- assets/src/ruboto/legacy.rb
|
87
|
+
- assets/src/ruboto/menu.rb
|
88
|
+
- assets/src/ruboto/preference.rb
|
89
|
+
- assets/src/ruboto/service.rb
|
90
|
+
- assets/src/ruboto/util/stack.rb
|
91
|
+
- assets/src/ruboto/util/toast.rb
|
92
|
+
- assets/src/ruboto/widget.rb
|
81
93
|
- assets/src/ruboto.rb
|
82
94
|
- assets/src/RubotoActivity.java
|
83
95
|
- assets/src/RubotoBroadcastReceiver.java
|
84
96
|
- assets/src/RubotoService.java
|
85
|
-
- assets/test/
|
97
|
+
- assets/test/src/test_helper.rb
|
86
98
|
- bin/ruboto
|
87
99
|
- lib/java_class_gen/android_api.xml
|
88
100
|
- lib/java_class_gen/InheritingClass.java.erb
|
@@ -108,15 +120,15 @@ files:
|
|
108
120
|
- test/activity/image_button_and_button_activity_test.rb
|
109
121
|
- test/activity/option_menu_activity.rb
|
110
122
|
- test/activity/option_menu_activity_test.rb
|
123
|
+
- test/activity/psych_activity.rb
|
124
|
+
- test/activity/psych_activity_test.rb
|
111
125
|
- test/activity/stack_activity.rb
|
112
126
|
- test/activity/stack_activity_test.rb
|
113
127
|
- test/app_test_methods.rb
|
114
128
|
- test/minimal_app_test.rb
|
115
129
|
- test/rake_test.rb
|
116
130
|
- test/ruboto_gen_test.rb
|
117
|
-
- test/ruboto_gen_with_psych_test.rb
|
118
131
|
- test/ruboto_update_test.rb
|
119
|
-
- test/ruboto_update_with_psych_test.rb
|
120
132
|
- test/service_test.rb
|
121
133
|
- test/test_helper.rb
|
122
134
|
- test/update_test_methods.rb
|