Changeset 238906 in webkit


Ignore:
Timestamp:
Dec 5, 2018 1:02:46 PM (5 years ago)
Author:
Jonathan Bedard
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):

Location:
trunk/Tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r238903 r238906  
     12018-12-05  Jonathan Bedard  <jbedard@apple.com>
     2
     3        webkitpy: Ignore case when comparing device types
     4        https://bugs.webkit.org/show_bug.cgi?id=192409
     5        <rdar://problem/46491558>
     6
     7        Reviewed by Lucas Forschler.
     8
     9        This allows DeviceTypes constructed with lowercase strings to correctly compare
     10        against DeviceTypes coming from the simulator runtime.
     11
     12        * Scripts/webkitpy/xcode/device_type.py:
     13        (DeviceType.__eq__):
     14        (DeviceType.__contains__):
     15        * Scripts/webkitpy/xcode/device_type_unittest.py:
     16        (DeviceTypeTest):
     17        (DeviceTypeTest.test_comparsion_lower_case):
     18
    1192018-12-05  Jonathan Bedard  <jbedard@apple.com>
    220
  • trunk/Tools/Scripts/webkitpy/xcode/device_type.py

    r226263 r238906  
    118118    def __eq__(self, other):
    119119        assert isinstance(other, DeviceType)
    120         if self.hardware_family is not None and other.hardware_family is not None and self.hardware_family != other.hardware_family:
     120        if self.hardware_family is not None and other.hardware_family is not None and self.hardware_family.lower() != other.hardware_family.lower():
    121121            return False
    122         if self.hardware_type is not None and other.hardware_type is not None and self.hardware_type != other.hardware_type:
     122        if self.hardware_type is not None and other.hardware_type is not None and self.hardware_type.lower() != other.hardware_type.lower():
    123123            return False
    124         if self.software_variant is not None and other.software_variant is not None and self.software_variant != other.software_variant:
     124        if self.software_variant is not None and other.software_variant is not None and self.software_variant.lower() != other.software_variant.lower():
    125125            return False
    126126        if self.software_version is not None and other.software_version is not None and self.software_version != other.software_version:
     
    130130    def __contains__(self, other):
    131131        assert isinstance(other, DeviceType)
    132         if self.hardware_family is not None and self.hardware_family != other.hardware_family:
     132        if self.hardware_family is not None and (not other.hardware_family or self.hardware_family.lower() != other.hardware_family.lower()):
    133133            return False
    134         if self.hardware_type is not None and self.hardware_type != other.hardware_type:
     134        if self.hardware_type is not None and (not other.hardware_type or self.hardware_type.lower() != other.hardware_type.lower()):
    135135            return False
    136         if self.software_variant is not None and self.software_variant != other.software_variant:
     136        if self.software_variant is not None and (not other.software_variant or self.software_variant.lower() != other.software_variant.lower()):
    137137            return False
    138138        if self.software_version is not None and other.software_version is not None and not other.software_version in self.software_version:
  • trunk/Tools/Scripts/webkitpy/xcode/device_type_unittest.py

    r238694 r238906  
    144144        self.assertTrue(DeviceType.from_string('iPhone', Version(11, 1)) in DeviceType.from_string('iPhone', Version(11)))
    145145        self.assertFalse(DeviceType.from_string('iPhone', Version(11)) in DeviceType.from_string('iPhone', Version(11, 1)))
     146
     147    def test_comparsion_lower_case(self):
     148        self.assertEqual(DeviceType.from_string('iphone X'), DeviceType.from_string('iPhone'))
     149        self.assertEqual(DeviceType.from_string('iphone'), DeviceType.from_string('iPhone X'))
     150        self.assertEqual(DeviceType.from_string('iPhone X'), DeviceType.from_string('iphone'))
     151        self.assertEqual(DeviceType.from_string('iPhone'), DeviceType.from_string('iphone X'))
     152        self.assertEqual(DeviceType.from_string('iphone X'), DeviceType.from_string('iphone'))
     153        self.assertEqual(DeviceType.from_string('iphone'), DeviceType.from_string('iphone X'))
     154
     155        self.assertTrue(DeviceType.from_string('iphone 6s') in DeviceType.from_string('iPhone'))
     156        self.assertTrue(DeviceType.from_string('iPhone 6s') in DeviceType.from_string('iphone'))
     157        self.assertTrue(DeviceType.from_string('iphone 6s') in DeviceType.from_string('iphone'))
Note: See TracChangeset for help on using the changeset viewer.