Search in sources :

Example 1 with AddToHomeScreenPrompt

use of com.android.launcher3.tapl.AddToHomeScreenPrompt in project Neo-Launcher by NeoApplications.

the class RequestPinItemTest method runTest.

private void runTest(String activityMethod, boolean isWidget, ItemOperator itemMatcher, Intent... commandIntents) throws Throwable {
    if (!Utilities.ATLEAST_OREO) {
        return;
    }
    clearHomescreen();
    mDevice.pressHome();
    // Open Pin item activity
    BlockingBroadcastReceiver openMonitor = new BlockingBroadcastReceiver(RequestPinItemActivity.class.getName());
    mLauncher.getWorkspace().switchToAllApps().getAppIcon("Test Pin Item").launch(getAppPackageName());
    assertNotNull(openMonitor.blockingGetExtraIntent());
    // Set callback
    PendingIntent callback = PendingIntent.getBroadcast(mTargetContext, 0, new Intent(mCallbackAction), PendingIntent.FLAG_ONE_SHOT);
    mTargetContext.sendBroadcast(RequestPinItemActivity.getCommandIntent(RequestPinItemActivity.class, "setCallback").putExtra(RequestPinItemActivity.EXTRA_PARAM + "0", callback));
    for (Intent command : commandIntents) {
        mTargetContext.sendBroadcast(command);
    }
    // call the requested method to start the flow
    mTargetContext.sendBroadcast(RequestPinItemActivity.getCommandIntent(RequestPinItemActivity.class, activityMethod));
    final AddToHomeScreenPrompt addToHomeScreenPrompt = mLauncher.getAddToHomeScreenPrompt();
    // Accept confirmation:
    BlockingBroadcastReceiver resultReceiver = new BlockingBroadcastReceiver(mCallbackAction);
    addToHomeScreenPrompt.addAutomatically();
    Intent result = resultReceiver.blockingGetIntent();
    assertNotNull(result);
    mAppWidgetId = result.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1);
    if (isWidget) {
        assertNotSame(-1, mAppWidgetId);
    }
    // Go back to home
    mLauncher.pressHome();
    Wait.atMost(null, new ItemSearchCondition(itemMatcher), DEFAULT_ACTIVITY_TIMEOUT);
}
Also used : AddToHomeScreenPrompt(com.android.launcher3.tapl.AddToHomeScreenPrompt) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent) RequestPinItemActivity(com.android.launcher3.testcomponent.RequestPinItemActivity)

Example 2 with AddToHomeScreenPrompt

use of com.android.launcher3.tapl.AddToHomeScreenPrompt in project android_packages_apps_Launcher3 by ArrowOS.

the class RequestPinItemTest method runTest.

private void runTest(String activityMethod, boolean isWidget, ItemOperator itemMatcher, Intent... commandIntents) throws Throwable {
    clearHomescreen();
    mDevice.pressHome();
    // Open Pin item activity
    BlockingBroadcastReceiver openMonitor = new BlockingBroadcastReceiver(RequestPinItemActivity.class.getName());
    mLauncher.getWorkspace().switchToAllApps().getAppIcon("Test Pin Item").launch(getAppPackageName());
    assertNotNull(openMonitor.blockingGetExtraIntent());
    // Set callback
    PendingIntent callback = PendingIntent.getBroadcast(mTargetContext, 0, new Intent(mCallbackAction), PendingIntent.FLAG_ONE_SHOT);
    mTargetContext.sendBroadcast(RequestPinItemActivity.getCommandIntent(RequestPinItemActivity.class, "setCallback").putExtra(RequestPinItemActivity.EXTRA_PARAM + "0", callback));
    for (Intent command : commandIntents) {
        mTargetContext.sendBroadcast(command);
    }
    // call the requested method to start the flow
    mTargetContext.sendBroadcast(RequestPinItemActivity.getCommandIntent(RequestPinItemActivity.class, activityMethod));
    final AddToHomeScreenPrompt addToHomeScreenPrompt = mLauncher.getAddToHomeScreenPrompt();
    // Accept confirmation:
    BlockingBroadcastReceiver resultReceiver = new BlockingBroadcastReceiver(mCallbackAction);
    addToHomeScreenPrompt.addAutomatically();
    Intent result = resultReceiver.blockingGetIntent();
    assertNotNull(result);
    mAppWidgetId = result.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1);
    if (isWidget) {
        assertNotSame(-1, mAppWidgetId);
    }
    // Go back to home
    mLauncher.pressHome();
    Wait.atMost("", new ItemSearchCondition(itemMatcher), DEFAULT_ACTIVITY_TIMEOUT, mLauncher);
}
Also used : AddToHomeScreenPrompt(com.android.launcher3.tapl.AddToHomeScreenPrompt) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent) RequestPinItemActivity(com.android.launcher3.testcomponent.RequestPinItemActivity)

