Search in sources :

Example 1 with Slice

use of androidx.slice.Slice in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class BluetoothSliceBuilderTest method getBluetoothSlice_correctSliceContent.

@Test
public void getBluetoothSlice_correctSliceContent() {
    final Slice BluetoothSlice = BluetoothSliceBuilder.getSlice(mContext);
    final SliceMetadata metadata = SliceMetadata.from(mContext, BluetoothSlice);
    assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.bluetooth_settings_title));
    final List<SliceAction> toggles = metadata.getToggles();
    assertThat(toggles).hasSize(1);
    final SliceAction primaryAction = metadata.getPrimaryAction();
    final IconCompat expectedToggleIcon = IconCompat.createWithResource(mContext, com.android.internal.R.drawable.ic_settings_bluetooth);
    assertThat(primaryAction.getIcon().toString()).isEqualTo(expectedToggleIcon.toString());
}
Also used : Slice(androidx.slice.Slice) IconCompat(androidx.core.graphics.drawable.IconCompat) SliceMetadata(androidx.slice.SliceMetadata) SliceAction(androidx.slice.core.SliceAction) Test(org.junit.Test)

Example 2 with Slice

use of androidx.slice.Slice in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ContextualCardFeatureProviderImplTest method logNotificationPackage_isNotContextualNotificationChannel_shouldNotLogPackage.

@Test
public void logNotificationPackage_isNotContextualNotificationChannel_shouldNotLogPackage() {
    final String packageName = "com.android.test.app";
    final Slice slice = buildSlice(FLASHLIGHT_SLICE_URI, packageName);
    mImpl.logNotificationPackage(slice);
    final Set<String> interactedPackages = mSharedPreferences.getStringSet(PREF_KEY_INTERACTED_PACKAGES, new ArraySet<>());
    assertThat(interactedPackages.contains(packageName)).isFalse();
}
Also used : Slice(androidx.slice.Slice) Test(org.junit.Test)

Example 3 with Slice

use of androidx.slice.Slice in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class EligibleCardCheckerTest method isCardEligibleToDisplay_errorSlice_returnFalse.

@Test
public void isCardEligibleToDisplay_errorSlice_returnFalse() {
    final Slice slice = new Slice.Builder(TEST_SLICE_URI).addHints(HINT_ERROR).build();
    doReturn(slice).when(mEligibleCardChecker).bindSlice(any(Uri.class));
    assertThat(mEligibleCardChecker.isCardEligibleToDisplay(getContextualCard(TEST_SLICE_URI))).isFalse();
}
Also used : Slice(androidx.slice.Slice) EmergencyInfoSlice(com.android.settings.homepage.contextualcards.deviceinfo.EmergencyInfoSlice) ContextualWifiSlice(com.android.settings.wifi.slice.ContextualWifiSlice) Uri(android.net.Uri) Test(org.junit.Test)

Example 4 with Slice

use of androidx.slice.Slice in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class EligibleCardCheckerTest method isSliceToggleable_cardWithToggle_returnTrue.

@Test
public void isSliceToggleable_cardWithToggle_returnTrue() {
    final ContextualWifiSlice wifiSlice = new ContextualWifiSlice(mContext);
    final Slice slice = wifiSlice.getSlice();
    assertThat(mEligibleCardChecker.isSliceToggleable(slice)).isTrue();
}
Also used : Slice(androidx.slice.Slice) EmergencyInfoSlice(com.android.settings.homepage.contextualcards.deviceinfo.EmergencyInfoSlice) ContextualWifiSlice(com.android.settings.wifi.slice.ContextualWifiSlice) ContextualWifiSlice(com.android.settings.wifi.slice.ContextualWifiSlice) Test(org.junit.Test)

Example 5 with Slice

use of androidx.slice.Slice in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class EligibleCardCheckerTest method isCardEligibleToDisplay_toggleSlice_hasInlineActionShouldBeTrue.

@Test
public void isCardEligibleToDisplay_toggleSlice_hasInlineActionShouldBeTrue() {
    final ContextualWifiSlice wifiSlice = new ContextualWifiSlice(mContext);
    final Slice slice = wifiSlice.getSlice();
    doReturn(slice).when(mEligibleCardChecker).bindSlice(any(Uri.class));
    mEligibleCardChecker.isCardEligibleToDisplay(getContextualCard(TEST_SLICE_URI));
    assertThat(mEligibleCardChecker.mCard.hasInlineAction()).isTrue();
}
Also used : Slice(androidx.slice.Slice) EmergencyInfoSlice(com.android.settings.homepage.contextualcards.deviceinfo.EmergencyInfoSlice) ContextualWifiSlice(com.android.settings.wifi.slice.ContextualWifiSlice) Uri(android.net.Uri) ContextualWifiSlice(com.android.settings.wifi.slice.ContextualWifiSlice) Test(org.junit.Test)

Aggregations

Slice (androidx.slice.Slice)114 Test (org.junit.Test)108 SliceMetadata (androidx.slice.SliceMetadata)44 SliceAction (androidx.slice.core.SliceAction)16 ParceledListSlice (android.content.pm.ParceledListSlice)14 Config (org.robolectric.annotation.Config)14 SliceItem (androidx.slice.SliceItem)13 IconCompat (androidx.core.graphics.drawable.IconCompat)10 Uri (android.net.Uri)8 EmergencyInfoSlice (com.android.settings.homepage.contextualcards.deviceinfo.EmergencyInfoSlice)5 ContextualWifiSlice (com.android.settings.wifi.slice.ContextualWifiSlice)5 PrivateStorageInfo (com.android.settingslib.deviceinfo.PrivateStorageInfo)5 VisibleForTesting (androidx.annotation.VisibleForTesting)2 BatteryTip (com.android.settings.fuelgauge.batterytip.tips.BatteryTip)2 EarlyWarningTip (com.android.settings.fuelgauge.batterytip.tips.EarlyWarningTip)2 LowBatteryTip (com.android.settings.fuelgauge.batterytip.tips.LowBatteryTip)2 AccessPoint (com.android.settingslib.wifi.AccessPoint)2 ArrayList (java.util.ArrayList)2 PendingIntent (android.app.PendingIntent)1 Intent (android.content.Intent)1