DeepLinkAction extends Action { @NonNull @Override public ActionResult perform(@NonNull ActionArguments arguments) { Uri uri = UriUtils.parse(arguments.getValue().getString()); if (uri == null) { return ActionResult.newEmptyResult(); } Logger.info("Deep linking: %s", uri); DeepLinkListener listener = UAirship.shared().getDeepLinkListener(); if (listener != null && listener.onDeepLink(uri.toString())) { Logger.info("Calling through to deep link listener with uri string: %s", uri.toString()); return ActionResult.newResult(arguments.getValue()); } Intent intent = new Intent(Intent.ACTION_VIEW, uri) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) .setPackage(UAirship.getPackageName()); PushMessage message = arguments.getMetadata().getParcelable(ActionArguments.PUSH_MESSAGE_METADATA); if (message != null) { intent.putExtra(PushManager.EXTRA_PUSH_MESSAGE_BUNDLE, message.getPushBundle()); } UAirship.getApplicationContext().startActivity(intent); return ActionResult.newResult(arguments.getValue()); }  @NonNull @Override ActionResult perform(@NonNull ActionArguments arguments); @Override boolean acceptsArguments(@NonNull ActionArguments arguments); @Override boolean shouldRunOnMainThread(); @NonNull
    static final String DEFAULT_REGISTRY_NAME; @NonNull
    static final String DEFAULT_REGISTRY_SHORT_NAME; }
@Test public void testPerform() { ActionArguments args = ActionTestUtils.createArgs(Action.SITUATION_WEB_VIEW_INVOCATION, "http: ActionResult result = action.perform(args); assertEquals("Value should be the uri", "http: validateLastActivity("http: args = ActionTestUtils.createArgs(Action.SITUATION_WEB_VIEW_INVOCATION, "adfadfafdsaf adfa dsfadfsa example"); result = action.perform(args); assertEquals("Value should be the uri", "adfadfafdsaf adfa dsfadfsa example", result.getValue().getString()); validateLastActivity("adfadfafdsaf adfa dsfadfsa example", null); }
@Test public void testDeepLinkListener() { final DeepLinkActionTest.TestDeepLinkListener listener = new DeepLinkActionTest.TestDeepLinkListener() { @Override public boolean onDeepLink(@NonNull String deepLink) { assertEquals("Value should be the deep link uri as a string", "http: return super.onDeepLink(deepLink); } }; UAirship.shared().setDeepLinkListener(listener); ActionArguments args = ActionTestUtils.createArgs(Action.SITUATION_WEB_VIEW_INVOCATION, "http: ActionResult result = action.perform(args); assertEquals(result.getStatus(), ActionResult.STATUS_COMPLETED); assertEquals("Value should be the uri", "http: }
@Test public void testPerformPushMessage() { Bundle bundle = new Bundle(); bundle.putString("oh", "hi"); PushMessage message = new PushMessage(bundle); Bundle metadata = new Bundle(); metadata.putParcelable(ActionArguments.PUSH_MESSAGE_METADATA, message); ActionArguments args = ActionTestUtils.createArgs(Action.SITUATION_PUSH_OPENED, "http: ActionResult result = action.perform(args); assertEquals("Value should be the uri", "http: validateLastActivity("http: }