Search in sources :

Example 31 with Tile

use of com.android.settingslib.drawer.Tile in project android_packages_apps_Settings by LineageOS.

the class SuggestionAdapterTest method makeSuggestions.

private List<Tile> makeSuggestions(String... pkgNames) {
    final List<Tile> suggestions = new ArrayList<>();
    for (String pkgName : pkgNames) {
        Tile suggestion = new Tile();
        suggestion.intent = new Intent("action");
        suggestion.intent.setComponent(new ComponentName(pkgName, "cls"));
        suggestions.add(suggestion);
        suggestion.icon = mock(Icon.class);
    }
    return suggestions;
}
Also used : ArrayList(java.util.ArrayList) Tile(com.android.settingslib.drawer.Tile) Intent(android.content.Intent) ComponentName(android.content.ComponentName) Icon(android.graphics.drawable.Icon)

Example 32 with Tile

use of com.android.settingslib.drawer.Tile in project android_packages_apps_Settings by LineageOS.

the class SuggestionAdapterTest method onBindViewHolder_viewsShouldClearOnRebind.

@Test
public void onBindViewHolder_viewsShouldClearOnRebind() {
    Context context = new ContextThemeWrapper(RuntimeEnvironment.application, R.style.Theme_Settings);
    List<Tile> packages = makeSuggestions("pkg1");
    RemoteViews remoteViews = mock(RemoteViews.class);
    FrameLayout layout = new FrameLayout(context);
    Button primary = new Button(context);
    primary.setId(android.R.id.primary);
    layout.addView(primary);
    doReturn(layout).when(remoteViews).apply(any(Context.class), any(ViewGroup.class));
    packages.get(0).remoteViews = remoteViews;
    setupSuggestions(mActivity, packages);
    mSuggestionAdapter.onBindViewHolder(mSuggestionHolder, 0);
    mSuggestionAdapter.onBindViewHolder(mSuggestionHolder, 0);
    ViewGroup itemView = (ViewGroup) mSuggestionHolder.itemView;
    assertThat(itemView.getChildCount()).isEqualTo(1);
}
Also used : Context(android.content.Context) RemoteViews(android.widget.RemoteViews) ContextThemeWrapper(android.view.ContextThemeWrapper) Button(android.widget.Button) ViewGroup(android.view.ViewGroup) FrameLayout(android.widget.FrameLayout) Tile(com.android.settingslib.drawer.Tile) Test(org.junit.Test)

Example 33 with Tile

use of com.android.settingslib.drawer.Tile in project android_packages_apps_Settings by LineageOS.

the class SuggestionFeatureProviderImplTest method getSuggestionIdentifier_nullContext_shouldNotCrash.

@Test
public void getSuggestionIdentifier_nullContext_shouldNotCrash() {
    final Tile suggestion = new Tile();
    suggestion.intent = new Intent().setClassName(RuntimeEnvironment.application.getPackageName(), "123");
    assertThat(mProvider.getSuggestionIdentifier(null, suggestion)).isNotEmpty();
}
Also used : Tile(com.android.settingslib.drawer.Tile) Intent(android.content.Intent) Test(org.junit.Test)

Example 34 with Tile

use of com.android.settingslib.drawer.Tile in project android_packages_apps_Settings by LineageOS.

the class SuggestionFeatureProviderImplTest method getSuggestionIdentifier_samePackage_returnClassName.

@Test
public void getSuggestionIdentifier_samePackage_returnClassName() {
    final Tile suggestion = new Tile();
    suggestion.intent = new Intent().setClassName(RuntimeEnvironment.application.getPackageName(), "123");
    assertThat(mProvider.getSuggestionIdentifier(RuntimeEnvironment.application, suggestion)).isEqualTo("123");
}
Also used : Tile(com.android.settingslib.drawer.Tile) Intent(android.content.Intent) Test(org.junit.Test)

Example 35 with Tile

use of com.android.settingslib.drawer.Tile in project android_packages_apps_Settings by LineageOS.

the class SuggestionsChecksTest method testFingerprintEnrollmentIntroductionIsCompleteWhenFingerprintNotSupported.

@Test
public void testFingerprintEnrollmentIntroductionIsCompleteWhenFingerprintNotSupported() {
    stubFingerprintSupported(false);
    Tile tile = createFingerprintTile();
    assertThat(mSuggestionsChecks.isSuggestionComplete(tile)).isTrue();
}
Also used : Tile(com.android.settingslib.drawer.Tile) Test(org.junit.Test)

Aggregations

Tile (com.android.settingslib.drawer.Tile)466 Test (org.junit.Test)309 Intent (android.content.Intent)158 Bundle (android.os.Bundle)117 Preference (android.support.v7.preference.Preference)108 DashboardCategory (com.android.settingslib.drawer.DashboardCategory)102 ComponentName (android.content.ComponentName)98 ArrayList (java.util.ArrayList)79 Context (android.content.Context)71 UserHandle (android.os.UserHandle)32 Activity (android.app.Activity)31 RecyclerView (android.support.v7.widget.RecyclerView)31 View (android.view.View)31 Icon (android.graphics.drawable.Icon)30 VisibleForTesting (android.support.annotation.VisibleForTesting)30 PackageManager (android.content.pm.PackageManager)25 TypedArray (android.content.res.TypedArray)24 ViewGroup (android.view.ViewGroup)24 RemoteViews (android.widget.RemoteViews)24 SettingsActivity (com.android.settings.SettingsActivity)24