lib/calabash/ios/device/device_implementation.rb in calabash-2.0.0.pre11 vs lib/calabash/ios/device/device_implementation.rb in calabash-2.0.0.prelegacy

- old
+ new

@@ -15,15 +15,17 @@ include Calabash::IOS::Routes::PlaybackRouteMixin include Calabash::IOS::StatusBarMixin include Calabash::IOS::RotationMixin include Calabash::IOS::KeyboardMixin include Calabash::IOS::UIAKeyboardMixin + include Calabash::IOS::TextMixin include Calabash::IOS::UIAMixin include Calabash::IOS::IPadMixin include Calabash::IOS::GesturesMixin attr_reader :run_loop + attr_reader :uia_strategy attr_reader :start_options # Returns the default simulator identifier. The string that is return # can be used as an argument to `instruments`. # @@ -46,11 +48,11 @@ else run_loop_device = Device.fetch_matching_simulator(identifier) if run_loop_device.nil? raise "Could not find a simulator with a UDID or name matching '#{identifier}'" end - run_loop_device.instruments_identifier(RunLoop::SimControl.new.xcode) + run_loop_device.instruments_identifier end end # Returns the default physical device identifier. The string that is # return can be used as an argument to `instruments`. @@ -80,18 +82,18 @@ if connected_devices.empty? raise 'There are no physical devices connected.' elsif connected_devices.count > 1 raise 'There is more than one physical devices connected. Use CAL_DEVICE_ID to indicate which you want to connect to.' else - connected_devices.first.instruments_identifier(RunLoop::SimControl.new.xcode) + connected_devices.first.instruments_identifier end else run_loop_device = Device.fetch_matching_physical_device(identifier) if run_loop_device.nil? raise "Could not find a physical device with a UDID or name matching '#{identifier}'" end - run_loop_device.instruments_identifier(RunLoop::SimControl.new.xcode) + run_loop_device.instruments_identifier end end # Returns the default identifier for an application. If the application # is a simulator bundle (.app), the default simulator identifier is @@ -341,11 +343,12 @@ # @todo Get the language code from the server! ensure_ipad_emulation_1x { :device => self, - :application => application + :application => application, + :uia_strategy => uia_strategy } end # @!visibility private def start_app_on_simulator(application, options) @@ -389,11 +392,11 @@ # @!visibility private def start_app_with_device_and_options(application, run_loop_device, user_defined_options) start_options = merge_start_options!(application, run_loop_device, user_defined_options) @run_loop = RunLoop.run(start_options) - @automator = Calabash::IOS::Automator::DeviceAgent.new(@run_loop) + @uia_strategy = @run_loop[:uia_strategy] end # @!visibility private def wait_for_server_to_start(options={}) ensure_test_server_ready(options) @@ -524,10 +527,16 @@ raise "Invalid application #{application} for iOS platform." end end # @!visibility private + def enter_text(text) + # @todo implement this + raise 'ni' + end + + # @!visibility private def clear_app_data_on_simulator(application, run_loop_device, bridge) begin bridge.reset_app_sandbox true rescue StandardError => e @@ -619,12 +628,13 @@ end # @!visibility private # Expensive! def Device.fetch_matching_simulator(udid_or_name) - RunLoop::SimControl.new.simulators.detect do |sim| - sim.instruments_identifier(RunLoop::SimControl.new.xcode) == udid_or_name || + sim_control = RunLoop::SimControl.new + sim_control.simulators.detect do |sim| + sim.instruments_identifier == udid_or_name || sim.udid == udid_or_name end end # @!visibility private @@ -650,11 +660,11 @@ if run_loop_device.nil? Logger.error("The identifier for this device is '#{identifier}'") Logger.error('which resolves to a physical device.') Logger.error("The server endpoint '#{server.endpoint}' is for an iOS Simulator.") Logger.error('Use CAL_ENDPOINT to specify the IP address of your device') - Logger.error("Ex. $ CAL_ENDPOINT=http://10.0.1.2:37265 CAL_DEVICE_ID=#{identifier} #{Calabash::Utility.bundle_exec_prepend}calabash ...") + Logger.error("Ex. $ CAL_ENDPOINT=http://10.0.1.2:37265 CAL_DEVICE_ID=#{identifier} be calabash ...") raise "Invalid device endpoint '#{server.endpoint}'" end end end @@ -691,11 +701,11 @@ default_options = { :app => application.path, :bundle_id => application.identifier, - :device_target => run_loop_device.instruments_identifier(RunLoop::SimControl.new.xcode), + :device_target => run_loop_device.instruments_identifier, :uia_strategy => strategy } @start_options = default_options.merge(options_from_user) end @@ -763,14 +773,16 @@ strategy = uia_strategy_from_environment(run_loop_device) end if strategy == :host @run_loop = RunLoop::HostCache.default.read + @uia_strategy = :host else pid = instruments_pid @run_loop = {} @run_loop[:uia_strategy] = strategy @run_loop[:pid] = pid + @uia_strategy = strategy end # populate the @runtime_attributes wait_for_server_to_start({:timeout => 2}) {