Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

add ability to restart simulator itself before launching the app

  • Loading branch information...
commit 0ba0629c13df0148beb2c4d00aa61abb24a2be9b 1 parent aa2543c
Pete Hodgson authored November 14, 2011
4  bin/sim_launcher
@@ -33,7 +33,9 @@ get '/launch_ipad_app' do
33 33
   raise 'no app_path provided' if app_path.nil?
34 34
 
35 35
   sdk = params[:sdk]
  36
+  restart_requested = ("true" == params[:restart])
36 37
   
  38
+  shared_simulator.quit_simulator if restart_requested
37 39
   shared_simulator.launch_ipad_app( app_path, sdk )
38 40
 end
39 41
 
@@ -42,6 +44,8 @@ get '/launch_iphone_app' do
42 44
   raise 'no app_path provided' if app_path.nil?
43 45
 
44 46
   sdk = params[:sdk]
  47
+  restart_requested = ("true" == params[:restart])
45 48
 
  49
+  shared_simulator.quit_simulator if restart_requested
46 50
   shared_simulator.launch_iphone_app( app_path, sdk )
47 51
 end
12  lib/sim_launcher/client.rb
@@ -25,15 +25,15 @@ def server_uri=(uri)
25 25
       @server_uri = URI.parse( uri.to_s )
26 26
     end
27 27
 
28  
-    def launch
29  
-      full_request_uri = launch_uri 
  28
+    def launch(restart=false)
  29
+      full_request_uri = launch_uri(restart)
30 30
       puts "requesting #{full_request_uri}" if $DEBUG
31 31
       response = Net::HTTP.get( full_request_uri )
32 32
       puts "iphonesim server reponded with:\n#{response}" if $DEBUG
33 33
     end
34 34
 
35 35
     def relaunch
36  
-      launch
  36
+      launch(true)
37 37
     end
38 38
 
39 39
     # check that there appears to be a server ready for us to send commands to
@@ -53,10 +53,12 @@ def ping
53 53
 
54 54
     private
55 55
 
56  
-    def launch_uri
  56
+    def launch_uri(requesting_restart)
57 57
       full_request_uri = @server_uri.dup
58 58
       full_request_uri.path = "/launch_#{@family}_app"
59  
-      full_request_uri.query = "app_path=" + CGI.escape( @app_path ) + "&sdk=" + CGI.escape(@sdk)
  59
+      full_request_uri.query = "app_path=" + CGI.escape( @app_path )
  60
+      full_request_uri.query += "&sdk=" + CGI.escape( @sdk ) unless @sdk.nil?
  61
+      full_request_uri.query += "&restart=" + (!!requesting_restart).to_s
60 62
       full_request_uri
61 63
     end
62 64
 
4  lib/sim_launcher/direct_client.rb
@@ -19,7 +19,9 @@ def launch
19 19
     end
20 20
 
21 21
     def relaunch
22  
-      launch
  22
+      simulator = SimLauncher::Simulator.new
  23
+      simulator.quit_simulator
  24
+      simulator.launch_ios_app( @app_path, @sdk, @family )
23 25
     end
24 26
   end
25 27
 end
4  lib/sim_launcher/simulator.rb
@@ -22,6 +22,10 @@ def launch_iphone_app( app_path, sdk )
22 22
     launch_ios_app( app_path, sdk, 'iphone' )
23 23
   end
24 24
 
  25
+  def quit_simulator
  26
+    `echo 'application "iPhone Simulator" quit' | osascript`
  27
+  end
  28
+
25 29
   def run_synchronous_command( *args )
26 30
     cmd = cmd_line_with_args( args )
27 31
     puts "executing #{cmd}" if $DEBUG

0 notes on commit 0ba0629

Please sign in to comment.
Something went wrong with that request. Please try again.