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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/physicalweb/UrlManagerTest.java

Issue 1977633002: Simplify Physical Web UrlManager logic (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add VisibleForTesting 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
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/physicalweb/UrlManager.java ('k') | no next file » | 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/physicalweb/UrlManagerTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/physicalweb/UrlManagerTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/physicalweb/UrlManagerTest.java
index d448b7e64d8f23af1cee0ad0f03e5ee182a5a4f5..8a159cbcbdff48d544b07860103cf5a9ee913c7a 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/physicalweb/UrlManagerTest.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/physicalweb/UrlManagerTest.java
@@ -130,6 +130,22 @@ public class UrlManagerTest extends InstrumentationTestCase {
}
@SmallTest
+ public void testAddTwoUrlsMakesOneNotification() throws Exception {
+ addPwsResult1();
+ addPwsResult2();
+
+ // Adding one URL should fire a notification.
+ mUrlManager.addUrl(URL1);
+ getInstrumentation().waitForIdleSync();
+ assertEquals(1, mMockNotificationManagerProxy.getNotifications().size());
+
+ // Adding a second should not.
+ mMockNotificationManagerProxy.cancelAll();
+ mUrlManager.addUrl(URL2);
+ assertEquals(0, mMockNotificationManagerProxy.getNotifications().size());
+ }
+
+ @SmallTest
public void testAddUrlGarbageCollectsForSize() throws Exception {
// Add and remove 101 URLs, making sure one is clearly slightly older than the others.
mMockPwsClient.addPwsResults(new ArrayList<PwsResult>());
@@ -155,19 +171,19 @@ public class UrlManagerTest extends InstrumentationTestCase {
mMockPwsClient.addPwsResults(new ArrayList<PwsResult>());
mMockPwsClient.addPwsResults(new ArrayList<PwsResult>());
UrlInfo urlInfo1 = new UrlInfo(URL1, -1.0, 0);
+ UrlInfo urlInfo2 = new UrlInfo(URL2, -1.0, System.currentTimeMillis());
mUrlManager.addUrl(urlInfo1);
mUrlManager.removeUrl(urlInfo1);
+ mUrlManager.addUrl(urlInfo2);
+ mUrlManager.removeUrl(urlInfo2);
- // Make sure the URL is still in the cache.
- assertTrue(mUrlManager.containsInAnyCache(URL1));
-
- // Trigger garbage collection and make sure we no longer have the old URL in the cache.
- mUrlManager.addUrl(new UrlInfo(URL2, -1.0, System.currentTimeMillis()));
+ // Make sure only URL2 is still in the cache.
assertFalse(mUrlManager.containsInAnyCache(URL1));
+ assertTrue(mUrlManager.containsInAnyCache(URL2));
}
@SmallTest
- public void testAddTwiceWorks() throws Exception {
+ public void testAddUrlTwiceWorks() throws Exception {
// Add and remove an old URL twice and add new URL twice before removing.
// This should cover several issues involved with updating the cache queue.
mMockPwsClient.addPwsResults(new ArrayList<PwsResult>());
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/physicalweb/UrlManager.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698