Merge "Making some classess accessible in multivalent tests" into main

This commit is contained in:
Treehugger Robot
2024-03-21 10:38:08 +00:00
committed by Android (Google) Code Review
22 changed files with 22 additions and 87 deletions
@@ -190,16 +190,14 @@ public class TaplViewInflationDuringSwipeUp extends AbstractQuickStepTest {
info.spanX = 2;
info.spanY = 2;
AtomicInteger widgetId = new AtomicInteger();
new FavoriteItemsTransaction(mTargetContext)
commitTransactionAndLoadHome(new FavoriteItemsTransaction(mTargetContext)
.addItem(() -> {
LauncherAppWidgetInfo item = createWidgetInfo(info, mTargetContext, true);
item.screenId = FIRST_SCREEN_ID;
widgetId.set(item.appWidgetId);
return item;
})
.commitAndLoadHome(mLauncher);
}));
assertTrue("Widget is not present",
mLauncher.goHome().tryGetWidget(info.label, DEFAULT_UI_TIMEOUT) != null);
+1 -47
View File
@@ -40,32 +40,6 @@ filegroup {
],
}
// Source code used for screenshot tests
filegroup {
name: "launcher-image-tests-helpers",
srcs: [
"src/com/android/launcher3/celllayout/board/*.java",
"src/com/android/launcher3/celllayout/board/*.kt",
"src/com/android/launcher3/celllayout/FavoriteItemsTransaction.java",
"src/com/android/launcher3/ui/AbstractLauncherUiTest.java",
"src/com/android/launcher3/ui/PortraitLandscapeRunner.java",
"src/com/android/launcher3/ui/TestViewHelpers.java",
"multivalentTests/src/com/android/launcher3/util/LauncherLayoutBuilder.java",
"src/com/android/launcher3/util/ModelTestExtensions.kt",
"src/com/android/launcher3/util/TestConstants.java",
"multivalentTests/src/com/android/launcher3/util/TestUtil.java",
"src/com/android/launcher3/util/Wait.java",
"multivalentTests/src/com/android/launcher3/util/WidgetUtils.java",
"src/com/android/launcher3/util/rule/*.java",
"src/com/android/launcher3/util/rule/*.kt",
"multivalentTests/src/com/android/launcher3/util/rule/*.java",
"multivalentTests/src/com/android/launcher3/util/rule/*.kt",
"src/com/android/launcher3/util/viewcapture_analysis/*.java",
"src/com/android/launcher3/testcomponent/*.java",
"src/com/android/launcher3/testcomponent/*.kt",
],
}
// Source code used for non-quickstep tests
filegroup {
name: "launcher-non-quickstep-tests-src",
@@ -79,35 +53,15 @@ filegroup {
filegroup {
name: "launcher-oop-tests-src",
srcs: [
":launcher-testing-helpers",
"src/com/android/launcher3/allapps/TaplOpenCloseAllAppsTest.java",
"src/com/android/launcher3/allapps/TaplAllAppsIconsWorkingTest.java",
"src/com/android/launcher3/appiconmenu/TaplAppIconMenuTest.java",
"src/com/android/launcher3/dragging/TaplDragTest.java",
"src/com/android/launcher3/dragging/TaplUninstallRemoveTest.java",
"src/com/android/launcher3/ui/AbstractLauncherUiTest.java",
"src/com/android/launcher3/ui/PortraitLandscapeRunner.java",
"src/com/android/launcher3/ui/TaplTestsLauncher3Test.java",
"src/com/android/launcher3/ui/widget/TaplWidgetPickerTest.java",
"src/com/android/launcher3/ui/workspace/TaplWorkspaceTest.java",
"multivalentTests/src/com/android/launcher3/util/LauncherLayoutBuilder.java",
"src/com/android/launcher3/util/TestConstants.java",
"multivalentTests/src/com/android/launcher3/util/TestUtil.java",
"src/com/android/launcher3/util/Wait.java",
"multivalentTests/src/com/android/launcher3/util/WidgetUtils.java",
"src/com/android/launcher3/util/rule/FailureWatcher.java",
"src/com/android/launcher3/util/rule/ViewCaptureRule.kt",
"src/com/android/launcher3/util/rule/SamplerRule.java",
"src/com/android/launcher3/util/rule/ScreenRecordRule.java",
"src/com/android/launcher3/util/rule/ShellCommandRule.java",
"src/com/android/launcher3/util/rule/TestIsolationRule.java",
"multivalentTests/src/com/android/launcher3/util/rule/TestStabilityRule.java",
"src/com/android/launcher3/util/viewcapture_analysis/*.java",
"src/com/android/launcher3/testcomponent/BaseTestingActivity.java",
"src/com/android/launcher3/testcomponent/OtherBaseTestingActivity.java",
"src/com/android/launcher3/testcomponent/CustomShortcutConfigActivity.java",
"src/com/android/launcher3/testcomponent/TestCommandReceiver.java",
"src/com/android/launcher3/testcomponent/TestLauncherActivity.java",
"src/com/android/launcher3/testcomponent/ImeTestActivity.java",
],
}
@@ -15,8 +15,6 @@
*/
package com.android.launcher3.celllayout;
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
import static com.android.launcher3.LauncherSettings.Favorites.TABLE_NAME;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import static com.android.launcher3.util.Executors.MODEL_EXECUTOR;
@@ -24,8 +22,6 @@ import static com.android.launcher3.util.TestUtil.runOnExecutorSync;
import android.content.Context;
import androidx.test.uiautomator.UiDevice;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherModel;
import com.android.launcher3.LauncherSettings;
@@ -33,7 +29,6 @@ import com.android.launcher3.model.ModelDbController;
import com.android.launcher3.model.data.FolderInfo;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.provider.LauncherDbUtils.SQLiteTransaction;
import com.android.launcher3.tapl.LauncherInstrumentation;
import com.android.launcher3.util.ContentWriter;
import com.android.launcher3.util.ModelTestExtensions;
@@ -106,15 +101,4 @@ public class FavoriteItemsTransaction {
runOnExecutorSync(MAIN_EXECUTOR, model::forceReload);
ModelTestExtensions.INSTANCE.loadModelSync(model);
}
/**
* Commits the transaction and waits for home load
*/
public void commitAndLoadHome(LauncherInstrumentation inst) {
commit();
// Launch the home activity
UiDevice.getInstance(getInstrumentation()).pressHome();
inst.waitForLauncherInitialized();
}
}
@@ -22,7 +22,6 @@ import static com.android.launcher3.ui.TestViewHelpers.findWidgetProvider;
import static com.android.launcher3.util.WidgetUtils.createWidgetInfo;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.graphics.Rect;
import android.os.Process;
@@ -32,11 +31,6 @@ import android.util.Log;
import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.celllayout.FavoriteItemsTransaction;
import com.android.launcher3.celllayout.board.CellLayoutBoard;
import com.android.launcher3.celllayout.board.CellType;
import com.android.launcher3.celllayout.board.FolderPoint;
import com.android.launcher3.celllayout.board.IconPoint;
import com.android.launcher3.celllayout.board.WidgetRect;
import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.model.data.FolderInfo;
import com.android.launcher3.model.data.ItemInfo;
@@ -56,12 +50,10 @@ public class TestWorkspaceBuilder {
private UserHandle mMyUser;
private Context mContext;
private ContentResolver mResolver;
public TestWorkspaceBuilder(Context context) {
mMyUser = Process.myUserHandle();
mContext = context;
mResolver = mContext.getContentResolver();
}
/**
@@ -56,6 +56,7 @@ import androidx.test.uiautomator.Until;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.Utilities;
import com.android.launcher3.celllayout.FavoriteItemsTransaction;
import com.android.launcher3.tapl.HomeAllApps;
import com.android.launcher3.tapl.HomeAppIcon;
import com.android.launcher3.tapl.LauncherInstrumentation;
@@ -685,4 +686,12 @@ public abstract class AbstractLauncherUiTest {
}
return homeAppIcon;
}
protected void commitTransactionAndLoadHome(FavoriteItemsTransaction transaction) {
transaction.commit();
// Launch the home activity
UiDevice.getInstance(getInstrumentation()).pressHome();
mLauncher.waitForLauncherInitialized();
}
}
@@ -87,7 +87,7 @@ public class TaplAddConfigWidgetTest extends AbstractLauncherUiTest {
* @param acceptConfig accept the config activity
*/
private void runTest(boolean acceptConfig) throws Throwable {
new FavoriteItemsTransaction(mTargetContext).commitAndLoadHome(mLauncher);
commitTransactionAndLoadHome(new FavoriteItemsTransaction(mTargetContext));
// Drag widget to homescreen
WidgetConfigStartupMonitor monitor = new WidgetConfigStartupMonitor();
@@ -56,7 +56,7 @@ public class TaplAddWidgetTest extends AbstractLauncherUiTest {
@ScreenRecord // b/316910614
public void testDragIcon() throws Throwable {
mLauncher.enableDebugTracing(); // b/289161193
new FavoriteItemsTransaction(mTargetContext).commitAndLoadHome(mLauncher);
commitTransactionAndLoadHome(new FavoriteItemsTransaction(mTargetContext));
waitForLauncherCondition("Workspace didn't finish loading", l -> !l.isWorkspaceLoading());
@@ -92,7 +92,7 @@ public class TaplAddWidgetTest extends AbstractLauncherUiTest {
// TODO(b/322820039): Enable test for tablets - the picker UI has changed and test needs to
// be updated to look for appropriate UI elements.
Assume.assumeFalse(mLauncher.isTablet());
new FavoriteItemsTransaction(mTargetContext).commitAndLoadHome(mLauncher);
commitTransactionAndLoadHome(new FavoriteItemsTransaction(mTargetContext));
mLauncher.getWorkspace().openAllWidgets()
.getWidget("com.android.launcher3.testcomponent.CustomShortcutConfigActivity")
@@ -108,7 +108,7 @@ public class TaplAddWidgetTest extends AbstractLauncherUiTest {
@Test
@ScreenRecord // b/316910614
public void testResizeWidget() throws Throwable {
new FavoriteItemsTransaction(mTargetContext).commitAndLoadHome(mLauncher);
commitTransactionAndLoadHome(new FavoriteItemsTransaction(mTargetContext));
waitForLauncherCondition("Workspace didn't finish loading", l -> !l.isWorkspaceLoading());
@@ -251,22 +251,20 @@ public class TaplBindWidgetTest extends AbstractLauncherUiTest {
private void addPendingItemToScreen(LauncherAppWidgetInfo item, int restoreStatus) {
item.restoreStatus = restoreStatus;
item.screenId = FIRST_SCREEN_ID;
new FavoriteItemsTransaction(mTargetContext)
.addItem(() -> item)
.commitAndLoadHome(mLauncher);
commitTransactionAndLoadHome(
new FavoriteItemsTransaction(mTargetContext).addItem(() -> item));
}
private LauncherAppWidgetProviderInfo addWidgetToScreen(boolean hasConfigureScreen,
boolean bindWidget, Consumer<LauncherAppWidgetInfo> itemOverride) {
LauncherAppWidgetProviderInfo info = TestViewHelpers.findWidgetProvider(hasConfigureScreen);
new FavoriteItemsTransaction(mTargetContext)
commitTransactionAndLoadHome(new FavoriteItemsTransaction(mTargetContext)
.addItem(() -> {
LauncherAppWidgetInfo item = createWidgetInfo(info, mTargetContext, bindWidget);
item.screenId = FIRST_SCREEN_ID;
itemOverride.accept(item);
return item;
})
.commitAndLoadHome(mLauncher);
}));
return info;
}
@@ -128,7 +128,7 @@ public class TaplRequestPinItemTest extends AbstractLauncherUiTest {
private void runTest(String activityMethod, boolean isWidget, ItemOperator itemMatcher,
Intent... commandIntents) throws Throwable {
new FavoriteItemsTransaction(mTargetContext).commitAndLoadHome(mLauncher);
commitTransactionAndLoadHome(new FavoriteItemsTransaction(mTargetContext));
// Open Pin item activity
BlockingBroadcastReceiver openMonitor = new BlockingBroadcastReceiver(