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

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

Issue 2416963005: Fix chrome_java FindBugs errors found when switching to n sdk. (Closed)
Patch Set: rebase Created 4 years, 2 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 unified diff | Download patch
OLDNEW
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 import android.util.Log;
9 9
10 import java.io.File; 10 import java.io.File;
11 import java.io.FileWriter; 11 import java.io.FileWriter;
12 import java.io.IOException; 12 import java.io.IOException;
13 import java.io.PrintWriter; 13 import java.io.PrintWriter;
14 import java.util.Arrays;
15 import java.util.List;
16 14
17 /** 15 /**
18 * Base case for Crash upload related tests. 16 * Base case for Crash upload related tests.
19 */ 17 */
20 public class CrashTestCase extends InstrumentationTestCase { 18 public class CrashTestCase extends InstrumentationTestCase {
21 private static final String TAG = "CrashTestCase"; 19 private static final String TAG = "CrashTestCase";
22 20
23 protected File mCrashDir; 21 protected File mCrashDir;
24 protected File mCacheDir; 22 protected File mCacheDir;
25 23
26 @Override 24 @Override
27 protected void setUp() throws Exception { 25 protected void setUp() throws Exception {
28 super.setUp(); 26 super.setUp();
29 mCacheDir = getInstrumentation().getTargetContext().getCacheDir(); 27 mCacheDir = getInstrumentation().getTargetContext().getCacheDir();
30 mCrashDir = new File( 28 mCrashDir = new File(
31 mCacheDir, 29 mCacheDir,
32 CrashFileManager.CRASH_DUMP_DIR); 30 CrashFileManager.CRASH_DUMP_DIR);
33 if (!mCrashDir.isDirectory() && !mCrashDir.mkdir()) { 31 if (!mCrashDir.isDirectory() && !mCrashDir.mkdir()) {
34 throw new Exception("Unable to create directory: " + mCrashDir.getAb solutePath()); 32 throw new Exception("Unable to create directory: " + mCrashDir.getAb solutePath());
35 } 33 }
36 } 34 }
37 35
38 @Override 36 @Override
39 protected void tearDown() throws Exception { 37 protected void tearDown() throws Exception {
40 super.tearDown(); 38 super.tearDown();
41 List<File> crashFiles = Arrays.asList(mCrashDir.listFiles()); 39 File[] crashFiles = mCrashDir.listFiles();
40 if (crashFiles == null) {
41 return;
Ilya Sherman 2016/10/15 00:02:53 Please log an error for this case.
42 }
43
42 for (File crashFile : crashFiles) { 44 for (File crashFile : crashFiles) {
43 if (!crashFile.delete()) { 45 if (!crashFile.delete()) {
44 Log.e(TAG, "Unable to delete: " + crashFile.getAbsolutePath()); 46 Log.e(TAG, "Unable to delete: " + crashFile.getAbsolutePath());
45 } 47 }
46 } 48 }
47 if (!mCrashDir.delete()) { 49 if (!mCrashDir.delete()) {
48 Log.e(TAG, "Unable to delete: " + mCrashDir.getAbsolutePath()); 50 Log.e(TAG, "Unable to delete: " + mCrashDir.getAbsolutePath());
49 } 51 }
50 } 52 }
51 53
(...skipping 21 matching lines...) Expand all
73 } 75 }
74 minidumpWriter.println(boundary + "--"); 76 minidumpWriter.println(boundary + "--");
75 minidumpWriter.flush(); 77 minidumpWriter.flush();
76 } finally { 78 } finally {
77 if (minidumpWriter != null) { 79 if (minidumpWriter != null) {
78 minidumpWriter.close(); 80 minidumpWriter.close();
79 } 81 }
80 } 82 }
81 } 83 }
82 } 84 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698