OLD | NEW |
(Empty) | |
| 1 (class DeviceEmulator { |
| 2 constructor(testRunner, session) { |
| 3 this._testRunner = testRunner; |
| 4 this._session = session; |
| 5 } |
| 6 |
| 7 async emulate(width, height, deviceScaleFactor, insets) { |
| 8 this._testRunner.log(`Emulating device: ${width}x${height}x${deviceScaleFact
or}`); |
| 9 var full = !!width && !!height && !!deviceScaleFactor; |
| 10 var params = { |
| 11 width, |
| 12 height, |
| 13 deviceScaleFactor, |
| 14 mobile: true, |
| 15 fitWindow: false, |
| 16 scale: 1, |
| 17 screenWidth: width, |
| 18 screenHeight: height, |
| 19 positionX: 0, |
| 20 positionY: 0 |
| 21 }; |
| 22 if (insets) { |
| 23 params.screenWidth += insets.left + insets.right; |
| 24 params.positionX = insets.left; |
| 25 params.screenHeight += insets.top + insets.bottom; |
| 26 params.positionY = insets.top; |
| 27 } |
| 28 var response = await this._session.protocol.Emulation.setDeviceMetricsOverri
de(params); |
| 29 if (response.error) |
| 30 this._testRunner.log('Error: ' + response.error); |
| 31 } |
| 32 |
| 33 async clear() { |
| 34 await this._session.protocol.Emulation.clearDeviceMetricsOverride(); |
| 35 } |
| 36 }) |
OLD | NEW |