use of com.android.launcher3.popup.SystemShortcut.WIDGETS in project android_packages_apps_Launcher3 by ProtonAOSP.
the class AddConfigWidgetTest method runTest.
/**
* @param acceptConfig accept the config activity
*/
private void runTest(boolean acceptConfig) throws Throwable {
clearHomescreen();
mDevice.pressHome();
final Widgets widgets = mLauncher.getWorkspace().openAllWidgets();
// Drag widget to homescreen
WidgetConfigStartupMonitor monitor = new WidgetConfigStartupMonitor();
WidgetResizeFrame resizeFrame = widgets.getWidget(mWidgetInfo.getLabel(mTargetContext.getPackageManager())).dragConfigWidgetToWorkspace(acceptConfig);
// Widget id for which the config activity was opened
mWidgetId = monitor.getWidgetId();
// Verify that the widget id is valid and bound
assertNotNull(mAppWidgetManager.getAppWidgetInfo(mWidgetId));
if (acceptConfig) {
assertNotNull("Widget resize frame not shown after widget added", resizeFrame);
resizeFrame.dismiss();
final Widget widget = mLauncher.getWorkspace().tryGetWidget(mWidgetInfo.label, DEFAULT_UI_TIMEOUT);
assertNotNull("Widget not found on the workspace", widget);
} else {
final Widget widget = mLauncher.getWorkspace().tryGetWidget(mWidgetInfo.label, DEFAULT_UI_TIMEOUT);
assertNull("Widget unexpectedly found on the workspace", widget);
}
}
use of com.android.launcher3.popup.SystemShortcut.WIDGETS in project android_packages_apps_Launcher3 by ProtonAOSP.
the class WidgetsListAdapterTest method setWidgetsOnSearch_expandedApp_shouldResetExpandedApp.
@Test
public void setWidgetsOnSearch_expandedApp_shouldResetExpandedApp() {
// GIVEN a list of widgets entries:
// [Empty item
// com.google.test0,
// com.google.test0 content,
// com.google.test1,
// com.google.test1 content,
// com.google.test2,
// com.google.test2 content]
// The visible widgets entries:
// [Empty item,
// com.google.test0,
// com.google.test1,
// com.google.test2].
ArrayList<WidgetsListBaseEntry> allEntries = generateSampleMap(3);
mAdapter.setWidgetsOnSearch(allEntries);
// GIVEN com.google.test.1 header is expanded. The visible entries list becomes:
// [Empty item, com.google.test0, com.google.test1, com.google.test1 content,
// com.google.test2]
mAdapter.onHeaderClicked(/* showWidgets= */
true, new PackageUserKey(TEST_PACKAGE_PLACEHOLDER + 1, mUserHandle));
Mockito.reset(mListener);
// WHEN same widget entries are set again.
mAdapter.setWidgetsOnSearch(allEntries);
// THEN expanded app is reset and the visible entries list becomes:
// [Empty item, com.google.test0, com.google.test1, com.google.test2]
verify(mListener).onItemRangeChanged(eq(2), eq(1), isNull());
verify(mListener).onItemRangeRemoved(/* positionStart= */
3, /* itemCount= */
1);
}
use of com.android.launcher3.popup.SystemShortcut.WIDGETS in project android_packages_apps_Launcher3 by ProtonAOSP.
the class WidgetsListAdapterTest method generateSampleMap.
/**
* Generates a list of sample widget entries.
*
* <p>Each sample app has 1 widget only. An app is represented by 2 entries,
* {@link WidgetsListHeaderEntry} & {@link WidgetsListContentEntry}. Only
* {@link WidgetsListHeaderEntry} is always visible in the {@link WidgetsListAdapter}.
* {@link WidgetsListContentEntry} is only shown upon clicking the corresponding app's
* {@link WidgetsListHeaderEntry}. Only at most one {@link WidgetsListContentEntry} is shown at
* a time.
*
* @param num the number of apps that have widgets.
*/
private ArrayList<WidgetsListBaseEntry> generateSampleMap(int num) {
ArrayList<WidgetsListBaseEntry> result = new ArrayList<>();
if (num <= 0)
return result;
for (int i = 0; i < num; i++) {
String packageName = TEST_PACKAGE_PLACEHOLDER + i;
List<WidgetItem> widgetItems = generateWidgetItems(packageName, /* numOfWidgets= */
1);
PackageItemInfo pInfo = new PackageItemInfo(packageName, widgetItems.get(0).user);
pInfo.title = pInfo.packageName;
pInfo.bitmap = BitmapInfo.of(Bitmap.createBitmap(10, 10, Bitmap.Config.ALPHA_8), 0);
result.add(new WidgetsListHeaderEntry(pInfo, /* titleSectionName= */
"", widgetItems));
result.add(new WidgetsListContentEntry(pInfo, /* titleSectionName= */
"", widgetItems));
}
return result;
}
use of com.android.launcher3.popup.SystemShortcut.WIDGETS in project android_packages_apps_Launcher3 by ProtonAOSP.
the class AbstractLauncherUiTest method checkLauncherIntegrity.
private void checkLauncherIntegrity(Launcher launcher, ContainerType expectedContainerType) {
if (launcher != null) {
final StateManager<LauncherState> stateManager = launcher.getStateManager();
final LauncherState stableState = stateManager.getCurrentStableState();
assertTrue("Stable state != state: " + stableState.getClass().getSimpleName() + ", " + stateManager.getState().getClass().getSimpleName(), stableState == stateManager.getState());
final boolean isResumed = launcher.hasBeenResumed();
final boolean isStarted = launcher.isStarted();
checkLauncherState(launcher, expectedContainerType, isResumed, isStarted);
final int ordinal = stableState.ordinal;
switch(expectedContainerType) {
case WORKSPACE:
case WIDGETS:
{
assertTrue("Launcher is not resumed in state: " + expectedContainerType, isResumed);
assertTrue(TestProtocol.stateOrdinalToString(ordinal), ordinal == TestProtocol.NORMAL_STATE_ORDINAL);
break;
}
case ALL_APPS:
{
assertTrue("Launcher is not resumed in state: " + expectedContainerType, isResumed);
assertTrue(TestProtocol.stateOrdinalToString(ordinal), ordinal == TestProtocol.ALL_APPS_STATE_ORDINAL);
break;
}
case OVERVIEW:
{
checkLauncherStateInOverview(launcher, expectedContainerType, isStarted, isResumed);
assertTrue(TestProtocol.stateOrdinalToString(ordinal), ordinal == TestProtocol.OVERVIEW_STATE_ORDINAL);
break;
}
case BACKGROUND:
{
assertTrue("Launcher is resumed in state: " + expectedContainerType, !isResumed);
assertTrue(TestProtocol.stateOrdinalToString(ordinal), ordinal == TestProtocol.NORMAL_STATE_ORDINAL);
break;
}
default:
throw new IllegalArgumentException("Illegal container: " + expectedContainerType);
}
} else {
assertTrue("Container type is not BACKGROUND or FALLBACK_OVERVIEW: " + expectedContainerType, expectedContainerType == ContainerType.BACKGROUND || expectedContainerType == ContainerType.FALLBACK_OVERVIEW);
}
}
use of com.android.launcher3.popup.SystemShortcut.WIDGETS in project android_packages_apps_Launcher3 by ProtonAOSP.
the class TaplTestsLauncher3 method testWidgets.
@Test
@PortraitLandscape
public void testWidgets() throws Exception {
// Test opening widgets.
executeOnLauncher(launcher -> assertTrue("Widgets is initially opened", getWidgetsView(launcher) == null));
Widgets widgets = mLauncher.getWorkspace().openAllWidgets();
assertNotNull("openAllWidgets() returned null", widgets);
widgets = mLauncher.getAllWidgets();
assertNotNull("getAllWidgets() returned null", widgets);
executeOnLauncher(launcher -> assertTrue("Widgets is not shown", getWidgetsView(launcher).isShown()));
executeOnLauncher(launcher -> assertEquals("Widgets is scrolled upon opening", 0, getWidgetsScroll(launcher)));
// Test flinging widgets.
widgets.flingForward();
Integer flingForwardY = getFromLauncher(launcher -> getWidgetsScroll(launcher));
executeOnLauncher(launcher -> assertTrue("Flinging forward didn't scroll widgets", flingForwardY > 0));
widgets.flingBackward();
executeOnLauncher(launcher -> assertTrue("Flinging backward didn't scroll widgets", getWidgetsScroll(launcher) < flingForwardY));
mLauncher.pressHome();
waitForLauncherCondition("Widgets were not closed", launcher -> getWidgetsView(launcher) == null);
}
Aggregations