Add intent-filter to SearchResultTrampoline

Bug: 64938328
Test: atest
Change-Id: I3ac6506a6af3af9ff2bd60354ba23617b700ace8
This commit is contained in:
Fan Zhang
2017-11-09 16:37:01 -08:00
parent ff4da23a65
commit 8068fda059
3 changed files with 51 additions and 99 deletions

View File

@@ -223,6 +223,10 @@
android:theme="@android:style/Theme.NoDisplay" android:theme="@android:style/Theme.NoDisplay"
android:excludeFromRecents="true" android:excludeFromRecents="true"
android:exported="true"> android:exported="true">
<intent-filter>
<action android:name="com.android.settings.SEARCH_RESULT_TRAMPOLINE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity> </activity>
<!-- Top-level settings --> <!-- Top-level settings -->

View File

@@ -60,8 +60,9 @@ public class DatabaseIndexingUtils {
args.putString(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY, key); args.putString(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY, key);
final Intent searchDestination = Utils.onBuildStartFragmentIntent(context, final Intent searchDestination = Utils.onBuildStartFragmentIntent(context,
className, args, null, 0, screenTitle, false, sourceMetricsCategory); className, args, null, 0, screenTitle, false, sourceMetricsCategory);
searchDestination.putExtra(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY, key); searchDestination.putExtra(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY, key)
searchDestination.setClass(context, SearchResultTrampoline.class); .setAction("com.android.settings.SEARCH_RESULT_TRAMPOLINE")
.setComponent(null);
return searchDestination; return searchDestination;
} }

View File

