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

Unified Diff: chrome/android/junit/src/org/chromium/chrome/browser/ChromeBackupAgentTest.java

Issue 1993243002: ⛲ Add presubmit to prevent SharedPreferences misuse. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add suppression for ContextUtils. Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/junit/src/org/chromium/chrome/browser/ChromeBackupAgentTest.java
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/ChromeBackupAgentTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/ChromeBackupAgentTest.java
index 20e1cb013f532fcd83b582f6498eed5792d52d2d..62853b63670ed4184200d8536f827d5e3cead0cb 100644
--- a/chrome/android/junit/src/org/chromium/chrome/browser/ChromeBackupAgentTest.java
+++ b/chrome/android/junit/src/org/chromium/chrome/browser/ChromeBackupAgentTest.java
@@ -9,9 +9,10 @@ import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat;
import android.content.SharedPreferences;
-import android.preference.PreferenceManager;
+import org.chromium.base.ContextUtils;
import org.chromium.testing.local.LocalRobolectricTestRunner;
+import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
@@ -32,10 +33,14 @@ public class ChromeBackupAgentTest {
}
}
+ @Before
+ public void setUp() throws Exception {
+ ContextUtils.initApplicationContextForTests(Robolectric.application);
+ }
+
@Test
public void testOnRestoreFinished() {
- SharedPreferences sharedPrefs =
- PreferenceManager.getDefaultSharedPreferences(Robolectric.application);
+ SharedPreferences sharedPrefs = ContextUtils.getAppSharedPreferences();
SharedPreferences.Editor editor = sharedPrefs.edit();
editor.putBoolean("crash_dump_upload", false);
editor.putString("google.services.username", "user1");

Powered by Google App Engine
This is Rietveld 408576698