Bug 1261494 - Add assertions & logging to resetTest for sanity checking. r=grisha
MozReview-Commit-ID: 2WDk0IJokL9
--- 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,