WebKit Bugzilla
Attachment 359070 Details for
Bug 193406
: webkitpy: Expose device_type from host-like objects
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-193406-20190114125544.patch (text/plain), 17.37 KB, created by
Jonathan Bedard
on 2019-01-14 12:55:44 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Jonathan Bedard
Created:
2019-01-14 12:55:44 PST
Size:
17.37 KB
patch
obsolete
>Index: Tools/ChangeLog >=================================================================== >--- Tools/ChangeLog (revision 239933) >+++ Tools/ChangeLog (working copy) >@@ -1,3 +1,33 @@ >+2019-01-14 Jonathan Bedard <jbedard@apple.com> >+ >+ webkitpy: Expose device_type from host-like objects >+ https://bugs.webkit.org/show_bug.cgi?id=193406 >+ <rdar://problem/47262305> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ 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 Wenson Hsieh <wenson_hsieh@apple.com> > > [iOS] Expose SPI to access the current sentence boundary and selection state >Index: Tools/Scripts/webkitpy/common/system/systemhost.py >=================================================================== >--- Tools/Scripts/webkitpy/common/system/systemhost.py (revision 239929) >+++ Tools/Scripts/webkitpy/common/system/systemhost.py (working copy) >@@ -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 @@ class SystemHost(object): > 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 >Index: Tools/Scripts/webkitpy/common/system/systemhost_mock.py >=================================================================== >--- Tools/Scripts/webkitpy/common/system/systemhost_mock.py (revision 239929) >+++ Tools/Scripts/webkitpy/common/system/systemhost_mock.py (working copy) >@@ -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 @@ class MockSystemHost(object): > > def symbolicate_crash_log_if_needed(self, path): > return self.filesystem.read_text_file(path) >+ >+ @property >+ def device_type(self): >+ return None >Index: Tools/Scripts/webkitpy/port/device.py >=================================================================== >--- Tools/Scripts/webkitpy/port/device.py (revision 239929) >+++ Tools/Scripts/webkitpy/port/device.py (working copy) >@@ -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 @@ class Device(object): > 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 > >Index: Tools/Scripts/webkitpy/xcode/simulated_device.py >=================================================================== >--- Tools/Scripts/webkitpy/xcode/simulated_device.py (revision 239929) >+++ Tools/Scripts/webkitpy/xcode/simulated_device.py (working copy) >@@ -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 @@ class SimulatedDeviceManager(object): > 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 @@ class SimulatedDeviceManager(object): > 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 @@ class SimulatedDeviceManager(object): > 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 @@ class SimulatedDeviceManager(object): > 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 @@ class SimulatedDeviceManager(object): > 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 @@ class SimulatedDeviceManager(object): > 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 @@ class SimulatedDeviceManager(object): > 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) > >Index: Tools/Scripts/webkitpy/xcode/simulated_device_unittest.py >=================================================================== >--- Tools/Scripts/webkitpy/xcode/simulated_device_unittest.py (revision 239929) >+++ Tools/Scripts/webkitpy/xcode/simulated_device_unittest.py (working copy) >@@ -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 @@ class SimulatedDeviceTest(unittest.TestC > 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 @@ class SimulatedDeviceTest(unittest.TestC > 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) >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 193406
: 359070