@After public void tearDown() throws Exception { // some tests below use FakeHttp.addPendingHttpResponse();. We should clear them after every // test. FakeHttp.clearPendingHttpResponses(); // reset the static flags in Logger that prevent accidental double sending of the // persistent file contents Field f1 = LogPersister.class.getDeclaredField("sendingLogs"); f1.setAccessible(true); f1.set(null, false); Field f2 = LogPersister.class.getDeclaredField("sendingAnalyticsLogs"); f2.setAccessible(true); f2.set(null, false); }
@Before public void reset() throws Exception { // reset Logger defaults: LogPersister.unsetContext(); // clear all shared prefs SharedPreferences sharedPreferences = RuntimeEnvironment.application.getSharedPreferences( LogPersister.SHARED_PREF_KEY, Context.MODE_PRIVATE); sharedPreferences.edit().clear().commit(); System.setProperty("http.agent", "Test user agent"); PackageManager pm = activity.getPackageManager(); PackageInfo pi = pm.getPackageInfo(activity.getPackageName(), PackageManager.GET_SIGNATURES); pi.signatures = new Signature[] {new Signature("1234567890abcdef")}; File file = new File(activity.getFilesDir(), FILE_NAME0); file.delete(); file = new File(activity.getFilesDir(), FILE_NAME1); file.delete(); file = new File(activity.getFilesDir(), FILE_NAME0 + ".send"); file.delete(); file = new File(activity.getFilesDir(), FILE_NAME1 + ".send"); file.delete(); file = new File(activity.getFilesDir(), ANALYTICS_FILE_NAME0); file.delete(); file = new File(activity.getFilesDir(), ANALYTICS_FILE_NAME1); file.delete(); file = new File(activity.getFilesDir(), ANALYTICS_FILE_NAME0 + ".send"); file.delete(); file = new File(activity.getFilesDir(), ANALYTICS_FILE_NAME1 + ".send"); file.delete(); // some tests below use FakeHttp.addPendingHttpResponse();. We should clear them after every // test. FakeHttp.clearPendingHttpResponses(); // reset the static flags in Logger that prevent accidental double sending of the // persistent file contents Field f1 = LogPersister.class.getDeclaredField("sendingLogs"); f1.setAccessible(true); f1.set(null, false); Field f2 = LogPersister.class.getDeclaredField("sendingAnalyticsLogs"); f2.setAccessible(true); f2.set(null, false); Logger.setLogPersister(new LogPersisterDelegate()); }