Module: Frank::Cucumber::HostScripting

Included in:
FrankHelper
Defined in:
lib/frank-cucumber/host_scripting.rb

Instance Method Summary collapse

Instance Method Details

#press_home_on_simulatorObject



73
74
75
# File 'lib/frank-cucumber/host_scripting.rb', line 73

def press_home_on_simulator
  simulator_hardware_menu_press Localize.t(:home)
end

#quit_double_simulatorObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/frank-cucumber/host_scripting.rb', line 32

def quit_double_simulator
  %x{osascript<<APPLESCRIPT
    activate application id "com.apple.iphonesimulator"
    tell application "System Events"
      set process_name_list to name of (application processes where bundle identifier is "com.apple.iphonesimulator")
   set process_name to first item of process_name_list
      tell process process_name
        if (value of static text 1 of window 1) is "#{Localize.t(:only_one_simulator)}" then
          click button 1 of window 1
        end if
      end tell
    end tell
  }
end

#quit_simulatorObject



26
27
28
29
30
# File 'lib/frank-cucumber/host_scripting.rb', line 26

def quit_simulator
  %x{osascript<<APPLESCRIPT-
    application id "com.apple.iphonesimulator" quit
  APPLESCRIPT}
end

#rotate_simulator_leftObject



77
78
79
# File 'lib/frank-cucumber/host_scripting.rb', line 77

def rotate_simulator_left
  simulator_hardware_menu_press Localize.t(:rotate_left)
end

#rotate_simulator_rightObject



81
82
83
# File 'lib/frank-cucumber/host_scripting.rb', line 81

def rotate_simulator_right
  simulator_hardware_menu_press Localize.t(:rotate_right)
end

#shake_simulatorObject



85
86
87
# File 'lib/frank-cucumber/host_scripting.rb', line 85

def shake_simulator
  simulator_hardware_menu_press Localize.t(:shake_gesture)
end

#simulate_hardware_keyboardObject



97
98
99
# File 'lib/frank-cucumber/host_scripting.rb', line 97

def simulate_hardware_keyboard
  simulator_hardware_menu_press Localize.t(:simulate_hardware_keyboard)
end

#simulate_memory_warningObject



89
90
91
# File 'lib/frank-cucumber/host_scripting.rb', line 89

def simulate_memory_warning
  simulator_hardware_menu_press Localize.t(:simulate_memory_warning)
end

#simulator_hardware_menu_press(menu_label) ⇒ Object

Note this needs to have “Enable access for assistive devices” chcked in the Universal Access system preferences



62
63
64
65
66
67
68
69
70
71
# File 'lib/frank-cucumber/host_scripting.rb', line 62

def simulator_hardware_menu_press( menu_label )
  %x{osascript -s o <<APPLESCRIPT
activate application id "com.apple.iphonesimulator"
tell application "System Events"
set process_name_list to name of (application processes where bundle identifier is "com.apple.iphonesimulator")
	set process_name to first item of process_name_list
	click menu item "#{menu_label}" of menu "#{Localize.t(:hardware)}" of menu bar 1 of process process_name
end tell
APPLESCRIPT}
end

#simulator_reset_dataObject



47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/frank-cucumber/host_scripting.rb', line 47

def simulator_reset_data
  %x{osascript<<APPLESCRIPT
activate application id "com.apple.iphonesimulator"
tell application "System Events"
  set process_name_list to name of (application processes where bundle identifier is "com.apple.iphonesimulator")
  set process_name to first item of process_name_list
  click menu item 5 of menu 1 of menu bar item 2 of menu bar 1 of process process_name
  delay 0.5
  click button "#{Localize.t(:iphone_simulator_reset)}" of window 1 of process process_name
end tell
  APPLESCRIPT}
end

#start_recordingObject



7
8
9
10
11
12
13
14
15
# File 'lib/frank-cucumber/host_scripting.rb', line 7

def start_recording
  %x{osascript<<APPLESCRIPT
	tell application "QuickTime Player"
	set sr to new screen recording
 tell sr to start
	end tell
APPLESCRIPT}

end

#stop_recordingObject



17
18
19
20
21
22
23
24
# File 'lib/frank-cucumber/host_scripting.rb', line 17

def stop_recording
  %x{osascript<<APPLESCRIPT
	tell application "QuickTime Player"
 set sr to (document 1)
 tell sr to stop
	end tell
APPLESCRIPT}
end

#toggle_call_status_barObject



93
94
95
# File 'lib/frank-cucumber/host_scripting.rb', line 93

def toggle_call_status_bar
  simulator_hardware_menu_press Localize.t(:toggle_call_status_bar)
end