Skip to content
Permalink
Browse files
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):


Canonical link: https://commits.webkit.org/207037@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238906 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
JonWBedard committed Dec 5, 2018
1 parent 0a28315 commit 0413e7d93677510aa87c1eaa969cc1d4f840a134
Showing 3 changed files with 36 additions and 6 deletions.
@@ -1,3 +1,21 @@
2018-12-05 Jonathan Bedard <jbedard@apple.com>

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 <jbedard@apple.com>

webkitpy: Sort tests by associated device type
@@ -117,23 +117,23 @@ def __str__(self):
# 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
return True

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
@@ -143,3 +143,15 @@ def test_contained_in(self):
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'))

0 comments on commit 0413e7d

Please sign in to comment.