Bug 1071039 - Update TestSuggestedSites to check IDs. r=lucasr
authorBrian Nicholson <bnicholson@mozilla.com>
Fri, 26 Sep 2014 11:37:04 -0700
changeset 207481 b9fad08dc0be1091866edd039b40e80d379e970c
parent 207480 398a0d8a790fa3ce4b8d6493a5b720459c4242f3
child 207482 eafd15b593cfc305ebecaff75ab9262588faed32
push id27555
push userryanvm@gmail.com
push dateFri, 26 Sep 2014 20:30:28 +0000
treeherderautoland@4ff52be673f6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslucasr
bugs1071039
milestone35.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1071039 - Update TestSuggestedSites to check IDs. r=lucasr
mobile/android/tests/browser/junit3/src/TestSuggestedSites.java
--- a/mobile/android/tests/browser/junit3/src/TestSuggestedSites.java
+++ b/mobile/android/tests/browser/junit3/src/TestSuggestedSites.java
@@ -147,16 +147,17 @@ public class TestSuggestedSites extends 
     }
 
     private String generateSites(int n, String prefix) {
         JSONArray sites = new JSONArray();
 
         try {
             for (int i = 0; i < n; i++) {
                 JSONObject site = new JSONObject();
+                site.put("trackingid", prefix + "trackingId" + i);
                 site.put("url", prefix + "url" + i);
                 site.put("title", prefix + "title" + i);
                 site.put("imageurl", prefix + "imageUrl" + i);
                 site.put("bgcolor", prefix + "bgColor" + i);
 
                 sites.put(site);
             }
         } catch (Exception e) {
@@ -233,26 +234,41 @@ public class TestSuggestedSites extends 
 
         // Empty string = empty cursor
         checkCursorCount("", 0);
 
         // Invalid json string = empty cursor
         checkCursorCount("{ broken: }", 0);
     }
 
+    public void testNoTrackingId() {
+        String content = "[{ url: \"url\", title: \"title\", imageurl: \"imageurl\", bgcolor: \"bgcolor\" }]";
+        resources.setSuggestedSitesResource(content);
+
+        Cursor c = new SuggestedSites(context).get(DEFAULT_LIMIT);
+        assertEquals(1, c.getCount());
+        c.moveToNext();
+
+        String trackingId = c.getString(c.getColumnIndexOrThrow(BrowserContract.SuggestedSites.TRACKING_ID));
+        assertNull(trackingId);
+    }
+
     public void testCursorContent() {
         resources.setSuggestedSitesResource(generateSites(3));
 
         Cursor c = new SuggestedSites(context).get(DEFAULT_LIMIT);
         assertEquals(3, c.getCount());
 
         c.moveToPosition(-1);
         while (c.moveToNext()) {
             int position = c.getPosition();
 
+            String trackingId = c.getString(c.getColumnIndexOrThrow(BrowserContract.SuggestedSites.TRACKING_ID));
+            assertEquals("trackingId" + position, trackingId);
+
             String url = c.getString(c.getColumnIndexOrThrow(BrowserContract.SuggestedSites.URL));
             assertEquals("url" + position, url);
 
             String title = c.getString(c.getColumnIndexOrThrow(BrowserContract.SuggestedSites.TITLE));
             assertEquals("title" + position, title);
 
             String imageUrl = c.getString(c.getColumnIndexOrThrow(BrowserContract.SuggestedSites.IMAGEURL));
             assertEquals("imageUrl" + position, imageUrl);