Chromium Code Reviews| Index: components/cronet/android/test/smoketests/src/org/chromium/net/smoke/TestSupport.java |
| diff --git a/components/cronet/android/test/smoketests/src/org/chromium/net/smoke/TestSupport.java b/components/cronet/android/test/smoketests/src/org/chromium/net/smoke/TestSupport.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..20b09ab3578d1328622b60a683c71057cf7d0faf |
| --- /dev/null |
| +++ b/components/cronet/android/test/smoketests/src/org/chromium/net/smoke/TestSupport.java |
| @@ -0,0 +1,94 @@ |
| +// 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.net.smoke; |
| + |
| +import android.content.Context; |
| + |
| +import org.json.JSONObject; |
| + |
| +import org.chromium.net.ExperimentalCronetEngine; |
| + |
| +import java.io.Closeable; |
| +import java.io.File; |
| + |
| +/** |
| + * Provides support for tests, so they can be run in different environments against different |
| + * servers. It contains methods, which behavior can be different in different testing environments. |
| + * The concrete implementation of this interface is determined dynamically at runtime by reading |
| + * the value of |TestSupportImplClass| from the Android string resource file. |
| + */ |
| +interface TestSupport { |
| + enum Protocol { |
| + H1, |
|
mef
2016/12/08 23:17:18
Maybe spell out HTTP1 and HTTP2?
kapishnikov
2016/12/19 19:31:11
Done. Renamed H2TestServer -> Http2TestServer
|
| + H2, |
| + QUIC, |
| + } |
| + |
| + /** |
| + * Creates a new test server that supports a given {@code protocol}. |
| + * |
| + * @param context context. |
| + * @param protocol protocol that should be supported by the server. |
| + * @return an instance of the server. |
| + * |
| + * @throws UnsupportedOperationException if the implementation of this interface |
| + * does not support a given {@code protocol}. |
| + */ |
| + TestServer createTestServer(Context context, Protocol protocol); |
| + |
| + /** |
| + * This method is called at the end of a test run if the netlog is available. An implementer |
| + * of {@link TestSupport} can use it to process the result netlog; e.g., to copy the netlog |
| + * to a directory where all test logs are collected. This method is optional and can be no-op. |
| + * |
| + * @param file the netlog file. |
| + */ |
| + void processNetLog(File file); |
| + |
| + /** |
| + * Adds host resolver rules to a given experimental option JSON file. |
| + * This method is optional. |
| + * |
| + * @param json experimental options. |
| + */ |
| + void addHostResolverRules(JSONObject json); |
| + |
| + /** |
| + * Installs mock certificate verifier for a given {@code builder}. |
| + * This method is optional. |
| + * |
| + * @param builder that should have the verifier installed. |
| + */ |
| + void installMockCertVerifierForTesting(ExperimentalCronetEngine.Builder builder); |
| + |
| + /** |
| + * Loads a native library that is required for testing if any required. |
| + */ |
| + void loadTestNativeLibrary(); |
| + |
| + /** |
| + * A test server. The server implements {@link Closeable} to facilitate auto-closing. |
| + */ |
| + interface TestServer extends Closeable { |
| + /** |
| + * Starts the server. |
| + * |
| + * @return true if the server started successfully. |
| + */ |
| + boolean start(); |
| + |
| + /** |
| + * Shuts down the server. |
| + */ |
| + void shutdown(); |
| + |
| + /** |
| + * Return a URL that can be used by the test code to receive a successful response. |
| + * |
| + * @return the URL as a string. |
| + */ |
| + String getSuccessURL(); |
| + } |
| +} |