Beispiel #1
0
    def test_existing_simulator(self):
        SimulatedDeviceTest.reset_simulated_device_manager()
        host = SimulatedDeviceTest.mock_host_for_simctl()
        SimulatedDeviceManager.available_devices(host)

        SimulatedDeviceManager.initialize_devices(DeviceRequest(
            DeviceType.from_string('iPhone', Version(11))),
                                                  host=host)

        self.assertEquals(1, len(SimulatedDeviceManager.INITIALIZED_DEVICES))
        self.assertEquals('34FB476C-6FA0-43C8-8945-1BD7A4EBF0DE',
                          SimulatedDeviceManager.INITIALIZED_DEVICES[0].udid)
        self.assertEquals(
            '15A8401',
            SimulatedDeviceManager.INITIALIZED_DEVICES[0].build_version)
        self.assertEquals(
            SimulatedDevice.DeviceState.BOOTED, SimulatedDeviceManager.
            INITIALIZED_DEVICES[0].platform_device.state())

        SimulatedDeviceManager.tear_down(host)
        self.assertIsNone(SimulatedDeviceManager.INITIALIZED_DEVICES)
Beispiel #2
0
    def _create_device_with_runtime(host, runtime, device_info):
        if device_info.get(
                'availability') != '(available)' and device_info.get(
                    'isAvailable') != 'YES' and device_info.get(
                        'isAvailable') != True:
            return None

        # Check existing devices.
        for device in SimulatedDeviceManager.AVAILABLE_DEVICES:
            if device.udid == device_info['udid']:
                return device

        # Check that the device.plist exists
        device_plist = host.filesystem.expanduser(
            host.filesystem.join(SimulatedDeviceManager.simulator_device_path,
                                 device_info['udid'], 'device.plist'))
        if not host.filesystem.isfile(device_plist):
            return None

        # Find device type. If we can't parse the device type, ignore this device.
        try:
            device_type_string = SimulatedDeviceManager._device_identifier_to_name[
                plistlib.readPlist(
                    host.filesystem.open_binary_file_for_reading(
                        device_plist))['deviceType']]
            device_type = DeviceType.from_string(device_type_string,
                                                 runtime.version)
            assert device_type.software_variant == runtime.os_variant
        except (ValueError, AssertionError):
            return None

        result = Device(
            SimulatedDevice(
                name=device_info['name'],
                udid=device_info['udid'],
                host=host,
                device_type=device_type,
            ))
        SimulatedDeviceManager.AVAILABLE_DEVICES.append(result)
        return result
Beispiel #3
0
 def test_max_child_processes(self):
     port = self.make_port()
     self.assertEqual(
         port.max_child_processes(DeviceType.from_string('Apple Watch')), 0)
Beispiel #4
0
 def _initialize_devices(self):
     if 'simulator' in self._port.port_name:
         SimulatedDeviceManager.initialize_devices(DeviceRequest(DeviceType.from_string(self._port.DEFAULT_DEVICE_CLASS), allow_incomplete_match=True), self.host, simulator_ui=False)
     elif 'device' in self._port.port_name:
         raise RuntimeError('Running api tests on {} is not supported'.format(self._port.port_name))
Beispiel #5
0
    def test_layout_searchpath_wih_device_type(self):
        search_path = self.make_port(port_name='ios-device-wk2', os_version=Version(12)).default_baseline_search_path(DeviceType.from_string('iPhone SE'))

        self.assertEqual(search_path, [
            '/mock-checkout/LayoutTests/platform/iphone-se-device-12-wk2',
            '/mock-checkout/LayoutTests/platform/iphone-se-device-12',
            '/mock-checkout/LayoutTests/platform/iphone-se-device-wk2',
            '/mock-checkout/LayoutTests/platform/iphone-se-device',
            '/mock-checkout/LayoutTests/platform/iphone-device-12-wk2',
            '/mock-checkout/LayoutTests/platform/iphone-device-12',
            '/mock-checkout/LayoutTests/platform/iphone-device-wk2',
            '/mock-checkout/LayoutTests/platform/iphone-device',
            '/mock-checkout/LayoutTests/platform/ios-device-12-wk2',
            '/mock-checkout/LayoutTests/platform/ios-device-12',
            '/mock-checkout/LayoutTests/platform/ios-device-wk2',
            '/mock-checkout/LayoutTests/platform/ios-device',
            '/mock-checkout/LayoutTests/platform/iphone-se-12-wk2',
            '/mock-checkout/LayoutTests/platform/iphone-se-12',
            '/mock-checkout/LayoutTests/platform/iphone-se-wk2',
            '/mock-checkout/LayoutTests/platform/iphone-se',
            '/mock-checkout/LayoutTests/platform/iphone-12-wk2',
            '/mock-checkout/LayoutTests/platform/iphone-12',
            '/mock-checkout/LayoutTests/platform/iphone-wk2',
            '/mock-checkout/LayoutTests/platform/iphone',
            '/mock-checkout/LayoutTests/platform/ios-12-wk2',
            '/mock-checkout/LayoutTests/platform/ios-12',
            '/mock-checkout/LayoutTests/platform/ios-wk2',
            '/mock-checkout/LayoutTests/platform/ios',
            '/mock-checkout/LayoutTests/platform/wk2',
        ])
