fix a bug in crash handling

currently, if a page load ended up in Java crash, the crash will be
intercepted by test harness and during the test tearDown step, the
test status file will be removed, and the harness would think all
sites have been loaded successfully

Change-Id: Ifc02d7f4b7e76c8e8aad06fff273f9d61060874d
diff --git a/tests/src/com/android/browser/PopularUrlsTest.java b/tests/src/com/android/browser/PopularUrlsTest.java
index 5e367be..3e7515f 100644
--- a/tests/src/com/android/browser/PopularUrlsTest.java
+++ b/tests/src/com/android/browser/PopularUrlsTest.java
@@ -305,12 +305,14 @@
         private int page;
         private String url;
         private boolean isRecovery;
+        private boolean allClear;
 
         private RunStatus(File file) throws IOException {
             mFile = file;
             FileReader input = null;
             BufferedReader reader = null;
             isRecovery = false;
+            allClear = false;
             iteration = 0;
             page = 0;
             try {
@@ -369,7 +371,9 @@
         }
 
         public void cleanUp() {
-            if (mFile.exists()) {
+            // only perform cleanup when allClear flag is set
+            // i.e. when the test was not interrupted by a Java crash
+            if (mFile.exists() && allClear) {
                 mFile.delete();
             }
         }
@@ -380,6 +384,7 @@
 
         public void incrementPage() {
             ++page;
+            allClear = true;
         }
 
         public void incrementIteration() {
@@ -400,6 +405,7 @@
 
         public void setUrl(String url) {
             this.url = url;
+            allClear = false;
         }
     }