Title: [261421] trunk/Tools
Revision
261421
Author
[email protected]
Date
2020-05-08 15:56:48 -0700 (Fri, 08 May 2020)

Log Message

webkitpy: 'iPhone SE' should match 'iPhone SE 1st generation'
https://bugs.webkit.org/show_bug.cgi?id=211642
<rdar://problems/62986242>

Rubber-stamped by Aakash Jain.

* Scripts/webkitpy/xcode/device_type.py:
(DeviceType):
(DeviceType.standardized_hardware_type): Strip '1st generation' from models.
(DeviceType.__eq__): Use standardized hardware type.
(DeviceType.__contains__): Ditto.
(DeviceType.__hash__): Ditto.
* Scripts/webkitpy/xcode/device_type_unittest.py:
(DeviceTypeTest):
(DeviceTypeTest.test_generation_matching):
* Scripts/webkitpy/xcode/simulated_device.py:
(SimulatedDeviceManager._get_device_identifier_for_type): Handle case where the requests model does not
end with '(1st generation)', but the simctl model does.
* Scripts/webkitpy/xcode/simulated_device_unittest.py:

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (261420 => 261421)


--- trunk/Tools/ChangeLog	2020-05-08 22:09:20 UTC (rev 261420)
+++ trunk/Tools/ChangeLog	2020-05-08 22:56:48 UTC (rev 261421)
@@ -1,3 +1,25 @@
+2020-05-08  Jonathan Bedard  <[email protected]>
+
+        webkitpy: 'iPhone SE' should match 'iPhone SE 1st generation'
+        https://bugs.webkit.org/show_bug.cgi?id=211642
+        <rdar://problems/62986242>
+
+        Rubber-stamped by Aakash Jain.
+
+        * Scripts/webkitpy/xcode/device_type.py:
+        (DeviceType):
+        (DeviceType.standardized_hardware_type): Strip '1st generation' from models.
+        (DeviceType.__eq__): Use standardized hardware type.
+        (DeviceType.__contains__): Ditto.
+        (DeviceType.__hash__): Ditto.
+        * Scripts/webkitpy/xcode/device_type_unittest.py:
+        (DeviceTypeTest):
+        (DeviceTypeTest.test_generation_matching):
+        * Scripts/webkitpy/xcode/simulated_device.py:
+        (SimulatedDeviceManager._get_device_identifier_for_type): Handle case where the requests model does not
+        end with '(1st generation)', but the simctl model does.
+        * Scripts/webkitpy/xcode/simulated_device_unittest.py:
+
 2020-05-08  Ryan Haddad  <[email protected]>
 
         TestWebKitAPI.WebKit.AllowsContentJavaScript fails on iPad simulator

Modified: trunk/Tools/Scripts/webkitpy/xcode/device_type.py (261420 => 261421)


--- trunk/Tools/Scripts/webkitpy/xcode/device_type.py	2020-05-08 22:09:20 UTC (rev 261420)
+++ trunk/Tools/Scripts/webkitpy/xcode/device_type.py	2020-05-08 22:56:48 UTC (rev 261421)
@@ -26,6 +26,7 @@
 
 # This class is designed to match device types. Because it is used for matching, 'None' is treated as a wild-card.
 class DeviceType(object):
+    FIRST_GENERATION = ' (1st generation)'
 
     @classmethod
     def from_string(cls, device_string, version=None):
@@ -108,6 +109,15 @@
         self._define_software_variant_from_hardware_family()
         self.check_consistency()
 
+    @property
+    def standardized_hardware_type(self):
+        if not self.hardware_type:
+            return None
+
+        if self.hardware_type.lower().endswith(self.FIRST_GENERATION):
+            return self.hardware_type[:-len(self.FIRST_GENERATION)]
+        return self.hardware_type
+
     def __str__(self):
         version = None
         if self.software_version and apple_additions():
@@ -126,7 +136,7 @@
         assert isinstance(other, DeviceType)
         if self.hardware_family is not None and other.hardware_family is not None and self.hardware_family.lower() != other.hardware_family.lower():
             return False
-        if self.hardware_type is not None and other.hardware_type is not None and self.hardware_type.lower() != other.hardware_type.lower():
+        if self.standardized_hardware_type is not None and other.standardized_hardware_type is not None and self.standardized_hardware_type.lower() != other.standardized_hardware_type.lower():
             return False
         if self.software_variant is not None and other.software_variant is not None and self.software_variant.lower() != other.software_variant.lower():
             return False
