Method: RunLoop::Core.prepare_simulator
- Defined in:
- lib/run_loop/core.rb
.prepare_simulator(launch_options, sim_control) ⇒ Object
Prepares the simulator for running.
-
enabling accessibility and software keyboard
-
installing / uninstalling apps
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
# File 'lib/run_loop/core.rb', line 141 def self.prepare_simulator(, sim_control) xcode = sim_control.xcode # Respect option passed from Calabash if [:relaunch_simulator] sim_control.quit_sim end if !xcode.version_gte_6? # Xcode 5.1.1 # Will quit the simulator! sim_control.enable_accessibility_on_sims({:verbose => false}) else # CoreSimulator app_bundle_path = [:bundle_dir_or_bundle_id] app = RunLoop::App.new(app_bundle_path) unless app.valid? if !File.exist?(app.path) = "App '#{app_bundle_path}' does not exist." else = "App '#{app_bundle_path}' is not a valid .app bundle" end raise RuntimeError, end udid = [:udid] device = sim_control.simulators.find do |sim| sim.udid == udid || sim.instruments_identifier(xcode) == udid end if device.nil? raise RuntimeError, "Could not find simulator with name or UDID that matches: '#{udid}'" end # Validate the architecture. self.expect_simulator_compatible_arch(device, app, xcode) # Quits the simulator. core_sim = RunLoop::CoreSimulator.new(device, app) # :reset is a legacy variable; has been replaced with :reset_app_sandbox if [:reset] || [:reset_app_sandbox] core_sim.reset_app_sandbox end # Will quit the simulator if it is running. # @todo fix accessibility_enabled? so we don't have to quit the sim # SimControl#accessibility_enabled? is always false during Core#prepare_simulator # https://github.com/calabash/run_loop/issues/167 sim_control.ensure_accessibility(device) # Will quit the simulator if it is running. # @todo fix software_keyboard_enabled? so we don't have to quit the sim # SimControl#software_keyboard_enabled? is always false during Core#prepare_simulator # https://github.com/calabash/run_loop/issues/168 sim_control.ensure_software_keyboard(device) # Launches the simulator if the app is not installed. core_sim.install # If CoreSimulator has already launched the simulator, it will not # launching it again. core_sim.launch_simulator end end |