Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/ChromeFeatureList.java

Issue 2723003010: 📰 Throw when unregistered feature is queried in tests (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/CardsVariationParameters.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/ChromeFeatureList.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ChromeFeatureList.java b/chrome/android/java/src/org/chromium/chrome/browser/ChromeFeatureList.java
index b734118c408d87ddac2423230b3722512dc0cbb6..528b7092c29df8872ec4a79d9d13028525a3b71a 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ChromeFeatureList.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ChromeFeatureList.java
@@ -8,7 +8,7 @@
import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.MainDex;
-import java.util.Set;
+import java.util.Map;
/**
* Java accessor for base/feature_list.h state.
@@ -17,21 +17,21 @@
@MainDex
public abstract class ChromeFeatureList {
/** Map that stores substitution feature flags for tests. */
- private static Set<String> sTestEnabledFeatures;
+ private static Map<String, Boolean> sTestFeatures;
// Prevent instantiation.
private ChromeFeatureList() {}
/**
* Sets the feature flags to use in JUnit tests, since native calls are not available there.
- * Do not use directly, prefer using the {@link EnableFeatures} annotation.
+ * Do not use directly, prefer using the {@link Features} annotation.
*
- * @see EnableFeatures
- * @see EnableFeatures.Processor
+ * @see Features
+ * @see Features.Processor
*/
@VisibleForTesting
- public static void setTestEnabledFeatures(Set<String> featureList) {
- sTestEnabledFeatures = featureList;
+ public static void setTestFeatures(Map<String, Boolean> features) {
+ sTestFeatures = features;
}
/**
@@ -44,8 +44,9 @@ public static void setTestEnabledFeatures(Set<String> featureList) {
* @return Whether the feature is enabled or not.
*/
public static boolean isEnabled(String featureName) {
- if (sTestEnabledFeatures == null) return nativeIsEnabled(featureName);
- return sTestEnabledFeatures.contains(featureName);
+ if (sTestFeatures == null) return nativeIsEnabled(featureName);
+ if (sTestFeatures.containsKey(featureName)) return sTestFeatures.get(featureName);
+ throw new IllegalArgumentException(featureName);
}
/**
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/CardsVariationParameters.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698