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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/dom_distiller/DistilledPagePrefsTest.java

Issue 426153006: Ensure Java DistilledPagePrefs observers can only be added once. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: styling Created 6 years, 4 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
« no previous file with comments | « no previous file | components/dom_distiller/android/java/src/org/chromium/components/dom_distiller/core/DistilledPagePrefs.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/javatests/src/org/chromium/chrome/browser/dom_distiller/DistilledPagePrefsTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/dom_distiller/DistilledPagePrefsTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/dom_distiller/DistilledPagePrefsTest.java
index cf39057a5c7a11356aad0bd2eb3b8f759c22c1d7..a5dc780ba3802e68cda435b999bed41a8804f7dd 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/dom_distiller/DistilledPagePrefsTest.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/dom_distiller/DistilledPagePrefsTest.java
@@ -92,6 +92,22 @@ public class DistilledPagePrefsTest extends ChromeShellTestBase {
mDistilledPagePrefs.removeObserver(testObserverTwo);
}
+ @SmallTest
+ @Feature({"DomDistiller"})
+ public void testRepeatedAddAndDeleteObserver() throws InterruptedException {
+ TestingObserver test = new TestingObserver();
+
+ // Should successfully add the observer the first time.
+ assertTrue(mDistilledPagePrefs.addObserver(test));
+ // Observer cannot be added again, should return false.
+ assertFalse(mDistilledPagePrefs.addObserver(test));
+
+ // Delete the observer the first time.
+ assertTrue(mDistilledPagePrefs.removeObserver(test));
+ // Observer cannot be deleted again, should return false.
+ assertFalse(mDistilledPagePrefs.removeObserver(test));
+ }
+
private static class TestingObserver implements DistilledPagePrefs.Observer {
private Theme mTheme;
« no previous file with comments | « no previous file | components/dom_distiller/android/java/src/org/chromium/components/dom_distiller/core/DistilledPagePrefs.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698