Changeset 238694 in webkit


Ignore:
Timestamp:
Nov 29, 2018 1:58:30 PM (5 years ago)
Author:
Jonathan Bedard
Message:

webkitpy: Unify device creation
https://bugs.webkit.org/show_bug.cgi?id=192158
<rdar://problem/46344757>

Reviewed by Lucas Forschler.

  • Scripts/webkitpy/port/device_port.py:

(DevicePort):
(DevicePort.setup_test_run): Use DEVICE_MANAGER to create devices based on the specified device class.

  • Scripts/webkitpy/port/ios.py:

(IOSPort): Add DEFAULT_DEVICE_CLASS.

  • Scripts/webkitpy/port/ios_device.py:

(IOSDevicePort):
(IOSDevicePort._create_devices): Deleted.

  • Scripts/webkitpy/port/ios_simulator.py:

(IOSSimulatorPort._create_devices): Deleted.

  • Scripts/webkitpy/port/watch.py:

(WatchPort): Add DEFAULT_DEVICE_CLASS.

  • Scripts/webkitpy/port/watch_device.py:

(WatchDevicePort):
(WatchDevicePort._create_devices): Deleted.

  • Scripts/webkitpy/port/watch_simulator.py:

(WatchSimulatorPort._create_devices): Deleted.

  • Scripts/webkitpy/xcode/device_type_unittest.py:

(DeviceTypeTest.test_from_string): Test that DeviceTypes without hardware types can be constructed
from strings.

