summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorYorke Lee <yorkelee@google.com>2012-12-05 11:48:58 -0800
committerYorke Lee <yorkelee@google.com>2013-02-04 15:00:39 -0800
commit697fa0977ea1d4569064c434bb86e9b9fbfc4b12 (patch)
tree3a9c37cf11033fdff4bffa504f91b5216773b15b /tests
parent81e0da49ca93081c3ef60d634755f39931c88c94 (diff)
downloadandroid_packages_apps_Dialer-697fa0977ea1d4569064c434bb86e9b9fbfc4b12.tar.gz
android_packages_apps_Dialer-697fa0977ea1d4569064c434bb86e9b9fbfc4b12.tar.bz2
android_packages_apps_Dialer-697fa0977ea1d4569064c434bb86e9b9fbfc4b12.zip
Enable initial matching for Smart Dialling
Allow the name matcher function used by smart dialling to perform initial matches of the variety 57 - (J)ohn (S)mith Refactor SmartDialNameMatcher testing method to allow checking multiple match positions. Add tests for initial matches Change-Id: Iadc5e3e8b2f408136c704015d2297e9b520e1065
Diffstat (limited to 'tests')
-rw-r--r--tests/src/com/android/dialer/dialpad/SmartDialNameMatcherTest.java25
1 files changed, 22 insertions, 3 deletions
diff --git a/tests/src/com/android/dialer/dialpad/SmartDialNameMatcherTest.java b/tests/src/com/android/dialer/dialpad/SmartDialNameMatcherTest.java
index 492e5b422..8b7ee03f6 100644
--- a/tests/src/com/android/dialer/dialpad/SmartDialNameMatcherTest.java
+++ b/tests/src/com/android/dialer/dialpad/SmartDialNameMatcherTest.java
@@ -66,6 +66,20 @@ public class SmartDialNameMatcherTest extends TestCase {
checkMatches("William J Smith", "6576", false, 0, 0);
}
+
+ public void testMatches_Initial() {
+ // wjs matches (W)illiam (J)ohn (S)mith
+ checkMatches("William John Smith", "957", true, 0, 1, 8, 9, 13, 14);
+ // wjsmit matches (W)illiam (J)ohn (Smit)h
+ checkMatches("William John Smith", "957648", true, 0, 1, 8, 9, 13, 17);
+ // wjohn matches (W)illiam (John) Smith
+ checkMatches("William John Smith", "95646", true, 0, 1, 8, 12);
+ // jsmi matches William (J)ohn (Smi)th
+ checkMatches("William John Smith", "5764", true, 8, 9, 13, 16);
+ // make sure multiple spaces don't mess things up
+ checkMatches("William John Smith", "5764", true, 15, 16, 22, 25);
+ }
+
// TODO: Do we want to make these pass anymore?
@Suppress
public void testMatches_repeatedSeparators() {
@@ -102,7 +116,7 @@ public class SmartDialNameMatcherTest extends TestCase {
}
private void checkMatches(String displayName, String query, boolean expectedMatches,
- int expectedMatchStart, int expectedMatchEnd) {
+ int... expectedMatchPositions) {
final SmartDialNameMatcher matcher = new SmartDialNameMatcher(query);
final ArrayList<SmartDialMatchPosition> matchPositions =
new ArrayList<SmartDialMatchPosition>();
@@ -115,9 +129,14 @@ public class SmartDialNameMatcherTest extends TestCase {
+ " nfkc=" + Normalizer.normalize(displayName, Normalizer.Form.NFKC)
+ " matches=" + matches);
assertEquals("matches", expectedMatches, matches);
+ final int length = expectedMatchPositions.length;
+ assertEquals(length % 2, 0);
if (matches) {
- assertEquals("start", expectedMatchStart, matchPositions.get(0).start);
- assertEquals("end", expectedMatchEnd, matchPositions.get(0).end);
+ for (int i = 0; i < length/2; i++) {
+ assertEquals("start", expectedMatchPositions[i * 2], matchPositions.get(i).start);
+ assertEquals("end", expectedMatchPositions[i * 2 + 1], matchPositions.get(i).end);
+ }
}
}
+
}