lib/calabash-android/operations.rb in calabash-android-0.8.0.pre1 vs lib/calabash-android/operations.rb in calabash-android-0.8.0.pre2
- old
+ new
@@ -16,14 +16,14 @@
require 'calabash-android/version'
require 'calabash-android/env'
require 'calabash-android/environment'
require 'calabash-android/dot_dir'
require 'calabash-android/logging'
+require 'calabash-android/retry'
require 'calabash-android/store/preferences'
require 'calabash-android/usage_tracker'
require 'calabash-android/dependencies'
-require 'retriable'
require 'cucumber'
require 'date'
require 'time'
require 'shellwords'
@@ -186,10 +186,28 @@
def clear_preferences(name)
default_device.clear_preferences(name)
end
+ def set_activity_orientation(orientation)
+ unless orientation.is_a?(Symbol)
+ raise ArgumentError, "Orientation is not a symbol"
+ end
+
+ unless orientation == :landscape || orientation == :portrait ||
+ orientation == :reverse_landscape || orientation == :reverse_portrait
+ raise ArgumentError, "Invalid orientation given. Use :landscape, :portrait, :reverse_landscape, or :reverse_portrait"
+ end
+
+ perform_action("set_activity_orientation", orientation.to_s)
+ end
+
+ # Note: Android 2.2 will always return either portrait or landscape, not reverse_portrait or reverse_landscape
+ def get_activity_orientation
+ perform_action("get_activity_orientation")
+ end
+
def query(uiquery, *args)
converted_args = []
args.each do |arg|
if arg.is_a?(Hash) and arg.count == 1
if arg.values.is_a?(Array) && arg.values.count == 1
@@ -616,11 +634,11 @@
wake_up_cmd = "#{adb_command} shell am start -a android.intent.action.MAIN -n #{package_name(@test_server_path)}/sh.calaba.instrumentationbackend.WakeUp"
log "Waking up device using:"
log wake_up_cmd
raise "Could not wake up the device" unless system(wake_up_cmd)
- Retriable.retriable :tries => 10, :interval => 1 do
+ Calabash::Android::Retry.retry :tries => 10, :interval => 1 do
raise "Could not remove the keyguard" if keyguard_enabled?
end
end
def clear_app_data
@@ -646,11 +664,11 @@
end
env_options = options.clone
env_options.delete(:intent)
- env_options[:main_activity] ||= main_activity(@app_path)
+ env_options[:main_activity] ||= ENV['MAIN_ACTIVITY'] || 'null'
env_options[:test_server_port] ||= @test_server_port
env_options[:class] ||= "sh.calaba.instrumentationbackend.InstrumentationBackend"
cmd_arr = [adb_command, "shell am instrument"]
@@ -666,15 +684,15 @@
log "Starting test server using:"
log cmd
raise "Could not execute command to start test server" unless system("#{cmd} 2>&1")
- Retriable.retriable :tries => 100, :interval => 0.1 do
+ Calabash::Android::Retry.retry :tries => 100, :interval => 0.1 do
raise "App did not start" unless app_running?
end
begin
- Retriable.retriable :tries => 300, :interval => 0.1 do
+ Calabash::Android::Retry.retry :tries => 300, :interval => 0.1 do
log "Checking if instrumentation backend is ready"
log "Is app running? #{app_running?}"
ready = http("/ready", {}, {:read_timeout => 1})
if ready != "true"