@@ -17,105 +17,52 @@
package com.android.settings.search; package com.android.settings.search;
import static com.google.common.truth.Truth.assertThat;
import android.provider.SearchIndexablesContract; import android.provider.SearchIndexablesContract;
import android.test.AndroidTestCase; import android.support.test.filters.SmallTest;
import android.test.suitebuilder.annotation.SmallTest; import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
public class SearchIndexablesContractTest extends AndroidTestCase { import org.junit.runner.RunWith;
@SmallTest
public void testRawColumns_IncludesRank() {
assertEquals(SearchIndexablesContract.RawData.COLUMN_RANK,
SearchIndexablesContract.INDEXABLES_RAW_COLUMNS[0]);
}
@SmallTest @SmallTest
public void testRawColumns_IncludesTitle() { @RunWith(AndroidJUnit4.class)
assertEquals(SearchIndexablesContract.RawData.COLUMN_TITLE, public class SearchIndexablesContractTest {
SearchIndexablesContract.INDEXABLES_RAW_COLUMNS[1]);
}
@SmallTest @Test
public void testRawColumns_IncludesSummaryOn() { public void testRawColumns_matchContractIndexing() {
assertEquals(SearchIndexablesContract.RawData.COLUMN_SUMMARY_ON, assertThat(SearchIndexablesContract.RawData.COLUMN_RANK)
SearchIndexablesContract.INDEXABLES_RAW_COLUMNS[2]); .isEqualTo(SearchIndexablesContract.INDEXABLES_RAW_COLUMNS[0]);
} assertThat(SearchIndexablesContract.RawData.COLUMN_TITLE)
.isEqualTo(SearchIndexablesContract.INDEXABLES_RAW_COLUMNS[1]);
@SmallTest assertThat(SearchIndexablesContract.RawData.COLUMN_SUMMARY_ON)
public void testRawColumns_IncludesSummaryOff() { .isEqualTo(SearchIndexablesContract.INDEXABLES_RAW_COLUMNS[2]);
assertEquals(SearchIndexablesContract.RawData.COLUMN_SUMMARY_OFF, assertThat(SearchIndexablesContract.RawData.COLUMN_SUMMARY_OFF)
SearchIndexablesContract.INDEXABLES_RAW_COLUMNS[3]); .isEqualTo(SearchIndexablesContract.INDEXABLES_RAW_COLUMNS[3]);
} assertThat(SearchIndexablesContract.RawData.COLUMN_ENTRIES)
.isEqualTo(SearchIndexablesContract.INDEXABLES_RAW_COLUMNS[4]);
@SmallTest assertThat(SearchIndexablesContract.RawData.COLUMN_KEYWORDS)
public void testRawColumns_IncludesEntries() { .isEqualTo(SearchIndexablesContract.INDEXABLES_RAW_COLUMNS[5]);
assertEquals(SearchIndexablesContract.RawData.COLUMN_ENTRIES, assertThat(SearchIndexablesContract.RawData.COLUMN_SCREEN_TITLE)
SearchIndexablesContract.INDEXABLES_RAW_COLUMNS[4]); .isEqualTo(SearchIndexablesContract.INDEXABLES_RAW_COLUMNS[6]);
} assertThat(SearchIndexablesContract.RawData.COLUMN_CLASS_NAME)
.isEqualTo(SearchIndexablesContract.INDEXABLES_RAW_COLUMNS[7]);
@SmallTest assertThat(SearchIndexablesContract.RawData.COLUMN_ICON_RESID)
public void testRawColumns_IncludesKeywords() { .isEqualTo(SearchIndexablesContract.INDEXABLES_RAW_COLUMNS[8]);
assertEquals(SearchIndexablesContract.RawData.COLUMN_KEYWORDS, assertThat(SearchIndexablesContract.RawData.COLUMN_INTENT_ACTION)
SearchIndexablesContract.INDEXABLES_RAW_COLUMNS[5]); .isEqualTo(SearchIndexablesContract.INDEXABLES_RAW_COLUMNS[9]);
} assertThat(SearchIndexablesContract.RawData.COLUMN_INTENT_TARGET_PACKAGE)
.isEqualTo(SearchIndexablesContract.INDEXABLES_RAW_COLUMNS[10]);
@SmallTest assertThat(SearchIndexablesContract.RawData.COLUMN_INTENT_TARGET_CLASS)
public void testRawColumns_IncludesScreenTitle() { .isEqualTo(SearchIndexablesContract.INDEXABLES_RAW_COLUMNS[11]);
assertEquals(SearchIndexablesContract.RawData.COLUMN_SCREEN_TITLE, assertThat(SearchIndexablesContract.RawData.COLUMN_KEY)
SearchIndexablesContract.INDEXABLES_RAW_COLUMNS[6]); .isEqualTo(SearchIndexablesContract.INDEXABLES_RAW_COLUMNS[12]);
} assertThat(SearchIndexablesContract.RawData.COLUMN_USER_ID)
.isEqualTo(SearchIndexablesContract.INDEXABLES_RAW_COLUMNS[13]);
@SmallTest assertThat(SearchIndexablesContract.RawData.PAYLOAD_TYPE)
public void testRawColumns_IncludesClassName() { .isEqualTo(SearchIndexablesContract.INDEXABLES_RAW_COLUMNS[14]);
assertEquals(SearchIndexablesContract.RawData.COLUMN_CLASS_NAME, assertThat(SearchIndexablesContract.RawData.PAYLOAD)
SearchIndexablesContract.INDEXABLES_RAW_COLUMNS[7]); .isEqualTo(SearchIndexablesContract.INDEXABLES_RAW_COLUMNS[15]);
}
@SmallTest
public void testRawColumns_IncludesIcon() {
assertEquals(SearchIndexablesContract.RawData.COLUMN_ICON_RESID,
SearchIndexablesContract.INDEXABLES_RAW_COLUMNS[8]);
}
@SmallTest
public void testRawColumns_IncludesIntentAction() {
assertEquals(SearchIndexablesContract.RawData.COLUMN_INTENT_ACTION,
SearchIndexablesContract.INDEXABLES_RAW_COLUMNS[9]);
}
@SmallTest
public void testRawColumns_IncludesIntentTargetPackage() {
assertEquals(SearchIndexablesContract.RawData.COLUMN_INTENT_TARGET_PACKAGE,
SearchIndexablesContract.INDEXABLES_RAW_COLUMNS[10]);
}
@SmallTest
public void testRawColumns_IncludesTargetClass() {
assertEquals(SearchIndexablesContract.RawData.COLUMN_INTENT_TARGET_CLASS,
SearchIndexablesContract.INDEXABLES_RAW_COLUMNS[11]);
}
@SmallTest
public void testRawColumns_IncludesKey() {
assertEquals(SearchIndexablesContract.RawData.COLUMN_KEY,
SearchIndexablesContract.INDEXABLES_RAW_COLUMNS[12]);
}
@SmallTest
public void testRawColumns_IncludesUserId() {
assertEquals(SearchIndexablesContract.RawData.COLUMN_USER_ID,
SearchIndexablesContract.INDEXABLES_RAW_COLUMNS[13]);
}
@SmallTest
public void testRawColumns_IncludesPayloadType() {
assertEquals(SearchIndexablesContract.RawData.PAYLOAD_TYPE,
SearchIndexablesContract.INDEXABLES_RAW_COLUMNS[14]);
}
@SmallTest
public void testRawColumns_IncludesPayload() {
assertEquals(SearchIndexablesContract.RawData.PAYLOAD,
SearchIndexablesContract.INDEXABLES_RAW_COLUMNS[15]);
} }
} }