Skip to content

Commit

Permalink
add ability to restart simulator itself before launching the app
Browse files Browse the repository at this point in the history
  • Loading branch information
moredip committed Nov 14, 2011
1 parent aa2543c commit 0ba0629
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
4 changes: 4 additions & 0 deletions bin/sim_launcher
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ get '/launch_ipad_app' do
raise 'no app_path provided' if app_path.nil?

sdk = params[:sdk]
restart_requested = ("true" == params[:restart])

shared_simulator.quit_simulator if restart_requested
shared_simulator.launch_ipad_app( app_path, sdk )
end

Expand All @@ -42,6 +44,8 @@ get '/launch_iphone_app' do
raise 'no app_path provided' if app_path.nil?

sdk = params[:sdk]
restart_requested = ("true" == params[:restart])

shared_simulator.quit_simulator if restart_requested
shared_simulator.launch_iphone_app( app_path, sdk )
end
12 changes: 7 additions & 5 deletions lib/sim_launcher/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ def server_uri=(uri)
@server_uri = URI.parse( uri.to_s )
end

def launch
full_request_uri = launch_uri
def launch(restart=false)
full_request_uri = launch_uri(restart)
puts "requesting #{full_request_uri}" if $DEBUG
response = Net::HTTP.get( full_request_uri )
puts "iphonesim server reponded with:\n#{response}" if $DEBUG
end

def relaunch
launch
launch(true)
end

# check that there appears to be a server ready for us to send commands to
Expand All @@ -53,10 +53,12 @@ def ping

private

def launch_uri
def launch_uri(requesting_restart)
full_request_uri = @server_uri.dup
full_request_uri.path = "/launch_#{@family}_app"
full_request_uri.query = "app_path=" + CGI.escape( @app_path ) + "&sdk=" + CGI.escape(@sdk)
full_request_uri.query = "app_path=" + CGI.escape( @app_path )
full_request_uri.query += "&sdk=" + CGI.escape( @sdk ) unless @sdk.nil?
full_request_uri.query += "&restart=" + (!!requesting_restart).to_s
full_request_uri
end

Expand Down
4 changes: 3 additions & 1 deletion lib/sim_launcher/direct_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ def launch
end

def relaunch
launch
simulator = SimLauncher::Simulator.new
simulator.quit_simulator
simulator.launch_ios_app( @app_path, @sdk, @family )
end
end
end
4 changes: 4 additions & 0 deletions lib/sim_launcher/simulator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ def launch_iphone_app( app_path, sdk )
launch_ios_app( app_path, sdk, 'iphone' )
end

def quit_simulator
`echo 'application "iPhone Simulator" quit' | osascript`
end

def run_synchronous_command( *args )
cmd = cmd_line_with_args( args )
puts "executing #{cmd}" if $DEBUG
Expand Down

0 comments on commit 0ba0629

Please sign in to comment.