Diff
Modified: trunk/Tools/ChangeLog (239944 => 239945)
--- trunk/Tools/ChangeLog 2019-01-14 21:56:07 UTC (rev 239944)
+++ trunk/Tools/ChangeLog 2019-01-14 22:02:18 UTC (rev 239945)
@@ -1,5 +1,35 @@
2019-01-14 Jonathan Bedard <[email protected]>
+ 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):
+
+2019-01-14 Jonathan Bedard <[email protected]>
+
webkitpy: Support alternate simctl device list output (Follow-up fix)
https://bugs.webkit.org/show_bug.cgi?id=193362
<rdar://problem/47122965>
Modified: trunk/Tools/Scripts/webkitpy/common/system/systemhost.py (239944 => 239945)
--- trunk/Tools/Scripts/webkitpy/common/system/systemhost.py 2019-01-14 21:56:07 UTC (rev 239944)
+++ trunk/Tools/Scripts/webkitpy/common/system/systemhost.py 2019-01-14 22:02:18 UTC (rev 239945)
@@ -1,4 +1,5 @@
# Copyright (c) 2011 Google Inc. All rights reserved.
+# Copyright (C) 2019 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
@@ -54,3 +55,7 @@
if not self.platform.is_mac():
return ''
return self.executive.run_command(['xcrun', 'lldb', '--python-path'], return_stderr=False).rstrip()
+
+ @property
+ def device_type(self):
+ return None
Modified: trunk/Tools/Scripts/webkitpy/common/system/systemhost_mock.py (239944 => 239945)
--- trunk/Tools/Scripts/webkitpy/common/system/systemhost_mock.py 2019-01-14 21:56:07 UTC (rev 239944)
+++ trunk/Tools/Scripts/webkitpy/common/system/systemhost_mock.py 2019-01-14 22:02:18 UTC (rev 239945)
@@ -1,30 +1,31 @@
- # Copyright (c) 2011 Google Inc. All rights reserved.
- #
- # Redistribution and use in source and binary forms, with or without
- # modification, are permitted provided that the following conditions are
- # met:
- #
- # * Redistributions of source code must retain the above copyright
- # notice, this list of conditions and the following disclaimer.
- # * Redistributions in binary form must reproduce the above
- # copyright notice, this list of conditions and the following disclaimer
- # in the documentation and/or other materials provided with the
- # distribution.
- # * Neither the name of Google Inc. nor the names of its
- # contributors may be used to endorse or promote products derived from
- # this software without specific prior written permission.
- #
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# Copyright (c) 2011 Google Inc. All rights reserved.
+# Copyright (C) 2019 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
from webkitpy.common.system.environment import Environment
from webkitpy.common.system.executive_mock import MockExecutive
@@ -57,3 +58,7 @@
def symbolicate_crash_log_if_needed(self, path):
return self.filesystem.read_text_file(path)
+
+ @property
+ def device_type(self):
+ return None
Modified: trunk/Tools/Scripts/webkitpy/port/device.py (239944 => 239945)
--- trunk/Tools/Scripts/webkitpy/port/device.py 2019-01-14 21:56:07 UTC (rev 239944)
+++ trunk/Tools/Scripts/webkitpy/port/device.py 2019-01-14 22:02:18 UTC (rev 239945)
@@ -1,4 +1,4 @@
-# Copyright (C) 2017 Apple Inc. All rights reserved.
+# Copyright (C) 2017-2019 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@@ -97,6 +97,10 @@
def udid(self):
return self.platform_device.udid
+ @property
+ def device_type(self):
+ return self.platform_device.device_type
+
def __nonzero__(self):
return self.platform_device is not None
Modified: trunk/Tools/Scripts/webkitpy/xcode/simulated_device.py (239944 => 239945)
--- trunk/Tools/Scripts/webkitpy/xcode/simulated_device.py 2019-01-14 21:56:07 UTC (rev 239944)
+++ trunk/Tools/Scripts/webkitpy/xcode/simulated_device.py 2019-01-14 22:02:18 UTC (rev 239945)
@@ -1,4 +1,4 @@
-# Copyright (C) 2017 Apple Inc. All rights reserved.
+# Copyright (C) 2017-2019 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@@ -175,7 +175,7 @@
if isinstance(initialized_device, Device) and device == initialized_device:
device = None
break
- if device and request.device_type == device.platform_device.device_type:
+ if device and request.device_type == device.device_type:
return device
return None
@@ -221,8 +221,8 @@
if full_device_type.hardware_family is None:
# We use the existing devices to determine a legal family if no family is specified
for device in SimulatedDeviceManager.AVAILABLE_DEVICES:
- if device.platform_device.device_type == full_device_type:
- full_device_type.hardware_family = device.platform_device.device_type.hardware_family
+ if device.device_type == full_device_type:
+ full_device_type.hardware_family = device.device_type.hardware_family
break
if full_device_type.hardware_type is None:
@@ -284,7 +284,7 @@
for request in requests:
if not request.use_booted_simulator:
continue
- if request.device_type == device.platform_device.device_type:
+ if request.device_type == device.device_type:
_log.debug("The request for '{}' matched {} exactly".format(request.device_type, device))
return request
@@ -292,7 +292,7 @@
for request in requests:
if not request.use_booted_simulator:
continue
- if device.platform_device.device_type in request.device_type:
+ if device.device_type in request.device_type:
_log.debug("The request for '{}' fuzzy-matched {}".format(request.device_type, device))
return request
@@ -305,7 +305,7 @@
for request in requests_copy:
if not request.use_booted_simulator or not request.allow_incomplete_match:
continue
- if request.device_type.software_variant == device.platform_device.device_type.software_variant:
+ if request.device_type.software_variant == device.device_type.software_variant:
_log.warn("The request for '{}' incomplete-matched {}".format(request.device_type, device))
_log.warn("This may cause unexpected behavior in code that expected the device type {}".format(request.device_type))
return request
@@ -340,7 +340,7 @@
return 0
if SimulatedDeviceManager.device_by_filter(lambda device: device.platform_device.is_booted_or_booting(), host=host) and use_booted_simulator:
- filter = lambda device: device.platform_device.is_booted_or_booting() and device.platform_device.device_type in device_type
+ filter = lambda device: device.platform_device.is_booted_or_booting() and device.device_type in device_type
return len(SimulatedDeviceManager.device_by_filter(filter, host=host))
for name in SimulatedDeviceManager._device_identifier_to_name.itervalues():
@@ -382,9 +382,9 @@
continue
if not request.use_booted_simulator:
continue
- if request.device_type != device.platform_device.device_type and not request.allow_incomplete_match:
+ if request.device_type != device.device_type and not request.allow_incomplete_match:
continue
- if request.device_type.software_variant != device.platform_device.device_type.software_variant:
+ if request.device_type.software_variant != device.device_type.software_variant:
continue
requests.remove(request)
Modified: trunk/Tools/Scripts/webkitpy/xcode/simulated_device_unittest.py (239944 => 239945)
--- trunk/Tools/Scripts/webkitpy/xcode/simulated_device_unittest.py 2019-01-14 21:56:07 UTC (rev 239944)
+++ trunk/Tools/Scripts/webkitpy/xcode/simulated_device_unittest.py 2019-01-14 22:02:18 UTC (rev 239945)
@@ -1,4 +1,4 @@
-# Copyright (C) 2017 Apple Inc. All rights reserved.
+# Copyright (C) 2017-2019 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@@ -568,33 +568,33 @@
SimulatedDeviceManager.available_devices(host)
# There should only be 1 iPhone X, iPhone 8 and iPhone SE
- self.assertEquals(1, len(SimulatedDeviceManager.device_by_filter(lambda device: device.platform_device.device_type == DeviceType.from_string('iPhone X'), host)))
- self.assertEquals(1, len(SimulatedDeviceManager.device_by_filter(lambda device: device.platform_device.device_type == DeviceType.from_string('iPhone 8'), host)))
+ self.assertEquals(1, len(SimulatedDeviceManager.device_by_filter(lambda device: device.device_type == DeviceType.from_string('iPhone X'), host)))
+ self.assertEquals(1, len(SimulatedDeviceManager.device_by_filter(lambda device: device.device_type == DeviceType.from_string('iPhone 8'), host)))
# There should be 2 5s and 6s
- self.assertEquals(2, len(SimulatedDeviceManager.device_by_filter(lambda device: device.platform_device.device_type == DeviceType.from_string('iPhone 5s'), host)))
- self.assertEquals(2, len(SimulatedDeviceManager.device_by_filter(lambda device: device.platform_device.device_type == DeviceType.from_string('iPhone 6s'), host)))
+ self.assertEquals(2, len(SimulatedDeviceManager.device_by_filter(lambda device: device.device_type == DeviceType.from_string('iPhone 5s'), host)))
+ self.assertEquals(2, len(SimulatedDeviceManager.device_by_filter(lambda device: device.device_type == DeviceType.from_string('iPhone 6s'), host)))
# 19 iPhones
- self.assertEquals(19, len(SimulatedDeviceManager.device_by_filter(lambda device: device.platform_device.device_type == DeviceType.from_string('iPhone'), host)))
+ self.assertEquals(19, len(SimulatedDeviceManager.device_by_filter(lambda device: device.device_type == DeviceType.from_string('iPhone'), host)))
# 11 iPads
- self.assertEquals(11, len(SimulatedDeviceManager.device_by_filter(lambda device: device.platform_device.device_type == DeviceType.from_string('iPad'), host)))
+ self.assertEquals(11, len(SimulatedDeviceManager.device_by_filter(lambda device: device.device_type == DeviceType.from_string('iPad'), host)))
# 18 Apple watches
- self.assertEquals(6, len(SimulatedDeviceManager.device_by_filter(lambda device: device.platform_device.device_type == DeviceType.from_string('Apple Watch'), host)))
+ self.assertEquals(6, len(SimulatedDeviceManager.device_by_filter(lambda device: device.device_type == DeviceType.from_string('Apple Watch'), host)))
# 3 Apple TVs
- self.assertEquals(3, len(SimulatedDeviceManager.device_by_filter(lambda device: device.platform_device.device_type == DeviceType.from_string('Apple TV'), host)))
+ self.assertEquals(3, len(SimulatedDeviceManager.device_by_filter(lambda device: device.device_type == DeviceType.from_string('Apple TV'), host)))
# 18 devices running iOS 11.0
- 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)))
+ self.assertEquals(18, len(SimulatedDeviceManager.device_by_filter(lambda device: device.device_type == DeviceType(software_variant='iOS', software_version=Version(11, 0, 1)), host)))
# 11 iPhones running iOS 11.0
- 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)))
+ self.assertEquals(11, len(SimulatedDeviceManager.device_by_filter(lambda device: device.device_type == DeviceType(hardware_family='iPhone', software_version=Version(11, 0, 1)), host)))
# 1 device running iOS 12
- 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)))
+ self.assertEquals(1, len(SimulatedDeviceManager.device_by_filter(lambda device: device.device_type == DeviceType(software_variant='iOS', software_version=Version(12, 0, 0)), host)))
def test_existing_simulator(self):
SimulatedDeviceTest.reset_simulated_device_manager()
@@ -640,8 +640,8 @@
SimulatedDeviceManager.available_devices(host)
# We won't test the creation and deletion of simulators, only managing existing sims
- 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)
- 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)
+ SimulatedDeviceTest.change_state_to(SimulatedDeviceManager.device_by_filter(lambda device: device.device_type == DeviceType.from_string('iPhone 8'), host)[0], SimulatedDevice.DeviceState.BOOTED)
+ SimulatedDeviceTest.change_state_to(SimulatedDeviceManager.device_by_filter(lambda device: device.device_type == DeviceType.from_string('iPhone X'), host)[0], SimulatedDevice.DeviceState.BOOTED)
SimulatedDeviceManager.initialize_devices(DeviceRequest(DeviceType.from_string('iPhone 8')), host=host)