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

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

Issue 2557593003: Store device addresses in UrlInfo (Closed)
Patch Set: Created 4 years 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 unified diff | Download patch
« no previous file with comments | « chrome/android/javatests/src/org/chromium/chrome/browser/physicalweb/UrlInfoTest.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.physicalweb; 5 package org.chromium.chrome.browser.physicalweb;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.content.SharedPreferences; 8 import android.content.SharedPreferences;
9 import android.test.InstrumentationTestCase; 9 import android.test.InstrumentationTestCase;
10 import android.test.suitebuilder.annotation.SmallTest; 10 import android.test.suitebuilder.annotation.SmallTest;
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 mUrlManager.removeUrl(urlInfo1); 256 mUrlManager.removeUrl(urlInfo1);
257 mUrlManager.addUrl(urlInfo2); 257 mUrlManager.addUrl(urlInfo2);
258 mUrlManager.removeUrl(urlInfo2); 258 mUrlManager.removeUrl(urlInfo2);
259 259
260 // Make sure only URL2 is still in the cache. 260 // Make sure only URL2 is still in the cache.
261 assertFalse(mUrlManager.containsInAnyCache(URL1)); 261 assertFalse(mUrlManager.containsInAnyCache(URL1));
262 assertTrue(mUrlManager.containsInAnyCache(URL2)); 262 assertTrue(mUrlManager.containsInAnyCache(URL2));
263 } 263 }
264 264
265 @SmallTest 265 @SmallTest
266 public void testAddUrlUpdatesCache() throws Exception {
267 addEmptyPwsResult();
268 addEmptyPwsResult();
269
270 UrlInfo urlInfo = new UrlInfo(URL1);
271 mUrlManager.addUrl(urlInfo);
272 List<UrlInfo> urls = mUrlManager.getUrls(true);
273 assertEquals(1, urls.size());
274 assertEquals(urlInfo.getDistance(), urls.get(0).getDistance());
275 assertEquals(urlInfo.getDeviceAddress(), urls.get(0).getDeviceAddress()) ;
276 assertEquals(urlInfo.getScanTimestamp(), urls.get(0).getScanTimestamp()) ;
277
278 urlInfo = new UrlInfo(URL1)
279 .setDistance(100.0)
280 .setDeviceAddress("00:11:22:33:AA:BB");
281 mUrlManager.addUrl(urlInfo);
282 urls = mUrlManager.getUrls(true);
283 assertEquals(1, urls.size());
284 assertEquals(urlInfo.getDistance(), urls.get(0).getDistance());
285 assertEquals(urlInfo.getDeviceAddress(), urls.get(0).getDeviceAddress()) ;
286 assertEquals(urlInfo.getScanTimestamp(), urls.get(0).getScanTimestamp()) ;
287 }
288
289 @SmallTest
266 @RetryOnFailure 290 @RetryOnFailure
267 public void testAddUrlTwiceWorks() throws Exception { 291 public void testAddUrlTwiceWorks() throws Exception {
268 // Add and remove an old URL twice and add new URL twice before removing . 292 // Add and remove an old URL twice and add new URL twice before removing .
269 // This should cover several issues involved with updating the cache que ue. 293 // This should cover several issues involved with updating the cache que ue.
270 addEmptyPwsResult(); 294 addEmptyPwsResult();
271 addEmptyPwsResult(); 295 addEmptyPwsResult();
272 addEmptyPwsResult(); 296 addEmptyPwsResult();
273 addEmptyPwsResult(); 297 addEmptyPwsResult();
274 UrlInfo urlInfo1 = new UrlInfo(URL1, -1.0, 0); 298 UrlInfo urlInfo1 = new UrlInfo(URL1, -1.0, 0);
275 UrlInfo urlInfo2 = new UrlInfo(URL2, -1.0, System.currentTimeMillis()); 299 UrlInfo urlInfo2 = new UrlInfo(URL2, -1.0, System.currentTimeMillis());
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 public boolean isSatisfied() { 486 public boolean isSatisfied() {
463 return mSharedPreferences.contains(UrlManager.getVersionKey()) 487 return mSharedPreferences.contains(UrlManager.getVersionKey())
464 && !mSharedPreferences.contains("physicalweb_resolved_ur ls"); 488 && !mSharedPreferences.contains("physicalweb_resolved_ur ls");
465 } 489 }
466 }, 5000, CriteriaHelper.DEFAULT_POLLING_INTERVAL); 490 }, 5000, CriteriaHelper.DEFAULT_POLLING_INTERVAL);
467 491
468 assertEquals(UrlManager.getVersion(), 492 assertEquals(UrlManager.getVersion(),
469 mSharedPreferences.getInt(UrlManager.getVersionKey(), 0)); 493 mSharedPreferences.getInt(UrlManager.getVersionKey(), 0));
470 } 494 }
471 } 495 }
OLDNEW
« no previous file with comments | « chrome/android/javatests/src/org/chromium/chrome/browser/physicalweb/UrlInfoTest.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698