Using collator for string matching

This provides a better matching for non-latin characters on N and above

Bug: 63763127
Change-Id: I220487d242ff547311ddd13e7af380a7e47eec0e
This commit is contained in:
Sunny Goyal
2017-07-18 01:22:01 -07:00
parent 751ea1c10e
commit 05d2df1678
2 changed files with 73 additions and 4 deletions
@@ -19,6 +19,7 @@ import android.content.ComponentName;
import android.test.InstrumentationTestCase;
import com.android.launcher3.AppInfo;
import com.android.launcher3.Utilities;
import java.util.ArrayList;
import java.util.List;
@@ -75,6 +76,25 @@ public class DefaultAppSearchAlgorithmTest extends InstrumentationTestCase {
assertTrue(mAlgorithm.matches(getInfo("电子邮件"), "电子"));
assertFalse(mAlgorithm.matches(getInfo("电子邮件"), ""));
assertFalse(mAlgorithm.matches(getInfo("电子邮件"), "邮件"));
assertFalse(mAlgorithm.matches(getInfo("Bot"), "ba"));
assertFalse(mAlgorithm.matches(getInfo("bot"), "ba"));
}
public void testMatchesVN() {
if (!Utilities.ATLEAST_NOUGAT) {
return;
}
assertTrue(mAlgorithm.matches(getInfo("다운로드"), ""));
assertTrue(mAlgorithm.matches(getInfo("드라이브"), ""));
assertTrue(mAlgorithm.matches(getInfo("다운로드 드라이브"), ""));
assertTrue(mAlgorithm.matches(getInfo("운로 드라이브"), ""));
assertTrue(mAlgorithm.matches(getInfo("abc"), "åbç"));
assertTrue(mAlgorithm.matches(getInfo("Alpha"), "ål"));
assertFalse(mAlgorithm.matches(getInfo("다운로드 드라이브"), "ㄷㄷ"));
assertFalse(mAlgorithm.matches(getInfo("로드라이브"), ""));
assertFalse(mAlgorithm.matches(getInfo("abc"), "åç"));
}
private AppInfo getInfo(String title) {