Commit 36338c27 authored by Peter Kotwicz's avatar Peter Kotwicz Committed by Commit Bot

[Android WebAPK] Fix WebAPK Share target POST

This CL fixes WebAPK share target POST which regressed as a result of
https://chromium-review.googlesource.com/c/chromium/src/+/2148380

BUG=1082895

Change-Id: Ib2ab90d70e11d82ede07a67186e8b2a865934783
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2203017
Commit-Queue: Peter Kotwicz <pkotwicz@chromium.org>
Reviewed-by: default avatarGlenn Hartmann <hartmanng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#769018}
parent 0e2e55ff
...@@ -39,7 +39,9 @@ public class WebappIntentUtils { ...@@ -39,7 +39,9 @@ public class WebappIntentUtils {
ShortcutHelper.EXTRA_SOURCE, WebApkConstants.EXTRA_WEBAPK_PACKAGE_NAME, ShortcutHelper.EXTRA_SOURCE, WebApkConstants.EXTRA_WEBAPK_PACKAGE_NAME,
WebApkConstants.EXTRA_SPLASH_PROVIDED_BY_WEBAPK, WebApkConstants.EXTRA_SPLASH_PROVIDED_BY_WEBAPK,
WebApkConstants.EXTRA_WEBAPK_LAUNCH_TIME, WebApkConstants.EXTRA_WEBAPK_LAUNCH_TIME,
WebApkConstants.EXTRA_NEW_STYLE_SPLASH_SHOWN_TIME}; WebApkConstants.EXTRA_NEW_STYLE_SPLASH_SHOWN_TIME,
WebApkConstants.EXTRA_WEBAPK_SELECTED_SHARE_TARGET_ACTIVITY_CLASS_NAME,
Intent.EXTRA_SUBJECT, Intent.EXTRA_TEXT, Intent.EXTRA_STREAM};
/** /**
* Converts color from signed Integer where an unspecified color is represented as null to * Converts color from signed Integer where an unspecified color is represented as null to
......
...@@ -9,6 +9,7 @@ import static org.junit.Assert.assertFalse; ...@@ -9,6 +9,7 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull; import static org.junit.Assert.assertNull;
import android.content.Intent; import android.content.Intent;
import android.net.Uri;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
...@@ -17,6 +18,8 @@ import org.robolectric.annotation.Config; ...@@ -17,6 +18,8 @@ import org.robolectric.annotation.Config;
import org.chromium.base.test.BaseRobolectricTestRunner; import org.chromium.base.test.BaseRobolectricTestRunner;
import org.chromium.chrome.browser.ShortcutHelper; import org.chromium.chrome.browser.ShortcutHelper;
import java.util.ArrayList;
/** /**
* Tests for {@link WebappIntentUtils}. * Tests for {@link WebappIntentUtils}.
*/ */
...@@ -35,6 +38,7 @@ public class WebappIntentUtilsTest { ...@@ -35,6 +38,7 @@ public class WebappIntentUtilsTest {
assertFalse(toIntent.hasExtra(ShortcutHelper.EXTRA_IS_ICON_ADAPTIVE)); assertFalse(toIntent.hasExtra(ShortcutHelper.EXTRA_IS_ICON_ADAPTIVE));
assertFalse(toIntent.hasExtra(ShortcutHelper.EXTRA_DISPLAY_MODE)); assertFalse(toIntent.hasExtra(ShortcutHelper.EXTRA_DISPLAY_MODE));
assertFalse(toIntent.hasExtra(ShortcutHelper.EXTRA_BACKGROUND_COLOR)); assertFalse(toIntent.hasExtra(ShortcutHelper.EXTRA_BACKGROUND_COLOR));
assertFalse(toIntent.hasExtra(Intent.EXTRA_STREAM));
} }
/** /**
...@@ -59,6 +63,35 @@ public class WebappIntentUtilsTest { ...@@ -59,6 +63,35 @@ public class WebappIntentUtilsTest {
assertEquals(1L, toIntent.getLongExtra(ShortcutHelper.EXTRA_BACKGROUND_COLOR, 0L)); assertEquals(1L, toIntent.getLongExtra(ShortcutHelper.EXTRA_BACKGROUND_COLOR, 0L));
} }
/**
* Test that {@link WebappIntentUtils#copyWebApkLaunchIntentExtras()} properly copies both of
* the data types which can be used for Intent.EXTRA_STREAM.
*/
@Test
public void testCopyStream() {
{
ArrayList fromList = new ArrayList<Uri>();
fromList.add(Uri.parse("https://www.google.com/"));
fromList.add(Uri.parse("https://www.blogspot.com/"));
Intent fromIntent = new Intent();
fromIntent.putExtra(Intent.EXTRA_STREAM, fromList);
Intent toIntent = new Intent();
WebappIntentUtils.copyWebApkLaunchIntentExtras(fromIntent, toIntent);
assertEquals(fromList, toIntent.getParcelableArrayListExtra(Intent.EXTRA_STREAM));
}
{
Uri fromUri = Uri.parse("https://www.google.com/");
Intent fromIntent = new Intent();
fromIntent.putExtra(Intent.EXTRA_STREAM, fromUri);
Intent toIntent = new Intent();
WebappIntentUtils.copyWebApkLaunchIntentExtras(fromIntent, toIntent);
assertEquals(fromUri, toIntent.getParcelableExtra(Intent.EXTRA_STREAM));
}
}
/** /**
* Test that {@link WebappIntentUtils#copyWebappLaunchIntentExtras()} does not copy non white * Test that {@link WebappIntentUtils#copyWebappLaunchIntentExtras()} does not copy non white
* listed intent extras. * listed intent extras.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment