Merge changes I8ce427ea,If33c3d3a,I579be569,I755c04da
* changes: move search test package to sdk 26 Update accessibilityserviceresult test to sdk 26 Update IntentSearchViewHolderTest to sdk 26 fix DatabaseIndexingManagerTest hanging in tests
This commit is contained in:
committed by
Android (Google) Code Review
commit
61691b5a4f
@@ -293,7 +293,8 @@ public class IndexDatabaseHelper extends SQLiteOpenHelper {
|
||||
}
|
||||
|
||||
static void setBuildIndexed(Context context, String buildNo) {
|
||||
context.getSharedPreferences(SHARED_PREFS_TAG, 0).edit().putBoolean(buildNo, true).commit();
|
||||
// Use #apply() instead of #commit() since #commit() Robolectric loop indefinitely in sdk 26
|
||||
context.getSharedPreferences(SHARED_PREFS_TAG, 0).edit().putBoolean(buildNo, true).apply();
|
||||
}
|
||||
|
||||
private void dropTables(SQLiteDatabase db) {
|
||||
|
@@ -17,6 +17,7 @@
|
||||
package com.android.settings.search;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.UserHandle;
|
||||
@@ -26,6 +27,7 @@ import android.util.IconDrawableFactory;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
|
||||
@@ -84,8 +86,7 @@ public abstract class SearchViewHolder extends RecyclerView.ViewHolder {
|
||||
AppSearchResult appResult = (AppSearchResult) result;
|
||||
PackageManager pm = fragment.getActivity().getPackageManager();
|
||||
UserHandle userHandle = appResult.getAppUserHandle();
|
||||
Drawable badgedIcon =
|
||||
mIconDrawableFactory.getBadgedIcon(appResult.info, userHandle.getIdentifier());
|
||||
Drawable badgedIcon = getBadgedIcon(appResult.info, userHandle.getIdentifier());
|
||||
iconView.setImageDrawable(badgedIcon);
|
||||
titleView.setContentDescription(
|
||||
pm.getUserBadgedLabel(appResult.info.loadLabel(pm), userHandle));
|
||||
@@ -112,4 +113,9 @@ public abstract class SearchViewHolder extends RecyclerView.ViewHolder {
|
||||
breadcrumbView.setText(breadcrumb);
|
||||
breadcrumbView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
Drawable getBadgedIcon(ApplicationInfo info, int userId) {
|
||||
return mIconDrawableFactory.getBadgedIcon(info, userId);
|
||||
}
|
||||
}
|
@@ -28,6 +28,7 @@ import android.content.pm.ResolveInfo;
|
||||
import android.content.pm.ServiceInfo;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.UserManager;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
|
||||
import com.android.settings.TestConfig;
|
||||
@@ -46,7 +47,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
|
||||
public class AccessibilityServiceResultFutureTaskTest {
|
||||
|
||||
private static final String QUERY = "test_query";
|
||||
@@ -59,6 +60,8 @@ public class AccessibilityServiceResultFutureTaskTest {
|
||||
private AccessibilityManager mAccessibilityManager;
|
||||
@Mock
|
||||
private SiteMapManager mSiteMapManager;
|
||||
@Mock
|
||||
private UserManager mUserManager;
|
||||
|
||||
private AccessibilityServiceResultLoader.AccessibilityServiceResultCallable mCallable;
|
||||
|
||||
@@ -67,6 +70,7 @@ public class AccessibilityServiceResultFutureTaskTest {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
when(mContext.getSystemService(Context.ACCESSIBILITY_SERVICE))
|
||||
.thenReturn(mAccessibilityManager);
|
||||
when((Object)mContext.getSystemService(UserManager.class)).thenReturn(mUserManager);
|
||||
when(mContext.getPackageManager()).thenReturn(mPackageManager);
|
||||
|
||||
mCallable = new AccessibilityServiceResultLoader.AccessibilityServiceResultCallable(
|
||||
|
@@ -45,7 +45,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
|
||||
public class BaseSearchIndexProviderTest {
|
||||
|
||||
private static final String TEST_PREF_KEY = "test_pref_key";
|
||||
|
@@ -52,7 +52,7 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
|
||||
public class CursorToSearchResultConverterTest {
|
||||
|
||||
private static final List<String> TITLES = Arrays.asList("title1", "title2", "title3");
|
||||
|
@@ -70,7 +70,7 @@ import java.util.Set;
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(
|
||||
manifest = TestConfig.MANIFEST_PATH,
|
||||
sdk = TestConfig.SDK_VERSION,
|
||||
sdk = TestConfig.SDK_VERSION_O,
|
||||
shadows = {
|
||||
ShadowRunnableAsyncTask.class,
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ import org.robolectric.annotation.Config;
|
||||
import java.util.Map;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
|
||||
public class DatabaseIndexingUtilsTest {
|
||||
|
||||
private Context mContext;
|
||||
|
@@ -14,7 +14,7 @@ import org.robolectric.annotation.Config;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
|
||||
public class InlineListPayloadTest {
|
||||
|
||||
private static final String DUMMY_SETTING = "inline_list_key";
|
||||
|
@@ -17,7 +17,7 @@ import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
|
||||
public class InlinePayloadTest {
|
||||
|
||||
private Context mContext;
|
||||
|
@@ -37,7 +37,7 @@ import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
|
||||
public class InlineSwitchPayloadTest {
|
||||
|
||||
private static final String DUMMY_SETTING = "inline_test";
|
||||
|
@@ -43,7 +43,7 @@ import org.robolectric.util.ReflectionHelpers;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
|
||||
public class InlineSwitchViewHolderTest {
|
||||
|
||||
private static final String TITLE = "title";
|
||||
|
@@ -56,7 +56,7 @@ import java.util.List;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH,
|
||||
sdk = TestConfig.SDK_VERSION,
|
||||
sdk = TestConfig.SDK_VERSION_O,
|
||||
shadows = {
|
||||
ShadowInputDevice.class
|
||||
})
|
||||
|
@@ -65,7 +65,7 @@ import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
|
||||
public class InstalledAppResultLoaderTest {
|
||||
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
|
@@ -18,6 +18,8 @@
|
||||
package com.android.settings.search;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
@@ -32,8 +34,10 @@ import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
||||
@@ -58,7 +62,7 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
|
||||
public class IntentSearchViewHolderTest {
|
||||
|
||||
private static final String TITLE = "title";
|
||||
@@ -72,6 +76,8 @@ public class IntentSearchViewHolderTest {
|
||||
private SearchFragment mFragment;
|
||||
@Mock
|
||||
private PackageManager mPackageManager;
|
||||
@Mock
|
||||
private UserManager mUserManager;
|
||||
private FakeFeatureFactory mFeatureFactory;
|
||||
private IntentSearchViewHolder mHolder;
|
||||
private Drawable mIcon;
|
||||
@@ -189,6 +195,9 @@ public class IntentSearchViewHolderTest {
|
||||
|
||||
@Test
|
||||
public void testBindViewElements_appSearchResult() {
|
||||
mHolder = spy(mHolder);
|
||||
doReturn(new ColorDrawable(0)).when(mHolder).getBadgedIcon(any(ApplicationInfo.class),
|
||||
anyInt());
|
||||
when(mPackageManager.getUserBadgedLabel(any(CharSequence.class),
|
||||
eq(new UserHandle(USER_ID)))).thenReturn(BADGED_LABEL);
|
||||
|
||||
|
@@ -30,7 +30,7 @@ import org.robolectric.annotation.Config;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
|
||||
public class ResultPayloadTest {
|
||||
private ResultPayload mPayload;
|
||||
|
||||
|
@@ -30,7 +30,7 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import static junit.framework.Assert.fail;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
|
||||
public class ResultPayloadUtilsTest {
|
||||
private ResultPayload payload;
|
||||
|
||||
|
@@ -38,7 +38,7 @@ import java.util.List;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
|
||||
public class SavedQueryLoaderTest {
|
||||
|
||||
private Context mContext;
|
||||
|
@@ -28,7 +28,7 @@ import org.robolectric.annotation.Config;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
|
||||
public class SavedQueryPayloadTest {
|
||||
|
||||
private SavedQueryPayload mPayload;
|
||||
|
@@ -36,7 +36,7 @@ import org.robolectric.annotation.Config;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
|
||||
public class SavedQueryRecorderAndRemoverTest {
|
||||
|
||||
private Context mContext;
|
||||
|
@@ -38,7 +38,7 @@ import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
|
||||
public class SavedQueryViewHolderTest {
|
||||
|
||||
@Mock
|
||||
|
@@ -68,7 +68,7 @@ import java.util.List;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH,
|
||||
sdk = TestConfig.SDK_VERSION,
|
||||
sdk = TestConfig.SDK_VERSION_O,
|
||||
shadows = {
|
||||
SettingsShadowResources.class,
|
||||
SettingsShadowResources.SettingsShadowTheme.class,
|
||||
|
@@ -40,7 +40,7 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
|
||||
public class SearchIndexableResourcesTest {
|
||||
|
||||
Set<Class> sProviderClassCopy;
|
||||
|
@@ -31,7 +31,7 @@ import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
|
||||
public class SearchResultAggregatorTest {
|
||||
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
|
@@ -37,7 +37,7 @@ import org.robolectric.shadows.ShadowApplication;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
|
||||
public class SearchResultBuilderTest {
|
||||
|
||||
private static final String TITLE = "title";
|
||||
|
@@ -46,7 +46,7 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
|
||||
public class SearchResultsAdapterTest {
|
||||
|
||||
@Mock
|
||||
|
@@ -27,7 +27,7 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
|
||||
public class SettingsSearchIndexablesProviderTest {
|
||||
|
||||
private final String BASE_AUTHORITY = "com.android.settings";
|
||||
|
@@ -63,7 +63,7 @@ import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
|
||||
public class StaticSearchResultFutureTaskTest {
|
||||
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
|
@@ -43,7 +43,7 @@ import org.xmlpull.v1.XmlPullParser;
|
||||
* with another preference with a matchin replacement attribute.
|
||||
*/
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
|
||||
public class XmlParserUtilTest {
|
||||
|
||||
private Context mContext;
|
||||
|
@@ -46,7 +46,7 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Mockito.spy;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION, qualifiers = "mcc999")
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O, qualifiers = "mcc999")
|
||||
public class IndexDataConverterTest {
|
||||
|
||||
private final String localeStr = "en_US";
|
||||
|
@@ -36,7 +36,7 @@ import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
|
||||
public class IndexDataTest {
|
||||
private IndexData.Builder mBuilder;
|
||||
|
||||
|
@@ -46,7 +46,7 @@ import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.spy;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION_O)
|
||||
public class PreIndexDataCollectorTest {
|
||||
|
||||
private final String AUTHORITY_ONE = "authority";
|
||||
|
Reference in New Issue
Block a user