Location:
trunk/Tools
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r238684 r238694  
     12018-11-29  Jonathan Bedard  <jbedard@apple.com>
     2
     3        webkitpy: Unify device creation
     4        https://bugs.webkit.org/show_bug.cgi?id=192158
     5        <rdar://problem/46344757>
     6
     7        Reviewed by Lucas Forschler.
     8
     9        * Scripts/webkitpy/port/device_port.py:
     10        (DevicePort):
     11        (DevicePort.setup_test_run): Use DEVICE_MANAGER to create devices based on the specified device class.
     12        * Scripts/webkitpy/port/ios.py:
     13        (IOSPort): Add DEFAULT_DEVICE_CLASS.
     14        * Scripts/webkitpy/port/ios_device.py:
     15        (IOSDevicePort):
     16        (IOSDevicePort._create_devices): Deleted.
     17        * Scripts/webkitpy/port/ios_simulator.py:
     18        (IOSSimulatorPort._create_devices): Deleted.
     19        * Scripts/webkitpy/port/watch.py:
     20        (WatchPort): Add DEFAULT_DEVICE_CLASS.
     21        * Scripts/webkitpy/port/watch_device.py:
     22        (WatchDevicePort):
     23        (WatchDevicePort._create_devices): Deleted.
     24        * Scripts/webkitpy/port/watch_simulator.py:
     25        (WatchSimulatorPort._create_devices): Deleted.
     26        * Scripts/webkitpy/xcode/device_type_unittest.py:
     27        (DeviceTypeTest.test_from_string): Test that DeviceTypes without hardware types can be constructed
     28        from strings.
     29
    1302018-11-29  Jonathan Bedard  <jbedard@apple.com>
    231
  • trunk/Tools/Scripts/webkitpy/port/device_port.py

    r238672 r238694  
    2828from webkitpy.port.darwin import DarwinPort
    2929from webkitpy.port.simulator_process import SimulatorProcess
     30from webkitpy.xcode.device_type import DeviceType
     31from webkitpy.xcode.simulated_device import DeviceRequest
    3032
    3133
     
    3638
    3739    DEVICE_MANAGER = None
     40    DEFAULT_DEVICE_CLASS = None
     41    NO_DEVICE_MANAGER = 'No device manager found for port'
    3842
    3943    def __init__(self, *args, **kwargs):
     
    107111
    108112    def setup_test_run(self, device_class=None):
    109         self._create_devices(device_class)
     113        if not self.DEVICE_MANAGER:
     114            raise RuntimeError(self.NO_DEVICE_MANAGER)
     115
     116        device_type = DeviceType.from_string(device_class if device_class else self.DEFAULT_DEVICE_CLASS, self.device_version())
     117        _log.debug('\nCreating devices for {}'.format(device_type))
     118
     119        request = DeviceRequest(
     120            device_type,
     121            use_booted_simulator=not self.get_option('dedicated_simulators', False),
     122            use_existing_simulator=False,
     123            allow_incomplete_match=True,
     124        )
     125        self.DEVICE_MANAGER.initialize_devices([request] * self.child_processes(), self.host)
     126
     127        if not self.devices():
     128            raise RuntimeError('No devices are available for testing')
     129        if self.default_child_processes() < self.child_processes():
     130            raise RuntimeError('To few connected devices for {} processes'.format(self.child_processes()))
     131
    110132        self._install()
    111133
  • trunk/Tools/Scripts/webkitpy/port/ios.py

    r238672 r238694  
    3939
    4040    CURRENT_VERSION = Version(12)
     41    # FIXME: This is not a clear way to do this (although it works) https://bugs.webkit.org/show_bug.cgi?id=192160
     42    DEFAULT_DEVICE_CLASS = ''
    4143
    4244    def __init__(self, host, port_name, **kwargs):
  • trunk/Tools/Scripts/webkitpy/port/ios_device.py

    r238672 r238694  
    4242
    4343    SDK = apple_additions().get_sdk('iphoneos') if apple_additions() else 'iphoneos'
    44     NO_ON_DEVICE_TESTING = 'On-device testing is not supported on this machine'
     44    NO_ON_DEVICE_TESTING = 'On-device testing is not supported in this configuration'
     45    NO_DEVICE_MANAGER = NO_ON_DEVICE_TESTING
    4546
    4647    @memoized
     
    113114        return 'ios-device'
    114115
    115     def _create_devices(self, device_class):
    116         if not apple_additions():
    117             raise RuntimeError(self.NO_ON_DEVICE_TESTING)
    118         if not self.devices():
    119             raise RuntimeError('No devices are available for testing')
    120 
    121         if self.default_child_processes() < self.child_processes():
    122             raise RuntimeError('Not enought connected devices for {} processes'.format(self.child_processes()))
    123 
    124116    def clean_up_test_run(self):
    125117        super(IOSDevicePort, self).clean_up_test_run()
  • trunk/Tools/Scripts/webkitpy/port/ios_simulator.py

    r238672 r238694  
    2828from webkitpy.port.ios import IOSPort
    2929from webkitpy.xcode.device_type import DeviceType
    30 from webkitpy.xcode.simulated_device import DeviceRequest, SimulatedDeviceManager
     30from webkitpy.xcode.simulated_device import SimulatedDeviceManager
    3131
    3232
     
    8181    def _set_device_class(self, device_class):
    8282        self._device_class = device_class if device_class else self.DEFAULT_DEVICE_CLASS
    83 
    84     def _create_devices(self, device_class):
    85         self._set_device_class(device_class)
    86         device_type = DeviceType.from_string(self._device_class, self.device_version())
    87 
    88         _log.debug('\nCreating devices for {}'.format(device_type))
    89 
    90         request = DeviceRequest(
    91             device_type,
    92             use_booted_simulator=not self.get_option('dedicated_simulators', False),
    93             use_existing_simulator=False,
    94             allow_incomplete_match=True,
    95         )
    96         SimulatedDeviceManager.initialize_devices([request] * self.child_processes(), self.host)
    9783
    9884    def clean_up_test_run(self):
  • trunk/Tools/Scripts/webkitpy/port/watch.py

    r238672 r238694  
    3737
    3838    CURRENT_VERSION = Version(5)
     39    DEFAULT_DEVICE_CLASS = 'Apple Watch'
    3940
    4041    def __init__(self, *args, **kwargs):
  • trunk/Tools/Scripts/webkitpy/port/watch_device.py

    r238672 r238694  
    4141    DEVICE_MANAGER = apple_additions().device_manager() if apple_additions() else None
    4242    NO_ON_DEVICE_TESTING = 'On-device testing is not supported in this configuration'
     43    NO_DEVICE_MANAGER = NO_ON_DEVICE_TESTING
    4344
    4445    @memoized
     
    111112        return 'watchos-device'
    112113
    113     def _create_devices(self, device_class):
    114         if not apple_additions():
    115             raise RuntimeError(self.NO_ON_DEVICE_TESTING)
    116         if not apple_additions().device_for_worker_number_map(self, software_variant='watchOS'):
    117             raise RuntimeError('No devices are available for testing')
    118 
    119         if self.default_child_processes() < self.child_processes():
    120             raise RuntimeError('Not enought connected devices for {} processes'.format(self.child_processes()))
    121 
    122114    def clean_up_test_run(self):
    123115        super(WatchDevicePort, self).clean_up_test_run()
  • trunk/Tools/Scripts/webkitpy/port/watch_simulator.py

    r238672 r238694  
    2828from webkitpy.port.watch import WatchPort
    2929from webkitpy.xcode.device_type import DeviceType
    30 from webkitpy.xcode.simulated_device import DeviceRequest, SimulatedDeviceManager
     30from webkitpy.xcode.simulated_device import SimulatedDeviceManager
    3131
    3232_log = logging.getLogger(__name__)
     
    9595        self._device_class = device_class or self.DEFAULT_DEVICE_CLASS
    9696
    97     def _create_devices(self, device_class):
    98         self._set_device_class(device_class)
    99         device_type = DeviceType.from_string(self._device_class, self.device_version())
    100 
    101         _log.debug('\nCreating devices for {}'.format(device_type))
    102 
    103         request = DeviceRequest(
    104             device_type,
    105             use_booted_simulator=not self.get_option('dedicated_simulators', False),
    106             use_existing_simulator=False,
    107             allow_incomplete_match=True,
    108         )
    109         SimulatedDeviceManager.initialize_devices([request] * self.child_processes(), self.host)
    110 
    11197    def operating_system(self):
    11298        return 'watchos-simulator'
  • trunk/Tools/Scripts/webkitpy/xcode/device_type_unittest.py

    r226263 r238694  
    104104        self.assertEqual('Apple Watch Series 2 - 42mm running watchOS', str(DeviceType.from_string('Apple Watch Series 2 - 42mm')))
    105105        self.assertEqual('Apple TV 4K running tvOS', str(DeviceType.from_string('Apple TV 4K')))
     106        self.assertEqual('Device running iOS', str(DeviceType.from_string('')))
     107        self.assertEqual('Apple Watch running watchOS', str(DeviceType.from_string('Apple Watch')))
    106108
    107109    def test_comparison(self):
Note: See TracChangeset for help on using the changeset viewer.