webkitpy: Implement device type specific expected results (Part 2)
[WebKit-https.git] / Tools / Scripts / webkitpy / port / ios_simulator.py
index e8f63fe..2a25d84 100644 (file)
@@ -27,7 +27,7 @@ from webkitpy.common.version import Version
 from webkitpy.port.config import apple_additions
 from webkitpy.port.ios import IOSPort
 from webkitpy.xcode.device_type import DeviceType
-from webkitpy.xcode.simulated_device import DeviceRequest, SimulatedDeviceManager
+from webkitpy.xcode.simulated_device import SimulatedDeviceManager
 
 
 _log = logging.getLogger(__name__)
@@ -42,17 +42,13 @@ class IOSSimulatorPort(IOSPort):
 
     DEVICE_MANAGER = SimulatedDeviceManager
 
-    DEFAULT_DEVICE_CLASS = 'iPhone SE'
-    CUSTOM_DEVICE_CLASSES = ['iPad', 'iPhone 7']
+    DEFAULT_DEVICE_TYPES = [
+        DeviceType(hardware_family='iPhone', hardware_type='SE'),
+        DeviceType(hardware_family='iPad', hardware_type='(5th generation)'),
+        DeviceType(hardware_family='iPhone', hardware_type='7'),
+    ]
     SDK = apple_additions().get_sdk('iphonesimulator') if apple_additions() else 'iphonesimulator'
 
-    def __init__(self, host, port_name, **kwargs):
-        super(IOSSimulatorPort, self).__init__(host, port_name, **kwargs)
-
-        optional_device_class = self.get_option('device_class')
-        self._device_class = optional_device_class if optional_device_class else self.DEFAULT_DEVICE_CLASS
-        _log.debug('IOSSimulatorPort _device_class is %s', self._device_class)
-
     @staticmethod
     def _version_from_name(name):
         if len(name.split('-')) > 2 and name.split('-')[2].isdigit():
@@ -60,42 +56,11 @@ class IOSSimulatorPort(IOSPort):
         return None
 
     @memoized
-    def ios_version(self):
+    def device_version(self):
         if self.get_option('version'):
             return Version.from_string(self.get_option('version'))
         return IOSSimulatorPort._version_from_name(self._name) if IOSSimulatorPort._version_from_name(self._name) else self.host.platform.xcode_sdk_version('iphonesimulator')
 
-    @memoized
-    def default_child_processes(self):
-        def booted_ios_devices_filter(device):
-            if not device.platform_device.is_booted_or_booting():
-                return False
-            return device.platform_device.device_type in DeviceType(software_variant='iOS',
-                                                                    software_version=self.ios_version())
-
-        if not self.get_option('dedicated_simulators', False):
-            num_booted_sims = len(SimulatedDeviceManager.device_by_filter(booted_ios_devices_filter, host=self.host))
-            if num_booted_sims:
-                return num_booted_sims
-        return SimulatedDeviceManager.max_supported_simulators(self.host)
-
-    def _set_device_class(self, device_class):
-        self._device_class = device_class if device_class else self.DEFAULT_DEVICE_CLASS
-
-    def _create_devices(self, device_class):
-        self._set_device_class(device_class)
-        device_type = DeviceType.from_string(self._device_class, self.ios_version())
-
-        _log.debug('\nCreating devices for {}'.format(device_type))
-
-        request = DeviceRequest(
-            device_type,
-            use_booted_simulator=not self.get_option('dedicated_simulators', False),
-            use_existing_simulator=False,
-            allow_incomplete_match=True,
-        )
-        SimulatedDeviceManager.initialize_devices([request] * self.child_processes(), self.host)
-
     def clean_up_test_run(self):
         super(IOSSimulatorPort, self).clean_up_test_run()
         _log.debug("clean_up_test_run")
@@ -127,14 +92,6 @@ class IOSSimulatorPort(IOSPort):
     def operating_system(self):
         return 'ios-simulator'
 
-    def check_sys_deps(self):
-        target_device_type = DeviceType(software_variant='iOS', software_version=self.ios_version())
-        for device in SimulatedDeviceManager.available_devices(self.host):
-            if device.platform_device.device_type in target_device_type:
-                return super(IOSSimulatorPort, self).check_sys_deps()
-        _log.error('No Simulated device matching "{}" defined in Xcode iOS SDK'.format(str(target_device_type)))
-        return False
-
     def reset_preferences(self):
         _log.debug("reset_preferences")
         SimulatedDeviceManager.tear_down(self.host)