Code review fixes.

This commit is contained in:
Onuray Sahin 2022-09-30 13:21:44 +03:00
parent 0f8637bc7a
commit bf4576d155
2 changed files with 33 additions and 14 deletions

View File

@ -48,7 +48,13 @@ class ParseDeviceUserAgentUseCase @Inject constructor() {
deviceModel = deviceInfoSegments.getOrNull(0)
deviceOperatingSystem = deviceInfoSegments.getOrNull(1)
}
return DeviceExtendedInfo(DeviceType.MOBILE, deviceModel, deviceOperatingSystem, appName, appVersion)
return DeviceExtendedInfo(
deviceType = DeviceType.MOBILE,
deviceModel = deviceModel,
deviceOperatingSystem = deviceOperatingSystem,
clientName = appName,
clientVersion = appVersion
)
}
private fun parseIosUserAgent(userAgent: String): DeviceExtendedInfo {
@ -57,7 +63,13 @@ class ParseDeviceUserAgentUseCase @Inject constructor() {
val deviceInfoSegments = userAgent.substringAfter("(").substringBeforeLast(")").split("; ")
val deviceModel = deviceInfoSegments.getOrNull(0)
val deviceOperatingSystem = deviceInfoSegments.getOrNull(1)
return DeviceExtendedInfo(DeviceType.MOBILE, deviceModel, deviceOperatingSystem, appName, appVersion)
return DeviceExtendedInfo(
deviceType = DeviceType.MOBILE,
deviceModel = deviceModel,
deviceOperatingSystem = deviceOperatingSystem,
clientName = appName,
clientVersion = appVersion
)
}
private fun parseDesktopUserAgent(userAgent: String): DeviceExtendedInfo {
@ -86,7 +98,14 @@ class ParseDeviceUserAgentUseCase @Inject constructor() {
} else {
deviceOperatingSystemSegments.getOrNull(0)
}
return DeviceExtendedInfo(DeviceType.DESKTOP, browserName, deviceOperatingSystem, null, null)
return DeviceExtendedInfo(
deviceType = DeviceType.DESKTOP,
deviceModel = null,
deviceOperatingSystem = deviceOperatingSystem,
clientName = null,
clientVersion = null,
browser = browserName
)
}
private fun parseWebUserAgent(userAgent: String): DeviceExtendedInfo {

View File

@ -61,8 +61,8 @@ private val A_USER_AGENT_LIST_FOR_DESKTOP = listOf(
"Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) ElementNightly/2022091301 Chrome/104.0.5112.102 Electron/20.1.1 Safari/537.36",
)
private val AN_EXPECTED_RESULT_LIST_FOR_DESKTOP = listOf(
DeviceExtendedInfo(DeviceType.DESKTOP, "Electron", "Macintosh", null, null),
DeviceExtendedInfo(DeviceType.DESKTOP, "Electron", "Windows NT 10.0", null, null),
DeviceExtendedInfo(DeviceType.DESKTOP, null, "Macintosh", null, null, "Electron"),
DeviceExtendedInfo(DeviceType.DESKTOP, null, "Windows NT 10.0", null, null, "Electron"),
)
private val A_USER_AGENT_LIST_FOR_WEB = listOf(
@ -77,15 +77,15 @@ private val A_USER_AGENT_LIST_FOR_WEB = listOf(
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246",
)
private val AN_EXPECTED_RESULT_LIST_FOR_WEB = listOf(
DeviceExtendedInfo(DeviceType.WEB, "Chrome", "Macintosh", null, null),
DeviceExtendedInfo(DeviceType.WEB, "Chrome", "Windows NT 10.0", null, null),
DeviceExtendedInfo(DeviceType.WEB, "Firefox", "Macintosh", null, null),
DeviceExtendedInfo(DeviceType.WEB, "Safari", "Macintosh", null, null),
DeviceExtendedInfo(DeviceType.WEB, "Chrome", "Android 9", null, null),
DeviceExtendedInfo(DeviceType.WEB, "Safari", "iPad", null, null),
DeviceExtendedInfo(DeviceType.WEB, "Safari", "iPhone", null, null),
DeviceExtendedInfo(DeviceType.WEB, "Firefox", "Windows NT 6.0", null, null),
DeviceExtendedInfo(DeviceType.WEB, "Edge", "Windows NT 10.0", null, null),
DeviceExtendedInfo(DeviceType.WEB, null, "Macintosh", null, null, "Chrome"),
DeviceExtendedInfo(DeviceType.WEB, null, "Windows NT 10.0", null, null, "Chrome"),
DeviceExtendedInfo(DeviceType.WEB, null, "Macintosh", null, null, "Firefox"),
DeviceExtendedInfo(DeviceType.WEB, null, "Macintosh", null, null, "Safari"),
DeviceExtendedInfo(DeviceType.WEB, null, "Android 9", null, null, "Chrome"),
DeviceExtendedInfo(DeviceType.WEB, null, "iPad", null, null, "Safari"),
DeviceExtendedInfo(DeviceType.WEB, null, "iPhone", null, null, "Safari"),
DeviceExtendedInfo(DeviceType.WEB, null, "Windows NT 6.0", null, null, "Firefox"),
DeviceExtendedInfo(DeviceType.WEB, null, "Windows NT 10.0", null, null, "Edge"),
)
private val AN_UNKNOWN_USER_AGENT_LIST = listOf(