Add call status sharing and automatic stream orientation
This commit is contained in:
1 parent
f97b728e78
commit
ea4ab1cc84
16 files changed
+223
-51
No files matched your search
+28
-6
@@ -4,18 +4,40 @@ import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
|
||||
class StreamOrientationTest {
|
||||
private val manual = StreamOrientation.values().filter { it != StreamOrientation.AUTO }
|
||||
|
||||
@Test fun rearCameraRotationFollowsManualOrientation() {
|
||||
assertEquals(listOf(90, 0, 270, 180), StreamOrientation.values().map { it.sensorRotation(90, false) })
|
||||
assertEquals(listOf(270, 180, 90, 0), StreamOrientation.values().map { it.sensorRotation(270, false) })
|
||||
assertEquals(listOf(90, 0, 270, 180), manual.map { it.sensorRotation(90, false) })
|
||||
assertEquals(listOf(270, 180, 90, 0), manual.map { it.sensorRotation(270, false) })
|
||||
}
|
||||
|
||||
@Test fun frontCameraUsesOppositeSensorCompensation() {
|
||||
assertEquals(listOf(270, 0, 90, 180), StreamOrientation.values().map { it.sensorRotation(270, true) })
|
||||
assertEquals(listOf(90, 180, 270, 0), StreamOrientation.values().map { it.sensorRotation(90, true) })
|
||||
assertEquals(listOf(270, 0, 90, 180), manual.map { it.sensorRotation(270, true) })
|
||||
assertEquals(listOf(90, 180, 270, 0), manual.map { it.sensorRotation(90, true) })
|
||||
}
|
||||
|
||||
@Test fun camerasWithZeroSensorRotationKeepAllFourDirections() {
|
||||
assertEquals(listOf(0, 270, 180, 90), StreamOrientation.values().map { it.sensorRotation(0, false) })
|
||||
assertEquals(listOf(0, 90, 180, 270), StreamOrientation.values().map { it.sensorRotation(0, true) })
|
||||
assertEquals(listOf(0, 270, 180, 90), manual.map { it.sensorRotation(0, false) })
|
||||
assertEquals(listOf(0, 90, 180, 270), manual.map { it.sensorRotation(0, true) })
|
||||
}
|
||||
|
||||
@Test fun autoMatchesVideoCallsForEveryCameraAndDeviceDirection() {
|
||||
for (sensor in listOf(0, 90, 180, 270)) for (angle in listOf(0, 90, 180, 270)) for (front in listOf(false, true)) {
|
||||
val orientation = CallVideoOrientation()
|
||||
orientation.observe(angle, 0)
|
||||
assertEquals(orientation.rotation(sensor, front), StreamOrientation.AUTO.sensorRotation(sensor, front, orientation.degrees))
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun manualOrientationIgnoresDeviceDirection() {
|
||||
for (option in manual) for (angle in listOf(0, 90, 180, 270)) for (front in listOf(false, true)) {
|
||||
assertEquals(option.sensorRotation(90, front), option.sensorRotation(90, front, angle))
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun newCaptureUsesAutoByDefault() {
|
||||
val mode = StreamCaptureMode("camera", 1280, 720, 30, 30, false, "encoder", 2_000_000)
|
||||
assertEquals(StreamOrientation.AUTO, StreamCaptureConfig(mode).orientation)
|
||||
assertEquals(StreamOrientation.AUTO.degrees, StreamCaptureSettings().rotation)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user