Example 3 with AddToHomeScreenPrompt

use of com.android.launcher3.tapl.AddToHomeScreenPrompt in project android_packages_apps_404Launcher by P-404.

the class RequestPinItemTest method runTest.

private void runTest(String activityMethod, boolean isWidget, ItemOperator itemMatcher, Intent... commandIntents) throws Throwable {
    clearHomescreen();
    mDevice.pressHome();
    // Open Pin item activity
    BlockingBroadcastReceiver openMonitor = new BlockingBroadcastReceiver(RequestPinItemActivity.class.getName());
    mLauncher.getWorkspace().switchToAllApps().getAppIcon("Test Pin Item").launch(getAppPackageName());
    assertNotNull(openMonitor.blockingGetExtraIntent());
    // Set callback
    PendingIntent callback = PendingIntent.getBroadcast(mTargetContext, 0, new Intent(mCallbackAction), PendingIntent.FLAG_ONE_SHOT);
    mTargetContext.sendBroadcast(RequestPinItemActivity.getCommandIntent(RequestPinItemActivity.class, "setCallback").putExtra(RequestPinItemActivity.EXTRA_PARAM + "0", callback));
    for (Intent command : commandIntents) {
        mTargetContext.sendBroadcast(command);
    }
    // call the requested method to start the flow
    mTargetContext.sendBroadcast(RequestPinItemActivity.getCommandIntent(RequestPinItemActivity.class, activityMethod));
    final AddToHomeScreenPrompt addToHomeScreenPrompt = mLauncher.getAddToHomeScreenPrompt();
    // Accept confirmation:
    BlockingBroadcastReceiver resultReceiver = new BlockingBroadcastReceiver(mCallbackAction);
    addToHomeScreenPrompt.addAutomatically();
    Intent result = resultReceiver.blockingGetIntent();
    assertNotNull(result);
    mAppWidgetId = result.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1);
    if (isWidget) {
        assertNotSame(-1, mAppWidgetId);
    }
    // Go back to home
    mLauncher.pressHome();
    Wait.atMost("", new ItemSearchCondition(itemMatcher), DEFAULT_ACTIVITY_TIMEOUT, mLauncher);
}
Also used : AddToHomeScreenPrompt(com.android.launcher3.tapl.AddToHomeScreenPrompt) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent) RequestPinItemActivity(com.android.launcher3.testcomponent.RequestPinItemActivity)

Example 4 with AddToHomeScreenPrompt

use of com.android.launcher3.tapl.AddToHomeScreenPrompt in project android_packages_apps_Launcher3 by crdroidandroid.

the class RequestPinItemTest method runTest.

