Merge "Install test app for work profile user" into udc-dev am: 47ab6f8ba2
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/23331908 Change-Id: I69bdb3302c5e376bc3f57ff2d73c8b52b1c1972b Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -19,6 +19,7 @@ import static com.android.launcher3.LauncherState.ALL_APPS;
|
|||||||
import static com.android.launcher3.LauncherState.NORMAL;
|
import static com.android.launcher3.LauncherState.NORMAL;
|
||||||
import static com.android.launcher3.allapps.AllAppsStore.DEFER_UPDATES_TEST;
|
import static com.android.launcher3.allapps.AllAppsStore.DEFER_UPDATES_TEST;
|
||||||
import static com.android.launcher3.testing.shared.TestProtocol.WORK_TAB_MISSING;
|
import static com.android.launcher3.testing.shared.TestProtocol.WORK_TAB_MISSING;
|
||||||
|
import static com.android.launcher3.util.TestUtil.installDummyAppForUser;
|
||||||
import static com.android.launcher3.util.rule.TestStabilityRule.LOCAL;
|
import static com.android.launcher3.util.rule.TestStabilityRule.LOCAL;
|
||||||
import static com.android.launcher3.util.rule.TestStabilityRule.PLATFORM_POSTSUBMIT;
|
import static com.android.launcher3.util.rule.TestStabilityRule.PLATFORM_POSTSUBMIT;
|
||||||
|
|
||||||
@@ -39,6 +40,7 @@ import com.android.launcher3.allapps.WorkPausedCard;
|
|||||||
import com.android.launcher3.allapps.WorkProfileManager;
|
import com.android.launcher3.allapps.WorkProfileManager;
|
||||||
import com.android.launcher3.tapl.LauncherInstrumentation;
|
import com.android.launcher3.tapl.LauncherInstrumentation;
|
||||||
import com.android.launcher3.testing.shared.TestProtocol;
|
import com.android.launcher3.testing.shared.TestProtocol;
|
||||||
|
import com.android.launcher3.util.TestUtil;
|
||||||
import com.android.launcher3.util.rule.TestStabilityRule.Stability;
|
import com.android.launcher3.util.rule.TestStabilityRule.Stability;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
@@ -69,11 +71,11 @@ public class WorkProfileTest extends AbstractLauncherUiTest {
|
|||||||
|
|
||||||
String[] tokens = output.split("\\s+");
|
String[] tokens = output.split("\\s+");
|
||||||
mProfileUserId = Integer.parseInt(tokens[tokens.length - 1]);
|
mProfileUserId = Integer.parseInt(tokens[tokens.length - 1]);
|
||||||
output = mDevice.executeShellCommand("am start-user " + mProfileUserId);
|
|
||||||
StringBuilder logStr = new StringBuilder().append("profileId: ").append(mProfileUserId);
|
StringBuilder logStr = new StringBuilder().append("profileId: ").append(mProfileUserId);
|
||||||
for (String str : tokens) {
|
for (String str : tokens) {
|
||||||
logStr.append(str).append("\n");
|
logStr.append(str).append("\n");
|
||||||
}
|
}
|
||||||
|
installDummyAppForUser(mProfileUserId);
|
||||||
updateWorkProfileSetupSuccessful("am start-user", output);
|
updateWorkProfileSetupSuccessful("am start-user", output);
|
||||||
|
|
||||||
Log.d(WORK_TAB_MISSING, "workProfileSuccessful? " + mWorkProfileSetupSuccessful +
|
Log.d(WORK_TAB_MISSING, "workProfileSuccessful? " + mWorkProfileSetupSuccessful +
|
||||||
@@ -101,6 +103,7 @@ public class WorkProfileTest extends AbstractLauncherUiTest {
|
|||||||
}
|
}
|
||||||
launcher.getAppsView().getAppsStore().disableDeferUpdates(DEFER_UPDATES_TEST);
|
launcher.getAppsView().getAppsStore().disableDeferUpdates(DEFER_UPDATES_TEST);
|
||||||
});
|
});
|
||||||
|
TestUtil.uninstallDummyApp();
|
||||||
mDevice.executeShellCommand("pm remove-user " + mProfileUserId);
|
mDevice.executeShellCommand("pm remove-user " + mProfileUserId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -58,8 +58,13 @@ import java.util.function.ToIntFunction;
|
|||||||
|
|
||||||
public class TestUtil {
|
public class TestUtil {
|
||||||
public static final String DUMMY_PACKAGE = "com.example.android.aardwolf";
|
public static final String DUMMY_PACKAGE = "com.example.android.aardwolf";
|
||||||
|
public static final int DEFAULT_USER_ID = 0;
|
||||||
|
|
||||||
public static void installDummyApp() throws IOException {
|
public static void installDummyApp() throws IOException {
|
||||||
|
installDummyAppForUser(DEFAULT_USER_ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void installDummyAppForUser(int userId) throws IOException {
|
||||||
// Copy apk from resources to a local file and install from there.
|
// Copy apk from resources to a local file and install from there.
|
||||||
final Resources resources = getContext().getResources();
|
final Resources resources = getContext().getResources();
|
||||||
final InputStream in = resources.openRawResource(
|
final InputStream in = resources.openRawResource(
|
||||||
@@ -80,7 +85,7 @@ public class TestUtil {
|
|||||||
out.close();
|
out.close();
|
||||||
|
|
||||||
final String result = UiDevice.getInstance(getInstrumentation())
|
final String result = UiDevice.getInstance(getInstrumentation())
|
||||||
.executeShellCommand("pm install " + apkFilename);
|
.executeShellCommand("pm install --user " + userId + " " + apkFilename);
|
||||||
Assert.assertTrue(
|
Assert.assertTrue(
|
||||||
"Failed to install wellbeing test apk; make sure the device is rooted",
|
"Failed to install wellbeing test apk; make sure the device is rooted",
|
||||||
"Success".equals(result.replaceAll("\\s+", "")));
|
"Success".equals(result.replaceAll("\\s+", "")));
|
||||||
|
|||||||
Reference in New Issue
Block a user