Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 264ae202 authored by yuemingw's avatar yuemingw Committed by Yueming Wang
Browse files

Change cross profile calendar API used in robolectric test.

The API changed from addCrossProfileCalendarPackage to
setCrossProfileCalendarPackages recently due to our decision
in b/121179845. Also added test for the case when
the whitelist is set to null.

Bug: 121179845
Test: make ROBOTEST_FILTER=CrossProfileCalendarPreferenceControllerTest -j40 RunSettingsRoboTests
Change-Id: I66b92aba6d26334e48207275b2d8981203598e15
parent d3c02d87
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.content.ComponentName;
import android.content.Context;
import android.os.UserHandle;
import android.provider.Settings;
import android.util.ArraySet;

import com.android.settingslib.RestrictedSwitchPreference;

@@ -45,6 +46,9 @@ import org.robolectric.RuntimeEnvironment;
import org.robolectric.Shadows;
import org.robolectric.shadows.ShadowDevicePolicyManager;

import java.util.Arrays;
import java.util.Collections;

@RunWith(RobolectricTestRunner.class)
public class CrossProfileCalendarPreferenceControllerTest {

@@ -123,7 +127,17 @@ public class CrossProfileCalendarPreferenceControllerTest {
    @Test
    public void updateState_somePackagesAllowed_preferenceShouldNotBeDisabled() throws Exception {
        dpm.setProfileOwner(TEST_COMPONENT_NAME);
        dpm.addCrossProfileCalendarPackage(TEST_COMPONENT_NAME, TEST_PACKAGE_NAME);
        dpm.setCrossProfileCalendarPackages(TEST_COMPONENT_NAME,
                Collections.singleton(TEST_PACKAGE_NAME));

        mController.updateState(mPreference);
        verify(mPreference).setDisabledByAdmin(null);
    }

    @Test
    public void updateState_allPackagesAllowed_preferenceShouldNotBeDisabled() throws Exception {
        dpm.setProfileOwner(TEST_COMPONENT_NAME);
        dpm.setCrossProfileCalendarPackages(TEST_COMPONENT_NAME, null);

        mController.updateState(mPreference);
        verify(mPreference).setDisabledByAdmin(null);