-
-
Notifications
You must be signed in to change notification settings - Fork 410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: bump generic iPhone for iOS 13.0 #1068
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export default { | ||
'ipad simulator': [ | ||
['0.0', 'iPad Retina'], | ||
['10.3', 'iPad Air'], | ||
], | ||
'iphone simulator': [ | ||
['0.0', 'iPhone 6'], | ||
['13.0', 'iPhone X'], | ||
] | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import { SubProcess, exec } from 'teen_process'; | |
import xcode from 'appium-xcode'; | ||
import _ from 'lodash'; | ||
import log from './logger'; | ||
import iosGenericSimulators from './ios-generic-simulators'; | ||
import _fs from 'fs'; | ||
import url from 'url'; | ||
import v8 from 'v8'; | ||
|
@@ -57,21 +58,37 @@ async function getAndCheckIosSdkVersion () { | |
} | ||
} | ||
|
||
function translateDeviceName (platformVersion, devName = '') { | ||
let deviceName = devName; | ||
switch (devName.toLowerCase().trim()) { | ||
case 'iphone simulator': | ||
deviceName = 'iPhone 6'; | ||
break; | ||
case 'ipad simulator': | ||
// iPad Retina is no longer available for ios 10.3 | ||
// so we pick another iPad to use as default | ||
deviceName = platformVersion && util.compareVersions(platformVersion, '<', '10.3') ? 'iPad Retina' : 'iPad Air'; | ||
break; | ||
} | ||
|
||
if (deviceName !== devName) { | ||
log.debug(`Changing deviceName from '${devName}' to '${deviceName}'`); | ||
/** | ||
* Get the generic simulator for a given IOS version and device type (iPhone, iPad) | ||
* | ||
* @param {string|number} platformVersion IOS version. e.g.) 13.0 | ||
* @param {string} deviceName Type of IOS device. Can be iPhone, iPad (possibly more in the future) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing return description |
||
* | ||
* @returns {string} Generic iPhone or iPad simulator (if applicable) | ||
*/ | ||
function getGenericSimulatorForIosVersion (platformVersion, deviceName) { | ||
let genericSimulators = iosGenericSimulators[deviceName]; | ||
|
||
if (genericSimulators) { | ||
genericSimulators = genericSimulators.sort(([simOne], [simTwo]) => util.compareVersions(simOne, '<', simTwo) ? -1 : 1); | ||
|
||
// Find the highest iOS version in the list that is below the provided version | ||
let genericIosSimulator; | ||
for (const [platformVersionFromList, iosSimulator] of genericSimulators) { | ||
if (util.compareVersions(platformVersionFromList, '>', platformVersion)) { | ||
break; | ||
} | ||
genericIosSimulator = iosSimulator; | ||
} | ||
return genericIosSimulator; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can the result be undefined? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No. The lowest iOS version in the list is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it makes sense to leave a comment about that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I changed it so now it can be undefined and |
||
} | ||
} | ||
|
||
function translateDeviceName (platformVersion, deviceName = '') { | ||
const deviceNameTranslated = getGenericSimulatorForIosVersion(platformVersion, deviceName.toLowerCase().trim()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is it necessary to change the device name to lower case? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mykola-mokhnach yeah if somebody provides |
||
if (deviceNameTranslated) { | ||
log.debug(`Changing deviceName from '${deviceName}' to '${deviceNameTranslated}'`); | ||
return deviceNameTranslated; | ||
} | ||
return deviceName; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth noting that these need to be strictly in order, or the parsing logic won't work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. Maybe I should just sort them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I sort them now to be safe.