def testLoadDevices(self): devices = emulation.LoadEmulatedDevices(file(os.path.join( _SRC_DIR, 'third_party/WebKit/Source/devtools/front_end', 'emulated_devices/module.json'))) # Just check we have something. We'll assume that if we were able to read # the file without dying we must be ok. self.assertTrue(devices)
def SetDeviceEmulation(self, device_name): """Set device emulation. Args: device_name: (str) Key from --devices_file. """ devices = emulation.LoadEmulatedDevices(file(OPTIONS.devices_file)) self._emulated_device = devices[device_name]
def testSetUpDevice(self): registry = StringIO("""{ "extensions": [ { "type": "emulated-device", "device": { "show-by-default": false, "title": "mattPhone" , "screen": { "horizontal": { "width": 480, "height": 320 }, "device-pixel-ratio": 2, "vertical": { "width": 320, "height": 480 } }, "capabilities": [ "touch", "mobile" ], "user-agent": "James Bond" } } ]}""") devices = emulation.LoadEmulatedDevices(registry) connection = test_utils.MockConnection(self) connection.ExpectSyncRequest({'result': True}, 'Emulation.canEmulate') metadata = emulation.SetUpDeviceEmulationAndReturnMetadata( connection, devices['mattPhone']) self.assertEqual(320, metadata['width']) self.assertEqual('James Bond', metadata['userAgent']) self.assertTrue(connection.AllExpectationsUsed()) self.assertEqual('Emulation.setDeviceMetricsOverride', connection.no_response_requests_seen[0][0])