• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2019 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 package org.chromium.base.test.params;
6 
7 import java.lang.annotation.ElementType;
8 import java.lang.annotation.Inherited;
9 import java.lang.annotation.Retention;
10 import java.lang.annotation.RetentionPolicy;
11 import java.lang.annotation.Target;
12 
13 /**
14  * Annotation to parameterize flags via the command-line flags file.
15  *
16  * For example, the following annotation would run the test 3 times:
17  *
18  * 1st: No flags.
19  * 2nd: --enable-features=one --one-params=p1
20  * 3rd: --enable-features=two --two-params=p2
21  *
22  * <code>
23  * @ParameterizedCommandLineFlags({
24  *     @Switches(),
25  *     @Switches({"enable-features=one", "one-params=p1"}),
26  *     @Switches({"enable-features=two", "two-params=p2"})
27  * })
28  * </code>
29  */
30 @Inherited
31 @Retention(RetentionPolicy.RUNTIME)
32 @Target({ElementType.METHOD, ElementType.TYPE})
33 public @interface ParameterizedCommandLineFlags {
34     /**
35      * Annotation to set commnad line flags in the command-line flags file
36      * for JUnit4 instrumentation tests.
37      *
38      * E.g. if you add the following annotation to your test class:
39      *
40      * <code>
41      * @ParameterizedCommandLineFlags.Switches({"FLAG_A", "FLAG_B"})
42      * public class MyTestClass
43      * </code>
44      *
45      * The test harness would run the test once with with --FLAG_A --FLAG_B.
46      *
47      * If you want to have the method run multiple times with different sets of
48      * parameters, see {@link ParameterizedCommandLineFlags}.
49      */
50     @Inherited
51     @Retention(RetentionPolicy.RUNTIME)
52     @Target({ElementType.METHOD, ElementType.TYPE})
53     public @interface Switches {
value()54         String[] value() default {};
55     }
56 
value()57     Switches[] value() default {};
58 }
59