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

Unified Diff: chrome/android/junit/src/org/chromium/chrome/browser/EnableFeatures.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 | « chrome/android/java_sources.gni ('k') | chrome/android/junit/src/org/chromium/chrome/browser/Features.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/junit/src/org/chromium/chrome/browser/EnableFeatures.java
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/EnableFeatures.java b/chrome/android/junit/src/org/chromium/chrome/browser/EnableFeatures.java
deleted file mode 100644
index a1344931264634fd8e6d2afe2839ae0d1a941f93..0000000000000000000000000000000000000000
--- a/chrome/android/junit/src/org/chromium/chrome/browser/EnableFeatures.java
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright 2016 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;
-
-import org.chromium.testing.local.AnnotationProcessor;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * Annotation used to set Feature flags during JUnit tests. To have an effect, the associated
- * {@link Processor} rule needs to be registered on the test class.
- *
- * Sample code:
- *
- * <pre>
- * public class Test {
- * &#64;Rule
- * public EnableFeatures.Processor processor = new EnableFeatures.Processor();
- *
- * &#64;EnableFeatures(ChromeFeatureList.NTP_SNIPPETS_OFFLINE_BADGE)
- * public void testFoo() { ... }
- * }
- * </pre>
- */
-@Inherited
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.METHOD, ElementType.TYPE})
-public @interface EnableFeatures {
-
- String[] value();
-
- /**
- * Add this rule to tests to activate the {@link EnableFeatures} annotations and choose flags
- * to enable, or get rid of exceptions when the production code tries to check for enabled
- * features.
- */
- public static class Processor extends AnnotationProcessor<EnableFeatures> {
- public Processor() {
- super(EnableFeatures.class);
- }
-
- @Override
- protected void before() throws Throwable {
- Set<String> enabledFeatures = new HashSet<>();
- String[] values = getAnnotation().value();
- enabledFeatures.addAll(Arrays.asList(values));
- ChromeFeatureList.setTestEnabledFeatures(enabledFeatures);
- }
-
- @Override
- protected void after() {
- ChromeFeatureList.setTestEnabledFeatures(null);
- }
- }
-}
« no previous file with comments | « chrome/android/java_sources.gni ('k') | chrome/android/junit/src/org/chromium/chrome/browser/Features.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698