mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-03 17:36:49 +00:00
Add a WidgetsSearchBar(Launcher3) and a WidgetsSearchController.
- Make WidgetsSearchBar in Launcher3 initialize WidgetsSearchController with SimpleWidgetsSearchPipeline - Modify SimpleWidgetsSearchPipeline to filter widgets entries on widgets/shortcut labels also. Test: Tested prototype locally. Also added robolectric test. Bug: b/157286785 Change-Id: I65f5fa0240ffb6d22023167e4e86d94d83bbd9f7
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.android.launcher3.search;
|
||||
|
||||
import static com.android.launcher3.search.StringMatcherUtility.matches;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.android.launcher3.search.StringMatcherUtility.StringMatcher;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link StringMatcherUtility}
|
||||
*/
|
||||
@SmallTest
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class StringMatcherUtilityTest {
|
||||
private static final StringMatcher MATCHER =
|
||||
StringMatcher.getInstance();
|
||||
|
||||
@Test
|
||||
public void testMatches() {
|
||||
assertTrue(matches("white ", "white cow", MATCHER));
|
||||
assertTrue(matches("white c", "white cow", MATCHER));
|
||||
assertTrue(matches("cow", "white cow", MATCHER));
|
||||
assertTrue(matches("cow", "whiteCow", MATCHER));
|
||||
assertTrue(matches("cow", "whiteCOW", MATCHER));
|
||||
assertTrue(matches("cow", "whitecowCOW", MATCHER));
|
||||
assertTrue(matches("cow", "white2cow", MATCHER));
|
||||
|
||||
assertFalse(matches("cow", "whitecow", MATCHER));
|
||||
assertFalse(matches("cow", "whitEcow", MATCHER));
|
||||
|
||||
assertTrue(matches("cow", "whitecowCow", MATCHER));
|
||||
assertTrue(matches("cow", "whitecow cow", MATCHER));
|
||||
assertFalse(matches("cow", "whitecowcow", MATCHER));
|
||||
assertFalse(matches("cow", "whit ecowcow", MATCHER));
|
||||
|
||||
assertTrue(matches("dog", "cats&dogs", MATCHER));
|
||||
assertTrue(matches("dog", "cats&Dogs", MATCHER));
|
||||
assertTrue(matches("&", "cats&Dogs", MATCHER));
|
||||
|
||||
assertTrue(matches("43", "2+43", MATCHER));
|
||||
assertFalse(matches("3", "2+43", MATCHER));
|
||||
|
||||
assertTrue(matches("q", "Q", MATCHER));
|
||||
assertTrue(matches("q", " Q", MATCHER));
|
||||
|
||||
// match lower case words
|
||||
assertTrue(matches("e", "elephant", MATCHER));
|
||||
assertTrue(matches("eL", "Elephant", MATCHER));
|
||||
|
||||
assertTrue(matches("电", "电子邮件", MATCHER));
|
||||
assertTrue(matches("电子", "电子邮件", MATCHER));
|
||||
assertTrue(matches("子", "电子邮件", MATCHER));
|
||||
assertTrue(matches("邮件", "电子邮件", MATCHER));
|
||||
|
||||
assertFalse(matches("ba", "Bot", MATCHER));
|
||||
assertFalse(matches("ba", "bot", MATCHER));
|
||||
assertFalse(matches("phant", "elephant", MATCHER));
|
||||
assertFalse(matches("elephants", "elephant", MATCHER));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMatchesVN() {
|
||||
assertTrue(matches("다", "다운로드", MATCHER));
|
||||
assertTrue(matches("드", "드라이브", MATCHER));
|
||||
assertTrue(matches("ㄷ", "다운로드 드라이브", MATCHER));
|
||||
assertTrue(matches("ㄷ", "운로 드라이브", MATCHER));
|
||||
assertTrue(matches("åbç", "abc", MATCHER));
|
||||
assertTrue(matches("ål", "Alpha", MATCHER));
|
||||
|
||||
assertFalse(matches("ㄷㄷ", "다운로드 드라이브", MATCHER));
|
||||
assertFalse(matches("ㄷ", "로드라이브", MATCHER));
|
||||
assertFalse(matches("åç", "abc", MATCHER));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user