⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 239945 in webkit


Ignore:
Timestamp:
Jan 14, 2019, 2:02:18 PM (8 years ago)
Author:
Jonathan Bedard
Message:

webkitpy: Expose device_type from host-like objects
https://bugs.webkit.org/show_bug.cgi?id=193406
<rdar://problem/47262305>

Reviewed by Lucas Forschler.

Devices should expose device_type. As a result, all host objects should
provide a device_type property, even if they do not yet define a device_type.

  • Scripts/webkitpy/common/system/systemhost.py:

(SystemHost):
(SystemHost.device_type):

  • Scripts/webkitpy/common/system/systemhost_mock.py:

(MockSystemHost):
(MockSystemHost.device_type):

  • Scripts/webkitpy/port/device.py:

(Device):
(Device.device_type):

  • Scripts/webkitpy/xcode/simulated_device.py:

(SimulatedDeviceManager._find_exisiting_device_for_request):
(SimulatedDeviceManager._disambiguate_device_type):
(SimulatedDeviceManager._does_fulfill_request):
(SimulatedDeviceManager.device_count_for_type):
(SimulatedDeviceManager.initialize_devices):

  • Scripts/webkitpy/xcode/simulated_device_unittest.py:

(test_available_devices):
(test_swapping_devices):

Location:
trunk/Tools
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r239939 r239945  
     12019-01-14  Jonathan Bedard  <jbedard@apple.com>
     2
     3        webkitpy: Expose device_type from host-like objects
     4        https://bugs.webkit.org/show_bug.cgi?id=193406
     5        <rdar://problem/47262305>
     6
     7        Reviewed by Lucas Forschler.
     8
     9        Devices should expose device_type. As a result, all host objects should
     10        provide a device_type property, even if they do not yet define a device_type.
     11
     12        * Scripts/webkitpy/common/system/systemhost.py:
     13        (SystemHost):
     14        (SystemHost.device_type):
     15        * Scripts/webkitpy/common/system/systemhost_mock.py:
     16        (MockSystemHost):
     17        (MockSystemHost.device_type):
     18        * Scripts/webkitpy/port/device.py:
     19        (Device):
     20        (Device.device_type):
     21        * Scripts/webkitpy/xcode/simulated_device.py:
     22        (SimulatedDeviceManager._find_exisiting_device_for_request):
     23        (SimulatedDeviceManager._disambiguate_device_type):
     24        (SimulatedDeviceManager._does_fulfill_request):
     25        (SimulatedDeviceManager.device_count_for_type):
     26        (SimulatedDeviceManager.initialize_devices):
     27        * Scripts/webkitpy/xcode/simulated_device_unittest.py:
     28        (test_available_devices):
     29        (test_swapping_devices):
     30
    1312019-01-14  Jonathan Bedard  <jbedard@apple.com>
    232
  • trunk/Tools/Scripts/webkitpy/common/system/systemhost.py

    r233332 r239945  
    11# Copyright (c) 2011 Google Inc. All rights reserved.
     2# Copyright (C) 2019 Apple Inc. All rights reserved.
    23#
    34# Redistribution and use in source and binary forms, with or without
     
    5556            return ''
    5657        return self.executive.run_command(['xcrun', 'lldb', '--python-path'], return_stderr=False).rstrip()
     58
     59    @property
     60    def device_type(self):
     61        return None
  • trunk/Tools/Scripts/webkitpy/common/system/systemhost_mock.py

    r217853 r239945  
    1     # Copyright (c) 2011 Google Inc. All rights reserved.
    2     #
    3     # Redistribution and use in source and binary forms, with or without
    4     # modification, are permitted provided that the following conditions are
    5     # met:
    6     #
    7     #     * Redistributions of source code must retain the above copyright
    8     # notice, this list of conditions and the following disclaimer.
    9     #     * Redistributions in binary form must reproduce the above
    10     # copyright notice, this list of conditions and the following disclaimer
    11     # in the documentation and/or other materials provided with the
    12     # distribution.
    13     #     * Neither the name of Google Inc. nor the names of its
    14     # contributors may be used to endorse or promote products derived from
    15     # this software without specific prior written permission.
    16     #
    17     # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    18     # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    19     # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    20     # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    21     # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    22     # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    23     # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    24     # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    25     # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    26     # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    27     # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     1# Copyright (c) 2011 Google Inc. All rights reserved.
     2# Copyright (C) 2019 Apple Inc. All rights reserved.
     3#
     4#  Redistribution and use in source and binary forms, with or without
     5# modification, are permitted provided that the following conditions are
     6# met:
     7#
     8#     * Redistributions of source code must retain the above copyright
     9# notice, this list of conditions and the following disclaimer.
     10#     * Redistributions in binary form must reproduce the above
     11# copyright notice, this list of conditions and the following disclaimer
     12# in the documentation and/or other materials provided with the
     13# distribution.
     14#     * Neither the name of Google Inc. nor the names of its
     15# contributors may be used to endorse or promote products derived from
     16# this software without specific prior written permission.
     17#
     18# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     21# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     22# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     23# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     24# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     25# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     26# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     27# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     28# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2829
    2930from webkitpy.common.system.environment import Environment
     
    5859    def symbolicate_crash_log_if_needed(self, path):
    5960        return self.filesystem.read_text_file(path)
     61
     62    @property
     63    def device_type(self):
     64        return None
  • trunk/Tools/Scripts/webkitpy/port/device.py

    r222510 r239945  
    1 # Copyright (C) 2017 Apple Inc. All rights reserved.
     1# Copyright (C) 2017-2019 Apple Inc. All rights reserved.
    22#
    33# Redistribution and use in source and binary forms, with or without
     
    9898        return self.platform_device.udid
    9999
     100    @property
     101    def device_type(self):
     102        return self.platform_device.device_type
     103
    100104    def __nonzero__(self):
    101105        return self.platform_device is not None
  • trunk/Tools/Scripts/webkitpy/xcode/simulated_device.py

    r239939 r239945  
    1 # Copyright (C) 2017 Apple Inc. All rights reserved.
     1# Copyright (C) 2017-2019 Apple Inc. All rights reserved.
    22#
    33# Redistribution and use in source and binary forms, with or without
     
    176176                    device = None
    177177                    break
    178             if device and request.device_type == device.platform_device.device_type:
     178            if device and request.device_type == device.device_type:
    179179                return device
    180180        return None
     
    222222            # We use the existing devices to determine a legal family if no family is specified
    223223            for device in SimulatedDeviceManager.AVAILABLE_DEVICES:
    224                 if device.platform_device.device_type == full_device_type:
    225                     full_device_type.hardware_family = device.platform_device.device_type.hardware_family
     224                if device.device_type == full_device_type:
     225                    full_device_type.hardware_family = device.device_type.hardware_family
    226226                    break
    227227
     
    285285            if not request.use_booted_simulator:
    286286                continue
    287             if request.device_type == device.platform_device.device_type:
     287            if request.device_type == device.device_type:
    288288                _log.debug("The request for '{}' matched {} exactly".format(request.device_type, device))
    289289                return request
     
    293293            if not request.use_booted_simulator:
    294294                continue
    295             if device.platform_device.device_type in request.device_type:
     295            if device.device_type in request.device_type:
    296296                _log.debug("The request for '{}' fuzzy-matched {}".format(request.device_type, device))
    297297                return request
     
    306306            if not request.use_booted_simulator or not request.allow_incomplete_match:
    307307                continue
    308             if request.device_type.software_variant == device.platform_device.device_type.software_variant:
     308            if request.device_type.software_variant == device.device_type.software_variant:
    309309                _log.warn("The request for '{}' incomplete-matched {}".format(request.device_type, device))
    310310                _log.warn("This may cause unexpected behavior in code that expected the device type {}".format(request.device_type))
     
    341341
    342342        if SimulatedDeviceManager.device_by_filter(lambda device: device.platform_device.is_booted_or_booting(), host=host) and use_booted_simulator:
    343             filter = lambda device: device.platform_device.is_booted_or_booting() and device.platform_device.device_type in device_type
     343            filter = lambda device: device.platform_device.is_booted_or_booting() and device.device_type in device_type
    344344            return len(SimulatedDeviceManager.device_by_filter(filter, host=host))
    345345
     
    383383                if not request.use_booted_simulator:
    384384                    continue
    385                 if request.device_type != device.platform_device.device_type and not request.allow_incomplete_match:
     385                if request.device_type != device.device_type and not request.allow_incomplete_match:
    386386                    continue
    387                 if request.device_type.software_variant != device.platform_device.device_type.software_variant:
     387                if request.device_type.software_variant != device.device_type.software_variant:
    388388                    continue
    389389                requests.remove(request)
  • trunk/Tools/Scripts/webkitpy/xcode/simulated_device_unittest.py

    r238940 r239945  
    1 # Copyright (C) 2017 Apple Inc. All rights reserved.
     1# Copyright (C) 2017-2019 Apple Inc. All rights reserved.
    22#
    33# Redistribution and use in source and binary forms, with or without
     
    569569
    570570        # There should only be 1 iPhone X, iPhone 8 and iPhone SE
    571         self.assertEquals(1, len(SimulatedDeviceManager.device_by_filter(lambda device: device.platform_device.device_type == DeviceType.from_string('iPhone X'), host)))
    572         self.assertEquals(1, len(SimulatedDeviceManager.device_by_filter(lambda device: device.platform_device.device_type == DeviceType.from_string('iPhone 8'), host)))
     571        self.assertEquals(1, len(SimulatedDeviceManager.device_by_filter(lambda device: device.device_type == DeviceType.from_string('iPhone X'), host)))
     572        self.assertEquals(1, len(SimulatedDeviceManager.device_by_filter(lambda device: device.device_type == DeviceType.from_string('iPhone 8'), host)))
    573573
    574574        # There should be 2 5s and 6s
    575         self.assertEquals(2, len(SimulatedDeviceManager.device_by_filter(lambda device: device.platform_device.device_type == DeviceType.from_string('iPhone 5s'), host)))
    576         self.assertEquals(2, len(SimulatedDeviceManager.device_by_filter(lambda device: device.platform_device.device_type == DeviceType.from_string('iPhone 6s'), host)))
     575        self.assertEquals(2, len(SimulatedDeviceManager.device_by_filter(lambda device: device.device_type == DeviceType.from_string('iPhone 5s'), host)))
     576        self.assertEquals(2, len(SimulatedDeviceManager.device_by_filter(lambda device: device.device_type == DeviceType.from_string('iPhone 6s'), host)))
    577577
    578578        # 19 iPhones
    579         self.assertEquals(19, len(SimulatedDeviceManager.device_by_filter(lambda device: device.platform_device.device_type == DeviceType.from_string('iPhone'), host)))
     579        self.assertEquals(19, len(SimulatedDeviceManager.device_by_filter(lambda device: device.device_type == DeviceType.from_string('iPhone'), host)))
    580580
    581581        # 11 iPads
    582         self.assertEquals(11, len(SimulatedDeviceManager.device_by_filter(lambda device: device.platform_device.device_type == DeviceType.from_string('iPad'), host)))
     582        self.assertEquals(11, len(SimulatedDeviceManager.device_by_filter(lambda device: device.device_type == DeviceType.from_string('iPad'), host)))
    583583
    584584        # 18 Apple watches
    585         self.assertEquals(6, len(SimulatedDeviceManager.device_by_filter(lambda device: device.platform_device.device_type == DeviceType.from_string('Apple Watch'), host)))
     585        self.assertEquals(6, len(SimulatedDeviceManager.device_by_filter(lambda device: device.device_type == DeviceType.from_string('Apple Watch'), host)))
    586586
    587587        # 3 Apple TVs
    588         self.assertEquals(3, len(SimulatedDeviceManager.device_by_filter(lambda device: device.platform_device.device_type == DeviceType.from_string('Apple TV'), host)))
     588        self.assertEquals(3, len(SimulatedDeviceManager.device_by_filter(lambda device: device.device_type == DeviceType.from_string('Apple TV'), host)))
    589589
    590590        # 18 devices running iOS 11.0
    591         self.assertEquals(18, len(SimulatedDeviceManager.device_by_filter(lambda device: device.platform_device.device_type == DeviceType(software_variant='iOS', software_version=Version(11, 0, 1)), host)))
     591        self.assertEquals(18, len(SimulatedDeviceManager.device_by_filter(lambda device: device.device_type == DeviceType(software_variant='iOS', software_version=Version(11, 0, 1)), host)))
    592592
    593593        # 11 iPhones running iOS 11.0
    594         self.assertEquals(11, len(SimulatedDeviceManager.device_by_filter(lambda device: device.platform_device.device_type == DeviceType(hardware_family='iPhone', software_version=Version(11, 0, 1)), host)))
     594        self.assertEquals(11, len(SimulatedDeviceManager.device_by_filter(lambda device: device.device_type == DeviceType(hardware_family='iPhone', software_version=Version(11, 0, 1)), host)))
    595595
    596596        # 1 device running iOS 12
    597         self.assertEquals(1, len(SimulatedDeviceManager.device_by_filter(lambda device: device.platform_device.device_type == DeviceType(software_variant='iOS', software_version=Version(12, 0, 0)), host)))
     597        self.assertEquals(1, len(SimulatedDeviceManager.device_by_filter(lambda device: device.device_type == DeviceType(software_variant='iOS', software_version=Version(12, 0, 0)), host)))
    598598
    599599    def test_existing_simulator(self):
     
    641641
    642642        # We won't test the creation and deletion of simulators, only managing existing sims
    643         SimulatedDeviceTest.change_state_to(SimulatedDeviceManager.device_by_filter(lambda device: device.platform_device.device_type == DeviceType.from_string('iPhone 8'), host)[0], SimulatedDevice.DeviceState.BOOTED)
    644         SimulatedDeviceTest.change_state_to(SimulatedDeviceManager.device_by_filter(lambda device: device.platform_device.device_type == DeviceType.from_string('iPhone X'), host)[0], SimulatedDevice.DeviceState.BOOTED)
     643        SimulatedDeviceTest.change_state_to(SimulatedDeviceManager.device_by_filter(lambda device: device.device_type == DeviceType.from_string('iPhone 8'), host)[0], SimulatedDevice.DeviceState.BOOTED)
     644        SimulatedDeviceTest.change_state_to(SimulatedDeviceManager.device_by_filter(lambda device: device.device_type == DeviceType.from_string('iPhone X'), host)[0], SimulatedDevice.DeviceState.BOOTED)
    645645
    646646        SimulatedDeviceManager.initialize_devices(DeviceRequest(DeviceType.from_string('iPhone 8')), host=host)
Note: See TracChangeset for help on using the changeset viewer.