| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.crash; | 5 package org.chromium.chrome.browser.crash; |
| 6 | 6 |
| 7 import android.test.InstrumentationTestCase; | 7 import android.test.InstrumentationTestCase; |
| 8 import android.util.Log; | 8 |
| 9 import org.chromium.base.Log; |
| 9 | 10 |
| 10 import java.io.File; | 11 import java.io.File; |
| 11 import java.io.FileWriter; | 12 import java.io.FileWriter; |
| 12 import java.io.IOException; | 13 import java.io.IOException; |
| 13 import java.io.PrintWriter; | 14 import java.io.PrintWriter; |
| 14 import java.util.Arrays; | 15 import java.util.Arrays; |
| 15 import java.util.List; | 16 import java.util.List; |
| 16 | 17 |
| 17 /** | 18 /** |
| 18 * Base case for Crash upload related tests. | 19 * Base case for Crash upload related tests. |
| 19 */ | 20 */ |
| 20 public class CrashTestCase extends InstrumentationTestCase { | 21 public class CrashTestCase extends InstrumentationTestCase { |
| 21 private static final String TAG = "CrashTestCase"; | 22 private static final String TAG = "CrashTestCase"; |
| 22 | 23 |
| 23 protected File mCrashDir; | 24 protected File mCrashDir; |
| 24 protected File mCacheDir; | 25 protected File mCacheDir; |
| 25 | 26 |
| 26 @Override | 27 @Override |
| 27 protected void setUp() throws Exception { | 28 protected void setUp() throws Exception { |
| 28 super.setUp(); | 29 super.setUp(); |
| 29 mCacheDir = getInstrumentation().getTargetContext().getCacheDir(); | 30 mCacheDir = getInstrumentation().getTargetContext().getCacheDir(); |
| 30 mCrashDir = new File( | 31 mCrashDir = new File(mCacheDir, CrashFileManager.CRASH_DUMP_DIR); |
| 31 mCacheDir, | |
| 32 CrashFileManager.CRASH_DUMP_DIR); | |
| 33 if (!mCrashDir.isDirectory() && !mCrashDir.mkdir()) { | 32 if (!mCrashDir.isDirectory() && !mCrashDir.mkdir()) { |
| 34 throw new Exception("Unable to create directory: " + mCrashDir.getAb
solutePath()); | 33 throw new Exception("Unable to create directory: " + mCrashDir.getAb
solutePath()); |
| 35 } | 34 } |
| 36 } | 35 } |
| 37 | 36 |
| 38 @Override | 37 @Override |
| 39 protected void tearDown() throws Exception { | 38 protected void tearDown() throws Exception { |
| 40 super.tearDown(); | 39 super.tearDown(); |
| 41 List<File> crashFiles = Arrays.asList(mCrashDir.listFiles()); | 40 List<File> crashFiles = Arrays.asList(mCrashDir.listFiles()); |
| 42 for (File crashFile : crashFiles) { | 41 for (File crashFile : crashFiles) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 73 } | 72 } |
| 74 minidumpWriter.println(boundary + "--"); | 73 minidumpWriter.println(boundary + "--"); |
| 75 minidumpWriter.flush(); | 74 minidumpWriter.flush(); |
| 76 } finally { | 75 } finally { |
| 77 if (minidumpWriter != null) { | 76 if (minidumpWriter != null) { |
| 78 minidumpWriter.close(); | 77 minidumpWriter.close(); |
| 79 } | 78 } |
| 80 } | 79 } |
| 81 } | 80 } |
| 82 } | 81 } |
| OLD | NEW |