Sha256: 6aa0ad316b2ff7d8462462a305fff87da7b10102ef2fb17b1249fc1e27781069
Contents?: true
Size: 1.14 KB
Versions: 6
Compression:
Stored size: 1.14 KB
Contents
require File.expand_path("test_helper", File.dirname(__FILE__)) require 'fileutils' class ServiceTest < Test::Unit::TestCase SRC_DIR ="#{APP_DIR}/src" def setup generate_app end def teardown cleanup_app end def test_service_startup Dir.chdir APP_DIR do system "#{RUBOTO_CMD} gen class Service --name RubotoTestService" service_filename = "#{SRC_DIR}/ruboto_test_service.rb" assert File.exists? service_filename File.open(service_filename, 'w'){|f| f << <<EOF} require 'ruboto' $service.handle_create do Thread.start do loop do sleep 1 puts "\#{self.class} running..." end end puts "\#{self.class} started." android.app.Service::START_STICKY end $service.handle_start_command do android.app.Service::START_STICKY end EOF activity_filename = "#{SRC_DIR}/ruboto_test_app_activity.rb" s = File.read(activity_filename) s.gsub!(/^(end)$/, " startService(android.content.Intent.new($activity.application_context, $package.RubotoTestService.java_class)) \\1\n") File.open(activity_filename, 'w') { |f| f << s } end run_app_tests end end
Version data entries
6 entries across 6 versions & 2 rubygems