public void testDisabledState() {
    resources.setSuggestedSitesResource(generateSites(3));

    Cursor c = new SuggestedSites(context).get(DEFAULT_LIMIT);
    assertEquals(3, c.getCount());
    c.close();

    // Disable suggested sites
    GoannaSharedPrefs.forApp(context)
        .edit()
        .putBoolean(GoannaPreferences.PREFS_SUGGESTED_SITES, false)
        .commit();

    c = new SuggestedSites(context).get(DEFAULT_LIMIT);
    assertNotNull(c);
    assertEquals(0, c.getCount());
    c.close();
  }
  public void testHiddenSites() {
    resources.setSuggestedSitesResource(generateSites(6));

    List<String> visibleUrls = new ArrayList<String>(3);
    visibleUrls.add("url3");
    visibleUrls.add("url4");
    visibleUrls.add("url5");

    List<String> hiddenUrls = new ArrayList<String>(3);
    hiddenUrls.add("url0");
    hiddenUrls.add("url1");
    hiddenUrls.add("url2");

    // Add mocked hidden sites to SharedPreferences.
    StringBuilder hiddenUrlBuilder = new StringBuilder();
    for (String s : hiddenUrls) {
      hiddenUrlBuilder.append(" ");
      hiddenUrlBuilder.append(Uri.encode(s));
    }

    final String hiddenPref = hiddenUrlBuilder.toString();
    GoannaSharedPrefs.forProfile(context)
        .edit()
        .putString(SuggestedSites.PREF_SUGGESTED_SITES_HIDDEN, hiddenPref)
        .commit();

    Cursor c = new SuggestedSites(context).get(DEFAULT_LIMIT);
    assertEquals(Math.min(3, DEFAULT_LIMIT), c.getCount());

    c.moveToPosition(-1);
    while (c.moveToNext()) {
      String url = c.getString(c.getColumnIndexOrThrow(BrowserContract.SuggestedSites.URL));
      assertFalse(hiddenUrls.contains(url));
      assertTrue(visibleUrls.contains(url));
    }

    c.close();
  }