| Index: chrome/android/javatests/src/org/chromium/chrome/browser/test/CommandLineInitRule.java
|
| diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/test/CommandLineInitRule.java b/chrome/android/javatests/src/org/chromium/chrome/browser/test/CommandLineInitRule.java
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..979e2b6b3a0c232cab536fe42ccbb0f235532560
|
| --- /dev/null
|
| +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/test/CommandLineInitRule.java
|
| @@ -0,0 +1,39 @@
|
| +// Copyright 2017 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.test;
|
| +
|
| +import org.junit.rules.TestRule;
|
| +import org.junit.runner.Description;
|
| +import org.junit.runners.model.Statement;
|
| +
|
| +import org.chromium.base.CommandLine;
|
| +
|
| +import java.util.Arrays;
|
| +
|
| +/**
|
| + * JUnit rule for setting command line arguments before initializing the browser.
|
| + *
|
| + * Having it as its own rule allows us to chain it using RuleChain and allows it to be explicitly
|
| + * run prior to initializing the browser.
|
| + */
|
| +public class CommandLineInitRule implements TestRule {
|
| + private String[] mArgs;
|
| +
|
| + public CommandLineInitRule(String[] args) {
|
| + if (args != null) {
|
| + mArgs = Arrays.copyOf(args, args.length);
|
| + }
|
| + }
|
| +
|
| + @Override
|
| + public Statement apply(Statement base, Description description) {
|
| + return new Statement() {
|
| + @Override
|
| + public void evaluate() {
|
| + CommandLine.init(mArgs);
|
| + }
|
| + };
|
| + }
|
| +}
|
|
|