Bug 1261494 - Add assertions & logging to resetTest for sanity checking. r=grisha draft
authorMichael Comella <michael.l.comella@gmail.com>
Fri, 03 Jun 2016 14:55:03 -0700
changeset 375317 5925ba9bbe18d246c89b84ad3f5e6a6436905112
parent 375316 075dd12ae1572ad24c7e104aadefd56695556be6
child 375318 c5ed93eccba83d9005df3a21743e5d5eae00a8e3
push id20227
push usermichael.l.comella@gmail.com
push dateFri, 03 Jun 2016 21:58:13 +0000
reviewersgrisha
bugs1261494
milestone49.0a1
Bug 1261494 - Add assertions & logging to resetTest for sanity checking. r=grisha MozReview-Commit-ID: 2WDk0IJokL9
mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testUnifiedTelemetryClientId.java
--- a/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testUnifiedTelemetryClientId.java
+++ b/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testUnifiedTelemetryClientId.java
@@ -1,16 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.tests;
 
 import static org.mozilla.gecko.tests.helpers.AssertionHelper.*;
 
+import android.util.Log;
 import org.json.JSONException;
 import org.json.JSONObject;
 import org.mozilla.gecko.GeckoProfile;
 
 import java.io.File;
 import java.io.IOException;
 import java.util.UUID;
 
@@ -18,40 +19,51 @@ public class testUnifiedTelemetryClientI
     private static final String TEST_JS = "testUnifiedTelemetryClientId.js";
 
     private static final String CLIENT_ID_PATH = "datareporting/state.json";
     private static final String FHR_DIR_PATH = "healthreport/";
     private static final String FHR_CLIENT_ID_PATH = FHR_DIR_PATH + "state.json";
 
     private GeckoProfile profile;
     private File profileDir;
+    private File[] filesToDeleteOnReset;
 
     public void setUp() throws Exception {
         super.setUp();
         profile = getTestProfile();
         profileDir = profile.getDir(); // Assumes getDir is tested.
+        filesToDeleteOnReset = new File[] {
+                getClientIdFile(),
+                getFHRClientIdFile(),
+                getFHRClientIdParentDir(),
+        };
 
         // In local testing, it's possible to ^C out of the harness and not have tearDown called,
         // hence reset. We can't clear the cache because Gecko is not running yet.
         resetTest(false);
     }
 
     public void tearDown() throws Exception {
         // Don't clear cache because who knows what state Gecko is in.
         resetTest(false);
         super.tearDown();
     }
 
     private void resetTest(final boolean resetJSCache) {
+        Log.d(LOGTAG, "resetTest: begin");
+
         if (resetJSCache) {
             resetJSCache();
         }
-        getClientIdFile().delete();
-        getFHRClientIdFile().delete();
-        getFHRClientIdParentDir().delete();
+        for (final File file : filesToDeleteOnReset) {
+            file.delete();
+            assertFalse("Deleted file in reset does not exist", file.exists());
+        }
+
+        Log.d(LOGTAG, "resetTest: end");
     }
 
     public void testUnifiedTelemetryClientId() throws Exception {
         blockForReadyAndLoadJS(TEST_JS);
         resetJSCache(); // Must be called after Gecko is loaded.
         fAssertTrue("Profile directory exists", profileDir.exists());
 
         // TODO: If these tests weren't so expensive to run in automation,