@@ -138,7 +148,7 @@
         assert isinstance(other, DeviceType)
         if self.hardware_family is not None and (not other.hardware_family or self.hardware_family.lower() != other.hardware_family.lower()):
             return False
-        if self.hardware_type is not None and (not other.hardware_type or self.hardware_type.lower() != other.hardware_type.lower()):
+        if self.standardized_hardware_type is not None and (not other.standardized_hardware_type or self.standardized_hardware_type.lower() != other.standardized_hardware_type.lower()):
             return False
         if self.software_variant is not None and (not other.software_variant or self.software_variant.lower() != other.software_variant.lower()):
             return False
@@ -147,4 +157,4 @@
         return True
 
     def __hash__(self):
-        return hash((self.hardware_family, self.hardware_type, self.software_variant, self.software_version))
+        return hash((self.hardware_family, self.standardized_hardware_type, self.software_variant, self.software_version))

Modified: trunk/Tools/Scripts/webkitpy/xcode/device_type_unittest.py (261420 => 261421)


--- trunk/Tools/Scripts/webkitpy/xcode/device_type_unittest.py	2020-05-08 22:09:20 UTC (rev 261420)
+++ trunk/Tools/Scripts/webkitpy/xcode/device_type_unittest.py	2020-05-08 22:56:48 UTC (rev 261421)
@@ -158,3 +158,8 @@
 
     def test_unmapped_version(self):
         self.assertEqual('iPhone running iOS', str(DeviceType.from_string('iPhone', Version(9))))
+
+    def test_generation_matching(self):
+        self.assertEqual(DeviceType.from_string('iPhone SE (1st generation)').standardized_hardware_type, 'SE')
+        self.assertTrue(DeviceType.from_string('iPhone SE') == DeviceType.from_string('iPhone SE (1st generation)'))
+        self.assertTrue(DeviceType.from_string('iPhone SE') != DeviceType.from_string('iPhone SE (2nd generation)'))

Modified: trunk/Tools/Scripts/webkitpy/xcode/simulated_device.py (261420 => 261421)


--- trunk/Tools/Scripts/webkitpy/xcode/simulated_device.py	2020-05-08 22:09:20 UTC (rev 261420)
+++ trunk/Tools/Scripts/webkitpy/xcode/simulated_device.py	2020-05-08 22:56:48 UTC (rev 261421)
@@ -249,9 +249,12 @@
 
     @staticmethod
     def _get_device_identifier_for_type(device_type):
+        type_name_for_request = u'{} {}'.format(device_type.hardware_family.lower(), device_type.standardized_hardware_type.lower())
         for type_id, type_name in SimulatedDeviceManager._device_identifier_to_name.items():
-            if type_name.lower() == u'{} {}'.format(device_type.hardware_family.lower(), device_type.hardware_type.lower()):
+            if type_name.lower() == type_name_for_request:
                 return type_id
+            if type_name.lower().endswith(DeviceType.FIRST_GENERATION) and type_name.lower()[:-len(DeviceType.FIRST_GENERATION)] == type_name_for_request:
+                return type_id
         return None
 
     @staticmethod

Modified: trunk/Tools/Scripts/webkitpy/xcode/simulated_device_unittest.py (261420 => 261421)


--- trunk/Tools/Scripts/webkitpy/xcode/simulated_device_unittest.py	2020-05-08 22:09:20 UTC (rev 261420)
+++ trunk/Tools/Scripts/webkitpy/xcode/simulated_device_unittest.py	2020-05-08 22:56:48 UTC (rev 261421)
@@ -67,7 +67,7 @@
      "identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-8-Plus"
    },
    {
-     "name" : "iPhone SE",
+     "name" : "iPhone SE (1st generation)",
      "identifier" : "com.apple.CoreSimulator.SimDeviceType.iPhone-SE"
    },
    {
@@ -373,7 +373,7 @@
      {
        "state" : "Shutdown",
        "availability" : "(available)",
-       "name" : "iPhone SE",
+       "name" : "iPhone SE (1st generation)",
        "udid" : "DB46D0DB-510E-4928-BDB4-1A0192ED4A38"
      },
      {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to