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

Unified Diff: components/cronet/android/test/smoketests/src/org/chromium/net/smoke/TestSupport.java

Issue 2561803002: Cronet smoke tests (Closed)
Patch Set: Got rid of //base/android/proguard/chromium_apk.flags proguard config. Created 4 years 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
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..539fcc49b56934933db706151718c2f12c217d4e
--- /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;
mef 2016/12/20 20:17:45 I *think* this is wrong import order.
kapishnikov 2016/12/22 19:21:13 The ordering rules has changed recently. "org.chro
mef 2016/12/22 21:35:29 Acknowledged.
+
+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.
+ */
+public interface TestSupport {
+ enum Protocol {
+ HTTP1,
+ HTTP2,
+ 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(Context context, 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.
mef 2016/12/20 20:17:45 How does Closeable.close() differ from shutdown()?
kapishnikov 2016/12/22 19:21:13 Removed all close() methods.
+ */
+ 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();
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698