Bug 1342105 - actually return if suggested site data is missing r=sebastian
authorAndrzej Hunt <ahunt@mozilla.com>
Thu, 23 Feb 2017 09:17:05 -0800
changeset 392049 093c7e787c9b1523b3364fdaac7a4481106002ca
parent 392048 578d891011c317df2bdfa315791f765394c9302c
child 392050 9f67d8a507479b15022bce420752b6d7c456a01e
push id7198
push userjlorenzo@mozilla.com
push dateTue, 18 Apr 2017 12:07:49 +0000
treeherdermozilla-beta@d57aa49c3948 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian
bugs1342105
milestone54.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 1342105 - actually return if suggested site data is missing r=sebastian MozReview-Commit-ID: GdshIa0e5Cj
mobile/android/base/java/org/mozilla/gecko/icons/loader/SuggestedSiteLoader.java
mobile/android/tests/background/junit4/src/org/mozilla/gecko/icons/loader/TestSuggestedSiteLoader.java
--- a/mobile/android/base/java/org/mozilla/gecko/icons/loader/SuggestedSiteLoader.java
+++ b/mobile/android/base/java/org/mozilla/gecko/icons/loader/SuggestedSiteLoader.java
@@ -64,16 +64,17 @@ public class SuggestedSiteLoader impleme
         final String iconLocation = suggestedSites.getImageUrlForUrl(siteURL);
         final String backgroundColorString = suggestedSites.getBackgroundColorForUrl(siteURL);
 
         if (iconLocation == null || backgroundColorString == null) {
             // There's little we can do if loading a bundled resource fails: this failure could
             // be caused by a distribution (as opposed to Gecko), so we should just shout loudly,
             // as opposed to crashing:
             Log.e(LOGTAG, "Unable to find tile data definitions for site:" + siteURL);
+            return null;
         }
 
         final int backgroundColor = Color.parseColor(backgroundColorString);
 
         try {
             final Bitmap foreground = loadBitmap(context, iconLocation);
 
             // Our supplied tile icons are bigger than the max favicon size. They are also not square,,
--- a/mobile/android/tests/background/junit4/src/org/mozilla/gecko/icons/loader/TestSuggestedSiteLoader.java
+++ b/mobile/android/tests/background/junit4/src/org/mozilla/gecko/icons/loader/TestSuggestedSiteLoader.java
@@ -125,16 +125,26 @@ public class TestSuggestedSiteLoader {
             final Bitmap out = response.getBitmap();
             final int expectedSize = context.getResources().getDimensionPixelSize(R.dimen.favicon_bg);
             Assert.assertEquals(expectedSize, out.getWidth());
             Assert.assertEquals(expectedSize, out.getWidth());
         }
     }
 
     @Test
+    public void testLoadingOtherIconFailsCleanly() throws IOException {
+        // Ensure that we return null (instead of crashing or providing wrong data) for a fake
+        // topsite.
+        final IconResponse response = loadIconForSite("http://www.arbitrary-not-bunled-site.notreal", false);
+
+        Assert.assertNull(response);
+    }
+
+
+    @Test
     public void testRespectsSkipDisk() throws IOException {
         for (final String site : DEFAULT_SUGGESTED_SITES_ICONS) {
             final IconResponse response = loadIconForSite(site, true);
 
             Assert.assertNull(response);
         }
     }
 }