Permalink
Browse files

add ability to restart simulator itself before launching the app

  • Loading branch information...
1 parent aa2543c commit 0ba0629c13df0148beb2c4d00aa61abb24a2be9b @moredip committed Nov 14, 2011
Showing with 18 additions and 6 deletions.
  1. +4 −0 bin/sim_launcher
  2. +7 −5 lib/sim_launcher/client.rb
  3. +3 −1 lib/sim_launcher/direct_client.rb
  4. +4 −0 lib/sim_launcher/simulator.rb
View
@@ -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
@@ -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
View
@@ -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
@@ -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
@@ -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
@@ -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

0 comments on commit 0ba0629

Please sign in to comment.