Using resource override instead of code-swap for ApiWrapper

Bug: 330920490
Flag: None
Test: Presubmit
Change-Id: Iac19f32e64d2c76ed5b4f8592943ee4ae7af51b5
This commit is contained in:
Sunny Goyal committed 2024-04-09 11:14:44 -07:00
1 parent 8ecbaa422f
commit 11117d9b2a
22 files changed
+246 -300

No files matched your search

@@ -47,8 +47,8 @@ import androidx.test.runner.AndroidJUnit4;
import com.android.launcher3.logging.StatsLogManager;
import com.android.launcher3.pm.UserCache;
import com.android.launcher3.uioverrides.ApiWrapper;
import com.android.launcher3.util.ActivityContextWrapper;
import com.android.launcher3.util.ApiWrapper;
import com.android.launcher3.util.UserIconInfo;
import com.android.launcher3.util.rule.TestStabilityRule;
@@ -108,7 +108,8 @@ public class PrivateProfileManagerTest {
when(mUserCache.getUserInfo(Process.myUserHandle())).thenReturn(MAIN_ICON_INFO);
when(mUserCache.getUserInfo(PRIVATE_HANDLE)).thenReturn(PRIVATE_ICON_INFO);
when(mAllApps.getContext()).thenReturn(mContext);
when(mAllApps.getContext().getResources()).thenReturn(mResources);
when(mContext.getResources()).thenReturn(mResources);
when(mContext.getApplicationContext()).thenReturn(getApplicationContext());
when(mAllApps.getAppsStore()).thenReturn(mAllAppsStore);
when(mAllApps.getActiveRecyclerView()).thenReturn(mAllAppsRecyclerView);
when(mContext.getPackageManager()).thenReturn(mPackageManager);
@@ -200,14 +201,15 @@ public class PrivateProfileManagerTest {
@Test
public void openPrivateSpaceSettings_triggersCorrectIntent() {
Intent expectedIntent = ApiWrapper.getPrivateSpaceSettingsIntent(mContext);
Intent expectedIntent = ApiWrapper.INSTANCE.get(mContext).getPrivateSpaceSettingsIntent();
ArgumentCaptor<Intent> acIntent = ArgumentCaptor.forClass(Intent.class);
mPrivateProfileManager.setPrivateSpaceSettingsAvailable(true);
mPrivateProfileManager.openPrivateSpaceSettings();
Mockito.verify(mContext).startActivity(acIntent.capture());
assertEquals("Intent Action is different", expectedIntent, acIntent.getValue());
assertEquals("Intent Action is different",
expectedIntent.toUri(0), acIntent.getValue().toUri(0));
}
private static void awaitTasksCompleted() throws Exception {