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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/crash/CrashTestCase.java

Issue 1141283003: Upstream oodles of Chrome for Android code into Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: final patch? Created 5 years, 7 months 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: chrome/android/javatests/src/org/chromium/chrome/browser/crash/CrashTestCase.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/crash/CrashTestCase.java b/chrome/android/javatests/src/org/chromium/chrome/browser/crash/CrashTestCase.java
new file mode 100644
index 0000000000000000000000000000000000000000..b1595c2012912e41037134a55cee0f69c9c16f09
--- /dev/null
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/crash/CrashTestCase.java
@@ -0,0 +1,73 @@
+// Copyright 2015 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.crash;
+
+import android.test.InstrumentationTestCase;
+import android.util.Log;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Base case for Crash upload related tests.
+ */
+public class CrashTestCase extends InstrumentationTestCase {
+ private static final String TAG = "CrashTestCase";
+
+ protected File mCrashDir;
+ protected File mCacheDir;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ mCacheDir = getInstrumentation().getTargetContext().getCacheDir();
+ mCrashDir = new File(
+ mCacheDir,
+ CrashFileManager.CRASH_DUMP_DIR);
+ if (!mCrashDir.isDirectory() && !mCrashDir.mkdir()) {
+ throw new Exception("Unable to create directory: " + mCrashDir.getAbsolutePath());
+ }
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ List<File> crashFiles = Arrays.asList(mCrashDir.listFiles());
+ for (File crashFile : crashFiles) {
+ if (!crashFile.delete()) {
+ Log.e(TAG, "Unable to delete: " + crashFile.getAbsolutePath());
+ }
+ }
+ if (!mCrashDir.delete()) {
+ Log.e(TAG, "Unable to delete: " + mCrashDir.getAbsolutePath());
+ }
+ }
+
+ protected static void setUpMinidumpFile(File file, String boundary) throws IOException {
+ PrintWriter miniDumpWriter = null;
+ try {
+ miniDumpWriter = new PrintWriter(new FileWriter(file));
+ miniDumpWriter.println("--" + boundary);
+ miniDumpWriter.println("Content-Disposition: form-data; name=\"prod\"");
+ miniDumpWriter.println();
+ miniDumpWriter.println("Chrome_Android");
+ miniDumpWriter.println("--" + boundary);
+ miniDumpWriter.println("Content-Disposition: form-data; name=\"ver\"");
+ miniDumpWriter.println();
+ miniDumpWriter.println("1");
+ miniDumpWriter.println(boundary + "--");
+ miniDumpWriter.flush();
+ miniDumpWriter.close();
+ } finally {
+ if (miniDumpWriter != null) {
+ miniDumpWriter.close();
+ }
+ }
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698