From 7316d82206973085d6a02a130d5240fd849d8f8f Mon Sep 17 00:00:00 2001 From: SvetoslavTsenov Date: Thu, 3 Oct 2019 01:29:17 +0300 Subject: [PATCH 1/5] feat(ios-controller): include ios devices screen info --- lib/ios-controller.d.ts | 1 + lib/ios-controller.ts | 197 ++++++++++++++++++++++------------------ package.json | 2 +- 3 files changed, 111 insertions(+), 89 deletions(-) diff --git a/lib/ios-controller.d.ts b/lib/ios-controller.d.ts index 52e6675..1783a6a 100644 --- a/lib/ios-controller.d.ts +++ b/lib/ios-controller.d.ts @@ -65,6 +65,7 @@ export declare class IOSController { private static tailLogsUntil; static getLogDir(token: any): string; private static loadIOSDevicesScreenInfo; + static devicesDisplaysInfos(): IOSDeviceScreenInfo[]; } export interface IOSDeviceScreenInfo { deviceType: any; diff --git a/lib/ios-controller.ts b/lib/ios-controller.ts index b9ad815..d6c110a 100644 --- a/lib/ios-controller.ts +++ b/lib/ios-controller.ts @@ -357,7 +357,7 @@ export class IOSController { * @param bundleId - should be provided when DeviceType.DEVICE else undefined * @param appName - should be provided when DeviceType.SIMULATOR else undefined **/ - public static async stopApplication(device: IDevice, bundleId: string, appName: string): Promise { + public static async stopApplication(device: IDevice, bundleId: string, appName: string): Promise { const apps = IOSController.getInstalledApplications(device); if (apps.some(app => app.includes(bundleId))) { if (!device.type) { @@ -499,7 +499,7 @@ export class IOSController { if (device.name.includes(k)) { device.config = { density: v.density, - offsetPixels: v.actionBarHeight + offsetPixels: v.actionBarHeight * v.density }; } }); @@ -789,100 +789,121 @@ export class IOSController { } private static loadIOSDevicesScreenInfo() { - const devices = new Map(); - - // IOSController.devicesScreenInfo.set("iPhone 5", new IOSDeviceScreenInfo("iPhone 5", 640, 1336, 326, 30)); - // IOSController.devicesScreenInfo.set("iPhone 5C", new IOSDeviceScreenInfo("iPhone 5C", 640, 1336, 326, 30)); - // IOSController.devicesScreenInfo.set("iPhone 5S", new IOSDeviceScreenInfo("iPhone 5S", 640, 1336, 326, 30)); - - IOSController.devicesScreenInfo.set("iPhone 6", { - deviceType: "iPhone 6", - width: 750, - height: 1334, - density: 2, - actionBarHeight: 33 - }); - - IOSController.devicesScreenInfo.set("iPhone 6s", { - deviceType: "iPhone 6s", - width: 750, - height: 1334, - density: 2, - actionBarHeight: 33 - }); - - IOSController.devicesScreenInfo.set("iPhone 7", { - deviceType: "iPhone 7", - width: 750, - height: 1334, - density: 2, - actionBarHeight: 33 - }); - - IOSController.devicesScreenInfo.set("iPhone 8", { - deviceType: "iPhone 8", - width: 750, - height: 1334, - density: 2, - actionBarHeight: 33 - }); - - IOSController.devicesScreenInfo.set("iPhone 6 Plus", { - deviceType: "iPhone 6 Plus", - width: 1242, - height: 2208, - density: 3, - actionBarHeight: 50 - }); - - IOSController.devicesScreenInfo.set("6 Plus", { - deviceType: "iPhone 6 Plus", - width: 1242, - height: 2208, - density: 3, - actionBarHeight: 50 - }); - - IOSController.devicesScreenInfo.set("7 Plus", { - deviceType: "iPhone 7 Plus", - width: 1242, - height: 2208, - density: 3, - actionBarHeight: 50 + IOSController.getDevicesScreenInfo().forEach(d => { + IOSController.devicesScreenInfo.set(d.deviceType, d); }); + } - IOSController.devicesScreenInfo.set("8 Plus", { - deviceType: "iPhone 8 Plus", - width: 1242, - height: 2208, - density: 3, - actionBarHeight: 50 - }); + public static devicesDisplaysInfos() { + const devicesInfo = new Array( + { + deviceType: "iPhone 6", + width: 750, + height: 1334, + density: 2, + actionBarHeight: 33 + }, + { + deviceType: "iPhone 6s", + width: 750, + height: 1334, + density: 2, + actionBarHeight: 33 + }, + { + deviceType: "iPhone 6 Plus", + width: 1242, + height: 2208, + density: 3, + actionBarHeight: 50 + }, + { + deviceType: "iPhone 7 Plus", + width: 1242, + height: 2208, + density: 3, + actionBarHeight: 50 + }, + { + deviceType: "iPhone 7", + width: 750, + height: 1334, + density: 2, + actionBarHeight: 33 + }, + { + deviceType: "iPhone 8", + height: 1334, + width: 750, + density: 2, + actionBarHeight: 20 + }, + { + deviceType: "iPhone 8 Plus", + width: 1242, + height: 2208, + density: 3, + actionBarHeight: 50 + }, + { + deviceType: "iPhone X", + width: 1242, + height: 2208, + density: 3, + actionBarHeight: 44 + }, + { + deviceType: "iPhone XR", + width: 828, + height: 1792, + density: 2, + actionBarHeight: 44 + }, + { + deviceType: "iPhone XS", + width: 1125, + height: 2436, + density: 3, + actionBarHeight: 44 + }, + { + deviceType: "iPhone XS Max", + width: 1242, + height: 2688, + density: 3, + actionBarHeight: 44 + }, + { + deviceType: "iPhone 11", + width: 828, + height: 1792, + density: 2, + actionBarHeight: 44 + }, + { + deviceType: "iPhone 11 Pro", + width: 375, + height: 812, + density: 3, + actionBarHeight: 44 + }, + { + deviceType: "iPhone 11", + width: 1242, + height: 2688, + density: 3, + actionBarHeight: 44 + }); - IOSController.devicesScreenInfo.set("X", { - deviceType: "iPhone X", - width: 1242, - height: 2208, - density: 3, - actionBarHeight: 87 + // longest names at the start + const sortedDevices = devicesInfo.sort((a, b) => { + return b.deviceType.length - a.deviceType.length; }); - // IOSController.devicesScreenInfo("Mini 2", new IOSDeviceScreenInfo("Mini 2", 11242, 2208, 401)); - // IOSController.devicesScreenInfo("Mini 3", new IOSDeviceScreenInfo("Mini 3", 11242, 2208, 401)); - // IOSController.devicesScreenInfo("Mini 4", new IOSDeviceScreenInfo("Mini 4", 11242, 2208, 401)); - - // IOSController.devicesScreenInfo("iPad 3", new IOSDeviceScreenInfo("iPad 3", 1536, 2048, 264)); - // IOSController.devicesScreenInfo("iPad 4", new IOSDeviceScreenInfo("iPad 4", 1536, 2048, 264)); - - // IOSController.devicesScreenInfo("iPad Air", new IOSDeviceScreenInfo("iPad Air", 1536, 2048, 264)); - // IOSController.devicesScreenInfo.set("iPad Air 2", new IOSDeviceScreenInfo("iPad Air 2", 1536, 2048, 264, 32)); - - // IOSController.devicesScreenInfo("9.7-inch Pro", new IOSDeviceScreenInfo("iPad Pro", 1536, 2048, 264)); - // IOSController.devicesScreenInfo("12.9-inch iPad Pro", new IOSDeviceScreenInfo("12.9-inch iPad Pro", 1536, 2048, 264)); + return sortedDevices; } } - export interface IOSDeviceScreenInfo { // In the context of iOS, the proper term for `density` is `screen scale`. Adhere to `density` for unified API. deviceType, diff --git a/package.json b/package.json index 909c377..c4426b2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mobile-devices-controller", - "version": "5.1.0", + "version": "5.2.0", "main": "index.js", "description": "Manage devices, emulators and simulators.", "keywords": [ From 2954b561855746c4c3d02284c01c3b4f791a8ad7 Mon Sep 17 00:00:00 2001 From: SvetoslavTsenov Date: Thu, 3 Oct 2019 10:56:45 +0300 Subject: [PATCH 2/5] fix: circle reference --- lib/ios-controller.ts | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ios-controller.ts b/lib/ios-controller.ts index d6c110a..a8bf953 100644 --- a/lib/ios-controller.ts +++ b/lib/ios-controller.ts @@ -789,7 +789,7 @@ export class IOSController { } private static loadIOSDevicesScreenInfo() { - IOSController.getDevicesScreenInfo().forEach(d => { + IOSController.devicesDisplaysInfos().forEach(d => { IOSController.devicesScreenInfo.set(d.deviceType, d); }); } diff --git a/package.json b/package.json index c4426b2..f516b7e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mobile-devices-controller", - "version": "5.2.0", + "version": "5.2.1", "main": "index.js", "description": "Manage devices, emulators and simulators.", "keywords": [ From eccf0d79114afd07a65d0f4fcd31655ac20cc9d6 Mon Sep 17 00:00:00 2001 From: SvetoslavTsenov Date: Fri, 4 Oct 2019 22:38:04 +0300 Subject: [PATCH 3/5] fix(ios): scale status bar height --- lib/ios-controller.ts | 28 ++++++++++++++-------------- package.json | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/ios-controller.ts b/lib/ios-controller.ts index a8bf953..64a3434 100644 --- a/lib/ios-controller.ts +++ b/lib/ios-controller.ts @@ -801,98 +801,98 @@ export class IOSController { width: 750, height: 1334, density: 2, - actionBarHeight: 33 + actionBarHeight: 40 }, { deviceType: "iPhone 6s", width: 750, height: 1334, density: 2, - actionBarHeight: 33 + actionBarHeight: 40 }, { deviceType: "iPhone 6 Plus", width: 1242, height: 2208, density: 3, - actionBarHeight: 50 + actionBarHeight: 60 }, { deviceType: "iPhone 7 Plus", width: 1242, height: 2208, density: 3, - actionBarHeight: 50 + actionBarHeight: 60 }, { deviceType: "iPhone 7", width: 750, height: 1334, density: 2, - actionBarHeight: 33 + actionBarHeight: 40 }, { deviceType: "iPhone 8", height: 1334, width: 750, density: 2, - actionBarHeight: 20 + actionBarHeight: 40 }, { deviceType: "iPhone 8 Plus", width: 1242, height: 2208, density: 3, - actionBarHeight: 50 + actionBarHeight: 60 }, { deviceType: "iPhone X", width: 1242, height: 2208, density: 3, - actionBarHeight: 44 + actionBarHeight: 132 }, { deviceType: "iPhone XR", width: 828, height: 1792, density: 2, - actionBarHeight: 44 + actionBarHeight: 88 }, { deviceType: "iPhone XS", width: 1125, height: 2436, density: 3, - actionBarHeight: 44 + actionBarHeight: 132 }, { deviceType: "iPhone XS Max", width: 1242, height: 2688, density: 3, - actionBarHeight: 44 + actionBarHeight: 132 }, { deviceType: "iPhone 11", width: 828, height: 1792, density: 2, - actionBarHeight: 44 + actionBarHeight: 88 }, { deviceType: "iPhone 11 Pro", width: 375, height: 812, density: 3, - actionBarHeight: 44 + actionBarHeight: 132 }, { deviceType: "iPhone 11", width: 1242, height: 2688, density: 3, - actionBarHeight: 44 + actionBarHeight: 132 }); // longest names at the start diff --git a/package.json b/package.json index f516b7e..fc365de 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mobile-devices-controller", - "version": "5.2.1", + "version": "5.2.2", "main": "index.js", "description": "Manage devices, emulators and simulators.", "keywords": [ From cc9cbe2cb173eaa44288acc87a3a3f61732c4907 Mon Sep 17 00:00:00 2001 From: Zdravko Date: Wed, 9 Oct 2019 14:16:36 +0300 Subject: [PATCH 4/5] fix: offset by not multiplying offset pixels by density. (#19) --- lib/ios-controller.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ios-controller.ts b/lib/ios-controller.ts index 64a3434..f0924e6 100644 --- a/lib/ios-controller.ts +++ b/lib/ios-controller.ts @@ -499,7 +499,7 @@ export class IOSController { if (device.name.includes(k)) { device.config = { density: v.density, - offsetPixels: v.actionBarHeight * v.density + offsetPixels: v.actionBarHeight }; } }); From aa8079b7e4a106d62f075cd124facd7bec9dae65 Mon Sep 17 00:00:00 2001 From: SvetoslavTsenov Date: Mon, 18 Nov 2019 15:16:30 +0200 Subject: [PATCH 5/5] fix: remove wrong duplicated ios sim --- lib/ios-controller.ts | 7 ------- package.json | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/lib/ios-controller.ts b/lib/ios-controller.ts index f0924e6..f77ca6a 100644 --- a/lib/ios-controller.ts +++ b/lib/ios-controller.ts @@ -886,13 +886,6 @@ export class IOSController { height: 812, density: 3, actionBarHeight: 132 - }, - { - deviceType: "iPhone 11", - width: 1242, - height: 2688, - density: 3, - actionBarHeight: 132 }); // longest names at the start diff --git a/package.json b/package.json index fc365de..7345150 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mobile-devices-controller", - "version": "5.2.2", + "version": "5.2.3", "main": "index.js", "description": "Manage devices, emulators and simulators.", "keywords": [