Class: FastlaneCore::DeviceManager::Device

Inherits:
Object
  • Object
show all
Defined in:
lib/fastlane/plugin/test_center/helper/multi_scan_manager/device_manager.rb

Instance Method Summary collapse

Instance Method Details

#bootObject



32
33
34
35
36
37
38
39
40
41
# File 'lib/fastlane/plugin/test_center/helper/multi_scan_manager/device_manager.rb', line 32

def boot
  return unless is_simulator
  return unless os_type == "iOS"
  return if self.state == 'Booted'

  UI.message("Booting #{self}")

  `xcrun simctl boot #{self.udid} 2>/dev/null`
  self.state = 'Booted'
end

#cloneObject



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/fastlane/plugin/test_center/helper/multi_scan_manager/device_manager.rb', line 4

def clone
  raise 'Can only clone iOS Simulators' unless self.is_simulator
  Device.new(
    name: self.name,
    udid: `xcrun simctl clone #{self.udid} '#{self.name}'`.chomp,
    os_type: self.os_type,
    os_version: self.os_version,
    state: self.state,
    is_simulator: self.is_simulator
  )
end

#disable_hardware_keyboardObject



21
22
23
24
25
26
27
28
29
30
# File 'lib/fastlane/plugin/test_center/helper/multi_scan_manager/device_manager.rb', line 21

def disable_hardware_keyboard
  UI.verbose("Disabling hardware keyboard for #{self.udid}")
  plist_filepath = File.expand_path("~/Library/Preferences/com.apple.iphonesimulator.plist")
  keyboard_pref_key = ":DevicePreferences:#{self.udid}:ConnectHardwareKeyboard"

  command = "/usr/libexec/PlistBuddy -c \"Set #{keyboard_pref_key} false\" #{plist_filepath} 2>/dev/null || "
  command << "/usr/libexec/PlistBuddy -c \"Add #{keyboard_pref_key} bool false\" #{plist_filepath}"

  `#{command}`
end

#rename(newname) ⇒ Object



16
17
18
19
# File 'lib/fastlane/plugin/test_center/helper/multi_scan_manager/device_manager.rb', line 16

def rename(newname)
  `xcrun simctl rename #{self.udid} '#{newname}'`
  self.name = newname
end

#shutdownObject



43
44
45
46
47
48
49
50
51
# File 'lib/fastlane/plugin/test_center/helper/multi_scan_manager/device_manager.rb', line 43

def shutdown
  return unless is_simulator
  return unless os_type == "iOS"
  return if self.state == 'Shutdown'

  UI.message("Shutting down #{self.udid}")
  `xcrun simctl shutdown #{self.udid} 2>/dev/null`
  self.state = 'Shutdown'
end