Skip to content

Instantly share code, notes, and snippets.

@navneetkumar
Created September 9, 2012 12:17
Show Gist options
  • Save navneetkumar/3684031 to your computer and use it in GitHub Desktop.
Save navneetkumar/3684031 to your computer and use it in GitHub Desktop.
require 'timeout'
namespace :android do
DEPLOYABLES_ANDROID_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'deployables', 'android'))
IBA_ANDROID_PKG = 'br.com.iba.readers'
ASSETS_RUNTIME = "/data/data/#{IBA_ANDROID_PKG}/#{IBA_ANDROID_PKG}/Local\\ Store/assets_runtime/htmlresources/buttons"
desc 'Runs the automated testing for Android'
task :ci =>
['android:app:deploy',
'android:app:open',
'android:app:update',
'android:spec']
namespace :app do
desc 'Deploys the APK onto a connected device'
task :deploy do
system '#{adb_command} devices > /dev/null 2>&1'
adb :command => :install,
:params => File.join(DEPLOYABLES_ANDROID_ROOT, 'adobe_air_emulator_runtime.apk'),
:ignore_fail => :INSTALL_FAILED_ALREADY_EXISTS
adb :command => :uninstall,
:params => IBA_ANDROID_PKG,
:timeout => 30
adb :command => :install,
:params => File.join(DEPLOYABLES_ANDROID_ROOT, 'iba.apk')
end
desc 'Updates app directly on a connected device'
task :update => ['package'] do
adb :command => :shell,
:params => "rm -r #{ASSETS_RUNTIME}",
:ignore_fail => 'No such file or directory'
VIEWS.each_with_index do |view, i|
unzip_file("build/#{view}.zip", "build/#{view}")
adb :command => :push,
:params => "build/#{view} #{ASSETS_RUNTIME}/button#{i+1}"
end
end
desc 'Open the app onto a connected device'
task :open do
adb :command => :shell,
:params => "am start -a android.intent.action.MAIN -n #{IBA_ANDROID_PKG}/.AppEntry"
adb :command => :shell,
:params => 'input keyevent 82', # unlock screen
:timeout => 5
# quick workaroud to fix the android:app:update for now
sleep 5
end
desc 'Close the app onto a connected device'
task :close do
adb :command => :shell,
:params => "kill `#{adb_command} shell ps | grep #{IBA_ANDROID_PKG} | awk '{ print $2 }'`"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment