Commit f73174ec authored by Sophey Dong's avatar Sophey Dong Committed by Commit Bot

Reland "[ShareCCT] Implement sharing in the toolbar and by default in CCT."

This is a reland of 6769a912
This caches the SHARE_BY_DEFAULT_IN_CCT flag, which should prevent JNI not enabled crashes.

Original change's description:
> [ShareCCT] Implement sharing in the toolbar and by default in CCT.
>
> Bug: 1135311
> Change-Id: I967300591d383a21b9f3f40233422b763180ddb0
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2459403
> Reviewed-by: Tanya Gupta <tgupta@chromium.org>
> Reviewed-by: Andrew Grieve <agrieve@chromium.org>
> Reviewed-by: Peter Conn <peconn@chromium.org>
> Commit-Queue: Sophey Dong <sophey@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#820029}

Bug: 1135311
Change-Id: I46e7b10e56f092e6fcec5c07b1610dfd71649ca5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2501189Reviewed-by: default avatarPeter Conn <peconn@chromium.org>
Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Reviewed-by: default avatarTanya Gupta <tgupta@chromium.org>
Reviewed-by: default avatarHenrique Nakashima <hnakashima@chromium.org>
Commit-Queue: Sophey Dong <sophey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821864}
parent e8bb8de8
...@@ -958,6 +958,7 @@ android_library("chrome_test_util_java") { ...@@ -958,6 +958,7 @@ android_library("chrome_test_util_java") {
"//base:base_java", "//base:base_java",
"//base:base_java_test_support", "//base:base_java_test_support",
"//chrome/android:chrome_java", "//chrome/android:chrome_java",
"//chrome/browser/flags:java",
"//chrome/browser/tab:java", "//chrome/browser/tab:java",
"//chrome/browser/ui/android/appmenu:java", "//chrome/browser/ui/android/appmenu:java",
"//chrome/test/android:chrome_java_test_support", "//chrome/test/android:chrome_java_test_support",
......
...@@ -461,6 +461,7 @@ chrome_java_sources = [ ...@@ -461,6 +461,7 @@ chrome_java_sources = [
"java/src/org/chromium/chrome/browser/customtabs/CustomTabsClientFileProcessor.java", "java/src/org/chromium/chrome/browser/customtabs/CustomTabsClientFileProcessor.java",
"java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnection.java", "java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnection.java",
"java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnectionServiceImpl.java", "java/src/org/chromium/chrome/browser/customtabs/CustomTabsConnectionServiceImpl.java",
"java/src/org/chromium/chrome/browser/customtabs/CustomTabsShareBroadcastReceiver.java",
"java/src/org/chromium/chrome/browser/customtabs/FirstMeaningfulPaintObserver.java", "java/src/org/chromium/chrome/browser/customtabs/FirstMeaningfulPaintObserver.java",
"java/src/org/chromium/chrome/browser/customtabs/HiddenTabHolder.java", "java/src/org/chromium/chrome/browser/customtabs/HiddenTabHolder.java",
"java/src/org/chromium/chrome/browser/customtabs/IncognitoCustomTabIntentDataProvider.java", "java/src/org/chromium/chrome/browser/customtabs/IncognitoCustomTabIntentDataProvider.java",
......
...@@ -924,6 +924,10 @@ ...@@ -924,6 +924,10 @@
android:exported="false" android:exported="false"
android:name="org.chromium.chrome.browser.browserservices.ui.trustedwebactivity.DisclosureAcceptanceBroadcastReceiver"> android:name="org.chromium.chrome.browser.browserservices.ui.trustedwebactivity.DisclosureAcceptanceBroadcastReceiver">
</receiver> # DIFF-ANCHOR: a31e6ce5 </receiver> # DIFF-ANCHOR: a31e6ce5
<receiver # DIFF-ANCHOR: 779ee86b
android:exported="false"
android:name="org.chromium.chrome.browser.customtabs.CustomTabsShareBroadcastReceiver">
</receiver> # DIFF-ANCHOR: 779ee86b
<receiver # DIFF-ANCHOR: bccc7d87 <receiver # DIFF-ANCHOR: bccc7d87
android:exported="false" android:exported="false"
android:name="org.chromium.chrome.browser.locale.LocaleChangedBroadcastReceiver"> android:name="org.chromium.chrome.browser.locale.LocaleChangedBroadcastReceiver">
......
...@@ -862,6 +862,10 @@ ...@@ -862,6 +862,10 @@
android:exported="false" android:exported="false"
android:name="org.chromium.chrome.browser.browserservices.ui.trustedwebactivity.DisclosureAcceptanceBroadcastReceiver"> android:name="org.chromium.chrome.browser.browserservices.ui.trustedwebactivity.DisclosureAcceptanceBroadcastReceiver">
</receiver> # DIFF-ANCHOR: a31e6ce5 </receiver> # DIFF-ANCHOR: a31e6ce5
<receiver # DIFF-ANCHOR: 779ee86b
android:exported="false"
android:name="org.chromium.chrome.browser.customtabs.CustomTabsShareBroadcastReceiver">
</receiver> # DIFF-ANCHOR: 779ee86b
<receiver # DIFF-ANCHOR: bccc7d87 <receiver # DIFF-ANCHOR: bccc7d87
android:exported="false" android:exported="false"
android:name="org.chromium.chrome.browser.locale.LocaleChangedBroadcastReceiver"> android:name="org.chromium.chrome.browser.locale.LocaleChangedBroadcastReceiver">
......
...@@ -1105,6 +1105,9 @@ by a child template that "extends" this file. ...@@ -1105,6 +1105,9 @@ by a child template that "extends" this file.
<receiver android:name="org.chromium.chrome.browser.app.send_tab_to_self.SendTabToSelfNotificationReceiver" <receiver android:name="org.chromium.chrome.browser.app.send_tab_to_self.SendTabToSelfNotificationReceiver"
android:exported="false"/> android:exported="false"/>
<receiver android:name="org.chromium.chrome.browser.customtabs.CustomTabsShareBroadcastReceiver"
android:exported="false"/>
<receiver android:name="org.chromium.chrome.browser.sharing.click_to_call.ClickToCallMessageHandler$TapReceiver" <receiver android:name="org.chromium.chrome.browser.sharing.click_to_call.ClickToCallMessageHandler$TapReceiver"
android:exported="false"/> android:exported="false"/>
<receiver android:name="org.chromium.chrome.browser.sharing.shared_clipboard.SharedClipboardMessageHandler$TapReceiver" <receiver android:name="org.chromium.chrome.browser.sharing.shared_clipboard.SharedClipboardMessageHandler$TapReceiver"
......
...@@ -64,6 +64,7 @@ public class ChromeCachedFlags { ...@@ -64,6 +64,7 @@ public class ChromeCachedFlags {
ChromeFeatureList.PAINT_PREVIEW_SHOW_ON_STARTUP, ChromeFeatureList.PAINT_PREVIEW_SHOW_ON_STARTUP,
ChromeFeatureList.PRIORITIZE_BOOTSTRAP_TASKS, ChromeFeatureList.PRIORITIZE_BOOTSTRAP_TASKS,
ChromeFeatureList.REPORT_FEED_USER_ACTIONS, ChromeFeatureList.REPORT_FEED_USER_ACTIONS,
ChromeFeatureList.SHARE_BY_DEFAULT_IN_CCT,
ChromeFeatureList.START_SURFACE_ANDROID, ChromeFeatureList.START_SURFACE_ANDROID,
ChromeFeatureList.SWAP_PIXEL_FORMAT_TO_FIX_CONVERT_FROM_TRANSLUCENT, ChromeFeatureList.SWAP_PIXEL_FORMAT_TO_FIX_CONVERT_FROM_TRANSLUCENT,
ChromeFeatureList.TAB_GRID_LAYOUT_ANDROID, ChromeFeatureList.TAB_GRID_LAYOUT_ANDROID,
......
...@@ -28,7 +28,9 @@ import androidx.browser.customtabs.CustomTabsIntent; ...@@ -28,7 +28,9 @@ import androidx.browser.customtabs.CustomTabsIntent;
import org.chromium.base.IntentUtils; import org.chromium.base.IntentUtils;
import org.chromium.base.Log; import org.chromium.base.Log;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.toolbar.ToolbarColors;
import org.chromium.components.browser_ui.widget.TintedDrawable; import org.chromium.components.browser_ui.widget.TintedDrawable;
import org.chromium.ui.util.ColorUtils;
import org.chromium.ui.widget.Toast; import org.chromium.ui.widget.Toast;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -237,6 +239,26 @@ public class CustomButtonParams { ...@@ -237,6 +239,26 @@ public class CustomButtonParams {
return new CustomButtonParams(id, bitmap, description, pendingIntent, tinted, onToolbar); return new CustomButtonParams(id, bitmap, description, pendingIntent, tinted, onToolbar);
} }
/**
* Creates and returns a {@link CustomButtonParams} for a share button in the toolbar.
*/
static CustomButtonParams createShareButton(Context context, int backgroundColor) {
int id = CustomTabsIntent.TOOLBAR_ACTION_BUTTON_ID;
String description = context.getResources().getString(R.string.share);
Intent shareIntent = new Intent(context, CustomTabsShareBroadcastReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(
context, 0, shareIntent, PendingIntent.FLAG_UPDATE_CURRENT);
TintedDrawable drawable =
TintedDrawable.constructTintedDrawable(context, R.drawable.ic_share_white_24dp);
boolean useLightTint = ColorUtils.shouldUseLightForegroundOnBackground(backgroundColor);
drawable.setTint(ToolbarColors.getThemedToolbarIconTint(context, useLightTint));
Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap();
return new CustomButtonParams(
id, bitmap, description, pendingIntent, /*tinted=*/true, /*onToolbar=*/true);
}
/** /**
* @return The bitmap contained in the given {@link Bundle}. Will return null if input is * @return The bitmap contained in the given {@link Bundle}. Will return null if input is
* invalid. * invalid.
......
...@@ -44,6 +44,7 @@ import org.chromium.chrome.browser.IntentHandler; ...@@ -44,6 +44,7 @@ import org.chromium.chrome.browser.IntentHandler;
import org.chromium.chrome.browser.app.ChromeActivity; import org.chromium.chrome.browser.app.ChromeActivity;
import org.chromium.chrome.browser.browserservices.BrowserServicesIntentDataProvider; import org.chromium.chrome.browser.browserservices.BrowserServicesIntentDataProvider;
import org.chromium.chrome.browser.flags.ActivityType; import org.chromium.chrome.browser.flags.ActivityType;
import org.chromium.chrome.browser.flags.CachedFeatureFlags;
import org.chromium.chrome.browser.flags.ChromeFeatureList; import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.version.ChromeVersionInfo; import org.chromium.chrome.browser.version.ChromeVersionInfo;
import org.chromium.components.browser_ui.styles.ChromeColors; import org.chromium.components.browser_ui.styles.ChromeColors;
...@@ -201,7 +202,7 @@ public class CustomTabIntentDataProvider extends BrowserServicesIntentDataProvid ...@@ -201,7 +202,7 @@ public class CustomTabIntentDataProvider extends BrowserServicesIntentDataProvid
private List<CustomButtonParams> mCustomButtonParams; private List<CustomButtonParams> mCustomButtonParams;
private Drawable mCloseButtonIcon; private Drawable mCloseButtonIcon;
private List<Pair<String, PendingIntent>> mMenuEntries = new ArrayList<>(); private List<Pair<String, PendingIntent>> mMenuEntries = new ArrayList<>();
private boolean mShowShareItem; private boolean mShowShareItemInMenu;
private List<CustomButtonParams> mToolbarButtons = new ArrayList<>(1); private List<CustomButtonParams> mToolbarButtons = new ArrayList<>(1);
private List<CustomButtonParams> mBottombarButtons = new ArrayList<>(2); private List<CustomButtonParams> mBottombarButtons = new ArrayList<>(2);
private RemoteViews mRemoteViews; private RemoteViews mRemoteViews;
...@@ -312,8 +313,8 @@ public class CustomTabIntentDataProvider extends BrowserServicesIntentDataProvid ...@@ -312,8 +313,8 @@ public class CustomTabIntentDataProvider extends BrowserServicesIntentDataProvid
List<Bundle> menuItems = List<Bundle> menuItems =
IntentUtils.getParcelableArrayListExtra(intent, CustomTabsIntent.EXTRA_MENU_ITEMS); IntentUtils.getParcelableArrayListExtra(intent, CustomTabsIntent.EXTRA_MENU_ITEMS);
updateExtraMenuItems(menuItems); updateExtraMenuItems(menuItems);
addShareOption(intent, context);
mActivityType = IntentUtils.safeGetBooleanExtra( mActivityType = IntentUtils.safeGetBooleanExtra(
intent, TrustedWebUtils.EXTRA_LAUNCH_AS_TRUSTED_WEB_ACTIVITY, false) intent, TrustedWebUtils.EXTRA_LAUNCH_AS_TRUSTED_WEB_ACTIVITY, false)
...@@ -324,9 +325,6 @@ public class CustomTabIntentDataProvider extends BrowserServicesIntentDataProvid ...@@ -324,9 +325,6 @@ public class CustomTabIntentDataProvider extends BrowserServicesIntentDataProvid
mTrustedWebActivityDisplayMode = resolveTwaDisplayMode(); mTrustedWebActivityDisplayMode = resolveTwaDisplayMode();
mTitleVisibilityState = IntentUtils.safeGetIntExtra( mTitleVisibilityState = IntentUtils.safeGetIntExtra(
intent, CustomTabsIntent.EXTRA_TITLE_VISIBILITY_STATE, CustomTabsIntent.NO_TITLE); intent, CustomTabsIntent.EXTRA_TITLE_VISIBILITY_STATE, CustomTabsIntent.NO_TITLE);
mShowShareItem = IntentUtils.safeGetBooleanExtra(intent,
CustomTabsIntent.EXTRA_DEFAULT_SHARE_MENU_ITEM,
mIsOpenedByChrome && mUiType == CustomTabsUiType.DEFAULT);
mRemoteViews = mRemoteViews =
IntentUtils.safeGetParcelableExtra(intent, CustomTabsIntent.EXTRA_REMOTEVIEWS); IntentUtils.safeGetParcelableExtra(intent, CustomTabsIntent.EXTRA_REMOTEVIEWS);
mClickableViewIds = IntentUtils.safeGetIntArrayExtra( mClickableViewIds = IntentUtils.safeGetIntArrayExtra(
...@@ -463,6 +461,39 @@ public class CustomTabIntentDataProvider extends BrowserServicesIntentDataProvid ...@@ -463,6 +461,39 @@ public class CustomTabIntentDataProvider extends BrowserServicesIntentDataProvid
return MAX_CUSTOM_TOOLBAR_ITEMS; return MAX_CUSTOM_TOOLBAR_ITEMS;
} }
/**
* Adds a share option to the custom tab according to the {@link
* CustomTabsIntent#EXTRA_SHARE_STATE} stored in the intent.
*
* <p>Shows share options according to the following rules:
*
* <ul>
* <li>If {@link CustomTabsIntent#SHARE_STATE_ON} or
* {@link CustomTabsIntent#SHARE_STATE_DEFAULT}, add to the top toolbar if empty, otherwise
* add to the overflow menu if it is not customized.
* <li>If {@link CustomTabsIntent#SHARE_STATE_OFF}, add to the overflow menu depending on
* {@link CustomTabsIntent#EXTRA_DEFAULT_SHARE_MENU_ITEM}.
* </ul>
*/
private void addShareOption(Intent intent, Context context) {
int shareState = IntentUtils.safeGetIntExtra(
intent, CustomTabsIntent.EXTRA_SHARE_STATE, CustomTabsIntent.SHARE_STATE_DEFAULT);
if (shareState == CustomTabsIntent.SHARE_STATE_ON
|| (shareState == CustomTabsIntent.SHARE_STATE_DEFAULT
&& CachedFeatureFlags.isEnabled(
ChromeFeatureList.SHARE_BY_DEFAULT_IN_CCT))) {
if (mToolbarButtons.isEmpty()) {
mToolbarButtons.add(CustomButtonParams.createShareButton(context, mToolbarColor));
} else if (mMenuEntries.isEmpty()) {
mShowShareItemInMenu = true;
}
} else {
mShowShareItemInMenu = IntentUtils.safeGetBooleanExtra(intent,
CustomTabsIntent.EXTRA_DEFAULT_SHARE_MENU_ITEM,
mIsOpenedByChrome && mUiType == CustomTabsUiType.DEFAULT);
}
}
/** /**
* Returns the color passed from the client app. * Returns the color passed from the client app.
*/ */
...@@ -665,7 +696,7 @@ public class CustomTabIntentDataProvider extends BrowserServicesIntentDataProvid ...@@ -665,7 +696,7 @@ public class CustomTabIntentDataProvider extends BrowserServicesIntentDataProvid
@Override @Override
public boolean shouldShowShareMenuItem() { public boolean shouldShowShareMenuItem() {
return mShowShareItem; return mShowShareItemInMenu;
} }
@Override @Override
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.customtabs;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
/**
* Receives shared content broadcast from Chrome Custom Tabs and shows a share sheet to share the
* url.
*/
public final class CustomTabsShareBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String url = intent.getDataString();
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_TEXT, url);
Intent chooserIntent = Intent.createChooser(shareIntent, null);
chooserIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(chooserIntent);
}
}
...@@ -948,6 +948,7 @@ public class CustomTabActivityTest { ...@@ -948,6 +948,7 @@ public class CustomTabActivityTest {
public void testActionButtonBadRatio() { public void testActionButtonBadRatio() {
Bitmap expectedIcon = createTestBitmap(60, 20); Bitmap expectedIcon = createTestBitmap(60, 20);
Intent intent = createMinimalCustomTabIntent(); Intent intent = createMinimalCustomTabIntent();
CustomTabsTestUtils.setShareState(intent, CustomTabsIntent.SHARE_STATE_OFF);
CustomTabsTestUtils.addActionButtonToIntent( CustomTabsTestUtils.addActionButtonToIntent(
intent, expectedIcon, "Good test", sIdToIncrement++); intent, expectedIcon, "Good test", sIdToIncrement++);
mCustomTabActivityTestRule.startCustomTabActivityWithIntent(intent); mCustomTabActivityTestRule.startCustomTabActivityWithIntent(intent);
......
...@@ -12,8 +12,10 @@ import org.hamcrest.Matchers; ...@@ -12,8 +12,10 @@ import org.hamcrest.Matchers;
import org.junit.Assert; import org.junit.Assert;
import org.chromium.base.ApplicationStatus; import org.chromium.base.ApplicationStatus;
import org.chromium.base.FeatureList;
import org.chromium.base.test.util.CallbackHelper; import org.chromium.base.test.util.CallbackHelper;
import org.chromium.chrome.browser.DeferredStartupHandler; import org.chromium.chrome.browser.DeferredStartupHandler;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.tab.EmptyTabObserver; import org.chromium.chrome.browser.tab.EmptyTabObserver;
import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tab.TabTestUtils; import org.chromium.chrome.browser.tab.TabTestUtils;
...@@ -21,6 +23,7 @@ import org.chromium.chrome.test.ChromeActivityTestRule; ...@@ -21,6 +23,7 @@ import org.chromium.chrome.test.ChromeActivityTestRule;
import org.chromium.content_public.browser.test.util.Criteria; import org.chromium.content_public.browser.test.util.Criteria;
import org.chromium.content_public.browser.test.util.CriteriaHelper; import org.chromium.content_public.browser.test.util.CriteriaHelper;
import java.util.Collections;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
...@@ -51,6 +54,10 @@ public class CustomTabActivityTestRule extends ChromeActivityTestRule<CustomTabA ...@@ -51,6 +54,10 @@ public class CustomTabActivityTestRule extends ChromeActivityTestRule<CustomTabA
@Override @Override
public void startActivityCompletely(Intent intent) { public void startActivityCompletely(Intent intent) {
if (!FeatureList.hasTestFeatures()) {
FeatureList.setTestFeatures(
Collections.singletonMap(ChromeFeatureList.SHARE_BY_DEFAULT_IN_CCT, true));
}
putCustomTabIdInIntent(intent); putCustomTabIdInIntent(intent);
int currentIntentId = getCustomTabIdFromIntent(intent); int currentIntentId = getCustomTabIdFromIntent(intent);
......
...@@ -279,4 +279,13 @@ public class CustomTabsTestUtils { ...@@ -279,4 +279,13 @@ public class CustomTabsTestUtils {
return Bitmap.createBitmap( return Bitmap.createBitmap(
(int) (widthDp * density), (int) (heightDp * density), Bitmap.Config.ARGB_8888); (int) (widthDp * density), (int) (heightDp * density), Bitmap.Config.ARGB_8888);
} }
/**
* Sets the {@link CustomTabsIntent.ShareState} of the custom tab.
* @param intent The intent to modify.
* @param shareState The {@link CustomTabsIntent.ShareState} being set.
*/
public static void setShareState(Intent intent, int shareState) {
intent.putExtra(CustomTabsIntent.EXTRA_SHARE_STATE, shareState);
}
} }
...@@ -25,6 +25,7 @@ import org.junit.Assert; ...@@ -25,6 +25,7 @@ import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.TestRule;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.Mockito; import org.mockito.Mockito;
...@@ -38,6 +39,7 @@ import org.chromium.chrome.browser.ChromeTabbedActivity; ...@@ -38,6 +39,7 @@ import org.chromium.chrome.browser.ChromeTabbedActivity;
import org.chromium.chrome.browser.customtabs.CustomTabActivity; import org.chromium.chrome.browser.customtabs.CustomTabActivity;
import org.chromium.chrome.browser.customtabs.CustomTabsTestUtils; import org.chromium.chrome.browser.customtabs.CustomTabsTestUtils;
import org.chromium.chrome.browser.document.ChromeLauncherActivity; import org.chromium.chrome.browser.document.ChromeLauncherActivity;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.locale.DefaultSearchEngineDialogHelperUtils; import org.chromium.chrome.browser.locale.DefaultSearchEngineDialogHelperUtils;
import org.chromium.chrome.browser.locale.LocaleManager; import org.chromium.chrome.browser.locale.LocaleManager;
import org.chromium.chrome.browser.locale.LocaleManager.SearchEnginePromoType; import org.chromium.chrome.browser.locale.LocaleManager.SearchEnginePromoType;
...@@ -46,6 +48,7 @@ import org.chromium.chrome.browser.privacy.settings.PrivacyPreferencesManager; ...@@ -46,6 +48,7 @@ import org.chromium.chrome.browser.privacy.settings.PrivacyPreferencesManager;
import org.chromium.chrome.browser.search_engines.TemplateUrlServiceFactory; import org.chromium.chrome.browser.search_engines.TemplateUrlServiceFactory;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner; import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.MultiActivityTestRule; import org.chromium.chrome.test.MultiActivityTestRule;
import org.chromium.chrome.test.util.browser.Features;
import org.chromium.components.policy.AbstractAppRestrictionsProvider; import org.chromium.components.policy.AbstractAppRestrictionsProvider;
import org.chromium.components.search_engines.TemplateUrl; import org.chromium.components.search_engines.TemplateUrl;
import org.chromium.content_public.browser.UiThreadTaskTraits; import org.chromium.content_public.browser.UiThreadTaskTraits;
...@@ -61,11 +64,14 @@ import java.util.Set; ...@@ -61,11 +64,14 @@ import java.util.Set;
* Integration test suite for the first run experience. * Integration test suite for the first run experience.
*/ */
@RunWith(ChromeJUnit4ClassRunner.class) @RunWith(ChromeJUnit4ClassRunner.class)
@Features.EnableFeatures(ChromeFeatureList.SHARE_BY_DEFAULT_IN_CCT)
public class FirstRunIntegrationTest { public class FirstRunIntegrationTest {
@Rule @Rule
public MultiActivityTestRule mTestRule = new MultiActivityTestRule(); public MultiActivityTestRule mTestRule = new MultiActivityTestRule();
@Rule
public TestRule mProcessor = new Features.JUnitProcessor();
@Mock @Mock
public FirstRunAppRestrictionInfo mMockAppRestrictionInfo; public FirstRunAppRestrictionInfo mMockAppRestrictionInfo;
@Mock @Mock
......
...@@ -19,17 +19,20 @@ import org.junit.Assert; ...@@ -19,17 +19,20 @@ import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.TestRule;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.chromium.base.test.util.CommandLineFlags; import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.UrlUtils; import org.chromium.base.test.util.UrlUtils;
import org.chromium.chrome.browser.customtabs.CustomTabActivity; import org.chromium.chrome.browser.customtabs.CustomTabActivity;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.flags.ChromeSwitches; import org.chromium.chrome.browser.flags.ChromeSwitches;
import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner; import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.MultiActivityTestRule; import org.chromium.chrome.test.MultiActivityTestRule;
import org.chromium.chrome.test.TestContentProvider; import org.chromium.chrome.test.TestContentProvider;
import org.chromium.chrome.test.util.ActivityUtils; import org.chromium.chrome.test.util.ActivityUtils;
import org.chromium.chrome.test.util.browser.Features;
import org.chromium.content_public.browser.test.util.Criteria; import org.chromium.content_public.browser.test.util.Criteria;
import org.chromium.content_public.browser.test.util.CriteriaHelper; import org.chromium.content_public.browser.test.util.CriteriaHelper;
...@@ -42,10 +45,14 @@ import java.util.concurrent.Callable; ...@@ -42,10 +45,14 @@ import java.util.concurrent.Callable;
*/ */
@RunWith(ChromeJUnit4ClassRunner.class) @RunWith(ChromeJUnit4ClassRunner.class)
@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE}) @CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE})
@Features.EnableFeatures(ChromeFeatureList.SHARE_BY_DEFAULT_IN_CCT)
public class MediaLauncherActivityTest { public class MediaLauncherActivityTest {
@Rule @Rule
public MultiActivityTestRule mTestRule = new MultiActivityTestRule(); public MultiActivityTestRule mTestRule = new MultiActivityTestRule();
@Rule
public TestRule mProcessor = new Features.JUnitProcessor();
private Context mContext; private Context mContext;
@Before @Before
......
...@@ -379,6 +379,7 @@ public class ReengagementNotificationControllerIntegrationTest { ...@@ -379,6 +379,7 @@ public class ReengagementNotificationControllerIntegrationTest {
// as expected with test values. // as expected with test values.
features.put(ChromeFeatureList.SEARCH_ENGINE_PROMO_EXISTING_DEVICE, false); features.put(ChromeFeatureList.SEARCH_ENGINE_PROMO_EXISTING_DEVICE, false);
features.put(ChromeFeatureList.OMNIBOX_SEARCH_ENGINE_LOGO, false); features.put(ChromeFeatureList.OMNIBOX_SEARCH_ENGINE_LOGO, false);
features.put(ChromeFeatureList.SHARE_BY_DEFAULT_IN_CCT, true);
FeatureList.setTestFeatures(features); FeatureList.setTestFeatures(features);
} }
} }
\ No newline at end of file
...@@ -57,6 +57,7 @@ public class CachedFeatureFlags { ...@@ -57,6 +57,7 @@ public class CachedFeatureFlags {
put(ChromeFeatureList.DOWNLOADS_AUTO_RESUMPTION_NATIVE, true); put(ChromeFeatureList.DOWNLOADS_AUTO_RESUMPTION_NATIVE, true);
put(ChromeFeatureList.PRIORITIZE_BOOTSTRAP_TASKS, true); put(ChromeFeatureList.PRIORITIZE_BOOTSTRAP_TASKS, true);
put(ChromeFeatureList.IMMERSIVE_UI_MODE, false); put(ChromeFeatureList.IMMERSIVE_UI_MODE, false);
put(ChromeFeatureList.SHARE_BY_DEFAULT_IN_CCT, false);
put(ChromeFeatureList.SWAP_PIXEL_FORMAT_TO_FIX_CONVERT_FROM_TRANSLUCENT, true); put(ChromeFeatureList.SWAP_PIXEL_FORMAT_TO_FIX_CONVERT_FROM_TRANSLUCENT, true);
put(ChromeFeatureList.START_SURFACE_ANDROID, false); put(ChromeFeatureList.START_SURFACE_ANDROID, false);
put(ChromeFeatureList.PAINT_PREVIEW_DEMO, false); put(ChromeFeatureList.PAINT_PREVIEW_DEMO, false);
......
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