summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTony Wickham <twickham@google.com>2015-11-06 17:08:57 -0800
committerTony Wickham <twickham@google.com>2015-11-06 17:08:57 -0800
commit3cfa97d4c14fa4af3ee3613e44ba7b7128141e31 (patch)
treed5d14c6152793c6fd8a88f38632c13f886ced4fa /tests
parent0e2f3849b84f59ed7c1c4336ca01ac17f096e265 (diff)
downloadandroid_packages_apps_Trebuchet-3cfa97d4c14fa4af3ee3613e44ba7b7128141e31.tar.gz
android_packages_apps_Trebuchet-3cfa97d4c14fa4af3ee3613e44ba7b7128141e31.tar.bz2
android_packages_apps_Trebuchet-3cfa97d4c14fa4af3ee3613e44ba7b7128141e31.zip
Added unit tests for b/25434120 regression.
Change-Id: I55b10274c4bb63ec6fd3138236e78a04e3eac91a
Diffstat (limited to 'tests')
-rw-r--r--tests/src/com/android/launcher3/util/FocusLogicTest.java35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/src/com/android/launcher3/util/FocusLogicTest.java b/tests/src/com/android/launcher3/util/FocusLogicTest.java
index ea87014e9..2c2f0d3df 100644
--- a/tests/src/com/android/launcher3/util/FocusLogicTest.java
+++ b/tests/src/com/android/launcher3/util/FocusLogicTest.java
@@ -57,4 +57,39 @@ public final class FocusLogicTest extends AndroidTestCase {
// may get created in real world to test this method. OR 2) Move all the matrix
// management routine to celllayout and write tests for them.
}
+
+ public void testMoveFromBottomRightToBottomLeft() {
+ int[][] map = transpose(new int[][] {
+ {-1, 0, -1, -1, -1, -1},
+ {-1, -1, -1, -1, -1, -1},
+ {-1, -1, -1, -1, -1, -1},
+ {-1, -1, -1, -1, -1, -1},
+ {100, 1, -1, -1, -1, -1},
+ });
+ int i = FocusLogic.handleKeyEvent(KeyEvent.KEYCODE_DPAD_RIGHT, 6, 5, map, 100, 1, 2, false);
+ assertEquals(1, i);
+ }
+
+ public void testMoveFromBottomRightToTopLeft() {
+ int[][] map = transpose(new int[][] {
+ {-1, 0, -1, -1, -1, -1},
+ {-1, -1, -1, -1, -1, -1},
+ {-1, -1, -1, -1, -1, -1},
+ {-1, -1, -1, -1, -1, -1},
+ {100, -1, -1, -1, -1, -1},
+ });
+ int i = FocusLogic.handleKeyEvent(KeyEvent.KEYCODE_DPAD_RIGHT, 6, 5, map, 100, 1, 2, false);
+ assertEquals(0, i);
+ }
+
+ /** Transposes the matrix so that we can write it in human-readable format in the tests. */
+ private int[][] transpose(int[][] m) {
+ int[][] t = new int[m[0].length][m.length];
+ for (int i = 0; i < m.length; i++) {
+ for (int j = 0; j < m[0].length; j++) {
+ t[j][i] = m[i][j];
+ }
+ }
+ return t;
+ }
}