summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorEino-Ville Talvala <etalvala@google.com>2011-10-18 13:33:25 -0700
committerEino-Ville Talvala <etalvala@google.com>2011-10-19 11:40:32 -0700
commit131cf9886c4f34431598be0b1f5b7aaa915277cc (patch)
treeda143de60c5decb4435e252952a3c1b6a97c620a /tests
parentd7a60abbee203872df4b5ab9a873e7efad80e239 (diff)
downloadLegacyCamera-131cf9886c4f34431598be0b1f5b7aaa915277cc.zip
LegacyCamera-131cf9886c4f34431598be0b1f5b7aaa915277cc.tar.gz
LegacyCamera-131cf9886c4f34431598be0b1f5b7aaa915277cc.tar.bz2
Add hysteresis to orientation rounding.
This prevents fast flickering between two orientation states, which can result in ugly UI issues, especially with the preview thumbnail. Bug: 5477483 Change-Id: I9513547207ae1918066c1a19947c974eaad72e24
Diffstat (limited to 'tests')
-rw-r--r--tests/src/com/android/camera/unittest/CameraTest.java54
1 files changed, 41 insertions, 13 deletions
diff --git a/tests/src/com/android/camera/unittest/CameraTest.java b/tests/src/com/android/camera/unittest/CameraTest.java
index b4bd632..ad0eed5 100644
--- a/tests/src/com/android/camera/unittest/CameraTest.java
+++ b/tests/src/com/android/camera/unittest/CameraTest.java
@@ -30,19 +30,47 @@ import junit.framework.TestCase;
@SmallTest
public class CameraTest extends TestCase {
public void testRoundOrientation() {
- assertEquals(0, Camera.roundOrientation(0));
- assertEquals(0, Camera.roundOrientation(0 + 44));
- assertEquals(90, Camera.roundOrientation(0 + 45));
- assertEquals(90, Camera.roundOrientation(90));
- assertEquals(90, Camera.roundOrientation(90 + 44));
- assertEquals(180, Camera.roundOrientation(90 + 45));
- assertEquals(180, Camera.roundOrientation(180));
- assertEquals(180, Camera.roundOrientation(180 + 44));
- assertEquals(270, Camera.roundOrientation(180 + 45));
- assertEquals(270, Camera.roundOrientation(270));
- assertEquals(270, Camera.roundOrientation(270 + 44));
- assertEquals(0, Camera.roundOrientation(270 + 45));
- assertEquals(0, Camera.roundOrientation(359));
+ int h = Util.ORIENTATION_HYSTERESIS;
+ assertEquals(0, Util.roundOrientation(0, 0));
+ assertEquals(0, Util.roundOrientation(359, 0));
+ assertEquals(0, Util.roundOrientation(0 + 44 + h, 0));
+ assertEquals(90, Util.roundOrientation(0 + 45 + h, 0));
+ assertEquals(0, Util.roundOrientation(360 - 44 - h, 0));
+ assertEquals(270, Util.roundOrientation(360 - 45 - h, 0));
+
+ assertEquals(90, Util.roundOrientation(90, 90));
+ assertEquals(90, Util.roundOrientation(90 + 44 + h, 90));
+ assertEquals(180, Util.roundOrientation(90 + 45 + h, 90));
+ assertEquals(90, Util.roundOrientation(90 - 44 - h, 90));
+ assertEquals(0, Util.roundOrientation(90 - 45 - h, 90));
+
+ assertEquals(180, Util.roundOrientation(180, 180));
+ assertEquals(180, Util.roundOrientation(180 + 44 + h, 180));
+ assertEquals(270, Util.roundOrientation(180 + 45 + h, 180));
+ assertEquals(180, Util.roundOrientation(180 - 44 - h, 180));
+ assertEquals(90, Util.roundOrientation(180 - 45 - h, 180));
+
+ assertEquals(270, Util.roundOrientation(270, 270));
+ assertEquals(270, Util.roundOrientation(270 + 44 + h, 270));
+ assertEquals(0, Util.roundOrientation(270 + 45 + h, 270));
+ assertEquals(270, Util.roundOrientation(270 - 44 - h, 270));
+ assertEquals(180, Util.roundOrientation(270 - 45 - h, 270));
+
+ assertEquals(90, Util.roundOrientation(90, 0));
+ assertEquals(180, Util.roundOrientation(180, 0));
+ assertEquals(270, Util.roundOrientation(270, 0));
+
+ assertEquals(0, Util.roundOrientation(0, 90));
+ assertEquals(180, Util.roundOrientation(180, 90));
+ assertEquals(270, Util.roundOrientation(270, 90));
+
+ assertEquals(0, Util.roundOrientation(0, 180));
+ assertEquals(90, Util.roundOrientation(90, 180));
+ assertEquals(270, Util.roundOrientation(270, 180));
+
+ assertEquals(0, Util.roundOrientation(0, 270));
+ assertEquals(90, Util.roundOrientation(90, 270));
+ assertEquals(180, Util.roundOrientation(180, 270));
}
public void testConvertToFocusArea() {