private void runTest(String activityMethod, boolean isWidget, ItemOperator itemMatcher, Intent... commandIntents) throws Throwable {
    clearHomescreen();
    mDevice.pressHome();
    // Open Pin item activity
    BlockingBroadcastReceiver openMonitor = new BlockingBroadcastReceiver(RequestPinItemActivity.class.getName());
    mLauncher.getWorkspace().switchToAllApps().getAppIcon("Test Pin Item").launch(getAppPackageName());
    assertNotNull(openMonitor.blockingGetExtraIntent());
    // Set callback
    PendingIntent callback = PendingIntent.getBroadcast(mTargetContext, 0, new Intent(mCallbackAction), PendingIntent.FLAG_ONE_SHOT);
    mTargetContext.sendBroadcast(RequestPinItemActivity.getCommandIntent(RequestPinItemActivity.class, "setCallback").putExtra(RequestPinItemActivity.EXTRA_PARAM + "0", callback));
    for (Intent command : commandIntents) {
        mTargetContext.sendBroadcast(command);
    }
    // call the requested method to start the flow
    mTargetContext.sendBroadcast(RequestPinItemActivity.getCommandIntent(RequestPinItemActivity.class, activityMethod));
    final AddToHomeScreenPrompt addToHomeScreenPrompt = mLauncher.getAddToHomeScreenPrompt();
    // Accept confirmation:
    BlockingBroadcastReceiver resultReceiver = new BlockingBroadcastReceiver(mCallbackAction);
    addToHomeScreenPrompt.addAutomatically();
    Intent result = resultReceiver.blockingGetIntent();
    assertNotNull(result);
    mAppWidgetId = result.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1);
    if (isWidget) {
        assertNotSame(-1, mAppWidgetId);
    }
    // Go back to home
    mLauncher.pressHome();
    Wait.atMost("", new ItemSearchCondition(itemMatcher), DEFAULT_ACTIVITY_TIMEOUT, mLauncher);
}
Also used : AddToHomeScreenPrompt(com.android.launcher3.tapl.AddToHomeScreenPrompt) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent) RequestPinItemActivity(com.android.launcher3.testcomponent.RequestPinItemActivity)

Example 5 with AddToHomeScreenPrompt

use of com.android.launcher3.tapl.AddToHomeScreenPrompt in project android_packages_apps_Trebuchet by LineageOS.

the class RequestPinItemTest method runTest.

private void runTest(String activityMethod, boolean isWidget, ItemOperator itemMatcher, Intent... commandIntents) throws Throwable {
    if (!Utilities.ATLEAST_OREO) {
        return;
    }
    clearHomescreen();
    mDevice.pressHome();
    // Open Pin item activity
    BlockingBroadcastReceiver openMonitor = new BlockingBroadcastReceiver(RequestPinItemActivity.class.getName());
    mLauncher.getWorkspace().switchToAllApps().getAppIcon("Test Pin Item").launch(getAppPackageName());
    assertNotNull(openMonitor.blockingGetExtraIntent());
    // Set callback
    PendingIntent callback = PendingIntent.getBroadcast(mTargetContext, 0, new Intent(mCallbackAction), PendingIntent.FLAG_ONE_SHOT);
    mTargetContext.sendBroadcast(RequestPinItemActivity.getCommandIntent(RequestPinItemActivity.class, "setCallback").putExtra(RequestPinItemActivity.EXTRA_PARAM + "0", callback));
    for (Intent command : commandIntents) {
        mTargetContext.sendBroadcast(command);
    }
    // call the requested method to start the flow
    mTargetContext.sendBroadcast(RequestPinItemActivity.getCommandIntent(RequestPinItemActivity.class, activityMethod));
    final AddToHomeScreenPrompt addToHomeScreenPrompt = mLauncher.getAddToHomeScreenPrompt();
    // Accept confirmation:
    BlockingBroadcastReceiver resultReceiver = new BlockingBroadcastReceiver(mCallbackAction);
    addToHomeScreenPrompt.addAutomatically();
    Intent result = resultReceiver.blockingGetIntent();
    assertNotNull(result);
    mAppWidgetId = result.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1);
    if (isWidget) {
        assertNotSame(-1, mAppWidgetId);
    }
    // Go back to home
    mLauncher.pressHome();
    Wait.atMost("", new ItemSearchCondition(itemMatcher), DEFAULT_ACTIVITY_TIMEOUT, mLauncher);
}
Also used : AddToHomeScreenPrompt(com.android.launcher3.tapl.AddToHomeScreenPrompt) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent) RequestPinItemActivity(com.android.launcher3.testcomponent.RequestPinItemActivity)

Aggregations

PendingIntent (android.app.PendingIntent)7 Intent (android.content.Intent)7 AddToHomeScreenPrompt (com.android.launcher3.tapl.AddToHomeScreenPrompt)7 RequestPinItemActivity (com.android.launcher3.testcomponent.RequestPinItemActivity)7