Beispiel #6
0
 def test_unmapped_version(self):
     self.assertEqual('iPhone running iOS',
                      str(DeviceType.from_string('iPhone', Version(9))))
Beispiel #7
0
    def test_comparison_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'))
Beispiel #8
0
    def test_comparison(self):
        # iPhone comparisons
        self.assertEqual(DeviceType.from_string('iPhone 6s'),
                         DeviceType.from_string('iPhone'))
        self.assertEqual(DeviceType.from_string('iPhone X'),
                         DeviceType.from_string('iPhone'))
        self.assertNotEqual(DeviceType.from_string('iPhone 6s'),
                            DeviceType.from_string('iPhone X'))

        # iPad comparisons
        self.assertEqual(DeviceType.from_string('iPad Air 2'),
                         DeviceType.from_string('iPad'))
        self.assertEqual(DeviceType.from_string('iPad Pro (12.9-inch)'),
                         DeviceType.from_string('iPad'))
        self.assertNotEqual(DeviceType.from_string('iPad Air 2'),
                            DeviceType.from_string('iPad Pro (12.9-inch)'))

        # Apple Watch comparisons
        self.assertEqual(DeviceType.from_string('Apple Watch Series 2 - 38mm'),
                         DeviceType.from_string('Apple Watch'))
        self.assertEqual(DeviceType.from_string('Apple Watch Series 2 - 42mm'),
                         DeviceType.from_string('Apple Watch'))
        self.assertNotEqual(
            DeviceType.from_string('Apple Watch Series 2 - 38mm'),
            DeviceType.from_string('Apple Watch Series 2 - 42mm'))

        # Apple TV comparisons
        self.assertEqual(DeviceType.from_string('Apple TV 4K'),
                         DeviceType.from_string('Apple TV'))
        self.assertEqual(DeviceType.from_string('Apple TV 4K (at 1080p)'),
                         DeviceType.from_string('Apple TV'))
        self.assertNotEqual(DeviceType.from_string('Apple TV 4K'),
                            DeviceType.from_string('Apple TV 4K (at 1080p)'))

        # Match by software_variant
        self.assertEqual(DeviceType.from_string('iPhone 6s'),
                         DeviceType(software_variant='iOS'))
        self.assertEqual(DeviceType.from_string('iPad Air 2'),
                         DeviceType(software_variant='iOS'))
        self.assertNotEqual(
            DeviceType.from_string('Apple Watch Series 2 - 42mm'),
            DeviceType(software_variant='iOS'))
        self.assertNotEqual(DeviceType.from_string('Apple TV 4K'),
                            DeviceType(software_variant='iOS'))

        # Cross-device comparisons
        self.assertNotEqual(DeviceType.from_string('iPad'),
                            DeviceType.from_string('iPhone'))
        self.assertNotEqual(DeviceType.from_string('Apple Watch'),
                            DeviceType.from_string('iPhone'))
        self.assertNotEqual(DeviceType.from_string('Apple Watch'),
                            DeviceType.from_string('Apple TV'))
Beispiel #9
0
    def test_available_devices(self):
        SimulatedDeviceTest.reset_simulated_device_manager()
        host = SimulatedDeviceTest.mock_host_for_simctl()
        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)))

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

        # 18 iPhones
        self.assertEquals(
            18,
            len(
                SimulatedDeviceManager.device_by_filter(
                    lambda device: device.platform_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)))

        # 18 Apple watches
        self.assertEquals(
            6,
            len(
                SimulatedDeviceManager.device_by_filter(
                    lambda device: device.platform_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)))

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

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