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

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

Issue 2561803002: Cronet smoke tests (Closed)
Patch Set: Moved to android.support.test.filters & added support for network-security-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/NativeCronetTestCase.java
diff --git a/components/cronet/android/test/smoketests/src/org/chromium/net/smoke/NativeCronetTestCase.java b/components/cronet/android/test/smoketests/src/org/chromium/net/smoke/NativeCronetTestCase.java
new file mode 100644
index 0000000000000000000000000000000000000000..6fcb18d35bfa0366e6ff5f256a2f35050af5975c
--- /dev/null
+++ b/components/cronet/android/test/smoketests/src/org/chromium/net/smoke/NativeCronetTestCase.java
@@ -0,0 +1,55 @@
+// 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 org.chromium.base.ContextUtils;
+import org.chromium.base.PathUtils;
+
+import java.io.File;
+
+/**
+ * Test base class for testing native Engine implementation. This class can import classes from the
+ * org.chromium.base package.
+ */
+public class NativeCronetTestCase extends CronetSmokeTestCase {
+ private static final String PRIVATE_DATA_DIRECTORY_SUFFIX = "cronet_test";
+ private static final String LOGFILE_NAME = "cronet-netlog.json";
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ ContextUtils.initApplicationContext(getContext().getApplicationContext());
+ PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX);
+ mTestSupport.loadTestNativeLibrary();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ stopAndSaveNetLog();
+ super.tearDown();
+ }
+
+ @Override
+ protected void initCronetEngine() {
+ super.initCronetEngine();
+ assertNativeEngine(mCronetEngine);
+ startNetLog();
+ }
+
+ private void startNetLog() {
+ if (mCronetEngine != null) {
+ mCronetEngine.startNetLogToFile(
+ PathUtils.getDataDirectory() + "/" + LOGFILE_NAME, false);
+ }
+ }
+
+ private void stopAndSaveNetLog() {
+ if (mCronetEngine == null) return;
+ mCronetEngine.stopNetLog();
+ File netLogFile = new File(PathUtils.getDataDirectory(), LOGFILE_NAME);
+ if (!netLogFile.exists()) return;
+ mTestSupport.processNetLog(getContext(), netLogFile);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698