[Android] Remove FeatureList#setTestFeatures() and usages.
Use either @Enable/DisableFeatures instead, or when necessary in parameterized tests, FeatureList#setTestValues() or FeatureList#setTestFeature(). Downstream migration: https://chrome-internal-review.googlesource.com/c/clank/internal/apps/+/7921738 Bug: 386813115 Change-Id: I002b09ebd96d83c85e5c0a4878312776fec6412b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6114359 Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> Owners-Override: Andrew Grieve <agrieve@chromium.org> Commit-Queue: Andrew Grieve <agrieve@chromium.org> Owners-Override: Henrique Nakashima <hnakashima@chromium.org> Auto-Submit: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Andrew Grieve <agrieve@chromium.org> Cr-Commit-Position: refs/heads/main@{#1401571}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
49285cd06b
commit
6d37ed5178
base
android
java
src
org
chromium
junit
src
test
android
junit
src
org
chromium
base
test
chrome
android
features
keyboard_accessory
javatests
src
org
chromium
chrome
browser
keyboard_accessory
sheet_component
javatests
src
org
chromium
chrome
browser
download
gesturenav
reengagement
junit
src
org
chromium
chrome
browser
browser
commerce
price_change
android
junit
src
org
chromium
chrome
browser
price_change
feed
android
java
src
org
chromium
chrome
flags
android
java
src
org
chromium
chrome
components
browser_ui
contacts_picker
android
java
src
org
chromium
components
browser_ui
contacts_picker
cached_flags
android
java
src
org
chromium
components
cached_flags
content/public/android/javatests/src/org/chromium/content/browser
ui/android/junit/src/org/chromium/ui/widget
@ -62,8 +62,9 @@ public class FeatureList {
|
||||
addFieldTrialParamOverride(param.getFeatureName(), param.getName(), testValue);
|
||||
}
|
||||
|
||||
@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
|
||||
@Nullable
|
||||
Boolean getFeatureFlagOverride(String featureName) {
|
||||
public Boolean getFeatureFlagOverride(String featureName) {
|
||||
return mFeatureFlags.get(featureName);
|
||||
}
|
||||
|
||||
@ -204,21 +205,6 @@ public class FeatureList {
|
||||
return sDisableNativeForTesting;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override feature flags for testing. Convenience method for #setTestValues() without params.
|
||||
*
|
||||
* <p>TODO(crbug.com/386813115): Migrate usages to #setTestFeature or #setTestValues to delete
|
||||
* this method.
|
||||
*/
|
||||
@VisibleForTesting
|
||||
public static void setTestFeatures(Map<String, Boolean> testFeatures) {
|
||||
assert testFeatures != null;
|
||||
|
||||
TestValues testValues = new TestValues();
|
||||
testValues.setFeatureFlagsOverride(testFeatures);
|
||||
setTestValues(testValues);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds overrides to feature flags and field trial parameters in addition to existing ones.
|
||||
*
|
||||
|
@ -44,8 +44,9 @@ public abstract class FeatureMap {
|
||||
* to be marked as active.
|
||||
*
|
||||
* <p>Should be called only after native is loaded. If {@link FeatureList#isInitialized()}
|
||||
* returns true, this method is safe to call. In tests, this will return any values set through
|
||||
* {@link FeatureList#setTestFeatures(Map)}, even before native is loaded.
|
||||
* returns true, this method is safe to call. In tests, this will return any values set
|
||||
* through @Enable/@DisableFeatures annotations or {@link
|
||||
* FeatureList#setTestValues(FeatureList.TestValues)}, even before native is loaded.
|
||||
*
|
||||
* @param featureName The name of the feature to query.
|
||||
* @return Whether the feature is enabled or not.
|
||||
|
@ -42,7 +42,7 @@ public class MutableFlagWithSafeDefaultUnitTest {
|
||||
FEATURE_MAP.mutableFlagWithSafeDefault(FEATURE_B, true);
|
||||
|
||||
// Values from ChromeFeatureList should be used from now on.
|
||||
FeatureList.setTestFeatures(A_ON_B_OFF);
|
||||
FeatureList.setTestValues(A_ON_B_OFF);
|
||||
|
||||
// Verify that {@link MutableFlagWithSafeDefault} returns native values.
|
||||
BaseFlagTestRule.assertIsEnabledMatches(A_ON_B_OFF, featureA, featureB);
|
||||
@ -70,7 +70,7 @@ public class MutableFlagWithSafeDefaultUnitTest {
|
||||
BaseFlagTestRule.assertIsEnabledMatches(A_OFF_B_ON, featureA, featureB);
|
||||
|
||||
// Values from ChromeFeatureList should be used from now on.
|
||||
FeatureList.setTestFeatures(A_ON_B_OFF);
|
||||
FeatureList.setTestValues(A_ON_B_OFF);
|
||||
|
||||
// Verify that {@link MutableFlagWithSafeDefault} returns native values.
|
||||
BaseFlagTestRule.assertIsEnabledMatches(A_ON_B_OFF, featureA, featureB);
|
||||
|
@ -44,7 +44,7 @@ public class PostNativeFlagUnitTest {
|
||||
PostNativeFlag featureB = new PostNativeFlag(BaseFlagTestRule.FEATURE_MAP, FEATURE_B);
|
||||
|
||||
// Values from ChromeFeatureList should be used from now on.
|
||||
FeatureList.setTestFeatures(A_OFF_B_ON);
|
||||
FeatureList.setTestValues(A_OFF_B_ON);
|
||||
|
||||
// Assert {@link MutableFlagWithSafeDefault} uses the values from {@link ChromeFeatureList}.
|
||||
assertIsEnabledMatches(A_OFF_B_ON, featureA, featureB);
|
||||
|
@ -10,12 +10,11 @@ import org.junit.rules.TestRule;
|
||||
import org.junit.runner.Description;
|
||||
import org.junit.runners.model.Statement;
|
||||
|
||||
import org.chromium.base.FeatureList;
|
||||
import org.chromium.base.FeatureMap;
|
||||
import org.chromium.base.FeatureParam;
|
||||
import org.chromium.base.Flag;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/** Test rule for testing subclasses of {@link Flag}. */
|
||||
public class BaseFlagTestRule implements TestRule {
|
||||
@Override
|
||||
@ -33,14 +32,21 @@ public class BaseFlagTestRule implements TestRule {
|
||||
public static final String FEATURE_A = "FeatureA";
|
||||
public static final String FEATURE_B = "FeatureB";
|
||||
|
||||
public static final Map<String, Boolean> A_OFF_B_ON =
|
||||
Map.of(FEATURE_A, false, FEATURE_B, true);
|
||||
public static final Map<String, Boolean> A_OFF_B_OFF =
|
||||
Map.of(FEATURE_A, false, FEATURE_B, false);
|
||||
public static final Map<String, Boolean> A_ON_B_OFF =
|
||||
Map.of(FEATURE_A, true, FEATURE_B, false);
|
||||
public static final Map<String, Boolean> A_ON_B_ON =
|
||||
Map.of(FEATURE_A, true, FEATURE_B, true);
|
||||
public static final FeatureList.TestValues A_OFF_B_ON = new FeatureList.TestValues();
|
||||
public static final FeatureList.TestValues A_OFF_B_OFF = new FeatureList.TestValues();
|
||||
public static final FeatureList.TestValues A_ON_B_OFF = new FeatureList.TestValues();
|
||||
public static final FeatureList.TestValues A_ON_B_ON = new FeatureList.TestValues();
|
||||
|
||||
static {
|
||||
A_OFF_B_ON.addFeatureFlagOverride(FEATURE_A, false);
|
||||
A_OFF_B_ON.addFeatureFlagOverride(FEATURE_B, true);
|
||||
A_OFF_B_OFF.addFeatureFlagOverride(FEATURE_A, false);
|
||||
A_OFF_B_OFF.addFeatureFlagOverride(FEATURE_B, false);
|
||||
A_ON_B_OFF.addFeatureFlagOverride(FEATURE_A, true);
|
||||
A_ON_B_OFF.addFeatureFlagOverride(FEATURE_B, false);
|
||||
A_ON_B_ON.addFeatureFlagOverride(FEATURE_A, true);
|
||||
A_ON_B_ON.addFeatureFlagOverride(FEATURE_B, true);
|
||||
}
|
||||
|
||||
/** A stub FeatureMap instance to create flags on. */
|
||||
public static final FeatureMap FEATURE_MAP =
|
||||
@ -55,8 +61,8 @@ public class BaseFlagTestRule implements TestRule {
|
||||
};
|
||||
|
||||
public static void assertIsEnabledMatches(
|
||||
Map<String, Boolean> state, Flag feature1, Flag feature2) {
|
||||
assertEquals(state.get(FEATURE_A), feature1.isEnabled());
|
||||
assertEquals(state.get(FEATURE_B), feature2.isEnabled());
|
||||
FeatureList.TestValues state, Flag feature1, Flag feature2) {
|
||||
assertEquals(state.getFeatureFlagOverride(FEATURE_A), feature1.isEnabled());
|
||||
assertEquals(state.getFeatureFlagOverride(FEATURE_B), feature2.isEnabled());
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,6 @@ import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
|
||||
import org.chromium.base.Callback;
|
||||
import org.chromium.base.FeatureList;
|
||||
import org.chromium.base.ThreadUtils;
|
||||
import org.chromium.base.test.BaseActivityTestRule;
|
||||
import org.chromium.base.test.params.ParameterAnnotations;
|
||||
@ -76,9 +75,7 @@ import org.chromium.ui.test.util.NightModeTestUtils;
|
||||
import org.chromium.ui.test.util.ViewUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* These tests render screenshots of various accessory sheets and compare them to a gold standard.
|
||||
@ -116,10 +113,6 @@ public class AccessorySheetRenderTest {
|
||||
@Mock private PersonalDataManager mPersonalDataManager;
|
||||
|
||||
public AccessorySheetRenderTest(boolean nightModeEnabled, boolean useRtlLayout) {
|
||||
Map<String, Boolean> featureMap = new HashMap<>();
|
||||
featureMap.put(ChromeFeatureList.AUTOFILL_ENABLE_NEW_CARD_ART_AND_NETWORK_IMAGES, false);
|
||||
FeatureList.setTestFeatures(featureMap);
|
||||
|
||||
setRtlForTesting(useRtlLayout);
|
||||
NightModeTestUtils.setUpNightModeForBlankUiTestActivity(nightModeEnabled);
|
||||
mRenderTestRule.setNightModeEnabled(nightModeEnabled);
|
||||
|
@ -28,10 +28,10 @@ import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import org.chromium.base.FeatureList;
|
||||
import org.chromium.base.ThreadUtils;
|
||||
import org.chromium.base.test.BaseActivityTestRule;
|
||||
import org.chromium.base.test.util.CommandLineFlags;
|
||||
import org.chromium.base.test.util.Features.DisableFeatures;
|
||||
import org.chromium.chrome.R;
|
||||
import org.chromium.chrome.browser.download.DirectoryOption;
|
||||
import org.chromium.chrome.browser.download.DownloadDialogBridge;
|
||||
@ -54,12 +54,11 @@ import org.chromium.ui.modaldialog.ModalDialogManager;
|
||||
import org.chromium.ui.test.util.BlankUiTestActivity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/** Test focus on verifying UI elements in the download location dialog. */
|
||||
@RunWith(ChromeJUnit4ClassRunner.class)
|
||||
@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE})
|
||||
@DisableFeatures(ChromeFeatureList.SMART_SUGGESTION_FOR_LARGE_DOWNLOADS)
|
||||
public class DownloadLocationDialogTest {
|
||||
private static final long TOTAL_BYTES = 1024L;
|
||||
private static final String SUGGESTED_PATH = "download.png";
|
||||
@ -102,9 +101,6 @@ public class DownloadLocationDialogTest {
|
||||
return new ModalDialogManager(
|
||||
mAppModalPresenter, ModalDialogManager.ModalDialogType.APP);
|
||||
});
|
||||
Map<String, Boolean> features = new HashMap<>();
|
||||
features.put(ChromeFeatureList.SMART_SUGGESTION_FOR_LARGE_DOWNLOADS, false);
|
||||
FeatureList.setTestFeatures(features);
|
||||
|
||||
setDownloadPromptStatus(DownloadPromptStatus.SHOW_INITIAL);
|
||||
ThreadUtils.runOnUiThreadBlocking(
|
||||
|
@ -24,7 +24,6 @@ import org.junit.runner.RunWith;
|
||||
|
||||
import org.chromium.base.ActivityState;
|
||||
import org.chromium.base.ApplicationStatus;
|
||||
import org.chromium.base.FeatureList;
|
||||
import org.chromium.base.ThreadUtils;
|
||||
import org.chromium.base.test.util.Batch;
|
||||
import org.chromium.base.test.util.CommandLineFlags;
|
||||
@ -65,7 +64,6 @@ import org.chromium.ui.base.DeviceFormFactor;
|
||||
import org.chromium.ui.base.PageTransition;
|
||||
import org.chromium.ui.base.UiAndroidFeatures;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
/** Tests {@link NavigationHandler} navigating back/forward using overscroll history navigation. */
|
||||
@ -490,16 +488,16 @@ public class NavigationHandlerTest {
|
||||
|
||||
@Test
|
||||
@SmallTest
|
||||
@DisableFeatures(ChromeFeatureList.BACK_FORWARD_TRANSITIONS)
|
||||
public void testLeftEdgeSwipeClosesTabLaunchedFromLink() {
|
||||
FeatureList.setTestFeatures(Map.of(ChromeFeatureList.BACK_FORWARD_TRANSITIONS, false));
|
||||
testLeftEdgeSwipeClosesTabLaunchedFromLinkInternal();
|
||||
}
|
||||
|
||||
@Test
|
||||
@SmallTest
|
||||
@EnableFeatures(ChromeFeatureList.BACK_FORWARD_TRANSITIONS)
|
||||
@DisabledTest(message = "crbug.com/1426201")
|
||||
public void testLeftEdgeSwipeClosesTabLaunchedFromLink_withBackForwardTransition() {
|
||||
FeatureList.setTestFeatures(Map.of(ChromeFeatureList.BACK_FORWARD_TRANSITIONS, true));
|
||||
testLeftEdgeSwipeClosesTabLaunchedFromLinkInternal();
|
||||
}
|
||||
|
||||
|
@ -33,12 +33,13 @@ import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
|
||||
import org.chromium.base.FeatureList;
|
||||
import org.chromium.base.ThreadUtils;
|
||||
import org.chromium.base.test.util.CallbackHelper;
|
||||
import org.chromium.base.test.util.CommandLineFlags;
|
||||
import org.chromium.base.test.util.CriteriaHelper;
|
||||
import org.chromium.base.test.util.DisabledTest;
|
||||
import org.chromium.base.test.util.Features.DisableFeatures;
|
||||
import org.chromium.base.test.util.Features.EnableFeatures;
|
||||
import org.chromium.base.test.util.UrlUtils;
|
||||
import org.chromium.chrome.browser.DefaultBrowserInfo2;
|
||||
import org.chromium.chrome.browser.app.reengagement.ReengagementActivity;
|
||||
@ -60,12 +61,13 @@ import org.chromium.components.feature_engagement.FeatureConstants;
|
||||
import org.chromium.components.feature_engagement.Tracker;
|
||||
import org.chromium.content_public.common.ContentUrlConstants;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/** Integration tests for {@link ReengagementNotificationController}. */
|
||||
@RunWith(ChromeJUnit4ClassRunner.class)
|
||||
@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE})
|
||||
@EnableFeatures(ChromeFeatureList.REENGAGEMENT_NOTIFICATION)
|
||||
// TODO(crbug.com/40142646): Remove these overrides when FeatureList#isInitialized() works
|
||||
// as expected with test values
|
||||
@DisableFeatures(ChromeFeatureList.VOICE_SEARCH_AUDIO_CAPTURE_POLICY)
|
||||
public class ReengagementNotificationControllerIntegrationTest {
|
||||
@Rule
|
||||
public ChromeTabbedActivityTestRule mTabbedActivityTestRule =
|
||||
@ -81,7 +83,6 @@ public class ReengagementNotificationControllerIntegrationTest {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
reset(mTracker);
|
||||
setReengagementNotificationEnabled(true);
|
||||
TrackerFactory.setTrackerForTests(mTracker);
|
||||
closeReengagementNotifications();
|
||||
}
|
||||
@ -229,9 +230,9 @@ public class ReengagementNotificationControllerIntegrationTest {
|
||||
|
||||
@Test
|
||||
@SmallTest
|
||||
@DisableFeatures(ChromeFeatureList.REENGAGEMENT_NOTIFICATION)
|
||||
@DisabledTest(message = "crbug.com/1112519 - Disabled while safety guard is in place.")
|
||||
public void testEngagementTrackedWhenDisabled() {
|
||||
setReengagementNotificationEnabled(false);
|
||||
mTabbedActivityTestRule.startMainActivityFromLauncher();
|
||||
verify(mTracker, times(1)).notifyEvent(EventConstants.STARTED_FROM_MAIN_INTENT);
|
||||
}
|
||||
@ -246,8 +247,8 @@ public class ReengagementNotificationControllerIntegrationTest {
|
||||
|
||||
@Test
|
||||
@MediumTest
|
||||
@DisableFeatures(ChromeFeatureList.REENGAGEMENT_NOTIFICATION)
|
||||
public void testEngagementNotificationNotSentDueToDisabled() {
|
||||
setReengagementNotificationEnabled(false);
|
||||
DefaultBrowserInfo2.setDefaultInfoForTests(
|
||||
createDefaultInfo(/* passesPrecondition= */ true));
|
||||
mCustomTabActivityTestRule.startCustomTabActivityWithIntent(
|
||||
@ -379,13 +380,4 @@ public class ReengagementNotificationControllerIntegrationTest {
|
||||
browserCount,
|
||||
/* systemCount= */ 0);
|
||||
}
|
||||
|
||||
private static void setReengagementNotificationEnabled(boolean enabled) {
|
||||
Map<String, Boolean> features = new HashMap<>();
|
||||
features.put(ChromeFeatureList.REENGAGEMENT_NOTIFICATION, enabled);
|
||||
// TODO(crbug.com/40142646): Remove these overrides when FeatureList#isInitialized() works
|
||||
// as expected with test values.
|
||||
features.put(ChromeFeatureList.VOICE_SEARCH_AUDIO_CAPTURE_POLICY, false);
|
||||
FeatureList.setTestFeatures(features);
|
||||
}
|
||||
}
|
||||
|
@ -21,10 +21,10 @@ import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import org.chromium.base.ContextUtils;
|
||||
import org.chromium.base.FeatureList;
|
||||
import org.chromium.base.supplier.ObservableSupplierImpl;
|
||||
import org.chromium.base.supplier.Supplier;
|
||||
import org.chromium.base.test.BaseRobolectricTestRunner;
|
||||
import org.chromium.base.test.util.Features.DisableFeatures;
|
||||
import org.chromium.chrome.R;
|
||||
import org.chromium.chrome.browser.ActivityTabProvider;
|
||||
import org.chromium.chrome.browser.bookmarks.BookmarkModel;
|
||||
@ -42,11 +42,14 @@ import org.chromium.content_public.browser.NavigationController;
|
||||
import org.chromium.url.GURL;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/** Unit tests for {@link CustomTabAppMenuPropertiesDelegate}. */
|
||||
@RunWith(BaseRobolectricTestRunner.class)
|
||||
@DisableFeatures({
|
||||
ChromeFeatureList.READALOUD_IN_OVERFLOW_MENU_IN_CCT,
|
||||
ContentFeatureList.ANDROID_OPEN_PDF_INLINE,
|
||||
ChromeFeatureList.ANDROID_OPEN_PDF_INLINE_BACKPORT
|
||||
})
|
||||
public class CustomTabAppMenuPropertiesDelegateUnitTest {
|
||||
@Mock private ActivityTabProvider mActivityTabProvider;
|
||||
@Mock private Tab mTab;
|
||||
@ -70,11 +73,6 @@ public class CustomTabAppMenuPropertiesDelegateUnitTest {
|
||||
when(mActivityTabProvider.get()).thenReturn(mTab);
|
||||
when(mTab.getUrl()).thenReturn(new GURL("https://google.com"));
|
||||
when(mTab.isNativePage()).thenReturn(false);
|
||||
Map<String, Boolean> featureMap = new HashMap<>();
|
||||
featureMap.put(ChromeFeatureList.READALOUD_IN_OVERFLOW_MENU_IN_CCT, false);
|
||||
featureMap.put(ContentFeatureList.ANDROID_OPEN_PDF_INLINE, false);
|
||||
featureMap.put(ChromeFeatureList.ANDROID_OPEN_PDF_INLINE_BACKPORT, false);
|
||||
FeatureList.setTestFeatures(featureMap);
|
||||
}
|
||||
|
||||
private Menu createMenu(Context context, int menuResourceId) {
|
||||
|
@ -15,8 +15,6 @@ import static org.mockito.Mockito.when;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@ -26,8 +24,9 @@ import org.mockito.Captor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import org.chromium.base.FeatureList;
|
||||
import org.chromium.base.test.BaseRobolectricTestRunner;
|
||||
import org.chromium.base.test.util.Features.DisableFeatures;
|
||||
import org.chromium.base.test.util.Features.EnableFeatures;
|
||||
import org.chromium.chrome.browser.app.feed.FeedActionDelegateImpl;
|
||||
import org.chromium.chrome.browser.bookmarks.BookmarkModel;
|
||||
import org.chromium.chrome.browser.feed.webfeed.WebFeedBridge;
|
||||
@ -101,27 +100,24 @@ public final class FeedActionDelegateImplTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFeatures(ChromeFeatureList.FEED_SHOW_SIGN_IN_COMMAND)
|
||||
public void testShowSyncConsentActivity_shownWhenFlagEnabled() {
|
||||
FeatureList.setTestFeatures(
|
||||
ImmutableMap.of(ChromeFeatureList.FEED_SHOW_SIGN_IN_COMMAND, true));
|
||||
mFeedActionDelegateImpl.showSyncConsentActivity(SigninAccessPoint.NTP_FEED_TOP_PROMO);
|
||||
verify(mMockSyncConsentActivityLauncher)
|
||||
.launchActivityIfAllowed(any(), eq(SigninAccessPoint.NTP_FEED_TOP_PROMO));
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFeatures(ChromeFeatureList.FEED_SHOW_SIGN_IN_COMMAND)
|
||||
public void testShowSyncConsentActivity_dontShowWhenFlagDisabled() {
|
||||
FeatureList.setTestFeatures(
|
||||
ImmutableMap.of(ChromeFeatureList.FEED_SHOW_SIGN_IN_COMMAND, false));
|
||||
mFeedActionDelegateImpl.showSyncConsentActivity(SigninAccessPoint.NTP_FEED_TOP_PROMO);
|
||||
verify(mMockSyncConsentActivityLauncher, never())
|
||||
.launchActivityIfAllowed(any(), eq(SigninAccessPoint.NTP_FEED_TOP_PROMO));
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFeatures(ChromeFeatureList.FEED_SHOW_SIGN_IN_COMMAND)
|
||||
public void testStartSigninFlow_shownWhenFlagEnabled() {
|
||||
FeatureList.setTestFeatures(
|
||||
ImmutableMap.of(ChromeFeatureList.FEED_SHOW_SIGN_IN_COMMAND, true));
|
||||
when(mMockSigninAndHistorySyncActivityLauncher.createBottomSheetSigninIntentOrShowError(
|
||||
any(), any(), any(), eq(SigninAccessPoint.NTP_FEED_TOP_PROMO)))
|
||||
.thenReturn(mSigninIntent);
|
||||
@ -146,9 +142,8 @@ public final class FeedActionDelegateImplTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFeatures(ChromeFeatureList.FEED_SHOW_SIGN_IN_COMMAND)
|
||||
public void testStartSigninFlow_dontShowWhenFlagDisabled() {
|
||||
FeatureList.setTestFeatures(
|
||||
ImmutableMap.of(ChromeFeatureList.FEED_SHOW_SIGN_IN_COMMAND, false));
|
||||
mFeedActionDelegateImpl.startSigninFlow(SigninAccessPoint.NTP_FEED_TOP_PROMO);
|
||||
verify(mMockSigninAndHistorySyncActivityLauncher, never())
|
||||
.createBottomSheetSigninIntentOrShowError(
|
||||
@ -156,9 +151,8 @@ public final class FeedActionDelegateImplTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFeatures(ChromeFeatureList.REPLACE_SYNC_PROMOS_WITH_SIGN_IN_PROMOS)
|
||||
public void testShowSigninInterstitial_replaceSyncPromosWithSignInPromosEnabled() {
|
||||
FeatureList.setTestFeatures(
|
||||
ImmutableMap.of(ChromeFeatureList.REPLACE_SYNC_PROMOS_WITH_SIGN_IN_PROMOS, true));
|
||||
when(mMockSigninAndHistorySyncActivityLauncher.createBottomSheetSigninIntentOrShowError(
|
||||
any(), any(), any(), eq(SigninAccessPoint.NTP_FEED_CARD_MENU_PROMO)))
|
||||
.thenReturn(mSigninIntent);
|
||||
@ -183,8 +177,8 @@ public final class FeedActionDelegateImplTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableFeatures(ChromeFeatureList.CORMORANT)
|
||||
public void testOpenWebFeed_enabledWhenCormorantFlagEnabled() {
|
||||
FeatureList.setTestFeatures(ImmutableMap.of(ChromeFeatureList.CORMORANT, true));
|
||||
String webFeedName = "SomeFeedName";
|
||||
|
||||
mFeedActionDelegateImpl.openWebFeed(webFeedName, SingleWebFeedEntryPoint.OTHER);
|
||||
@ -197,9 +191,9 @@ public final class FeedActionDelegateImplTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableFeatures(ChromeFeatureList.CORMORANT)
|
||||
public void testOpenWebFeed_disabledWhenCormorantFlagDisabled() {
|
||||
when(mWebFeedBridgeJniMock.isCormorantEnabledForLocale()).thenReturn(false);
|
||||
FeatureList.setTestFeatures(ImmutableMap.of(ChromeFeatureList.CORMORANT, false));
|
||||
mFeedActionDelegateImpl.openWebFeed("SomeFeedName", SingleWebFeedEntryPoint.OTHER);
|
||||
verify(mActivity, never()).startActivity(any());
|
||||
}
|
||||
|
@ -40,9 +40,9 @@ import org.robolectric.annotation.Config;
|
||||
|
||||
import org.chromium.base.Callback;
|
||||
import org.chromium.base.ContextUtils;
|
||||
import org.chromium.base.FeatureList;
|
||||
import org.chromium.base.shared_preferences.SharedPreferencesManager;
|
||||
import org.chromium.base.test.BaseRobolectricTestRunner;
|
||||
import org.chromium.base.test.util.Features.EnableFeatures;
|
||||
import org.chromium.chrome.R;
|
||||
import org.chromium.chrome.browser.flags.ChromeFeatureList;
|
||||
import org.chromium.chrome.browser.magic_stack.ModuleDelegate;
|
||||
@ -70,10 +70,8 @@ import org.chromium.url.GURL;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/** Test relating to {@link PriceChangeModuleMediator} */
|
||||
@ -81,6 +79,7 @@ import java.util.Set;
|
||||
@Config(
|
||||
manifest = Config.NONE,
|
||||
shadows = {ShadowAppCompatResources.class})
|
||||
@EnableFeatures(ChromeFeatureList.PRICE_CHANGE_MODULE)
|
||||
public class PriceChangeModuleMediatorUnitTest {
|
||||
|
||||
@Rule public MockitoRule mMockitoRule = MockitoJUnit.rule();
|
||||
@ -137,10 +136,6 @@ public class PriceChangeModuleMediatorUnitTest {
|
||||
mSharedPreferenceManager = ChromeSharedPreferences.getInstance();
|
||||
mFaviconSize = mContext.getResources().getDimensionPixelSize(R.dimen.default_favicon_size);
|
||||
PriceTrackingFeatures.setPriceAnnotationsEnabledForTesting(true);
|
||||
|
||||
Map<String, Boolean> featureOverride = new HashMap<>();
|
||||
featureOverride.put(ChromeFeatureList.PRICE_CHANGE_MODULE, true);
|
||||
FeatureList.setTestFeatures(featureOverride);
|
||||
}
|
||||
|
||||
@After
|
||||
|
@ -24,7 +24,6 @@ import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.TypedValue;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
@ -49,9 +48,10 @@ import org.robolectric.annotation.LooperMode;
|
||||
import org.robolectric.shadows.ShadowLog;
|
||||
|
||||
import org.chromium.base.Callback;
|
||||
import org.chromium.base.FeatureList;
|
||||
import org.chromium.base.supplier.Supplier;
|
||||
import org.chromium.base.test.BaseRobolectricTestRunner;
|
||||
import org.chromium.base.test.util.Features.DisableFeatures;
|
||||
import org.chromium.base.test.util.Features.EnableFeatures;
|
||||
import org.chromium.base.test.util.HistogramWatcher;
|
||||
import org.chromium.chrome.browser.feed.v2.FeedUserActionType;
|
||||
import org.chromium.chrome.browser.feed.webfeed.WebFeedBridge;
|
||||
@ -82,15 +82,15 @@ import org.chromium.url.JUnitTestGURLs;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/** Unit tests for {@link FeedStream}. */
|
||||
@RunWith(BaseRobolectricTestRunner.class)
|
||||
@Config(manifest = Config.NONE)
|
||||
// TODO(crbug.com/40182398): Rewrite using paused loop. See crbug for details.
|
||||
@LooperMode(LooperMode.Mode.LEGACY)
|
||||
@EnableFeatures(ChromeFeatureList.FEED_LOADING_PLACEHOLDER)
|
||||
@DisableFeatures(ChromeFeatureList.FEED_CONTAINMENT)
|
||||
public class FeedStreamTest {
|
||||
private static final int LOAD_MORE_TRIGGER_LOOKAHEAD = 5;
|
||||
private static final int LOAD_MORE_TRIGGER_SCROLL_DISTANCE_DP = 100;
|
||||
@ -151,13 +151,6 @@ public class FeedStreamTest {
|
||||
}
|
||||
}
|
||||
|
||||
private void setFeatureOverrides(boolean feedLoadingPlaceholderOn) {
|
||||
Map<String, Boolean> overrides = new ArrayMap<>();
|
||||
overrides.put(ChromeFeatureList.FEED_LOADING_PLACEHOLDER, feedLoadingPlaceholderOn);
|
||||
overrides.put(ChromeFeatureList.FEED_CONTAINMENT, false);
|
||||
FeatureList.setTestFeatures(overrides);
|
||||
}
|
||||
|
||||
private static HistogramWatcher expectFeedRecordForLoadMoreTrigger(
|
||||
@StreamKind int streamKind, int itemCount, int numCardsRemaining) {
|
||||
return HistogramWatcher.newBuilder()
|
||||
@ -206,8 +199,6 @@ public class FeedStreamTest {
|
||||
when(mRenderer.getListLayoutHelper()).thenReturn(mLayoutManager);
|
||||
when(mRenderer.getAdapter()).thenReturn(mAdapter);
|
||||
|
||||
setFeatureOverrides(/* feedLoadingPlaceholderOn= */ true);
|
||||
|
||||
// Print logs to stdout.
|
||||
ShadowLog.stream = System.out;
|
||||
}
|
||||
@ -1151,8 +1142,8 @@ public class FeedStreamTest {
|
||||
|
||||
@Test
|
||||
@SmallTest
|
||||
@DisableFeatures(ChromeFeatureList.FEED_LOADING_PLACEHOLDER)
|
||||
public void testShowSpinner_PlaceholderDisabled() {
|
||||
setFeatureOverrides(/* feedLoadingPlaceholderOn= */ false);
|
||||
createHeaderContent(1);
|
||||
bindToView();
|
||||
FeedUiProto.StreamUpdate update =
|
||||
@ -1196,10 +1187,8 @@ public class FeedStreamTest {
|
||||
|
||||
@Test
|
||||
@SmallTest
|
||||
@DisableFeatures(ChromeFeatureList.WEB_FEED_SORT)
|
||||
public void testUnreadContentObserver_notNullWebFeed_sortOff() {
|
||||
Map<String, Boolean> features = new HashMap<>();
|
||||
features.put(ChromeFeatureList.WEB_FEED_SORT, false);
|
||||
FeatureList.setTestFeatures(features);
|
||||
FeedStream stream =
|
||||
new FeedStream(
|
||||
mActivity,
|
||||
@ -1219,10 +1208,8 @@ public class FeedStreamTest {
|
||||
|
||||
@Test
|
||||
@SmallTest
|
||||
@EnableFeatures(ChromeFeatureList.WEB_FEED_SORT)
|
||||
public void testUnreadContentObserver_notNullWebFeed_sortOn() {
|
||||
Map<String, Boolean> features = new HashMap<>();
|
||||
features.put(ChromeFeatureList.WEB_FEED_SORT, true);
|
||||
FeatureList.setTestFeatures(features);
|
||||
FeedStream stream =
|
||||
new FeedStream(
|
||||
mActivity,
|
||||
@ -1242,10 +1229,8 @@ public class FeedStreamTest {
|
||||
|
||||
@Test
|
||||
@SmallTest
|
||||
@DisableFeatures(ChromeFeatureList.WEB_FEED_SORT)
|
||||
public void testSupportsOptions_InterestFeed_sortOff() {
|
||||
Map<String, Boolean> features = new HashMap<>();
|
||||
features.put(ChromeFeatureList.WEB_FEED_SORT, false);
|
||||
FeatureList.setTestFeatures(features);
|
||||
FeedStream stream =
|
||||
new FeedStream(
|
||||
mActivity,
|
||||
@ -1265,10 +1250,8 @@ public class FeedStreamTest {
|
||||
|
||||
@Test
|
||||
@SmallTest
|
||||
@EnableFeatures(ChromeFeatureList.WEB_FEED_SORT)
|
||||
public void testSupportsOptions_InterestFeed_sortOn() {
|
||||
Map<String, Boolean> features = new HashMap<>();
|
||||
features.put(ChromeFeatureList.WEB_FEED_SORT, true);
|
||||
FeatureList.setTestFeatures(features);
|
||||
FeedStream stream =
|
||||
new FeedStream(
|
||||
mActivity,
|
||||
@ -1288,10 +1271,8 @@ public class FeedStreamTest {
|
||||
|
||||
@Test
|
||||
@SmallTest
|
||||
@DisableFeatures(ChromeFeatureList.WEB_FEED_SORT)
|
||||
public void testSupportsOptions_WebFeed_sortOff() {
|
||||
Map<String, Boolean> features = new HashMap<>();
|
||||
features.put(ChromeFeatureList.WEB_FEED_SORT, false);
|
||||
FeatureList.setTestFeatures(features);
|
||||
FeedStream stream =
|
||||
new FeedStream(
|
||||
mActivity,
|
||||
@ -1311,10 +1292,8 @@ public class FeedStreamTest {
|
||||
|
||||
@Test
|
||||
@SmallTest
|
||||
@EnableFeatures(ChromeFeatureList.WEB_FEED_SORT)
|
||||
public void testSupportsOptions_WebFeed_sortOn() {
|
||||
Map<String, Boolean> features = new HashMap<>();
|
||||
features.put(ChromeFeatureList.WEB_FEED_SORT, true);
|
||||
FeatureList.setTestFeatures(features);
|
||||
FeedStream stream =
|
||||
new FeedStream(
|
||||
mActivity,
|
||||
|
13
chrome/browser/feed/android/java/src/org/chromium/chrome/browser/feed/SingleWebFeedStreamTest.java
13
chrome/browser/feed/android/java/src/org/chromium/chrome/browser/feed/SingleWebFeedStreamTest.java
@ -16,7 +16,6 @@ import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.util.ArrayMap;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.AppCompatTextView;
|
||||
@ -36,9 +35,9 @@ import org.robolectric.annotation.LooperMode;
|
||||
import org.robolectric.shadows.ShadowLog;
|
||||
|
||||
import org.chromium.base.Callback;
|
||||
import org.chromium.base.FeatureList;
|
||||
import org.chromium.base.supplier.Supplier;
|
||||
import org.chromium.base.test.BaseRobolectricTestRunner;
|
||||
import org.chromium.base.test.util.Features.EnableFeatures;
|
||||
import org.chromium.chrome.browser.feed.v2.FeedUserActionType;
|
||||
import org.chromium.chrome.browser.feed.webfeed.WebFeedBridge;
|
||||
import org.chromium.chrome.browser.feed.webfeed.WebFeedBridge.FollowResults;
|
||||
@ -67,13 +66,13 @@ import org.chromium.ui.base.WindowAndroid;
|
||||
import org.chromium.url.JUnitTestGURLs;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
|
||||
/** Unit tests for {@link FeedStream}. */
|
||||
@RunWith(BaseRobolectricTestRunner.class)
|
||||
@Config(manifest = Config.NONE)
|
||||
// TODO(crbug.com/40182398): Rewrite using paused loop. See crbug for details.
|
||||
@LooperMode(LooperMode.Mode.LEGACY)
|
||||
@EnableFeatures(ChromeFeatureList.FEED_LOADING_PLACEHOLDER)
|
||||
public class SingleWebFeedStreamTest {
|
||||
private static final int LOAD_MORE_TRIGGER_LOOKAHEAD = 5;
|
||||
private static final int LOAD_MORE_TRIGGER_SCROLL_DISTANCE_DP = 100;
|
||||
@ -129,12 +128,6 @@ public class SingleWebFeedStreamTest {
|
||||
}
|
||||
}
|
||||
|
||||
private void setFeatureOverrides(boolean feedLoadingPlaceholderOn) {
|
||||
Map<String, Boolean> overrides = new ArrayMap<>();
|
||||
overrides.put(ChromeFeatureList.FEED_LOADING_PLACEHOLDER, feedLoadingPlaceholderOn);
|
||||
FeatureList.setTestFeatures(overrides);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
@ -174,8 +167,6 @@ public class SingleWebFeedStreamTest {
|
||||
when(mRenderer.getListLayoutHelper()).thenReturn(mLayoutManager);
|
||||
when(mRenderer.getAdapter()).thenReturn(mAdapter);
|
||||
|
||||
setFeatureOverrides(/* feedLoadingPlaceholderOn= */ true);
|
||||
|
||||
// Print logs to stdout.
|
||||
ShadowLog.stream = System.out;
|
||||
}
|
||||
|
@ -33,8 +33,6 @@ import org.chromium.components.prefs.PrefService;
|
||||
import org.chromium.components.user_prefs.UserPrefs;
|
||||
import org.chromium.components.user_prefs.UserPrefsJni;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/** Test for the WebFeedFollowIntroView class. */
|
||||
@RunWith(BaseRobolectricTestRunner.class)
|
||||
public final class WebFeedFollowIntroViewTest {
|
||||
@ -58,9 +56,6 @@ public final class WebFeedFollowIntroViewTest {
|
||||
mMenuButtonAnchorView = new View(mActivity);
|
||||
TrackerFactory.setTrackerForTests(mTracker);
|
||||
|
||||
// This empty setTestFeatures call below is needed to enable the field trial param calls.
|
||||
FeatureList.setTestFeatures(new HashMap<String, Boolean>());
|
||||
|
||||
// Build the class under test.
|
||||
Runnable noOp = CallbackUtils.emptyRunnable();
|
||||
mWebFeedFollowIntroView =
|
||||
|
@ -7,8 +7,6 @@ package org.chromium.chrome.browser.flags;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import android.util.ArrayMap;
|
||||
|
||||
import androidx.test.filters.MediumTest;
|
||||
|
||||
import org.junit.Before;
|
||||
@ -24,8 +22,6 @@ import org.chromium.base.test.util.Features.EnableFeatures;
|
||||
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
|
||||
import org.chromium.chrome.test.ChromeTabbedActivityTestRule;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/** Tests the behavior of {@link ChromeFeatureList} in instrumentation tests. */
|
||||
@RunWith(ChromeJUnit4ClassRunner.class)
|
||||
@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE})
|
||||
@ -57,11 +53,11 @@ public class ChromeFeatureListInstrumentationTest {
|
||||
|
||||
@Test
|
||||
@MediumTest
|
||||
public void testSetTestFeatures() {
|
||||
Map<String, Boolean> overrides = new ArrayMap<>();
|
||||
overrides.put(ChromeFeatureList.TEST_DEFAULT_DISABLED, true);
|
||||
overrides.put(ChromeFeatureList.TEST_DEFAULT_ENABLED, false);
|
||||
FeatureList.setTestFeatures(overrides);
|
||||
public void testSetTestValues() {
|
||||
FeatureList.TestValues overrides = new FeatureList.TestValues();
|
||||
overrides.addFeatureFlagOverride(ChromeFeatureList.TEST_DEFAULT_DISABLED, true);
|
||||
overrides.addFeatureFlagOverride(ChromeFeatureList.TEST_DEFAULT_ENABLED, false);
|
||||
FeatureList.setTestValues(overrides);
|
||||
|
||||
assertTrue(ChromeFeatureList.isEnabled(ChromeFeatureList.TEST_DEFAULT_DISABLED));
|
||||
assertFalse(ChromeFeatureList.isEnabled(ChromeFeatureList.TEST_DEFAULT_ENABLED));
|
||||
|
@ -60,21 +60,21 @@ public class ChromeFeatureListUnitTest {
|
||||
|
||||
/**
|
||||
* In unit tests, flags may have their value specified by calling {@link
|
||||
* FeatureList#setTestFeatures(java.util.Map)}.
|
||||
* FeatureList#setTestFeature(String, boolean)}.
|
||||
*/
|
||||
@Test
|
||||
@EnableFeatures(ChromeFeatureList.TEST_DEFAULT_DISABLED)
|
||||
public void testSetTestFeaturesEnabled_returnsEnabled() {
|
||||
public void testSetTestFeatureEnabled_returnsEnabled() {
|
||||
FeatureList.setTestFeature(ChromeFeatureList.TEST_DEFAULT_DISABLED, true);
|
||||
assertTrue(ChromeFeatureList.isEnabled(ChromeFeatureList.TEST_DEFAULT_DISABLED));
|
||||
}
|
||||
|
||||
/**
|
||||
* In unit tests, flags may have their value specified by calling {@link
|
||||
* FeatureList#setTestFeatures(java.util.Map)}.
|
||||
* FeatureList#setTestFeature(String, boolean)}.
|
||||
*/
|
||||
@Test
|
||||
@DisableFeatures(ChromeFeatureList.TEST_DEFAULT_ENABLED)
|
||||
public void testSetTestFeaturesDisabled_returnsDisabled() {
|
||||
FeatureList.setTestFeature(ChromeFeatureList.TEST_DEFAULT_ENABLED, false);
|
||||
assertFalse(ChromeFeatureList.isEnabled(ChromeFeatureList.TEST_DEFAULT_ENABLED));
|
||||
}
|
||||
|
||||
|
@ -30,13 +30,13 @@ import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import org.chromium.base.FeatureList;
|
||||
import org.chromium.base.ThreadUtils;
|
||||
import org.chromium.base.test.BaseActivityTestRule;
|
||||
import org.chromium.base.test.BaseJUnit4ClassRunner;
|
||||
import org.chromium.base.test.util.Batch;
|
||||
import org.chromium.base.test.util.CallbackHelper;
|
||||
import org.chromium.base.test.util.Feature;
|
||||
import org.chromium.base.test.util.Features.EnableFeatures;
|
||||
import org.chromium.blink.mojom.ContactIconBlob;
|
||||
import org.chromium.components.browser_ui.contacts_picker.test.R;
|
||||
import org.chromium.components.browser_ui.widget.RecyclerViewTestUtils;
|
||||
@ -59,12 +59,12 @@ import org.chromium.ui.test.util.RenderTestRule;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/** Tests for the ContactsPickerDialog class. */
|
||||
@RunWith(BaseJUnit4ClassRunner.class)
|
||||
@Batch(Batch.PER_CLASS)
|
||||
@EnableFeatures(ContactsPickerFeatureList.CONTACTS_PICKER_SELECT_ALL)
|
||||
public class ContactsPickerDialogTest
|
||||
implements ContactsPickerListener, SelectionObserver<ContactDetails> {
|
||||
@ClassRule
|
||||
@ -153,9 +153,6 @@ public class ContactsPickerDialogTest
|
||||
when(mWebContents.isDestroyed()).thenReturn(false);
|
||||
when(mWebContents.getVisibility()).thenReturn(Visibility.VISIBLE);
|
||||
|
||||
FeatureList.setTestFeatures(
|
||||
Collections.singletonMap(
|
||||
ContactsPickerFeatureList.CONTACTS_PICKER_SELECT_ALL, true));
|
||||
mIcon = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas(mIcon);
|
||||
canvas.drawColor(Color.BLUE);
|
||||
|
@ -130,7 +130,7 @@ public class CachedFlagUnitTest {
|
||||
CachedFlag featureB = new CachedFlag(mFeatureMap, FEATURE_B, true);
|
||||
|
||||
// Force different values
|
||||
FeatureList.setTestFeatures(A_ON_B_OFF);
|
||||
FeatureList.setTestValues(A_ON_B_OFF);
|
||||
|
||||
// Verify that the forced value is returned.
|
||||
assertIsEnabledMatches(A_ON_B_OFF, featureA, featureB);
|
||||
|
@ -107,12 +107,13 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.chromium.base.FeatureList;
|
||||
import org.chromium.base.ThreadUtils;
|
||||
import org.chromium.base.test.util.Criteria;
|
||||
import org.chromium.base.test.util.CriteriaHelper;
|
||||
import org.chromium.base.test.util.DisableIf;
|
||||
import org.chromium.base.test.util.DisabledTest;
|
||||
import org.chromium.base.test.util.Features.DisableFeatures;
|
||||
import org.chromium.base.test.util.Features.EnableFeatures;
|
||||
import org.chromium.base.test.util.HistogramWatcher;
|
||||
import org.chromium.base.test.util.Restriction;
|
||||
import org.chromium.base.test.util.TestAnimations;
|
||||
@ -123,7 +124,6 @@ import org.chromium.ui.accessibility.AccessibilityState;
|
||||
import org.chromium.ui.base.DeviceFormFactor;
|
||||
import org.chromium.ui.test.util.DeviceRestriction;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
@ -171,12 +171,6 @@ public class WebContentsAccessibilityTest {
|
||||
private static final String FOCUSING_ERROR =
|
||||
"Expected focus to be on a different node than it is.";
|
||||
|
||||
// ContentFeatureList maps used for various tests.
|
||||
private static final Map<String, Boolean> INCLUDE_LONG_CLICK_ENABLED =
|
||||
Map.of(ContentFeatureList.ACCESSIBILITY_INCLUDE_LONG_CLICK_ACTION, true);
|
||||
private static final Map<String, Boolean> INCLUDE_LONG_CLICK_DISABLED =
|
||||
Map.of(ContentFeatureList.ACCESSIBILITY_INCLUDE_LONG_CLICK_ACTION, false);
|
||||
|
||||
// Constant values for unit tests
|
||||
private static final int UNSUPPRESSED_EXPECTED_COUNT = 15;
|
||||
|
||||
@ -2028,11 +2022,10 @@ public class WebContentsAccessibilityTest {
|
||||
/** Test that ACTION_LONG_CLICK is included when experiment is running. */
|
||||
@Test
|
||||
@SmallTest
|
||||
@EnableFeatures(ContentFeatureList.ACCESSIBILITY_INCLUDE_LONG_CLICK_ACTION)
|
||||
public void testNodeInfo_Actions_longClickIncluded() throws Throwable {
|
||||
setupTestWithHTML("<p id='id1'>Example</p>");
|
||||
|
||||
FeatureList.setTestFeatures(INCLUDE_LONG_CLICK_ENABLED);
|
||||
|
||||
int vvId = waitForNodeMatching(sViewIdResourceNameMatcher, "id1");
|
||||
mNodeInfo = createAccessibilityNodeInfo(vvId);
|
||||
Assert.assertNotNull(NODE_TIMEOUT_ERROR, mNodeInfo);
|
||||
@ -2043,11 +2036,10 @@ public class WebContentsAccessibilityTest {
|
||||
/** Test that ACTION_LONG_CLICK is excluded when experiment is paused. */
|
||||
@Test
|
||||
@SmallTest
|
||||
@DisableFeatures(ContentFeatureList.ACCESSIBILITY_INCLUDE_LONG_CLICK_ACTION)
|
||||
public void testNodeInfo_Actions_longClickExcluded() throws Throwable {
|
||||
setupTestWithHTML("<p id='id1'>Example</p>");
|
||||
|
||||
FeatureList.setTestFeatures(INCLUDE_LONG_CLICK_DISABLED);
|
||||
|
||||
int vvId = waitForNodeMatching(sViewIdResourceNameMatcher, "id1");
|
||||
mNodeInfo = createAccessibilityNodeInfo(vvId);
|
||||
Assert.assertNotNull(NODE_TIMEOUT_ERROR, mNodeInfo);
|
||||
|
@ -14,22 +14,20 @@ import android.view.inputmethod.CursorAnchorInfo;
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.chromium.base.FeatureList;
|
||||
import org.chromium.base.test.util.Batch;
|
||||
import org.chromium.base.test.util.Feature;
|
||||
import org.chromium.base.test.util.Features.DisableFeatures;
|
||||
import org.chromium.blink_public.common.BlinkFeatures;
|
||||
import org.chromium.content_public.browser.test.ContentJUnit4ClassRunner;
|
||||
import org.chromium.content_public.browser.test.util.TestInputMethodManagerWrapper;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/** Test for {@link CursorAnchorInfoController}. */
|
||||
@RunWith(ContentJUnit4ClassRunner.class)
|
||||
@Batch(Batch.UNIT_TESTS)
|
||||
@DisableFeatures(BlinkFeatures.CURSOR_ANCHOR_INFO_MOJO_PIPE)
|
||||
public class CursorAnchorInfoControllerTest {
|
||||
private static final class TestViewDelegate implements CursorAnchorInfoController.ViewDelegate {
|
||||
public int locationX;
|
||||
@ -144,13 +142,6 @@ public class CursorAnchorInfoControllerTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
// Cannot access native features exposed to Java in tests without native initialization.
|
||||
// Instead, assign a test value to the feature.
|
||||
FeatureList.setTestFeatures(Map.of(BlinkFeatures.CURSOR_ANCHOR_INFO_MOJO_PIPE, false));
|
||||
}
|
||||
|
||||
@Test
|
||||
@SmallTest
|
||||
@Feature({"Input-Text-IME"})
|
||||
|
@ -20,16 +20,15 @@ import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.chromium.base.FeatureList;
|
||||
import org.chromium.base.test.BaseActivityTestRule;
|
||||
import org.chromium.base.test.BaseJUnit4ClassRunner;
|
||||
import org.chromium.base.test.util.Batch;
|
||||
import org.chromium.base.test.util.Features.DisableFeatures;
|
||||
import org.chromium.base.test.util.Features.EnableFeatures;
|
||||
import org.chromium.ui.R;
|
||||
import org.chromium.ui.base.UiAndroidFeatures;
|
||||
import org.chromium.ui.test.util.BlankUiTestActivity;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
/** Unit tests for {@link TextViewWithLeading}. */
|
||||
@RunWith(BaseJUnit4ClassRunner.class)
|
||||
@Batch(Batch.PER_CLASS)
|
||||
@ -85,28 +84,22 @@ public class TextViewWithLeadingTest {
|
||||
|
||||
@Test(expected = InflateException.class)
|
||||
@MediumTest
|
||||
@EnableFeatures(UiAndroidFeatures.REQUIRE_LEADING_IN_TEXT_VIEW_WITH_LEADING)
|
||||
public void testNoLeading() {
|
||||
FeatureList.setTestFeatures(
|
||||
Collections.singletonMap(
|
||||
UiAndroidFeatures.REQUIRE_LEADING_IN_TEXT_VIEW_WITH_LEADING, true));
|
||||
inflate(R.layout.text_view_with_leading_no_leading);
|
||||
}
|
||||
|
||||
@Test
|
||||
@MediumTest
|
||||
@DisableFeatures(UiAndroidFeatures.REQUIRE_LEADING_IN_TEXT_VIEW_WITH_LEADING)
|
||||
public void testLeadingKillSwitch() {
|
||||
FeatureList.setTestFeatures(
|
||||
Collections.singletonMap(
|
||||
UiAndroidFeatures.REQUIRE_LEADING_IN_TEXT_VIEW_WITH_LEADING, false));
|
||||
inflateAndVerify(R.layout.text_view_with_leading_direct);
|
||||
}
|
||||
|
||||
@Test
|
||||
@MediumTest
|
||||
@DisableFeatures(UiAndroidFeatures.REQUIRE_LEADING_IN_TEXT_VIEW_WITH_LEADING)
|
||||
public void testNoLeadingKillSwitch() {
|
||||
FeatureList.setTestFeatures(
|
||||
Collections.singletonMap(
|
||||
UiAndroidFeatures.REQUIRE_LEADING_IN_TEXT_VIEW_WITH_LEADING, false));
|
||||
inflate(R.layout.text_view_with_leading_no_leading);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user