Loading src/com/android/settings/applications/appinfo/DefaultAppShortcutPreferenceControllerBase.java +6 −2 Original line number Diff line number Diff line Loading @@ -14,7 +14,9 @@ package com.android.settings.applications.appinfo; import android.app.role.RoleControllerManager; import android.app.role.RoleManager; import android.app.settings.SettingsEnums; import android.content.Context; import android.content.Intent; import android.os.UserManager; Loading Loading @@ -56,12 +58,14 @@ public abstract class DefaultAppShortcutPreferenceControllerBase extends BasePre mRoleManager = context.getSystemService(RoleManager.class); final RoleControllerManager roleControllerManager = mContext.getSystemService(RoleControllerManager.class); final Executor executor = mContext.getMainExecutor(); mRoleManager.isRoleVisible(mRoleName, executor, visible -> { roleControllerManager.isRoleVisible(mRoleName, executor, visible -> { mRoleVisible = visible; refreshAvailability(); }); mRoleManager.isApplicationVisibleForRole(mRoleName, mPackageName, executor, roleControllerManager.isApplicationVisibleForRole(mRoleName, mPackageName, executor, visible -> { mAppVisible = visible; refreshAvailability(); Loading tests/robotests/src/com/android/settings/applications/appinfo/DefaultAppShortcutPreferenceControllerBaseTest.java +7 −3 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import static org.mockito.Mockito.when; import static org.robolectric.Shadows.shadowOf; import android.app.Activity; import android.app.role.RoleControllerManager; import android.app.role.RoleManager; import android.content.Context; import android.content.Intent; Loading Loading @@ -62,6 +63,8 @@ public class DefaultAppShortcutPreferenceControllerBaseTest { @Mock private RoleManager mRoleManager; @Mock private RoleControllerManager mRoleControllerManager; @Mock private Preference mPreference; private Activity mActivity; Loading @@ -74,6 +77,7 @@ public class DefaultAppShortcutPreferenceControllerBaseTest { MockitoAnnotations.initMocks(this); ShadowApplication shadowApplication = ShadowApplication.getInstance(); shadowApplication.setSystemService(Context.ROLE_SERVICE, mRoleManager); shadowApplication.setSystemService(Context.ROLE_CONTROLLER_SERVICE, mRoleControllerManager); mActivity = Robolectric.setupActivity(Activity.class); mShadowUserManager = shadowOf(mActivity.getSystemService(UserManager.class)); mController = new TestRolePreferenceController(mActivity); Loading @@ -82,7 +86,7 @@ public class DefaultAppShortcutPreferenceControllerBaseTest { @Test public void constructor_callsIsApplicationVisibleForRole() { verify(mRoleManager).isApplicationVisibleForRole(eq(TEST_ROLE_NAME), eq( verify(mRoleControllerManager).isApplicationVisibleForRole(eq(TEST_ROLE_NAME), eq( TEST_PACKAGE_NAME), any(Executor.class), any(Consumer.class)); } Loading Loading @@ -149,7 +153,7 @@ public class DefaultAppShortcutPreferenceControllerBaseTest { private void setRoleIsVisible(boolean visible) { final ArgumentCaptor<Consumer<Boolean>> callbackCaptor = ArgumentCaptor.forClass( Consumer.class); verify(mRoleManager).isRoleVisible(eq(TEST_ROLE_NAME), any(Executor.class), verify(mRoleControllerManager).isRoleVisible(eq(TEST_ROLE_NAME), any(Executor.class), callbackCaptor.capture()); final Consumer<Boolean> callback = callbackCaptor.getValue(); callback.accept(visible); Loading @@ -158,7 +162,7 @@ public class DefaultAppShortcutPreferenceControllerBaseTest { private void setApplicationIsVisibleForRole(boolean visible) { final ArgumentCaptor<Consumer<Boolean>> callbackCaptor = ArgumentCaptor.forClass( Consumer.class); verify(mRoleManager).isApplicationVisibleForRole(eq(TEST_ROLE_NAME), eq( verify(mRoleControllerManager).isApplicationVisibleForRole(eq(TEST_ROLE_NAME), eq( TEST_PACKAGE_NAME), any(Executor.class), callbackCaptor.capture()); final Consumer<Boolean> callback = callbackCaptor.getValue(); callback.accept(visible); Loading tests/robotests/src/com/android/settings/applications/appinfo/DefaultBrowserShortcutPreferenceControllerTest.java +4 −3 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ package com.android.settings.applications.appinfo; import static com.google.common.truth.Truth.assertThat; import android.app.role.RoleManager; import android.app.role.RoleControllerManager; import android.content.Context; import org.junit.Before; Loading @@ -34,14 +34,15 @@ import org.robolectric.shadows.ShadowApplication; public class DefaultBrowserShortcutPreferenceControllerTest { @Mock private RoleManager mRoleManager; private RoleControllerManager mRoleControllerManager; private DefaultBrowserShortcutPreferenceController mController; @Before public void setUp() { MockitoAnnotations.initMocks(this); ShadowApplication.getInstance().setSystemService(Context.ROLE_SERVICE, mRoleManager); ShadowApplication.getInstance().setSystemService(Context.ROLE_CONTROLLER_SERVICE, mRoleControllerManager); mController = new DefaultBrowserShortcutPreferenceController(RuntimeEnvironment.application, "Package1"); } Loading tests/robotests/src/com/android/settings/applications/appinfo/DefaultEmergencyShortcutPreferenceControllerTest.java +4 −3 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ package com.android.settings.applications.appinfo; import static com.google.common.truth.Truth.assertThat; import android.app.role.RoleManager; import android.app.role.RoleControllerManager; import android.content.Context; import org.junit.Before; Loading @@ -34,14 +34,15 @@ import org.robolectric.shadows.ShadowApplication; public class DefaultEmergencyShortcutPreferenceControllerTest { @Mock private RoleManager mRoleManager; private RoleControllerManager mRoleControllerManager; private DefaultEmergencyShortcutPreferenceController mController; @Before public void setUp() { MockitoAnnotations.initMocks(this); ShadowApplication.getInstance().setSystemService(Context.ROLE_SERVICE, mRoleManager); ShadowApplication.getInstance().setSystemService(Context.ROLE_CONTROLLER_SERVICE, mRoleControllerManager); mController = new DefaultEmergencyShortcutPreferenceController( RuntimeEnvironment.application, "Package1"); } Loading tests/robotests/src/com/android/settings/applications/appinfo/DefaultHomeShortcutPreferenceControllerTest.java +4 −3 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ package com.android.settings.applications.appinfo; import static com.google.common.truth.Truth.assertThat; import android.app.role.RoleManager; import android.app.role.RoleControllerManager; import android.content.Context; import org.junit.Before; Loading @@ -34,14 +34,15 @@ import org.robolectric.shadows.ShadowApplication; public class DefaultHomeShortcutPreferenceControllerTest { @Mock private RoleManager mRoleManager; private RoleControllerManager mRoleControllerManager; private DefaultHomeShortcutPreferenceController mController; @Before public void setUp() { MockitoAnnotations.initMocks(this); ShadowApplication.getInstance().setSystemService(Context.ROLE_SERVICE, mRoleManager); ShadowApplication.getInstance().setSystemService(Context.ROLE_CONTROLLER_SERVICE, mRoleControllerManager); mController = new DefaultHomeShortcutPreferenceController(RuntimeEnvironment.application, "Package1"); } Loading Loading
src/com/android/settings/applications/appinfo/DefaultAppShortcutPreferenceControllerBase.java +6 −2 Original line number Diff line number Diff line Loading @@ -14,7 +14,9 @@ package com.android.settings.applications.appinfo; import android.app.role.RoleControllerManager; import android.app.role.RoleManager; import android.app.settings.SettingsEnums; import android.content.Context; import android.content.Intent; import android.os.UserManager; Loading Loading @@ -56,12 +58,14 @@ public abstract class DefaultAppShortcutPreferenceControllerBase extends BasePre mRoleManager = context.getSystemService(RoleManager.class); final RoleControllerManager roleControllerManager = mContext.getSystemService(RoleControllerManager.class); final Executor executor = mContext.getMainExecutor(); mRoleManager.isRoleVisible(mRoleName, executor, visible -> { roleControllerManager.isRoleVisible(mRoleName, executor, visible -> { mRoleVisible = visible; refreshAvailability(); }); mRoleManager.isApplicationVisibleForRole(mRoleName, mPackageName, executor, roleControllerManager.isApplicationVisibleForRole(mRoleName, mPackageName, executor, visible -> { mAppVisible = visible; refreshAvailability(); Loading
tests/robotests/src/com/android/settings/applications/appinfo/DefaultAppShortcutPreferenceControllerBaseTest.java +7 −3 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import static org.mockito.Mockito.when; import static org.robolectric.Shadows.shadowOf; import android.app.Activity; import android.app.role.RoleControllerManager; import android.app.role.RoleManager; import android.content.Context; import android.content.Intent; Loading Loading @@ -62,6 +63,8 @@ public class DefaultAppShortcutPreferenceControllerBaseTest { @Mock private RoleManager mRoleManager; @Mock private RoleControllerManager mRoleControllerManager; @Mock private Preference mPreference; private Activity mActivity; Loading @@ -74,6 +77,7 @@ public class DefaultAppShortcutPreferenceControllerBaseTest { MockitoAnnotations.initMocks(this); ShadowApplication shadowApplication = ShadowApplication.getInstance(); shadowApplication.setSystemService(Context.ROLE_SERVICE, mRoleManager); shadowApplication.setSystemService(Context.ROLE_CONTROLLER_SERVICE, mRoleControllerManager); mActivity = Robolectric.setupActivity(Activity.class); mShadowUserManager = shadowOf(mActivity.getSystemService(UserManager.class)); mController = new TestRolePreferenceController(mActivity); Loading @@ -82,7 +86,7 @@ public class DefaultAppShortcutPreferenceControllerBaseTest { @Test public void constructor_callsIsApplicationVisibleForRole() { verify(mRoleManager).isApplicationVisibleForRole(eq(TEST_ROLE_NAME), eq( verify(mRoleControllerManager).isApplicationVisibleForRole(eq(TEST_ROLE_NAME), eq( TEST_PACKAGE_NAME), any(Executor.class), any(Consumer.class)); } Loading Loading @@ -149,7 +153,7 @@ public class DefaultAppShortcutPreferenceControllerBaseTest { private void setRoleIsVisible(boolean visible) { final ArgumentCaptor<Consumer<Boolean>> callbackCaptor = ArgumentCaptor.forClass( Consumer.class); verify(mRoleManager).isRoleVisible(eq(TEST_ROLE_NAME), any(Executor.class), verify(mRoleControllerManager).isRoleVisible(eq(TEST_ROLE_NAME), any(Executor.class), callbackCaptor.capture()); final Consumer<Boolean> callback = callbackCaptor.getValue(); callback.accept(visible); Loading @@ -158,7 +162,7 @@ public class DefaultAppShortcutPreferenceControllerBaseTest { private void setApplicationIsVisibleForRole(boolean visible) { final ArgumentCaptor<Consumer<Boolean>> callbackCaptor = ArgumentCaptor.forClass( Consumer.class); verify(mRoleManager).isApplicationVisibleForRole(eq(TEST_ROLE_NAME), eq( verify(mRoleControllerManager).isApplicationVisibleForRole(eq(TEST_ROLE_NAME), eq( TEST_PACKAGE_NAME), any(Executor.class), callbackCaptor.capture()); final Consumer<Boolean> callback = callbackCaptor.getValue(); callback.accept(visible); Loading
tests/robotests/src/com/android/settings/applications/appinfo/DefaultBrowserShortcutPreferenceControllerTest.java +4 −3 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ package com.android.settings.applications.appinfo; import static com.google.common.truth.Truth.assertThat; import android.app.role.RoleManager; import android.app.role.RoleControllerManager; import android.content.Context; import org.junit.Before; Loading @@ -34,14 +34,15 @@ import org.robolectric.shadows.ShadowApplication; public class DefaultBrowserShortcutPreferenceControllerTest { @Mock private RoleManager mRoleManager; private RoleControllerManager mRoleControllerManager; private DefaultBrowserShortcutPreferenceController mController; @Before public void setUp() { MockitoAnnotations.initMocks(this); ShadowApplication.getInstance().setSystemService(Context.ROLE_SERVICE, mRoleManager); ShadowApplication.getInstance().setSystemService(Context.ROLE_CONTROLLER_SERVICE, mRoleControllerManager); mController = new DefaultBrowserShortcutPreferenceController(RuntimeEnvironment.application, "Package1"); } Loading
tests/robotests/src/com/android/settings/applications/appinfo/DefaultEmergencyShortcutPreferenceControllerTest.java +4 −3 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ package com.android.settings.applications.appinfo; import static com.google.common.truth.Truth.assertThat; import android.app.role.RoleManager; import android.app.role.RoleControllerManager; import android.content.Context; import org.junit.Before; Loading @@ -34,14 +34,15 @@ import org.robolectric.shadows.ShadowApplication; public class DefaultEmergencyShortcutPreferenceControllerTest { @Mock private RoleManager mRoleManager; private RoleControllerManager mRoleControllerManager; private DefaultEmergencyShortcutPreferenceController mController; @Before public void setUp() { MockitoAnnotations.initMocks(this); ShadowApplication.getInstance().setSystemService(Context.ROLE_SERVICE, mRoleManager); ShadowApplication.getInstance().setSystemService(Context.ROLE_CONTROLLER_SERVICE, mRoleControllerManager); mController = new DefaultEmergencyShortcutPreferenceController( RuntimeEnvironment.application, "Package1"); } Loading
tests/robotests/src/com/android/settings/applications/appinfo/DefaultHomeShortcutPreferenceControllerTest.java +4 −3 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ package com.android.settings.applications.appinfo; import static com.google.common.truth.Truth.assertThat; import android.app.role.RoleManager; import android.app.role.RoleControllerManager; import android.content.Context; import org.junit.Before; Loading @@ -34,14 +34,15 @@ import org.robolectric.shadows.ShadowApplication; public class DefaultHomeShortcutPreferenceControllerTest { @Mock private RoleManager mRoleManager; private RoleControllerManager mRoleControllerManager; private DefaultHomeShortcutPreferenceController mController; @Before public void setUp() { MockitoAnnotations.initMocks(this); ShadowApplication.getInstance().setSystemService(Context.ROLE_SERVICE, mRoleManager); ShadowApplication.getInstance().setSystemService(Context.ROLE_CONTROLLER_SERVICE, mRoleControllerManager); mController = new DefaultHomeShortcutPreferenceController(RuntimeEnvironment.application, "Package1"); } Loading