Title: [238906] trunk/Tools
Revision
238906
Author
[email protected]
Date
2018-12-05 13:02:46 -0800 (Wed, 05 Dec 2018)

Log Message

webkitpy: Ignore case when comparing device types
https://bugs.webkit.org/show_bug.cgi?id=192409
<rdar://problem/46491558>

Reviewed by Lucas Forschler.

This allows DeviceTypes constructed with lowercase strings to correctly compare
against DeviceTypes coming from the simulator runtime.

* Scripts/webkitpy/xcode/device_type.py:
(DeviceType.__eq__):
(DeviceType.__contains__):
* Scripts/webkitpy/xcode/device_type_unittest.py:
(DeviceTypeTest):
(DeviceTypeTest.test_comparsion_lower_case):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (238905 => 238906)


--- trunk/Tools/ChangeLog	2018-12-05 20:58:55 UTC (rev 238905)
+++ trunk/Tools/ChangeLog	2018-12-05 21:02:46 UTC (rev 238906)
@@ -1,5 +1,23 @@
 2018-12-05  Jonathan Bedard  <[email protected]>
 
+        webkitpy: Ignore case when comparing device types
+        https://bugs.webkit.org/show_bug.cgi?id=192409
+        <rdar://problem/46491558>
+
+        Reviewed by Lucas Forschler.
+
+        This allows DeviceTypes constructed with lowercase strings to correctly compare
+        against DeviceTypes coming from the simulator runtime.
+
+        * Scripts/webkitpy/xcode/device_type.py:
+        (DeviceType.__eq__):
+        (DeviceType.__contains__):
+        * Scripts/webkitpy/xcode/device_type_unittest.py:
+        (DeviceTypeTest):
+        (DeviceTypeTest.test_comparsion_lower_case):
+
+2018-12-05  Jonathan Bedard  <[email protected]>
+
         webkitpy: Sort tests by associated device type
         https://bugs.webkit.org/show_bug.cgi?id=192161
         <rdar://problem/46345392>

Modified: trunk/Tools/Scripts/webkitpy/xcode/device_type.py (238905 => 238906)


--- trunk/Tools/Scripts/webkitpy/xcode/device_type.py	2018-12-05 20:58:55 UTC (rev 238905)
+++ trunk/Tools/Scripts/webkitpy/xcode/device_type.py	2018-12-05 21:02:46 UTC (rev 238906)
@@ -117,11 +117,11 @@
     # This technique of matching treats 'None' a wild-card.
     def __eq__(self, other):
         assert isinstance(other, DeviceType)
-        if self.hardware_family is not None and other.hardware_family is not None and self.hardware_family != other.hardware_family:
+        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 != other.hardware_type:
+        if self.hardware_type is not None and other.hardware_type is not None and self.hardware_type.lower() != other.hardware_type.lower():
             return False
-        if self.software_variant is not None and other.software_variant is not None and self.software_variant != other.software_variant:
+        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
         if self.software_version is not None and other.software_version is not None and self.software_version != other.software_version:
             return False
@@ -129,11 +129,11 @@
 
     def __contains__(self, other):
         assert isinstance(other, DeviceType)
-        if self.hardware_family is not None and self.hardware_family != other.hardware_family:
+        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 self.hardware_type != other.hardware_type:
+        if self.hardware_type is not None and (not other.hardware_type or self.hardware_type.lower() != other.hardware_type.lower()):
             return False
-        if self.software_variant is not None and self.software_variant != other.software_variant:
+        if self.software_variant is not None and (not other.software_variant or self.software_variant.lower() != other.software_variant.lower()):
             return False
         if self.software_version is not None and other.software_version is not None and not other.software_version in self.software_version:
             return False

Modified: trunk/Tools/Scripts/webkitpy/xcode/device_type_unittest.py (238905 => 238906)


--- trunk/Tools/Scripts/webkitpy/xcode/device_type_unittest.py	2018-12-05 20:58:55 UTC (rev 238905)
+++ trunk/Tools/Scripts/webkitpy/xcode/device_type_unittest.py	2018-12-05 21:02:46 UTC (rev 238906)
@@ -143,3 +143,15 @@
         self.assertFalse(DeviceType.from_string('iPhone') in DeviceType.from_string('iPhone 6s'))
         self.assertTrue(DeviceType.from_string('iPhone', Version(11, 1)) in DeviceType.from_string('iPhone', Version(11)))
         self.assertFalse(DeviceType.from_string('iPhone', Version(11)) in DeviceType.from_string('iPhone', Version(11, 1)))
+
+    def test_comparsion_lower_case(self):
+        self.assertEqual(DeviceType.from_string('iphone X'), DeviceType.from_string('iPhone'))
+        self.assertEqual(DeviceType.from_string('iphone'), DeviceType.from_string('iPhone X'))
+        self.assertEqual(DeviceType.from_string('iPhone X'), DeviceType.from_string('iphone'))
+        self.assertEqual(DeviceType.from_string('iPhone'), DeviceType.from_string('iphone X'))
+        self.assertEqual(DeviceType.from_string('iphone X'), DeviceType.from_string('iphone'))
+        self.assertEqual(DeviceType.from_string('iphone'), DeviceType.from_string('iphone X'))
+
+        self.assertTrue(DeviceType.from_string('iphone 6s') in DeviceType.from_string('iPhone'))
+        self.assertTrue(DeviceType.from_string('iPhone 6s') in DeviceType.from_string('iphone'))
+        self.assertTrue(DeviceType.from_string('iphone 6s') in DeviceType.from_string('iphone'))
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to