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



67
68
69
# File 'lib/frank-cucumber/host_scripting.rb', line 67

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
# 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"
      tell process "#{Localize.t(:iphone_simulator)}"
        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



71
72
73
# File 'lib/frank-cucumber/host_scripting.rb', line 71

def rotate_simulator_left
  simulator_hardware_menu_press Localize.t(:rotate_left)
end

#rotate_simulator_rightObject



75
76
77
# File 'lib/frank-cucumber/host_scripting.rb', line 75

def rotate_simulator_right
  simulator_hardware_menu_press Localize.t(:rotate_right)
end

#shake_simulatorObject



79
80
81
# File 'lib/frank-cucumber/host_scripting.rb', line 79

def shake_simulator
  simulator_hardware_menu_press Localize.t(:shake_gesture)
end

#simulate_hardware_keyboardObject



91
92
93
# File 'lib/frank-cucumber/host_scripting.rb', line 91

def simulate_hardware_keyboard
  simulator_hardware_menu_press Localize.t(:simulate_hardware_keyboard)
end

#simulate_memory_warningObject



83
84
85
# File 'lib/frank-cucumber/host_scripting.rb', line 83

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



58
59
60
61
62
63
64
65
# File 'lib/frank-cucumber/host_scripting.rb', line 58

def simulator_hardware_menu_press( menu_label )
  %x{osascript<<APPLESCRIPT
activate application id "com.apple.iphonesimulator"
tell application "System Events"
	click menu item "#{menu_label}" of menu "#{Localize.t(:hardware)}" of menu bar of process "#{Localize.t(:iphone_simulator)}"
end tell
APPLESCRIPT}
end

#simulator_reset_dataObject



45
46
47
48
49
50
51
52
53
54
# File 'lib/frank-cucumber/host_scripting.rb', line 45

def simulator_reset_data
  %x{osascript<<APPLESCRIPT
activate application id "com.apple.iphonesimulator"
tell application "System Events"
  click menu item 5 of menu 1 of menu bar item 2 of menu bar 1 of process "#{Localize.t(:iphone_simulator)}"
  delay 0.5
  click button "#{Localize.t(:iphone_simulator_reset)}" of window 1 of process "#{Localize.t(:iphone_simulator)}"
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



87
88
89
# File 'lib/frank-cucumber/host_scripting.rb', line 87

def toggle_call_status_bar
  simulator_hardware_menu_press Localize.t(:toggle_call_status_bar)
end