Some test fixes where default user is assumed to be user 0
CheckLongPressHelper: Cancelling view longpress which inturn also cancels self This ensures that long press is properly cancelled if the default timeout for system longpress is same as ours Bug: 379777736 Bug: 379807782 Bug: 379805363 Bug: 379805788 Bug: 379777734 Bug: 379774350 Flag: EXEMPT bugfix Test: Presubmit Change-Id: Ic4d9d6c4f79325a5d7ab98eafa1c86db4c2e67a5
This commit is contained in:
@@ -151,6 +151,8 @@ public class CheckLongPressHelper {
|
||||
handled = mView.performLongClick();
|
||||
}
|
||||
if (handled) {
|
||||
// Cancel any default long-press action on the view
|
||||
mView.cancelLongPress();
|
||||
mView.setPressed(false);
|
||||
mHasPerformedLongPress = true;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import static org.junit.Assert.assertTrue;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Process;
|
||||
import android.os.UserHandle;
|
||||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
@@ -49,16 +50,17 @@ public final class FolderNameProviderTest {
|
||||
@Before
|
||||
public void setUp() {
|
||||
mContext = new ActivityContextWrapper(getApplicationContext());
|
||||
int workUserId = Process.myUserHandle().hashCode() + 1;
|
||||
mItem1 = new WorkspaceItemInfo(new AppInfo(
|
||||
new ComponentName("a.b.c", "a.b.c/a.b.c.d"),
|
||||
"title1",
|
||||
UserHandle.of(10),
|
||||
UserHandle.of(workUserId),
|
||||
new Intent().setComponent(new ComponentName("a.b.c", "a.b.c/a.b.c.d"))
|
||||
));
|
||||
mItem2 = new WorkspaceItemInfo(new AppInfo(
|
||||
new ComponentName("a.b.c", "a.b.c/a.b.c.d"),
|
||||
"title2",
|
||||
UserHandle.of(10),
|
||||
UserHandle.of(workUserId),
|
||||
new Intent().setComponent(new ComponentName("a.b.c", "a.b.c/a.b.c.d"))
|
||||
));
|
||||
}
|
||||
|
||||
+9
-5
@@ -20,7 +20,7 @@ import android.app.PendingIntent
|
||||
import android.content.ComponentName
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageInstaller.SessionInfo
|
||||
import android.os.UserHandle
|
||||
import android.os.Process.myUserHandle
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import com.android.launcher3.LauncherSettings.Favorites.CONTAINER_DESKTOP
|
||||
@@ -77,16 +77,18 @@ class FirstScreenBroadcastHelperTest {
|
||||
SessionInfo().apply {
|
||||
installerPackageName = expectedInstallerPackage
|
||||
appPackageName = expectedAppPackage
|
||||
userId = myUserHandle().identifier
|
||||
}
|
||||
val sessionInfoUnexpected =
|
||||
SessionInfo().apply {
|
||||
installerPackageName = expectedInstallerPackage
|
||||
appPackageName = unexpectedAppPackage
|
||||
userId = myUserHandle().identifier
|
||||
}
|
||||
val sessionInfoMap: HashMap<PackageUserKey, SessionInfo> =
|
||||
hashMapOf(
|
||||
PackageUserKey(unexpectedAppPackage, UserHandle(0)) to sessionInfoExpected,
|
||||
PackageUserKey(expectedAppPackage, UserHandle(0)) to sessionInfoUnexpected,
|
||||
PackageUserKey(unexpectedAppPackage, myUserHandle()) to sessionInfoExpected,
|
||||
PackageUserKey(expectedAppPackage, myUserHandle()) to sessionInfoUnexpected,
|
||||
)
|
||||
|
||||
// When
|
||||
@@ -200,16 +202,18 @@ class FirstScreenBroadcastHelperTest {
|
||||
SessionInfo().apply {
|
||||
installerPackageName = expectedInstallerPackage
|
||||
appPackageName = expectedAppPackage
|
||||
userId = myUserHandle().identifier
|
||||
}
|
||||
val sessionInfoUnexpected =
|
||||
SessionInfo().apply {
|
||||
installerPackageName = expectedInstallerPackage
|
||||
appPackageName = unexpectedAppPackage
|
||||
userId = myUserHandle().identifier
|
||||
}
|
||||
val sessionInfoMap: HashMap<PackageUserKey, SessionInfo> =
|
||||
hashMapOf(
|
||||
PackageUserKey(unexpectedAppPackage, UserHandle(0)) to sessionInfoExpected,
|
||||
PackageUserKey(expectedAppPackage, UserHandle(0)) to sessionInfoUnexpected,
|
||||
PackageUserKey(unexpectedAppPackage, myUserHandle()) to sessionInfoExpected,
|
||||
PackageUserKey(expectedAppPackage, myUserHandle()) to sessionInfoUnexpected,
|
||||
)
|
||||
val expectedItemInfo = WorkspaceItemInfo().apply { intent = expectedIntent }
|
||||
val expectedFolderInfo = FolderInfo().apply { add(expectedItemInfo) }
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.launcher3.compat;
|
||||
|
||||
import static android.os.Process.myUserHandle;
|
||||
|
||||
import static com.android.launcher3.Flags.FLAG_ENABLE_SUPPORT_FOR_ARCHIVING;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
@@ -136,7 +138,8 @@ public class PromiseIconUiTest extends BaseLauncherActivityTest<Launcher> {
|
||||
public void testPromiseIcon_addedArchivedApp() throws Throwable {
|
||||
installDummyAppAndWaitForUIUpdate();
|
||||
assertThat(executeShellCommand(
|
||||
String.format("pm archive %s", DUMMY_PACKAGE)))
|
||||
String.format("pm archive --user %d %s",
|
||||
myUserHandle().getIdentifier(), DUMMY_PACKAGE)))
|
||||
.isEqualTo("Success\n");
|
||||
|
||||
// Create and add test session
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.android.launcher3.model
|
||||
|
||||
import android.appwidget.AppWidgetManager
|
||||
import android.content.Intent
|
||||
import android.os.Process
|
||||
import android.os.UserHandle
|
||||
import android.platform.test.annotations.DisableFlags
|
||||
import android.platform.test.annotations.EnableFlags
|
||||
@@ -136,7 +137,7 @@ class LoaderTaskTest {
|
||||
@Test
|
||||
fun loadsDataProperly() =
|
||||
with(BgDataModel()) {
|
||||
val MAIN_HANDLE = UserHandle.of(0)
|
||||
val MAIN_HANDLE = Process.myUserHandle()
|
||||
val mockUserHandles = arrayListOf<UserHandle>(MAIN_HANDLE)
|
||||
`when`(userCache.userProfiles).thenReturn(mockUserHandles)
|
||||
`when`(userCache.getUserInfo(MAIN_HANDLE)).thenReturn(UserIconInfo(MAIN_HANDLE, 1))
|
||||
@@ -186,7 +187,7 @@ class LoaderTaskTest {
|
||||
fun setsQuietModeFlagCorrectlyForWorkProfile() =
|
||||
with(BgDataModel()) {
|
||||
setFlagsRule.enableFlags(Flags.FLAG_ENABLE_PRIVATE_SPACE)
|
||||
val MAIN_HANDLE = UserHandle.of(0)
|
||||
val MAIN_HANDLE = Process.myUserHandle()
|
||||
val mockUserHandles = arrayListOf<UserHandle>(MAIN_HANDLE)
|
||||
`when`(userCache.userProfiles).thenReturn(mockUserHandles)
|
||||
`when`(userManagerState?.isUserQuiet(MAIN_HANDLE)).thenReturn(true)
|
||||
@@ -215,7 +216,7 @@ class LoaderTaskTest {
|
||||
fun setsQuietModeFlagCorrectlyForPrivateProfile() =
|
||||
with(BgDataModel()) {
|
||||
setFlagsRule.enableFlags(Flags.FLAG_ENABLE_PRIVATE_SPACE)
|
||||
val MAIN_HANDLE = UserHandle.of(0)
|
||||
val MAIN_HANDLE = Process.myUserHandle()
|
||||
val mockUserHandles = arrayListOf<UserHandle>(MAIN_HANDLE)
|
||||
`when`(userCache.userProfiles).thenReturn(mockUserHandles)
|
||||
`when`(userManagerState?.isUserQuiet(MAIN_HANDLE)).thenReturn(true)
|
||||
|
||||
@@ -21,6 +21,7 @@ import static com.android.launcher3.tapl.TestHelpers.getLauncherInMyProcess;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.os.Process;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
@@ -109,8 +110,9 @@ public class ShellCommandRule implements TestRule {
|
||||
}
|
||||
|
||||
public static String getLauncherCommand(ActivityInfo launcher) {
|
||||
return "cmd package set-home-activity " +
|
||||
new ComponentName(launcher.packageName, launcher.name).flattenToString();
|
||||
return String.format("cmd package set-home-activity --user %d %s",
|
||||
Process.myUserHandle().getIdentifier(),
|
||||
new ComponentName(launcher.packageName, launcher.name).flattenToString());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,10 +33,9 @@ import android.util.Log;
|
||||
import androidx.test.uiautomator.SearchCondition;
|
||||
import androidx.test.uiautomator.UiDevice;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class TestHelpers {
|
||||
|
||||
@@ -113,8 +112,8 @@ public class TestHelpers {
|
||||
}
|
||||
|
||||
private static String checkCrash(Context context, String label, long startTime) {
|
||||
DropBoxManager dropbox = (DropBoxManager) context.getSystemService(Context.DROPBOX_SERVICE);
|
||||
Assert.assertNotNull("Unable access the DropBoxManager service", dropbox);
|
||||
DropBoxManager dropbox = Objects.requireNonNull(
|
||||
context.getSystemService(DropBoxManager.class));
|
||||
|
||||
long timestamp = startTime;
|
||||
DropBoxManager.Entry entry;
|
||||
|
||||
Reference in New Issue
Block a user