Title: [243770] branches/safari-607-branch/Tools
Revision
243770
Author
[email protected]
Date
2019-04-02 17:04:01 -0700 (Tue, 02 Apr 2019)

Log Message

Cherry-pick r239945. rdar://problem/49539128

    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):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239945 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-607-branch/Tools/ChangeLog (243769 => 243770)


--- branches/safari-607-branch/Tools/ChangeLog	2019-04-03 00:03:56 UTC (rev 243769)
+++ branches/safari-607-branch/Tools/ChangeLog	2019-04-03 00:04:01 UTC (rev 243770)
@@ -1,5 +1,69 @@
 2019-04-02  Kocsen Chung  <[email protected]>
 
+        Cherry-pick r239945. rdar://problem/49539128
+
+    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):
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239945 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    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-04-02  Kocsen Chung  <[email protected]>
+
         Cherry-pick r239875. rdar://problem/49539128
 
     webkitpy: Incorporate device type into baseline search path

Modified: branches/safari-607-branch/Tools/Scripts/webkitpy/common/system/systemhost.py (243769 => 243770)


--- branches/safari-607-branch/Tools/Scripts/webkitpy/common/system/systemhost.py	2019-04-03 00:03:56 UTC (rev 243769)
+++ branches/safari-607-branch/Tools/Scripts/webkitpy/common/system/systemhost.py	2019-04-03 00:04:01 UTC (rev 243770)
@@ -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: branches/safari-607-branch/Tools/Scripts/webkitpy/common/system/systemhost_mock.py (243769 => 243770)


--- branches/safari-607-branch/Tools/Scripts/webkitpy/common/system/systemhost_mock.py	2019-04-03 00:03:56 UTC (rev 243769)
+++ branches/safari-607-branch/Tools/Scripts/webkitpy/common/system/systemhost_mock.py	2019-04-03 00:04:01 UTC (rev 243770)
@@ -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: branches/safari-607-branch/Tools/Scripts/webkitpy/port/device.py (243769 => 243770)


--- branches/safari-607-branch/Tools/Scripts/webkitpy/port/device.py	2019-04-03 00:03:56 UTC (rev 243769)
+++ branches/safari-607-branch/Tools/Scripts/webkitpy/port/device.py	2019-04-03 00:04:01 UTC (rev 243770)
@@ -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

Modified: branches/safari-607-branch/Tools/Scripts/webkitpy/xcode/simulated_device.py (243769 => 243770)


--- branches/safari-607-branch/Tools/Scripts/webkitpy/xcode/simulated_device.py	2019-04-03 00:03:56 UTC (rev 243769)
+++ branches/safari-607-branch/Tools/Scripts/webkitpy/xcode/simulated_device.py	2019-04-03 00:04:01 UTC (rev 243770)
@@ -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
@@ -176,7 +176,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
 
@@ -222,8 +222,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:
@@ -285,7 +285,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
 
@@ -293,7 +293,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
 
@@ -306,7 +306,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
@@ -341,7 +341,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():
@@ -383,9 +383,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: branches/safari-607-branch/Tools/Scripts/webkitpy/xcode/simulated_device_unittest.py (243769 => 243770)


--- branches/safari-607-branch/Tools/Scripts/webkitpy/xcode/simulated_device_unittest.py	2019-04-03 00:03:56 UTC (rev 243769)
+++ branches/safari-607-branch/Tools/Scripts/webkitpy/xcode/simulated_device_unittest.py	2019-04-03 00:04:01 UTC (rev 243770)
@@ -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()
@@ -641,8 +641,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)
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to